semiotic 3.4.1 → 3.5.0

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 (164) hide show
  1. package/CLAUDE.md +114 -9
  2. package/README.md +45 -4
  3. package/ai/behaviorContracts.cjs +311 -0
  4. package/ai/chartSuggestions.cjs +291 -0
  5. package/ai/cli.js +255 -30
  6. package/ai/componentMetadata.cjs +107 -0
  7. package/ai/dist/mcp-server.js +907 -227
  8. package/ai/schema.json +3954 -2537
  9. package/ai/system-prompt.md +23 -4
  10. package/dist/components/LinkedCharts.d.ts +5 -1
  11. package/dist/components/Tooltip/Tooltip.d.ts +1 -1
  12. package/dist/components/charts/custom/NetworkCustomChart.d.ts +64 -0
  13. package/dist/components/charts/custom/OrdinalCustomChart.d.ts +71 -0
  14. package/dist/components/charts/custom/XYCustomChart.d.ts +59 -0
  15. package/dist/components/charts/geo/ChoroplethMap.d.ts +93 -2
  16. package/dist/components/charts/geo/DistanceCartogram.d.ts +51 -4
  17. package/dist/components/charts/geo/FlowMap.d.ts +55 -0
  18. package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +53 -0
  19. package/dist/components/charts/index.d.ts +6 -0
  20. package/dist/components/charts/network/ChordDiagram.d.ts +34 -2
  21. package/dist/components/charts/network/CirclePack.d.ts +36 -1
  22. package/dist/components/charts/network/ForceDirectedGraph.d.ts +130 -2
  23. package/dist/components/charts/network/OrbitDiagram.d.ts +37 -0
  24. package/dist/components/charts/network/SankeyDiagram.d.ts +51 -2
  25. package/dist/components/charts/network/TreeDiagram.d.ts +37 -2
  26. package/dist/components/charts/network/Treemap.d.ts +36 -2
  27. package/dist/components/charts/ordinal/BarChart.d.ts +111 -1
  28. package/dist/components/charts/ordinal/BoxPlot.d.ts +31 -0
  29. package/dist/components/charts/ordinal/DonutChart.d.ts +36 -0
  30. package/dist/components/charts/ordinal/DotPlot.d.ts +31 -0
  31. package/dist/components/charts/ordinal/FunnelChart.d.ts +40 -0
  32. package/dist/components/charts/ordinal/GaugeChart.d.ts +45 -0
  33. package/dist/components/charts/ordinal/GroupedBarChart.d.ts +38 -0
  34. package/dist/components/charts/ordinal/Histogram.d.ts +95 -0
  35. package/dist/components/charts/ordinal/LikertChart.d.ts +42 -0
  36. package/dist/components/charts/ordinal/PieChart.d.ts +90 -1
  37. package/dist/components/charts/ordinal/RidgelinePlot.d.ts +27 -0
  38. package/dist/components/charts/ordinal/StackedBarChart.d.ts +38 -0
  39. package/dist/components/charts/ordinal/SwarmPlot.d.ts +36 -0
  40. package/dist/components/charts/ordinal/SwimlaneChart.d.ts +60 -0
  41. package/dist/components/charts/ordinal/ViolinPlot.d.ts +32 -0
  42. package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +22 -4
  43. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +5 -2
  44. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +24 -3
  45. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +12 -0
  46. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +14 -0
  47. package/dist/components/charts/realtime/defaultRealtimeTooltip.d.ts +43 -0
  48. package/dist/components/charts/realtime/resolveWindowSize.d.ts +26 -0
  49. package/dist/components/charts/shared/chartSpecs.d.ts +91 -0
  50. package/dist/components/charts/shared/colorPalettes.d.ts +62 -0
  51. package/dist/components/charts/shared/colorUtils.d.ts +9 -10
  52. package/dist/components/charts/shared/numberFormat.d.ts +58 -0
  53. package/dist/components/charts/shared/sparseArray.d.ts +27 -0
  54. package/dist/components/charts/shared/streamPropsHelpers.d.ts +113 -0
  55. package/dist/components/charts/shared/timeFormat.d.ts +60 -0
  56. package/dist/components/charts/shared/useChartSetup.d.ts +8 -0
  57. package/dist/components/charts/shared/useCustomChartSetup.d.ts +84 -0
  58. package/dist/components/charts/shared/useFrameImperativeHandle.d.ts +28 -0
  59. package/dist/components/charts/shared/useOrdinalStreaming.d.ts +6 -19
  60. package/dist/components/charts/shared/useStreamingLegend.d.ts +27 -11
  61. package/dist/components/charts/shared/validateProps.d.ts +2 -2
  62. package/dist/components/charts/shared/validationMap.d.ts +2 -1
  63. package/dist/components/charts/shared/withChartWrapper.d.ts +13 -4
  64. package/dist/components/charts/xy/AreaChart.d.ts +30 -1
  65. package/dist/components/charts/xy/CandlestickChart.d.ts +33 -6
  66. package/dist/components/charts/xy/ConnectedScatterplot.d.ts +24 -0
  67. package/dist/components/charts/xy/MinimapChart.d.ts +51 -0
  68. package/dist/components/charts/xy/MultiAxisLineChart.d.ts +27 -0
  69. package/dist/components/charts/xy/QuadrantChart.d.ts +21 -0
  70. package/dist/components/charts/xy/Scatterplot.d.ts +34 -2
  71. package/dist/components/charts/xy/ScatterplotMatrix.d.ts +16 -0
  72. package/dist/components/charts/xy/StackedAreaChart.d.ts +49 -1
  73. package/dist/components/export/selectionSerializer.d.ts +1 -1
  74. package/dist/components/realtime/types.d.ts +7 -9
  75. package/dist/components/recipes/bullet.d.ts +86 -0
  76. package/dist/components/recipes/calendar.d.ts +43 -0
  77. package/dist/components/recipes/dagre.d.ts +56 -0
  78. package/dist/components/recipes/flextree.d.ts +55 -0
  79. package/dist/components/recipes/marimekko.d.ts +55 -0
  80. package/dist/components/recipes/parallelCoordinates.d.ts +97 -0
  81. package/dist/components/recipes/recipeUtils.d.ts +27 -0
  82. package/dist/components/recipes/waffle.d.ts +46 -0
  83. package/dist/components/semiotic-ai.d.ts +4 -0
  84. package/dist/components/semiotic-network.d.ts +3 -0
  85. package/dist/components/semiotic-ordinal.d.ts +3 -0
  86. package/dist/components/semiotic-recipes.d.ts +24 -0
  87. package/dist/components/semiotic-xy.d.ts +3 -0
  88. package/dist/components/semiotic.d.ts +2 -2
  89. package/dist/components/server/renderToStaticSVG.d.ts +8 -2
  90. package/dist/components/server/serverChartConfigs.d.ts +47 -1
  91. package/dist/components/server/staticAnnotations.d.ts +6 -0
  92. package/dist/components/store/ObservationStore.d.ts +1 -3
  93. package/dist/components/store/SelectionStore.d.ts +2 -4
  94. package/dist/components/store/ThemeStore.d.ts +4 -4
  95. package/dist/components/store/TooltipStore.d.ts +5 -3
  96. package/dist/components/store/createStore.d.ts +4 -2
  97. package/dist/components/store/useSelection.d.ts +7 -4
  98. package/dist/components/stream/CanvasHitTester.d.ts +10 -8
  99. package/dist/components/stream/DataSourceAdapter.d.ts +9 -0
  100. package/dist/components/stream/GeoPipelineStore.d.ts +9 -0
  101. package/dist/components/stream/GeoTileRenderer.d.ts +14 -0
  102. package/dist/components/stream/NetworkPipelineStore.d.ts +25 -0
  103. package/dist/components/stream/NetworkSVGOverlay.d.ts +18 -12
  104. package/dist/components/stream/OrdinalPipelineStore.d.ts +12 -0
  105. package/dist/components/stream/PipelineStore.d.ts +51 -0
  106. package/dist/components/stream/SVGOverlay.d.ts +12 -0
  107. package/dist/components/stream/SceneGraph.d.ts +15 -1
  108. package/dist/components/stream/SceneToSVG.d.ts +1 -1
  109. package/dist/components/stream/categoryDomain.d.ts +4 -0
  110. package/dist/components/stream/composeOverlays.d.ts +15 -0
  111. package/dist/components/stream/customLayout.d.ts +76 -0
  112. package/dist/components/stream/customLayoutPalette.d.ts +29 -0
  113. package/dist/components/stream/geoTypes.d.ts +33 -8
  114. package/dist/components/stream/hoverUtils.d.ts +4 -10
  115. package/dist/components/stream/keyboardNav.d.ts +18 -6
  116. package/dist/components/stream/networkCustomLayout.d.ts +67 -0
  117. package/dist/components/stream/networkTypes.d.ts +87 -21
  118. package/dist/components/stream/ordinalCustomLayout.d.ts +84 -0
  119. package/dist/components/stream/ordinalTypes.d.ts +47 -13
  120. package/dist/components/stream/renderers/barFunnelCanvasRenderer.d.ts +9 -1
  121. package/dist/components/stream/renderers/canvasRenderHelpers.d.ts +92 -0
  122. package/dist/components/stream/sampleCurvePath.d.ts +9 -0
  123. package/dist/components/stream/types.d.ts +57 -10
  124. package/dist/components/stream/useHydration.d.ts +89 -0
  125. package/dist/components/stream/useStableShallow.d.ts +1 -0
  126. package/dist/components/stream/xySceneBuilders/types.d.ts +4 -0
  127. package/dist/geo.min.js +2 -1
  128. package/dist/geo.module.min.js +2 -1
  129. package/dist/network.min.js +2 -1
  130. package/dist/network.module.min.js +2 -1
  131. package/dist/ordinal.min.js +2 -1
  132. package/dist/ordinal.module.min.js +2 -1
  133. package/dist/realtime.min.js +2 -1
  134. package/dist/realtime.module.min.js +2 -1
  135. package/dist/semiotic-ai.d.ts +69 -65
  136. package/dist/semiotic-ai.min.js +2 -1
  137. package/dist/semiotic-ai.module.min.js +2 -1
  138. package/dist/semiotic-data.d.ts +4 -4
  139. package/dist/semiotic-geo.d.ts +15 -15
  140. package/dist/semiotic-network.d.ts +19 -16
  141. package/dist/semiotic-ordinal.d.ts +31 -28
  142. package/dist/semiotic-realtime.d.ts +17 -17
  143. package/dist/semiotic-recipes.d.ts +24 -0
  144. package/dist/semiotic-recipes.min.js +1 -0
  145. package/dist/semiotic-recipes.module.min.js +1 -0
  146. package/dist/semiotic-server.d.ts +6 -6
  147. package/dist/semiotic-statisticalOverlays-C3DsOgr_.js +1 -0
  148. package/dist/semiotic-themes.d.ts +3 -3
  149. package/dist/semiotic-themes.min.js +2 -1
  150. package/dist/semiotic-themes.module.min.js +2 -1
  151. package/dist/semiotic-utils.d.ts +23 -23
  152. package/dist/semiotic-utils.min.js +2 -1
  153. package/dist/semiotic-utils.module.min.js +2 -1
  154. package/dist/semiotic-xy.d.ts +27 -24
  155. package/dist/semiotic.d.ts +63 -63
  156. package/dist/semiotic.min.js +2 -1
  157. package/dist/semiotic.module.min.js +2 -1
  158. package/dist/server.min.js +1 -1
  159. package/dist/server.module.min.js +1 -1
  160. package/dist/test-utils/canvasMock.d.ts +34 -5
  161. package/dist/xy.min.js +2 -1
  162. package/dist/xy.module.min.js +2 -1
  163. package/package.json +40 -20
  164. package/dist/semiotic-statisticalOverlays-Ckd_jM8z.js +0 -1
@@ -1 +1,2 @@
1
- "use strict";const t=require("react/jsx-runtime"),e=require("react"),n=require("d3-selection"),i=require("d3-brush"),o=require("d3-scale"),r=require("d3-quadtree"),s=require("d3-scale-chromatic"),l=require("d3-array"),a=require("d3-hierarchy"),c=require("d3-shape"),u=require("regression"),d=require("d3-interpolate"),h=require("d3-force"),f=require("d3-chord");function g(t){return t&&t.__esModule?t:{default:t}}function y(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const n in t)if("default"!==n){const i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}return e.default=t,Object.freeze(e)}const p=y(e),v=g(u);function m(t,e){let n=0,i=e.length-1;for(;i>n;){const o=n+i+1>>1;e[o]>t?i=o-1:n=o}return e[n]}function x(t,e){let n=0,i=e.length-1;for(;i>n;){const o=n+i>>1;t>e[o]?n=o+1:i=o}return e[n]}function b({width:o,height:r,totalWidth:s,totalHeight:l,margin:a,dimension:c,scales:u,onBrush:d,binSize:h,snap:f,binBoundaries:g,snapDuring:y,streaming:p}){const v=e.useRef(null),b=e.useRef(null),k=e.useRef(d);k.current=d;const w=e.useRef(u);w.current=u;const A=e.useMemo(()=>g?[...g].sort((t,e)=>t-e):void 0,[g]),S=e.useRef(A);S.current=A;const M=e.useRef(!1),_=e.useRef(null);return e.useEffect(()=>{if(!v.current)return;const t=n.select(v.current).select(".brush-g"),e="x"===c?i.brushX():"y"===c?i.brushY():i.brush();return e.extent([[0,0],[o,r]]),e.on("brush end",n=>{if(M.current)return;const i=w.current;if(!i)return;if(!n.selection)return _.current=null,void k.current(null);let s,l;if("x"===c){const[t,e]=n.selection;s=[i.x.invert(t),i.x.invert(e)],l=[i.y.invert(r),i.y.invert(0)]}else if("y"===c){const[t,e]=n.selection;s=[i.x.invert(0),i.x.invert(o)],l=[i.y.invert(e),i.y.invert(t)]}else{const[[t,e],[o,r]]=n.selection;s=[i.x.invert(t),i.x.invert(o)],l=[i.y.invert(r),i.y.invert(e)]}if("bin"===f&&"y"!==c&&("end"===n.type||"brush"===n.type&&y)){const o=S.current;o&&o.length>0?s=function(t,e){return 0===e.length?t:[m(t[0],e),x(t[1],e)]}(s,o):h&&h>0&&(s=[Math.floor(s[0]/h)*h,Math.ceil(s[1]/h)*h]);const r=i.x(s[0]),l=i.x(s[1]);if(M.current=!0,"x"===c)t.call(e.move,[r,l]);else if("xy"===c){const i=n.selection;t.call(e.move,[[r,i[0][1]],[l,i[1][1]]])}M.current=!1}const a={x:s,y:l};_.current=a,k.current(a)}),t.call(e),b.current=e,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{e.on("brush end",null),b.current=null}},[o,r,c,f,h,y]),e.useEffect(()=>{if(!(p&&u&&b.current&&_.current))return;if(!v.current)return;if("y"===c)return;const t=_.current,e=u.x.domain()[0],i=n.select(v.current).select(".brush-g");if(e>=t.x[1])return M.current=!0,i.call(b.current.move,null),M.current=!1,_.current=null,void k.current(null);let o=t.x[0],r=!1;if(e>t.x[0]){if(o=e,"bin"===f){const t=S.current;t&&t.length>0?o=x(e,t):h&&h>0&&(o=Math.ceil(e/h)*h)}if(o>=t.x[1])return M.current=!0,i.call(b.current.move,null),M.current=!1,_.current=null,void k.current(null);r=!0}const s=u.x(o),l=u.x(t.x[1]);if(M.current=!0,"x"===c)i.call(b.current.move,[s,l]);else{const e=u.y(t.y[1]),n=u.y(t.y[0]);i.call(b.current.move,[[s,e],[l,n]])}if(M.current=!1,r){const e={x:[o,t.x[1]],y:t.y};_.current=e,k.current(e)}},[u,p,c,f,h]),t.jsx("svg",{ref:v,width:s,height:l,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:t.jsx("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`})})}class k{constructor(t,e){var n,i;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=t,this.chunkThreshold=null!==(n=null==e?void 0:e.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(i=null==e?void 0:e.chunkSize)&&void 0!==i?i: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(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 i=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,i),bounded:!1}),e=i,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(t){if(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 i=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,i),bounded:!1}),e=i,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){this.pushBuffer.push(t),this.scheduleFlush()}pushMany(t){if(0!==t.length){for(let e=0;t.length>e;e++)this.pushBuffer.push(t[e]);this.scheduleFlush()}}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}function w(n){const i=e.createContext(null),o=A(n);return[function({children:o}){const r=e.useMemo(()=>A(n),[]);return t.jsx(i.Provider,{value:r,children:o})},t=>{var n;const r=null!==(n=e.useContext(i))&&void 0!==n?n:o,s=e.useRef(t);s.current=t;const l=e.useCallback(()=>s.current(r.getState()),[r]),a=e.useCallback(()=>s.current(r.getState()),[r]);return e.useSyncExternalStore(r.subscribe,l,a)}]}function A(t){const e=new EventTarget;let n=t(function(t){n=Object.assign(Object.assign({},n),t(n)),e.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(t){return e.addEventListener("update",t),()=>e.removeEventListener("update",t)}}}function S(t){if(!(null==t?void 0:t.colors))return;const e=t.colors;return{primary:e.primary,secondary:e.secondary||e.primary,surface:e.surface||e.background,success:e.success,danger:e.danger,warning:e.warning,error:e.error,info:e.info,text:e.text,textSecondary:e.textSecondary,border:e.border,grid:e.grid}}function M(t){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{categorical:_})})),t.accessibility.highContrast){const t="dark"===e.mode;e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{text:t?"#ffffff":"#000000",textSecondary:t?"#cccccc":"#333333",grid:t?"#666666":"#999999",border:t?"#888888":"#000000"})})}return e}const _=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],j={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:10}},P={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:10}},C={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"},[E,T]=w(t=>({theme:j,setTheme(e){t(t=>{if("light"===e)return{theme:j};if("dark"===e)return{theme:P};if("high-contrast"===e)return{theme:C};if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?P:j;return{theme:M(Object.assign(Object.assign(Object.assign({},t),e),{colors:Object.assign(Object.assign({},t.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.typography),e.typography||{})}))}}return{theme:M(Object.assign(Object.assign(Object.assign({},t.theme),e),{colors:Object.assign(Object.assign({},t.theme.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.theme.typography),e.typography||{})}))}})}}));class D{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const n of t){const t=this.push(n);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;return{next:()=>this._size>t?{done:!1,value:this.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t(this.buffer[(e+n)%this._capacity],n)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t[n]=this.buffer[(e+n)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),n=[];for(;e.length>t;)n.push(e.shift());this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(const t of e)this.push(t);return n}update(t,e){const n=[],i=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){const r=(i+o)%this._capacity,s=this.buffer[r];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:Object.assign({},s),n.push(t),this.buffer[r]=e(s)}}return n}remove(t){const e=[],n=[];if(this.forEach(i=>{t(i)?n.push(i):e.push(i)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class L{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isNaN(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.isNaN(t)||(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function O(t,e,n,i,o){const r=new Map;for(const s of t){const t=e(s),l=n(s);if(null==t||null==l||Number.isNaN(t)||Number.isNaN(l))continue;const a=Math.floor(t/i)*i;let c=r.get(a);if(c||(c={start:a,end:a+i,total:0,categories:new Map},r.set(a,c)),c.total+=l,o){const t=o(s);c.categories.set(t,(c.categories.get(t)||0)+l)}}return r}function N(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function $(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function I(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function W(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}const R=s.schemeCategory10,z=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function Y(t,e,n){var i,o,r;if(1>=n)return 1;const s=null!==(i=t.minOpacity)&&void 0!==i?i:.1,l=n-1-e;switch(t.type){case"linear":return s+(1-l/(n-1))*(1-s);case"exponential":{const e=null!==(o=t.halfLife)&&void 0!==o?o:n/2;return s+Math.pow(.5,l/e)*(1-s)}case"step":return(null!==(r=t.stepThreshold)&&void 0!==r?r:.5*n)>l?1:s;default:return 1}}function B(t,e,n){var i;const o=null!==(i=t.duration)&&void 0!==i?i:500,r=n-e;return o>r?1-r/o:0}function F(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function H(t,e){return Math.min((t-e.startTime)/e.duration,1)}function X(t,e,n){return t+(e-t)*n}function G(t,e,n){var i,o,r,s;if(e._transitionKey)return e._transitionKey;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const n=t.getX(e.datum),i=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${n}:${i}`;if(null!=n&&null!=i)return`p:${n}:${i}`}return"p:"+n;case"rect":return`r:${e.group||""}:${null!==(s=null!==(o=null===(i=e.datum)||void 0===i?void 0:i.binStart)&&void 0!==o?o:null===(r=e.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:n}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+n:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function V(t,e,n,i,o,r){const s=[];for(const o of t){const t=n(o),r=i(o);null==t||null==r||Number.isNaN(t)||Number.isNaN(r)||s.push({px:e.x(t),py:e.y(r),rawY:r,d:o})}s.sort((t,e)=>t.px-e.px);const l=Array(s.length),a=Array(s.length),c=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];l[t]=[e.px,e.py],a[t]=e.rawY,c[t]=e.d}return{type:"line",path:l,rawValues:a,style:o,datum:c,group:r}}function q(t,e,n,i,o,r,s,l){const a=[];for(const r of t){const t=n(r),s=i(r);if(null==t||null==s||Number.isNaN(t)||Number.isNaN(s))continue;const c=e.x(t),u=l?l(r):o;a.push({px:c,topY:e.y(s),botY:e.y(u)})}a.sort((t,e)=>t.px-e.px);const c=Array(a.length),u=Array(a.length);for(let t=0;a.length>t;t++){const e=a[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 U(t,e,n,i,o,r,s){const l=n(t),a=i(t);if(null==l||null==a||Number.isNaN(l)||Number.isNaN(a))return null;const c={type:"point",x:e.x(l),y:e.y(a),r:o,style:r,datum:t};return void 0!==s&&(c.pointId=s),c}function K(t,e,n,i,o,r,s){return{type:"rect",x:t,y:e,w:n,h:i,style:o,datum:r,group:s}}function Z(t,e,n,i,o,r,s){const l={type:"heatcell",x:t,y:e,w:n,h:i,fill:o,datum:r};return(null==s?void 0:s.showValues)&&(l.showValues=!0,l.value=s.value,s.valueFormat&&(l.valueFormat=s.valueFormat)),l}function Q(t,e,n){if(!t.getBounds||!t.scales)return null;const i=[],o=[];for(const n of e){const e=t.getX(n),r=t.getY(n);if(null==e||null==r||Number.isNaN(e)||Number.isNaN(r))continue;const s=t.getBounds(n),l=t.scales.x(e);if(s&&0!==s)i.push([l,t.scales.y(r+s)]),o.push([l,t.scales.y(r-s)]);else{const e=t.scales.y(r);i.push([l,e]),o.push([l,e])}}return 2>i.length?null:{type:"area",topPath:i,bottomPath:o,style:t.resolveBoundsStyle(n,e[0]),datum:e,group:n,interactive:!1}}function J(t,e,n,i){var o;if(!t.config.pointStyle)return;const r=null!=i?i:t.getY;for(const i of e){const e=t.resolveGroupColor(i.key);for(const s of i.data){let i=t.config.pointStyle(s);!i.fill&&e&&(i=Object.assign(Object.assign({},i),{fill:e}));const l=null!==(o=i.r)&&void 0!==o?o:3,a=t.getPointId?t.getPointId(s)+"":void 0,c=U(s,t.scales,t.getX,r,l,i,a);c&&n.push(c)}}}const tt={blues:s.interpolateBlues,reds:s.interpolateReds,greens:s.interpolateGreens,viridis:s.interpolateViridis,oranges:s.interpolateOranges,purples:s.interpolatePurples,greys:s.interpolateGreys,plasma:s.interpolatePlasma,inferno:s.interpolateInferno,magma:s.interpolateMagma,cividis:s.interpolateCividis,turbo:s.interpolateTurbo},et=new Map;class nt{constructor(t){if(this.xExtent=new L,this.yExtent=new L,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._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.xIsDate=!1,this._quadtree=null,this._maxPointRadius=0,this.config=t,this.buffer=new D(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=$(t.timeAccessor||t.xAccessor,"time"),this.getY=$(t.valueAccessor||t.yAccessor,"value")):(this.getX=$(t.xAccessor,"x"),this.getY=$(t.yAccessor,"y")),this.getGroup=W(t.groupAccessor),this.getCategory=W(t.categoryAccessor),this.getSize=t.sizeAccessor?$(t.sizeAccessor,"size"):void 0,this.getColor=W(t.colorAccessor),this.getBounds=t.boundsAccessor?$(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?$(t.y0Accessor,"y0"):void 0,this.getPointId=W(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,n=null!=t.closeAccessor;this.getOpen=e?$(t.openAccessor,"open"):void 0,this.getHigh=$(t.highAccessor,"high"),this.getLow=$(t.lowAccessor,"low"),this.getClose=n?$(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!n}t.pulse&&(this.timestampBuffer=new D(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.bounded){if(this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.getX=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?$(this.config.timeAccessor||this.config.xAccessor,"time"):$(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],n=this.config.xAccessor,i="function"==typeof n?n(e):e[n||"x"],o=i instanceof Date,r="string"==typeof i&&i.length>=10&&!isNaN(new Date(i).getTime())&&isNaN(Number(i));if(this.xIsDate=o||r,r){const t="string"==typeof n?n:void 0;this.getX=t?e=>+new Date(e[t]):t=>+(n(t)instanceof Date?n(t):new Date(n(t)))}}const n=t.totalSize||t.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of t.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n)))}else for(const n of t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity||1e6;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const t=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n))),null!=t&&(this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):this.yExtent.evict(this.getY(t)))}return!0}computeScene(t){var e,n,i,r,s,l,a;const{config:c,buffer:u}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(e=this.config.scalePadding)&&void 0!==e?e:0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);if(this.xExtent.dirty&&this.xExtent.recalculate(u,this.getX),this.yExtent.dirty)if("candlestick"===c.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of u)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(u,this.getY);const d=this.getBufferArray(),h=this.xExtent.extent,f=this.yExtent.extent;let g=c.xExtent?[null!==(n=c.xExtent[0])&&void 0!==n?n:h[0],null!==(i=c.xExtent[1])&&void 0!==i?i:h[1]]:h,y=c.yExtent?[null!==(r=c.yExtent[0])&&void 0!==r?r:f[0],null!==(s=c.yExtent[1])&&void 0!==s?s:f[1]]:f;const p=c.yExtent&&null!=c.yExtent[0]&&null!=c.yExtent[1];if("stackedarea"===c.chartType&&!p&&u.size>0)if(c.normalize)y=[0,1+c.extentPadding];else{const t=`${u.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)y=this._stackExtentCache.yDomain;else{const e=this.groupData(d),n=new Map;let i=0;for(const t of e)for(const e of t.data){const t=this.getX(e),o=this.getY(e);if(null==t||null==o||Number.isNaN(t)||Number.isNaN(o))continue;const r=(n.get(t)||0)+o;n.set(t,r),r>i&&(i=r)}y=[0,i+(i>0?i*c.extentPadding:1)],this._stackExtentCache={key:t,yDomain:y}}}else if("bar"===c.chartType&&c.binSize&&!p&&u.size>0){const[,t]=function(t,e,n,i,o){const r=O(t,e,n,i,o);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]}(u,this.getX,this.getY,c.binSize,this.getCategory);y=[0,t+t*c.extentPadding]}else if("waterfall"===c.chartType&&!p&&u.size>0){const[t,e]=function(t,e){let n=0,i=0,o=0;for(const r of t){const t=e(r);null==t||Number.isNaN(t)||(o+=t,n>o&&(n=o),o>i&&(i=o))}return[n,i]}(u,this.getY),n=e-t,i=n>0?n*c.extentPadding:1;y=[Math.min(0,t-Math.abs(i)),Math.max(0,e+Math.abs(i))]}else if(!p&&y[0]!==1/0){if(this.getBounds)for(const t of d){const e=this.getY(t),n=this.getBounds(t);null!=e&&!Number.isNaN(e)&&n&&(e+n>y[1]&&(y[1]=e+n),y[0]>e-n&&(y[0]=e-n))}const t=y[1]-y[0],e=t>0?t*c.extentPadding:1,n=null===(l=c.yExtent)||void 0===l?void 0:l[0],i=null===(a=c.yExtent)||void 0===a?void 0:a[1];y=[null!=n?y[0]:y[0]-e,null!=i?y[1]:y[1]+e],"log"===c.yScaleType&&0>=y[0]&&f[0]>0&&(y[0]=null!=n?y[0]:f[0]/(1+c.extentPadding))}if(g[0]===1/0||g[1]===-1/0)if("time"===c.xScaleType){const t=Date.now();g=[t-864e5,t]}else g=[0,1];y[0]!==1/0&&y[1]!==-1/0||(y=[0,1]);const v="streaming"===c.runtimeMode,m=Math.max(0,Math.min(c.scalePadding||0,Math.min(t.width,t.height)/2-1));if(v)if("x"==("up"===(x=c.arrowOfTime)||"down"===x?"y":"x")){const e="right"===c.arrowOfTime?[m,t.width-m]:[t.width-m,m];this.scales={x:o.scaleLinear().domain(g).range(e),y:o.scaleLinear().domain(y).range([t.height-m,m])}}else{const e="down"===c.arrowOfTime?[m,t.height-m]:[t.height-m,m];this.scales={x:o.scaleLinear().domain(y).range([m,t.width-m]),y:o.scaleLinear().domain(g).range(e)}}else{const e=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return o.scaleLog().domain(t).range(n).clamp(!0)}return"time"===t?o.scaleTime().domain([new Date(e[0]),new Date(e[1])]).range(n):o.scaleLinear().domain(e).range(n)};this.scales={x:e(c.xScaleType,g,[m,t.width-m]),y:e(c.yScaleType,y,[t.height-m,m])}}var x;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,d),this.config.decay&&this.applyDecay(this.scene,d),this.config.pulse&&this.applyPulse(this.scene,d),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}rebuildQuadtree(){const t=this.config.chartType;if("scatter"!==t&&"bubble"!==t)return this._quadtree=null,void(this._maxPointRadius=0);let e=0,n=0;for(const t of this.scene)"point"===t.type&&(e++,t.r>n&&(n=t.r));if(this._maxPointRadius=n,nt.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const i=Array(e);let o=0;for(const t of this.scene)"point"===t.type&&(i[o++]=t);this._quadtree=r.quadtree().x(t=>t.x).y(t=>t.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}remapScene(t){const e=t.width/this.lastLayout.width,n=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const i of t.path)i[0]*=e,i[1]*=n;break;case"area":for(const i of t.topPath)i[0]*=e,i[1]*=n;for(const i of t.bottomPath)i[0]*=e,i[1]*=n;break;case"point":t.x*=e,t.y*=n;break;case"rect":case"heatcell":t.x*=e,t.y*=n,t.w*=e,t.h*=n;break;case"candlestick":t.x*=e,t.openY*=n,t.closeY*=n,t.highY*=n,t.lowY*=n}const i=this.scales.x.domain(),r=this.scales.y.domain(),s=this.scales.x.range(),l=this.scales.y.range(),a=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return o.scaleLog().domain(t).range(n).clamp(!0)}return"time"===t?o.scaleTime().domain([new Date(e[0]),new Date(e[1])]).range(n):o.scaleLinear().domain(e).range(n)},c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),u=l[1]>l[0];this.scales={x:a(this.config.xScaleType,i,s[0]>s[1]?[t.width-c,c]:[c,t.width-c]),y:a(this.config.yScaleType,r,u?[c,t.height-c]:[t.height-c,c])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){var n;const{config:i,scales:o}=this;if(!o||0===e.length)return[];const r={scales:o,config:i,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,getBounds:this.getBounds,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(t,e)=>this.resolveLineStyle(t,e),resolveAreaStyle:(t,e)=>this.resolveAreaStyle(t,e),resolveBoundsStyle:(t,e)=>this.resolveBoundsStyle(t,e),resolveColorMap:t=>this.resolveColorMap(t),resolveGroupColor:t=>this.resolveGroupColor(t),groupData:t=>this.groupData(t),barCategoryCache:this._barCategoryCache};switch(i.chartType){case"line":return function(t,e){var n;const i=t.groupData(e),o=[],r=null===(n=t.config.annotations)||void 0===n?void 0:n.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.getBounds)for(const e of i){const n=Q(t,e.data,e.key);n&&o.push(n)}for(const e of i){const n=t.resolveLineStyle(e.key,e.data[0]),i=V(e.data,t.scales,t.getX,t.getY,n,e.key);r&&r.length>0&&(i.colorThresholds=r),t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),o.push(i)}return J(t,i,o),o}(r,e);case"area":return function(t,e){const n=t.groupData(e),i=[],o=t.scales.y.domain()[0],r=t.getY0?e=>{const n=t.getY0(e);return null==n?o:n}:void 0;for(const e of n){const n=t.resolveAreaStyle(e.key,e.data[0]),s=q(e.data,t.scales,t.getX,t.getY,o,n,e.key,r);t.config.gradientFill&&(s.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),i.push(s)}return J(t,n,i),i}(r,e);case"mixed":return function(t,e){const n=t.groupData(e),i=[],o=t.config.areaGroups||new Set,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(o.has(e.key)){const n=t.resolveAreaStyle(e.key,e.data[0]),o=q(e.data,t.scales,t.getX,t.getY,r,n,e.key,s);t.config.gradientFill&&(o.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),i.push(o)}else{const n=t.resolveLineStyle(e.key,e.data[0]),o=V(e.data,t.scales,t.getX,t.getY,n,e.key);t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),i.push(o)}return J(t,n,i),i}(r,e);case"stackedarea":return function(t,e){const n=t.groupData(e);n.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);const i=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,{nodes:o,stackedTops:r}=function(t,e,n,i,o,r,s){var l;const a=new Set;for(const e of t)for(const t of e.data){const e=n(t);null==e||Number.isNaN(e)||a.add(e)}const c=Array.from(a).sort((t,e)=>t-e),u=new Map;for(const e of t){const t=new Map;for(const o of e.data){const e=n(o),r=i(o);null==e||null==r||Number.isNaN(e)||Number.isNaN(r)||t.set(e,(t.get(e)||0)+r)}u.set(e.key,t)}let d;if(r){d=new Map;for(const e of c){let n=0;for(const i of t)n+=(null===(l=u.get(i.key))||void 0===l?void 0:l.get(e))||0;d.set(e,n||1)}}const h=[],f=new Map,g=new Map;for(const t of c)g.set(t,0);for(const n of t){const t=u.get(n.key),i=[],l=[],a=new Map;for(const n of c){let o=t.get(n)||0;const s=g.get(n);r&&(o/=d.get(n));const c=s+o,u=e.x(n);l.push([u,e.y(s)]),i.push([u,e.y(c)]),g.set(n,c),a.set(n,c)}f.set(n.key,a);const y={type:"area",topPath:i,bottomPath:l,style:o(n.key,n.data[0]),datum:n.data,group:n.key};s&&(y.curve=s),h.push(y)}return{nodes:h,stackedTops:f}}(n,t.scales,t.getX,t.getY,(e,n)=>t.resolveAreaStyle(e,n),t.config.normalize,i),s=o;if(t.config.pointStyle){const e=new WeakMap;for(const i of n){const n=r.get(i.key);if(n)for(const o of i.data){const i=t.getX(o),r=t.getY(o);null==i||Number.isNaN(i)||null==r||Number.isNaN(r)||!n.has(i)||e.set(o,n.get(i))}}const i=n=>{var i;return null!==(i=e.get(n))&&void 0!==i?i:t.getY(n)};J(t,n,s,i)}return s}(r,e);case"scatter":case"bubble":return function(t,e){var n;const i=[],o="bubble"===t.config.chartType?10:5,r=t.config.sizeRange||[3,15];let s=null;if(t.getSize&&!t.config.pointStyle){const n=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(n.length>0){let t=1/0,e=-1/0;for(const i of n)t>i&&(t=i),i>e&&(e=i);s=n=>t===e?(r[0]+r[1])/2:r[0]+(n-t)/(e-t)*(r[1]-r[0])}}const l=t.getColor?t.resolveColorMap(e):null,a=(null===(n=t.config.themeSemantic)||void 0===n?void 0:n.primary)||"#4e79a7";for(const n of e){let e=t.config.pointStyle?t.config.pointStyle(n):{fill:a,opacity:.8},r=e.r||o;if(s&&t.getSize){const e=t.getSize(n);null==e||Number.isNaN(e)||(r=s(e))}if(l&&t.getColor&&!e.fill){const i=t.getColor(n);i&&l.has(i)&&(e=Object.assign(Object.assign({},e),{fill:l.get(i)}))}const c=t.getPointId?t.getPointId(n)+"":void 0,u=U(n,t.scales,t.getX,t.getY,r,e,c);u&&i.push(u)}return i}(r,e);case"heatmap":return function(t,e,n){if(t.config.heatmapAggregation)return function(t,e,n){var i,o,r;const s=Math.max(1,Math.floor(null!==(i=t.config.heatmapXBins)&&void 0!==i?i:20)),l=Math.max(1,Math.floor(null!==(o=t.config.heatmapYBins)&&void 0!==o?o:20)),a=null!==(r=t.config.heatmapAggregation)&&void 0!==r?r:"count",c=$(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[u,d]=t.scales.x.domain(),[h,f]=t.scales.y.domain(),g=(d-u||1)/s,y=(f-h||1)/l,p=s*l;if(p>1e6)return[];const v=new Int32Array(p),m=new Float64Array(p);for(let n=0;e.length>n;n++){const i=e[n],o=t.getX(i),r=t.getY(i);if(!isFinite(o)||!isFinite(r))continue;const a=Math.min(Math.floor((o-u)/g),s-1),d=Math.min(Math.floor((r-h)/y),l-1);if(0>a||0>d)continue;const f=d*s+a;v[f]++;const p=c(i);m[f]+=isFinite(p)?p:0}let x=1/0,b=-1/0;for(let t=0;p>t;t++){if(0===v[t])continue;let e;switch(a){case"sum":e=m[t];break;case"mean":e=m[t]/v[t];break;default:e=v[t]}x>e&&(x=e),e>b&&(b=e)}if(!isFinite(x))return[];const k=b-x||1,w=n.width/s,A=n.height/l,S=t.config.showValues,M=t.config.heatmapValueFormat,_=[];for(let t=0;l>t;t++){const e=t*s;for(let n=0;s>n;n++){const i=e+n;if(0===v[i])continue;let o;switch(a){case"sum":o=m[i];break;case"mean":o=m[i]/v[i];break;default:o=v[i]}const r=(o-x)/k;_.push(Z(n*w,(l-1-t)*A,w,A,`rgb(${220-(180*r+.5)|0},${220-(100*r+.5)|0},${255-(50*r+.5)|0})`,{xi:n,yi:t,value:o,count:v[i],sum:m[i]},S?{value:o,showValues:!0,valueFormat:M}:void 0))}}return _}(t,e,n);if(0===e.length)return[];const i=$(t.config.valueAccessor,"value"),o=I(t.config.xAccessor,"x"),r=I(t.config.yAccessor,"y"),l=new Map,a=new Map,c=Array(e.length),u=Array(e.length);for(let t=0;e.length>t;t++){const n=e[t],i=o(n),s=r(n);c[t]=i,u[t]=s,l.has(i)||l.set(i,l.size),a.has(s)||a.set(s,a.size)}const d=l.size,h=a.size;if(0===d||0===h)return[];const f=Array.from(l.keys()),g=Array.from(a.keys()),y=f.every(t=>"number"==typeof t&&!isNaN(t)),p=g.every(t=>"number"==typeof t&&!isNaN(t));if(y){f.sort((t,e)=>t-e),l.clear();for(let t=0;f.length>t;t++)l.set(f[t],t)}if(p){g.sort((t,e)=>t-e),a.clear();for(let t=0;g.length>t;t++)a.set(g[t],t)}const v=new Float64Array(e.length),m=new Float64Array(e.length),x=Array(e.length),b=new Map;let k=0;for(let t=0;e.length>t;t++){const n=e[t],o=l.get(c[t]),r=a.get(u[t]);if(void 0===o||void 0===r)continue;const s=i(n),h=r*d+o,f=b.get(h);let g;void 0!==f?g=f:(g=k++,b.set(h,g)),v[g]=h,m[g]=s,x[g]=n}let w=1/0,A=-1/0;for(let t=0;k>t;t++){const e=m[t];isFinite(e)&&(w>e&&(w=e),e>A&&(A=e))}if(!isFinite(w)||!isFinite(A))return[];const S=function(t){const e=t in tt?t:"blues";let n=et.get(e);if(n)return n;n=Array(256);const i=tt[e]||s.interpolateBlues;for(let t=0;256>t;t++)n[t]=i(t/255);return et.set(e,n),n}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),M=255/(A-w||1),_=n.width/d,j=n.height/h,P=t.config.showValues,C=t.config.heatmapValueFormat,E=[];for(let t=0;k>t;t++){const e=m[t];if(!isFinite(e))continue;const n=v[t],i=n%d;E.push(Z(i*_,(h-1-(n-i)/d)*j,_,j,S[Math.min((e-w)*M+.5|0,255)],x[t],P?{value:e,showValues:!0,valueFormat:C}:void 0))}return E}(r,e,t);case"bar":{const t=function(t,e){var n,i;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const o=O(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===o.size)return{nodes:[],binBoundaries:[]};let r=null;if(t.getCategory){const e=new Set;for(const t of o.values())for(const n of t.categories.keys())e.add(n);const n=t.config.barColors?Object.keys(t.config.barColors):[],i=new Set(n),s=Array.from(e).filter(t=>!i.has(t)).sort(),l=n.filter(t=>e.has(t)),a=l.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===a?r=t.barCategoryCache.order:(r=[...l,...s],t.barCategoryCache={key:a,order:r})}const s=[],l=t.scales,[a,c]=l.x.domain(),u=t.config.barStyle,d=null===(n=t.config.themeSemantic)||void 0===n?void 0:n.primary,h=null==u?void 0:u.gap,f="number"!=typeof h||0>h?1:h,g={};(null==u?void 0:u.stroke)&&(g.stroke=u.stroke),"number"==typeof(null==u?void 0:u.strokeWidth)&&(g.strokeWidth=u.strokeWidth),"number"==typeof(null==u?void 0:u.opacity)&&(g.opacity=u.opacity);for(const e of o.values()){const n=Math.max(e.start,a),o=Math.min(e.end,c);if(n>=o)continue;const h=l.x(n),y=l.x(o),p=Math.abs(y-h),v=p>f+1?f:0,m=Math.min(h,y)+v/2,x=Math.max(p-v,1);if(x>0)if(r&&e.categories.size>0){let n=0;for(const o of r){const r=e.categories.get(o)||0;if(0===r)continue;const a=l.y(n),c=l.y(n+r),h=(null===(i=t.config.barColors)||void 0===i?void 0:i[o])||(null==u?void 0:u.fill)||d||"#4e79a7";s.push(K(m,Math.min(a,c),x,Math.abs(a-c),Object.assign({fill:h},g),{binStart:e.start,binEnd:e.end,total:e.total,category:o,categoryValue:r},o)),n+=r}}else{const t=l.y(0),n=l.y(e.total);s.push(K(m,Math.min(t,n),x,Math.abs(t-n),Object.assign({fill:(null==u?void 0:u.fill)||d||"#007bff"},g),{binStart:e.start,binEnd:e.end,total:e.total}))}}const y=new Set;for(const t of o.values())y.add(t.start),y.add(t.end);return{nodes:s,binBoundaries:Array.from(y).sort((t,e)=>t-e)}}(r,e);return this._barCategoryCache=null!==(n=r.barCategoryCache)&&void 0!==n?n:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var n,i,o,r,s,l;const a=[],c=t.config.swarmStyle||{},u=null!==(n=c.radius)&&void 0!==n?n:3,d=null!==(r=null!==(i=c.fill)&&void 0!==i?i:null===(o=t.config.themeSemantic)||void 0===o?void 0:o.primary)&&void 0!==r?r:"#007bff",h=null!==(s=c.opacity)&&void 0!==s?s:.7,f=c.stroke,g=c.strokeWidth;for(const n of e){const e=t.getX(n),i=t.getY(n);if(null==i||Number.isNaN(i))continue;const o=t.scales.x(e),r=t.scales.y(i);let s=d;if(t.getCategory){const e=t.getCategory(n);s=(null===(l=t.config.barColors)||void 0===l?void 0:l[e])||s}const c={type:"point",x:o,y:r,r:u,style:{fill:s,opacity:h,stroke:f,strokeWidth:g},datum:n};t.getPointId&&(c.pointId=t.getPointId(n)+""),a.push(c)}return a}(r,e);case"waterfall":return function(t,e,n){var i,o,r,s,l,a,c;const u=[],d=t.scales,h=t.config.waterfallStyle,f=e.filter(e=>{const n=t.getY(e),i=t.getX(e);return null!=n&&!Number.isNaN(n)&&null!=i&&isFinite(i)});if(0===f.length)return u;const g=null!==(r=null!==(i=null==h?void 0:h.positiveColor)&&void 0!==i?i:null===(o=t.config.themeSemantic)||void 0===o?void 0:o.success)&&void 0!==r?r:"#28a745",y=null!==(a=null!==(s=null==h?void 0:h.negativeColor)&&void 0!==s?s:null===(l=t.config.themeSemantic)||void 0===l?void 0:l.danger)&&void 0!==a?a:"#dc3545",p=null!==(c=null==h?void 0:h.gap)&&void 0!==c?c:1,v=null==h?void 0:h.stroke,m=null==h?void 0:h.strokeWidth,x=null==h?void 0:h.opacity;let b=0;for(let e=0;f.length>e;e++){const i=f[e],o=t.getX(i),r=t.getY(i),s=b+r;let l;l=f.length-1>e?t.getX(f[e+1])-o:e>0?o-t.getX(f[e-1]):0;const a=d.x(o),c=0!==l?d.x(o+l):a+n.width/10,k=Math.min(a,c)+p/2,w=Math.max(a,c)-p/2-k;if(0>=w){b=s;continue}const A=d.y(b),S=d.y(s),M=Math.min(A,S),_=Math.abs(A-S),j={fill:0>r?y:g,stroke:v,strokeWidth:m};null!=x&&(j.opacity=x),u.push(K(k,M,w,_,j,Object.assign(Object.assign({},i),{baseline:b,cumEnd:s,delta:r,_connectorStroke:null==h?void 0:h.connectorStroke,_connectorWidth:null==h?void 0:h.connectorWidth}))),b=s}return u}(r,e,t);case"candlestick":return function(t,e){var n,i;if(!t.getHigh||!t.getLow||!t.scales)return[];const o=null!==(n=t.config.candlestickRangeMode)&&void 0!==n&&n;if(!(o||t.getOpen&&t.getClose))return[];const r=[],s=t.config.candlestickStyle||{},l=s.rangeColor||"#6366f1",a=o?l:s.upColor||"#28a745",c=o?l:s.downColor||"#dc3545",u=o?l:s.wickColor||"#333",d=s.wickWidth||(o?2:1),h=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let f=null!==(i=s.bodyWidth)&&void 0!==i?i:0;if(null==s.bodyWidth)if(h.length>1){let e=1/0;for(let n=1;h.length>n;n++){const i=Math.abs(t.scales.x(h[n])-t.scales.x(h[n-1]));i>0&&e>i&&(e=i)}f=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else f=6;for(const n of e){const e=t.getX(n);if(null==e||Number.isNaN(e))continue;const i=t.getHigh(n),s=t.getLow(n);if(null==i||Number.isNaN(i)||null==s||Number.isNaN(s))continue;const l=o?i:t.getOpen(n),h=o?s:t.getClose(n);if(!o&&[l,h].some(t=>null==t||Number.isNaN(t)))continue;const g=h>=l,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(l),closeY:t.scales.y(h),highY:t.scales.y(i),lowY:t.scales.y(s),bodyWidth:f,upColor:a,downColor:c,wickColor:u,wickWidth:d,isUp:g,datum:n};o&&(y.isRange=!0),r.push(y)}return r}(r,e);default:return[]}}resolveBoundsStyle(t,e){var n;const i=this.config.boundsStyle;return"function"==typeof i?i(e||{},t):i&&"object"==typeof i?i:{fill:this.resolveLineStyle(t,e).stroke||(null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary)||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const n=this.config.decay;return n&&e>1?Y(n,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,n){var i,o;const r=n.length;if(1>=r)return;const s=new Map;for(let t=0;n.length>t;t++)s.set(n[t],t);for(const n of e){if("line"===n.type){const e=Array.isArray(n.datum)?n.datum:[];if(2>e.length)continue;const i=Array(e.length);let o=!1;for(let n=0;e.length>n;n++){const l=s.get(e[n]);null!=l?(i[n]=Y(t,l,r),1>i[n]&&(o=!0)):i[n]=1}o&&(n._decayOpacities=i);continue}if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[],i=n.topPath?n.topPath.length:e.length;if(2>i)continue;if(e.length===i){const o=Array(i);let l=!1;for(let n=0;e.length>n;n++){const i=s.get(e[n]);null!=i?(o[n]=Y(t,i,r),1>o[n]&&(l=!0)):o[n]=1}l&&(n._decayOpacities=o)}else{let o=1;for(const n of e){const e=s.get(n);if(null!=e){const n=Y(t,e,r);o>n&&(o=n)}}if(1>o){const t=Array(i);t.fill(o),n._decayOpacities=t}}continue}const e=s.get(n.datum);if(null==e)continue;const l=Y(t,e,r);if("heatcell"===n.type)n.style={opacity:l};else if("candlestick"===n.type)n._decayOpacity=l;else{const t=null!==(o=null===(i=n.style)||void 0===i?void 0:i.opacity)&&void 0!==o?o:1;n.style=Object.assign(Object.assign({},n.style),{opacity:t*l})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,n,i){var o,r;const s="undefined"!=typeof performance?performance.now():Date.now(),l=null!==(o=t.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",a=null!==(r=t.glowRadius)&&void 0!==r?r:4,c=new Map;for(let t=0;n.length>t;t++)c.set(n[t],t);for(const n of e){if("line"===n.type)continue;if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[n.datum];let o=0;for(const n of e){const e=c.get(n);if(null==e)continue;const r=i.get(e);if(null==r)continue;const l=B(t,r,s);l>o&&(o=l)}o>0&&(n._pulseIntensity=o,n._pulseColor=l);continue}const e=c.get(n.datum);if(null==e)continue;const o=i.get(e);if(null==o)continue;const r=B(t,o,s);r>0&&(n._pulseIntensity=r,n._pulseColor=l,n._pulseGlowRadius=a)}}(this.config.pulse,t,e,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(t,e){var n;if(!e||0===e.size)return!1;const i="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(n=t.duration)&&void 0!==n?n:500,r=e.peek();return null!=r&&o>i-r}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,n,i){var o,r,s,l;n.clear(),i.clear();for(let a=0;e.length>a;a++){const c=e[a],u=G(t,c,a);u&&("point"===c.type?n.set(u,{x:c.x,y:c.y,r:c.r,opacity:c.style.opacity}):"rect"===c.type?n.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:c.style.opacity}):"heatcell"===c.type?n.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:null===(o=c.style)||void 0===o?void 0:o.opacity}):"candlestick"===c.type?n.set(u,{x:c.x,y:c.openY,w:c.bodyWidth,openY:c.openY,closeY:c.closeY,highY:c.highY,lowY:c.lowY,opacity:null===(r=c.style)||void 0===r?void 0:r.opacity}):"line"===c.type?i.set(u,{path:c.path.map(t=>[t[0],t[1]]),opacity:null===(s=c.style)||void 0===s?void 0:s.opacity}):"area"===c.type&&i.set(u,{topPath:c.topPath.map(t=>[t[0],t[1]]),bottomPath:c.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(l=c.style)||void 0===l?void 0:l.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){var t,e,n;this.prevPositionMap.clear(),this.prevPathMap.clear();const i=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.y(0))&&void 0!==e?e:0;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],o=G(this.transitionContext,e,t);o&&("point"===e.type?this.prevPositionMap.set(o,{x:e.x,y:e.y,r:0,opacity:0}):"rect"===e.type?this.prevPositionMap.set(o,{x:e.x,y:i,w:e.w,h:0,opacity:null!==(n=e.style.opacity)&&void 0!==n?n:1}):"heatcell"===e.type?this.prevPositionMap.set(o,{x:e.x,y:e.y,w:e.w,h:e.h,opacity:0}):"line"===e.type?(e._introClipFraction=0,this.prevPathMap.set(o,{path:e.path.map(t=>[t[0],t[1]]),opacity:e.style.opacity})):"area"===e.type&&(e._introClipFraction=0,this.prevPathMap.set(o,{topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),opacity:e.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,n,i,o){var r,s,l,a,c,u,d,h,f,g,y,p,v,m,x,b,k,w,A,S,M,_,j,P,C,E,T,D,L,O,N,$,I,W,R,z,Y,B,F,H,X;if(0===i.size&&0===o.size)return n;const V=null!==(r=e.duration)&&void 0!==r?r:300;if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}let q=!1;const U=new Set,K=new Set;for(let e=0;n.scene.length>e;e++){const r=n.scene[e],E=G(t,r,e);if(!E)continue;if(r._transitionKey=E,"line"===r.type||"area"===r.type){const t=o.get(E);if(t){if(K.add(E),"line"===r.type&&t.path&&t.path.length===r.path.length){r._targetPath=r.path.map(t=>[t[0],t[1]]),r._prevPath=t.path;for(let e=0;r.path.length>e;e++)r.path[e]=[t.path[e][0],t.path[e][1]];q=!0}else if("area"===r.type&&t.topPath&&t.bottomPath&&t.topPath.length===r.topPath.length&&t.bottomPath.length===r.bottomPath.length){r._targetTopPath=r.topPath.map(t=>[t[0],t[1]]),r._targetBottomPath=r.bottomPath.map(t=>[t[0],t[1]]),r._prevTopPath=t.topPath,r._prevBottomPath=t.bottomPath;for(let e=0;r.topPath.length>e;e++)r.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;r.bottomPath.length>e;e++)r.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];q=!0}r._targetOpacity=null!==(s=r.style.opacity)&&void 0!==s?s:1,r._startOpacity=null!==(a=null!==(l=t.opacity)&&void 0!==l?l:r.style.opacity)&&void 0!==a?a:1}else r._targetOpacity=null!==(c=r.style.opacity)&&void 0!==c?c:1,r._startOpacity=0,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),q=!0;continue}const T=i.get(E);if("point"===r.type)if(T){U.add(E);const t={x:r.x,y:r.y,r:r.r};r._targetOpacity=null!==(u=r.style.opacity)&&void 0!==u?u:1,T.x===t.x&&T.y===t.y&&T.r===t.r||(r._targetX=t.x,r._targetY=t.y,r._targetR=t.r,r.x=T.x,r.y=T.y,r.r=null!==(d=T.r)&&void 0!==d?d:r.r,q=!0)}else r._targetOpacity=null!==(h=r.style.opacity)&&void 0!==h?h:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),q=!0;else if("rect"===r.type)if(T){U.add(E);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(f=r.style.opacity)&&void 0!==f?f:1,T.x===t.x&&T.y===t.y&&T.w===t.w&&T.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=T.x,r.y=T.y,r.w=null!==(g=T.w)&&void 0!==g?g:r.w,r.h=null!==(y=T.h)&&void 0!==y?y:r.h,q=!0)}else r._targetOpacity=null!==(p=r.style.opacity)&&void 0!==p?p:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),q=!0;else if("heatcell"===r.type)if(T){U.add(E);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(m=null===(v=r.style)||void 0===v?void 0:v.opacity)&&void 0!==m?m:1,T.x===t.x&&T.y===t.y&&T.w===t.w&&T.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=T.x,r.y=T.y,r.w=null!==(x=T.w)&&void 0!==x?x:r.w,r.h=null!==(b=T.h)&&void 0!==b?b:r.h,q=!0)}else r._targetOpacity=null!==(w=null===(k=r.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),q=!0;else if("candlestick"===r.type)if(T&&null!=T.openY){U.add(E);const t={x:r.x,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY};r._targetOpacity=null!==(S=null===(A=r.style)||void 0===A?void 0:A.opacity)&&void 0!==S?S:1,(T.x!==t.x||T.openY!==t.openY||T.closeY!==t.closeY||T.highY!==t.highY||T.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=T.x,r.openY=T.openY,r.closeY=null!==(M=T.closeY)&&void 0!==M?M:r.closeY,r.highY=null!==(_=T.highY)&&void 0!==_?_:r.highY,r.lowY=null!==(j=T.lowY)&&void 0!==j?j:r.lowY,q=!0)}else r._targetOpacity=null!==(C=null===(P=r.style)||void 0===P?void 0:P.opacity)&&void 0!==C?C:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),q=!0}for(const[t,e]of o)if(!K.has(t))if(t.startsWith("l:")&&e.path){const i={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(E=e.opacity)&&void 0!==E?E:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(i),q=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const i={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:null!==(T=e.opacity)&&void 0!==T?T:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(i),q=!0}for(const[t,e]of i)if(!U.has(t)){if(t.startsWith("p:")){const i={type:"point",x:e.x,y:e.y,r:null!==(D=e.r)&&void 0!==D?D:3,style:{opacity:null!==(L=e.opacity)&&void 0!==L?L:1},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}else if(t.startsWith("r:")){const i={type:"rect",x:e.x,y:e.y,w:null!==(O=e.w)&&void 0!==O?O:0,h:null!==(N=e.h)&&void 0!==N?N:0,style:{opacity:null!==($=e.opacity)&&void 0!==$?$:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}else if(t.startsWith("h:")){const i={type:"heatcell",x:e.x,y:e.y,w:null!==(I=e.w)&&void 0!==I?I:0,h:null!==(W=e.h)&&void 0!==W?W:0,fill:"#999",datum:null,style:{opacity:null!==(R=e.opacity)&&void 0!==R?R:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}else if(t.startsWith("c:")){const i=null!==(z=e.openY)&&void 0!==z?z:e.y,o={type:"candlestick",x:e.x,openY:i,closeY:null!==(Y=e.closeY)&&void 0!==Y?Y:i,highY:null!==(B=e.highY)&&void 0!==B?B:i,lowY:null!==(F=e.lowY)&&void 0!==F?F:i,bodyWidth:null!==(H=e.w)&&void 0!==H?H:6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:null!==(X=e.opacity)&&void 0!==X?X:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(o)}q=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),q&&(n.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:V}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(t,e,n,i){var o,r,s,l,a,c;if(!n.activeTransition)return!1;const u=H(t,n.activeTransition),d=F(u,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of n.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,r=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;t.style.opacity=X(r,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=X(n.x,t._targetX,d),t.y=X(n.y,t._targetY,d),void 0!==t._targetR&&void 0!==n.r&&(t.r=X(n.r,t._targetR,d))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,o=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;t.style.opacity=X(o,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=X(n.x,t._targetX,d),t.y=X(n.y,t._targetY,d),void 0!==n.w&&(t.w=X(n.w,t._targetW,d)),void 0!==n.h&&(t.h=X(n.h,t._targetH,d))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,o=n?null!==(s=n.opacity)&&void 0!==s?s:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:X(o,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=X(n.x,t._targetX,d),t.y=X(n.y,t._targetY,d),void 0!==n.w&&(t.w=X(n.w,t._targetW,d)),void 0!==n.h&&(t.h=X(n.h,t._targetH,d))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,o=n?null!==(l=n.opacity)&&void 0!==l?l:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:X(o,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=X(n.x,t._targetX,d),void 0!==n.openY&&(t.openY=X(n.openY,t._targetOpenY,d)),void 0!==n.closeY&&(t.closeY=X(n.closeY,t._targetCloseY,d)),void 0!==n.highY&&(t.highY=X(n.highY,t._targetHighY,d)),void 0!==n.lowY&&(t.lowY=X(n.lowY,t._targetLowY,d))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=null!==(a=t._startOpacity)&&void 0!==a?a:0;t.style=Object.assign(Object.assign({},t.style),{opacity:X(e,t._targetOpacity,d)})}void 0!==t._introClipFraction&&(t._introClipFraction=d);const e=t._prevPath,n=t._targetPath;if(e&&n&&e.length===t.path.length)for(let i=0;t.path.length>i;i++)t.path[i][0]=X(e[i][0],n[i][0],d),t.path[i][1]=X(e[i][1],n[i][1],d)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(c=t._startOpacity)&&void 0!==c?c:0;t.style=Object.assign(Object.assign({},t.style),{opacity:X(e,t._targetOpacity,d)})}void 0!==t._introClipFraction&&(t._introClipFraction=d);const e=t._prevTopPath,n=t._prevBottomPath,i=t._targetTopPath,o=t._targetBottomPath;if(e&&i&&e.length===t.topPath.length)for(let n=0;t.topPath.length>n;n++)t.topPath[n][0]=X(e[n][0],i[n][0],d),t.topPath[n][1]=X(e[n][1],i[n][1],d);if(n&&o&&n.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=X(n[e][0],o[e][0],d),t.bottomPath[e][1]=X(n[e][1],o[e][1],d)}}if(u>=1){for(const t of n.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style=Object.assign(Object.assign({},"line"===t.type||"area"===t.type?t.style:t.style||{}),{opacity:0===e?0:e}),t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("candlestick"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let n=0;t.path.length>n;n++)t.path[n]=e[n];t._prevPath=void 0,t._targetPath=void 0,t._introClipFraction=void 0}else if("area"===t.type){const e=t._targetTopPath,n=t._targetBottomPath;if(e)for(let n=0;t.topPath.length>n;n++)t.topPath[n]=e[n];if(n)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=n[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0,t._introClipFraction=void 0}}if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,n}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const n of t){const t=this.getGroup(n);e.has(t)||e.set(t,[]),e.get(t).push(n)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveColorMap(t){if(this._colorMapCache&&this._colorMapCache.version===this._ingestVersion)return this._colorMapCache.map;const e=new Set;for(const n of t){const t=this.getColor(n);t&&e.add(t)}const n=Array.from(e).sort(),i=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===i)return this._colorMapCache.version=this._ingestVersion,this._colorMapCache.map;const o=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||z,r=new Map;for(let t=0;n.length>t;t++)r.set(n[t],o[t%o.length]);return this._colorMapCache={key:i,map:r,version:this._ingestVersion},r}resolveLineStyle(t,e){var n;const i=this.config.lineStyle;if("function"==typeof i){const n=i(e||{},t);if(n&&!n.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{stroke:e})}return n}const o=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary;return i&&"object"==typeof i?{stroke:i.stroke||o||"#007bff",strokeWidth:i.strokeWidth||2,strokeDasharray:i.strokeDasharray,fill:i.fill,fillOpacity:i.fillOpacity,opacity:i.opacity}:{stroke:this.resolveGroupColor(t)||o||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var n,i;if(this.config.areaStyle){const n=this.config.areaStyle(e||{});if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}const o=this.config.lineStyle;if("function"==typeof o){const n=o(e||{},t);if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}const r=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary;if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||r||"#4e79a7",fillOpacity:null!==(i=o.fillOpacity)&&void 0!==i?i:.7,stroke:o.stroke||r||"#4e79a7",strokeWidth:o.strokeWidth||2};const s=this.resolveGroupColor(t)||r||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}resolveGroupColor(t){if(this._colorMapCache){const e=this._colorMapCache.map.get(t);if(e)return e}const e=this._groupColorMap.get(t);if(e)return e;const n=(Array.isArray(this.config.colorScheme)&&this.config.colorScheme.length>0?this.config.colorScheme:null)||(Array.isArray(this.config.themeCategorical)&&this.config.themeCategorical.length>0?this.config.themeCategorical:null)||z;if(0===n.length)return null;const i=n[this._groupColorCounter%n.length];if(this._groupColorCounter++,this._groupColorMap.set(t,i),this._groupColorMap.size>nt.GROUP_COLOR_MAP_CAP){const t=this._groupColorMap.keys().next().value;void 0!==t&&this._groupColorMap.delete(t)}return i}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),n=this.getPointId,i=t=>e.has(n(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,n)=>{i(t)&&e.add(n)}),this.timestampBuffer.clear();for(let n=0;t.length>n;n++)e.has(n)||this.timestampBuffer.push(t[n])}const o=this.buffer.remove(i);if(0===o.length)return o;for(const t of o)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,o}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=new Set(Array.isArray(t)?t:[t]),i=this.getPointId,o=new Set;this.buffer.forEach((t,e)=>{n.has(i(t))&&o.add(e)});const r=this.buffer.update(t=>n.has(i(t)),e);if(0===r.length)return r;for(const t of r)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.buffer.forEach((t,e)=>{o.has(e)&&(this.xExtent.push(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))):(this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,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.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._maxPointRadius=0,this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(t){var e,n,i,o;const r=Object.assign({},this.config);("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(this._stackExtentCache=null);let s=!1;Object.assign(this.config,t);const l="chartType"in t&&t.chartType!==r.chartType||"runtimeMode"in t&&t.runtimeMode!==r.runtimeMode;if(l||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const a=l||!N(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(n=r.xAccessor)&&void 0!==n?n:r.timeAccessor),c=l||!N(null!==(i=t.yAccessor)&&void 0!==i?i:t.valueAccessor,null!==(o=r.yAccessor)&&void 0!==o?o:r.valueAccessor);(a||c)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=$(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=$(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=$(this.config.xAccessor,"x"),this.getY=$(this.config.yAccessor,"y")),s=!0)}if("groupAccessor"in t&&!N(t.groupAccessor,r.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?W(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in t&&!N(t.categoryAccessor,r.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?W(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in t&&!N(t.sizeAccessor,r.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?$(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in t&&!N(t.colorAccessor,r.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?W(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in t&&!N(t.y0Accessor,r.y0Accessor)&&(this.getY0=this.config.y0Accessor?$(this.config.y0Accessor,"y0"):void 0,s=!0),"pointIdAccessor"in t&&!N(t.pointIdAccessor,r.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?W(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&("openAccessor"in t&&!N(t.openAccessor,r.openAccessor)||"closeAccessor"in t&&!N(t.closeAccessor,r.closeAccessor)||"highAccessor"in t&&!N(t.highAccessor,r.highAccessor)||"lowAccessor"in t&&!N(t.lowAccessor,r.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?$(this.config.openAccessor,"open"):void 0,this.getHigh=$(this.config.highAccessor,"high"),this.getLow=$(this.config.lowAccessor,"low"),this.getClose=e?$(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,s=!0}if(!s){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const n of e)if(t[n]!==r[n]){s=!0;break}}s&&(this.needsFullRebuild=!0)}}function it(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 ot(t,e=30){return Math.max((null!=t?t:4)+5,12,e)}function rt(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function st(t,e){const n=rt(t);if(!n)return!1;const i=rt(e);return!i||n.getFullYear()!==i.getFullYear()||n.getMonth()!==i.getMonth()}function lt(t){let e=t%(2*Math.PI);return 0>e&&(e+=2*Math.PI),e}function at(t,e,n,i=30,o,r=0){let s=null;if(o){const t=function(t,e,n,i,o){const r=Math.max(i,o+5,12),s=e-r,l=e+r,a=n-r,c=n+r;let u=null,d=1/0;return t.visit((t,o,r,h,f)=>{if(o>l||s>h||r>c||a>f)return!0;if(!t.length){let o=t;do{const t=o.data,r=t.x-e,s=t.y-n,l=Math.sqrt(r*r+s*s);ot(t.r,i)>=l&&d>l&&(u=t,d=l),o=o.next}while(o)}return!1}),u?{node:u,distance:d}:null}(o,e,n,i,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(o)break;t=ut(r,e,n,i);break;case"line":t=dt(r,e,n,i);break;case"rect":t=ft(r,e,n);break;case"heatcell":t=gt(r,e,n);break;case"area":if(!1===r.interactive)break;t=pt(r,e,n);break;case"candlestick":t=yt(r,e,n)}t&&i>t.distance&&(s&&t.distance>=s.distance||(s=t))}return s}function ct(t,e,n){if(0===t.length)return null;const i=vt(t,e);if(0>i)return null;if(Math.abs(t[i][0]-e)>n)return null;let o=i,r=i;i>0&&t[i][0]>=e?(o=i-1,r=i):t.length-1>i&&(o=i,r=i+1);const[s,l]=t[o],[a,c]=t[r];return a===s?l:l+Math.max(0,Math.min(1,(e-s)/(a-s)))*(c-l)}function ut(t,e,n,i=30){const o=e-t.x,r=n-t.y,s=Math.sqrt(o*o+r*r);return s>ot(t.r,i)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function dt(t,e,n,i=30){var o,r,s,l;if(0===t.path.length)return null;const a=vt(t.path,e);if(0>a)return null;const[c,u]=t.path[a];let d;if(t.path.length>1){let i=1/0;const o=Math.max(0,a-1),r=Math.min(t.path.length-2,a);for(let s=o;r>=s;s++){const[o,r]=t.path[s],[l,a]=t.path[s+1],c=ht(e,n,o,r,l,a);i>c&&(i=c)}d=i}else{const t=e-c,i=n-u;d=Math.sqrt(t*t+i*i)}const h=null!==(l=null!==(r=null===(o=t.style)||void 0===o?void 0:o.strokeWidth)&&void 0!==r?r:null===(s=t.style)||void 0===s?void 0:s.lineWidth)&&void 0!==l?l:1;return d>Math.max(5,h/2+2,i)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[a]?t.datum[a]:t.datum,x:c,y:u,distance:d}}function ht(t,e,n,i,o,r){const s=o-n,l=r-i,a=s*s+l*l;if(0===a)return Math.sqrt(Math.pow(t-n,2)+Math.pow(e-i,2));let c=((t-n)*s+(e-i)*l)/a;c=Math.max(0,Math.min(1,c));const u=i+c*l;return Math.sqrt(Math.pow(t-(n+c*s),2)+Math.pow(e-u,2))}function ft(t,e,n){const i=it(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function gt(t,e,n){const i=it(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function yt(t,e,n){const i=t.bodyWidth/2,o=Math.min(t.openY,t.closeY);if(!(t.x-i-3>e||e>t.x+i+3||t.highY-3>n||n>t.lowY+3)){const i=o+Math.max(Math.max(t.openY,t.closeY)-o,1)/2,r=e-t.x,s=n-i;return{node:t,datum:t.datum,x:t.x,y:i,distance:Math.sqrt(r*r+s*s)}}return null}function pt(t,e,n){if(0===t.topPath.length)return null;const i=vt(t.topPath,e);if(0>i)return null;const[o,r]=t.topPath[i],s=e-o,l=n-r,a=Math.sqrt(s*s+l*l);return{node:t,datum:Array.isArray(t.datum)&&t.datum[i]?t.datum[i]:t.datum,x:o,y:r,distance:a}}function vt(t,e){if(0===t.length)return-1;let n=0,i=t.length-1;for(;i>n;){const o=n+i>>1;e>t[o][0]?n=o+1:i=o}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}function mt(t){var e,n;const i=new Map;for(const n of t){const t=null!==(e=n.group)&&void 0!==e?e:"_default";let o=i.get(t);o||(o=[],i.set(t,o)),o.push(n)}for(const t of i.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 o=Array.from(i.keys()).sort((t,e)=>{const n=i.get(t),o=i.get(e);return(n.length>0?n[0].y:0)-(o.length>0?o[0].y:0)}),r=Array.from(i.values()).flat();r.sort((t,e)=>t.x-e.x||t.y-e.y);const s=new Map;for(let t=0;r.length>t;t++){r[t]._flatIndex=t;const e=null===(n=r[t].datum)||void 0===n?void 0:n.id;null!=e&&s.set(e+"",t)}return{flat:r,groups:o,byGroup:i,idToIdx:s}}function xt(t,e){var n,i;if(0===t.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const o=Math.max(0,Math.min(e,t.flat.length-1)),r=t.flat[o];return{flatIndex:o,group:null!==(n=r.group)&&void 0!==n?n:"_default",indexInGroup:null!==(i=r._groupIndex)&&void 0!==i?i:0}}function bt(t,e,n){const{group:i,indexInGroup:o}=e,r=n.byGroup.get(i);switch(t){case"ArrowRight":return r.length-1>o?r[o+1]._flatIndex:e.flatIndex;case"ArrowLeft":return o>0?r[o-1]._flatIndex:e.flatIndex;case"ArrowDown":{const t=n.groups.indexOf(i);return n.groups.length-1>t?kt(n,n.groups[t+1],r[o]):e.flatIndex}case"ArrowUp":{const t=n.groups.indexOf(i);return t>0?kt(n,n.groups[t-1],r[o]):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}}function kt(t,e,n){const i=t.byGroup.get(e);let o=0,r=Math.abs(i[0].x-n.x);for(let t=1;i.length>t;t++){const e=Math.abs(i[t].x-n.x);r>e&&(r=e,o=t)}return i[o]._flatIndex}function wt(t){const e=t.datum||{};return Object.assign(Object.assign({},"object"!=typeof e||null===e||Array.isArray(e)?{}:e),{data:e,x:t.x,y:t.y,time:t.x,value:t.y})}function At(t,n,i,o,r,s){e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{var e;const l=n.current;if(!l||0===l.lastIngestTime)return;const a="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(e=t.threshold)&&void 0!==e?e:5e3,u=a-l.lastIngestTime>c;u!==r&&(s(u),i.current=!0,o())},1e3);return()=>clearInterval(e)},[t,r,o])}nt.GROUP_COLOR_MAP_CAP=1e3,nt.QUADTREE_THRESHOLD=500;const St={fill:e=>t.jsx("rect",{style:e,width:16,height:16}),line:e=>t.jsx("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function Mt(t,e,n,i){let o;return o="function"==typeof n?n(t):(0,St[n])(i(t,e)),o}function _t(){return t.jsx("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function jt(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}const Pt=(e,n,i,o,r,s,l,a,c,u)=>{const{type:d="fill",styleFn:h,items:f}=e,g=[];let y=0;const p=!(!n&&!i),v="isolate"===u||void 0===u&&null!=r;return f.forEach((e,u)=>{const m=Mt(e,u,d,h),x=jt(e,o,r),b=r&&r.size>0&&r.has(e.label);g.push(t.jsxs("g",{transform:`translate(0,${y})`,onClick:n?()=>n(e):void 0,onMouseEnter:i?()=>i(e):void 0,onMouseLeave:i?()=>i(null):void 0,tabIndex:p?a===s&&u===l?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&v?b||!1:void 0,"aria-current":p&&!v&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:p?t=>{var i;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),n&&n(e)),"ArrowDown"===t.key||"ArrowUp"===t.key){t.preventDefault();const e=(u+("ArrowDown"===t.key?1:-1)+f.length)%f.length;c(a,e);const n=null===(i=t.currentTarget.parentElement)||void 0===i?void 0:i.children[e];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:p?t=>{c(a,u),i&&i(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:p?t=>{i&&i(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:p?"pointer":"default",opacity:x,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[p&&t.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),m,b&&t.jsx(_t,{}),t.jsx("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+u)),y+=22}),g};function Ct({config:e,orientation:n="vertical",width:i=100}){const{colorFn:o,domain:r,label:s,format:l}=e,a=l||(t=>Math.round(100*t)/100+""),c="grad-legend-"+p.useId();if("horizontal"===n){const e=12,n=Math.min(i,200),l=Math.max(0,(i-n)/2),u=[];for(let e=0;64>=e;e++){const n=e/64;u.push(t.jsx("stop",{offset:100*n+"%",stopColor:o(r[0]+n*(r[1]-r[0]))},e))}return t.jsxs("g",{"aria-label":s||"Gradient legend",children:[t.jsx("defs",{children:t.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:u})}),s&&t.jsx("text",{x:l+n/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),t.jsx("rect",{x:l,y:0,width:n,height:e,fill:`url(#${c})`,rx:2}),t.jsx("text",{x:l,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[0])}),t.jsx("text",{x:l+n,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[1])})]})}const u=[];for(let e=0;64>=e;e++){const n=e/64;u.push(t.jsx("stop",{offset:100*n+"%",stopColor:o(r[1]-n*(r[1]-r[0]))},e))}return t.jsxs("g",{"aria-label":s||"Gradient legend",children:[s&&t.jsx("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),t.jsx("defs",{children:t.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:u})}),t.jsx("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),t.jsx("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[1])}),t.jsx("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[0])})]})}function Et(e){const{legendGroups:n,customClickBehavior:i,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:s,legendInteraction:l,title:a="Legend",width:c=100,height:u=20,orientation:d="vertical"}=e,[h,f]=p.useState(0),[g,y]=p.useState(0),v=p.useCallback((t,e)=>{f(t),y(e)},[]),m="vertical"===d?(({legendGroups:e,width:n,customClickBehavior:i,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:l,focusedItemIndex:a,onFocusedIndexChange:c,legendInteraction:u})=>{let d=24;const h=[];return e.forEach((e,f)=>{d+=5,h.push(t.jsx("line",{stroke:"gray",x1:0,y1:d,x2:n,y2:d},"legend-top-line legend-symbol-"+f)),d+=8,e.label&&(d+=16,h.push(t.jsx("text",{y:d,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+f)),d+=8),h.push(t.jsx("g",{className:"legend-item",transform:`translate(0,${d})`,children:Pt(e,i,o,r,s,l,a,f,c,u)},"legend-group-"+f)),d+=22*e.items.length+8}),h})({legendGroups:n||[],width:c,customClickBehavior:i,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:v,legendInteraction:l}):(({legendGroups:e,height:n,width:i,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:s,isolatedCategories:l,focusedGroupIndex:a,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:d})=>{let h=0;const f=[];e.forEach((e,n)=>{let g=0;e.label&&(g+=16);const y=((e,n,i,o,r,s,l,a,c,u,d)=>{const{type:h="fill",styleFn:f,items:g}=e,y=[];let p=0,v=0;const m=!(!n&&!i),x="isolate"===u||void 0===u&&null!=r;g.forEach((e,u)=>{const b=Mt(e,u,h,f),k=jt(e,o,r),w=r&&r.size>0&&r.has(e.label),A=26+7*e.label.length;d&&d>0&&p>0&&p+A>d&&(v++,p=0),y.push(t.jsxs("g",{transform:`translate(${p},${22*v})`,onClick:n?()=>n(e):void 0,onMouseEnter:i?()=>i(e):void 0,onMouseLeave:i?()=>i(null):void 0,tabIndex:m?a===s&&u===l?0:-1:void 0,role:m?"option":void 0,"aria-selected":m&&x?w||!1:void 0,"aria-current":m&&!x&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:m?t=>{var i;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),n&&n(e)),"ArrowRight"===t.key||"ArrowLeft"===t.key){t.preventDefault();const e=(u+("ArrowRight"===t.key?1:-1)+g.length)%g.length;c(a,e);const n=null===(i=t.currentTarget.parentElement)||void 0===i?void 0:i.children[e];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:m?t=>{c(a,u),i&&i(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:m?t=>{i&&i(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:m?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[m&&t.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),b,w&&t.jsx(_t,{}),t.jsx("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+u)),p+=A});let b=0,k=0;for(const t of g){const e=26+7*t.label.length;d&&d>0&&k>0&&k+e>d?(b=Math.max(b,k),k=e):k+=e}b=Math.max(b,k);const w=v+1;return{items:y,offset:b,totalRows:w,totalHeight:22*w}})(e,o,r,s,l,a,c,n,u,d,i);g+=y.offset+5,f.push(Object.assign(Object.assign({label:e.label},y),{offset:g,totalRows:y.totalRows,totalHeight:y.totalHeight})),h+=g+12});let g=h>i?0:Math.max(0,(i-h)/2);const y=[];return f.forEach((i,o)=>{const r=e[o];r.label&&(y.push(t.jsx("text",{transform:`translate(${g},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:r.label},"legend-text-"+o)),g+=16),y.push(t.jsx("g",{className:"legend-item",transform:`translate(${g},0)`,children:i.items},"legend-group-"+o)),g+=i.offset+5,e[o+1]&&y.push(t.jsx("line",{stroke:"gray",x1:g,y1:-8,x2:g,y2:(i.totalHeight||n)+0+8},"legend-top-line legend-symbol-"+o)),g+=12}),t.jsx("g",{children:y})})({legendGroups:n||[],title:a,height:u,width:c,customClickBehavior:i,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:v,legendInteraction:l}),x=!(!i&&!o);return t.jsxs("g",{role:x?"listbox":void 0,"aria-multiselectable":!(!x||"isolate"!==l&&(void 0!==l||null==s))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==a&&""!==a&&"vertical"===d&&t.jsx("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:a}),m]})}function Tt(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}function Dt(t){return"object"==typeof t&&null!==t&&"gradient"in t}function Lt(e){const{legend:n,totalWidth:i,totalHeight:o,margin:r,legendPosition:s="right",title:l,legendHoverBehavior:a,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=e;if(!n)return null;const f="top"===s||"bottom"===s;let g,y;return"left"===s?(g=4,y=r.top):"top"===s?(g=0,y=l?32:8):"bottom"===s?(g=0,y=o-r.bottom+50):(g=i-r.right+10,y=r.top),t.jsx("g",{transform:`translate(${g}, ${y})`,children:Dt(n)?t.jsx(Ct,{config:n.gradient,orientation:f?"horizontal":"vertical",width:f?i:100}):Tt(n)?t.jsx(Et,{legendGroups:n.legendGroups,title:"",width:f?i:100,orientation:f?"horizontal":"vertical",customHoverBehavior:a,customClickBehavior:c,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):n})}function Ot(t){return"string"==typeof t?{type:t}:t}function Nt({orient:n,config:i,values:o,scale:r,size:s,length:a}){const c=function(t){var e,n,i,o,r;return{type:t.type,bins:null!==(e=t.bins)&&void 0!==e?e:20,fill:null!==(n=t.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(i=t.fillOpacity)&&void 0!==i?i:.5,stroke:null!==(o=t.stroke)&&void 0!==o?o:"none",strokeWidth:null!==(r=t.strokeWidth)&&void 0!==r?r:1}}(i),u="top"===n||"bottom"===n,d=e.useMemo(()=>{if(0===o.length)return null;const e=r.domain(),i=s-8;if("boxplot"===c.type){const e=function(t){const e=[...t].sort((t,e)=>t-e),n=e.length;if(0===n)return null;const i=e[Math.floor(.25*n)],o=e[Math.floor(.5*n)],r=e[Math.floor(.75*n)],s=r-i;return{q1:i,median:o,q3:r,whiskerLow:Math.max(e[0],i-1.5*s),whiskerHigh:Math.min(e[n-1],r+1.5*s)}}(o);if(!e)return null;const{q1:s,median:l,q3:a,whiskerLow:d,whiskerHigh:h}=e,f=Math.min(.5*i,20),g=(i-f)/2+4;if(u){const e=r(s),i=r(a),o=r(l),u=r(d),y=r(h),p="top"===n?-1:1,v=0;return t.jsxs("g",{"data-testid":"marginal-boxplot-"+n,children:[t.jsx("line",{x1:u,y1:v+p*(g+f/2),x2:y,y2:v+p*(g+f/2),stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:u,y1:v+p*g,x2:u,y2:v+p*(g+f),stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:y,y1:v+p*g,x2:y,y2:v+p*(g+f),stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("rect",{x:Math.min(e,i),y:"top"===n?v-g-f:v+g,width:Math.abs(i-e),height:f,fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:o,y1:"top"===n?v-g-f:v+g,x2:o,y2:"top"===n?v-g:v+g+f,stroke:c.fill,strokeWidth:2})]})}{const e=r(s),i=r(a),o=r(l),u=r(d),y=r(h),p="left"===n?-1:1,v=0;return t.jsxs("g",{"data-testid":"marginal-boxplot-"+n,children:[t.jsx("line",{x1:v+p*(g+f/2),y1:u,x2:v+p*(g+f/2),y2:y,stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:v+p*g,y1:u,x2:v+p*(g+f),y2:u,stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:v+p*g,y1:y,x2:v+p*(g+f),y2:y,stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("rect",{x:"left"===n?v-g-f:v+g,y:Math.min(e,i),width:f,height:Math.abs(i-e),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:"left"===n?v-g-f:v+g,y1:o,x2:"left"===n?v-g:v+g+f,y2:o,stroke:c.fill,strokeWidth:2})]})}}const d=l.bin().domain(e).thresholds(c.bins)(o);if(0===d.length)return null;const h=Math.max(...d.map(t=>t.length));if(0===h)return null;if("histogram"===c.type)return t.jsx("g",{"data-testid":"marginal-histogram-"+n,children:d.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const s=e.length/h*i;if(u){const i=r(e.x0),l=r(e.x1)-r(e.x0);return t.jsx("rect",{x:i,y:"top"===n?-4-s:4,width:Math.max(l,.5),height:s,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},o)}{const i=r(e.x0),l=r(e.x1)-r(e.x0);return t.jsx("rect",{x:"left"===n?-4-s:4,y:Math.min(i,i+l),width:s,height:Math.abs(l),fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},o)}})});if("violin"===c.type){const e=i/2+4,o=[];for(const t of d){if(null==t.x0||null==t.x1)continue;const s=t.length/h*(i/2),l=r((t.x0+t.x1)/2);o.push(u?`${l},${"top"===n?-(e-s):e-s}`:`${"left"===n?-(e-s):e-s},${l}`)}for(let t=d.length-1;t>=0;t--){const s=d[t];if(null==s.x0||null==s.x1)continue;const l=s.length/h*(i/2),a=r((s.x0+s.x1)/2);o.push(u?`${a},${"top"===n?-(e+l):e+l}`:`${"left"===n?-(e+l):e+l},${a}`)}return t.jsx("g",{"data-testid":"marginal-violin-"+n,children:t.jsx("polygon",{points:o.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}if("ridgeline"===c.type){const e=[];if(u){const t=0,o=null!=d[0].x0?r(d[0].x0):0;e.push(`M${o},${t}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const o=t.length/h*i,s=r((t.x0+t.x1)/2);e.push(`L${s},${"top"===n?-o-4:o+4}`)}const s=null!=d[d.length-1].x1?r(d[d.length-1].x1):a;e.push(`L${s},${t}`),e.push("Z")}else{const t=0,o=null!=d[0].x0?r(d[0].x0):0;e.push(`M${t},${o}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const o=t.length/h*i,s=r((t.x0+t.x1)/2);e.push(`L${"left"===n?-o-4:o+4},${s}`)}const s=null!=d[d.length-1].x1?r(d[d.length-1].x1):a;e.push(`L${t},${s}`),e.push("Z")}return t.jsx("g",{"data-testid":"marginal-ridgeline-"+n,children:t.jsx("path",{d:e.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}return null},[o,r,c,s,a,n,u,4]);return d?t.jsx("g",{className:"marginal-"+n,"data-testid":"marginal-"+n,children:d}):null}function $t(t,e=120,n=8){if(!t)return[];const i=Math.max(1,Math.floor(e/n)),o=t.split(/\s+/),r=[];let s="";for(const t of o)s&&s.length+1+t.length>i?(r.push(s),s=t):s=s?`${s} ${t}`:t;return s&&r.push(s),r}function It(t,e,n,i){return"curly"===t?i?`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`:i?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function Wt(e,n,i,o){if(!e)return t.jsx("g",{className:"annotation-note"});const{label:r,title:s,orientation:l,align:a,wrap:c=120,noWrap:u}=e;if(!r&&!s)return t.jsx("g",{className:"annotation-note"});let d=l;d||(d=Math.abs(n)>Math.abs(i)?"leftRight":"topBottom");let h=a;h&&"dynamic"!==h||(h="topBottom"===d?0>n?"right":"left":0>i?"bottom":"top");let f="start";"topBottom"===d?"right"===h?f="end":"middle"===h&&(f="middle"):f=0>n?"end":"start";const g=16,y=s?u?[s]:$t(s,c):[],p=r?u?[r]:$t(r,c):[],v="leftRight"===d?"end"===f?-4:4:0;let m=0;const x=[],b=o||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";y.length>0&&(x.push(t.jsx("text",{className:"annotation-note-title",fill:b,textAnchor:f,fontWeight:"bold",children:y.map((e,n)=>t.jsx("tspan",{x:v,dy:0===n?0:g,children:e},n))},"annotation-note-title")),m=y.length*g),p.length>0&&x.push(t.jsx("text",{className:"annotation-note-label",fill:b,textAnchor:f,y:m,children:p.map((e,n)=>t.jsx("tspan",{x:v,dy:0===n?0:g,children:e},n))},"annotation-note-label"));let k=null;if((s||r)&&(0!==n||0!==i))if("topBottom"===d){const e=Math.min(c,120);let n=0,i=e;"end"===f?(n=-e,i=0):"middle"===f&&(n=-e/2,i=e/2),k=t.jsx("line",{className:"note-line",x1:n,x2:i,y1:0,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(y.length+p.length)*g+(p.length>0?g:0);let n=0,i=e;"bottom"===h?(n=-e,i=0):"middle"===h&&(n=-e/2,i=e/2),k=t.jsx("line",{className:"note-line",x1:0,x2:0,y1:n,y2:i,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,y.length+p.length-1)*g;let A=0;return"topBottom"===d?A=0>i?-(w+2):18:"leftRight"===d&&(A="middle"===h?-(w+g+(p.length>0&&y.length>0?2:0))/2+8:"bottom"===h||0>i?-(w+2):18),t.jsxs("g",{className:"annotation-note",transform:`translate(${n},${i})`,children:[t.jsx("g",{className:"annotation-note-content",transform:0!==A?`translate(0,${A})`:void 0,children:x}),k]})}function Rt(e,n,i,o,r){var s;const l=[];switch(e){case"callout-circle":{const e=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);e>0&&l.push(t.jsx("circle",{r:e,fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=(null==n?void 0:n.width)||0,o=(null==n?void 0:n.height)||0;(e>0||o>0)&&l.push(t.jsx("rect",{width:e,height:o,fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":(null==n?void 0:n.custom)&&l.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const e=o||0,s=r||0;if(void 0!==(null==n?void 0:n.x)){const o=(n.x||0)-e;l.push(t.jsx("line",{x1:o,y1:(n.y1||0)-s,x2:o,y2:(n.y2||0)-s,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==(null==n?void 0:n.y)){const o=(n.y||0)-s;l.push(t.jsx("line",{x1:(n.x1||0)-e,y1:o,x2:(n.x2||0)-e,y2:o,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?l.push(t.jsx("line",{x1:(n.x1||0)-e,y1:0,x2:(n.x2||0)-e,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||l.push(t.jsx("line",{x1:0,y1:(n.y1||0)-s,x2:0,y2:(n.y2||0)-s,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=null!==(s=null==n?void 0:n.width)&&void 0!==s?s:null==n?void 0:n.height;void 0!==e&&l.push(t.jsx("path",{d:It((null==n?void 0:n.type)||"curly",e,(null==n?void 0:n.depth)||30,void 0===(null==n?void 0:n.width)),fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return t.jsx("g",{className:"annotation-subject",children:l})}function zt(e,n,i,o,r,s){const l=[];let a=0,c=0;if("callout-circle"!==r&&"label"!==r||!(null==s?void 0:s.radius)){if("callout-rect"===r&&s){const t=s.width||0,i=s.height||0;if(t>0||i>0){const o=t/2,r=i/2,s=e-o,l=n-r;if(0!==s||0!==l){const e=Math.abs(s),n=Math.abs(l),u=t/2,d=i/2,h=e*d>n*u?u/e:d/n;a=o+s*h,c=r+l*h}}}else if("bracket"===r&&s){const t=s.width,e=s.height,n=s.depth||30;void 0!==t?(a=t/2,c=n):void 0!==e&&(a=n,c=e/2)}}else{const t=(s.radius||0)+(s.radiusPadding||0);if(t>0&&(0!==e||0!==n)){const i=Math.atan2(n,e);a=Math.cos(i)*t,c=Math.sin(i)*t}}if(Math.sqrt(Math.pow(e-a,2)+Math.pow(n-c,2))>.5&&(l.push(t.jsx("line",{x1:a,y1:c,x2:e,y2:n,stroke:o||"var(--semiotic-text-secondary, currentColor)"},"connector-line")),"arrow"===(null==i?void 0:i.end))){const i=10,r=16/180*Math.PI,s=Math.atan2(n-c,e-a);l.push(t.jsx("path",{d:`M${a},${c}L${a+i*Math.cos(s+r)},${c+i*Math.sin(s+r)}L${a+i*Math.cos(s-r)},${c+i*Math.sin(s-r)}Z`,fill:o||"var(--semiotic-text-secondary, currentColor)",stroke:"none"},"connector-arrow"))}return t.jsx("g",{className:"annotation-connector",children:l})}function Yt(e){const{x:n=0,y:i=0,dx:o,dy:r,nx:s,ny:l,note:a,connector:c,subject:u,type:d,color:h,className:f,disable:g,events:y={},"data-testid":p}=e,v=new Set(Array.isArray(g)?g:[]);let m=o||0,x=r||0;null!=s&&(m=s-n),null!=l&&(x=l-i);const b="string"==typeof d?d:"label";if("bracket"===b&&u&&0===m&&0===x)if(void 0!==u.width){m=u.width/2;const t=u.depth||30;x=t+(0>t?-5:5)}else if(void 0!==u.height){const t=u.depth||30;m=t+(0>t?-5:5),x=u.height/2}return t.jsxs("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${n},${i})`,"data-testid":p},y,{children:[!v.has("connector")&&zt(m,x,c,h,b,u),!v.has("subject")&&Rt(b,u,h,n,i),!v.has("note")&&Wt(a,m,x,h)]}))}function Bt(e){var n,i;const{noteData:o}=e,{screenCoordinates:r}=o,s="string"==typeof o.type?o.type:"label",l=o.eventListeners||o.events||{};if(o.coordinates&&r){const e=o.nx||r[0][0]+(null!==(n=o.dx)&&void 0!==n?n:0),l=o.ny||r[0][1]+(null!==(i=o.dy)&&void 0!==i?i:0),a=r.map((n,i)=>{const r=Object.assign({},o,{note:0===i?o.note:{label:""},x:n[0],y:n[1],nx:e,ny:l});return t.jsx(Yt,Object.assign({"data-testid":"semiotic-annotation"},r,{type:s}),"multi-annotation-"+i)});return t.jsx("g",{children:a})}const a=o.note||{title:"none",label:o.label},c=`${a.label}-${a.title}-${o.i}`;return t.jsx(Yt,Object.assign({"data-testid":"semiotic-annotation",events:l},o,{type:s}),c)}function Ft(t,e){var n,i,o;const r=null!==(i=null===(n=e.scales)||void 0===n?void 0:n.x)&&void 0!==i?i:null===(o=e.scales)||void 0===o?void 0:o.time;return r?null!=t.x?r(t.x):e.xAccessor&&null!=t[e.xAccessor]?r(t[e.xAccessor]):null:null}function Ht(t,e){var n,i,o;const r=null!==(i=null===(n=e.scales)||void 0===n?void 0:n.y)&&void 0!==i?i:null===(o=e.scales)||void 0===o?void 0:o.value;return r?null!=t.y?r(t.y):e.yAccessor&&null!=t[e.yAccessor]?r(t[e.yAccessor]):null:null}function Xt(t,e,n){var i,o,r,s;const l=t.anchor||"fixed";if("latest"===l){if(null!=t.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const r=n.pointNodes[o];if(r.pointId===t.pointId){const t={x:r.x,y:r.y};return null===(i=n.stickyPositionCache)||void 0===i||i.set(e,t),t}}const r=function(t){var e,n,i,o,r,s;const l=t.data;if(!l||0===l.length)return null;const a=l[l.length-1],c=null!==(n=null===(e=t.scales)||void 0===e?void 0:e.x)&&void 0!==n?n:null===(i=t.scales)||void 0===i?void 0:i.time,u=null!==(r=null===(o=t.scales)||void 0===o?void 0:o.y)&&void 0!==r?r:null===(s=t.scales)||void 0===s?void 0:s.value;if(!c||!u)return null;const d=a[t.xAccessor||"x"],h=a[t.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return r&&(null===(o=n.stickyPositionCache)||void 0===o||o.set(e,r)),r}let a=null,c=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);e&&(a=e.x,c=e.y)}if(null!=a&&null!=c||(a=Ft(t,n),c=Ht(t,n)),null!=a&&null!=c)return null===(r=n.stickyPositionCache)||void 0===r||r.set(e,{x:a,y:c}),{x:a,y:c};if("sticky"===l){const t=null===(s=n.stickyPositionCache)||void 0===s?void 0:s.get(e);if(t)return t}return null}function Gt(t,e,n,i=50){return!(-i>t||t>(n.width||0)+i||-i>e||e>(n.height||0)+i)}const Vt={linear:c.curveLinear,monotoneX:c.curveMonotoneX,monotoneY:c.curveMonotoneY,step:c.curveStep,stepAfter:c.curveStepAfter,stepBefore:c.curveStepBefore,basis:c.curveBasis,cardinal:c.curveCardinal,catmullRom:c.curveCatmullRom};let qt={positions:new Map};const Ut=new Set;function Kt(){for(const t of Ut)t()}function Zt(t,e){const n=qt.positions.get(t);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==e)return;const i=new Map(qt.positions);i.delete(t),qt={positions:i},Kt()}function Qt(t,e){const n=qt.positions.get(t);if(!(null==n?void 0:n.locked))return;if(e&&n.sourceId!==e)return;const i=new Map(qt.positions);i.delete(t),qt={positions:i},Kt()}function Jt(){return qt}function te(t){return Ut.add(t),()=>Ut.delete(t)}const ee={positions:new Map};function ne(){return()=>{}}function ie(){return ee}function oe(t){if(t)return"dashed"===t?"6,4":"dotted"===t?"2,4":t}function re(t,e,n){if("left"===t||"right"===t){const i="left"===t?n:0,o="left"===t?-1:1,r=Math.ceil(e/8);let s="M0,"+i;for(let t=0;r>t;t++){const n=8*(t+1);s+=`L${Math.min(8*t+4,e)},${i+4*o}`,s+=`L${Math.min(n,e)},${i}`}return s}{const i="bottom"===t?0:e,o="bottom"===t?1:-1,r=Math.ceil(n/8);let s=`M${i},0`;for(let t=0;r>t;t++){const e=8*(t+1);s+=`L${i+4*o},${Math.min(8*t+4,n)}`,s+=`L${i},${Math.min(e,n)}`}return s}}function se(n){const{width:i,height:o,totalWidth:r,totalHeight:s,margin:l,scales:a,showAxes:c,axes:u,showGrid:d,xFormat:h,yFormat:f}=n,g=e.useMemo(()=>{var t;if(!a)return[];const e=null==u?void 0:u.find(t=>"bottom"===t.orient),n=(null==e?void 0:e.tickFormat)||h||le,o=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,r=a.x.ticks(Math.min(o,Math.max(2,Math.floor(i/70)))),s=r.map(t=>t.valueOf()),l=r.map((t,e)=>({value:t,pixel:a.x(t),label:n(t,e,s)})),c=l.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0);return ae(l,Math.max(55,c+8))},[a,u,h,i]),y=e.useMemo(()=>{var t;if(!a)return[];const e=null==u?void 0:u.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||f||le,i=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return ae(a.y.ticks(Math.min(i,Math.max(2,Math.floor(o/30)))).map(t=>({value:t,pixel:a.y(t),label:n(t)})),22)},[a,u,f,o]),p=d&&a,v=c&&a;if(!p&&!v)return null;const m=null==u?void 0:u.find(t=>"bottom"===t.orient),x=null==u?void 0:u.find(t=>"left"===t.orient),b=v&&(!m||!1!==m.baseline),k=v&&(!x||!1!==x.baseline),w=(null==m?void 0:m.jaggedBase)||!1,A=(null==x?void 0:x.jaggedBase)||!1,S="var(--semiotic-border, #ccc)";return t.jsx("svg",{width:r,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:t.jsxs("g",{transform:`translate(${l.left},${l.top})`,children:[p&&(()=>{var e,n;const r=oe(null===(e=null==u?void 0:u.find(t=>"bottom"===t.orient))||void 0===e?void 0:e.gridStyle),s=oe(null===(n=null==u?void 0:u.find(t=>"left"===t.orient))||void 0===n?void 0:n.gridStyle);return t.jsxs("g",{className:"stream-grid",children:[g.map((e,n)=>t.jsx("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"xgrid-"+n)),y.map((e,n)=>t.jsx("line",{x1:0,y1:e.pixel,x2:i,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:s},"ygrid-"+n))]})})(),b&&!w&&t.jsx("line",{x1:0,y1:o,x2:i,y2:o,stroke:S,strokeWidth:1}),w&&t.jsx("path",{d:re("bottom",i,o),fill:"none",stroke:S,strokeWidth:1}),k&&!A&&t.jsx("line",{x1:0,y1:0,x2:0,y2:o,stroke:S,strokeWidth:1}),A&&t.jsx("path",{d:re("left",i,o),fill:"none",stroke:S,strokeWidth:1})]})})}function le(t,e,n){return t instanceof Date?`${t.toLocaleString("en",{month:"short"})} ${t.getDate()}`:"number"==typeof t?Math.round(100*t)/100+"":t+""}function ae(t,e){if(2>=t.length)return t;const n=[t[0]];for(let i=1;t.length-1>i;i++)e>Math.abs(t[i].pixel-n[n.length-1].pixel)||n.push(t[i]);const i=t[t.length-1];return e>Math.abs(i.pixel-n[n.length-1].pixel)?n[n.length-1]=i:n.push(i),n}function ce(n){var i,o;const{width:r,height:s,totalWidth:l,totalHeight:u,margin:d,scales:h,showAxes:f,axes:g,xLabel:y,yLabel:p,yLabelRight:m,xFormat:x,yFormat:b,showGrid:k,title:w,legend:A,legendHoverBehavior:S,legendClickBehavior:M,legendHighlightedCategory:_,legendIsolatedCategories:j,legendPosition:P="right",foregroundGraphics:C,marginalGraphics:E,xValues:T,yValues:D,annotations:L,svgAnnotationRules:O,xAccessor:N,yAccessor:$,annotationData:I,pointNodes:W,curve:R,underlayRendered:z,linkedCrosshairName:Y,linkedCrosshairSourceId:B,children:F}=n,H=e.useMemo(()=>{var t;if(!f||!h)return[];const e=null==g?void 0:g.find(t=>"bottom"===t.orient),n=(null==e?void 0:e.tickFormat)||x||le,i=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,o=h.x.ticks(Math.min(i,Math.max(2,Math.floor(r/70)))),s=o.map(t=>t.valueOf()),l=o.map((t,e)=>({value:t,pixel:h.x(t),label:n(t,e,s)})),a=l.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0),c=(null==e?void 0:e.autoRotate)?Math.max(20,Math.min(a+8,55)):Math.max(55,a+8);let u=ae(l,c);if(u.length>1&&(u=u.filter((t,e)=>0===e||t.label+""!=u[e-1].label+"")),(null==e?void 0:e.includeMax)&&u.length>0){const t=h.x.domain()[1],e=h.x(t),i=u[u.length-1].pixel;if(Math.abs(e-i)>1){const o=n(t,u.length,s);c>e-i&&u.length>1&&(u=u.slice(0,-1)),u.push({value:t,pixel:e,label:o})}}return u},[f,h,g,x,r]),X=e.useMemo(()=>{var t;if(!f||!h)return[];const e=null==g?void 0:g.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||b||le,i=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;let o=ae(h.y.ticks(Math.min(i,Math.max(2,Math.floor(s/30)))).map(t=>({value:t,pixel:h.y(t),label:n(t)})),22);if(o.length>1&&(o=o.filter((t,e)=>0===e||t.label+""!=o[e-1].label+"")),(null==e?void 0:e.includeMax)&&o.length>0){const t=h.y.domain()[1],e=h.y(t),i=o[o.length-1].pixel;if(Math.abs(e-i)>1){const r=n(t);22>Math.abs(e-i)&&o.length>1&&(o=o.slice(0,-1)),o.push({value:t,pixel:e,label:r})}}return o},[f,h,g,b,s]),G=e.useMemo(()=>{var t;if(!f||!h)return[];const e=null==g?void 0:g.find(t=>"right"===t.orient);if(!e)return[];const n=e.tickFormat||b||le,i=null!==(t=e.ticks)&&void 0!==t?t:5;return ae(h.y.ticks(Math.min(i,Math.max(2,Math.floor(s/30)))).map(t=>({value:t,pixel:h.y(t),label:n(t)})),22)},[f,h,g,b,s]),V=e.useRef(new Map),q=e.useRef(null!==(i=null==L?void 0:L.length)&&void 0!==i?i:0),U=null!==(o=null==L?void 0:L.length)&&void 0!==o?o:0;q.current!==U&&(q.current=U,V.current=new Map);const K=e.useMemo(()=>{if(!L||0===L.length)return null;const e=function(e,n,i){var o,r,s,l,u,d,h,f,g,y,p,m,x,b,k,w,A,S,M,_,j,P,C,E,T,D,L,O,N,$,I,W,R,z,Y,B,F,H,X,G,V,q,U,K,Z,Q,J,tt;switch(e.type){case"label":{const o=Xt(e,n,i);if(!o)return null;const{x:r,y:s}=o;return Gt(r,s,i)?t.jsx(Bt,{noteData:{x:r,y:s,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"label",connector:e.connector||{end:"arrow"},color:e.color}},"ann-"+n):null}case"callout":{const o=Xt(e,n,i);if(!o)return null;const{x:r,y:s}=o;return Gt(r,s,i)?t.jsx(Bt,{noteData:{x:r,y:s,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"callout-circle",subject:{radius:e.radius||12},connector:e.connector||{end:"arrow"},color:e.color}},"ann-"+n):null}case"x-threshold":{const o=Ft(e,i);if(null==o)return null;const r=e.color||"#f97316",s=e.labelPosition||"top";let l;return l="bottom"===s?(i.height||0)-4:"center"===s?(i.height||0)/2:12,t.jsxs("g",{children:[t.jsx("line",{x1:o,y1:0,x2:o,y2:i.height||0,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.jsx("text",{x:o+4,y:l,fill:r,fontSize:12,fontWeight:"bold",children:e.label})]},"ann-"+n)}case"y-threshold":{const o=Ht(e,i);if(null==o)return null;const r=e.color||"#f97316",s=e.labelPosition||"right";let l,a;return"left"===s?(l=4,a="start"):"center"===s?(l=(i.width||0)/2,a="middle"):(l=(i.width||0)-4,a="end"),t.jsxs("g",{children:[t.jsx("line",{x1:0,y1:o,x2:i.width||0,y2:o,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.jsx("text",{x:l,y:o-4,textAnchor:a,fill:r,fontSize:12,fontWeight:"bold",children:e.label})]},"ann-"+n)}case"enclose":{const o=(e.coordinates||[]).map(t=>({x:Ft(Object.assign(Object.assign({},t),{type:"point"}),i),y:Ht(Object.assign(Object.assign({},t),{type:"point"}),i),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>o.length)return null;const r=a.packEnclose(o),s=e.padding||10;return t.jsxs("g",{children:[t.jsx("circle",{cx:r.x,cy:r.y,r:r.r+s,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&t.jsx("text",{x:r.x,y:r.y-r.r-s-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:e.label})]},"ann-"+n)}case"rect-enclose":{const o=(e.coordinates||[]).map(t=>({x:Ft(Object.assign(Object.assign({},t),{type:"point"}),i),y:Ht(Object.assign(Object.assign({},t),{type:"point"}),i)})).filter(t=>null!=t.x&&null!=t.y);if(2>o.length)return null;const r=e.padding||10,s=o.map(t=>t.x),l=o.map(t=>t.y),a=Math.min(...s)-r,c=Math.max(...s)+r,u=Math.min(...l)-r,d=Math.max(...l)+r;return t.jsxs("g",{children:[t.jsx("rect",{x:a,y:u,width:c-a,height:d-u,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&t.jsx("text",{x:(a+c)/2,y:u-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:e.label})]},"ann-"+n)}case"highlight":{const o=i.data||[],r="function"==typeof e.filter?o.filter(e.filter):e.field&&null!=e.value?o.filter(t=>t[e.field]===e.value):[],s={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return t.jsx("g",{children:r.map((n,o)=>{const r=Ft(n,i),l=Ht(n,i);if(null==r||null==l)return null;const a="function"==typeof e.r?e.r(n):e.r||6,c="function"==typeof e.style?e.style(n):e.style||s;return t.jsx("circle",Object.assign({cx:r,cy:l,r:a},c),"hl-"+o)})},"ann-"+n)}case"bracket":{const o=Ft(e,i),r=Ht(e,i);return t.jsx(Bt,{noteData:{x:null!=o?o:0,y:null!=r?r:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},"ann-"+n)}case"trend":{const a=i.data||[];if(2>a.length)return null;const c=i.xAccessor||"x",f=i.yAccessor||"y",g=a.map(t=>[t[c],t[f]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>g.length)return null;const y=null!==(r=null===(o=i.scales)||void 0===o?void 0:o.x)&&void 0!==r?r:null===(s=i.scales)||void 0===s?void 0:s.time,p=null!==(u=null===(l=i.scales)||void 0===l?void 0:l.y)&&void 0!==u?u:null===(d=i.scales)||void 0===d?void 0:d.value;if(!y||!p)return null;const m=e.method||"linear";let x;x="loess"===m?function(t,e=.3){const n=t.length;if(2>n)return t.slice();const i=t.slice().sort((t,e)=>t[0]-e[0]),o=i.map(t=>t[0]),r=i.map(t=>t[1]),s=Math.max(2,Math.ceil(e*n)),l=[];for(let t=0;n>t;t++){const e=o[t],i=o.map(t=>Math.abs(t-e)),a=i.slice().sort((t,e)=>t-e)[Math.min(s-1,n-1)]||1,c=[];for(let t=0;n>t;t++){const e=0===a?0:i[t]/a;c[t]=1>e?Math.pow(1-Math.pow(e,3),3):0}let u=0,d=0,h=0,f=0,g=0;for(let t=0;n>t;t++){const e=c[t];0!==e&&(u+=e,d+=e*o[t],h+=e*r[t],f+=e*o[t]*o[t],g+=e*o[t]*r[t])}if(0===u){l.push([e,r[t]]);continue}const y=u*f-d*d;if(1e-12>Math.abs(y))l.push([e,h/u]);else{const t=(u*g-d*h)/y;l.push([e,(h-t*d)/u+t*e])}}return l}(g,null!==(h=e.bandwidth)&&void 0!==h?h:.3):("polynomial"===m?v.default.polynomial(g,{order:e.order||2}):v.default.linear(g)).points;const b=x.map(([t,e])=>`${y(t)},${p(e)}`).join(" "),k=e.color||"#6366f1";return t.jsxs("g",{children:[t.jsx("polyline",{points:b,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.jsx("text",{x:y(x[x.length-1][0])+4,y:p(x[x.length-1][1])-4,fill:k,fontSize:11,children:e.label})]},"ann-"+n)}case"band":{const o=null!==(g=null===(f=i.scales)||void 0===f?void 0:f.y)&&void 0!==g?g:null===(y=i.scales)||void 0===y?void 0:y.value,r=null!==(p=null==o?void 0:o(e.y0))&&void 0!==p?p:0,s=null!==(m=null==o?void 0:o(e.y1))&&void 0!==m?m:i.height||0;return t.jsxs("g",{children:[t.jsx("rect",{x:0,y:Math.min(r,s),width:i.width||0,height:Math.abs(s-r),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&t.jsx("text",{x:(i.width||0)-4,y:Math.min(r,s)-4,textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,children:e.label})]},"ann-"+n)}case"envelope":{const o=i.data||[];if(2>o.length)return null;const r=i.xAccessor||"x",s=null!==(b=null===(x=i.scales)||void 0===x?void 0:x.x)&&void 0!==b?b:null===(k=i.scales)||void 0===k?void 0:k.time,l=null!==(A=null===(w=i.scales)||void 0===w?void 0:w.y)&&void 0!==A?A:null===(S=i.scales)||void 0===S?void 0:S.value;if(!s||!l)return null;const a=e.upperAccessor||"upperBounds",u=e.lowerAccessor||"lowerBounds",d=e.filter,h=o.filter(t=>null!=t[a]&&null!=t[u]&&!(d&&!d(t))).sort((t,e)=>t[r]-e[r]);if(2>h.length)return null;const f=Vt[i.curve||"linear"]||c.curveLinear,g=c.area().x(t=>s(t[r])).y0(t=>l(t[u])).y1(t=>l(t[a])).curve(f)(h);if(!g)return null;const y=e.fill||"#6366f1";return t.jsxs("g",{children:[t.jsx("path",{d:g,fill:y,fillOpacity:null!==(M=e.fillOpacity)&&void 0!==M?M:.15,stroke:"none"}),e.label&&h.length>0&&t.jsx("text",{x:s(h[h.length-1][r])+4,y:l(h[h.length-1][a])-4,fill:y,fontSize:11,children:e.label})]},"ann-"+n)}case"anomaly-band":{const o=i.data||[];if(2>o.length)return null;const r=i.yAccessor||"y",s=null!==(j=null===(_=i.scales)||void 0===_?void 0:_.x)&&void 0!==j?j:null===(P=i.scales)||void 0===P?void 0:P.time,l=null!==(E=null===(C=i.scales)||void 0===C?void 0:C.y)&&void 0!==E?E:null===(T=i.scales)||void 0===T?void 0:T.value;if(!s||!l)return null;const a=o.map(t=>t[r]).filter(t=>null!=t&&isFinite(t));if(2>a.length)return null;const c=a.reduce((t,e)=>t+e,0)/a.length,u=a.reduce((t,e)=>t+Math.pow(e-c,2),0)/a.length,d=Math.sqrt(u),h=null!==(D=e.threshold)&&void 0!==D?D:2,f=c-h*d,g=!1!==e.showBand,y=e.fill||"#6366f1",p=null!==(L=e.fillOpacity)&&void 0!==L?L:.1,v=e.anomalyColor||"#ef4444",m=null!==(O=e.anomalyRadius)&&void 0!==O?O:6,x=l(c+h*d),b=l(f),k=o.filter(t=>{const e=t[r];return null!=e&&Math.abs(e-c)>h*d});return t.jsxs("g",{children:[g&&t.jsx("rect",{x:0,y:Math.min(x,b),width:i.width||0,height:Math.abs(b-x),fill:y,fillOpacity:p}),k.map((e,n)=>{const o=Ft(e,i),r=Ht(e,i);return null==o||null==r?null:t.jsx("circle",{cx:o,cy:r,r:m,fill:v,fillOpacity:.7,stroke:v,strokeWidth:1.5},"anomaly-"+n)}),e.label&&t.jsx("text",{x:(i.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:y,fontSize:11,children:e.label})]},"ann-"+n)}case"forecast":{const o=i.data||[];if(3>o.length)return null;const r=i.xAccessor||"x",s=i.yAccessor||"y",l=null!==($=null===(N=i.scales)||void 0===N?void 0:N.x)&&void 0!==$?$:null===(I=i.scales)||void 0===I?void 0:I.time,a=null!==(R=null===(W=i.scales)||void 0===W?void 0:W.y)&&void 0!==R?R:null===(z=i.scales)||void 0===z?void 0:z.value;if(!l||!a)return null;const c=o.map(t=>[t[r],t[s]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>c.length)return null;let u;if("polynomial"===(e.method||"linear")){const t=v.default.polynomial(c,{order:e.order||2}).equation;u=e=>t.reduce((t,n,i)=>t+n*Math.pow(e,i),0)}else{const t=c.length;let e=0,n=0,i=0,o=0;for(const[t,r]of c)e+=t,n+=r,i+=t*t,o+=t*r;const r=t*i-e*e;if(1e-12>Math.abs(r))return null;const s=(t*o-e*n)/r,l=(n-s*e)/t;u=t=>l+s*t}const d=c.length,h=c.map(([t,e])=>e-u(t)).reduce((t,e)=>t+e*e,0),f=Math.sqrt(h/Math.max(d-2,1)),g=c.reduce((t,e)=>t+e[0],0)/d,y=c.reduce((t,e)=>t+Math.pow(e[0]-g,2),0),p=null!==(Y=e.confidence)&&void 0!==Y?Y:.95,m=.99>p?.95>p?.9>p?1:1.645:1.96:2.576,x=null!==(B=e.steps)&&void 0!==B?B:5,b=c[d-1][0],k=(b-c[0][0])/Math.max(d-1,1),w=[];for(let t=1;x>=t;t++)w.push(b+t*k);const A=[];for(const t of w){const e=u(t),n=f*Math.sqrt(1+1/d+(y>0?Math.pow(t-g,2)/y:0))*m;A.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const S=`M${A.map(t=>`${l(t.x)},${a(t.yUpper)}`).join(" L")} L${A.slice().reverse().map(t=>`${l(t.x)},${a(t.yLower)}`).join(" L")} Z`,M=A.map(t=>`${l(t.x)},${a(t.yCenter)}`).join(" "),_=`${l(b)},${a(u(b))}`,j=e.strokeColor||"#6366f1";return t.jsxs("g",{children:[t.jsx("path",{d:S,fill:e.fill||"#6366f1",fillOpacity:null!==(F=e.fillOpacity)&&void 0!==F?F:.15,stroke:"none"}),t.jsx("polyline",{points:`${_} ${M}`,fill:"none",stroke:j,strokeWidth:null!==(H=e.strokeWidth)&&void 0!==H?H:2,strokeDasharray:null!==(X=e.strokeDasharray)&&void 0!==X?X:"6,3"}),e.label&&A.length>0&&t.jsx("text",{x:l(A[A.length-1].x)+4,y:a(A[A.length-1].yCenter)-4,fill:j,fontSize:11,children:e.label})]},"ann-"+n)}case"widget":{let o=null,r=null;if(null!=e.px&&null!=e.py)o=e.px,r=e.py;else{const t=Xt(e,n,i);if(!t)return null;o=t.x,r=t.y}if(null==o||null==r)return null;if(!Gt(o,r,i))return null;const s=null!==(G=e.dx)&&void 0!==G?G:0,l=null!==(V=e.dy)&&void 0!==V?V:0,a=null!==(q=e.width)&&void 0!==q?q:32,c=null!==(U=e.height)&&void 0!==U?U:32,u=null!==(K=e.content)&&void 0!==K?K:t.jsx("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});return t.jsx("foreignObject",{x:o+s-a/2,y:r+l-c/2,width:a,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:t.jsx("div",{style:{width:a,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+n)}case"text":{const o=Xt(e,n,i);if(!o)return null;const{x:r,y:s}=o;return t.jsx("text",{x:r+(e.dx||0),y:s+(e.dy||0),fill:e.color||"var(--semiotic-text, #333)",fontSize:e.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label},"ann-text-"+n)}case"category-highlight":{const o=e.category;if(null==o)return null;const r=null===(Z=i.scales)||void 0===Z?void 0:Z.o,s=null===(Q=i.scales)||void 0===Q?void 0:Q.x,l=null===(J=i.scales)||void 0===J?void 0:J.y,a=(null==r?void 0:r.bandwidth)?r:(null==s?void 0:s.bandwidth)?s:(null==l?void 0:l.bandwidth)?l:null;if(!a)return null;const c=a(o);if(null==c)return null;const u=a.bandwidth(),d=e.color||"var(--semiotic-primary, #4589ff)",h=null!==(tt=e.opacity)&&void 0!==tt?tt:.15,f=e.label;return t.jsxs("g",(i.projection?"vertical"===i.projection:a===s)?{children:[t.jsx("rect",{x:c,y:0,width:u,height:i.height||0,fill:d,fillOpacity:h}),f&&t.jsx("text",{x:c+u/2,y:12,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold",children:f})]}:{children:[t.jsx("rect",{x:0,y:c,width:i.width||0,height:u,fill:d,fillOpacity:h}),f&&t.jsx("text",{x:12,y:c+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold",children:f})]},"ann-"+n)}default:return null}},n={scales:h?{x:h.x,y:h.y,time:h.x,value:h.y}:null,timeAxis:"x",xAccessor:N,yAccessor:$,width:r,height:s,data:I,frameType:"xy",pointNodes:W,curve:R,stickyPositionCache:V.current};return L.map((t,i)=>{if(O){const o=O(t,i,n);return null!=o?o:e(t,i,n)}return e(t,i,n)}).filter(Boolean)},[L,O,r,s,N,$,I,h,W,R]),Z=function(t){var n;const i=e.useSyncExternalStore(t?te:ne,t?Jt:ie,t?Jt:ie);return t&&null!==(n=i.positions.get(t))&&void 0!==n?n:null}(Y);return e.useEffect(()=>{if(!(null==Z?void 0:Z.locked)||!Y)return;const t=t=>{"Escape"===t.key&&Qt(Y)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[null==Z?void 0:Z.locked,Y]),f||w||A||C||E||K&&K.length>0||k||F||Z?t.jsxs("svg",{role:"img",width:l,height:u,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[t.jsx("title",{children:"string"==typeof w?w:"XY Chart"}),t.jsx("desc",{children:"string"==typeof w?w+" — XY data visualization":"XY data visualization"}),t.jsxs("g",{transform:`translate(${d.left},${d.top})`,children:[k&&h&&!z&&(()=>{var e,n;const i=oe(null===(e=null==g?void 0:g.find(t=>"bottom"===t.orient))||void 0===e?void 0:e.gridStyle),o=oe(null===(n=null==g?void 0:g.find(t=>"left"===t.orient))||void 0===n?void 0:n.gridStyle);return t.jsxs("g",{className:"stream-grid",children:[H.map((e,n)=>t.jsx("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:s,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i},"xgrid-"+n)),X.map((e,n)=>t.jsx("line",{x1:0,y1:e.pixel,x2:r,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"ygrid-"+n))]})})(),f&&h&&(()=>{const e=null==g?void 0:g.find(t=>"left"===t.orient),n=null==g?void 0:g.find(t=>"bottom"===t.orient),i=!e||!1!==e.baseline,o=!n||!1!==n.baseline,l=(null==e?void 0:e.jaggedBase)||!1,a=(null==n?void 0:n.jaggedBase)||!1,c=null==n?void 0:n.landmarkTicks,u=null==e?void 0:e.landmarkTicks,h="var(--semiotic-border, #ccc)",f="var(--semiotic-text-secondary, var(--semiotic-text, #666))",v="var(--semiotic-text, #333)",x=!!(null==n?void 0:n.autoRotate)&&H.length>1&&(()=>{const t=r/Math.max(H.length-1,1);return H.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:60),0)+8>t})();return t.jsxs("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[!z&&o&&!a&&t.jsx("line",{x1:0,y1:s,x2:r,y2:s,stroke:h,strokeWidth:1}),!z&&a&&t.jsx("path",{d:re("bottom",r,s),fill:"none",stroke:h,strokeWidth:1}),H.map((e,n)=>{const i=!!c&&("function"==typeof c?c(e.value,n):st(e.value,n>0?H[n-1].value:void 0));return t.jsxs("g",{transform:`translate(${e.pixel},${s})`,children:[t.jsx("line",{y2:5,stroke:h,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?t.jsx("text",{y:x?10:18,textAnchor:x?"end":"middle",fontSize:i?11:10,fontWeight:i?600:400,fill:f,style:{userSelect:"none"},transform:x?"rotate(-45)":void 0,children:e.label}):t.jsx("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:t.jsx("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"},children:e.label})})]},"xtick-"+n)}),y&&t.jsx("text",{x:r/2,y:s+40,textAnchor:"middle",fontSize:12,fill:v,style:{userSelect:"none"},children:y}),!z&&i&&!l&&t.jsx("line",{x1:0,y1:0,x2:0,y2:s,stroke:h,strokeWidth:1}),!z&&l&&t.jsx("path",{d:re("left",r,s),fill:"none",stroke:h,strokeWidth:1}),X.map((e,n)=>{const i=!!u&&("function"==typeof u?u(e.value,n):st(e.value,n>0?X[n-1].value:void 0));return t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:h,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:i?11:10,fontWeight:i?600:400,fill:f,style:{userSelect:"none"},children:e.label}):t.jsx("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:t.jsx("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"},children:e.label})})]},"ytick-"+n)}),(()=>{const n=(null==e?void 0:e.label)||p;return n?t.jsx("text",{x:15-d.left,y:s/2,textAnchor:"middle",fontSize:12,fill:v,transform:`rotate(-90, ${15-d.left}, ${s/2})`,style:{userSelect:"none"},children:n}):null})(),(()=>{const e=null==g?void 0:g.find(t=>"right"===t.orient);if(!e||0===G.length)return null;const n=e.landmarkTicks,i=e.label||m;return t.jsxs(t.Fragment,{children:[!1!==e.baseline&&t.jsx("line",{x1:r,y1:0,x2:r,y2:s,stroke:h,strokeWidth:1}),G.map((e,i)=>{const o=!!n&&("function"==typeof n?n(e.value,i):st(e.value,i>0?G[i-1].value:void 0));return t.jsxs("g",{transform:`translate(${r},${e.pixel})`,children:[t.jsx("line",{x2:5,stroke:h,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?t.jsx("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:f,style:{userSelect:"none"},children:e.label}):t.jsx("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:t.jsx("div",{style:{textAlign:"left",fontSize:10,userSelect:"none"},children:e.label})})]},"ytick-r-"+i)}),i&&t.jsx("text",{x:r+d.right-15,y:s/2,textAnchor:"middle",fontSize:12,fill:v,transform:`rotate(90, ${r+d.right-15}, ${s/2})`,style:{userSelect:"none"},children:i})]})})()]})})(),K,E&&h&&T&&D&&t.jsxs(t.Fragment,{children:[E.top&&t.jsx("g",{transform:"translate(0, 0)",children:t.jsx(Nt,{orient:"top",config:Ot(E.top),values:T,scale:h.x,size:d.top,length:r})}),E.bottom&&t.jsx("g",{transform:`translate(0, ${s})`,children:t.jsx(Nt,{orient:"bottom",config:Ot(E.bottom),values:T,scale:h.x,size:d.bottom,length:r})}),E.left&&t.jsx("g",{transform:"translate(0, 0)",children:t.jsx(Nt,{orient:"left",config:Ot(E.left),values:D,scale:h.y,size:d.left,length:s})}),E.right&&t.jsx("g",{transform:`translate(${r}, 0)`,children:t.jsx(Nt,{orient:"right",config:Ot(E.right),values:D,scale:h.y,size:d.right,length:s})})]}),C,Z&&Z.sourceId!==B&&(null==h?void 0:h.x)&&(()=>{const e=h.x(Z.xValue);if(null==e||0>e||e>r)return null;const n=Z.locked;return t.jsx("line",{x1:e,y1:0,x2:e,y2:s,stroke:n?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:n?1.5:1,strokeDasharray:n?"6,3":"4,4",pointerEvents:"none"})})(),F]}),w&&t.jsx("text",{x:l/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"},children:"string"==typeof w?w:null}),Lt({legend:A,totalWidth:l,totalHeight:u,margin:d,legendPosition:P,title:w,legendHoverBehavior:S,legendClickBehavior:M,legendHighlightedCategory:_,legendIsolatedCategories:j})]}):null}function ue(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}const de="undefined"==typeof window||"undefined"==typeof document,he=p.createContext(null);function fe(){return p.useContext(he)}const ge={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function ye(t,e){if(!t||0===t.length)return e+", empty";const n={};for(const e of t)n[e.type]=(n[e.type]||0)+1;const i=[],o={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),i=r.indexOf(e);return(-1===n?999:n)-(-1===i?999:i)});for(const t of s)i.push(`${n[t]} ${o[t]||t}`);return`${e}, ${i.join(", ")}`}function pe(t,e,n){const i=[];return t>0&&i.push(t+" nodes"),e>0&&i.push(e+" edges"),0===i.length?n+", empty":`${n}, ${i.join(", ")}`}const ve=t=>{if(null==t)return"";const e=Math.round(100*t)/100;return Number.isNaN(e)?"":e+""},me={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid 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-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},xe={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},be={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},ke={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},we={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},Ae={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},Se={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function Me({scene:e,chartType:n,tableId:i,chartTitle:o}){var r;const[s,l]=p.useState(!1),a=fe(),c=null!==(r=null==a?void 0:a.visible)&&void 0!==r&&r,u=s||c,d=p.useRef(null),h=o?"Data summary for "+o:i?`Data summary for ${n} ${i}`:"Data summary for "+n,f=p.useCallback(()=>{s||c||l(!0)},[s,c]),g=p.useCallback(t=>{var e;c||(null===(e=d.current)||void 0===e?void 0:e.contains(t.relatedTarget))||l(!1)},[c]);if(!e||0===e.length)return i?t.jsx("span",{id:i,tabIndex:-1,style:ge}):null;if(!u)return t.jsx("div",{id:i,tabIndex:-1,onFocus:f,style:ge,role:"region","aria-label":h,children:t.jsxs("button",{type:"button",onClick:()=>l(!0),children:["View data summary (",e.length," elements)"]})});const y=function(t){var e,n,i,o,r,s,l,a,c,u,d,h,f,g,y,p,v,m,x,b,k,w,A,S,M;const _=[];if(!Array.isArray(t))return _;for(const j of t)if(j&&"object"==typeof j)try{switch(j.type){case"point":_.push({label:"Point",values:{x:j.x,y:j.y}});break;case"line":{const t=j.path,e=Array.isArray(j.datum)?j.datum:[];if(!Array.isArray(t))break;for(let n=0;t.length>n&&e.length>n;n++){const e=t[n];Array.isArray(e)&&_.push({label:"Line point",values:{x:e[0],y:e[1]}})}break}case"area":{const t=j.topPath,e=Array.isArray(j.datum)?j.datum:[];if(!Array.isArray(t))break;for(let n=0;t.length>n&&e.length>n;n++){const e=t[n];Array.isArray(e)&&_.push({label:"Area point",values:{x:e[0],y:e[1]}})}break}case"rect":{const t=null!=j.datum&&"object"==typeof j.datum?j.datum:{},r=null!==(n=null!==(e=t.category)&&void 0!==e?e:j.group)&&void 0!==n?n:"",s=null!==(o=null!==(i=t.value)&&void 0!==i?i:t.__aggregateValue)&&void 0!==o?o:t.total;_.push({label:"Bar",values:{category:r,value:null!=s?s:""}});break}case"heatcell":_.push({label:"Cell",values:{x:j.x,y:j.y,value:j.value}});break;case"wedge":_.push({label:"Wedge",values:{category:null!==(a=null!==(s=null===(r=j.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:null===(l=j.datum)||void 0===l?void 0:l.label)&&void 0!==a?a:"",value:null!==(u=null===(c=j.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":_.push({label:"Node",values:{id:null!==(h=null===(d=j.datum)||void 0===d?void 0:d.id)&&void 0!==h?h:"",x:null!==(f=j.cx)&&void 0!==f?f:j.x,y:null!==(g=j.cy)&&void 0!==g?g:j.y}});break;case"arc":_.push({label:"Arc",values:{id:null!==(p=null===(y=j.datum)||void 0===y?void 0:y.id)&&void 0!==p?p:"",x:null!==(v=j.cx)&&void 0!==v?v:j.x,y:null!==(m=j.cy)&&void 0!==m?m:j.y}});break;case"candlestick":_.push({label:"Candlestick",values:{x:j.x,open:j.open,high:j.high,low:j.low,close:j.close}});break;case"geoarea":_.push({label:"Region",values:{name:null!==(A=null!==(k=null===(b=null===(x=j.datum)||void 0===x?void 0:x.properties)||void 0===b?void 0:b.name)&&void 0!==k?k:null===(w=j.datum)||void 0===w?void 0:w.name)&&void 0!==A?A:"",value:null!==(M=null===(S=j.datum)||void 0===S?void 0:S.value)&&void 0!==M?M:""}})}}catch(t){}return _}(e),v=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 i of e){const e=[],o=new Set;for(const n of t){if(!n||!n.values)continue;const t=n.values[i];null!=t&&""!==t&&("number"==typeof t&&!Number.isNaN(t)&&Number.isFinite(t)?e.push(t):"number"==typeof t||"object"!=typeof t&&"function"!=typeof t&&o.add(t+""))}if(e.length>0){let t=e[0],o=e[0],r=0;for(const n of e)t>n&&(t=n),n>o&&(o=n),r+=n;n.push({name:i,count:e.length,numeric:!0,min:t,max:o,mean:r/e.length})}else if(o.size>0){const t=Array.from(o);n.push({name:i,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}: ${ve(t.min)} to ${ve(t.max)}, mean ${ve(t.mean)}.`);else{const e=t.uniqueValues,i=e.length>3?`${e.slice(0,3).join(", ")}… (${t.count} unique)`:e.join(", ");n.push(`${t.name}: ${i}.`)}return n.join(" ")}(y.length,v),x=y.slice(0,5),b=new Set;for(const t of x)for(const e of Object.keys(t.values))b.add(e);const k=Array.from(b);return t.jsxs("div",{ref:d,id:i,tabIndex:-1,onBlur:g,style:me,role:"region","aria-label":h,children:[t.jsx("button",{type:"button",onClick:()=>{c&&a&&a.setVisible(!1),l(!1)},"aria-label":"Close data summary",style:be,children:"×"}),t.jsx("div",{role:"note",style:xe,children:m}),t.jsxs("table",{role:"table","aria-label":"Sample data for "+n,style:ke,children:[t.jsxs("caption",{style:Se,children:["First ",x.length," of ",y.length," data points"]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{style:we,children:"type"}),k.map(e=>t.jsx("th",{style:we,children:e},e))]})}),t.jsx("tbody",{children:x.map((e,n)=>t.jsxs("tr",{children:[t.jsx("td",{style:Ae,children:e.label}),k.map(n=>{return t.jsx("td",{style:Ae,children:(i=e.values[n],null==i||""===i?"—":"number"==typeof i?Number.isNaN(i)?"—":ve(i):"boolean"==typeof i?i?"true":"false":"object"==typeof i?"—":i+"")},n);var i})]},n))})]})]})}function _e({nodes:e,edges:n,chartType:i,tableId:o,chartTitle:r}){var s,l,a,c,u,d,h,f,g,y,v,m,x,b;const[k,w]=p.useState(!1),A=fe(),S=null!==(s=null==A?void 0:A.visible)&&void 0!==s&&s,M=k||S,_=r?"Data summary for "+r:o?`Data summary for ${i} ${o}`:"Data summary for "+i,j=p.useRef(null),P=p.useCallback(()=>{k||S||w(!0)},[k,S]),C=p.useCallback(t=>{var e;S||(null===(e=j.current)||void 0===e?void 0:e.contains(t.relatedTarget))||w(!1)},[S]);if(!e||0===e.length)return o?t.jsx("span",{id:o,tabIndex:-1,style:ge}):null;if(!M)return t.jsx("div",{id:o,tabIndex:-1,onFocus:P,style:ge,role:"region","aria-label":_,children:t.jsxs("button",{type:"button",onClick:()=>w(!0),children:["View data summary (",e.length," nodes, ",n.length," edges)"]})});const E=Array.isArray(e)?e:[],T=Array.isArray(n)?n:[],D=new Map,L=new Map,O=new Map,N=new Map;for(const t of T){if(!t||"object"!=typeof t)continue;const e=null!==(l=t.datum)&&void 0!==l?l:t,n="object"==typeof e.source?null===(a=e.source)||void 0===a?void 0:a.id:e.source,i="object"==typeof e.target?null===(c=e.target)||void 0===c?void 0:c.id:e.target,o="number"==typeof e.value&&Number.isFinite(e.value)?e.value:0;if(null!=n&&""!==n){const t=n+"";L.set(t,(null!==(u=L.get(t))&&void 0!==u?u:0)+1),N.set(t,(null!==(d=N.get(t))&&void 0!==d?d:0)+o)}if(null!=i&&""!==i){const t=i+"";D.set(t,(null!==(h=D.get(t))&&void 0!==h?h:0)+1),O.set(t,(null!==(f=O.get(t))&&void 0!==f?f:0)+o)}}const $=[];for(let t=0;E.length>t;t++){const e=E[t];if(!e||"object"!=typeof e)continue;const n=null!==(y=null===(g=e.datum)||void 0===g?void 0:g.id)&&void 0!==y?y:e.id,i=null!=n?n+"":"node-"+t,o=null!==(v=D.get(i))&&void 0!==v?v:0,r=null!==(m=L.get(i))&&void 0!==m?m:0,s=null!==(x=O.get(i))&&void 0!==x?x:0,l=null!==(b=N.get(i))&&void 0!==b?b:0;$.push({id:i,degree:o+r,inDeg:o,outDeg:r,wDegree:s+l,wInDeg:s,wOutDeg:l})}$.sort((t,e)=>e.degree-t.degree);let I=0,W=0;if($.length>0){let t=0;for(const e of $)t+=e.degree,e.degree>W&&(W=e.degree);I=t/$.length}const R=T.some(t=>{var e;const n=null!==(e=null==t?void 0:t.datum)&&void 0!==e?e:t;return"number"==typeof(null==n?void 0:n.value)&&Number.isFinite(n.value)}),z=[`${$.length} nodes, ${T.length} edges.`];$.length>0&&z.push(`Mean degree: ${ve(I)}, max degree: ${W}.`);const Y=$.slice(0,5);return t.jsxs("div",{ref:j,id:o,tabIndex:-1,onBlur:C,style:me,role:"region","aria-label":_,children:[t.jsx("button",{type:"button",onClick:()=>{S&&A&&A.setVisible(!1),w(!1)},"aria-label":"Close data summary",style:be,children:"×"}),t.jsx("div",{role:"note",style:xe,children:z.join(" ")}),t.jsxs("table",{role:"table","aria-label":"Node degree summary for "+i,style:ke,children:[t.jsxs("caption",{style:Se,children:["Top ",Y.length," of ",$.length," nodes by degree"]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{style:we,children:"id"}),t.jsx("th",{style:we,children:"degree"}),t.jsx("th",{style:we,children:"in"}),t.jsx("th",{style:we,children:"out"}),R&&t.jsx("th",{style:we,children:"w. degree"}),R&&t.jsx("th",{style:we,children:"w. in"}),R&&t.jsx("th",{style:we,children:"w. out"})]})}),t.jsx("tbody",{children:Y.map((e,n)=>t.jsxs("tr",{children:[t.jsx("td",{style:Ae,children:e.id}),t.jsx("td",{style:Ae,children:e.degree}),t.jsx("td",{style:Ae,children:e.inDeg}),t.jsx("td",{style:Ae,children:e.outDeg}),R&&t.jsx("td",{style:Ae,children:ve(e.wDegree)}),R&&t.jsx("td",{style:Ae,children:ve(e.wInDeg)}),R&&t.jsx("td",{style:Ae,children:ve(e.wOutDeg)})]},n))})]})]})}function je({summary:e}){return e?t.jsx("div",{role:"note",style:ge,children:e}):null}function Pe({tableId:e}){return t.jsx("a",{href:"#"+e,style:ge,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:t=>{Object.assign(t.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:t=>{const e=t.currentTarget;e.removeAttribute("style"),Object.assign(e.style,ge)},children:"Skip to data table"})}function Ce({hoverPoint:e}){let n="";if(e){const t=e.data||e;n="object"==typeof t?"Focused on data point: "+Object.entries(t).filter(([,t])=>"object"!=typeof t&&"function"!=typeof t).map(([t,e])=>`${t}: ${e}`).join(", "):"Focused on data point: "+t}return t.jsx("div",{"aria-live":"polite","aria-atomic":"true",style:ge,children:n})}const Ee="var(--semiotic-focus, #005fcc)";function Te({active:e,hoverPoint:n,margin:i,size:o,shape:r="circle",width:s,height:l}){if(!e||!n)return null;const a=n.x+i.left,c=n.y+i.top;let u;if("rect"===r&&null!=s&&null!=l){const e=Math.max(s,4),n=Math.max(l,4);u=t.jsx("rect",{x:a-e/2-3,y:c-n/2-3,width:e+6,height:n+6,rx:3,fill:"none",stroke:Ee,strokeWidth:2,strokeDasharray:"4,2"})}else u=t.jsx("circle","wedge"===r?{cx:a,cy:c,r:12,fill:"none",stroke:Ee,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:a,cy:c,r:8,fill:"none",stroke:Ee,strokeWidth:2,strokeDasharray:"4,2"});return t.jsx("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}function De({x:e,y:n,containerWidth:i,containerHeight:o,margin:r,children:s,className:l="stream-frame-tooltip",zIndex:a=1}){const c=p.useRef(null),[u,d]=p.useState(null);p.useLayoutEffect(()=>{const t=c.current;if(!t)return;const e=t.getBoundingClientRect();d(t=>t&&t.width===e.width&&t.height===e.height?t:{width:e.width,height:e.height})},[s,l,i,o]);let h;return h=u?`translate(${u.width+12>i-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>o-n?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*i?"calc(-100% - 12px)":"12px"}, ${.3*o>n?"4px":"calc(-100% - 4px)"})`,t.jsx("div",{ref:c,className:l,style:{position:"absolute",left:r.left+e,top:r.top+n,transform:h,pointerEvents:"none",zIndex:a,width:"max-content"},children:s})}const Le=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Oe=new WeakMap;let Ne=0,$e=!1,Ie=null,We=null,Re=null;function ze(t,e){var n,i;if(!e)return e;const o=Le.exec(e);if(!o)return e;const r=t.canvas;if(!r)return(null===(n=o[2])||void 0===n?void 0:n.trim())||e;!function(){if($e)return;if("undefined"==typeof window||"undefined"==typeof document)return;$e=!0;const t=()=>{Ne++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(Ie=new MutationObserver(t),Ie.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{We=window.matchMedia("(prefers-color-scheme: dark)"),Re=t,"function"==typeof We.addEventListener?We.addEventListener("change",Re):"function"==typeof We.addListener&&We.addListener(Re)}catch(t){}}();let s=Oe.get(r);s&&s.version===Ne||(s={version:Ne,map:new Map},Oe.set(r,s));const l=s.map.get(e);if(void 0!==l)return l;const a=getComputedStyle(r).getPropertyValue(o[1]).trim()||(null===(i=o[2])||void 0===i?void 0:i.trim())||e;return s.map.set(e,a),a}function Ye(t,e,n){return"function"==typeof t?t({size:e,margin:n}):t}function Be(t){const n=function(){const[t,n]=e.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return e.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const t=window.matchMedia("(prefers-reduced-motion: reduce)");return n(t.matches),function(t,e){return"function"==typeof t.addEventListener?(t.addEventListener("change",e),()=>t.removeEventListener("change",e)):(t.addListener(e),()=>t.removeListener(e))}(t,t=>n(t.matches))},[]),t}(),i=e.useRef(n);i.current=n;const[o,r]=function(t,n,i){const o=e.useRef(null),[r,s]=e.useState(null);return e.useEffect(()=>{if(!n&&!i)return;const t=o.current;if(!t)return;const e=new ResizeObserver(t=>{for(const e of t){const{width:t,height:n}=e.contentRect;s(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n})}});return e.observe(t),()=>e.disconnect()},[n,i]),[o,[n&&r?r.w:t[0],i&&r?r.h:t[1]]]}(t.sizeProp,t.responsiveWidth,t.responsiveHeight),s=e.useMemo(()=>Object.assign(Object.assign({},t.marginDefault),t.userMargin),[t.marginDefault,t.userMargin]),l=r[0]-s.left-s.right,a=r[1]-s.top-s.bottom,c=Ye(t.foregroundGraphics,r,s),u=Ye(t.backgroundGraphics,r,s),d=T(t=>t.theme),{transition:h,introEnabled:f}=function(t,e){var n,i;if(!1===t)return{transition:void 0,introEnabled:!1};const o="undefined"!=typeof window&&(null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-reduced-motion: reduce)").matches);return{transition:t?!0===t?{duration:300}:{duration:null!==(i=t.duration)&&void 0!==i?i:300,easing:"linear"===t.easing?"linear":"ease-out"}:e,introEnabled:!(o||!t||!0!==t&&!1===t.intro)}}(t.animate,t.transitionProp),g="semiotic-table-"+p.useId(),y=e.useRef(0),v=e.useRef(()=>{}),m=e.useCallback(()=>{y.current||(y.current=requestAnimationFrame(()=>v.current()))},[]);e.useEffect(()=>()=>{y.current&&(cancelAnimationFrame(y.current),y.current=0)},[]);const x=e.useRef(()=>{}),b=e.useRef(()=>{}),k=e.useRef(null),w=e.useRef(0),A=e.useCallback(()=>{w.current=0;const t=k.current;k.current=null,t&&x.current(t)},[]),S=e.useCallback(t=>{k.current={clientX:t.clientX,clientY:t.clientY},0===w.current&&(w.current=requestAnimationFrame(A))},[A]),M=e.useCallback(()=>{k.current=null,0!==w.current&&(cancelAnimationFrame(w.current),w.current=0),b.current()},[]);e.useEffect(()=>()=>{k.current=null,0!==w.current&&(cancelAnimationFrame(w.current),w.current=0)},[]);const _=t.themeDirtyRef;return e.useEffect(()=>{_&&(Ne++,_.current=!0,m())},[d,m,_]),{reducedMotion:n,reducedMotionRef:i,responsiveRef:o,size:r,margin:s,adjustedWidth:l,adjustedHeight:a,resolvedForeground:c,resolvedBackground:u,currentTheme:d,transition:h,introEnabled:f,tableId:g,rafRef:y,renderFnRef:v,scheduleRender:m,hoverHandlerRef:x,hoverLeaveRef:b,onPointerMove:S,onPointerLeave:M}}function Fe(t,e,n,i){const o=t.getContext("2d");if(!o)return null;const r=e[0]*i,s=e[1]*i,l=e[0]+"px",a=e[1]+"px";return t.style.width!==l&&(t.style.width=l),t.style.height!==a&&(t.style.height=a),t.width===r&&t.height===s||(t.width=r,t.height=s),o.setTransform(i,0,0,i,0,0),o.translate(n.left,n.top),o}function He(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function Xe(t){switch(t){case"monotoneX":return c.curveMonotoneX;case"monotoneY":return c.curveMonotoneY;case"cardinal":return c.curveCardinal;case"catmullRom":return c.curveCatmullRom;case"step":return c.curveStep;case"stepBefore":return c.curveStepBefore;case"stepAfter":return c.curveStepAfter;case"basis":return c.curveBasis;case"natural":return c.curveNatural;default:return null}}function Ge(t,e,n){let i=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(i=n.color):t>n.value&&(i=n.color);return i}function Ve(t,e,n,i,o,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],i=e[t][1]-e[t-1][1];s.push(s[t-1]+Math.sqrt(n*n+i*i))}const l=s[s.length-1];if(0===l)return;const a=Math.min(.2*l,40);t.strokeStyle=n,t.lineWidth=i,t.lineCap=r;for(let n=0;e.length-1>n;n++){const i=(s[n]+s[n+1])/2;let r=o;a>i&&(r*=i/a),a>l-i&&(r*=(l-i)/a),t.globalAlpha=Math.max(0,r),t.beginPath(),t.moveTo(e[n][0],e[n][1]),t.lineTo(e[n+1][0],e[n+1][1]),t.stroke()}}const qe=(t,e,n,i)=>{var o,r;const s=e.filter(t=>"line"===t.type);for(const l of s){if(2>l.path.length)continue;const a=l._introClipFraction;void 0!==a&&1>a&&(t.save(),t.beginPath(),t.rect(0,0,i.width*a,i.height),t.clip());const u=l.style.stroke||"#007bff",d=ze(t,u)||u,h=l.style.strokeWidth||2,f=l.colorThresholds,g=l.rawValues;if(t.setLineDash(l.style.strokeDasharray?l.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=l.style.opacity&&(t.globalAlpha=l.style.opacity),t.lineWidth=h,t.lineCap=l.style.strokeLinecap||"butt",l.style._edgeFade){const m=null!==(o=l.style.opacity)&&void 0!==o?o:1;Ve(t,l.path,d,h,m,l.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const y=Xe(l.curve),p=f&&f.length>0&&g&&g.length===l.path.length,v=l._decayOpacities;if(v&&v.length===l.path.length&&!p){t.strokeStyle=d;const x=null!==(r=l.style.opacity)&&void 0!==r?r:1;for(let b=0;l.path.length-1>b;b++)t.globalAlpha=.5*(v[b]+v[b+1])*x,t.beginPath(),t.moveTo(l.path[b][0],l.path[b][1]),t.lineTo(l.path[b+1][0],l.path[b+1][1]),t.stroke()}else if(p){let k=null,w=null,A=null,S=null,M=!1;function _(e,n,i){t.beginPath(),t.strokeStyle=e,t.moveTo(n,i),M=!0}function j(){M&&(t.stroke(),M=!1)}for(let P=0;l.path.length>P;P++){const[C,E]=l.path[P],T=g[P],D=Ge(T,f,d);if(null!==k&&null!==S&&null!==A){if(D===S)t.lineTo(C,E);else{const L=[];for(const O of f){const N=O.value;(A>N||N>T)&&(N>A||T>N)||A===N||T===N||L.push({t:(N-A)/(T-A)})}L.sort((t,e)=>t.t-e.t);for(const $ of L){const I=k+(C-k)*$.t,W=w+(E-w)*$.t,R=Ge(A+(T-A)*Math.min($.t+1e-4,1),f,d);t.lineTo(I,W),j(),_(R,I,W)}t.lineTo(C,E)}k=C,w=E,A=T,S=D}else _(D,C,E),k=C,w=E,A=T,S=D}j()}else{if(t.beginPath(),!l.strokeGradient||2>l.strokeGradient.colorStops.length||2>l.path.length)t.strokeStyle=d;else{const z=t.createLinearGradient(l.path[0][0],0,l.path[l.path.length-1][0],0);for(const Y of l.strokeGradient.colorStops)z.addColorStop(Math.max(0,Math.min(1,Y.offset)),Y.color);t.strokeStyle=z}if(y)c.line().x(t=>t[0]).y(t=>t[1]).curve(y).context(t)(l.path);else{const[B,F]=l.path[0];t.moveTo(B,F);for(let H=1;l.path.length>H;H++)t.lineTo(l.path[H][0],l.path[H][1])}t.stroke()}if(l.style.fill&&l.style.fillOpacity&&l.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=l.style.fillOpacity,t.fillStyle=("string"==typeof l.style.fill?ze(t,l.style.fill):l.style.fill)||l.style.fill,y&&!p)c.line().x(t=>t[0]).y(t=>t[1]).curve(y).context(t)(l.path);else{const[G,V]=l.path[0];t.moveTo(G,V);for(let q=1;l.path.length>q;q++)t.lineTo(l.path[q][0],l.path[q][1])}const X=l.path[0][0];t.lineTo(l.path[l.path.length-1][0],i.height),t.lineTo(X,i.height),t.closePath(),t.fill()}void 0!==a&&1>a&&t.restore(),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}};function Ue(t,e){const n=t.fillStyle,i="#010203";try{t.fillStyle=i,t.fillStyle=e}catch(e){return t.fillStyle=n,[78,121,167]}const o=t.fillStyle;if(t.fillStyle=n,"string"!=typeof o)return[78,121,167];if(o.toLowerCase()===i&&e.trim().toLowerCase()!==i)return[78,121,167];if(o.startsWith("#"))return[parseInt(o.slice(1,3),16),parseInt(o.slice(3,5),16),parseInt(o.slice(5,7),16)];const r=o.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return r?[+r[1],+r[2],+r[3]]:[78,121,167]}function Ke(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function Ze(t,e,n=.3){Ke(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 Qe(t,e,n=.6){var i,o,r,s,l;if(!Ke(e))return;const a=null!==(i=e._pulseGlowRadius)&&void 0!==i?i:4,c=e.r+a*e._pulseIntensity,u=null!==(r=null!==(o=e.cx)&&void 0!==o?o:e.x)&&void 0!==r?r:0,d=null!==(l=null!==(s=e.cy)&&void 0!==s?s:e.y)&&void 0!==l?l:0;t.beginPath(),t.arc(u,d,c,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=e._pulseIntensity*n,t.stroke()}function Je(t,e,n,i=.35){Ke(e)&&(t.globalAlpha=e._pulseIntensity*i,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill())}function tn(t){switch(t){case"monotoneX":return c.curveMonotoneX;case"monotoneY":return c.curveMonotoneY;case"cardinal":return c.curveCardinal;case"catmullRom":return c.curveCatmullRom;case"step":return c.curveStep;case"stepBefore":return c.curveStepBefore;case"stepAfter":return c.curveStepAfter;case"basis":return c.curveBasis;case"natural":return c.curveNatural;default:return null}}function en(t,e){const n=tn(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 i=c.area().x(t=>t[0]).y0((t,n)=>e.bottomPath[n][1]).y1(t=>t[1]).curve(n).context(t);t.beginPath(),i(e.topPath)}}const nn=(t,e,n,i)=>{var o,r,s;const l=e.filter(t=>"area"===t.type);for(const e of l){if(2>e.topPath.length)continue;const n=e._introClipFraction;void 0!==n&&1>n&&(t.save(),t.beginPath(),t.rect(0,0,i.width*n,i.height),t.clip());const l=e.style.fill||"#4e79a7",a=e._decayOpacities;if(a&&a.length===e.topPath.length){const n=null!==(o=e.style.fillOpacity)&&void 0!==o?o:.7;t.fillStyle=l;for(let i=0;e.topPath.length-1>i;i++)t.globalAlpha=.5*(a[i]+a[i+1])*n,t.beginPath(),t.moveTo(e.topPath[i][0],e.topPath[i][1]),t.lineTo(e.topPath[i+1][0],e.topPath[i+1][1]),t.lineTo(e.bottomPath[i+1][0],e.bottomPath[i+1][1]),t.lineTo(e.bottomPath[i][0],e.bottomPath[i][1]),t.closePath(),t.fill();if(e.style.stroke&&"none"!==e.style.stroke){t.strokeStyle=ze(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*(a[n]+a[n+1]),t.beginPath(),t.moveTo(e.topPath[n][0],e.topPath[n][1]),t.lineTo(e.topPath[n+1][0],e.topPath[n+1][1]),t.stroke()}t.globalAlpha=1;continue}const u=null!==(r=e.style.opacity)&&void 0!==r?r:1;if(en(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 i=-1/0;for(const t of e.bottomPath)t[1]>i&&(i=t[1]);const o=t.createLinearGradient(0,n,0,i);if("colorStops"in e.fillGradient)for(const t of e.fillGradient.colorStops){const e=Math.max(0,Math.min(1,t.offset));isNaN(e)||o.addColorStop(e,t.color)}else if("topOpacity"in e.fillGradient){const[n,i,r]=Ue(t,"string"==typeof l?l:"#4e79a7");o.addColorStop(0,`rgba(${n},${i},${r},${e.fillGradient.topOpacity})`),o.addColorStop(1,`rgba(${n},${i},${r},${e.fillGradient.bottomOpacity})`)}t.fillStyle=o,t.globalAlpha=u}else{const n=null!==(s=e.style.fillOpacity)&&void 0!==s?s:.7;t.globalAlpha=n*u,t.fillStyle=l}if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(en(t,e),Je(t,e)),e.style.stroke&&"none"!==e.style.stroke){if(t.globalAlpha=u,!e.strokeGradient||2>e.strokeGradient.colorStops.length||2>e.topPath.length)t.strokeStyle=ze(t,e.style.stroke)||e.style.stroke;else{const n=t.createLinearGradient(e.topPath[0][0],0,e.topPath[e.topPath.length-1][0],0);for(const t of e.strokeGradient.colorStops)n.addColorStop(Math.max(0,Math.min(1,t.offset)),t.color);t.strokeStyle=n}t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);const n=tn(e.curve);if(t.beginPath(),n)c.line().x(t=>t[0]).y(t=>t[1]).curve(n).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!==n&&1>n&&t.restore(),t.globalAlpha=1}},on=(t,e,n,i)=>{var o;const r=e.filter(t=>"point"===t.type);if(0!==r.length){t.save();try{for(const e of r){t.beginPath(),t.arc(e.x,e.y,e.r,0,2*Math.PI);const n=null!==(o=e.style.opacity)&&void 0!==o?o:e.style.fillOpacity;null!=n&&(t.globalAlpha=n),t.fillStyle=("string"==typeof e.style.fill?ze(t,e.style.fill):e.style.fill)||"#4e79a7",t.fill(),e.style.stroke&&(t.strokeStyle=("string"==typeof e.style.stroke?ze(t,e.style.stroke):e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke()),Qe(t,e),t.globalAlpha=1}}finally{t.restore()}}};function rn(t,e,n){const i=e.fillGradient;if(!i)return null;const o=e.roundedEdge;let r=e.x,s=e.y,l=e.x,a=e.y+e.h;if("bottom"===o?(s=e.y+e.h,a=e.y):"right"===o?(r=e.x+e.w,s=e.y,l=e.x,a=e.y):"left"===o&&(r=e.x,s=e.y,l=e.x+e.w,a=e.y),"colorStops"in i){const e=i.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>e.length)return null;const n=t.createLinearGradient(r,s,l,a);for(const t of e)n.addColorStop(t.offset,t.color);return n}const c=t.createLinearGradient(r,s,l,a),[u,d,h]=Ue(t,n);return c.addColorStop(0,`rgba(${u},${d},${h},${i.topOpacity})`),c.addColorStop(1,`rgba(${u},${d},${h},${i.bottomOpacity})`),c}const sn=(t,e,n,i)=>{const o=e.filter(t=>"rect"===t.type);for(const e of o){if(null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon)ln(t,e);else if(e.roundedTop&&e.roundedTop>0){const n=("string"==typeof e.style.fill?ze(t,e.style.fill):e.style.fill)||ze(t,"var(--semiotic-primary, #007bff)"),i="string"==typeof n?rn(t,e,n):null;t.fillStyle=i||n;const o=Math.min(e.roundedTop,e.w/2,e.h/2);t.beginPath();const{x:r,y:s,w:l,h:a}=e;switch(e.roundedEdge){case"right":t.moveTo(r,s),t.lineTo(r+l-o,s),t.arcTo(r+l,s,r+l,s+o,o),t.lineTo(r+l,s+a-o),t.arcTo(r+l,s+a,r+l-o,s+a,o),t.lineTo(r,s+a);break;case"left":t.moveTo(r+l,s),t.lineTo(r+o,s),t.arcTo(r,s,r,s+o,o),t.lineTo(r,s+a-o),t.arcTo(r,s+a,r+o,s+a,o),t.lineTo(r+l,s+a);break;case"bottom":t.moveTo(r,s),t.lineTo(r+l,s),t.lineTo(r+l,s+a-o),t.arcTo(r+l,s+a,r+l-o,s+a,o),t.lineTo(r+o,s+a),t.arcTo(r,s+a,r,s+a-o,o);break;default:t.moveTo(r,s+a),t.lineTo(r,s+o),t.arcTo(r,s,r+o,s,o),t.lineTo(r+l-o,s),t.arcTo(r+l,s,r+l,s+o,o),t.lineTo(r+l,s+a)}t.closePath(),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=ze(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else{const n=("string"==typeof e.style.fill?ze(t,e.style.fill):e.style.fill)||ze(t,"var(--semiotic-primary, #007bff)"),i="string"==typeof n?rn(t,e,n):null;t.fillStyle=i||n,t.fillRect(e.x,e.y,e.w,e.h),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=ze(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))}Ze(t,e),t.globalAlpha=1}};function ln(t,e){const n=e.style.icon,i=e.style.iconPadding||2,o=Math.min(e.w,e.h)-i;if(0>=o)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=o+i,s=e.x+(e.w-o)/2;for(let i=e.y+e.h-o;i>=e.y-o;i-=r)t.drawImage(n,s,i,o,o)}else{const r=o+i,s=e.y+(e.h-o)/2;for(let i=e.x;e.x+e.w>i;i+=r)t.drawImage(n,i,s,o,o)}t.restore()}function an(t,e,n,i){return Object.assign(Object.assign(Object.assign({},function(t){return"object"!=typeof t||null===t||Array.isArray(t)?{}:t}(t)),{data:t,x:e,y:n,time:e,value:n}),i)}function cn(t){const[e,n,i]=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*i>128?"#000":"#fff"}function un(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}const dn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function hn(t){const e=t[1]-t[0],n=3156e7;return 864e5>e?t=>{const e=new Date(t);return`${(e.getUTCHours()+"").padStart(2,"0")}:${(e.getUTCMinutes()+"").padStart(2,"0")}`}:n>e?t=>{const e=new Date(t);return`${dn[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*n>e?t=>{const e=new Date(t);return`${dn[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}const fn={line:[nn,qe,on],area:[nn,on],stackedarea:[nn,on],scatter:[on],bubble:[on],heatmap:[(t,e,n,i)=>{const o=e.filter(t=>"heatcell"===t.type);t.save();try{for(const e of o){const n=e.style;if(null!=(null==n?void 0:n.opacity)&&(t.globalAlpha=n.opacity),t.fillStyle=e.fill,t.fillRect(e.x,e.y,e.w,e.h),t.strokeStyle=ze(t,"var(--semiotic-surface, #fff)"),t.lineWidth=1,t.strokeRect(e.x,e.y,e.w,e.h),Ze(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):un(e.value),i=Math.max(10,Math.min(16,.3*Math.min(e.w,e.h))),o=e.x+e.w/2,r=e.y+e.h/2;t.fillStyle=cn(e.fill),t.font=i+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,o,r)}}}finally{t.restore()}}],bar:[sn],swarm:[on],waterfall:[(t,e,n,i)=>{var o,r,s;sn(t,e);const l=e.filter(t=>"rect"===t.type);if(2>l.length)return;const a=l[0].datum,c=null==a?void 0:a._connectorStroke;if(c){t.save(),t.strokeStyle=ze(t,c)||c,t.lineWidth=null!==(o=null==a?void 0:a._connectorWidth)&&void 0!==o?o:1,t.setLineDash([]);for(let e=0;l.length-1>e;e++){const i=l[e],o=l[e+1];if(!(null===(r=i.datum)||void 0===r?void 0:r.cumEnd)||!(null===(s=o.datum)||void 0===s?void 0:s.baseline))continue;const a=n.y(i.datum.cumEnd),c=i.x+i.w,u=o.x;t.beginPath(),t.moveTo(c,a),t.lineTo(u,a),t.stroke()}t.restore()}}],candlestick:[(t,e,n,i)=>{var o,r,s;for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.save();const l=(null!==(o=e._decayOpacity)&&void 0!==o?o:1)*(null!==(s=null===(r=e.style)||void 0===r?void 0:r.opacity)&&void 0!==s?s:1);1!==l&&(t.globalAlpha=l);const a=ze(t,e.wickColor)||e.wickColor,c=60>i.height,u=c?Math.max(e.wickWidth,2):e.wickWidth,d=()=>{t.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=a,t.lineWidth=u,t.stroke()};if(c||d(),e.isRange){const n=Math.max(2,Math.min(e.bodyWidth/2,.12*i.height));t.fillStyle=a,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),i=Math.abs(e.openY-e.closeY),o=e.isUp?e.upColor:e.downColor,r=ze(t,o)||o;t.fillStyle=r,t.fillRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(i,1)),t.strokeStyle=r,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(i,1))}c&&d(),t.restore()}}],mixed:[nn,qe,on]},gn={top:20,right:20,bottom:30,left:40},yn={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white",primary:"#007bff"};function pn(t,e){const n=t.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const t=n[1],i=n[2],o=n[3];return`#${t}${t}${i}${i}${o}${o}${e}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${e}`;const i=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return i?`rgba(${i[1]}, ${(parseInt(e,16)/255).toFixed(3)})`:n}const vn={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function mn({hover:e}){const n=t=>Number.isInteger(t)?t+"":t.toFixed(2);return t.jsxs("div",{className:"semiotic-tooltip",style:vn,children:[t.jsx("div",{style:{fontWeight:600,marginBottom:2},children:n(e.value)}),t.jsx("div",{style:{opacity:.7,fontSize:11},children:n(e.time)})]})}const xn=e.forwardRef(function(n,i){var o,r,s,l,a,c,u,d,h,f,g;const{chartType:y,runtimeMode:v,data:m,chunkThreshold:x,chunkSize:w,xAccessor:A,yAccessor:M,colorAccessor:_,sizeAccessor:j,groupAccessor:P,lineDataAccessor:C,curve:E,normalize:T,binSize:D,valueAccessor:L,arrowOfTime:O="right",windowMode:N="sliding",windowSize:$=200,timeAccessor:I,xExtent:W,yExtent:R,extentPadding:z=.1,scalePadding:Y,sizeRange:B,size:F=[500,300],responsiveWidth:H,responsiveHeight:X,margin:G,className:V,background:q,lineStyle:U,pointStyle:K,areaStyle:Z,barStyle:Q,waterfallStyle:J,swarmStyle:tt,barColors:et,colorScheme:it,boundsAccessor:ot,boundsStyle:rt,y0Accessor:st,gradientFill:lt,lineGradient:ut,areaGroups:dt,openAccessor:ht,highAccessor:ft,lowAccessor:gt,closeAccessor:yt,candlestickStyle:pt,showAxes:kt=!0,axes:St,xLabel:Mt,yLabel:_t,yLabelRight:jt,xFormat:Pt,yFormat:Ct,tickFormatTime:Et,tickFormatValue:Tt,hoverAnnotation:Dt,tooltipContent:Lt,customHoverBehavior:Ot,customClickBehavior:Nt,enableHover:$t,hoverRadius:It=30,tooltipMode:Wt,annotations:Rt,svgAnnotationRules:zt,showGrid:Yt,legend:Bt,legendHoverBehavior:Ft,legendClickBehavior:Ht,legendHighlightedCategory:Xt,legendIsolatedCategories:Gt,legendPosition:Vt,backgroundGraphics:qt,foregroundGraphics:Ut,canvasPreRenderers:Kt,svgPreRenderers:Zt,title:Qt,categoryAccessor:Jt,brush:te,onBrush:ee,decay:ne,pulse:ie,transition:oe,animate:re,staleness:le,heatmapAggregation:ae,heatmapXBins:he,heatmapYBins:fe,showValues:ge,heatmapValueFormat:pe,marginalGraphics:ve,pointIdAccessor:me,xScaleType:xe,yScaleType:be,accessibleTable:ke=!0,description:we,summary:Ae,linkedCrosshairName:Se,linkedCrosshairSourceId:_e}=n,Ee=e.useRef(!1),Le=Be({sizeProp:F,responsiveWidth:H,responsiveHeight:X,userMargin:G,marginDefault:gn,animate:re,transitionProp:oe,themeDirtyRef:Ee}),{reducedMotionRef:Oe,responsiveRef:Ne,size:$e,currentTheme:Ie,transition:We,introEnabled:Re,tableId:ze,rafRef:Ye,renderFnRef:Xe,scheduleRender:Ge}=Le;let Ve=Le.margin;if(ve){const t=60,e=Object.assign({},Le.margin);ve.top&&t>e.top&&(e.top=t),ve.bottom&&t>e.bottom&&(e.bottom=t),ve.left&&t>e.left&&(e.left=t),ve.right&&t>e.right&&(e.right=t),Ve=e}const qe="function"==typeof Ut?Ut({size:$e,margin:Ve}):Ut,Ue="function"==typeof qt?qt({size:$e,margin:Ve}):qt,Ke=$e[0]-Ve.left-Ve.right,Ze=$e[1]-Ve.top-Ve.bottom,Qe=null!=Dt?Dt:$t,Je=e.useRef(null),tn=e.useRef(null),[en,nn]=e.useState(0),[on,rn]=e.useState(null),sn=e.useRef(null),ln=e.useRef(null),[cn,un]=e.useState(null),dn=e.useRef(yn.primary),[vn,xn]=e.useState(!1),[bn,kn]=e.useState([]),[wn,An]=e.useState([]),Sn="streaming"===v||["bar","swarm","waterfall"].includes(y),Mn=e.useMemo(()=>{var t,e,n;return{chartType:y,runtimeMode:Sn?"streaming":"bounded",windowSize:$,windowMode:N,arrowOfTime:Sn?O:"right",extentPadding:z,scalePadding:Y,xAccessor:Sn?void 0:A,yAccessor:Sn?void 0:M,timeAccessor:Sn?I:void 0,valueAccessor:L,colorAccessor:_,sizeAccessor:j,groupAccessor:P||(C?"_lineGroup":void 0),categoryAccessor:Jt,lineDataAccessor:C,xScaleType:xe,yScaleType:be,xExtent:W,yExtent:R,sizeRange:B,binSize:D,normalize:T,boundsAccessor:ot,boundsStyle:rt,y0Accessor:st,gradientFill:!0===lt?{topOpacity:.8,bottomOpacity:.05}:!1===lt?void 0:lt,areaGroups:dt?new Set(dt):void 0,lineGradient:ut,openAccessor:ht,highAccessor:ft,lowAccessor:gt,closeAccessor:yt,candlestickStyle:pt,lineStyle:U,pointStyle:K,areaStyle:Z,swarmStyle:tt,waterfallStyle:J,colorScheme:it,barColors:et,barStyle:Q,annotations:Rt,decay:ne,pulse:ie,transition:We,introAnimation:Re,staleness:le,heatmapAggregation:ae,heatmapXBins:he,heatmapYBins:fe,showValues:ge,heatmapValueFormat:pe,pointIdAccessor:me,curve:E,themeCategorical:null===(t=null==Ie?void 0:Ie.colors)||void 0===t?void 0:t.categorical,themeSemantic:S(Ie),themeSequential:null===(e=null==Ie?void 0:Ie.colors)||void 0===e?void 0:e.sequential,themeDiverging:null===(n=null==Ie?void 0:Ie.colors)||void 0===n?void 0:n.diverging}},[y,$,N,O,z,Y,A,M,I,L,xe,be,_,j,P,Jt,C,W,R,B,D,T,ot,rt,st,lt,ut,dt,ht,ft,gt,yt,pt,U,K,Z,tt,J,Q,it,et,Rt,ne,ie,null==We?void 0:We.duration,null==We?void 0:We.easing,Re,le,ae,he,fe,ge,pe,Sn,me,E,Ie]),_n=e.useRef(null);_n.current||(_n.current=new nt(Mn)),e.useEffect(()=>{var t;null===(t=_n.current)||void 0===t||t.updateConfig(Mn),Ee.current=!0,Ge()},[Mn,Ge]);const jn=e.useRef(null);jn.current||(jn.current=new k(t=>{const e=_n.current;e&&e.ingest(t)&&(Ee.current=!0,Ge())},{chunkThreshold:x,chunkSize:w})),e.useEffect(()=>{var t;null===(t=jn.current)||void 0===t||t.updateChunkOptions({chunkThreshold:x,chunkSize:w})},[x,w]);const Pn=e.useCallback(t=>{var e;null===(e=jn.current)||void 0===e||e.push(t)},[]),Cn=e.useCallback(t=>{var e;null===(e=jn.current)||void 0===e||e.pushMany(t)},[]),En=e.useCallback(()=>{var t,e;null===(t=jn.current)||void 0===t||t.clear(),null===(e=_n.current)||void 0===e||e.clear(),Ee.current=!0,Ge()},[Ge]);e.useImperativeHandle(i,()=>({push:Pn,pushMany:Cn,remove:t=>{var e,n,i;null===(e=jn.current)||void 0===e||e.flush();const o=null!==(i=null===(n=_n.current)||void 0===n?void 0:n.remove(t))&&void 0!==i?i:[];return o.length>0&&(sn.current&&o.some(t=>{var e;return t===(null===(e=sn.current)||void 0===e?void 0:e.data)})&&(sn.current=null,un(null)),Ee.current=!0,Ge()),o},update:(t,e)=>{var n,i,o;null===(n=jn.current)||void 0===n||n.flush();const r=null!==(o=null===(i=_n.current)||void 0===i?void 0:i.update(t,e))&&void 0!==o?o:[];return r.length>0&&(Ee.current=!0,Ge()),r},clear:En,getData:()=>{var t,e,n;return null===(t=jn.current)||void 0===t||t.flush(),null!==(n=null===(e=_n.current)||void 0===e?void 0:e.getData())&&void 0!==n?n:[]},getScales:()=>{var t,e;return null!==(e=null===(t=_n.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=_n.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[Pn,Cn,En,Ge]),e.useEffect(()=>{var t,e;if(m){if(C&&m.length>0&&"object"==typeof m[0]&&null!==m[0]){const e="string"==typeof C?C:"coordinates";if(Array.isArray(m[0][e])){const n=[];for(const t of m){const i=t[e];if(Array.isArray(i)){const e=t.label||t.id||t.key;if(null!=e)for(const t of i)n.push(Object.assign(Object.assign({},t),{_lineGroup:e}));else for(const t of i)n.push(t)}}return void(null===(t=jn.current)||void 0===t||t.setBoundedData(n))}}null===(e=jn.current)||void 0===e||e.setBoundedData(m)}},[m,C]);const{hoverHandlerRef:Tn,hoverLeaveRef:Dn,onPointerMove:Ln,onPointerLeave:On}=Le;Tn.current=t=>{if(!Qe)return;const e=Je.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-Ve.left,o=t.clientY-n.top-Ve.top;if(0>i||i>Ke||0>o||o>Ze)return void(sn.current&&(sn.current=null,ln.current=null,un(null),Ot&&(Ot(null),Ee.current=!0),Ge()));const r=_n.current;if(!r||0===r.scene.length)return;const s=at(r.scene,i,o,It,r.quadtree,r.maxPointRadius);if(!s)return void(sn.current&&(sn.current=null,ln.current=null,un(null),Ot&&Ot(null),Ge()));const l=an(s.datum||{},s.x,s.y);if("multi"===Wt&&r.scene.length>0&&r.scales){const t=function(t,e,n=30){const i=[];for(const o of t)if("line"===o.type){const t=o;if(2>t.path.length)continue;const r=ct(t.path,e,n);if(null===r)continue;const s=vt(t.path,e);i.push({node:o,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"===o.type){const t=o;if(!1===t.interactive)continue;if(2>t.topPath.length)continue;const r=ct(t.topPath,e,n);if(null===r)continue;const s=vt(t.topPath,e);i.push({node:o,datum:Array.isArray(t.datum)&&t.datum[s]?t.datum[s]:t.datum,x:t.topPath[s][0],y:r,group:t.group,color:"string"==typeof t.style.stroke?t.style.stroke:"string"==typeof t.style.fill?t.style.fill:void 0})}return i}(r.scene,s.x,It),e=r.scales.y.invert,n=r.scales.x.invert;if(t.length>0){const i=n?n(s.x):s.x;l.xValue=i,l.xPx=s.x;const o=dn.current;l.allSeries=t.map(t=>({group:t.group||"",value:e?e(t.y):t.y,valuePx:t.y,color:t.color||o,datum:t.datum}))}}sn.current=l,ln.current=s.node,un(l),Ot&&(Ot(l),Ee.current=!0),Ge()},Dn.current=()=>{sn.current&&(sn.current=null,ln.current=null,un(null),Ot&&(Ot(null),Ee.current=!0),Ge())};const Nn=e.useRef(()=>{});Nn.current=t=>{if(!Nt)return;const e=Je.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-Ve.left,o=t.clientY-n.top-Ve.top;if(0>i||i>Ke||0>o||o>Ze)return void Nt(null);const r=_n.current;if(!r||0===r.scene.length)return void Nt(null);const s=at(r.scene,i,o,It,r.quadtree,r.maxPointRadius);Nt(s?an(s.datum||{},s.x,s.y):null)};const $n=e.useCallback(t=>Nn.current(t),[]),In=e.useRef(-1),Wn=e.useRef(null),Rn=e.useRef(null),zn=e.useCallback(t=>{const e=_n.current;if(!e||0===e.scene.length)return;const n=e.version;let i;if(Rn.current&&Rn.current.version===n)i=Rn.current.graph;else{const t=function(t){var e,n,i,o;const r=[];for(const s of t)switch(s.type){case"point":r.push({x:s.x,y:s.y,datum:s.datum,shape:"circle",group:null!==(e=s.group)&&void 0!==e?e:"_default"});break;case"line":{const t=s,e=Array.isArray(t.datum)?t.datum:[],i=null!==(n=t.group)&&void 0!==n?n:"_default";for(let n=0;t.path.length>n&&e.length>n;n++)r.push({x:t.path[n][0],y:t.path[n][1],datum:e[n],shape:"circle",group:i});break}case"area":{const t=s,e=Array.isArray(t.datum)?t.datum:[],n=null!==(i=t.group)&&void 0!==i?i:"_default";for(let i=0;t.topPath.length>i&&e.length>i;i++)r.push({x:t.topPath[i][0],y:t.topPath[i][1],datum:e[i],shape:"circle",group:n});break}case"rect":r.push({x:s.x+s.w/2,y:s.y+s.h/2,datum:s.datum,shape:"rect",w:s.w,h:s.h,group:null!==(o=s.group)&&void 0!==o?o:"_default"});break;case"heatcell":r.push({x:s.x+s.w/2,y:s.y+s.h/2,datum:s.datum,shape:"rect",w:s.w,h:s.h,group:"_default"})}return r.sort((t,e)=>t.x-e.x||t.y-e.y),r}(e.scene);if(0===t.length)return;i=mt(t),Rn.current={version:n,graph:i}}const o=In.current;if(0>o){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key))return;t.preventDefault(),In.current=0;const e=i.flat[0];Wn.current={shape:e.shape,w:e.w,h:e.h};const n=wt(e);return sn.current=n,un(n),Ot&&Ot(n),void Ge()}const r=xt(i,o),s=bt(t.key,r,i);if(null===s)return;if(t.preventDefault(),0>s)return In.current=-1,Wn.current=null,sn.current=null,ln.current=null,un(null),Ot&&Ot(null),void Ge();In.current=s;const l=i.flat[s];Wn.current={shape:l.shape,w:l.w,h:l.h};const a=wt(l);sn.current=a,un(a),Ot&&Ot(a),Ge()},[Ot,Ge]),Yn=e.useCallback(t=>{In.current=-1,Wn.current=null,Ln(t)},[Ln]);Xe.current=()=>{var t,e;Ye.current=0;const n=Je.current,i=tn.current;if(!n||!i)return;const o=_n.current;if(!o)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=o.advanceTransition(Oe.current?r+1e6:r),l=!Oe.current&&s,a=Ee.current||s;a&&!l&&o.computeScene({width:Ke,height:Ze});const c=He(),u=function(t){if(!t)return yn;const e=getComputedStyle(t),n=e.getPropertyValue("--semiotic-border").trim(),i=e.getPropertyValue("--semiotic-text-secondary").trim(),o=e.getPropertyValue("--semiotic-bg").trim(),r=e.getPropertyValue("--semiotic-primary").trim(),s=i||e.getPropertyValue("--text-secondary").trim(),l=e.getPropertyValue("--text-primary").trim(),a=n||e.getPropertyValue("--surface-3").trim(),c=o||e.getPropertyValue("--surface-0").trim();return s||l||n||r?{axisStroke:a||yn.axisStroke,tickText:s||yn.tickText,crosshair:s?pn(s,"66"):yn.crosshair,hoverFill:c?pn(c,"4D"):yn.hoverFill,hoverStroke:s?pn(s,"99"):yn.hoverStroke,pointRing:c||yn.pointRing,primary:r||yn.primary}:yn}(n);dn.current=u.primary;const d=null!==(t=null==le?void 0:le.threshold)&&void 0!==t?t:5e3,h=le&&o.lastIngestTime>0&&r-o.lastIngestTime>d;if(a){const t=Fe(n,$e,Ve,c);if(t){if(t.clearRect(-Ve.left,-Ve.top,$e[0],$e[1]),h&&(t.globalAlpha=null!==(e=null==le?void 0:le.dimOpacity)&&void 0!==e?e:.5),"transparent"!==q&&!qt){const e=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=q||(e&&"transparent"!==e?e:null);i&&(t.fillStyle=i,t.fillRect(-Ve.left,-Ve.top,$e[0],$e[1]))}if(t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,Ke,Ze),t.clip()),Kt&&o.scales)for(const e of Kt)t.save(),e(t,o.scene,o.scales,{width:Ke,height:Ze}),t.restore();const i=fn[y];if(i&&o.scales)for(const e of i)e(t,o.scene,o.scales,{width:Ke,height:Ze});t.restore(),h&&(t.globalAlpha=1)}}{const t=Fe(i,$e,Ve,c);if(t&&(t.clearRect(-Ve.left,-Ve.top,$e[0],$e[1]),Qe&&sn.current&&o.scales&&function(t,e,n,i,o,r,s){var l;if(!1===o.crosshair)return;const a=e.allSeries,c=a&&a.length>0,u=null!==(l=e.xPx)&&void 0!==l?l:e.x;t.save();const d="object"==typeof o.crosshair?o.crosshair:{};if(t.strokeStyle=d.stroke||s.crosshair,t.lineWidth=d.strokeWidth||1,t.setLineDash(d.strokeDasharray?d.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(c?u:e.x,0),t.lineTo(c?u:e.x,i),t.stroke(),c||(t.beginPath(),t.moveTo(0,e.y),t.lineTo(n,e.y),t.stroke()),t.restore(),c){t.lineWidth=2,t.strokeStyle=s.pointRing;for(const e of a)null!=e.valuePx&&(t.beginPath(),t.arc(u,e.valuePx,4,0,2*Math.PI),t.fillStyle=e.color||s.primary,t.fill(),t.stroke())}else{const n=o.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,sn.current,Ke,Ze,"object"==typeof Qe?Qe:{},ln.current,u),ln.current&&Array.isArray(Dt))){const e=Dt.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,n,i,o){var r;if(!n)return;const s=n.group;if(void 0!==s)for(const n of e){if("line"!==n.type)continue;if(n.group!==s)continue;if(2>n.path.length)continue;const e="function"==typeof i.style?i.style(n.datum):i.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||o.primary,t.lineWidth=e.strokeWidth||(n.style.strokeWidth||2)+2,t.globalAlpha=null!==(r=e.opacity)&&void 0!==r?r:1,t.stroke(),t.restore()}}(t,o.scene,ln.current,e,u)}}a&&n&&n.setAttribute("aria-label",ye(o.scene,y+" chart"));const f=Ee.current;if(Ee.current=!1,f&&o.scales){const t=t=>"object"==typeof t&&null!==t&&"function"==typeof t.valueOf?t.valueOf():t;if((!on||t(on.x.domain()[0])!==t(o.scales.x.domain()[0])||t(on.x.domain()[1])!==t(o.scales.x.domain()[1])||t(on.y.domain()[0])!==t(o.scales.y.domain()[0])||t(on.y.domain()[1])!==t(o.scales.y.domain()[1])||on.x.range()[0]!==o.scales.x.range()[0]||on.x.range()[1]!==o.scales.x.range()[1]||on.y.range()[0]!==o.scales.y.range()[0]||on.y.range()[1]!==o.scales.y.range()[1])&&rn(o.scales),ve){const t=o.getData(),e="function"==typeof A?A:t=>t[A||"x"],n="function"==typeof M?M:t=>t[M||"y"];kn(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),An(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}}f&&Rt&&Rt.length>0&&nn(t=>t+1),(null==le?void 0:le.showBadge)&&xn(!!h),(l||null!=o.activeTransition||o.hasActivePulses)&&(Ye.current=requestAnimationFrame(()=>Xe.current()))},e.useEffect(()=>(Ge(),()=>{var t;null===(t=jn.current)||void 0===t||t.clear()}),[Ge]),e.useEffect(()=>{Ee.current=!0,Ge()},[y,Ke,Ze,kt,q,U,Kt,Ge]),At(le,_n,Ee,Ge,vn,xn);const Bn=e.useMemo(()=>{if(Pt||Et)return;const t=_n.current;return(null==t?void 0:t.xIsDate)&&on?hn(on.x.domain()):void 0},[Pt,Et,on]),Fn=Pt||Et||Bn,Hn=Qe&&cn?Lt?Lt(cn):t.jsx(mn,{hover:cn}):null,Xn=Hn?t.jsx(De,{x:cn.x,y:cn.y,containerWidth:Ke,containerHeight:Ze,margin:Ve,className:"stream-frame-tooltip",children:Hn}):null,Gn=Wn.current,Vn=t.jsx(Te,{active:In.current>=0,hoverPoint:cn,margin:Ve,size:$e,shape:null==Gn?void 0:Gn.shape,width:null==Gn?void 0:Gn.w,height:null==Gn?void 0:Gn.h}),qn=(t,e,n,i)=>"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:i,fn:e}:{key:void 0,fn:null},Un=qn(A,I,"__semiotic_resolvedX","__semiotic_resolvedTime"),Kn=qn(M,L,"__semiotic_resolvedY","__semiotic_resolvedValue"),Zn=Un.key,Qn=Kn.key,Jn=Rt&&Rt.length>0,ti=t=>{if(!t||!Jn||!Un.fn&&!Kn.fn)return t;let e=!1;const n=t.map(t=>{const n=Un.fn&&Un.key&&!(Un.key in t),i=Kn.fn&&Kn.key&&!(Kn.key in t);if(!n&&!i)return t;e=!0;const o=Object.assign({},t);return n&&(o[Un.key]=Un.fn(t)),i&&(o[Kn.key]=Kn.fn(t)),o});return e?n:t};if(de){const e=_n.current;e&&m&&(e.ingest({inserts:m,bounded:!0}),e.computeScene({width:Ke,height:Ze}));const n=null!==(o=null==e?void 0:e.scene)&&void 0!==o?o:[],i=null!==(r=null==e?void 0:e.scales)&&void 0!==r?r:null,s=Fn||(()=>{if((null==e?void 0:e.xIsDate)&&i)return hn(i.x.domain())})();return t.jsxs("div",{className:"stream-xy-frame"+(V?" "+V:""),role:"img","aria-label":we||("string"==typeof Qt?Qt:"XY chart"),style:{position:"relative",width:$e[0],height:$e[1]},children:[t.jsx(je,{summary:Ae}),t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:$e[0],height:$e[1],style:{position:"absolute",left:0,top:0},children:[t.jsx("g",{transform:`translate(${Ve.left},${Ve.top})`,children:Ue}),t.jsxs("g",{transform:`translate(${Ve.left},${Ve.top})`,children:[q&&t.jsx("rect",{x:0,y:0,width:Ke,height:Ze,fill:q}),Zt&&i&&Zt.map((e,o)=>t.jsx(p.Fragment,{children:e(n,i,{width:Ke,height:Ze})},"svgpre-"+o)),n.map((e,n)=>function(e,n){var i,o,r;switch(e.type){case"line":{const i=e;if(0===i.path.length)return null;const o="M"+i.path.map(([t,e])=>`${t},${e}`).join("L");return t.jsx("path",{d:o,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth||2,strokeDasharray:i.style.strokeDasharray,opacity:i.style.opacity},"line-"+n)}case"area":{const r=e;if(0===r.topPath.length)return null;const s=r.topPath.map(([t,e])=>`${t},${e}`).join("L"),l=[...r.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return t.jsx("path",{d:`M${s}L${l}Z`,fill:ue(r.style.fill),fillOpacity:null!==(o=null!==(i=r.style.fillOpacity)&&void 0!==i?i:r.style.opacity)&&void 0!==o?o:.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth},"area-"+n)}case"point":{const i=e;return t.jsx("circle",{cx:i.x,cy:i.y,r:i.r,fill:ue(i.style.fill),opacity:null!==(r=i.style.opacity)&&void 0!==r?r:.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth},"point-"+n)}case"rect":{const i=e;return t.jsx("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:ue(i.style.fill),opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth},"rect-"+n)}case"heatcell":{const i=e;if(i.showValues&&null!=i.value&&i.w>=20&&i.h>=20){const e=i.valueFormat?i.valueFormat(i.value):Number.isInteger(i.value)?i.value+"":100>Math.abs(i.value)?1>Math.abs(i.value)?i.value.toPrecision(3):i.value.toFixed(1):i.value.toFixed(0),[o,r,s]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(i.fill),l=.299*o+.587*r+.114*s>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(i.w,i.h)));return t.jsxs("g",{children:[t.jsx("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill}),t.jsx("text",{x:i.x+i.w/2,y:i.y+i.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:l,fontSize:a+"px",children:e})]},"heatcell-"+n)}return t.jsx("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill},"heatcell-"+n)}case"candlestick":{const i=e,o=Math.min(i.openY,i.closeY),r=Math.max(Math.abs(i.openY-i.closeY),1),s=i.isUp?i.upColor:i.downColor;return t.jsxs("g",{children:[t.jsx("line",{x1:i.x,y1:i.highY,x2:i.x,y2:i.lowY,stroke:i.wickColor,strokeWidth:i.wickWidth}),t.jsx("rect",{x:i.x-i.bodyWidth/2,y:o,width:i.bodyWidth,height:r,fill:s,stroke:s,strokeWidth:1})]},"candle-"+n)}default:return null}}(e,n)).filter(Boolean)]})]}),t.jsx(ce,{width:Ke,height:Ze,totalWidth:$e[0],totalHeight:$e[1],margin:Ve,scales:i,showAxes:kt,axes:St,xLabel:Mt,yLabel:_t,yLabelRight:jt,xFormat:s,yFormat:Ct||Tt,showGrid:Yt,title:Qt,legend:Bt,legendHoverBehavior:Ft,legendClickBehavior:Ht,legendHighlightedCategory:Xt,legendIsolatedCategories:Gt,legendPosition:Vt,foregroundGraphics:qe,marginalGraphics:ve,xValues:[],yValues:[],annotations:Rt,svgAnnotationRules:zt,annotationFrame:0,xAccessor:Zn,yAccessor:Qn,annotationData:ti(null==e?void 0:e.getData()),pointNodes:null==e?void 0:e.scene.filter(t=>"point"===t.type),curve:"string"==typeof E?E:void 0,linkedCrosshairName:Se,linkedCrosshairSourceId:_e})]})}return t.jsxs("div",{ref:Ne,className:"stream-xy-frame"+(V?" "+V:""),role:"group","aria-label":we||("string"==typeof Qt?Qt:"XY chart"),tabIndex:0,style:{position:"relative",width:H?"100%":$e[0],height:X?"100%":$e[1],overflow:"visible"},onKeyDown:zn,children:[ke&&t.jsx(Pe,{tableId:ze}),ke&&t.jsx(Me,{scene:null!==(l=null===(s=_n.current)||void 0===s?void 0:s.scene)&&void 0!==l?l:[],chartType:y+" chart",tableId:ze,chartTitle:"string"==typeof Qt?Qt:void 0}),t.jsx(je,{summary:Ae}),t.jsxs("div",{role:"img","aria-label":we||("string"==typeof Qt?Qt:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Qe?Yn:void 0,onMouseLeave:Qe?On:void 0,onClick:Nt?$n:void 0,children:[Ue&&t.jsx("svg",{style:{position:"absolute",left:0,top:0,width:$e[0],height:$e[1],pointerEvents:"none"},children:t.jsx("g",{transform:`translate(${Ve.left},${Ve.top})`,children:Ue})}),t.jsx(se,{width:Ke,height:Ze,totalWidth:$e[0],totalHeight:$e[1],margin:Ve,scales:on,showAxes:kt,axes:St,showGrid:Yt,xFormat:Fn,yFormat:Ct||Tt}),t.jsx("canvas",{ref:Je,"aria-label":ye(null!==(c=null===(a=_n.current)||void 0===a?void 0:a.scene)&&void 0!==c?c:[],y+" chart"),style:{position:"absolute",left:0,top:0}}),t.jsx("canvas",{ref:tn,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),t.jsx(Ce,{hoverPoint:cn}),t.jsx(ce,{width:Ke,height:Ze,totalWidth:$e[0],totalHeight:$e[1],margin:Ve,scales:on,showAxes:kt,axes:St,xLabel:Mt,yLabel:_t,yLabelRight:jt,xFormat:Fn,yFormat:Ct||Tt,showGrid:Yt,title:Qt,legend:Bt,legendHoverBehavior:Ft,legendClickBehavior:Ht,legendHighlightedCategory:Xt,legendIsolatedCategories:Gt,legendPosition:Vt,foregroundGraphics:qe,marginalGraphics:ve,xValues:bn,yValues:wn,annotations:Rt,svgAnnotationRules:zt,annotationFrame:en,xAccessor:Zn,yAccessor:Qn,annotationData:ti(null===(u=_n.current)||void 0===u?void 0:u.getData()),pointNodes:null===(d=_n.current)||void 0===d?void 0:d.scene.filter(t=>"point"===t.type),curve:"string"==typeof E?E:void 0,underlayRendered:!0,linkedCrosshairName:Se,linkedCrosshairSourceId:_e}),(te||ee)&&t.jsx(b,{width:Ke,height:Ze,totalWidth:$e[0],totalHeight:$e[1],margin:Ve,dimension:null!==(h=null==te?void 0:te.dimension)&&void 0!==h?h:"xy",scales:on,onBrush:null!=ee?ee:()=>{},binSize:D,snap:null==te?void 0:te.snap,binBoundaries:null!==(f=null==te?void 0:te.binBoundaries)&&void 0!==f?f:"bar"===y?null===(g=_n.current)||void 0===g?void 0:g.getBinBoundaries():void 0,snapDuring:null==te?void 0:te.snapDuring,streaming:"streaming"===v}),(null==le?void 0:le.showBadge)&&t.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===le.badgePosition?{top:4,left:4}:"bottom-left"===le.badgePosition?{bottom:4,left:4}:"bottom-right"===le.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:vn?"#dc3545":"#28a745",color:"white"}),children:vn?"STALE":"LIVE"}),Vn,Xn]})]})});xn.displayName="StreamXYFrame";const bn={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},kn={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class wn{constructor(t){this.capacity=t,this.particles=Array(t),this._freeIndices=Array(t);for(let e=0;t>e;e++)this.particles[e]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[e]=t-1-e}spawn(t){const e=this._freeIndices.pop();if(void 0===e)return null;const n=this.particles[e];return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=t,n.x=0,n.y=0,n}step(t,e,n,i){var o;for(let r=0;this.capacity>r;r++){const s=this.particles[r];if(!s.active)continue;const l=n[s.edgeIndex];if(!l||!l.bezier){s.active=!1,this._freeIndices.push(r);continue}const a=i&&null!==(o=i[s.edgeIndex])&&void 0!==o?o:1;s.t+=t*e*a*(l.bezier.circular?.3:1),1>s.t?An(l.bezier,s.t,s.offset,s):(s.active=!1,this._freeIndices.push(r))}}countForEdge(t){let e=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===t&&e++;return e}clear(){for(let t=0;this.capacity>t;t++)this.particles[t].active=!1;this._freeIndices.length=0;for(let t=this.capacity-1;t>=0;t--)this._freeIndices.push(t)}resize(t){if(this.capacity>=t)return;const e=this.particles;this.particles=Array(t);for(let n=0;t>n;n++)e.length>n?this.particles[n]=e[n]:(this.particles[n]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(n));this.capacity=t}}function An(t,e,n,i){if(t.circular&&t.segments)return void function(t,e,n,i,o){const r=t.length,s=e*r,l=Math.min(Math.floor(s),r-1),a=s-l,[c,u,d,h]=t[l];Sn(c,u,d,h,a,o);const f=h.x-c.x,g=h.y-c.y,y=Math.sqrt(f*f+g*g);if(y>.001){const t=f/y;o.x+=-g/y*n*i*2,o.y+=t*n*i*2}}(t.segments,e,n,t.halfWidth,i);if(!t.points)return i.x=0,void(i.y=0);const[o,r,s,l]=t.points;Sn(o,r,s,l,e,i);const a=l.x-o.x,c=l.y-o.y,u=Math.sqrt(a*a+c*c);if(u>.001){const e=a/u;i.x+=-c/u*n*t.halfWidth*2,i.y+=e*n*t.halfWidth*2}}function Sn(t,e,n,i,o,r){const s=1-o,l=s*s,a=l*s,c=o*o,u=c*o;r.x=a*t.x+3*l*o*e.x+3*s*c*n.x+u*i.x,r.y=a*t.y+3*l*o*e.y+3*s*c*n.y+u*i.y}function Mn(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function _n(t,e){var n,i=[],o=[],r=[],s={},l=[];function a(t){r[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],r[e]&&a(e)})}function c(t){var e,i,d=!1;for(o.push(t),r[t]=!0,e=0;l[t].length>e;e++)(i=l[t][e])===n?(u(n,o),d=!0):r[i]||(d=c(i));if(d)a(t);else for(e=0;l[t].length>e;e++){var h=s[i=l[t][e]];h||(s[i]=h={}),h[i]=!0}return o.pop(),d}function u(t,e){var n=[].concat(e).concat(t);i.push(n)}function d(e){!function(e){for(var n=0;t.length>n;n++)n>=e&&t[n]||(t[n]=[]),t[n]=t[n].filter(function(t){return t>=e})}(e);for(var n,i=function(t){for(var e=t.length,n=Array(e),i=Array(e),o=Array(e),r=Array(e),s=Array(e),l=Array(e),a=0;e>a;++a)n[a]=-1,i[a]=0,o[a]=!1,r[a]=0,s[a]=-1,l[a]=[];var c,u=0,d=[],h=[];function f(e){var a=[e],c=[e];for(n[e]=i[e]=u,o[e]=!0,u+=1;c.length>0;){var f=t[e=c[c.length-1]];if(f.length>r[e]){for(var g=r[e];f.length>g;++g){var y=f[g];if(0>n[y]){n[y]=i[y]=u,o[y]=!0,u+=1,a.push(y),c.push(y);break}o[y]&&(i[e]=0|Math.min(i[e],i[y])),0>s[y]||l[e].push(s[y])}r[e]=g}else{if(i[e]===n[e]){var p=[],v=[],m=0;for(g=a.length-1;g>=0;--g){var x=a[g];if(o[x]=!1,p.push(x),v.push(l[x]),m+=l[x].length,s[x]=d.length,x===e){a.length=g;break}}d.push(p);var b=Array(m);for(g=0;v.length>g;g++)for(var k=0;v[g].length>k;k++)b[--m]=v[g][k];h.push(b)}c.pop()}}}for(a=0;e>a;++a)0>n[a]&&f(a);for(a=0;h.length>a;a++){var g=h[a];if(0!==g.length){g.sort(function(t,e){return t-e}),c=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&c.push(g[y]);h[a]=c}}return{components:d,adjacencyList:h}}(t),o=i.components.filter(function(t){return t.length>1}),r=1/0,s=0;o.length>s;s++)for(var l=0;o[s].length>l;l++)r>o[s][l]&&(r=o[s][l],n=s);var a=o[n];if(!a)return!1;var c=t.map(function(t,e){return-1===a.indexOf(e)?[]:t.filter(function(t){return-1!==a.indexOf(t)})});return{leastVertex:r,adjList:c}}n=0;for(var h=t.length;h>n;){var f=d(n);if(n=f.leastVertex,l=f.adjList){for(var g=0;l.length>g;g++)for(var y=0;l[g].length>y;y++){var p=l[g][y];r[+p]=!1,s[p]={}}c(n),n+=1}else n=h}return i}function jn(t){return t.y0-t.y1>0?"up":"down"}function Pn(t,e){return e(t.source)==e(t.target)}function Cn(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 En(t){return t.target.x0-t.source.x1}function Tn(t,e){var n=Ln(t),i=En(e)/Math.tan(n);return"up"==jn(t)?t.y1-i:t.y1+i}function Dn(t,e){var n=Ln(t),i=En(e)/Math.tan(n);return"up"==jn(t)?t.y1+i:t.y1-i}function Ln(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function On(t,e){return e(t)}function Nn(t){return In(t.source)}function $n(t){return In(t.target)}function In(t){return(t.y0+t.y1)/2}function Wn(t){return t.virtual?0:t.value}function Rn(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!Pn(t,e)?n+1:n});var i=0;return t.targetLinks.forEach(function(t){i=t.circular&&!Pn(t,e)?i+1:i}),n+i}function zn(t){return t.target.depth}function Yn(t,e){return t.sourceLinks.length?t.depth:e-1}function Bn(t,e){return t.y0-e.y0}function Fn(t,e){return e.y0-t.y0}function Hn(t,e){return t.y1-e.y1}function Xn(t,e){return e.y1-t.y1}function Gn(t,e){return qn(t.source,e.source)||t.index-e.index}function Vn(t,e){return qn(t.target,e.target)||t.index-e.index}function qn(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Un(t,e){return Kn(t)==Kn(e)?"bottom"==t.circularLinkType?Fn(t,e):Bn(t,e):Kn(e)-Kn(t)}function Kn(t){return t.target.column-t.source.column}function Zn(t,e){return Qn(t)==Qn(e)}function Qn(t){return t.y0-t.y1>0?"up":"down"}function Jn(t,e,n,i,o){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=l.min(r.links,function(t){return t.source.y0});r.links.forEach(function(t){t.circular&&(t.circularPathData={})});var c=r.links.filter(function(t){return t.circular});return c.sort(function(t,e){return e.value-t.value}),c.forEach(function(t,e){t._circularStub=e>=4}),ti(r.links.filter(function(t){return"top"==t.circularLinkType}),e,n),ti(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+i,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,Pn(t,e)&&Cn(t))t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+o+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-o-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?Fn:Bn);var u=0;c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2+o*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?Xn:Hn),u=0,c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2+o*n+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(r.y1,t.source.y1,t.target.y1)+o+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-o-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,i=t.target.x0,o=t.y1,r=(e+i)/2;return"M"+e+","+n+"C"+r+","+n+" "+r+","+o+" "+i+","+o}(t)}),r}function ti(t,e,n){t.sort(Un);var i=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,o){var r=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(Pn(t,e)&&Cn(t))t.circularPathData.verticalBuffer=r+t._circularWidth/2;else{for(var s=0;i.length>s;s++){var l=i[s];if(l!==t&&l.circularPathData&&void 0!==l.circularPathData.verticalBuffer&&ei(t,l)){var a=l.circularPathData.verticalBuffer+(l._circularWidth||l.width)/2+n;r=a>r?a:r}}t.circularPathData.verticalBuffer=r+t._circularWidth/2}}),t}function ei(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function ni(t){return function(){return t}}function ii(t){return t.index}function oi(t){return t.nodes}function ri(t){return t.links}function si(t,e,n){var i=l.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});i.forEach(function(o,r){var s=o.length;if(e)o.sort(e);else if(r>0){var l=new Map;o.forEach(function(t,e){var n,i,o,r=(i=0,o=0,(n=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=In(t.source)*e,i+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=In(t.target)*e,i+=e}}),i>0?o/i:NaN);l.set(t,{bc:r,idx:e})}),o.sort(function(t,e){var n=l.get(t),i=l.get(e),o=n.bc,r=i.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(o)||isNaN(r)?isNaN(o)?isNaN(r)?n.idx-i.idx:1:-1:o-r})}else o.sort(function(t,e){return t.circularLinkType==e.circularLinkType?Rn(e,n)-Rn(t,n):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});o.forEach(function(e,o){e.depth==i.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==Rn(e,n)?(e.y0=t.y1/2+o,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+o,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-o,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/s*o,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-s/2+o,e.y1=e.y0+e.value*t.ky)})})}function li(t,e,n,i,o,r){var s=l.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});d();for(var a=1,c=r;c>0;--c)u(a*=.99,n),d();function u(e,n){var i=s.length;s.forEach(function(o){var r=o.length,s=o[0].depth;o.forEach(function(o){var a;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&Rn(o,n)>0){var c=l.mean(o.sourceLinks,$n),u=l.mean(o.targetLinks,Nn),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-In(o))*e*.3;o.y0+=h,o.y1+=h}}else if(0==s&&1==r)o.y0=t.y1/2-(a=o.y1-o.y0)/2,o.y1=t.y1/2+a/2;else if(s==i-1&&1==r)o.y0=t.y1/2-(a=o.y1-o.y0)/2,o.y1=t.y1/2+a/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)a=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+a;else{var f=l.mean(o.sourceLinks,$n),g=l.mean(o.targetLinks,Nn),y=((f&&g?(f+g)/2:f||g)-In(o))*e;o.y0+=y,o.y1+=y}})})}function d(){s.forEach(function(n){var r,s,l,a=t.y0,c=n.length;for(n.sort(e||qn),l=0;c>l;++l)(s=a-(r=n[l]).y0)>0&&(r.y0+=s,r.y1+=s),a=r.y1+i;if((s=a-i-t.y1)>0)for(a=r.y0-=s,r.y1-=s,l=c-2;l>=0;--l)(s=(r=n[l]).y1+o-a)>0&&(r.y0-=s,r.y1-=s),a=r.y0})}}function ai(t){t.nodes.forEach(function(t){t.sourceLinks.sort(Vn),t.targetLinks.sort(Gn)}),t.nodes.forEach(function(t){var e=t.y0,n=e,i=t.y1,o=i;t.sourceLinks.forEach(function(t){t.circular?(t.y0=i-t.width/2,i-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=o-t.width/2,o-=t.width):(t.y1=n+t.width/2,n+=t.width)})})}function ci(){var t=0,e=0,n=1,i=1,o=24,r=8,s=null,a=ii,c=Yn,u=void 0,d=32,h=2,f=oi,g=ri;function y(){var y={nodes:f.apply(null,arguments),links:g.apply(null,arguments)};return function(f){f.x0=t,f.y0=e,f.x1=n,f.y1=i,f.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 l.group(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 i=t.source,o=t.target;"object"!=typeof i&&(i=t.source=Mn(n,i)),"object"!=typeof o&&(o=t.target=Mn(n,o)),i.sourceLinks.push(t),o.targetLinks.push(t)})}(f,a),function(t,e){var n=0;if(null==e){for(var i=[],o=0;t.links.length>o;o++){var r=t.links[o],s=r.source.index,l=r.target.index;i[s]||(i[s]=[]),i[l]||(i[l]=[]),-1===i[s].indexOf(l)&&i[s].push(l)}var a=_n(i);a.sort(function(t,e){return t.length-e.length});var c={};for(o=0;a.length>o;o++){var u=a[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,i=t.source.index;e===i||c[i]&&c[i][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++)})}(f,u),function(t,e){var n=0,i=0;t.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:i>n?"top":"bottom","top"==o.circularLinkType?n++:i++,t.nodes.forEach(function(t){On(t,e)!=On(o.source,e)&&On(t,e)!=On(o.target,e)||(t.circularLinkType=o.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),Pn(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(f,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(l.sum(t.sourceLinks,Wn),l.sum(t.targetLinks,Wn)),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)})})}(f),function(t,e,n){var i,o,r;if(null!=e){t.nodes.sort(function(t,n){return e(t)<e(n)?-1:1});var s=0,l=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==l?s:s+1,l=e(t)==l?l:e(t),t.column=s})}for(i=t.nodes,o=[],r=0;i.length;++r,i=o,o=[])i.forEach(function(t){t.depth=r,t.sourceLinks.forEach(function(t){0>o.indexOf(t.target)&&!t.circular&&o.push(t.target)})});for(i=t.nodes,o=[],r=0;i.length;++r,i=o,o=[])i.forEach(function(t){t.height=r,t.targetLinks.forEach(function(t){0>o.indexOf(t.source)&&!t.circular&&o.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?n(t,r):t.column})}(f,u,c);var g=r;if(null!==s){var y=l.groups(f.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=l.max(y,function(t){return t.length});p>1&&(g=Math.max(1,(i-e)*s/(p-1)))}(function(t,e,n){var i=l.groups(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 o=l.min(i,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/l.sum(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var r=l.max(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})})(f,g,o),si(f,u,a),li(f,u,a,g,g,d),ai(f),Jn(f,a,h,10,8),si(f,u,a),li(f,u,a,g,g,d),ai(f),Jn(f,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 i=n.links.filter(function(n){return On(n.source,e)==On(t,e)}),o=i.length;o>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!Zn(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=Tn(e,t);return t.y1-n}if(e.target.column>t.target.column)return Tn(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;i.forEach(function(t){t.y0=r+t.width/2,r+=t.width}),i.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,s=0;o>r;r++)s+=i[r].width;e.y0=t.y1-s-e.width/2}})})}(f,a),function(t,e){let n=t;n.nodes.forEach(function(t){var i=n.links.filter(function(n){return On(n.target,e)==On(t,e)}),o=i.length;o>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!Zn(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=Dn(e,t);return t.y0-n}if(e.source.column>t.source.column)return Dn(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;i.forEach(function(t){t.y1=r+t.width/2,r+=t.width}),i.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,s=0;o>r;r++)s+=i[r].width;e.y1=t.y1-s-e.width/2}})})}(f,a),function(t){var e=t.nodes,n=t.links,i=!1,o=!1;if(n.forEach(function(t){"top"==t.circularLinkType?i=!0:"bottom"==t.circularLinkType&&(o=!0)}),0==i||0==o){var r=l.min(e,function(t){return t.y0}),s=l.max(e,function(t){return t.y1}),a=(t.y1-t.y0)/(s-r);function c(e){return(e-r)/(s-r)*(t.y1-t.y0)+t.y0}1>a?(e.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1)}),n.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1),t.width=t.width*a})):e.forEach(function(t){var e=t.y1-t.y0,n=c(t.y0)-t.y0;t.y0=c(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})})}}(f),Jn(f,a,h,10,8)}(y),y}return y.update=function(t){return ai(t),Jn(t,a,h,10,8),t},y.nodeWidth=function(t){return arguments.length?(o=+t,y):o},y.nodePadding=function(t){return arguments.length?(r=+t,y):r},y.nodePaddingRatio=function(t){return arguments.length?(s=+t,y):s},y.nodes=function(t){return arguments.length?(f="function"==typeof t?t:ni(t),y):f},y.links=function(t){return arguments.length?(g="function"==typeof t?t:ni(t),y):g},y.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:ni(t),y):a},y.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:ni(t),y):c},y.nodeSort=function(t){return arguments.length?(u=t,y):u},y.iterations=function(t){return arguments.length?(d=+t,y):d},y.circularLinkGap=function(t){return arguments.length?(h=+t,y):h},y.extent=function(o){return arguments.length?(t=+o[0][0],e=+o[0][1],n=+o[1][0],i=+o[1][1],y):[[t,e],[n,i]]},y.size=function(o){return arguments.length?(t=e=0,n=+o[0],i=+o[1],y):[n-t,i-e]},y}const ui=t=>{let e,n,i,o,r,s,l,a,c;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,i=t.y1+t.sankeyWidth/2,o=t.y0+t.sankeyWidth/2,r=t.source.x1,s=t.target.x0,l=d.interpolateNumber(r,s),a=l(.5),c=l(.5),`M${e},${r}C${e},${a} ${n},${c} ${n},${s}L${i},${s}C${i},${c} ${o},${a} ${o},${r}Z`):(e=t.source.x1,n=t.target.x0,l=d.interpolateNumber(e,n),i=l(.5),o=l(.5),r=t.y0-t.sankeyWidth/2,s=t.y1-t.sankeyWidth/2,a=t.y1+t.sankeyWidth/2,c=t.y0+t.sankeyWidth/2,`M${e},${r}C${i},${r} ${o},${s} ${n},${s}L${n},${a}C${o},${a} ${i},${c} ${e},${c}Z`)};function di(t){var e;const n=t.sankeyWidth/2,i=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,o=t.circularPathData;if(!o)return null;if("down"===t.direction)return null;if(t._circularStub){const e=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 l=Math.max(15,Math.min(40,.33*(o.rightFullExtent-e))),a=Math.max(15,Math.min(40,.33*(r-o.leftFullExtent)));return`M${e},${i-n}L${e+l},${i-n}L${e+l},${i+n}L${e},${i+n}ZM${r},${s-n}L${r-a},${s-n}L${r-a},${s+n}L${r},${s+n}Z`}const r=o.sourceX,s=o.sourceY,l=o.targetX,a=o.targetY,c=o.rightFullExtent,u=o.leftFullExtent,d=o.verticalFullExtent,h="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(i,15));return`M${r},${s-h*n}L${c},${s-h*n}L${c+i},${s-h*n+h*f}L${c+i},${d+h*i-h*f}L${c+i-f},${d+h*i}L${u-i+f},${d+h*i}L${u-i},${d+h*i-h*f}L${u-i},${a-h*n+h*f}L${u-i+f},${a-h*n}L${l},${a-h*n}L${l},${a+h*n}L${u+i},${a+h*n}L${u+i},${d-h*i}L${c-i},${d-h*i}L${c-i},${s+h*n}L${r},${s+h*n}Z`}const hi=new Set,fi=new WeakMap;function gi(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let n=fi.get(t);if(n){const t=n.get(e);if(t)return t}else n=new Map,fi.set(t,n);const i=new Proxy(t,{get(t,n,i){if("string"==typeof n&&!(n in t)&&t.data&&n in t.data){const t=`${e}:${n}`;hi.has(t)||(hi.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,i)}});return n.set(e,i),i}const yi={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(zn))-1:0},justify:Yn},pi={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var o,r,s,l,a,c,u;if(0===t.length)return;const d="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",f=null!==(o=n.nodeWidth)&&void 0!==o?o:15,g=null!==(r=n.nodePaddingRatio)&&void 0!==r?r:.05,y=null!==(s=n.iterations)&&void 0!==s?s:100,p=t.map(t=>Object.assign({},t)),v=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let m;m="down"===d?[[0,0],[i[1],i[0]]]:[[0,0],[i[0],i[1]]];const x=ci().extent(m).links(v).nodes(p).nodeAlign(yi[h]||Yn).nodeId(t=>t.id).nodeWidth(f).iterations(y);x.nodePaddingRatio&&x.nodePaddingRatio(g),x();{let t=1/0,e=-1/0,n=1/0,o=-1/0;for(const i of p)t>i.x0&&(t=i.x0),i.x1>e&&(e=i.x1),n>i.y0&&(n=i.y0),i.y1>o&&(o=i.y1);for(const i of v){if(!i.circular||!i.circularPathData)continue;const r=i.circularPathData,s=(null!==(a=null!==(l=i._circularWidth)&&void 0!==l?l:i.width)&&void 0!==a?a: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>o&&(o=r.verticalFullExtent+s)}const r=e-t,s=o-n,u=i[0],d=i[1];if(r>0&&s>0&&(0>t||0>n||e>u||o>d)){const e=Math.min(u/r,d/s),i=-t*e+(u-r*e)/2,o=-n*e+(d-s*e)/2;for(const t of p)t.x0=t.x0*e+i,t.x1=t.x1*e+i,t.y0=t.y0*e+o,t.y1=t.y1*e+o;for(const t of v)if(t.y0=t.y0*e+o,t.y1=t.y1*e+o,t.width=(null!==(c=t.width)&&void 0!==c?c:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const n=t.circularPathData;n.sourceX=n.sourceX*e+i,n.targetX=n.targetX*e+i,n.sourceY=n.sourceY*e+o,n.targetY=n.targetY*e+o,n.rightFullExtent=n.rightFullExtent*e+i,n.leftFullExtent=n.leftFullExtent*e+i,n.verticalFullExtent=n.verticalFullExtent*e+o,n.rightInnerExtent=n.rightInnerExtent*e+i,n.leftInnerExtent=n.leftInnerExtent*e+i,n.verticalRightInnerExtent=n.verticalRightInnerExtent*e+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*e+o,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 b=new Map;for(const e of t)b.set(e.id,e);for(const t of p){const e=b.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const k=new Map;for(const t of e)k.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of v){const e=t.source,n=t.target,i="object"==typeof e&&null!==e?e.id:e+"",o="object"==typeof n&&null!==n?n.id:n+"",r=k.get(t._edgeKey?t._edgeKey:`${i}\0${o}`);if(r){r.y0=t.y0,r.y1=t.y1,r.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,r.circular=!!t.circular,r.circularPathData=t.circularPathData,r._circularWidth=t._circularWidth,r._circularStub=t._circularStub,r.path=t.path,r.circularLinkType=t.circularLinkType,r.direction=d;const e=b.get(i),n=b.get(o);e&&(r.source=e),n&&(r.target=n)}}},buildScene(t,e,n,i){var o,r,l,a,c,u;const d="vertical"===n.orientation?"down":"right",h=n.nodeStyle,f=n.edgeStyle,g=null!==(o=n.edgeOpacity)&&void 0!==o?o:.5,y=n.edgeColorBy||"source",p=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:s.schemeCategory10,v=new Map;t.forEach((t,e)=>{v.set(t.id,p[e%p.length])});const m=[],x=[],b=[],k=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 i=h?h(gi(e,"nodeStyle")):{},o={fill:i.fill||v.get(e.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity};k.set(e.id,("string"==typeof o.fill?o.fill:null)||v.get(e.id)||"#4d430c"),m.push("down"===d?{type:"rect",x:e.y0,y:e.x0,w:n,h:t,style:o,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:o,datum:e,id:e.id,label:e.id})}const w=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of w){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let o=(null===(r=n.themeSemantic)||void 0===r?void 0:r.border)||(null===(l=n.themeSemantic)||void 0===l?void 0:l.secondary)||"#999";o="function"==typeof y?y(t)||o:"target"===y?k.get(i.id)||v.get(i.id)||o:k.get(e.id)||v.get(e.id)||o;const s=f?f(gi(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,i=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),r=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),l=s.fill||o;x.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+i},${e.sourceY-n}L${e.sourceX+i},${e.sourceY+n}L${e.sourceX},${e.sourceY+n}Z`,style:{fill:l,fillOpacity:null!==(a=s.fillOpacity)&&void 0!==a?a:g,stroke:"none",opacity:s.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+i}}),x.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-n}L${e.targetX-r},${e.targetY-n}L${e.targetX-r},${e.targetY+n}L${e.targetX},${e.targetY+n}Z`,style:{fill:l,fillOpacity:null!==(c=s.fillOpacity)&&void 0!==c?c:g,stroke:"none",opacity:s.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-r,x1:e.targetX}});continue}let d;if(d=t.circular&&t.circularPathData?di(t):ui(t),!d)continue;const h={fill:s.fill||o,fillOpacity:null!==(u=s.fillOpacity)&&void 0!==u?u:g,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity};x.push({type:"bezier",pathD:d,bezierCache:t.bezier,style:h,datum:t})}if(!1!==n.showLabels){const e=(A=n.nodeLabel)?"function"==typeof A?A:t=>t[A]||t.id:null;for(const n of t){const t=n.x1-n.x0,o=n.y1-n.y0;if(0>=t||0>=o)continue;const r=e?e(n):n.id;if(!r)continue;let s,l,a;"down"===d?(s=n.y0+(n.y1-n.y0)/2,l=n.x1+14,a="middle"):(i[0]/2>n.x0+t/2?(s=n.x0-6,a="end"):(s=n.x1+6,a="start"),l=n.y0+o/2),b.push({x:s,y:l,text:r+"",anchor:a,baseline:"middle",fontSize:11})}}var A;return{sceneNodes:m,sceneEdges:x,labels:b}}},vi={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var o,r;if(0===t.length)return;const s=null!==(o=n.forceStrength)&&void 0!==o?o:.1,l=i[0]/2,a=i[1]/2,c=n.__previousPositions;let u=0;const d=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),n=null==c?void 0:c.get(e.id);t?u++:n?(e.x=n.x,e.y=n.y,u++):d.push(e)}const f=u>0&&.3>=(t.length>0?d.length/t.length:1);if(f){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of d){const i=mi(t.id,e,n);if(i.length>0){let e=0,n=0;for(const t of i)e+=t.x,n+=t.y;const o=xi(t.id),r=o%360*(Math.PI/180),s=10+o%20;t.x=e/i.length+s*Math.cos(r),t.y=n/i.length+s*Math.sin(r)}else{const e=xi(t.id),n=e%360*(Math.PI/180),i=15+e%30;t.x=l+i*Math.cos(n),t.y=a+i*Math.sin(n)}}}else{const e=2.399963229728653;for(let n=0;t.length>n;n++){const i=t[n];if(null==i.x||null==i.y||0===i.x&&0===i.y){const t=10*Math.sqrt(n+.5),o=n*e;i.x=l+t*Math.cos(o),i.y=a+t*Math.sin(o)}}}const g=null!==(r=n.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),y=0===n.iterations?0:f?40:g,p=bi(n.nodeSize,n.nodeSizeRange,t),v=t=>p(t);if(y>0){const n=h.forceLink().strength(t=>{const e=t.weight;return Math.min(2.5,e?e*s:s)}).id(t=>t.id),i=h.forceSimulation().force("charge",h.forceManyBody().strength(t=>-25*v(t))).force("center",h.forceCenter(l,a).strength(.8)).force("x",h.forceX(l).strength(.15)).force("y",h.forceY(a).strength(.15));if(i.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));i.force("link",n),i.force("link").links(t)}f?i.alpha(.3):.1>i.alpha()&&i.alpha(1),i.stop();for(let t=0;y>t;++t)i.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=v(e);e.x=Math.max(t,Math.min(i[0]-t,e.x)),e.y=Math.max(t,Math.min(i[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const m=new Map;for(const e of t)m.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=m.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=m.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,i){var o,r,l,a,c,u,d;const h=n.nodeStyle,f=n.edgeStyle,g=bi(n.nodeSize,n.nodeSizeRange,t),y=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:s.schemeCategory10,p=new Map;t.forEach((t,e)=>{p.set(t.id,y[e%y.length])});const v=[],m=[],x=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=g(gi(e,"nodeSize")),i=h?h(gi(e,"nodeStyle")):{},s={fill:i.fill||p.get(e.id)||(null===(o=n.themeSemantic)||void 0===o?void 0:o.primary)||"#007bff",stroke:i.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(l=i.strokeWidth)&&void 0!==l?l:2,opacity:i.opacity};v.push({type:"circle",cx:e.x,cy:e.y,r:t,style:s,datum:e,id:e.id,label:e.id})}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:b.get(t.source),i="object"==typeof t.target?t.target:b.get(t.target);if(!e||!i)continue;if(null==e.x||null==e.y)continue;if(null==i.x||null==i.y)continue;const o=f?f(gi(t,"edgeStyle")):{},r={stroke:o.stroke||(null===(a=n.themeSemantic)||void 0===a?void 0:a.border)||(null===(c=n.themeSemantic)||void 0===c?void 0:c.secondary)||"#999",strokeWidth:null!==(u=o.strokeWidth)&&void 0!==u?u:1,opacity:null!==(d=o.opacity)&&void 0!==d?d:.6};m.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:r,datum:t})}if(!1!==n.showLabels){const e=(k=n.nodeLabel)?"function"==typeof k?k:t=>t[k]||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 i=g(gi(n,"nodeSize"));x.push({x:n.x,y:n.y-i-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var k;return{sceneNodes:v,sceneEdges:m,labels:x}}};function mi(t,e,n){const i=[];for(const o of e){const e="string"==typeof o.source?o.source:o.source.id,r="string"==typeof o.target?o.target:o.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||i.push({x:t.x,y:t.y})}}return i}function xi(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 bi(t,e,n){var i,r;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const s=e||[5,20],a=n.map(e=>{var n;return null===(n=e.data)||void 0===n?void 0:n[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===a.length)return()=>s[0];const c=null!==(i=l.min(a))&&void 0!==i?i:0,u=null!==(r=l.max(a))&&void 0!==r?r:1;if(c===u)return()=>(s[0]+s[1])/2;const d=o.scaleLinear().domain([c,u]).range(s).clamp(!0);return e=>{var n;const i=null===(n=e.data)||void 0===n?void 0:n[t];return null==i||"number"!=typeof i?s[0]:d(i)}}const ki=s.schemeCategory10,wi={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,i){if(0===t.length)return;const{padAngle:o=.01,groupWidth:r=20,sortGroups:s}=n,l=Math.min(i[0],i[1])/2,a=l-r,u=i[0]/2,d=i[1]/2,h=(g=n.valueAccessor)?"function"==typeof g?g:t=>{var e;return null!==(e=t[g])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var g;const y=new Map;for(let e=0;t.length>e;e++)y.set(t[e].id,e);const p=t.length,v=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=y.get("string"==typeof t.source?t.source:t.source.id),i=y.get(e);if(void 0===n||void 0===i)continue;const o=h(t);v[n][i]=o}const m=f.chord().padAngle(o);s&&m.sortGroups(s);const x=m(v),b=x.groups,k=c.arc().innerRadius(a).outerRadius(l);for(const e of b){const n=t[e.index],i=k.centroid(e);n.x=i[0]+u,n.y=i[1]+d,n.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const w=new Map;for(const e of t)w.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=w.get("string"==typeof t.source?t.source:t.source.id),i=w.get(e);n&&(t.source=n),i&&(t.target=i)}const A=new Map;for(const t of e)A.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 x){const n=t[e.source.index].id,i=t[e.target.index].id,o=A.get(`${n}\0${i}`)||A.get(`${i}\0${n}`);o&&(o.chordData=e)}},buildScene(t,e,n,i){var o,r,s,l;const{groupWidth:a=20,edgeOpacity:c=.5}=n,u=Math.min(i[0],i[1])/2,d=u-a,h=i[0]/2,g=i[1]/2,y=n.nodeStyle,p=n.edgeStyle,v=n.edgeColorBy||"source",m=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:ki,x=new Map;t.forEach((t,e)=>{x.set(t.id,m[e%m.length])});const b=f.ribbon().radius(d),k=[],w=[],A=[];for(let e=0;t.length>e;e++){const n=t[e],i=n.arcData;if(!i)continue;let r;r=y?y(gi(n,"nodeStyle")).fill||x.get(n.id)||m[e%m.length]:x.get(n.id)||m[e%m.length];const s=y?y(gi(n,"nodeStyle")):{},l={fill:r,stroke:s.stroke||"black",strokeWidth:null!==(o=s.strokeWidth)&&void 0!==o?o:1,opacity:s.opacity};k.push({type:"arc",cx:h,cy:g,innerR:d,outerR:u,startAngle:i.startAngle-Math.PI/2,endAngle:i.endAngle-Math.PI/2,style:l,datum:n,id:n.id,label:n.id})}for(const t of e){const e=t.chordData;if(!e)continue;const i=b(e);if(!i)continue;const o=Ai(i,h,g);let a=(null===(r=n.themeSemantic)||void 0===r?void 0:r.border)||(null===(s=n.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";if(p)a=p(gi(t,"edgeStyle")).fill||a;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===v&&n?a=x.get(n.id)||a:e&&(a=x.get(e.id)||a)}const u=p?p(gi(t,"edgeStyle")):{},d={fill:a,fillOpacity:null!==(l=u.fillOpacity)&&void 0!==l?l:c,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};w.push({type:"ribbon",pathD:o,style:d,datum:t})}if(!1!==n.showLabels){const e=(S=n.nodeLabel)?"function"==typeof S?S:t=>t[S]||t.id:null,i=u+12;for(const n of t){const t=n.arcData;if(!t)continue;const o=e?e(n):n.id;if(!o)continue;const r=(t.startAngle+t.endAngle)/2,s=r-Math.PI/2;A.push({x:h+Math.cos(s)*i,y:g+Math.sin(s)*i,text:o+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var S;return{sceneNodes:k,sceneEdges:w,labels:A}}};function Ai(t,e,n){const i=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!i)return t;const o=[];let r=0;for(;i.length>r;){const t=i[r];if("M"===t||"L"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("C"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)for(let t=0;3>t&&i.length>r&&!isNaN(Number(i[r]));t++)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("Q"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)for(let t=0;2>t&&i.length>r&&!isNaN(Number(i[r]));t++)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("A"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&(o.push(Number(i[r])+e+""),r++),i.length>r&&(o.push(Number(i[r])+n+""),r++);else"Z"===t||"z"===t?(o.push(t),r++):(o.push(i[r]),r++)}return o.join(" ")}const Si=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Mi(t){const[e,n,i]=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*i>150?"#222":"#fff"}function _i(t,e,n){const i=e.nodeIDAccessor;return"function"==typeof i?i(t.data)+"":"string"==typeof i&&void 0!==t.data[i]?t.data[i]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function ji(t){return t?"function"==typeof t?t:e=>{var n;return(null===(n=e.data)||void 0===n?void 0:n[t])||e[t]||e.id}:null}function Pi(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:Si}function Ci(t){var e;return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)?t.themeSemantic.primary:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical[0]:"#4d430c"}function Ei(t,e,n,i,o){if("horizontal"===o){const o=(t+n)/2;return`M ${t},${e} C ${o},${e} ${o},${i} ${n},${i}`}if("radial"===o){const o=(t+n)/2;return`M ${t},${e} Q ${o},${e} ${o},${(e+i)/2} T ${n},${i}`}{const o=(e+i)/2;return`M ${t},${e} C ${t},${o} ${n},${o} ${n},${i}`}}const Ti={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,i){var o;const r=n.__hierarchyRoot;if(!r)return;const s=n.chartType,l=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(n.childrenAccessor),c=n.hierarchySum,u="function"==typeof c?c:"string"==typeof c?t=>{var e;return null!==(e=t[c])&&void 0!==e?e:0}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0},d=a.hierarchy(r,l);d.sum(u),d.sort((t,e)=>{var n,i;return(null!==(n=e.value)&&void 0!==n?n:0)-(null!==(i=t.value)&&void 0!==i?i:0)});const[h,f]=i;switch(s){case"tree":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=a.tree();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(d,n,h,f);break;case"cluster":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=a.cluster();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(d,n,h,f);break;case"treemap":!function(t,e,n,i){var o,r;const s=null!==(o=e.padding)&&void 0!==o?o:4,l=null!==(r=e.paddingTop)&&void 0!==r?r:0,c=a.treemap().size([n,i]).tile(a.treemapBinary).padding(s);l>0&&c.paddingTop(l),c(t)}(d,n,h,f);break;case"circlepack":!function(t,e,n,i){var o;const r=null!==(o=e.padding)&&void 0!==o?o:4;a.pack().size([n,i]).padding(r)(t)}(d,n,h,f);break;case"partition":!function(t,e,n,i){var o;a.partition().size([n,i]).padding(null!==(o=e.padding)&&void 0!==o?o:1)(t)}(d,n,h,f)}const g=d.descendants();t.length=0,e.length=0;const y=new Map;for(let e=0;g.length>e;e++){const i=g[e],r={id:_i(i,n,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=i.value)&&void 0!==o?o:0,depth:i.depth,data:i.data,createdByFrame:!0};"tree"===s||"cluster"===s?Di(r,i,n):"treemap"===s||"partition"===s?Li(r,i):"circlepack"===s&&Oi(r,i),r.__hierarchyNode=i,t.push(r),y.set(i,r)}if("tree"===s||"cluster"===s)for(const t of g)if(t.parent){const n=y.get(t.parent),i=y.get(t);n&&i&&e.push({source:n,target:i,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,i){const o=n.nodeStyle||(()=>({})),r=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,i,o,r){var s,l,a,c,u,d,h,f;const g=[],y=[],p=[],v=n.treeOrientation||"vertical",m="radial"===v,x=i[0]/2,b=i[1]/2,k="number"==typeof(w=n.nodeSize)?w:5;var w;for(const e of t){let t=e.x,i=e.y;m&&(t+=x,i+=b);const r=o(gi(e,"nodeStyle"));let a=r.fill||Ci(n);if(n.colorByDepth&&void 0!==e.depth){const t=Pi(n);a=t[e.depth%t.length]}const c={fill:a,stroke:r.stroke||(null===(s=n.themeSemantic)||void 0===s?void 0:s.surface)||"#fff",strokeWidth:null!==(l=r.strokeWidth)&&void 0!==l?l:1,opacity:r.opacity};g.push({type:"circle",cx:t,cy:i,r:k,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const A=null!==(a=n.edgeOpacity)&&void 0!==a?a:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let o=e.x,s=e.y,l=i.x,a=i.y;m&&(o+=x,s+=b,l+=x,a+=b);const f=Ei(o,s,l,a,v),g=r(gi(t,"edgeStyle")),p={fill:"none",stroke:g.stroke||(null===(c=n.themeSemantic)||void 0===c?void 0:c.border)||(null===(u=n.themeSemantic)||void 0===u?void 0:u.secondary)||"#999",strokeWidth:null!==(d=g.strokeWidth)&&void 0!==d?d:1.5,opacity:null!==(h=g.opacity)&&void 0!==h?h:A};y.push({type:"curved",pathD:f,style:p,datum:t})}if(!1!==n.showLabels){const e=ji(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let i,o,r,s=n.x,l=n.y;if(m&&(s+=x,l+=b),m){const t=s-x,e=l-b,n=Math.sqrt(t*t+e*e);n>0?(i=s+t/n*10,o=l+e/n*10,r=0>t?"end":"start"):(i=s,o=l-12,r="middle")}else"horizontal"===v?((null===(f=n.data)||void 0===f?void 0:f.children)&&0!==n.data.children.length?(i=s-k-6,r="end"):(i=s+k+6,r="start"),o=l):(i=s,o=l+k+14,r="middle");p.push({x:i,y:o,text:t+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:y,labels:p}}(t,e,n,i,o,r);case"treemap":case"partition":return function(t,e,n,i){var o,r,s,l,a;const c=[],u=[];for(const n of t){const t=n.x1-n.x0,s=n.y1-n.y0;if(0>=t||0>=s)continue;const l=i(gi(n,"nodeStyle"));let a=l.fill||Ci(e);if(e.colorByDepth&&void 0!==n.depth){const t=Pi(e);a=t[n.depth%t.length]}const u={fill:a,stroke:l.stroke||(null===(o=e.themeSemantic)||void 0===o?void 0:o.surface)||"#fff",strokeWidth:null!==(r=l.strokeWidth)&&void 0!==r?r:1,opacity:l.opacity};c.push({type:"rect",x:n.x0,y:n.y0,w:t,h:s,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=ji(e.nodeLabel),o=e.labelMode||"leaf",r="partition"===e.chartType;for(const c of t){const t=c.x1-c.x0,d=c.y1-c.y0;if(0>=t||0>=d)continue;const h=!((null===(s=c.data)||void 0===s?void 0:s.children)&&c.data.children.length>0);if(!r){if("leaf"===o&&!h)continue;if("parent"===o&&h)continue}const f=n?n(c):c.id;if(!f)continue;if((h?30:40)>t||(h?16:14)>d)continue;let g=i(gi(c,"nodeStyle")).fill||Ci(e);if(e.colorByDepth&&void 0!==c.depth){const t=Pi(e);g=t[c.depth%t.length]}const y="string"==typeof g?Mi(g):null!==(a=null===(l=e.themeSemantic)||void 0===l?void 0:l.text)&&void 0!==a?a:"#000";u.push(h?{x:c.x0+t/2,y:c.y0+d/2,text:f+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,d)/6)),fill:y}:{x:c.x0+4,y:c.y0+12,text:f+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:y})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(t,n,0,o);case"circlepack":return function(t,e,n,i){var o,r,s,l,a,c,u,d,h,f;const g=[],y=[];for(const n of t){const t=null!==(o=n.__radius)&&void 0!==o?o:5;if(0>=t)continue;const a=i(gi(n,"nodeStyle"));let c=a.fill||Ci(e);if(e.colorByDepth&&void 0!==n.depth){const t=Pi(e);c=t[n.depth%t.length]}const u={fill:c,stroke:a.stroke||(null===(r=e.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=a.strokeWidth)&&void 0!==s?s:1,opacity:null!==(l=a.opacity)&&void 0!==l?l:.7};g.push({type:"circle",cx:n.x,cy:n.y,r:t,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=ji(e.nodeLabel);for(const o of t){const t=null!==(a=o.__radius)&&void 0!==a?a:5,r=n?n(o):o.id;if(!r)continue;if(15>t)continue;const s=!((null===(c=o.data)||void 0===c?void 0:c.children)&&o.data.children.length>0);let l=i(gi(o,"nodeStyle")).fill||Ci(e);if(e.colorByDepth&&void 0!==o.depth){const t=Pi(e);l=t[o.depth%t.length]}if(s){const n="string"==typeof l?Mi(l):null!==(d=null===(u=e.themeSemantic)||void 0===u?void 0:u.text)&&void 0!==d?d:"#000";y.push({x:o.x,y:o.y,text:r+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:n})}else y.push({x:o.x,y:o.y-t+14,text:r+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:(null===(h=e.themeSemantic)||void 0===h?void 0:h.text)||"#000",stroke:(null===(f=e.themeSemantic)||void 0===f?void 0:f.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:g,sceneEdges:[],labels:y}}(t,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Di(t,e,n){const i=n.treeOrientation||"vertical";if("radial"===i){const n=e.x,i=e.y;t.x=i*Math.cos(n-Math.PI/2),t.y=i*Math.sin(n-Math.PI/2)}else"horizontal"===i?(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 Li(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 Oi(t,e){var n;const i=null!==(n=e.r)&&void 0!==n?n:0;t.x=e.x,t.y=e.y,t.x0=e.x-i,t.x1=e.x+i,t.y0=e.y-i,t.y1=e.y+i,t.width=2*i,t.height=2*i,t.__radius=i}function Ni(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const $i={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,i){const o=n.__hierarchyRoot;o&&function(t,e,n,i,o){var r,s;const l=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(n.childrenAccessor),a=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>{var n;return(null!==(n=t[e])&&void 0!==n?n:"")+""}}(n.nodeIDAccessor),u=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),d=null!==(r=n.orbitSize)&&void 0!==r?r:2.95,h=null!==(s=n.orbitEccentricity)&&void 0!==s?s:1,f="number"==typeof d?()=>d:d,g="number"==typeof h?()=>h:h,y=Ni(n);y.metaMap.clear(),i.length=0,o.length=0;const p=new Map;function v(t){var e;const n=null!==(e=p.get(t))&&void 0!==e?e:0;return p.set(t,n+1),0===n?t:`${t}__${n}`}const m=e[0]/2,x=e[1]/2,b=Math.min(e[0],e[1])/2*.85,k=v(a(t));i.push({id:k,x:m,y:x,x0:m,x1:m,y0:x,y1:x,width:0,height:0,value:0,depth:0,data:t}),y.metaMap.set(k,{ring:b,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,n,r,s,d,h,p){const m=l(e);if(!(null==m?void 0:m.length))return;const x=m.length;let b=0,k=0,w=0;for(;x>k;)k+=u[Math.min(w,u.length-1)],w++,b++;let A=0;for(let x=0;b>x;x++){const k=u[Math.min(x,u.length-1)],w=m.slice(A,A+k);if(!w.length)break;const S=(x+1)/b,M={id:n,depth:h,data:e,parentId:n},_=p?d/f(M)*S:d*S,j=c.pie().value(t=>{var e;return(null===(e=l(t))||void 0===e?void 0:e.length)?4:1}).sort(null),P=j(w),C=g(M);for(let e=0;w.length>e;e++){const l=(P[e].startAngle+P[e].endAngle)/2,c=w[e],u=v(a(c)),d=r+_*Math.sin(l),f=s+_*Math.cos(l)*C;i.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:h,data:c}),y.metaMap.set(u,{ring:_,angle:l,depth:h,parentId:n,eccentricity:C}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),t(c,u,d,f,_,h+1,!0)}A+=k}}(t,k,m,x,b,1,!1)}(o,i,n,t,e)},buildScene(t,e,n,i){var o,r,s,l,a,c,u;const d=n.nodeStyle,h=n.nodeSize,f="number"==typeof h?()=>h:"function"==typeof h?h:()=>6,g=[],y=[],p=[];if(!1!==n.orbitShowRings){const e=Ni(n),i=new Map;for(const e of t)i.set(e.id,e);const o=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=i.get(t.parentId);if(!e)continue;const n=`${t.parentId}:${t.ring}`;o.has(n)||o.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:i}]of o)for(let o=0;r>o;o++){const l=o/r*Math.PI*2,a=(o+1)/r*Math.PI*2;y.push({type:"line",x1:t+n*Math.sin(l),y1:e+n*Math.cos(l)*i,x2:t+n*Math.sin(a),y2:e+n*Math.cos(a)*i,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=f(gi(e,"nodeSize")),i=d?d(gi(e,"nodeStyle")):{},c={fill:i.fill||(null===(o=n.themeSemantic)||void 0===o?void 0:o.primary)||"#6366f1",stroke:i.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=i.strokeWidth)&&void 0!==s?s:1,opacity:null!==(l=i.opacity)&&void 0!==l?l:0===(null!==(a=e.depth)&&void 0!==a?a:0)?1:.85};g.push({type:"circle",cx:e.x,cy:e.y,r:t,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const v=new Map;for(const e of t)v.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:v.get(t.source),n="object"==typeof t.target?t.target:v.get(t.target);e&&n&&(null!=e.x&&null!=n.x&&y.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(n.showLabels){const e=n.nodeLabel;for(const n of t){const t=f(gi(n,"nodeSize"));if(4>=t)continue;const i="function"==typeof e?e(n):e&&null!==(u=null===(c=n.data)||void 0===c?void 0:c[e])&&void 0!==u?u:n.id;p.push({x:n.x,y:n.y+t+12,text:i+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:g,sceneEdges:y,labels:p}},tick:(t,e,n,i,o)=>!1!==n.orbitAnimated&&(function(t,e){var n,i;const o=Ni(e),r=null!==(n=e.orbitSpeed)&&void 0!==n?n:.25,s=null!==(i=e.orbitRevolution)&&void 0!==i?i:function(t){switch(t){case"decay":return t=>{var e;return Math.pow(.6,null!==(e=t.depth)&&void 0!==e?e:0)};case"alternate":return t=>{var e;const n=null!==(e=t.depth)&&void 0!==e?e:0;return(n%2==0?1:-1)/(n+1)};default:return t=>{var e;return 1/((null!==(e=t.depth)&&void 0!==e?e:0)+1)}}}(e.orbitRevolutionStyle),l=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,a=r*(Math.PI/6),c=new Map;for(const e of t)c.set(e.id,e);for(const e of t){const t=o.metaMap.get(e.id);if(!t||!t.parentId)continue;const n=c.get(t.parentId);if(!n)continue;const i=t.angle+l*a*s({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=n.x+t.ring*Math.sin(i),e.y=n.y+t.ring*Math.cos(i)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,n),!0)},Ii={sankey:pi,force:vi,chord:wi,tree:Ti,cluster:Ti,treemap:Ti,circlepack:Ti,partition:Ti,orbit:$i};function Wi(t){return Ii[t]}class Ri{constructor(t){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.particlePool=null,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._lastPositionSnapshot=null,this.config=t,this.tensionConfig=Object.assign(Object.assign({},bn),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&(this.particlePool=new wn(2e3))}updateConfig(t){const e=this.config;e.__orbitState&&(t.__orbitState=e.__orbitState),e.__hierarchyRoot&&(t.__hierarchyRoot=e.__hierarchyRoot),this.config=t,this.tensionConfig=Object.assign(Object.assign({},bn),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&!this.particlePool&&(this.particlePool=new wn(2e3))}ingestHierarchy(t,e){this._boundedPrevSnapshot=new Map;for(const[t,e]of this.nodes)0===e.x0&&0===e.x1&&0===e.y0&&0===e.y1||this._boundedPrevSnapshot.set(t,{x0:e.x0,x1:e.x1,y0:e.y0,y1:e.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.config.__hierarchyRoot=t,this.runLayout(e),this._boundedPrevSnapshot=null}ingestBounded(t,e,n){const{nodeIDAccessor:i="id",sourceAccessor:o="source",targetAccessor:r="target",valueAccessor:s="value"}=this.config,l="function"==typeof i?i:t=>t[i],a="function"==typeof o?o:t=>t[o],c="function"==typeof r?r:t=>t[r],u="function"==typeof s?s:t=>{var e;return null!==(e=t[s])&&void 0!==e?e:1};this._boundedPrevSnapshot=new Map;for(const[t,e]of this.nodes)0===e.x0&&0===e.x1&&0===e.y0&&0===e.y1||this._boundedPrevSnapshot.set(t,{x0:e.x0,x1:e.x1,y0:e.y0,y1:e.y1});this._boundedEdgeSnapshot=new Map;for(const[,t]of this.edges)t.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,{y0:t.y0,y1:t.y1,sankeyWidth:t.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of t){const t=l(e)+"";this.nodes.set(t,Object.assign(Object.assign({},zi(t)),{data:e}))}for(let t=0;e.length>t;t++){const n=e[t],i=a(n)+"",o=c(n)+"",r=Number(u(n))||1;this.nodes.has(i)||this.nodes.set(i,Object.assign(Object.assign({},zi(i)),{data:n})),this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},zi(o)),{data:n}));const s=`${i}\0${o}\0${t}`;this.edges.set(s,{source:i,target:o,value:r,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:s})}this.runLayout(n)}edgeKey(t,e){return`${t}\0${e}`}ingestEdge(t){const{source:e,target:n,value:i}=t,o=0===this.nodes.size;let r=!1;const s="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=s,this._decaySortedNodes=null,this.nodes.has(e)||(this.nodes.set(e,zi(e)),this.nodeTimestamps.set(e,s),this.tension+=this.tensionConfig.newNode,r=!0),this.nodes.has(n)||(this.nodes.set(n,zi(n)),this.nodeTimestamps.set(n,s),this.tension+=this.tensionConfig.newNode,r=!0);const l=this.edgeKey(e,n),a=this.edges.get(l);let c=!1;return a?(a.value+=i,this.edgeTimestamps.set(l,s),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(l,{source:e,target:n,value:i,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(l,s),this.tension+=this.tensionConfig.newEdge,r=!0),o||r||c||this.tension>=this.tensionConfig.threshold}runLayout(t){var e,n,i,o,r,s,l,a;const c=Wi(this.config.chartType);if(!c)return;let u=Array.from(this.nodes.values());const d=Array.from(this.edges.values());if(0===u.length&&!c.hierarchical)return;if(this.prepareForRelayout(),c.supportsStreaming&&!c.hierarchical){const t=new Map;for(const l of u)if(void 0!==l._prevX0){const a=(null!==(e=l._prevX1)&&void 0!==e?e:0)-(null!==(n=l._prevX0)&&void 0!==n?n:0),c=(null!==(i=l._prevY1)&&void 0!==i?i:0)-(null!==(o=l._prevY0)&&void 0!==o?o:0);t.set(l.id,{x:(null!==(r=l._prevX0)&&void 0!==r?r:0)+a/2,y:(null!==(s=l._prevY0)&&void 0!==s?s:0)+c/2})}else 0===l.x&&0===l.y||t.set(l.id,{x:l.x,y:l.y});if(this._lastPositionSnapshot)for(const[e,n]of this._lastPositionSnapshot)t.has(e)||t.set(e,n);this.config.__previousPositions=t.size>0?t:void 0}if(c.computeLayout(u,d,this.config,t),this.config.__previousPositions=void 0,c.hierarchical&&u.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const t of u)this.nodes.set(t.id,t);for(let t=0;d.length>t;t++){const e=d[t],n=e._edgeKey||`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}\0${t}`;e._edgeKey=n,this.edges.set(n,e)}const t=this._boundedPrevSnapshot;if(t&&t.size>0)for(const e of this.nodes.values()){const n=t.get(e.id);n&&(e._prevX0=n.x0,e._prevX1=n.x1,e._prevY0=n.y0,e._prevY1=n.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,u=Array.from(this.nodes.values())}this.finalizeLayout();const h=new Map;for(const t of this.nodes.values())0===t.x&&0===t.y||h.set(t.id,{x:t.x,y:t.y});this._lastPositionSnapshot=h,this.saveTargetPositions();const f=u.some(t=>void 0!==t._prevX0&&(0!==t._prevX0||0!==t._prevX1||0!==t._prevY0||0!==t._prevY1)),g=null!==(a=null===(l=this.config.transition)||void 0===l?void 0:l.duration)&&void 0!==a?a:this.tensionConfig.transitionDuration;if(!this._hasRenderedOnce&&this.config.introAnimation&&["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType)&&u.length>0&&g>0){const e=t[0]/2,n=t[1]/2;for(const t of this.nodes.values())t._prevX0=e,t._prevX1=e,t._prevY0=n,t._prevY1=n;for(const t of this.edges.values())t._prevY0=n,t._prevY1=n,t._prevSankeyWidth=0,t._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:g}}else f&&g>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:g});this._hasRenderedOnce=!0;const y=new Set(this.nodes.keys()),p=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of y)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)y.has(t)||this.removedNodes.add(t);for(const t of p)this.previousEdgeKeys.has(t)||this.addedEdges.add(t);for(const t of this.previousEdgeKeys)p.has(t)||this.removedEdges.add(t);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=y,this.previousEdgeKeys=p,this.layoutVersion++}buildScene(t){const e=Wi(this.config.chartType);if(!e)return;const n=Array.from(this.nodes.values()),i=Array.from(this.edges.values()),{sceneNodes:o,sceneEdges:r,labels:s}=e.buildScene(n,i,this.config,t);this.sceneNodes=o,this.sceneEdges=r,this.labels=s}get isAnimating(){const t=Wi(this.config.chartType);return!!(null==t?void 0:t.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(t,e){const n=Wi(this.config.chartType);if(!(null==n?void 0:n.tick))return!1;const i=Array.from(this.nodes.values()),o=Array.from(this.edges.values());return n.tick(i,o,this.config,t,e)}advanceTransition(t){if(!this.transition)return!1;const e=H(t,this.transition),n=F(e);for(const t of this.nodes.values())void 0===t._targetX0||void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=X(t._prevX0,t._targetX0,n),t.x1=X(t._prevX1,t._targetX1,n),t.y0=X(t._prevY0,t._targetY0,n),t.y1=X(t._prevY1,t._targetY1,n));for(const t of this.edges.values())void 0!==t._targetY0&&void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&(t._prevSankeyWidth>0||t._introFromZero)&&(t.y0=X(t._prevY0,t._targetY0,n),t.y1=X(t._prevY1,t._targetY1,n),t.sankeyWidth=X(t._prevSankeyWidth,t._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>e||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const t=this._boundedPrevSnapshot;for(const e of this.nodes.values()){const n=null==t?void 0:t.get(e.id);n&&0===e.x0&&0===e.x1&&0===e.y0&&0===e.y1?(e._prevX0=n.x0,e._prevX1=n.x1,e._prevY0=n.y0,e._prevY1=n.y1):(e._prevX0=e.x0,e._prevX1=e.x1,e._prevY0=e.y0,e._prevY1=e.y1)}const e=this._boundedEdgeSnapshot;for(const t of this.edges.values()){if(e&&0===t.sankeyWidth){const n=e.get(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`);if(n){t._prevY0=n.y0,t._prevY1=n.y1,t._prevSankeyWidth=n.sankeyWidth;continue}}t._prevY0=t.y0,t._prevY1=t.y1,t._prevSankeyWidth=t.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}finalizeLayout(){const t="vertical"===this.config.orientation?"down":"right";for(const t of this.nodes.values())if(0!==t.x0||0!==t.x1||0!==t.y0||0!==t.y1)t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;else{const e=5;t.x0=t.x-e,t.x1=t.x+e,t.y0=t.y-e,t.y1=t.y+e,t.width=2*e,t.height=2*e}for(const e of this.edges.values())e.direction=t,this.updateEdgeBezier(e);this.tension=0}saveTargetPositions(){for(const t of this.nodes.values())t._targetX0=t.x0,t._targetX1=t.x1,t._targetY0=t.y0,t._targetY1=t.y1;for(const t of this.edges.values())t._targetY0=t.y0,t._targetY1=t.y1,t._targetSankeyWidth=t.sankeyWidth}restorePreviousPositions(){for(const t of this.nodes.values())void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=t._prevX0,t.x1=t._prevX1,t.y0=t._prevY0,t.y1=t._prevY1);for(const t of this.edges.values())void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&t._prevSankeyWidth>0&&(t.y0=t._prevY0,t.y1=t._prevY1,t.sankeyWidth=t._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const t of this.nodes.values())void 0!==t._targetX0&&(t.x0=t._targetX0,t.x1=t._targetX1,t.y0=t._targetY0,t.y1=t._targetY1);for(const t of this.edges.values())void 0!==t._targetY0&&(t.y0=t._targetY0,t.y1=t._targetY1,t.sankeyWidth=t._targetSankeyWidth),t._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(t){const e="string"==typeof t.source?this.nodes.get(t.source):t.source,n="string"==typeof t.target?this.nodes.get(t.target):t.target;e&&n&&(t.bezier=t.circular&&t.circularPathData?this.buildCircularBezier(t):this.buildStandardBezier(t,e,n))}buildStandardBezier(t,e,n){const i=(t.sankeyWidth||1)/2;if("down"===t.direction){const o=e.x1,r=n.x0,s=d.interpolateNumber(o,r);return{circular:!1,points:[{x:t.y0,y:o},{x:t.y0,y:s(.5)},{x:t.y1,y:s(.5)},{x:t.y1,y:r}],halfWidth:i}}const o=e.x1,r=n.x0,s=d.interpolateNumber(o,r);return{circular:!1,points:[{x:o,y:t.y0},{x:s(.5),y:t.y0},{x:s(.5),y:t.y1},{x:r,y:t.y1}],halfWidth:i}}buildCircularBezier(t){const e=(t._circularWidth||t.sankeyWidth||1)/2,n=t.circularPathData;if(t._circularStub){const t=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),i=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*t,y:n.sourceY},{x:n.sourceX+.66*t,y:n.sourceY},{x:n.sourceX+t,y:n.sourceY}],[{x:n.targetX-i,y:n.targetY},{x:n.targetX-.66*i,y:n.targetY},{x:n.targetX-.33*i,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:e}}let i;i="down"===t.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const o=[];for(let t=0;i.length-1>t;t++){const e=i[t],n=i[t+1],r=n.x-e.x,s=n.y-e.y;o.push([e,{x:e.x+r/3,y:e.y+s/3},{x:e.x+2*r/3,y:e.y+2*s/3},n])}return{circular:!0,segments:o,halfWidth:e}}rebuildAllBeziers(){for(const t of this.nodes.values())t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;for(const t of this.edges.values())this.updateEdgeBezier(t)}applyPulse(t){var e,n,i,o,r;const s=this.config.pulse;if(!s)return;const l=null!==(e=s.duration)&&void 0!==e?e:500,a=null!==(n=s.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(i=s.glowRadius)&&void 0!==i?i:4;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const i=this.nodeTimestamps.get(n);if(!i)continue;const o=t-i;l>o&&(e._pulseIntensity=1-o/l,e._pulseColor=a,e._pulseGlowRadius=c)}for(const e of this.sceneEdges){const n=e.datum;if(!n)continue;const i="object"==typeof n.source?null===(o=n.source)||void 0===o?void 0:o.id:n.source,s="object"==typeof n.target?null===(r=n.target)||void 0===r?void 0:r.id:n.target;if(!i||!s)continue;const c=this.edgeTimestamps.get(`${i}\0${s}`);if(!c)continue;const u=t-c;l>u&&(e._pulseIntensity=1-u/l,e._pulseColor=a)}}applyDecay(){var t,e;const n=this.config.decay;if(!n)return;const i=this.nodeTimestamps.size;if(1>=i)return;this._decaySortedNodes||(this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((t,e)=>t[1]-e[1]));const o=this._decaySortedNodes,r=new Map;for(let t=0;o.length>t;t++)r.set(o[t][0],t);for(const o of this.sceneNodes){const s=o.id;if(!s)continue;const l=r.get(s);if(void 0===l)continue;const a=Y(n,l,i),c=null!==(e=null===(t=o.style)||void 0===t?void 0:t.opacity)&&void 0!==e?e:1;o.style=Object.assign(Object.assign({},o.style),{opacity:c*a})}}applyTopologyDiff(t){var e;if(0===this.addedNodes.size)return;const n=t-this.lastTopologyChangeTime;if(n>=2e3)return;const i=1-n/2e3;for(const t of this.sceneNodes){const n=t.id;n&&this.addedNodes.has(n)&&(t._pulseIntensity=Math.max(null!==(e=t._pulseIntensity)&&void 0!==e?e:0,i),t._pulseColor="rgba(34, 197, 94, 0.7)",t._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(t){var e,n;const i=this.config.thresholds;if(!i)return;const o=null!==(e=i.warningColor)&&void 0!==e?e:"#f59e0b",r=null!==(n=i.criticalColor)&&void 0!==n?n:"#ef4444",s=!1!==i.pulse;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const l=this.nodes.get(n);if(!l)continue;const a=i.metric(l);let c=null;void 0===i.critical||i.critical>a?void 0===i.warning||i.warning>a||(c=o):c=r,c&&(e.style=Object.assign(Object.assign({},e.style),{fill:c}),s&&(e._pulseIntensity=.6+.4*Math.sin(t/300),e._pulseColor=c,e._pulseGlowRadius=6))}}get hasActiveThresholds(){const t=this.config.thresholds;if(!t)return!1;for(const e of this.nodes.values()){const n=t.metric(e);if(void 0!==t.warning&&n>=t.warning||void 0!==t.critical&&n>=t.critical)return!0}return!1}get hasActivePulses(){var t;const e=this.config.pulse;if(!e||0===this.lastIngestTime)return!1;const n="undefined"!=typeof performance?performance.now():Date.now();return(null!==(t=e.duration)&&void 0!==t?t:500)>n-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(t,e){var n;const i=this.nodes.get(t);if(!i)return null;const o=i.data?Object.assign({},i.data):{};return i.data=e(null!==(n=i.data)&&void 0!==n?n:{}),this.layoutVersion++,o}updateEdge(t,e,n){var i;const o=this.config.valueAccessor,r="function"==typeof o?o:o?t=>t[o]:t=>t.value,s=[];for(const[,o]of this.edges)if(("string"==typeof o.source?o.source:o.source.id)===t&&("string"==typeof o.target?o.target:o.target.id)===e){s.push(o.data?Object.assign({},o.data):{}),o.data=n(null!==(i=o.data)&&void 0!==i?i:{});const t=r(o.data);null!=t&&(o.value=Number(t))}return s.length>0&&this.layoutVersion++,s}removeNode(t){if(!this.nodes.has(t))return!1;this.nodes.delete(t),this.nodeTimestamps.delete(t);for(const[e,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==t&&("string"==typeof n.target?n.target:n.target.id)!==t||(this.edges.delete(e),this.edgeTimestamps.delete(e));return this.layoutVersion++,!0}removeEdge(t,e){const n=[];if(void 0===e){const e=this.config.edgeIdAccessor;if(!e)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const i="function"==typeof e?e:t=>null==t?void 0:t[e];for(const[e,o]of this.edges)o.data&&i(o.data)===t&&n.push(e)}else for(const[i,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===t&&("string"==typeof o.target?o.target:o.target.id)===e&&n.push(i);for(const t of n)this.edges.delete(t),this.edgeTimestamps.delete(t);return n.length>0&&this.layoutVersion++,n.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function zi(t){return{id:t,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function Yi(t,e,n,i,o=30){let r=null,s=o,l=1/0;for(const e of t){const t=Bi(e,n,i,o);if(t)if("rect"===e.type){const n=e.w*e.h;l>n&&(r=t,l=n)}else s>t.distance&&(r=t,s=t.distance)}if(r)return r;for(const t of e){const e=Vi(t,n,i);e&&s>e.distance&&(r=e,s=e.distance)}return r}function Bi(t,e,n,i=30){switch(t.type){case"circle":return function(t,e,n,i=30){const o=e-t.cx,r=n-t.cy,s=Math.sqrt(o*o+r*r);return s>ot(t.r,i)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:s}}(t,e,n,i);case"rect":return function(t,e,n){const i=it(e,n,t);return i.hit?{type:"node",datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}(t,e,n);case"arc":return function(t,e,n){const i=e-t.cx,o=n-t.cy,r=Math.sqrt(i*i+o*o);if(t.innerR-2>r||r>t.outerR+2)return null;const s=lt(Math.atan2(o,i)),l=lt(t.startAngle),a=lt(t.endAngle);if(l>a?s>=l||a>=s:s>=l&&a>=s){const e=(t.startAngle+t.endAngle)/2,n=(t.innerR+t.outerR)/2;return{type:"node",datum:t.datum,x:t.cx+n*Math.cos(e),y:t.cy+n*Math.sin(e),distance:0}}return null}(t,e,n);default:return null}}let Fi=null,Hi=null;function Xi(){return Hi||(Fi=document.createElement("canvas"),Fi.width=1,Fi.height=1,Hi=Fi.getContext("2d")),Hi}function Gi(t){if(t._cachedPath2D&&t._cachedPath2DSource===t.pathD)return t._cachedPath2D;try{return t._cachedPath2D=new Path2D(t.pathD),t._cachedPath2DSource=t.pathD,t._cachedPath2D}catch(t){return null}}function Vi(t,e,n){switch(t.type){case"bezier":return function(t,e,n){var i,o;if(!t.pathD)return null;const r=Gi(t),s=Xi();if(!r||!s)return null;try{if(s.isPointInPath(r,e,n)){const r="object"==typeof(null===(i=t.datum)||void 0===i?void 0:i.source)?t.datum.source:null,s="object"==typeof(null===(o=t.datum)||void 0===o?void 0:o.target)?t.datum.target:null;return{type:"edge",datum:t.datum,x:r&&s?(r.x1+s.x0)/2:e,y:t.datum?(t.datum.y0+t.datum.y1)/2:n,distance:0}}const l=s.lineWidth;s.lineWidth=10;const a=s.isPointInStroke(r,e,n);if(s.lineWidth=l,a)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch(t){}return null}(t,e,n);case"line":return function(t,e,n){const i=t.x2-t.x1,o=t.y2-t.y1,r=i*i+o*o;if(0===r)return null;let s=((e-t.x1)*i+(n-t.y1)*o)/r;s=Math.max(0,Math.min(1,s));const l=t.x1+s*i,a=t.y1+s*o,c=Math.sqrt(Math.pow(e-l,2)+Math.pow(n-a,2));return c>5?null:{type:"edge",datum:t.datum,x:l,y:a,distance:c}}(t,e,n);case"ribbon":case"curved":return function(t,e,n){if(!t.pathD)return null;const i=Gi(t),o=Xi();if(!i||!o)return null;try{if(o.isPointInPath(i,e,n))return{type:"edge",datum:t.datum,x:e,y:n,distance:0};const r=o.lineWidth;o.lineWidth=10;const s=o.isPointInStroke(i,e,n);if(o.lineWidth=r,s)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch(t){}return null}(t,e,n);default:return null}}function qi(e){const{width:n,height:i,totalWidth:o,totalHeight:r,margin:s,labels:l,title:a,legend:c,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f,legendPosition:g="right",foregroundGraphics:y,sceneNodes:v,annotations:m,svgAnnotationRules:x}=e;return t.jsxs(t.Fragment,{children:[t.jsxs("svg",{role:"img",width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[t.jsx("title",{children:"string"==typeof a?a:"Network Chart"}),t.jsx("desc",{children:"string"==typeof a?a+" — network data visualization":"Network data visualization"}),t.jsxs("g",{transform:`translate(${s.left},${s.top})`,children:[l.map((e,n)=>t.jsx("text",{x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"currentColor",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"},children:e.text},"label-"+n)),m&&m.filter(t=>"widget"!==t.type).map((e,o)=>{if(x){const r=x(e,o,{width:n,height:i,sceneNodes:v});if(r)return t.jsx(p.Fragment,{children:r},"annotation-"+o)}return null}),y]}),a&&"string"==typeof a?t.jsx("text",{x:o/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor",children:a}):a?t.jsx("foreignObject",{x:0,y:0,width:o,height:s.top,children:a}):null,Lt({legend:c,totalWidth:o,totalHeight:r,margin:s,legendPosition:g,title:a,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f})]}),null==m?void 0:m.filter(t=>"widget"===t.type&&t.nodeId&&v).map((e,n)=>{var i,o,r,l,a,c,u,d,h;const f=v.find(t=>{var n,i,o,r,s;return t.id===e.nodeId||(null===(n=t.datum)||void 0===n?void 0:n.id)===e.nodeId||(null===(o=null===(i=t.datum)||void 0===i?void 0:i.data)||void 0===o?void 0:o.id)===e.nodeId||(null===(s=null===(r=t.datum)||void 0===r?void 0:r.data)||void 0===s?void 0:s.name)===e.nodeId});if(!f)return null;const g=s.left+(null!==(i=f.cx)&&void 0!==i?i:null!=f.x&&null!=f.w?f.x+f.w/2:null!==(o=f.x)&&void 0!==o?o:0),y=s.top+(null!==(r=f.cy)&&void 0!==r?r:null!=f.y&&null!=f.h?f.y+f.h/2:null!==(l=f.y)&&void 0!==l?l:0),p=null!==(a=e.dx)&&void 0!==a?a:0,m=null!==(c=e.dy)&&void 0!==c?c:-16,x=null!==(u=e.width)&&void 0!==u?u:32,b=null!==(d=e.height)&&void 0!==d?d:32,k=null!==(h=e.content)&&void 0!==h?h:t.jsx("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return t.jsx("div",{style:{position:"absolute",left:g+p-x/2,top:y+m-b/2,width:x,height:b,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5},children:k},"widget-"+n)})]})}function Ui(t){return t._cachedPath2D&&t._cachedPath2DSource===t.pathD||(t._cachedPath2D=new Path2D(t.pathD),t._cachedPath2DSource=t.pathD),t._cachedPath2D}function Ki(t,e){var n,i,o,r,s,l;if(!e.pathD)return;t.save();const a=Ui(e);if(e.style.fill&&"none"!==e.style.fill){const s=e._gradient;if(s){const o=t.createLinearGradient(s.x0,0,s.x1,0),r=null!==(i=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==i?i:.5,l="string"==typeof e.style.fill?e.style.fill:"#999",a=ze(t,l)||l;o.addColorStop(0,1===s.from?a:"transparent"),o.addColorStop(1,1===s.to?a:"transparent"),t.fillStyle=o,t.globalAlpha=r}else t.fillStyle="string"==typeof e.style.fill&&ze(t,e.style.fill)||e.style.fill,t.globalAlpha=null!==(r=null!==(o=e.style.fillOpacity)&&void 0!==o?o:e.style.opacity)&&void 0!==r?r:.5;t.fill(a)}e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=ze(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(s=e.style.strokeWidth)&&void 0!==s?s:.5,t.globalAlpha=.5*(null!==(l=e.style.opacity)&&void 0!==l?l:1),t.stroke(a)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.2*e._pulseIntensity,t.fill(a)),t.restore()}function Zi(t,e){var n,i;t.save();const o=e.style.stroke||"#999";t.strokeStyle=ze(t,o)||o,t.lineWidth=null!==(n=e.style.strokeWidth)&&void 0!==n?n:1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.strokeDasharray&&t.setLineDash(e.style.strokeDasharray.split(/[\s,]+/).map(Number)),t.beginPath(),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.stroke(),e._pulseIntensity&&e._pulseIntensity>0&&(t.setLineDash([]),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=(null!==(i=e.style.strokeWidth)&&void 0!==i?i:1)+3*e._pulseIntensity,t.globalAlpha=.4*e._pulseIntensity,t.beginPath(),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.stroke()),t.restore()}function Qi(t,e){var n,i,o,r;if(!e.pathD)return;t.save();const s=Ui(e);e.style.fill&&"none"!==e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&ze(t,e.style.fill)||e.style.fill,t.globalAlpha=null!==(i=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==i?i:.5,t.fill(s)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=ze(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(o=e.style.strokeWidth)&&void 0!==o?o:.5,t.globalAlpha=.3*(null!==(r=e.style.opacity)&&void 0!==r?r:1),t.stroke(s)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.25*e._pulseIntensity,t.fill(s)),t.restore()}function Ji(t,e){var n,i;if(!e.pathD)return;t.save();const o=Ui(e),r=e.style.stroke||"#999";t.strokeStyle=ze(t,r)||r,t.lineWidth=null!==(n=e.style.strokeWidth)&&void 0!==n?n:1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.stroke(o),e.style.fill&&"none"!==e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&ze(t,e.style.fill)||e.style.fill,t.globalAlpha=null!==(i=e.style.fillOpacity)&&void 0!==i?i:.1,t.fill(o)),t.restore()}qi.displayName="NetworkSVGOverlay";const to={top:20,right:80,bottom:20,left:80},eo={top:40,right:40,bottom:40,left:40},no=new Set(["chord","force","circlepack","orbit"]),io=[800,600],oo={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function ro({data:e}){var n,i,o,r,s,l;if("edge"===e.nodeOrEdge){const n=e.data;return t.jsxs("div",{className:"semiotic-tooltip",style:oo,children:[t.jsxs("div",{style:{fontWeight:600},children:["object"==typeof n.source?n.source.id:n.source," → ","object"==typeof n.target?n.target.id:n.target]}),null!=n.value&&t.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof n.value?n.value.toLocaleString():n.value+""]})]})}const a=e.data,c=null==a?void 0:a.__hierarchyNode;if(c){const e=[];let s=c;for(;s;){const t=null!==(r=null!==(i=null===(n=s.data)||void 0===n?void 0:n.name)&&void 0!==i?i:null===(o=s.data)||void 0===o?void 0:o.id)&&void 0!==r?r:a.id;null!=t&&e.unshift(t+""),s=s.parent}e.length>1&&e.shift();const l=e.length-1;return t.jsxs("div",{className:"semiotic-tooltip",style:oo,children:[t.jsx("div",{children:e.map((e,n)=>t.jsxs("span",{children:[n>0&&t.jsx("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),n===l?t.jsx("strong",{children:e}):t.jsx("span",{style:{opacity:.7},children:e})]},n))}),null!=a.value&&a.value>0&&t.jsx("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof a.value?a.value.toLocaleString():a.value+""})]})}const u=((null===(s=a.sourceLinks)||void 0===s?void 0:s.length)||0)+((null===(l=a.targetLinks)||void 0===l?void 0:l.length)||0),d=(a.sourceLinks||[]).reduce((t,e)=>t+(e.value||0),0)+(a.targetLinks||[]).reduce((t,e)=>t+(e.value||0),0);return t.jsxs("div",{className:"semiotic-tooltip",style:oo,children:[t.jsx("div",{style:{fontWeight:600},children:a.id}),null!=a.value&&a.value>0&&t.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof a.value?a.value.toLocaleString():a.value+""]}),u>0&&t.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",u,d!==u&&` (weighted: ${d.toLocaleString()})`]})]})}const so=e.forwardRef(function(n,i){var o,r,s,l,a,u,d,h,f,g,y,p,v,m,x,b,k;const{chartType:w,nodes:A,edges:M,data:_,initialEdges:j,nodeIDAccessor:P="id",sourceAccessor:C="source",targetAccessor:E="target",valueAccessor:T="value",edgeIdAccessor:D,childrenAccessor:L,hierarchySum:O,orientation:N="horizontal",nodeAlign:$="justify",nodePaddingRatio:I=.05,nodeWidth:W=15,iterations:z=300,forceStrength:Y=.1,padAngle:B=.01,groupWidth:F=20,sortGroups:H,edgeSort:X,treeOrientation:G="vertical",edgeType:V="curve",padding:q,paddingTop:U,tensionConfig:K,showParticles:Z=!1,particleStyle:Q,nodeStyle:J,edgeStyle:tt,colorBy:et,colorScheme:nt="category10",edgeColorBy:it="source",edgeOpacity:ot=.5,colorByDepth:rt=!1,nodeSize:st=8,nodeSizeRange:lt=[5,20],nodeLabel:at,showLabels:ct=!0,labelMode:ut,size:dt=io,responsiveWidth:ht,responsiveHeight:ft,margin:gt,className:yt,background:pt,enableHover:vt=!0,tooltipContent:kt,customHoverBehavior:wt,customClickBehavior:St,onObservation:Mt,chartId:_t,onTopologyChange:jt,annotations:Pt,svgAnnotationRules:Ct,legend:Et,legendPosition:Tt,legendHoverBehavior:Dt,legendClickBehavior:Lt,legendHighlightedCategory:Ot,legendIsolatedCategories:Nt,title:$t,foregroundGraphics:It,backgroundGraphics:Wt,decay:Rt,pulse:zt,transition:Yt,animate:Bt,staleness:Ft,thresholds:Ht,accessibleTable:Xt=!0,description:Gt,summary:Vt,orbitMode:qt,orbitSize:Ut,orbitSpeed:Kt,orbitRevolution:Zt,orbitRevolutionStyle:Qt,orbitEccentricity:Jt,orbitShowRings:te,orbitAnimated:ee}=n,ne=no.has(w)?eo:to,ie=e.useRef(!0),oe=Be({sizeProp:dt,responsiveWidth:ht,responsiveHeight:ft,userMargin:gt,marginDefault:ne,foregroundGraphics:It,backgroundGraphics:Wt,animate:Bt,transitionProp:Yt,themeDirtyRef:ie}),{reducedMotionRef:re,responsiveRef:se,size:le,margin:ae,adjustedWidth:ce,adjustedHeight:he,resolvedForeground:fe,resolvedBackground:ge,transition:ye,introEnabled:ve,tableId:me,rafRef:xe,renderFnRef:be,scheduleRender:ke,currentTheme:we}=oe,Ae=e.useMemo(()=>Object.assign(Object.assign({},bn),K),[K]),Se=e.useMemo(()=>Object.assign(Object.assign({},kn),Q),[Q]),Me=e.useMemo(()=>{var t;return{chartType:w,nodeIDAccessor:P,sourceAccessor:C,targetAccessor:E,valueAccessor:T,edgeIdAccessor:D,childrenAccessor:L,hierarchySum:O,orientation:N,nodeAlign:$,nodePaddingRatio:I,nodeWidth:W,iterations:z,forceStrength:Y,padAngle:B,groupWidth:F,sortGroups:H,edgeSort:X,treeOrientation:G,edgeType:V,padding:q,paddingTop:U,tensionConfig:Ae,showParticles:Z,particleStyle:Se,nodeStyle:J,edgeStyle:tt,nodeLabel:at,showLabels:ct,labelMode:ut,colorBy:et,colorScheme:nt,themeCategorical:null===(t=null==we?void 0:we.colors)||void 0===t?void 0:t.categorical,themeSemantic:S(we),edgeColorBy:it,edgeOpacity:ot,colorByDepth:rt,nodeSize:st,nodeSizeRange:lt,decay:Rt,pulse:zt,transition:ye,introAnimation:ve,staleness:Ft,thresholds:Ht,orbitMode:qt,orbitSize:Ut,orbitSpeed:Kt,orbitRevolution:Zt,orbitRevolutionStyle:Qt,orbitEccentricity:Jt,orbitShowRings:te,orbitAnimated:ee}},[w,P,C,E,T,L,O,N,$,I,W,z,Y,B,F,H,X,G,V,q,U,Ae,Z,Se,J,tt,at,ct,ut,et,nt,it,ot,rt,st,lt,Rt,zt,null==ye?void 0:ye.duration,null==ye?void 0:ye.easing,ve,Ft,Ht,qt,Ut,Kt,Zt,Qt,Jt,te,ee,we]),Ee=e.useRef(null),Le=e.useRef(0),Oe=e.useRef(null);Oe.current||(Oe.current=new Ri(Me));const[Ne,$e]=e.useState(null),[Ie,We]=e.useState(0),[Re,Ye]=e.useState(0),[Xe,Ge]=e.useState(!1),Ve=e.useRef(null),qe=e.useRef(new Map),Ue=e.useRef(0),Ke=e.useCallback(t=>{if("function"==typeof et)return et(t)+"";if("string"==typeof et&&t.data){const e=t.data[et];if(void 0!==e){if(!qe.current.has(e+"")){const t=Array.isArray(nt)?nt:R;qe.current.set(e+"",t[Ue.current++%t.length])}return qe.current.get(e+"")}}if(qe.current.has(t.id))return qe.current.get(t.id);const e=Array.isArray(nt)?nt:R,n=et?e[Ue.current++%e.length]:e[0];return qe.current.set(t.id,n),n},[et,nt]),Je=(null===(o=null==we?void 0:we.colors)||void 0===o?void 0:o.border)||(null===(r=null==we?void 0:we.colors)||void 0===r?void 0:r.secondary)||(null===(s=null==we?void 0:we.colors)||void 0===s?void 0:s.primary)||"#999",tn=e.useCallback(t=>{if("function"==typeof it)return it(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===it&&n?Ke(n):e?Ke(e):Je},[it,Ke,Je]),en=e.useCallback(t=>{if(!(null==Q?void 0:Q.colorBy))return tn(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===Se.colorBy&&n?Ke(n):e?Ke(e):Je},[null==Q?void 0:Q.colorBy,Se.colorBy,Ke,tn,Je]),nn="sankey"===w&&Z||!!zt||null!==(a=null===(l=Oe.current)||void 0===l?void 0:l.isAnimating)&&void 0!==a&&a;e.useEffect(()=>{var t;null===(t=Oe.current)||void 0===t||t.updateConfig(Me),ie.current=!0,ke()},[Me,ke]),e.useEffect(()=>{var t;const e=Oe.current;if(e){e.buildScene([ce,he]);for(const n of e.sceneNodes)n.id&&"string"==typeof(null===(t=n.style)||void 0===t?void 0:t.fill)&&qe.current.set(n.id,n.style.fill);ie.current=!0,ke()}},[we,ce,he,ke]);const on=e.useCallback(()=>{var t;const e=Oe.current;if(!e)return;e.runLayout([ce,he]),e.buildScene([ce,he]),ie.current=!0;for(const n of e.sceneNodes)n.id&&"string"==typeof(null===(t=n.style)||void 0===t?void 0:t.fill)&&qe.current.set(n.id,n.style.fill);const n=Array.isArray(nt)?nt:R,i=Array.from(e.nodes.values());for(let t=0;i.length>t;t++){const e=i[t];qe.current.has(e.id)||qe.current.set(e.id,n[t%n.length])}if(Ue.current=i.length,We(e.layoutVersion),jt){const{nodes:t,edges:n}=e.getLayoutData();jt(t,n)}},[ce,he,jt,nt]),rn=e.useCallback(t=>{const e=Oe.current;e&&(e.ingestEdge(t)&&on(),ke())},[on,ke]),sn=e.useCallback(t=>{const e=Oe.current;if(!e)return;let n=!1;for(const i of t)e.ingestEdge(i)&&(n=!0);n&&on(),ke()},[on,ke]),ln=e.useCallback(()=>{var t;null===(t=Oe.current)||void 0===t||t.clear(),qe.current.clear(),Ue.current=0,We(0),$e(null),Ve.current=null,ie.current=!0,ke()},[ke]),cn=e.useCallback(()=>{const t=Oe.current;t&&(t.tension+=999,on(),ke())},[on,ke]);e.useImperativeHandle(i,()=>({push:rn,pushMany:sn,removeNode:t=>{var e,n,i;const o=null!==(n=null===(e=Oe.current)||void 0===e?void 0:e.removeNode(t))&&void 0!==n&&n;if(o){const e=(null===(i=Ve.current)||void 0===i?void 0:i.data)?"function"==typeof P?P(Ve.current.data):Ve.current.data[P]:void 0;Ve.current&&"node"===Ve.current.nodeOrEdge&&e===t&&(Ve.current=null,$e(null)),qe.current.delete(t),on(),ie.current=!0,ke()}return o},removeEdge:(t,e)=>{var n,i;const o=null!==(i=null===(n=Oe.current)||void 0===n?void 0:n.removeEdge(t,e))&&void 0!==i&&i;if(o){if(Ve.current&&"edge"===Ve.current.nodeOrEdge){const n=Ve.current.data;let i;i=void 0!==e?("object"==typeof(null==n?void 0:n.source)?n.source.id:null==n?void 0:n.source)===t&&("object"==typeof(null==n?void 0:n.target)?n.target.id:null==n?void 0:n.target)===e:!D||!n||("function"==typeof D?D:t=>null==t?void 0:t[D])(n)===t,i&&(Ve.current=null,$e(null))}on(),ie.current=!0,ke()}return o},updateNode:(t,e)=>{var n,i;const o=null!==(i=null===(n=Oe.current)||void 0===n?void 0:n.updateNode(t,e))&&void 0!==i?i:null;return o&&(ie.current=!0,ke()),o},updateEdge:(t,e,n)=>{var i,o;const r=null!==(o=null===(i=Oe.current)||void 0===i?void 0:i.updateEdge(t,e,n))&&void 0!==o?o:[];return r.length>0&&(on(),ie.current=!0,ke()),r},clear:ln,getTopology:()=>{var t,e;return null!==(e=null===(t=Oe.current)||void 0===t?void 0:t.getLayoutData())&&void 0!==e?e:{nodes:[],edges:[]}},getTopologyDiff:()=>{const t=Oe.current;return t?{addedNodes:Array.from(t.addedNodes),removedNodes:Array.from(t.removedNodes),addedEdges:Array.from(t.addedEdges),removedEdges:Array.from(t.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:cn,getTension:()=>{var t,e;return null!==(e=null===(t=Oe.current)||void 0===t?void 0:t.tension)&&void 0!==e?e:0}}),[rn,sn,ln,cn,on,ke]);const un=["tree","cluster","treemap","circlepack","partition","orbit"].includes(w),dn=un?_||(Array.isArray(M)?void 0:M):void 0;e.useEffect(()=>{var t;const e=Oe.current;if(e)if(un&&dn)e.ingestHierarchy(dn,[ce,he]),e.buildScene([ce,he]),ie.current=!0,ke();else{const n=A||[],i=Array.isArray(M)?M:[];if(0===n.length&&0===i.length)return;e.ingestBounded(n,i,[ce,he]),e.buildScene([ce,he]);for(const n of e.sceneNodes)n.id&&(null===(t=n.style)||void 0===t?void 0:t.fill)&&qe.current.set(n.id,n.style.fill+"");const o=Array.isArray(nt)?nt:R,r=Array.from(e.nodes.values());for(let t=0;r.length>t;t++){const e=r[t];qe.current.has(e.id)||qe.current.set(e.id,o[t%o.length])}Ue.current=r.length,ie.current=!0,ke()}},[A,M,_,dn,un,ce,he,Me,ke,nt]),e.useEffect(()=>{j&&j.length>0&&sn(j)},[]);const hn=e.useCallback(t=>{if(wt&&wt(t),Mt){const e=Date.now();Mt(t?{type:"hover",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:_t}:{type:"hover-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:_t})}},[wt,Mt,_t]),fn=e.useCallback(t=>{if(St&&St(t),Mt){const e=Date.now();Mt(t?{type:"click",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:_t}:{type:"click-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:_t})}},[St,Mt,_t]),{hoverHandlerRef:gn,hoverLeaveRef:yn,onPointerMove:pn,onPointerLeave:vn}=oe;gn.current=t=>{if(!vt)return;const e=Ee.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-ae.left,o=t.clientY-n.top-ae.top;if(0>i||i>ce||0>o||o>he)return void(Ve.current&&(Ve.current=null,$e(null),hn&&(hn(null),ie.current=!0),ke()));const r=Oe.current;if(!r)return;const s=Yi(r.sceneNodes,r.sceneEdges,i,o);if(!s)return void(Ve.current&&(Ve.current=null,$e(null),hn&&(hn(null),ie.current=!0),ke()));const l=an(s.datum||{},s.x,s.y,{nodeOrEdge:s.type});Ve.current=l,$e(l),hn&&(hn(l),ie.current=!0),ke()},yn.current=()=>{Ve.current&&(Ve.current=null,$e(null),hn&&(hn(null),ie.current=!0),ke())};const mn=e.useRef(()=>{});mn.current=t=>{if(!St&&!Mt)return;const e=Ee.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-ae.left,o=t.clientY-n.top-ae.top;if(0>i||i>ce||0>o||o>he)return;const r=Oe.current;if(!r)return;const s=Yi(r.sceneNodes,r.sceneEdges,i,o);fn(s?an(s.datum||{},s.x,s.y,{nodeOrEdge:s.type}):null)};const xn=e.useCallback(t=>mn.current(t),[]),wn=e.useRef(-1),An=e.useRef(null),Sn=e.useRef(-1),Mn=e.useCallback(t=>{var e;const n=Oe.current;if(!n)return;const i=function(t){var e,n,i,o,r,s;const l=[];for(const a of t)"circle"===a.type&&null!=a.cx?l.push({x:a.cx,y:a.cy,datum:a.datum,shape:"circle",group:null!==(n=null===(e=a.datum)||void 0===e?void 0:e.id)&&void 0!==n?n:"_default"}):"rect"===a.type&&null!=a.x?l.push({x:a.x+a.w/2,y:a.y+a.h/2,datum:a.datum,shape:"rect",w:a.w,h:a.h,group:null!==(o=null===(i=a.datum)||void 0===i?void 0:i.id)&&void 0!==o?o:"_default"}):"arc"===a.type&&null!=a.cx&&l.push({x:a.cx,y:a.cy,datum:a.datum,shape:"circle",group:null!==(s=null===(r=a.datum)||void 0===r?void 0:r.id)&&void 0!==s?s:"_default"});return l.sort((t,e)=>t.x-e.x||t.y-e.y),l}(n.sceneNodes);if(0===i.length)return;const o=mt(i),r=wn.current;if(0>r){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(t.key))return;t.preventDefault(),wn.current=0,Sn.current=-1;const e=o.flat[0];An.current={shape:e.shape,w:e.w,h:e.h};const n=an(e.datum||{},e.x,e.y,{nodeOrEdge:"node"});return Ve.current=n,$e(n),hn&&(hn(n),ie.current=!0),void ke()}const s=xt(o,r),l=function(t,e,n,i,o){var r,s,l;const a=n.flat[e.flatIndex];if(!a)return bt(t,e,n);const c=null===(r=a.datum)||void 0===r?void 0:r.id;switch(t){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const i=null!==(s=function(t,e,n){let i=null,o=1/0;for(let r=0;t.flat.length>r;r++){const s=t.flat[r];if(s===e)continue;const l=s.x-e.x,a=s.y-e.y;let c=!1;switch(n){case"right":c=l>0&&Math.abs(l)>=Math.abs(a);break;case"left":c=0>l&&Math.abs(l)>=Math.abs(a);break;case"down":c=a>0&&Math.abs(a)>=Math.abs(l);break;case"up":c=0>a&&Math.abs(a)>=Math.abs(l)}if(!c)continue;const u=l*l+a*a;o>u&&(o=u,i=r)}return i}(n,a,"ArrowRight"===t?"right":"ArrowLeft"===t?"left":"ArrowDown"===t?"down":"up"))&&void 0!==s?s:e.flatIndex;return i!==e.flatIndex&&(o.current=-1),i}case"Enter":{if(null==c)return e.flatIndex;const t=function(t,e){var n,i,o;const r=t+"",s=[];for(const t of e){const e=null!==(n=t.datum)&&void 0!==n?n:t,l="object"==typeof e.source?null===(i=e.source)||void 0===i?void 0:i.id:e.source,a="object"==typeof e.target?null===(o=e.target)||void 0===o?void 0:o.id:e.target,c=null!=l,u=null!=a;c&&l+""===r&&u?s.push(a+""):u&&a+""===r&&c&&s.push(l+"")}return s}(c,i);if(0===t.length)return e.flatIndex;const r=null!==(l=n.idToIdx.get(t[(o.current+1)%t.length]))&&void 0!==l?l:-1;return 0>r?e.flatIndex:(o.current=-1,r)}default:{const i=bt(t,e,n);return null!==i&&i!==e.flatIndex&&(o.current=-1),i}}}(t.key,s,o,null!==(e=n.sceneEdges)&&void 0!==e?e:[],Sn);if(null===l)return;if(t.preventDefault(),0>l)return wn.current=-1,An.current=null,Sn.current=-1,Ve.current=null,$e(null),hn&&(hn(null),ie.current=!0),void ke();wn.current=l;const a=o.flat[l];An.current={shape:a.shape,w:a.w,h:a.h};const c=a.datum||{},u=Object.assign(Object.assign({},"object"!=typeof c||null===c||Array.isArray(c)?{}:c),{data:c,x:a.x,y:a.y,time:a.x,value:a.y,nodeOrEdge:"node"});Ve.current=u,$e(u),hn&&(hn(u),ie.current=!0),ke()},[hn,ke]),_n=e.useCallback(t=>{wn.current=-1,An.current=null,pn(t)},[pn]);be.current=()=>{var t,e,n,i,o,r,s;xe.current=0;const l=Ee.current;if(!l)return;const a=l.getContext("2d");if(!a)return;const c=Oe.current;if(!c)return;const u=performance.now(),d=Le.current?Math.min((u-Le.current)/1e3,.1):.016;Le.current=u;const h=c.advanceTransition(re.current?u+1e6:u),f=!re.current&&h,g=!re.current&&c.tickAnimation([ce,he],d);(h||ie.current||g)&&c.buildScene([ce,he]);const y=He();if(!Fe(l,le,ae,y))return;a.clearRect(-ae.left,-ae.top,le[0],le[1]),pt&&(a.fillStyle=pt,a.fillRect(0,0,ce,he)),Rt&&c.applyDecay(),zt&&c.applyPulse(u),Ht&&c.applyThresholds(u),c.applyTopologyDiff(u);const p=null!==(t=null==Ft?void 0:Ft.threshold)&&void 0!==t?t:5e3,v=Ft&&c.lastIngestTime>0&&u-c.lastIngestTime>p;if(v&&(a.globalAlpha=null!==(e=null==Ft?void 0:Ft.dimOpacity)&&void 0!==e?e:.5),function(t,e){for(const n of e)switch(n.type){case"bezier":Ki(t,n);break;case"line":Zi(t,n);break;case"ribbon":Qi(t,n);break;case"curved":Ji(t,n)}}(a,c.sceneEdges),function(t,e){var n,i,o;for(const r of e){if("rect"!==r.type)continue;const e=r;e.w>0&&e.h>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&ze(t,e.style.fill)||e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fillRect(e.x,e.y,e.w,e.h)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=ze(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.strokeRect(e.x,e.y,e.w,e.h)),Ze(t,e),t.restore())}}(a,c.sceneNodes),function(t,e){var n,i,o;for(const r of e){if("circle"!==r.type)continue;const e=r;e.r>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.r,0,2*Math.PI),e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&ze(t,e.style.fill)||e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=ze(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.stroke()),Qe(t,e),t.restore())}}(a,c.sceneNodes),function(t,e){var n,i,o;for(const r of e){if("arc"!==r.type)continue;const e=r;t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.outerR,e.startAngle,e.endAngle),t.arc(e.cx,e.cy,e.innerR,e.endAngle,e.startAngle,!0),t.closePath(),e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&ze(t,e.style.fill)||e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=ze(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.stroke()),t.restore()}}(a,c.sceneNodes),Z&&c.particlePool&&!v){const t=Array.from(c.edges.values());if(t.length>0){!function(t,e,n,i){var o,r;const s=null!==(o=i.spawnRate)&&void 0!==o?o:kn.spawnRate,l=null!==(r=i.maxPerEdge)&&void 0!==r?r:kn.maxPerEdge;for(let i=0;e.length>i;i++){const o=e[i];if(!o.bezier)continue;if(t.countForEdge(i)>=l)continue;const r=o.value*s*n*(o.bezier.circular?.3:1),a=Math.floor(r),c=r-a;let u=a;Math.random()<c&&u++;for(let e=0;u>e&&t.countForEdge(i)<l;e++)t.spawn(i)}}(c.particlePool,t,d,Se);const e=.5*(null!==(n=Se.speedMultiplier)&&void 0!==n?n:1);let i;if(Se.proportionalSpeed){const e=t.reduce((t,e)=>Math.max(t,e.value||1),1);i=t.map(t=>.3+(t.value||1)/e*1.7)}c.particlePool.step(d,e,t,i),function(t,e,n,i,o){var r,s;const l=null!==(r=i.radius)&&void 0!==r?r:kn.radius,a=null!==(s=i.opacity)&&void 0!==s?s:kn.opacity;t.globalAlpha=a;for(let r=0;e.particles.length>r;r++){const s=e.particles[r];if(!s.active)continue;const a=n[s.edgeIndex];if(a){if("function"==typeof i.color){const e="object"==typeof a.source?a.source:null;t.fillStyle=e?i.color(a,e):ze(t,"var(--semiotic-secondary, #666)")}else t.fillStyle=i.color&&"inherit"!==i.color?i.color:o(a);t.beginPath(),t.arc(s.x,s.y,l,0,2*Math.PI),t.fill()}}t.globalAlpha=1}(a,c.particlePool,t,Se,en)}}v&&(a.globalAlpha=1);const m=ie.current;if(ie.current=!1,m||f||g){const t=Ee.current;t&&t.setAttribute("aria-label",pe(null!==(o=null===(i=c.sceneNodes)||void 0===i?void 0:i.length)&&void 0!==o?o:0,null!==(s=null===(r=c.sceneEdges)||void 0===r?void 0:r.length)&&void 0!==s?s:0,"Network chart"))}(m||f||g)&&Ye(t=>t+1),(nn||f||null!=c.transition||g||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff)&&(xe.current=requestAnimationFrame(()=>be.current()))},e.useEffect(()=>(ke(),()=>{}),[ke]),e.useEffect(()=>{ie.current=!0,ke()},[w,ce,he,pt,ke]),At(Ft,Oe,ie,ke,Xe,Ge);const jn=vt&&Ne?t.jsx(De,{x:Ne.x,y:Ne.y,containerWidth:ce,containerHeight:he,margin:ae,className:"stream-network-tooltip",zIndex:2,children:kt?kt(Ne):t.jsx(ro,{data:Ne})}):null;if(de){const e=Oe.current;if(e){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(w),n=t?_||(Array.isArray(M)?void 0:M):void 0;if(t&&n)e.ingestHierarchy(n,[ce,he]),e.buildScene([ce,he]);else{const t=A||[],n=Array.isArray(M)?M:[];(t.length>0||n.length>0)&&(e.ingestBounded(t,n,[ce,he]),e.buildScene([ce,he]))}}const n=null!==(u=null==e?void 0:e.sceneNodes)&&void 0!==u?u:[],i=null!==(d=null==e?void 0:e.sceneEdges)&&void 0!==d?d:[],o=null!==(h=null==e?void 0:e.labels)&&void 0!==h?h:[];return t.jsxs("div",{className:"stream-network-frame"+(yt?" "+yt:""),role:"img","aria-label":Gt||("string"==typeof $t?$t:"Network chart"),style:{position:"relative",width:le[0],height:le[1]},children:[t.jsx(je,{summary:Vt}),t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:le[0],height:le[1],style:{position:"absolute",left:0,top:0},children:[ge&&t.jsx("g",{transform:`translate(${ae.left},${ae.top})`,children:ge}),t.jsxs("g",{transform:`translate(${ae.left},${ae.top})`,children:[pt&&t.jsx("rect",{x:0,y:0,width:ce,height:he,fill:pt}),i.map((e,n)=>function(e,n){switch(e.type){case"line":return t.jsx("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+n);case"bezier":{const i=e;return t.jsx("path",{d:i.pathD,fill:ue(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-edge-"+n)}case"ribbon":{const i=e;return t.jsx("path",{d:i.pathD,fill:ue(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-edge-"+n)}case"curved":{const i=e;return t.jsx("path",{d:i.pathD,fill:ue(i.style.fill,"none"),stroke:i.style.stroke||"#999",strokeWidth:i.style.strokeWidth||1,opacity:i.style.opacity},"net-edge-"+n)}default:return null}}(e,n)).filter(Boolean),n.map((e,n)=>function(e,n){switch(e.type){case"circle":{const i=e;return t.jsx("circle",{cx:i.cx,cy:i.cy,r:i.r,fill:ue(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-circle-"+n)}case"rect":{const i=e;return t.jsx("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:ue(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-rect-"+n)}case"arc":{const i=e,o=c.arc().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2)({})||"";return t.jsx("path",{d:o,transform:`translate(${i.cx},${i.cy})`,fill:ue(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-arc-"+n)}default:return null}}(e,n)).filter(Boolean),o.map((e,n)=>function(e,n){return t.jsx("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"#333",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+n)}(e,n)).filter(Boolean)]})]}),t.jsx(qi,{width:ce,height:he,totalWidth:le[0],totalHeight:le[1],margin:ae,labels:o,sceneNodes:n,title:$t,legend:Et,legendPosition:Tt,legendHoverBehavior:Dt,legendClickBehavior:Lt,legendHighlightedCategory:Ot,legendIsolatedCategories:Nt,foregroundGraphics:fe,annotations:Pt,svgAnnotationRules:Ct,annotationFrame:0})]})}const Pn=Oe.current;return t.jsxs("div",{ref:se,className:"stream-network-frame"+(yt?" "+yt:""),role:"group","aria-label":Gt||("string"==typeof $t?$t:"Network chart"),tabIndex:0,style:{position:"relative",width:ht?"100%":le[0],height:ft?"100%":le[1],overflow:"visible"},onKeyDown:Mn,children:[Xt&&t.jsx(Pe,{tableId:me}),Xt&&t.jsx(_e,{nodes:null!==(f=null==Pn?void 0:Pn.sceneNodes)&&void 0!==f?f:[],edges:null!==(g=null==Pn?void 0:Pn.sceneEdges)&&void 0!==g?g:[],chartType:"Network chart",tableId:me,chartTitle:"string"==typeof $t?$t:void 0}),t.jsx(je,{summary:Vt}),t.jsxs("div",{role:"img","aria-label":Gt||("string"==typeof $t?$t:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:vt?_n:void 0,onMouseLeave:vt?vn:void 0,onClick:St||Mt?xn:void 0,children:[ge&&t.jsx("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:le[0],height:le[1],pointerEvents:"none",overflow:"visible"},children:t.jsx("g",{transform:`translate(${ae.left},${ae.top})`,children:ge})}),t.jsx("canvas",{ref:Ee,"aria-label":pe(null!==(p=null===(y=null==Pn?void 0:Pn.sceneNodes)||void 0===y?void 0:y.length)&&void 0!==p?p:0,null!==(m=null===(v=null==Pn?void 0:Pn.sceneEdges)||void 0===v?void 0:v.length)&&void 0!==m?m:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),t.jsx(Ce,{hoverPoint:Ne}),t.jsx(qi,{width:ce,height:he,totalWidth:le[0],totalHeight:le[1],margin:ae,labels:(null==Pn?void 0:Pn.labels)||[],sceneNodes:null==Pn?void 0:Pn.sceneNodes,title:$t,legend:Et,legendPosition:Tt,legendHoverBehavior:Dt,legendClickBehavior:Lt,legendHighlightedCategory:Ot,legendIsolatedCategories:Nt,foregroundGraphics:fe,annotations:Pt,svgAnnotationRules:Ct,annotationFrame:Re}),t.jsx(Te,{active:wn.current>=0,hoverPoint:Ne,margin:ae,size:le,shape:null===(x=An.current)||void 0===x?void 0:x.shape,width:null===(b=An.current)||void 0===b?void 0:b.w,height:null===(k=An.current)||void 0===k?void 0:k.h}),jn,(null==Ft?void 0:Ft.showBadge)&&t.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Ft.badgePosition?{top:4,left:4}:"bottom-left"===Ft.badgePosition?{bottom:4,left:4}:"bottom-right"===Ft.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Xe?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"}),children:Xe?"STALE":"LIVE"})]})]})});function lo(t){const e=[];for(const[n,i]of Object.entries(t.fields))if("point"===i.type)e.push(t=>i.values.has(t[n]));else{const[t,o]=i.range;e.push(e=>{const i=e[n];return i>=t&&o>=i})}return t=>e.every(e=>e(t))}function ao(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}so.displayName="StreamNetworkFrame";const[co,uo]=w(t=>({selections:new Map,setClause(e,n){t(t=>{const i=new Map(t.selections),o=ao(i,e),r=new Map(o.clauses);return r.set(n.clientId,n),i.set(e,Object.assign(Object.assign({},o),{clauses:r})),{selections:i}})},clearClause(e,n){t(t=>{const i=t.selections.get(e);if(!i)return{};const o=new Map(t.selections),r=new Map(i.clauses);return r.delete(n),o.set(e,Object.assign(Object.assign({},i),{clauses:r})),{selections:o}})},setResolution(e,n){t(t=>{const i=new Map(t.selections),o=ao(i,e);return i.set(e,Object.assign(Object.assign({},o),{resolution:n})),{selections:i}})},clearSelection(e){t(t=>{const n=new Map(t.selections),i=n.get(e);return i&&n.set(e,Object.assign(Object.assign({},i),{clauses:new Map})),{selections:n}})}})),[ho,fo]=w(t=>({observations:[],maxObservations:100,version:0,pushObservation(e){t(t=>{const n=t.observations;return n.push(e),n.length>t.maxObservations&&n.shift(),{version:t.version+1}})},clearObservations(){t(()=>({observations:[],version:0}))}}));function go(t){const n=e.useId(),i=t.clientId||n,{name:o}=t,r=uo(t=>t.selections.get(o)),s=uo(t=>t.setClause),l=uo(t=>t.clearClause),a=e.useMemo(()=>!!r&&r.clauses.size>0,[r]);return{predicate:e.useMemo(()=>r&&0!==r.clauses.size?function(t,e){const n=[];for(const[i,o]of t.clauses)"crossfilter"===t.resolution&&i===e||n.push(lo(o));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(r,i):()=>!0,[r,i]),isActive:a,selectPoints:e.useCallback(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"point",values:new Set(i)};s(o,{clientId:i,type:"point",fields:e})},[i,o,s]),selectInterval:e.useCallback(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"interval",range:i};s(o,{clientId:i,type:"interval",fields:e})},[i,o,s]),clear:e.useCallback(()=>{l(o,i)},[l,o,i]),clientId:i}}function yo({selection:t,linkedHover:n,fallbackFields:i=[],unwrapData:o=!1,onObservation:r,chartType:s,chartId:l,onClick:a,hoverHighlight:c,colorByField:u}){const d=e.useId(),h=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}:null}(n,i),f=go({name:(null==t?void 0:t.name)||"__unused__"}),g=function(t){const n=t.name||"hover",{fields:i}=t,{predicate:o,isActive:r,selectPoints:s,clear:l}=go({name:n});return{onHover:e.useCallback(t=>{if(!t)return void l();const e={};for(const n of i){const i=t[n];void 0!==i&&(e[n]=[i])}Object.keys(e).length>0&&s(e)},[i,s,l,n]),predicate:o,isActive:r}}({name:(null==h?void 0:h.name)||"hover",fields:(null==h?void 0:h.fields)||i||[]}),y=fo(t=>t.pushObservation),p=t?{isActive:f.isActive,predicate:f.predicate}:null,[v,m]=e.useState(null),x=u||i[0],b=e.useMemo(()=>{if(!c||null==v||!x)return null;const t=v,e=x;return{isActive:!0,predicate:n=>{var i;return("string"==typeof n[e]?n[e]:(null!==(i=n[e])&&void 0!==i?i:"")+"")===t}}},[c,v,x]),k=e.useCallback(t=>{var e,i;if(n)if(t){let e=t.data||t.datum||t;if(Array.isArray(e)&&(e=e[0]),"x-position"===(null==h?void 0:h.mode)&&h.xField){const t=null==e?void 0:e[h.xField];null!=t&&Number.isFinite(Number(t))&&function(t,e,n){const i=qt.positions.get(t);(null==i?void 0:i.locked)||i&&i.xValue===e&&i.sourceId===n||(qt={positions:new Map(qt.positions).set(t,{xValue:e,sourceId:n})},Kt())}(h.name||"hover",Number(t),d)}"x-position"!==(null==h?void 0:h.mode)&&g.onHover(e)}else"x-position"===(null==h?void 0:h.mode)&&Zt(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&g.onHover(null);if(c&&x)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=null==e?void 0:e[x];m(null!=n?n+"":null)}else m(null);if(r||y){const n={timestamp:Date.now(),chartType:s||"unknown",chartId:l};if(t){let o=t.data||t.datum||t;Array.isArray(o)&&(o=o[0]);const s=Object.assign(Object.assign({},n),{type:"hover",datum:o||{},x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(i=t.y)&&void 0!==i?i:0});r&&r(s),y&&y(s)}else{const t=Object.assign(Object.assign({},n),{type:"hover-end"});r&&r(t),y&&y(t)}}},[n,g,h,d,r,s,l,y,c,x]),w=e.useCallback(t=>{var e,n,i,o;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=null==e?void 0:e[h.xField];null!=n&&Number.isFinite(Number(n))&&function(t,e,n){const i=qt.positions.get(t);if(null==i?void 0:i.locked){const e=new Map(qt.positions);return e.delete(t),qt={positions:e},Kt(),!1}qt={positions:new Map(qt.positions).set(t,{xValue:e,sourceId:n,locked:!0})},Kt()}(h.name||"hover",Number(n),d)}if(t&&a){let i=t.data||t.datum||t;Array.isArray(i)&&(i=i[0]),a(i,{x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0})}if(r||y){const e={timestamp:Date.now(),chartType:s||"unknown",chartId:l};if(t){let n=t.data||t.datum||t;Array.isArray(n)&&(n=n[0]);const s=Object.assign(Object.assign({},e),{type:"click",datum:n||{},x:null!==(i=t.x)&&void 0!==i?i:0,y:null!==(o=t.y)&&void 0!==o?o:0});r&&r(s),y&&y(s)}else{const t=Object.assign(Object.assign({},e),{type:"click-end"});r&&r(t),y&&y(t)}}},[a,r,y,s,l,h,d]);return e.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const t=h.name||"hover";return()=>{Qt(t,d),Zt(t,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:p,hoverSelectionHook:b,customHoverBehavior:k,customClickBehavior:w,crosshairSourceId:d}}const po={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function vo(t,e,n){var i,o,r,s,l,a,c;const u=po[t||"primary"],d="context"===t||"sparkline"===t;return{width:null!==(i=e.width)&&void 0!==i?i:u.width,height:null!==(o=e.height)&&void 0!==o?o:u.height,showAxes:null!==(r=e.showAxes)&&void 0!==r?r:u.showAxes,showGrid:null!==(s=e.showGrid)&&void 0!==s?s:u.showGrid,enableHover:null!==(l=e.enableHover)&&void 0!==l?l:!!e.linkedHover||u.enableHover,showLegend:null!==(a=e.showLegend)&&void 0!==a?a:u.showLegend,showLabels:null!==(c=e.showLabels)&&void 0!==c?c:u.showLabels,title:d?void 0:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:d?void 0:e.xLabel,yLabel:d?void 0:e.yLabel,categoryLabel:d?void 0:e.categoryLabel,valueLabel:d?void 0:e.valueLabel,marginDefaults:mo(u.marginDefaults,e.showCategoryTicks,e.orientation),compactMode:d}}function mo(t,e,n){if(!1!==e)return t;const i=Object.assign({},t);return"horizontal"===n?i.left=Math.min(i.left,15):i.bottom=Math.min(i.bottom,15),i}"undefined"!=typeof process&&process;const xo={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},bo={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function ko(e,n,i,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?t.jsx("div",{style:Object.assign(Object.assign({},xo),{width:n,height:i}),children:o||"No data available"}):null}function wo(e,n,i){if(!e)return null;const o=Math.min(5,Math.floor(i/40)),r=Math.max(8,Math.floor(i/(3*o))),s=Math.max(6,Math.floor(i/(2.5*o))),l=Math.floor((i-(o*(r+s)-s))/2);return t.jsx("div",{style:{width:n,height:i,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:o},(e,i)=>t.jsx("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},bo),{position:"absolute",top:l+i*(r+s),left:Math.floor(.1*n),width:30+(37*i+13)%50+"%",height:r,opacity:.5+i%2*.2})},i))})}const Ao=e.forwardRef(function(n,i){var o,r,s,l;const a=vo(n.mode,{width:null!==(r=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==r?r:n.width,height:null!==(l=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==l?l:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:c,margin:u,className:d,arrowOfTime:h="right",windowMode:f="sliding",windowSize:g=200,data:y,timeAccessor:p,valueAccessor:v,timeExtent:m,valueExtent:x,extentPadding:b,stroke:k="#007bff",strokeWidth:w=2,strokeDasharray:A,opacity:S,background:M,tooltipContent:_,tooltip:j,onHover:P,annotations:C,svgAnnotationRules:E,tickFormatTime:T,tickFormatValue:D,decay:L,pulse:O,staleness:N,transition:$,linkedHover:I,selection:W,onObservation:R,chartId:z,loading:Y,emptyContent:B,emphasis:F,legendPosition:H}=n,X=a.showAxes,G=a.enableHover,V=null!=u?u:a.marginDefaults,q=null!=c?c:[a.width,a.height],U=null!=_?_:j,K=e.useRef(null),{customHoverBehavior:Z}=yo({selection:W,linkedHover:I,unwrapData:!0,onObservation:R,chartType:"RealtimeLineChart",chartId:z}),Q=e.useCallback(t=>{P&&P(t),Z(t)},[P,Z]);e.useImperativeHandle(i,()=>({push:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=K.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=K.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=K.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}));const J=wo(Y,q[0],q[1]),tt=J?null:ko(y,q[0],q[1],B),et={stroke:k,strokeWidth:w,strokeDasharray:A};return null!=S&&(et.opacity=S),J||tt||t.jsx(xn,{ref:K,chartType:"line",runtimeMode:"streaming",size:q,margin:V,className:F?`${d||""} semiotic-emphasis-${F}`.trim():d,arrowOfTime:h,windowMode:f,windowSize:g,data:y,timeAccessor:p,valueAccessor:v,xExtent:m,yExtent:x,extentPadding:b,lineStyle:et,showAxes:X,background:M,hoverAnnotation:G,tooltipContent:U,customHoverBehavior:Q,annotations:C,svgAnnotationRules:E,tickFormatTime:T,tickFormatValue:D,decay:L,pulse:O,staleness:N,transition:$,pointIdAccessor:n.pointIdAccessor,legendPosition:H})});Ao.displayName="RealtimeLineChart";const So=e.forwardRef(function(n,i){var o,r,s,l;const a=vo(n.mode,{width:null!==(r=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==r?r:n.width,height:null!==(l=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==l?l:n.height,showAxes:n.showAxes,enableHover:null!=n.enableHover?!!n.enableHover:void 0,linkedHover:n.linkedHover}),{binSize:c,size:u,margin:d,className:h,arrowOfTime:f="right",windowMode:g="sliding",windowSize:y=200,data:p,timeAccessor:v,valueAccessor:m,timeExtent:x,valueExtent:b,extentPadding:k,categoryAccessor:w,colors:A,fill:S,stroke:M,strokeWidth:_,opacity:j,gap:P,background:C,tooltipContent:E,tooltip:T,onHover:D,annotations:L,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:$,linkedHover:I,selection:W,decay:R,pulse:z,staleness:Y,transition:B,onObservation:F,chartId:H,loading:X,emptyContent:G,emphasis:V,legendPosition:q,brush:U,onBrush:K,linkedBrush:Z}=n,Q=a.showAxes,J=a.enableHover,tt=null!=d?d:a.marginDefaults,et=null!=u?u:[a.width,a.height],nt=null!=E?E:T,it=e.useRef(null),{customHoverBehavior:ot}=yo({selection:W,linkedHover:I,unwrapData:!0,onObservation:F,chartType:"RealtimeTemporalHistogram",chartId:H}),rt=e.useCallback(t=>{D&&D(t),ot(t)},[D,ot]),st=!0===U?{dimension:"x",snap:"bin"}:"x"===U?{dimension:"x"}:"object"==typeof U?U:void 0,lt=(at=Z)?"string"==typeof at?{name:at}:at:null;var at;const ct=function(t){const{name:n,xField:i,yField:o}=t,{predicate:r,isActive:s,selectInterval:l,clear:a}=go({name:n}),c=i&&o?"xyBrush":i?"xBrush":"yBrush",u=e.useCallback(t=>{if(!t)return void a();const e={};"xyBrush"===c&&Array.isArray(t)&&2===t.length?(i&&(e[i]=[Math.min(t[0][0],t[1][0]),Math.max(t[0][0],t[1][0])]),o&&(e[o]=[Math.min(t[0][1],t[1][1]),Math.max(t[0][1],t[1][1])])):"xBrush"===c&&Array.isArray(t)?i&&(e[i]=[Math.min(...t),Math.max(...t)]):"yBrush"===c&&Array.isArray(t)&&o&&(e[o]=[Math.min(...t),Math.max(...t)]),Object.keys(e).length>0&&l(e)},[c,i,o,l,a]);return{brushInteraction:e.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:r,isActive:s,clear:a}}(Object.assign({name:(null==lt?void 0:lt.name)||"__unused_hist_brush__",xField:(null==lt?void 0:lt.xField)||("string"==typeof v?v:"time")},(null==lt?void 0:lt.yField)?{yField:lt.yField}:{})),ut=e.useRef(ct.brushInteraction);ut.current=ct.brushInteraction;const dt=e.useCallback(t=>{if(K&&K(t),F&&F(t?{type:"brush",extent:t,timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:H}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:H}),lt){const e=ut.current;e.end(t?"xBrush"===e.brush?t.x:"yBrush"===e.brush?t.y:[[t.x[0],t.y[0]],[t.x[1],t.y[1]]]:null)}},[K,F,H,lt]);e.useImperativeHandle(i,()=>({push:t=>{var e;return null===(e=it.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=it.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=it.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=it.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=it.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=it.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=it.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}));const ht=wo(X,et[0],et[1]),ft=ht?null:ko(p,et[0],et[1],G),gt={};return null!=S&&(gt.fill=S),null!=M&&(gt.stroke=M),null!=_&&(gt.strokeWidth=_),null!=j&&(gt.opacity=j),null!=P&&(gt.gap=P),ht||ft||t.jsx(xn,{ref:it,chartType:"bar",runtimeMode:"streaming",size:et,margin:tt,className:V?`${h||""} semiotic-emphasis-${V}`.trim():h,arrowOfTime:f,windowMode:g,windowSize:y,data:p,timeAccessor:v,valueAccessor:m,xExtent:x,yExtent:b,extentPadding:k,binSize:c,categoryAccessor:w,barColors:A,barStyle:gt,showAxes:Q,background:C,hoverAnnotation:J,tooltipContent:nt,customHoverBehavior:rt,annotations:L,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:$,decay:R,pulse:z,staleness:Y,transition:B,pointIdAccessor:n.pointIdAccessor,legendPosition:q,brush:st||(Z?{dimension:"x"}:void 0),onBrush:st||Z?dt:void 0})});So.displayName="RealtimeTemporalHistogram";const Mo=So,_o=e.forwardRef(function(n,i){var o,r,s,l;const a=vo(n.mode,{width:null!==(r=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==r?r:n.width,height:null!==(l=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==l?l:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:c,margin:u,className:d,arrowOfTime:h="right",windowMode:f="sliding",windowSize:g=200,data:y,timeAccessor:p,valueAccessor:v,timeExtent:m,valueExtent:x,extentPadding:b,categoryAccessor:k,colors:w,radius:A,fill:S,opacity:M,stroke:_,strokeWidth:j,background:P,tooltipContent:C,tooltip:E,onHover:T,annotations:D,svgAnnotationRules:L,tickFormatTime:O,tickFormatValue:N,linkedHover:$,selection:I,onObservation:W,chartId:R,loading:z,emptyContent:Y,emphasis:B,legendPosition:F}=n,H=a.showAxes,X=a.enableHover,G=null!=u?u:a.marginDefaults,V=null!=c?c:[a.width,a.height],q=null!=C?C:E,U=e.useRef(null),{customHoverBehavior:K}=yo({selection:I,linkedHover:$,unwrapData:!0,onObservation:W,chartType:"RealtimeSwarmChart",chartId:R}),Z=e.useCallback(t=>{T&&T(t),K(t)},[T,K]);e.useImperativeHandle(i,()=>({push:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=U.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=U.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=U.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=U.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=U.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}));const Q=wo(z,V[0],V[1]),J=Q?null:ko(y,V[0],V[1],Y),tt={};return null!=A&&(tt.radius=A),null!=S&&(tt.fill=S),null!=M&&(tt.opacity=M),null!=_&&(tt.stroke=_),null!=j&&(tt.strokeWidth=j),Q||J||t.jsx(xn,{ref:U,chartType:"swarm",runtimeMode:"streaming",size:V,margin:G,className:B?`${d||""} semiotic-emphasis-${B}`.trim():d,arrowOfTime:h,windowMode:f,windowSize:g,data:y,timeAccessor:p,valueAccessor:v,xExtent:m,yExtent:x,extentPadding:b,categoryAccessor:k,barColors:w,swarmStyle:tt,showAxes:H,background:P,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:Z,annotations:D,svgAnnotationRules:L,tickFormatTime:O,tickFormatValue:N,legendPosition:F,pointIdAccessor:n.pointIdAccessor})});_o.displayName="RealtimeSwarmChart";const jo=e.forwardRef(function(n,i){var o,r,s,l;const a=vo(n.mode,{width:null!==(r=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==r?r:n.width,height:null!==(l=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==l?l:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:c,margin:u,className:d,arrowOfTime:h="right",windowMode:f="sliding",windowSize:g=200,data:y,timeAccessor:p,valueAccessor:v,timeExtent:m,valueExtent:x,extentPadding:b,positiveColor:k,negativeColor:w,connectorStroke:A,connectorWidth:S,gap:M,stroke:_,strokeWidth:j,opacity:P,background:C,tooltipContent:E,tooltip:T,onHover:D,annotations:L,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:$,linkedHover:I,selection:W,onObservation:R,chartId:z,loading:Y,emptyContent:B,emphasis:F,legendPosition:H}=n,X=a.showAxes,G=a.enableHover,V=null!=u?u:a.marginDefaults,q=null!=c?c:[a.width,a.height],U=null!=E?E:T,K=e.useRef(null),{customHoverBehavior:Z}=yo({selection:W,linkedHover:I,unwrapData:!0,onObservation:R,chartType:"RealtimeWaterfallChart",chartId:z}),Q=e.useCallback(t=>{D&&D(t),Z(t)},[D,Z]);e.useImperativeHandle(i,()=>({push:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=K.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=K.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=K.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}));const J=wo(Y,q[0],q[1]),tt=J?null:ko(y,q[0],q[1],B),et={};return null!=k&&(et.positiveColor=k),null!=w&&(et.negativeColor=w),null!=A&&(et.connectorStroke=A),null!=S&&(et.connectorWidth=S),null!=M&&(et.gap=M),null!=_&&(et.stroke=_),null!=j&&(et.strokeWidth=j),null!=P&&(et.opacity=P),J||tt||t.jsx(xn,{ref:K,chartType:"waterfall",runtimeMode:"streaming",size:q,margin:V,className:F?`${d||""} semiotic-emphasis-${F}`.trim():d,arrowOfTime:h,windowMode:f,windowSize:g,data:y,timeAccessor:p,valueAccessor:v,xExtent:m,yExtent:x,extentPadding:b,waterfallStyle:et,showAxes:X,background:C,hoverAnnotation:G,tooltipContent:U,customHoverBehavior:Q,annotations:L,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:$,legendPosition:H,pointIdAccessor:n.pointIdAccessor})});jo.displayName="RealtimeWaterfallChart";const Po=e.forwardRef(function(n,i){var o,r,s,l;const a=vo(n.mode,{width:null!==(r=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==r?r:n.width,height:null!==(l=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==l?l:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:c,margin:u,className:d,arrowOfTime:h="right",windowMode:f="sliding",windowSize:g=200,data:y,timeAccessor:p,valueAccessor:v,categoryAccessor:m,timeExtent:x,valueExtent:b,extentPadding:k,heatmapXBins:w=20,heatmapYBins:A=20,aggregation:S="count",background:M,tooltipContent:_,tooltip:j,onHover:P,annotations:C,svgAnnotationRules:E,tickFormatTime:T,tickFormatValue:D,decay:L,pulse:O,staleness:N,linkedHover:$,selection:I,onObservation:W,chartId:R,loading:z,emptyContent:Y,emphasis:B,legendPosition:F}=n,H=a.showAxes,X=a.enableHover,G=null!=u?u:a.marginDefaults,V=null!=c?c:[a.width,a.height],q=null!=_?_:j,U=e.useRef(null),{customHoverBehavior:K}=yo({selection:I,linkedHover:$,unwrapData:!0,onObservation:W,chartType:"RealtimeHeatmap",chartId:R}),Z=e.useCallback(t=>{P&&P(t),K(t)},[P,K]);e.useImperativeHandle(i,()=>({push:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=U.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=U.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=U.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=U.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=U.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}));const Q=wo(z,V[0],V[1]),J=Q?null:ko(y,V[0],V[1],Y);return Q||J||t.jsx(xn,{ref:U,chartType:"heatmap",runtimeMode:"streaming",size:V,margin:G,className:B?`${d||""} semiotic-emphasis-${B}`.trim():d,arrowOfTime:h,windowMode:f,windowSize:g,data:y,timeAccessor:p,valueAccessor:v,categoryAccessor:m,xExtent:x,yExtent:b,extentPadding:k,heatmapXBins:w,heatmapYBins:A,heatmapAggregation:S,showAxes:H,background:M,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:Z,annotations:C,svgAnnotationRules:E,tickFormatTime:T,tickFormatValue:D,decay:L,pulse:O,staleness:N,legendPosition:F,pointIdAccessor:n.pointIdAccessor})});Po.displayName="RealtimeHeatmap",exports.IncrementalExtent=L,exports.RealtimeHeatmap=Po,exports.RealtimeHistogram=Mo,exports.RealtimeLineChart=Ao,exports.RealtimeSwarmChart=_o,exports.RealtimeWaterfallChart=jo,exports.RingBuffer=D,exports.StreamNetworkFrame=so,exports.StreamXYFrame=xn;
1
+ "use client";
2
+ "use strict";const t=require("react/jsx-runtime"),e=require("react"),n=require("d3-selection"),i=require("d3-brush"),o=require("d3-scale"),r=require("d3-quadtree"),s=require("d3-shape"),l=require("d3-array"),a=require("d3-hierarchy"),c=require("regression"),u=require("d3-interpolate"),d=require("d3-force"),h=require("d3-chord");function f(t){return t&&t.__esModule?t:{default:t}}function g(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const n in t)if("default"!==n){const i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}return e.default=t,Object.freeze(e)}const y=g(e),p=f(c);function v(t,e){let n=0,i=e.length-1;for(;i>n;){const o=n+i+1>>1;e[o]>t?i=o-1:n=o}return e[n]}function m(t,e){let n=0,i=e.length-1;for(;i>n;){const o=n+i>>1;t>e[o]?n=o+1:i=o}return e[n]}function x({width:o,height:r,totalWidth:s,totalHeight:l,margin:a,dimension:c,scales:u,onBrush:d,binSize:h,snap:f,binBoundaries:g,snapDuring:y,streaming:p}){const x=e.useRef(null),b=e.useRef(null),k=e.useRef(d);k.current=d;const w=e.useRef(u);w.current=u;const A=e.useMemo(()=>g?[...g].sort((t,e)=>t-e):void 0,[g]),S=e.useRef(A);S.current=A;const M=e.useRef(!1),_=e.useRef(null);return e.useEffect(()=>{if(!x.current)return;const t=n.select(x.current).select(".brush-g"),e="x"===c?i.brushX():"y"===c?i.brushY():i.brush();return e.extent([[0,0],[o,r]]),e.on("brush end",n=>{if(M.current)return;const i=w.current;if(!i)return;if(!n.selection)return _.current=null,void k.current(null);let s,l;if("x"===c){const[t,e]=n.selection;s=[i.x.invert(t),i.x.invert(e)],l=[i.y.invert(r),i.y.invert(0)]}else if("y"===c){const[t,e]=n.selection;s=[i.x.invert(0),i.x.invert(o)],l=[i.y.invert(e),i.y.invert(t)]}else{const[[t,e],[o,r]]=n.selection;s=[i.x.invert(t),i.x.invert(o)],l=[i.y.invert(r),i.y.invert(e)]}if("bin"===f&&"y"!==c&&("end"===n.type||"brush"===n.type&&y)){const o=S.current;o&&o.length>0?s=function(t,e){return 0===e.length?t:[v(t[0],e),m(t[1],e)]}(s,o):h&&h>0&&(s=[Math.floor(s[0]/h)*h,Math.ceil(s[1]/h)*h]);const r=i.x(s[0]),l=i.x(s[1]);if(M.current=!0,"x"===c)t.call(e.move,[r,l]);else if("xy"===c){const i=n.selection;t.call(e.move,[[r,i[0][1]],[l,i[1][1]]])}M.current=!1}const a={x:s,y:l};_.current=a,k.current(a)}),t.call(e),b.current=e,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{e.on("brush end",null),b.current=null}},[o,r,c,f,h,y]),e.useEffect(()=>{if(!(p&&u&&b.current&&_.current))return;if(!x.current)return;if("y"===c)return;const t=_.current,e=u.x.domain()[0],i=n.select(x.current).select(".brush-g");if(e>=t.x[1])return M.current=!0,i.call(b.current.move,null),M.current=!1,_.current=null,void k.current(null);let o=t.x[0],r=!1;if(e>t.x[0]){if(o=e,"bin"===f){const t=S.current;t&&t.length>0?o=m(e,t):h&&h>0&&(o=Math.ceil(e/h)*h)}if(o>=t.x[1])return M.current=!0,i.call(b.current.move,null),M.current=!1,_.current=null,void k.current(null);r=!0}const s=u.x(o),l=u.x(t.x[1]);if(M.current=!0,"x"===c)i.call(b.current.move,[s,l]);else{const e=u.y(t.y[1]),n=u.y(t.y[0]);i.call(b.current.move,[[s,e],[l,n]])}if(M.current=!1,r){const e={x:[o,t.x[1]],y:t.y};_.current=e,k.current(e)}},[u,p,c,f,h]),t.jsx("svg",{ref:x,width:s,height:l,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:t.jsx("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`})})}const b=Object.freeze([]);function k(t){if(!t)return b;let e=!1;for(let n=0;t.length>n;n++){const i=t[n];if(null==i||"object"!=typeof i){e=!0;break}}if(!e)return t;const n=[];for(const e of t)null!=e&&"object"==typeof e&&n.push(e);return n}class w{constructor(t,e){var n,i;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=t,this.chunkThreshold=null!==(n=null==e?void 0:e.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(i=null==e?void 0:e.chunkSize)&&void 0!==i?i: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=k(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 i=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,i),bounded:!1}),e=i,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(t){if(t=k(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 i=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,i),bounded:!1}),e=i,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 i=t[n];null!=i&&"object"==typeof i&&(this.pushBuffer.push(i),e++)}0!==e&&this.scheduleFlush()}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}function A(n){let i=null;const o=()=>(i||(i=e.createContext(null)),i),r=S(n);return[function({children:i,initialState:r}){const s=e.useRef(r),l=e.useMemo(()=>S(n,s.current),[]),a=o();return t.jsx(a.Provider,{value:l,children:i})},t=>{var n;const i=o(),s=null!==(n=e.useContext(i))&&void 0!==n?n:r,l=e.useRef(t);l.current=t;const a=e.useCallback(()=>l.current(s.getState()),[s]),c=e.useCallback(()=>l.current(s.getState()),[s]);return e.useSyncExternalStore(s.subscribe,a,c)}]}function S(t,e){const n=new EventTarget;let i=Object.assign(Object.assign({},t(function(t){i=Object.assign(Object.assign({},i),t(i)),n.dispatchEvent(new Event("update"))})),null!=e?e:{});return{getState:()=>i,subscribe:function(t){return n.addEventListener("update",t),()=>n.removeEventListener("update",t)}}}function M(t){if(!(null==t?void 0:t.colors))return;const e=t.colors;return{primary:e.primary,secondary:e.secondary||e.primary,surface:e.surface||e.background,success:e.success,danger:e.danger,warning:e.warning,error:e.error,info:e.info,text:e.text,textSecondary:e.textSecondary,border:e.border,grid:e.grid}}function _(t){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{categorical:j})})),t.accessibility.highContrast){const t="dark"===e.mode;e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{text:t?"#ffffff":"#000000",textSecondary:t?"#cccccc":"#333333",grid:t?"#666666":"#999999",border:t?"#888888":"#000000"})})}return e}const j=["#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:10}},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:10}},E={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:j,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 E;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 _(Object.assign(Object.assign(Object.assign({},t),e),{colors:Object.assign(Object.assign({},t.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.typography),e.typography||{})}))}return _(Object.assign(Object.assign(Object.assign({},t),e),{colors:Object.assign(Object.assign({},t.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.typography),e.typography||{})}))}const[O,T]=A(t=>({theme:P,setTheme(e){t(t=>({theme:L(t.theme,e)}))}}));class D{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const n of t){const t=this.push(n);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;return{next:()=>this._size>t?{done:!1,value:this.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t(this.buffer[(e+n)%this._capacity],n)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t[n]=this.buffer[(e+n)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),n=[];for(;e.length>t;)n.push(e.shift());this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(const t of e)this.push(t);return n}update(t,e){const n=[],i=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){const r=(i+o)%this._capacity,s=this.buffer[r];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:Object.assign({},s),n.push(t),this.buffer[r]=e(s)}}return n}remove(t){const e=[],n=[];if(this.forEach(i=>{t(i)?n.push(i):e.push(i)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class R{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const n of t){const t=e?e(n):n;Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function I(t,e,n,i,o){const r=new Map;for(const s of t){const t=e(s),l=n(s);if(null==t||null==l||Number.isNaN(t)||Number.isNaN(l))continue;const a=Math.floor(t/i)*i;let c=r.get(a);if(c||(c={start:a,end:a+i,total:0,categories:new Map},r.set(a,c)),c.total+=l,o){const t=o(s);c.categories.set(t,(c.categories.get(t)||0)+l)}}return r}function $(t,e,n,i,o,r){const s=[];for(const o of t){const t=n(o),r=i(o);Number.isFinite(t)&&Number.isFinite(r)&&s.push({px:e.x(t),py:e.y(r),rawY:r,d:o})}s.sort((t,e)=>t.px-e.px);const l=Array(s.length),a=Array(s.length),c=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];l[t]=[e.px,e.py],a[t]=e.rawY,c[t]=e.d}return{type:"line",path:l,rawValues:a,style:o,datum:c,group:r}}function N(t,e,n,i,o,r,s,l){const a=[];for(const r of t){const t=n(r),s=i(r);if(!Number.isFinite(t)||!Number.isFinite(s))continue;const c=e.x(t),u=l?l(r):o;a.push({px:c,topY:e.y(s),botY:e.y(u)})}a.sort((t,e)=>t.px-e.px);const c=Array(a.length),u=Array(a.length);for(let t=0;a.length>t;t++){const e=a[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 W(t,e,n,i){var o,r,s;const l=new Map;if("silhouette"===i)for(const i of t){let t=0;for(const o of e)t+=n(o,i)||0;l.set(i,-t/2)}else if("wiggle"===i){t.length>0&&l.set(t[0],0);for(let i=1;t.length>i;i++){const r=t[i-1],s=t[i];let a=0,c=0,u=0;for(const t of e){const e=n(t,s)||0;a+=(2*u+e)*(e-(n(t,r)||0)),c+=e,u+=e}const d=null!==(o=l.get(r))&&void 0!==o?o:0;l.set(s,d-(c>0?a/(2*c):0))}if(t.length>0){let i=0;for(const o of t){let t=0;for(const i of e)t+=n(i,o)||0;i+=(null!==(r=l.get(o))&&void 0!==r?r:0)+t/2}const o=i/t.length;for(const e of t)l.set(e,(null!==(s=l.get(e))&&void 0!==s?s:0)-o)}}else for(const e of t)l.set(e,0);return l}function z(t,e,n,i,o,r,s){const l=n(t),a=i(t);if(!Number.isFinite(l)||!Number.isFinite(a))return null;const c={type:"point",x:e.x(l),y:e.y(a),r:o,style:r,datum:t};return void 0!==s&&(c.pointId=s),c}function Y(t,e,n,i,o,r,s){return{type:"rect",x:t,y:e,w:n,h:i,style:o,datum:r,group:s}}function F(t,e,n,i,o,r,s){const l={type:"heatcell",x:t,y:e,w:n,h:i,fill:o,datum:r};return(null==s?void 0:s.showValues)&&(l.showValues=!0,l.value=s.value,s.valueFormat&&(l.valueFormat=s.valueFormat)),l}function B(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function H(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function X(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function G(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}function V(t){return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function q(t,e,n){const i=t=>t.toString(16).padStart(2,"0");return`#${i(t)}${i(e)}${i(n)}`}function U(t){const e=t.map(V),n=e.length-1;return t=>{if(0>=t){const[t,n,i]=e[0];return q(t,n,i)}if(t>=1){const[t,i,o]=e[n];return q(t,i,o)}const i=t*n,o=Math.floor(i),r=i-o,[s,l,a]=e[o],[c,u,d]=e[o+1];return q(Math.round(s+(c-s)*r),Math.round(l+(u-l)*r),Math.round(a+(d-a)*r))}}const 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"]),it=U(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),ot=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"]),lt=U(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),at=U(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]);U(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),U(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),U(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),U(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),U(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),U(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),U(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);const ct={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"],blues:Z,reds:Q,greens:J,oranges:tt,purples:et,viridis:it,plasma:ot},ut=K,dt=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function ht(t,e,n){var i,o,r;if(1>=n)return 1;const s=null!==(i=t.minOpacity)&&void 0!==i?i:.1,l=n-1-e;switch(t.type){case"linear":return s+(1-l/(n-1))*(1-s);case"exponential":{const e=null!==(o=t.halfLife)&&void 0!==o?o:n/2;return s+Math.pow(.5,l/e)*(1-s)}case"step":return(null!==(r=t.stepThreshold)&&void 0!==r?r:.5*n)>l?1:s;default:return 1}}function ft(t,e,n){var i;const o=null!==(i=t.duration)&&void 0!==i?i:500,r=n-e;return o>r?1-r/o:0}function gt(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function yt(t,e){return Math.min((t-e.startTime)/e.duration,1)}function pt(t,e,n){return t+(e-t)*n}function vt(t,e,n){var i,o,r,s;if(e._transitionKey)return e._transitionKey;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const n=t.getX(e.datum),i=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${n}:${i}`;if(null!=n&&null!=i)return`p:${n}:${i}`}return"p:"+n;case"rect":return`r:${e.group||""}:${null!==(s=null!==(o=null===(i=e.datum)||void 0===i?void 0:i.binStart)&&void 0!==o?o:null===(r=e.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:n}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+n:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function mt(t,e,n){if(!t.getBounds||!t.scales)return null;const i=[],o=[];for(const n of e){const e=t.getX(n),r=t.getY(n);if(null==e||null==r||Number.isNaN(e)||Number.isNaN(r))continue;const s=t.getBounds(n),l=t.scales.x(e);if(s&&0!==s)i.push([l,t.scales.y(r+s)]),o.push([l,t.scales.y(r-s)]);else{const e=t.scales.y(r);i.push([l,e]),o.push([l,e])}}return 2>i.length?null:{type:"area",topPath:i,bottomPath:o,style:t.resolveBoundsStyle(n,e[0]),datum:e,group:n,interactive:!1}}function xt(t,e,n,i){var o;if(!t.config.pointStyle)return;const r=null!=i?i:t.getY;for(const i of e){const e=t.resolveGroupColor(i.key);for(const s of i.data){let i=t.config.pointStyle(s);!i.fill&&e&&(i=Object.assign(Object.assign({},i),{fill:e}));const l=null!==(o=i.r)&&void 0!==o?o:3,a=t.getPointId?t.getPointId(s)+"":void 0,c=z(s,t.scales,t.getX,r,l,i,a);c&&n.push(c)}}}const bt={blues:Z,reds:Q,greens:J,viridis:it,oranges:tt,purples:et,greys:nt,plasma:ot,inferno:rt,magma:st,cividis:lt,turbo:at},kt=new Map;class wt{constructor(t){if(this.xExtent=new R,this.yExtent=new R,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._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this.xIsDate=!1,this._quadtree=null,this._maxPointRadius=0,this._lastBoundedInsertsRef=null,this.config=t,this.buffer=new D(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=H(t.timeAccessor||t.xAccessor,"time"),this.getY=H(t.valueAccessor||t.yAccessor,"value")):(this.getX=H(t.xAccessor,"x"),this.getY=H(t.yAccessor,"y")),this.getGroup=G(t.groupAccessor),this.getCategory=G(t.categoryAccessor),this.getSize=t.sizeAccessor?H(t.sizeAccessor,"size"):void 0,this.getColor=G(t.colorAccessor),this.getBounds=t.boundsAccessor?H(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?H(t.y0Accessor,"y0"):void 0,this.getPointId=G(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,n=null!=t.closeAccessor;this.getOpen=e?H(t.openAccessor,"open"):void 0,this.getHigh=H(t.highAccessor,"high"),this.getLow=H(t.lowAccessor,"low"),this.getClose=n?H(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!n}t.pulse&&(this.timestampBuffer=new D(t.windowSize))}pushDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(t)),void this.yExtent.push(this.getLow(t));this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t))}rebuildYExtent(){this.yExtent.clear();for(const t of this.buffer)this.pushDatumYExtent(t)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const t of this.buffer)this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t)}ingest(t){if(t.bounded&&this._lastBoundedInsertsRef===t.inserts)return!1;const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.bounded){if(this._lastBoundedInsertsRef=t.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.getX=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?H(this.config.timeAccessor||this.config.xAccessor,"time"):H(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],n=this.config.xAccessor,i="function"==typeof n?n(e):e[n||"x"],o=i instanceof Date,r="string"==typeof i&&i.length>=10&&!isNaN(new Date(i).getTime())&&isNaN(Number(i));if(this.xIsDate=o||r,r){const t="string"==typeof n?n:void 0;this.getX=t?e=>+new Date(e[t]):t=>+(n(t)instanceof Date?n(t):new Date(n(t)))}}const n=t.totalSize||t.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of t.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n)))}else for(const n of t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity||1e6;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const t=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n))),null!=t&&(this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t))))}return!0}computeScene(t){var e,n,i,r,s,l,a,c,u,d,h,f,g,y;const{config:p,buffer:v}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(e=this.config.scalePadding)&&void 0!==e?e:0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);this.xExtent.dirty&&this.xExtent.recalculate(v,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const m=this.getBufferArray(),x=this.xExtent.extent,b=this.yExtent.extent;let k=p.xExtent?[null!==(n=p.xExtent[0])&&void 0!==n?n:x[0],null!==(i=p.xExtent[1])&&void 0!==i?i:x[1]]:x,w=p.yExtent?[null!==(r=p.yExtent[0])&&void 0!==r?r:b[0],null!==(s=p.yExtent[1])&&void 0!==s?s:b[1]]:b;const A=p.yExtent&&null!=p.yExtent[0]&&null!=p.yExtent[1];if("stackedarea"===p.chartType&&!A&&v.size>0)if(p.normalize)w=[0,1+p.extentPadding];else{const t=`${v.size}:${this._ingestVersion}:${null!==(l=p.baseline)&&void 0!==l?l:"zero"}:${null!==(a=p.stackOrder)&&void 0!==a?a:"key"}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)w=this._stackExtentCache.yDomain;else{const e=this.groupData(m),n=new Map,i=new Set;let o=0;const r=new Map,s=new Map;for(const t of e){const e=new Map;let l=0;for(const n of t.data){const t=this.getX(n),s=this.getY(n);if(!Number.isFinite(t)||!Number.isFinite(s))continue;e.set(t,(e.get(t)||0)+s),i.add(t),l+=s;const a=(r.get(t)||0)+s;r.set(t,a),a>o&&(o=a)}n.set(t.key,e),s.set(t.key,l)}const l=null!==(c=p.stackOrder)&&void 0!==c?c:"key",a=(t,e)=>e>t?-1:t>e?1:0;let g;if("insideOut"===l){const t=[...e].map(t=>t.key).sort((t,e)=>{var n,i;const o=(null!==(n=s.get(e))&&void 0!==n?n:0)-(null!==(i=s.get(t))&&void 0!==i?i:0);return 0!==o?o:a(t,e)}),n=[],i=[];let o=0,r=0;for(const e of t)r>o?(n.push(e),o+=null!==(u=s.get(e))&&void 0!==u?u:0):(i.push(e),r+=null!==(d=s.get(e))&&void 0!==d?d:0);g=[...i.reverse(),...n]}else g="asc"===l?e.map(t=>t.key).sort((t,e)=>{var n,i;const o=(null!==(n=s.get(t))&&void 0!==n?n:0)-(null!==(i=s.get(e))&&void 0!==i?i:0);return 0!==o?o:a(t,e)}):"desc"===l?e.map(t=>t.key).sort((t,e)=>{var n,i;const o=(null!==(n=s.get(e))&&void 0!==n?n:0)-(null!==(i=s.get(t))&&void 0!==i?i:0);return 0!==o?o:a(t,e)}):e.map(t=>t.key).sort(a);if("wiggle"===p.baseline||"silhouette"===p.baseline){const t=Array.from(i).sort((t,e)=>t-e),e=W(t,g,(t,e)=>{var i;return(null===(i=n.get(t))||void 0===i?void 0:i.get(e))||0},p.baseline);let o=1/0,s=-1/0;for(const n of t){const t=null!==(h=e.get(n))&&void 0!==h?h:0,i=null!==(f=r.get(n))&&void 0!==f?f:0;o>t&&(o=t),t+i>s&&(s=t+i)}Number.isFinite(o)&&Number.isFinite(s)||(o=0,s=0);const l=s-o,a=l>0?l*p.extentPadding:1;w=[o-a,s+a]}else w=[0,o+(o>0?o*p.extentPadding:1)];this._stackExtentCache={key:t,yDomain:w}}}else if("bar"===p.chartType&&p.binSize&&!A&&v.size>0){const[,t]=function(t,e,n,i,o){const r=I(t,e,n,i,o);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]}(v,this.getX,this.getY,p.binSize,this.getCategory);w=[0,t+t*p.extentPadding]}else if("waterfall"===p.chartType&&!A&&v.size>0){const[t,e]=function(t,e){let n=0,i=0,o=0;for(const r of t){const t=e(r);null==t||Number.isNaN(t)||(o+=t,n>o&&(n=o),o>i&&(i=o))}return[n,i]}(v,this.getY),n=e-t,i=n>0?n*p.extentPadding:1;w=[Math.min(0,t-Math.abs(i)),Math.max(0,e+Math.abs(i))]}else if(!A&&w[0]!==1/0){if(this.getBounds)for(const t of m){const e=this.getY(t),n=this.getBounds(t);null!=e&&!Number.isNaN(e)&&n&&(e+n>w[1]&&(w[1]=e+n),w[0]>e-n&&(w[0]=e-n))}const t=w[1]-w[0],e=t>0?t*p.extentPadding:1,n=null===(g=p.yExtent)||void 0===g?void 0:g[0],i=null===(y=p.yExtent)||void 0===y?void 0:y[1];w=[null!=n?w[0]:w[0]-e,null!=i?w[1]:w[1]+e],"log"===p.yScaleType&&0>=w[0]&&b[0]>0&&(w[0]=null!=n?w[0]:b[0]/(1+p.extentPadding))}if(k[0]===1/0||k[1]===-1/0)if("time"===p.xScaleType){const t=Date.now();k=[t-864e5,t]}else k=[0,1];w[0]!==1/0&&w[1]!==-1/0||(w=[0,1]);const S="streaming"===p.runtimeMode,M=Math.max(0,Math.min(p.scalePadding||0,Math.min(t.width,t.height)/2-1));if(S)if("x"==("up"===(_=p.arrowOfTime)||"down"===_?"y":"x")){const e="right"===p.arrowOfTime?[M,t.width-M]:[t.width-M,M];this.scales={x:o.scaleLinear().domain(k).range(e),y:o.scaleLinear().domain(w).range([t.height-M,M])}}else{const e="down"===p.arrowOfTime?[M,t.height-M]:[t.height-M,M];this.scales={x:o.scaleLinear().domain(w).range([M,t.width-M]),y:o.scaleLinear().domain(k).range(e)}}else{const e=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return o.scaleLog().domain(t).range(n).clamp(!0)}return"time"===t?o.scaleTime().domain([new Date(e[0]),new Date(e[1])]).range(n):o.scaleLinear().domain(e).range(n)};this.scales={x:e(p.xScaleType,k,[M,t.width-M]),y:e(p.yScaleType,w,[t.height-M,M])}}var _;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,m),this.config.decay&&this.applyDecay(this.scene,m),this.config.pulse&&this.applyPulse(this.scene,m),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}rebuildQuadtree(){const t=this.config.chartType;if("scatter"!==t&&"bubble"!==t)return this._quadtree=null,void(this._maxPointRadius=0);let e=0,n=0;for(const t of this.scene)"point"===t.type&&(e++,t.r>n&&(n=t.r));if(this._maxPointRadius=n,wt.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const i=Array(e);let o=0;for(const t of this.scene)"point"===t.type&&(i[o++]=t);this._quadtree=r.quadtree().x(t=>t.x).y(t=>t.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}remapScene(t){const e=t.width/this.lastLayout.width,n=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const i of t.path)i[0]*=e,i[1]*=n;break;case"area":for(const i of t.topPath)i[0]*=e,i[1]*=n;for(const i of t.bottomPath)i[0]*=e,i[1]*=n;t.clipRect&&(t.clipRect={x:t.clipRect.x*e,y:t.clipRect.y*n,width:t.clipRect.width*e,height:t.clipRect.height*n});break;case"point":t.x*=e,t.y*=n;break;case"rect":case"heatcell":t.x*=e,t.y*=n,t.w*=e,t.h*=n;break;case"candlestick":t.x*=e,t.openY*=n,t.closeY*=n,t.highY*=n,t.lowY*=n}const i=this.scales.x.domain(),r=this.scales.y.domain(),s=this.scales.x.range(),l=this.scales.y.range(),a=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return o.scaleLog().domain(t).range(n).clamp(!0)}return"time"===t?o.scaleTime().domain([new Date(e[0]),new Date(e[1])]).range(n):o.scaleLinear().domain(e).range(n)},c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),u=l[1]>l[0];this.scales={x:a(this.config.xScaleType,i,s[0]>s[1]?[t.width-c,c]:[c,t.width-c]),y:a(this.config.yScaleType,r,u?[c,t.height-c]:[t.height-c,c])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){var n,i,o,r,s,l,a;const{config:c,scales:u}=this;if(!u)return[];if(c.customLayout){const a=null!==(n=c.layoutMargin)&&void 0!==n?n:{top:0,right:0,bottom:0,left:0},d={data:e,scales:u,dimensions:{width:t.width,height:t.height,margin:a,plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:null!==(i=c.themeSemantic)&&void 0!==i?i:{},categorical:null!==(o=c.themeCategorical)&&void 0!==o?o:dt},resolveColor:(t,e)=>{var n,i;const o=this.resolveGroupColor(t);if(o)return o;const r=this.resolveLineStyle(t,e);return r.stroke?r.stroke:"string"==typeof r.fill?r.fill:null!==(i=null===(n=c.themeSemantic)||void 0===n?void 0:n.primary)&&void 0!==i?i:"#4e79a7"},config:null!==(r=c.layoutConfig)&&void 0!==r?r:{}};let h;try{h=c.customLayout(d)}catch(t){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",t),this.customLayoutOverlays=null,[]}return this.customLayoutOverlays=null!==(s=h.overlays)&&void 0!==s?s:null,null!==(l=h.nodes)&&void 0!==l?l:[]}if(this.customLayoutOverlays=null,0===e.length)return[];const d={scales:u,config:c,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,getBounds:this.getBounds,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(c.chartType){case"line":return function(t,e){var n;const i=t.groupData(e),o=[],r=null===(n=t.config.annotations)||void 0===n?void 0:n.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.getBounds)for(const e of i){const n=mt(t,e.data,e.key);n&&o.push(n)}for(const e of i){const n=t.resolveLineStyle(e.key,e.data[0]),i=$(e.data,t.scales,t.getX,t.getY,n,e.key);r&&r.length>0&&(i.colorThresholds=r),t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),o.push(i)}return xt(t,i,o),o}(d,e);case"area":return function(t,e){const n=t.groupData(e),i=[],o=t.scales.y.domain()[0],r=t.getY0?e=>{const n=t.getY0(e);return null==n?o:n}:void 0;for(const e of n){const n=t.resolveAreaStyle(e.key,e.data[0]),s=N(e.data,t.scales,t.getX,t.getY,o,n,e.key,r);t.config.gradientFill&&(s.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),i.push(s)}return xt(t,n,i),i}(d,e);case"mixed":return function(t,e){const n=t.groupData(e),i=[],o=t.config.areaGroups||new Set,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(o.has(e.key)){const n=t.resolveAreaStyle(e.key,e.data[0]),o=N(e.data,t.scales,t.getX,t.getY,r,n,e.key,s);t.config.gradientFill&&(o.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),i.push(o)}else{const n=t.resolveLineStyle(e.key,e.data[0]),o=$(e.data,t.scales,t.getX,t.getY,n,e.key);t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),i.push(o)}return xt(t,n,i),i}(d,e);case"stackedarea":return function(t,e){var n,i,o,r;const s=t.groupData(e),l=null!==(n=t.config.stackOrder)&&void 0!==n?n:"key",a=()=>s.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);if("key"===l)a();else if("asc"===l||"desc"===l||"insideOut"===l){const e=new Map;for(const n of s){let i=0;for(const e of n.data){const n=t.getX(e),o=t.getY(e);Number.isFinite(n)&&Number.isFinite(o)&&(i+=o)}e.set(n.key,i)}const n=(t,e)=>e>t?-1:t>e?1:0;if("asc"===l)s.sort((t,i)=>{var o,r;const s=(null!==(o=e.get(t.key))&&void 0!==o?o:0)-(null!==(r=e.get(i.key))&&void 0!==r?r:0);return 0!==s?s:n(t.key,i.key)});else if("desc"===l)s.sort((t,i)=>{var o,r;const s=(null!==(o=e.get(i.key))&&void 0!==o?o:0)-(null!==(r=e.get(t.key))&&void 0!==r?r:0);return 0!==s?s:n(t.key,i.key)});else{const t=[...s].sort((t,i)=>{var o,r;const s=(null!==(o=e.get(i.key))&&void 0!==o?o:0)-(null!==(r=e.get(t.key))&&void 0!==r?r:0);return 0!==s?s:n(t.key,i.key)}),r=[],l=[];let a=0,c=0;for(const n of t)c>a?(r.push(n),a+=null!==(i=e.get(n.key))&&void 0!==i?i:0):(l.push(n),c+=null!==(o=e.get(n.key))&&void 0!==o?o:0);s.length=0,s.push(...l.reverse(),...r)}}else a();const c=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,u=t.config.normalize?"zero":null!==(r=t.config.baseline)&&void 0!==r?r:"zero",{nodes:d,stackedTops:h}=function(t,e,n,i,o,r,s,l="zero"){var a,c;const u=new Set;for(const e of t)for(const t of e.data){const e=n(t);Number.isFinite(e)&&u.add(e)}const d=Array.from(u).sort((t,e)=>t-e),h=new Map;for(const e of t){const t=new Map;for(const o of e.data){const e=n(o),r=i(o);Number.isFinite(e)&&Number.isFinite(r)&&t.set(e,(t.get(e)||0)+r)}h.set(e.key,t)}let f;if(r){f=new Map;for(const e of d){let n=0;for(const i of t)n+=(null===(a=h.get(i.key))||void 0===a?void 0:a.get(e))||0;f.set(e,n||1)}}const g=W(d,t.map(t=>t.key),(t,e)=>{var n;return(null===(n=h.get(t))||void 0===n?void 0:n.get(e))||0},l),y=[],p=new Map,v=new Map;for(const t of d)v.set(t,null!==(c=g.get(t))&&void 0!==c?c:0);for(const n of t){const t=h.get(n.key),i=[],l=[],a=new Map;for(const n of d){let o=t.get(n)||0;const s=v.get(n);r&&(o/=f.get(n));const c=s+o,u=e.x(n);l.push([u,e.y(s)]),i.push([u,e.y(c)]),v.set(n,c),a.set(n,c)}p.set(n.key,a);const c={type:"area",topPath:i,bottomPath:l,style:o(n.key,n.data[0]),datum:n.data,group:n.key};s&&(c.curve=s),y.push(c)}return{nodes:y,stackedTops:p}}(s,t.scales,t.getX,t.getY,(e,n)=>t.resolveAreaStyle(e,n),t.config.normalize,c,u),f=d;if(t.config.pointStyle){const e=new WeakMap;for(const n of s){const i=h.get(n.key);if(i)for(const o of n.data){const n=t.getX(o),r=t.getY(o);null==n||Number.isNaN(n)||null==r||Number.isNaN(r)||!i.has(n)||e.set(o,i.get(n))}}const n=n=>{var i;return null!==(i=e.get(n))&&void 0!==i?i:t.getY(n)};xt(t,s,f,n)}return f}(d,e);case"scatter":case"bubble":return function(t,e){var n;const i=[],o="bubble"===t.config.chartType?10:5,r=t.config.sizeRange||[3,15];let s=null;if(t.getSize&&!t.config.pointStyle){const n=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(n.length>0){let t=1/0,e=-1/0;for(const i of n)t>i&&(t=i),i>e&&(e=i);s=n=>t===e?(r[0]+r[1])/2:r[0]+(n-t)/(e-t)*(r[1]-r[0])}}const l=t.getColor?t.resolveColorMap(e):null,a=(null===(n=t.config.themeSemantic)||void 0===n?void 0:n.primary)||"#4e79a7";for(const n of e){let e=t.config.pointStyle?t.config.pointStyle(n):{fill:a,opacity:.8},r=e.r||o;if(s&&t.getSize){const e=t.getSize(n);null==e||Number.isNaN(e)||(r=s(e))}if(l&&t.getColor&&!e.fill){const i=t.getColor(n);i&&l.has(i)&&(e=Object.assign(Object.assign({},e),{fill:l.get(i)}))}const c=t.getPointId?t.getPointId(n)+"":void 0,u=z(n,t.scales,t.getX,t.getY,r,e,c);u&&i.push(u)}return i}(d,e);case"heatmap":return function(t,e,n){if(t.config.heatmapAggregation)return function(t,e,n){var i,o,r;const s=Math.max(1,Math.floor(null!==(i=t.config.heatmapXBins)&&void 0!==i?i:20)),l=Math.max(1,Math.floor(null!==(o=t.config.heatmapYBins)&&void 0!==o?o:20)),a=null!==(r=t.config.heatmapAggregation)&&void 0!==r?r:"count",c=H(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[u,d]=t.scales.x.domain(),[h,f]=t.scales.y.domain(),g=(d-u||1)/s,y=(f-h||1)/l,p=s*l;if(p>1e6)return[];const v=new Int32Array(p),m=new Float64Array(p);for(let n=0;e.length>n;n++){const i=e[n],o=t.getX(i),r=t.getY(i);if(!isFinite(o)||!isFinite(r))continue;const a=Math.min(Math.floor((o-u)/g),s-1),d=Math.min(Math.floor((r-h)/y),l-1);if(0>a||0>d)continue;const f=d*s+a;v[f]++;const p=c(i);m[f]+=isFinite(p)?p:0}let x=1/0,b=-1/0;for(let t=0;p>t;t++){if(0===v[t])continue;let e;switch(a){case"sum":e=m[t];break;case"mean":e=m[t]/v[t];break;default:e=v[t]}x>e&&(x=e),e>b&&(b=e)}if(!isFinite(x))return[];const k=b-x||1,w=n.width/s,A=n.height/l,S=t.config.showValues,M=t.config.heatmapValueFormat,_=[];for(let t=0;l>t;t++){const e=t*s;for(let n=0;s>n;n++){const i=e+n;if(0===v[i])continue;let o;switch(a){case"sum":o=m[i];break;case"mean":o=m[i]/v[i];break;default:o=v[i]}const r=(o-x)/k;_.push(F(n*w,(l-1-t)*A,w,A,`rgb(${220-(180*r+.5)|0},${220-(100*r+.5)|0},${255-(50*r+.5)|0})`,{xi:n,yi:t,value:o,count:v[i],sum:m[i]},S?{value:o,showValues:!0,valueFormat:M}:void 0))}}return _}(t,e,n);if(0===e.length)return[];const i=H(t.config.valueAccessor,"value"),o=X(t.config.xAccessor,"x"),r=X(t.config.yAccessor,"y"),s=new Map,l=new Map,a=Array(e.length),c=Array(e.length);for(let t=0;e.length>t;t++){const n=e[t],i=o(n),u=r(n);a[t]=i,c[t]=u,s.has(i)||s.set(i,s.size),l.has(u)||l.set(u,l.size)}const u=s.size,d=l.size;if(0===u||0===d)return[];const h=Array.from(s.keys()),f=Array.from(l.keys()),g=h.every(t=>"number"==typeof t&&!isNaN(t)),y=f.every(t=>"number"==typeof t&&!isNaN(t));if(g){h.sort((t,e)=>t-e),s.clear();for(let t=0;h.length>t;t++)s.set(h[t],t)}if(y){f.sort((t,e)=>t-e),l.clear();for(let t=0;f.length>t;t++)l.set(f[t],t)}const p=new Float64Array(e.length),v=new Float64Array(e.length),m=Array(e.length),x=new Map;let b=0;for(let t=0;e.length>t;t++){const n=e[t],o=s.get(a[t]),r=l.get(c[t]);if(void 0===o||void 0===r)continue;const d=i(n),h=r*u+o,f=x.get(h);let g;void 0!==f?g=f:(g=b++,x.set(h,g)),p[g]=h,v[g]=d,m[g]=n}let k=1/0,w=-1/0;for(let t=0;b>t;t++){const e=v[t];isFinite(e)&&(k>e&&(k=e),e>w&&(w=e))}if(!isFinite(k)||!isFinite(w))return[];const A=function(t){const e=t in bt?t:"blues";let n=kt.get(e);if(n)return n;n=Array(256);const i=bt[e]||Z;for(let t=0;256>t;t++)n[t]=i(t/255);return kt.set(e,n),n}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),S=255/(w-k||1),M=n.width/u,_=n.height/d,j=t.config.showValues,P=t.config.heatmapValueFormat,C=[];for(let t=0;b>t;t++){const e=v[t];if(!isFinite(e))continue;const n=p[t],i=n%u;C.push(F(i*M,(d-1-(n-i)/u)*_,M,_,A[Math.min((e-k)*S+.5|0,255)],m[t],j?{value:e,showValues:!0,valueFormat:P}:void 0))}return C}(d,e,t);case"bar":{const t=function(t,e){var n,i;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const o=I(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===o.size)return{nodes:[],binBoundaries:[]};let r=null;if(t.getCategory){const e=new Set;for(const t of o.values())for(const n of t.categories.keys())e.add(n);const n=t.config.barColors?Object.keys(t.config.barColors):[],i=new Set(n),s=Array.from(e).filter(t=>!i.has(t)).sort(),l=n.filter(t=>e.has(t)),a=l.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===a?r=t.barCategoryCache.order:(r=[...l,...s],t.barCategoryCache={key:a,order:r})}const s=[],l=t.scales,[a,c]=l.x.domain(),u=t.config.barStyle,d=null===(n=t.config.themeSemantic)||void 0===n?void 0:n.primary,h=null==u?void 0:u.gap,f="number"!=typeof h||0>h?1:h,g={};(null==u?void 0:u.stroke)&&(g.stroke=u.stroke),"number"==typeof(null==u?void 0:u.strokeWidth)&&(g.strokeWidth=u.strokeWidth),"number"==typeof(null==u?void 0:u.opacity)&&(g.opacity=u.opacity);for(const e of o.values()){const n=Math.max(e.start,a),o=Math.min(e.end,c);if(n>=o)continue;const h=l.x(n),y=l.x(o),p=Math.abs(y-h),v=p>f+1?f:0,m=Math.min(h,y)+v/2,x=Math.max(p-v,1);if(x>0)if(r&&e.categories.size>0){let n=0;for(const o of r){const r=e.categories.get(o)||0;if(0===r)continue;const a=l.y(n),c=l.y(n+r),h=(null===(i=t.config.barColors)||void 0===i?void 0:i[o])||(null==u?void 0:u.fill)||d||"#4e79a7";s.push(Y(m,Math.min(a,c),x,Math.abs(a-c),Object.assign({fill:h},g),{binStart:e.start,binEnd:e.end,total:e.total,category:o,categoryValue:r},o)),n+=r}}else{const t=l.y(0),n=l.y(e.total);s.push(Y(m,Math.min(t,n),x,Math.abs(t-n),Object.assign({fill:(null==u?void 0:u.fill)||d||"#007bff"},g),{binStart:e.start,binEnd:e.end,total:e.total}))}}const y=new Set;for(const t of o.values())y.add(t.start),y.add(t.end);return{nodes:s,binBoundaries:Array.from(y).sort((t,e)=>t-e)}}(d,e);return this._barCategoryCache=null!==(a=d.barCategoryCache)&&void 0!==a?a:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var n,i,o,r,s,l;const a=[],c=t.config.swarmStyle||{},u=null!==(n=c.radius)&&void 0!==n?n:3,d=null!==(r=null!==(i=c.fill)&&void 0!==i?i:null===(o=t.config.themeSemantic)||void 0===o?void 0:o.primary)&&void 0!==r?r:"#007bff",h=null!==(s=c.opacity)&&void 0!==s?s:.7,f=c.stroke,g=c.strokeWidth;for(const n of e){const e=t.getX(n),i=t.getY(n);if(null==i||Number.isNaN(i))continue;const o=t.scales.x(e),r=t.scales.y(i);let s=d;if(t.getCategory){const e=t.getCategory(n);s=(null===(l=t.config.barColors)||void 0===l?void 0:l[e])||s}const c={type:"point",x:o,y:r,r:u,style:{fill:s,opacity:h,stroke:f,strokeWidth:g},datum:n};t.getPointId&&(c.pointId=t.getPointId(n)+""),a.push(c)}return a}(d,e);case"waterfall":return function(t,e,n){var i,o,r,s,l,a,c;const u=[],d=t.scales,h=t.config.waterfallStyle,f=e.filter(e=>{const n=t.getY(e),i=t.getX(e);return null!=n&&!Number.isNaN(n)&&null!=i&&isFinite(i)});if(0===f.length)return u;const g=null!==(r=null!==(i=null==h?void 0:h.positiveColor)&&void 0!==i?i:null===(o=t.config.themeSemantic)||void 0===o?void 0:o.success)&&void 0!==r?r:"#28a745",y=null!==(a=null!==(s=null==h?void 0:h.negativeColor)&&void 0!==s?s:null===(l=t.config.themeSemantic)||void 0===l?void 0:l.danger)&&void 0!==a?a:"#dc3545",p=null!==(c=null==h?void 0:h.gap)&&void 0!==c?c:1,v=null==h?void 0:h.stroke,m=null==h?void 0:h.strokeWidth,x=null==h?void 0:h.opacity;let b=0;for(let e=0;f.length>e;e++){const i=f[e],o=t.getX(i),r=t.getY(i),s=b+r;let l;l=f.length-1>e?t.getX(f[e+1])-o:e>0?o-t.getX(f[e-1]):0;const a=d.x(o),c=0!==l?d.x(o+l):a+n.width/10,k=Math.min(a,c)+p/2,w=Math.max(a,c)-p/2-k;if(0>=w){b=s;continue}const A=d.y(b),S=d.y(s),M=Math.min(A,S),_=Math.abs(A-S),j={fill:0>r?y:g,stroke:v,strokeWidth:m};null!=x&&(j.opacity=x),u.push(Y(k,M,w,_,j,Object.assign(Object.assign({},i),{baseline:b,cumEnd:s,delta:r,_connectorStroke:null==h?void 0:h.connectorStroke,_connectorWidth:null==h?void 0:h.connectorWidth}))),b=s}return u}(d,e,t);case"candlestick":return function(t,e){var n,i;if(!t.getHigh||!t.getLow||!t.scales)return[];const o=null!==(n=t.config.candlestickRangeMode)&&void 0!==n&&n;if(!(o||t.getOpen&&t.getClose))return[];const r=[],s=t.config.candlestickStyle||{},l=s.rangeColor||"#6366f1",a=o?l:s.upColor||"#28a745",c=o?l:s.downColor||"#dc3545",u=o?l:s.wickColor||"#333",d=s.wickWidth||(o?2:1),h=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let f=null!==(i=s.bodyWidth)&&void 0!==i?i:0;if(null==s.bodyWidth)if(h.length>1){let e=1/0;for(let n=1;h.length>n;n++){const i=Math.abs(t.scales.x(h[n])-t.scales.x(h[n-1]));i>0&&e>i&&(e=i)}f=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else f=6;for(const n of e){const e=t.getX(n);if(null==e||Number.isNaN(e))continue;const i=t.getHigh(n),s=t.getLow(n);if(null==i||Number.isNaN(i)||null==s||Number.isNaN(s))continue;const l=o?i:t.getOpen(n),h=o?s:t.getClose(n);if(!o&&[l,h].some(t=>null==t||Number.isNaN(t)))continue;const g=h>=l,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(l),closeY:t.scales.y(h),highY:t.scales.y(i),lowY:t.scales.y(s),bodyWidth:f,upColor:a,downColor:c,wickColor:u,wickWidth:d,isUp:g,datum:n};o&&(y.isRange=!0),r.push(y)}return r}(d,e);default:return[]}}resolveBoundsStyle(t,e){var n;const i=this.config.boundsStyle;return"function"==typeof i?i(e||{},t):i&&"object"==typeof i?i:{fill:this.resolveLineStyle(t,e).stroke||(null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary)||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const n=this.config.decay;return n&&e>1?ht(n,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,n){var i,o;const r=n.length;if(1>=r)return;const s=new Map;for(let t=0;n.length>t;t++)s.set(n[t],t);for(const n of e){if("line"===n.type){const e=Array.isArray(n.datum)?n.datum:[];if(2>e.length)continue;const i=Array(e.length);let o=!1;for(let n=0;e.length>n;n++){const l=s.get(e[n]);null!=l?(i[n]=ht(t,l,r),1>i[n]&&(o=!0)):i[n]=1}o&&(n._decayOpacities=i);continue}if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[],i=n.topPath?n.topPath.length:e.length;if(2>i)continue;if(e.length===i){const o=Array(i);let l=!1;for(let n=0;e.length>n;n++){const i=s.get(e[n]);null!=i?(o[n]=ht(t,i,r),1>o[n]&&(l=!0)):o[n]=1}l&&(n._decayOpacities=o)}else{let o=1;for(const n of e){const e=s.get(n);if(null!=e){const n=ht(t,e,r);o>n&&(o=n)}}if(1>o){const t=Array(i);t.fill(o),n._decayOpacities=t}}continue}const e=s.get(n.datum);if(null==e)continue;const l=ht(t,e,r);if("heatcell"===n.type)n.style={opacity:l};else if("candlestick"===n.type)n._decayOpacity=l;else{const t=null!==(o=null===(i=n.style)||void 0===i?void 0:i.opacity)&&void 0!==o?o:1;n.style=Object.assign(Object.assign({},n.style),{opacity:t*l})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,n,i){var o,r;const s="undefined"!=typeof performance?performance.now():Date.now(),l=null!==(o=t.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",a=null!==(r=t.glowRadius)&&void 0!==r?r:4,c=new Map;for(let t=0;n.length>t;t++)c.set(n[t],t);for(const n of e){if("line"===n.type)continue;if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[n.datum];let o=0;for(const n of e){const e=c.get(n);if(null==e)continue;const r=i.get(e);if(null==r)continue;const l=ft(t,r,s);l>o&&(o=l)}o>0&&(n._pulseIntensity=o,n._pulseColor=l);continue}const e=c.get(n.datum);if(null==e)continue;const o=i.get(e);if(null==o)continue;const r=ft(t,o,s);r>0&&(n._pulseIntensity=r,n._pulseColor=l,n._pulseGlowRadius=a)}}(this.config.pulse,t,e,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(t,e){var n;if(!e||0===e.size)return!1;const i="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(n=t.duration)&&void 0!==n?n:500,r=e.peek();return null!=r&&o>i-r}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,n,i){var o,r,s,l;n.clear(),i.clear();for(let a=0;e.length>a;a++){const c=e[a],u=vt(t,c,a);u&&("point"===c.type?n.set(u,{x:c.x,y:c.y,r:c.r,opacity:c.style.opacity}):"rect"===c.type?n.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:c.style.opacity}):"heatcell"===c.type?n.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:null===(o=c.style)||void 0===o?void 0:o.opacity}):"candlestick"===c.type?n.set(u,{x:c.x,y:c.openY,w:c.bodyWidth,openY:c.openY,closeY:c.closeY,highY:c.highY,lowY:c.lowY,opacity:null===(r=c.style)||void 0===r?void 0:r.opacity}):"line"===c.type?i.set(u,{path:c.path.map(t=>[t[0],t[1]]),opacity:null===(s=c.style)||void 0===s?void 0:s.opacity}):"area"===c.type&&i.set(u,{topPath:c.topPath.map(t=>[t[0],t[1]]),bottomPath:c.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(l=c.style)||void 0===l?void 0:l.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){var t,e,n;this.prevPositionMap.clear(),this.prevPathMap.clear();const i=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.y(0))&&void 0!==e?e:0;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],o=vt(this.transitionContext,e,t);o&&("point"===e.type?this.prevPositionMap.set(o,{x:e.x,y:e.y,r:0,opacity:0}):"rect"===e.type?this.prevPositionMap.set(o,{x:e.x,y:i,w:e.w,h:0,opacity:null!==(n=e.style.opacity)&&void 0!==n?n:1}):"heatcell"===e.type?this.prevPositionMap.set(o,{x:e.x,y:e.y,w:e.w,h:e.h,opacity:0}):"line"===e.type?(e._introClipFraction=0,this.prevPathMap.set(o,{path:e.path.map(t=>[t[0],t[1]]),opacity:e.style.opacity})):"area"===e.type&&(e._introClipFraction=0,this.prevPathMap.set(o,{topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),opacity:e.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,n,i,o){var r,s,l,a,c,u,d,h,f,g,y,p,v,m,x,b,k,w,A,S,M,_,j,P,C,E,L,O,T,D,R,I,$,N,W,z,Y,F,B,H,X;if(0===i.size&&0===o.size)return n;const G=null!==(r=e.duration)&&void 0!==r?r:300;if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}let V=!1;const q=new Set,U=new Set;for(let e=0;n.scene.length>e;e++){const r=n.scene[e],E=vt(t,r,e);if(!E)continue;if(r._transitionKey=E,"line"===r.type||"area"===r.type){const t=o.get(E);if(t){if(U.add(E),"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]];V=!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]];V=!0}r._targetOpacity=null!==(s=r.style.opacity)&&void 0!==s?s:1,r._startOpacity=null!==(a=null!==(l=t.opacity)&&void 0!==l?l:r.style.opacity)&&void 0!==a?a:1}else r._targetOpacity=null!==(c=r.style.opacity)&&void 0!==c?c:1,r._startOpacity=0,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),V=!0;continue}const L=i.get(E);if("point"===r.type)if(L){q.add(E);const t={x:r.x,y:r.y,r:r.r};r._targetOpacity=null!==(u=r.style.opacity)&&void 0!==u?u:1,L.x===t.x&&L.y===t.y&&L.r===t.r||(r._targetX=t.x,r._targetY=t.y,r._targetR=t.r,r.x=L.x,r.y=L.y,r.r=null!==(d=L.r)&&void 0!==d?d:r.r,V=!0)}else r._targetOpacity=null!==(h=r.style.opacity)&&void 0!==h?h:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),V=!0;else if("rect"===r.type)if(L){q.add(E);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(f=r.style.opacity)&&void 0!==f?f:1,L.x===t.x&&L.y===t.y&&L.w===t.w&&L.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=L.x,r.y=L.y,r.w=null!==(g=L.w)&&void 0!==g?g:r.w,r.h=null!==(y=L.h)&&void 0!==y?y:r.h,V=!0)}else r._targetOpacity=null!==(p=r.style.opacity)&&void 0!==p?p:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),V=!0;else if("heatcell"===r.type)if(L){q.add(E);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(m=null===(v=r.style)||void 0===v?void 0:v.opacity)&&void 0!==m?m:1,L.x===t.x&&L.y===t.y&&L.w===t.w&&L.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=L.x,r.y=L.y,r.w=null!==(x=L.w)&&void 0!==x?x:r.w,r.h=null!==(b=L.h)&&void 0!==b?b:r.h,V=!0)}else r._targetOpacity=null!==(w=null===(k=r.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),V=!0;else if("candlestick"===r.type)if(L&&null!=L.openY){q.add(E);const t={x:r.x,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY};r._targetOpacity=null!==(S=null===(A=r.style)||void 0===A?void 0:A.opacity)&&void 0!==S?S:1,(L.x!==t.x||L.openY!==t.openY||L.closeY!==t.closeY||L.highY!==t.highY||L.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=L.x,r.openY=L.openY,r.closeY=null!==(M=L.closeY)&&void 0!==M?M:r.closeY,r.highY=null!==(_=L.highY)&&void 0!==_?_:r.highY,r.lowY=null!==(j=L.lowY)&&void 0!==j?j:r.lowY,V=!0)}else r._targetOpacity=null!==(C=null===(P=r.style)||void 0===P?void 0:P.opacity)&&void 0!==C?C:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),V=!0}for(const[t,e]of o)if(!U.has(t))if(t.startsWith("l:")&&e.path){const i={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(E=e.opacity)&&void 0!==E?E:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(i),V=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const i={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:null!==(L=e.opacity)&&void 0!==L?L:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(i),V=!0}for(const[t,e]of i)if(!q.has(t)){if(t.startsWith("p:")){const i={type:"point",x:e.x,y:e.y,r:null!==(O=e.r)&&void 0!==O?O:3,style:{opacity:null!==(T=e.opacity)&&void 0!==T?T:1},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}else if(t.startsWith("r:")){const i={type:"rect",x:e.x,y:e.y,w:null!==(D=e.w)&&void 0!==D?D:0,h:null!==(R=e.h)&&void 0!==R?R:0,style:{opacity:null!==(I=e.opacity)&&void 0!==I?I:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}else if(t.startsWith("h:")){const i={type:"heatcell",x:e.x,y:e.y,w:null!==($=e.w)&&void 0!==$?$:0,h:null!==(N=e.h)&&void 0!==N?N:0,fill:"#999",datum:null,style:{opacity:null!==(W=e.opacity)&&void 0!==W?W:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}else if(t.startsWith("c:")){const i=null!==(z=e.openY)&&void 0!==z?z:e.y,o={type:"candlestick",x:e.x,openY:i,closeY:null!==(Y=e.closeY)&&void 0!==Y?Y:i,highY:null!==(F=e.highY)&&void 0!==F?F:i,lowY:null!==(B=e.lowY)&&void 0!==B?B:i,bodyWidth:null!==(H=e.w)&&void 0!==H?H:6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:null!==(X=e.opacity)&&void 0!==X?X:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(o)}V=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),V&&(n.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:G}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(t,e,n,i){var o,r,s,l,a,c;if(!n.activeTransition)return!1;const u=yt(t,n.activeTransition),d=gt(u,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of n.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,r=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;t.style.opacity=pt(r,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=pt(n.x,t._targetX,d),t.y=pt(n.y,t._targetY,d),void 0!==t._targetR&&void 0!==n.r&&(t.r=pt(n.r,t._targetR,d))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,o=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;t.style.opacity=pt(o,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=pt(n.x,t._targetX,d),t.y=pt(n.y,t._targetY,d),void 0!==n.w&&(t.w=pt(n.w,t._targetW,d)),void 0!==n.h&&(t.h=pt(n.h,t._targetH,d))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,o=n?null!==(s=n.opacity)&&void 0!==s?s:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:pt(o,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=pt(n.x,t._targetX,d),t.y=pt(n.y,t._targetY,d),void 0!==n.w&&(t.w=pt(n.w,t._targetW,d)),void 0!==n.h&&(t.h=pt(n.h,t._targetH,d))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,o=n?null!==(l=n.opacity)&&void 0!==l?l:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:pt(o,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=pt(n.x,t._targetX,d),void 0!==n.openY&&(t.openY=pt(n.openY,t._targetOpenY,d)),void 0!==n.closeY&&(t.closeY=pt(n.closeY,t._targetCloseY,d)),void 0!==n.highY&&(t.highY=pt(n.highY,t._targetHighY,d)),void 0!==n.lowY&&(t.lowY=pt(n.lowY,t._targetLowY,d))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=null!==(a=t._startOpacity)&&void 0!==a?a:0;t.style=Object.assign(Object.assign({},t.style),{opacity:pt(e,t._targetOpacity,d)})}void 0!==t._introClipFraction&&(t._introClipFraction=d);const e=t._prevPath,n=t._targetPath;if(e&&n&&e.length===t.path.length)for(let i=0;t.path.length>i;i++)t.path[i][0]=pt(e[i][0],n[i][0],d),t.path[i][1]=pt(e[i][1],n[i][1],d)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(c=t._startOpacity)&&void 0!==c?c:0;t.style=Object.assign(Object.assign({},t.style),{opacity:pt(e,t._targetOpacity,d)})}void 0!==t._introClipFraction&&(t._introClipFraction=d);const e=t._prevTopPath,n=t._prevBottomPath,i=t._targetTopPath,o=t._targetBottomPath;if(e&&i&&e.length===t.topPath.length)for(let n=0;t.topPath.length>n;n++)t.topPath[n][0]=pt(e[n][0],i[n][0],d),t.topPath[n][1]=pt(e[n][1],i[n][1],d);if(n&&o&&n.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=pt(n[e][0],o[e][0],d),t.bottomPath[e][1]=pt(n[e][1],o[e][1],d)}}if(u>=1){for(const t of n.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style=Object.assign(Object.assign({},"line"===t.type||"area"===t.type?t.style:t.style||{}),{opacity:0===e?0:e}),t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("candlestick"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let n=0;t.path.length>n;n++)t.path[n]=e[n];t._prevPath=void 0,t._targetPath=void 0,t._introClipFraction=void 0}else if("area"===t.type){const e=t._targetTopPath,n=t._targetBottomPath;if(e)for(let n=0;t.topPath.length>n;n++)t.topPath[n]=e[n];if(n)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=n[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0,t._introClipFraction=void 0}}if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,n}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const t of this.scene)"line"!==t.type&&"area"!==t.type||(t._introClipFraction=void 0)}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const n of t){const t=this.getGroup(n);e.has(t)||e.set(t,[]),e.get(t).push(n)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveColorMap(t){if(this._colorMapCache&&this._colorMapCache.version===this._ingestVersion)return this._colorMapCache.map;const e=new Set;for(const n of t){const t=this.getColor(n);t&&e.add(t)}const n=Array.from(e).sort(),i=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===i)return this._colorMapCache.version=this._ingestVersion,this._colorMapCache.map;const o=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||dt,r=new Map;for(let t=0;n.length>t;t++)r.set(n[t],o[t%o.length]);return this._colorMapCache={key:i,map:r,version:this._ingestVersion},r}resolveLineStyle(t,e){var n;const i=this.config.lineStyle;if("function"==typeof i){const n=i(e||{},t);if(n&&!n.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{stroke:e})}return n}const o=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary;return i&&"object"==typeof i?{stroke:i.stroke||o||"#007bff",strokeWidth:i.strokeWidth||2,strokeDasharray:i.strokeDasharray,fill:i.fill,fillOpacity:i.fillOpacity,opacity:i.opacity}:{stroke:this.resolveGroupColor(t)||o||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var n,i;if(this.config.areaStyle){const n=this.config.areaStyle(e||{});if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}const o=this.config.lineStyle;if("function"==typeof o){const n=o(e||{},t);if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}const r=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary;if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||r||"#4e79a7",fillOpacity:null!==(i=o.fillOpacity)&&void 0!==i?i:.7,stroke:o.stroke||r||"#4e79a7",strokeWidth:o.strokeWidth||2};const s=this.resolveGroupColor(t)||r||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}resolveGroupColor(t){if(this._colorMapCache){const e=this._colorMapCache.map.get(t);if(e)return e}const e=this._groupColorMap.get(t);if(e)return e;const n=(Array.isArray(this.config.colorScheme)&&this.config.colorScheme.length>0?this.config.colorScheme:null)||(Array.isArray(this.config.themeCategorical)&&this.config.themeCategorical.length>0?this.config.themeCategorical:null)||dt;if(0===n.length)return null;const i=n[this._groupColorCounter%n.length];if(this._groupColorCounter++,this._groupColorMap.set(t,i),this._groupColorMap.size>wt.GROUP_COLOR_MAP_CAP){const t=this._groupColorMap.keys().next().value;void 0!==t&&this._groupColorMap.delete(t)}return i}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),n=this.getPointId,i=t=>e.has(n(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,n)=>{i(t)&&e.add(n)}),this.timestampBuffer.clear();for(let n=0;t.length>n;n++)e.has(n)||this.timestampBuffer.push(t[n])}const o=this.buffer.remove(i);if(0===o.length)return o;for(const t of o)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,o}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=new Set(Array.isArray(t)?t:[t]),i=this.getPointId,o=new Set;this.buffer.forEach((t,e)=>{n.has(i(t))&&o.add(e)});const r=this.buffer.update(t=>n.has(i(t)),e);if(0===r.length)return r;for(const t of r)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.buffer.forEach((t,e)=>{o.has(e)&&(this.xExtent.push(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))):(this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,r}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._maxPointRadius=0,this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(t){var e,n,i,o;const r=Object.assign({},this.config);("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"boundsAccessor"in t||"y0Accessor"in t||"openAccessor"in t||"highAccessor"in t||"lowAccessor"in t||"closeAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(this._stackExtentCache=null);let s=!1,l=!1;Object.assign(this.config,t);const a="chartType"in t&&t.chartType!==r.chartType||"runtimeMode"in t&&t.runtimeMode!==r.runtimeMode;if(a||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const c=a||!B(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(n=r.xAccessor)&&void 0!==n?n:r.timeAccessor),u=a||!B(null!==(i=t.yAccessor)&&void 0!==i?i:t.valueAccessor,null!==(o=r.yAccessor)&&void 0!==o?o:r.valueAccessor);(c||u)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=H(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=H(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=H(this.config.xAccessor,"x"),this.getY=H(this.config.yAccessor,"y")),s=!0,l=!0)}if("groupAccessor"in t&&!B(t.groupAccessor,r.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?G(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in t&&!B(t.categoryAccessor,r.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?G(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in t&&!B(t.sizeAccessor,r.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?H(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in t&&!B(t.colorAccessor,r.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?G(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in t&&!B(t.y0Accessor,r.y0Accessor)&&(this.getY0=this.config.y0Accessor?H(this.config.y0Accessor,"y0"):void 0,s=!0,l=!0),"boundsAccessor"in t&&!B(t.boundsAccessor,r.boundsAccessor)&&(this.getBounds=this.config.boundsAccessor?H(this.config.boundsAccessor,"bounds"):void 0,s=!0,l=!0),"pointIdAccessor"in t&&!B(t.pointIdAccessor,r.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?G(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&(a||"openAccessor"in t&&!B(t.openAccessor,r.openAccessor)||"closeAccessor"in t&&!B(t.closeAccessor,r.closeAccessor)||"highAccessor"in t&&!B(t.highAccessor,r.highAccessor)||"lowAccessor"in t&&!B(t.lowAccessor,r.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?H(this.config.openAccessor,"open"):void 0,this.getHigh=H(this.config.highAccessor,"high"),this.getLow=H(this.config.lowAccessor,"low"),this.getClose=e?H(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,s=!0,l=!0}if(!s){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const n of e)if(t[n]!==r[n]){s=!0;break}}s&&(l&&this.rebuildExtents(),this.needsFullRebuild=!0)}}function At(...t){const e=t.filter(t=>null!=t);return 0===e.length?null:1===e.length?e[0]:y.createElement(y.Fragment,null,...e)}function St(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 Mt(t,e=30){return Math.max((null!=t?t:4)+5,12,e)}function _t(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function jt(t,e){const n=_t(t);if(!n)return!1;const i=_t(e);return!i||n.getFullYear()!==i.getFullYear()||n.getMonth()!==i.getMonth()}function Pt(t){let e=t%(2*Math.PI);return 0>e&&(e+=2*Math.PI),e}wt.GROUP_COLOR_MAP_CAP=1e3,wt.QUADTREE_THRESHOLD=500;const Ct=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Et=new WeakMap;let Lt=0,Ot=!1,Tt=null,Dt=null,Rt=null;function It(t,e){var n,i;if(!e)return e;const o=Ct.exec(e);if(!o)return e;const r=t.canvas;if(!r)return(null===(n=o[2])||void 0===n?void 0:n.trim())||e;!function(){if(Ot)return;if("undefined"==typeof window||"undefined"==typeof document)return;Ot=!0;const t=()=>{Lt++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(Tt=new MutationObserver(t),Tt.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{Dt=window.matchMedia("(prefers-color-scheme: dark)"),Rt=t,"function"==typeof Dt.addEventListener?Dt.addEventListener("change",Rt):"function"==typeof Dt.addListener&&Dt.addListener(Rt)}catch(t){}}();let s=Et.get(r);s&&s.version===Lt||(s={version:Lt,map:new Map},Et.set(r,s));const l=s.map.get(e);if(void 0!==l)return l;const a=getComputedStyle(r).getPropertyValue(o[1]).trim()||(null===(i=o[2])||void 0===i?void 0:i.trim())||e;return s.map.set(e,a),a}function $t(t){switch(t){case"monotoneX":return s.curveMonotoneX;case"monotoneY":return s.curveMonotoneY;case"cardinal":return s.curveCardinal;case"catmullRom":return s.curveCatmullRom;case"step":return s.curveStep;case"stepBefore":return s.curveStepBefore;case"stepAfter":return s.curveStepAfter;case"basis":return s.curveBasis;case"natural":return s.curveNatural;default:return null}}function Nt(t,e,n){return null==e?n:"string"!=typeof e?e:It(t,e)||n}function Wt(t,e,n,i,o,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 l=t.createLinearGradient(i,o,r,s);for(const t of n)l.addColorStop(t.offset,t.color);return l}const{topOpacity:l,bottomOpacity:a}=e;if(!Number.isFinite(l)||!Number.isFinite(a))return null;const c=Math.max(0,Math.min(1,l)),u=Math.max(0,Math.min(1,a)),d=t.createLinearGradient(i,o,r,s),[h,f,g]=function(t,e){const n=t.fillStyle,i="#010203";try{t.fillStyle=i,t.fillStyle=e}catch(e){return t.fillStyle=n,[78,121,167]}const o=t.fillStyle;if(t.fillStyle=n,"string"!=typeof o)return[78,121,167];if(o.toLowerCase()===i&&e.trim().toLowerCase()!==i)return[78,121,167];if(o.startsWith("#"))return[parseInt(o.slice(1,3),16),parseInt(o.slice(3,5),16),parseInt(o.slice(5,7),16)];const r=o.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return r?[+r[1],+r[2],+r[3]]:[78,121,167]}(t,n);return d.addColorStop(0,`rgba(${h},${f},${g},${c})`),d.addColorStop(1,`rgba(${h},${f},${g},${u})`),d}function zt(t,e,n,i,o,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 l=t.createLinearGradient(n,i,o,r);for(const t of s)l.addColorStop(t.offset,t.color);return l}const Yt=new WeakMap;function Ft(t,e){const n=$t(e);if(!n)return t;const i=Yt.get(t);if(i)return i;const o=function(t,e,n=8){if(!e||2>t.length)return t.map(([t,e])=>[t,e]);const i=[];let o=null;const r={moveTo(t,e){o=[t,e],i.push([t,e])},lineTo(t,e){o=[t,e],i.push([t,e])},bezierCurveTo(t,e,r,s,l,a){if(!o)return o=[l,a],void i.push([l,a]);const[c,u]=o;for(let o=1;n>=o;o++){const d=o/n,h=1-d;i.push([h*h*h*c+3*h*h*d*t+3*h*d*d*r+d*d*d*l,h*h*h*u+3*h*h*d*e+3*h*d*d*s+d*d*d*a])}o=[l,a]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(t,e,n,r){o=[n,r],i.push([n,r])}};return s.line().x(t=>t[0]).y(t=>t[1]).curve(e).context(r)(t),i}(t,n);return Yt.set(t,o),o}function Bt(t,e,n,i=30,o,r=0){let s=null;if(o){const t=function(t,e,n,i,o){const r=Math.max(i,o+5,12),s=e-r,l=e+r,a=n-r,c=n+r;let u=null,d=1/0;return t.visit((t,o,r,h,f)=>{if(o>l||s>h||r>c||a>f)return!0;if(!t.length){let o=t;do{const t=o.data,r=t.x-e,s=t.y-n,l=Math.sqrt(r*r+s*s);Mt(t.r,i)>=l&&d>l&&(u=t,d=l),o=o.next}while(o)}return!1}),u?{node:u,distance:d}:null}(o,e,n,i,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(o)break;t=Xt(r,e,n,i);break;case"line":t=Gt(r,e,n,i);break;case"rect":if(null==r.datum)break;t=qt(r,e,n);break;case"heatcell":t=Ut(r,e,n);break;case"area":if(!1===r.interactive)break;t=Zt(r,e,n);break;case"candlestick":t=Kt(r,e,n)}t&&i>t.distance&&(s&&t.distance>=s.distance||(s=t))}return s}function Ht(t,e,n){if(0===t.length)return null;if(t[0][0]>e||e>t[t.length-1][0])return null;const i=Qt(t,e);if(0>i)return null;if(Math.abs(t[i][0]-e)>n)return null;let o=i,r=i;i>0&&t[i][0]>=e?(o=i-1,r=i):t.length-1>i&&(o=i,r=i+1);const[s,l]=t[o],[a,c]=t[r];return a===s?l:l+Math.max(0,Math.min(1,(e-s)/(a-s)))*(c-l)}function Xt(t,e,n,i=30){const o=e-t.x,r=n-t.y,s=Math.sqrt(o*o+r*r);return s>Mt(t.r,i)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function Gt(t,e,n,i=30){var o,r,s,l;if(0===t.path.length)return null;const a=Qt(t.path,e);if(0>a)return null;const[c,u]=t.path[a];let d;if(t.path.length>1){let i=1/0;const o=Math.max(0,a-1),r=Math.min(t.path.length-2,a);for(let s=o;r>=s;s++){const[o,r]=t.path[s],[l,a]=t.path[s+1],c=Vt(e,n,o,r,l,a);i>c&&(i=c)}d=i}else{const t=e-c,i=n-u;d=Math.sqrt(t*t+i*i)}const h=null!==(l=null!==(r=null===(o=t.style)||void 0===o?void 0:o.strokeWidth)&&void 0!==r?r:null===(s=t.style)||void 0===s?void 0:s.lineWidth)&&void 0!==l?l:1;return d>Math.max(5,h/2+2,i)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[a]?t.datum[a]:t.datum,x:c,y:u,distance:d}}function Vt(t,e,n,i,o,r){const s=o-n,l=r-i,a=s*s+l*l;if(0===a)return Math.sqrt(Math.pow(t-n,2)+Math.pow(e-i,2));let c=((t-n)*s+(e-i)*l)/a;c=Math.max(0,Math.min(1,c));const u=i+c*l;return Math.sqrt(Math.pow(t-(n+c*s),2)+Math.pow(e-u,2))}function qt(t,e,n){const i=St(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function Ut(t,e,n){const i=St(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function Kt(t,e,n){const i=t.bodyWidth/2,o=Math.min(t.openY,t.closeY);if(!(t.x-i-3>e||e>t.x+i+3||t.highY-3>n||n>t.lowY+3)){const i=o+Math.max(Math.max(t.openY,t.closeY)-o,1)/2,r=e-t.x,s=n-i;return{node:t,datum:t.datum,x:t.x,y:i,distance:Math.sqrt(r*r+s*s)}}return null}function Zt(t,e,n){if(0===t.topPath.length)return null;const i=Qt(t.topPath,e);if(0>i)return null;const[o,r]=t.topPath[i],s=e-o,l=n-r,a=Math.sqrt(s*s+l*l);return{node:t,datum:Array.isArray(t.datum)&&t.datum[i]?t.datum[i]:t.datum,x:o,y:r,distance:a}}function Qt(t,e){if(0===t.length)return-1;let n=0,i=t.length-1;for(;i>n;){const o=n+i>>1;e>t[o][0]?n=o+1:i=o}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}function Jt(t){var e,n;const i=new Map;for(const n of t){const t=null!==(e=n.group)&&void 0!==e?e:"_default";let o=i.get(t);o||(o=[],i.set(t,o)),o.push(n)}for(const t of i.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 o=Array.from(i.keys()).sort((t,e)=>{const n=i.get(t),o=i.get(e);return(n.length>0?n[0].y:0)-(o.length>0?o[0].y:0)}),r=Array.from(i.values()).flat();r.sort((t,e)=>t.x-e.x||t.y-e.y);const s=new Map;for(let t=0;r.length>t;t++){r[t]._flatIndex=t;const e=null===(n=r[t].datum)||void 0===n?void 0:n.id;null!=e&&s.set(e+"",t)}return{flat:r,groups:o,byGroup:i,idToIdx:s}}function te(t,e){var n,i;if(0===t.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const o=Math.max(0,Math.min(e,t.flat.length-1)),r=t.flat[o];return{flatIndex:o,group:null!==(n=r.group)&&void 0!==n?n:"_default",indexInGroup:null!==(i=r._groupIndex)&&void 0!==i?i:0}}function ee(t,e,n){const{group:i,indexInGroup:o}=e,r=n.byGroup.get(i);switch(t){case"ArrowRight":return r.length-1>o?r[o+1]._flatIndex:e.flatIndex;case"ArrowLeft":return o>0?r[o-1]._flatIndex:e.flatIndex;case"ArrowDown":{const t=n.groups.indexOf(i);return n.groups.length-1>t?ne(n,n.groups[t+1],r[o]):e.flatIndex}case"ArrowUp":{const t=n.groups.indexOf(i);return t>0?ne(n,n.groups[t-1],r[o]):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}}function ne(t,e,n){const i=t.byGroup.get(e);let o=0,r=Math.abs(i[0].x-n.x);for(let t=1;i.length>t;t++){const e=Math.abs(i[t].x-n.x);r>e&&(r=e,o=t)}return i[o]._flatIndex}function ie(t){return"object"==typeof t&&null!==t&&"id"in t?t.id:t}function oe(t){return{data:t.datum||{},x:t.x,y:t.y,__semioticHoverData:!0}}function re(t,n,i,o,r,s){e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{var e;const l=n.current;if(!l||0===l.lastIngestTime)return;const a="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(e=t.threshold)&&void 0!==e?e:5e3,u=a-l.lastIngestTime>c;u!==r&&(s(u),i.current=!0,o())},1e3);return()=>clearInterval(e)},[t,r,o])}const se={fill:e=>t.jsx("rect",{style:e,width:16,height:16}),line:e=>t.jsx("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function le(t,e,n,i){let o;return o="function"==typeof n?n(t):(0,se[n])(i(t,e)),o}function ae(){return t.jsx("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function ce(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}const ue=(e,n,i,o,r,s,l,a,c,u)=>{const{type:d="fill",styleFn:h,items:f}=e,g=[];let y=0;const p=!(!n&&!i),v="isolate"===u||void 0===u&&null!=r;return f.forEach((e,u)=>{const m=le(e,u,d,h),x=ce(e,o,r),b=r&&r.size>0&&r.has(e.label);g.push(t.jsxs("g",{transform:`translate(0,${y})`,onClick:n?()=>n(e):void 0,onMouseEnter:i?()=>i(e):void 0,onMouseLeave:i?()=>i(null):void 0,tabIndex:p?a===s&&u===l?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&v?b||!1:void 0,"aria-current":p&&!v&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:p?t=>{var i;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),n&&n(e)),"ArrowDown"===t.key||"ArrowUp"===t.key){t.preventDefault();const e=(u+("ArrowDown"===t.key?1:-1)+f.length)%f.length;c(a,e);const n=null===(i=t.currentTarget.parentElement)||void 0===i?void 0:i.children[e];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:p?t=>{c(a,u),i&&i(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:p?t=>{i&&i(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:p?"pointer":"default",opacity:x,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[p&&t.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),m,b&&t.jsx(ae,{}),t.jsx("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+u)),y+=22}),g};function de({config:e,orientation:n="vertical",width:i=100}){const{colorFn:o,domain:r,label:s,format:l}=e,a=l||(t=>Math.round(100*t)/100+""),c="grad-legend-"+y.useId();if("horizontal"===n){const e=12,n=Math.min(i,200),l=Math.max(0,(i-n)/2),u=[];for(let e=0;64>=e;e++){const n=e/64;u.push(t.jsx("stop",{offset:100*n+"%",stopColor:o(r[0]+n*(r[1]-r[0]))},e))}return t.jsxs("g",{"aria-label":s||"Gradient legend",children:[t.jsx("defs",{children:t.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:u})}),s&&t.jsx("text",{x:l+n/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),t.jsx("rect",{x:l,y:0,width:n,height:e,fill:`url(#${c})`,rx:2}),t.jsx("text",{x:l,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[0])}),t.jsx("text",{x:l+n,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[1])})]})}const u=[];for(let e=0;64>=e;e++){const n=e/64;u.push(t.jsx("stop",{offset:100*n+"%",stopColor:o(r[1]-n*(r[1]-r[0]))},e))}return t.jsxs("g",{"aria-label":s||"Gradient legend",children:[s&&t.jsx("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),t.jsx("defs",{children:t.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:u})}),t.jsx("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),t.jsx("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[1])}),t.jsx("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[0])})]})}function he(e){const{legendGroups:n,customClickBehavior:i,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:s,legendInteraction:l,title:a="Legend",width:c=100,height:u=20,orientation:d="vertical"}=e,[h,f]=y.useState(0),[g,p]=y.useState(0),v=y.useCallback((t,e)=>{f(t),p(e)},[]),m="vertical"===d?(({legendGroups:e,width:n,customClickBehavior:i,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:l,focusedItemIndex:a,onFocusedIndexChange:c,legendInteraction:u})=>{let d=24;const h=[];return e.forEach((e,f)=>{d+=5,h.push(t.jsx("line",{stroke:"gray",x1:0,y1:d,x2:n,y2:d},"legend-top-line legend-symbol-"+f)),d+=8,e.label&&(d+=16,h.push(t.jsx("text",{y:d,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+f)),d+=8),h.push(t.jsx("g",{className:"legend-item",transform:`translate(0,${d})`,children:ue(e,i,o,r,s,l,a,f,c,u)},"legend-group-"+f)),d+=22*e.items.length+8}),h})({legendGroups:n||[],width:c,customClickBehavior:i,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:v,legendInteraction:l}):(({legendGroups:e,height:n,width:i,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:s,isolatedCategories:l,focusedGroupIndex:a,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:d})=>{let h=0;const f=[];e.forEach((e,n)=>{let g=0;e.label&&(g+=16);const y=((e,n,i,o,r,s,l,a,c,u,d)=>{const{type:h="fill",styleFn:f,items:g}=e,y=[];let p=0,v=0;const m=!(!n&&!i),x="isolate"===u||void 0===u&&null!=r;g.forEach((e,u)=>{const b=le(e,u,h,f),k=ce(e,o,r),w=r&&r.size>0&&r.has(e.label),A=26+7*e.label.length;d&&d>0&&p>0&&p+A>d&&(v++,p=0),y.push(t.jsxs("g",{transform:`translate(${p},${22*v})`,onClick:n?()=>n(e):void 0,onMouseEnter:i?()=>i(e):void 0,onMouseLeave:i?()=>i(null):void 0,tabIndex:m?a===s&&u===l?0:-1:void 0,role:m?"option":void 0,"aria-selected":m&&x?w||!1:void 0,"aria-current":m&&!x&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:m?t=>{var i;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),n&&n(e)),"ArrowRight"===t.key||"ArrowLeft"===t.key){t.preventDefault();const e=(u+("ArrowRight"===t.key?1:-1)+g.length)%g.length;c(a,e);const n=null===(i=t.currentTarget.parentElement)||void 0===i?void 0:i.children[e];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:m?t=>{c(a,u),i&&i(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:m?t=>{i&&i(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:m?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[m&&t.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),b,w&&t.jsx(ae,{}),t.jsx("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+u)),p+=A});let b=0,k=0;for(const t of g){const e=26+7*t.label.length;d&&d>0&&k>0&&k+e>d?(b=Math.max(b,k),k=e):k+=e}b=Math.max(b,k);const w=v+1;return{items:y,offset:b,totalRows:w,totalHeight:22*w}})(e,o,r,s,l,a,c,n,u,d,i);g+=y.offset+5,f.push(Object.assign(Object.assign({label:e.label},y),{offset:g,totalRows:y.totalRows,totalHeight:y.totalHeight})),h+=g+12});let g=h>i?0:Math.max(0,(i-h)/2);const y=[];return f.forEach((i,o)=>{const r=e[o];r.label&&(y.push(t.jsx("text",{transform:`translate(${g},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:r.label},"legend-text-"+o)),g+=16),y.push(t.jsx("g",{className:"legend-item",transform:`translate(${g},0)`,children:i.items},"legend-group-"+o)),g+=i.offset+5,e[o+1]&&y.push(t.jsx("line",{stroke:"gray",x1:g,y1:-8,x2:g,y2:(i.totalHeight||n)+0+8},"legend-top-line legend-symbol-"+o)),g+=12}),t.jsx("g",{children:y})})({legendGroups:n||[],title:a,height:u,width:c,customClickBehavior:i,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:v,legendInteraction:l}),x=!(!i&&!o);return t.jsxs("g",{role:x?"listbox":void 0,"aria-multiselectable":!(!x||"isolate"!==l&&(void 0!==l||null==s))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==a&&""!==a&&"vertical"===d&&t.jsx("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:a}),m]})}function fe(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}function ge(t){return"object"==typeof t&&null!==t&&"gradient"in t}function ye(e){const{legend:n,totalWidth:i,totalHeight:o,margin:r,legendPosition:s="right",title:l,legendHoverBehavior:a,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=e;if(!n)return null;const f="top"===s||"bottom"===s;let g,y;return"left"===s?(g=4,y=r.top):"top"===s?(g=0,y=l?32:8):"bottom"===s?(g=0,y=o-r.bottom+50):(g=i-r.right+10,y=r.top),t.jsx("g",{transform:`translate(${g}, ${y})`,children:ge(n)?t.jsx(de,{config:n.gradient,orientation:f?"horizontal":"vertical",width:f?i:100}):fe(n)?t.jsx(he,{legendGroups:n.legendGroups,title:"",width:f?i:100,orientation:f?"horizontal":"vertical",customHoverBehavior:a,customClickBehavior:c,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):n})}function pe(t){return"string"==typeof t?{type:t}:t}function ve({orient:n,config:i,values:o,scale:r,size:s,length:a}){const c=function(t){var e,n,i,o,r;return{type:t.type,bins:null!==(e=t.bins)&&void 0!==e?e:20,fill:null!==(n=t.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(i=t.fillOpacity)&&void 0!==i?i:.5,stroke:null!==(o=t.stroke)&&void 0!==o?o:"none",strokeWidth:null!==(r=t.strokeWidth)&&void 0!==r?r:1}}(i),u="top"===n||"bottom"===n,d=e.useMemo(()=>{if(0===o.length)return null;const e=r.domain(),i=s-8;if("boxplot"===c.type){const e=function(t){const e=[...t].sort((t,e)=>t-e),n=e.length;if(0===n)return null;const i=e[Math.floor(.25*n)],o=e[Math.floor(.5*n)],r=e[Math.floor(.75*n)],s=r-i;return{q1:i,median:o,q3:r,whiskerLow:Math.max(e[0],i-1.5*s),whiskerHigh:Math.min(e[n-1],r+1.5*s)}}(o);if(!e)return null;const{q1:s,median:l,q3:a,whiskerLow:d,whiskerHigh:h}=e,f=Math.min(.5*i,20),g=(i-f)/2+4;if(u){const e=r(s),i=r(a),o=r(l),u=r(d),y=r(h),p="top"===n?-1:1,v=0;return t.jsxs("g",{"data-testid":"marginal-boxplot-"+n,children:[t.jsx("line",{x1:u,y1:v+p*(g+f/2),x2:y,y2:v+p*(g+f/2),stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:u,y1:v+p*g,x2:u,y2:v+p*(g+f),stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:y,y1:v+p*g,x2:y,y2:v+p*(g+f),stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("rect",{x:Math.min(e,i),y:"top"===n?v-g-f:v+g,width:Math.abs(i-e),height:f,fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:o,y1:"top"===n?v-g-f:v+g,x2:o,y2:"top"===n?v-g:v+g+f,stroke:c.fill,strokeWidth:2})]})}{const e=r(s),i=r(a),o=r(l),u=r(d),y=r(h),p="left"===n?-1:1,v=0;return t.jsxs("g",{"data-testid":"marginal-boxplot-"+n,children:[t.jsx("line",{x1:v+p*(g+f/2),y1:u,x2:v+p*(g+f/2),y2:y,stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:v+p*g,y1:u,x2:v+p*(g+f),y2:u,stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:v+p*g,y1:y,x2:v+p*(g+f),y2:y,stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("rect",{x:"left"===n?v-g-f:v+g,y:Math.min(e,i),width:f,height:Math.abs(i-e),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:"left"===n?v-g-f:v+g,y1:o,x2:"left"===n?v-g:v+g+f,y2:o,stroke:c.fill,strokeWidth:2})]})}}const d=l.bin().domain(e).thresholds(c.bins)(o);if(0===d.length)return null;const h=Math.max(...d.map(t=>t.length));if(0===h)return null;if("histogram"===c.type)return t.jsx("g",{"data-testid":"marginal-histogram-"+n,children:d.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const s=e.length/h*i;if(u){const i=r(e.x0),l=r(e.x1)-r(e.x0);return t.jsx("rect",{x:i,y:"top"===n?-4-s:4,width:Math.max(l,.5),height:s,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},o)}{const i=r(e.x0),l=r(e.x1)-r(e.x0);return t.jsx("rect",{x:"left"===n?-4-s:4,y:Math.min(i,i+l),width:s,height:Math.abs(l),fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},o)}})});if("violin"===c.type){const e=i/2+4,o=[];for(const t of d){if(null==t.x0||null==t.x1)continue;const s=t.length/h*(i/2),l=r((t.x0+t.x1)/2);o.push(u?`${l},${"top"===n?-(e-s):e-s}`:`${"left"===n?-(e-s):e-s},${l}`)}for(let t=d.length-1;t>=0;t--){const s=d[t];if(null==s.x0||null==s.x1)continue;const l=s.length/h*(i/2),a=r((s.x0+s.x1)/2);o.push(u?`${a},${"top"===n?-(e+l):e+l}`:`${"left"===n?-(e+l):e+l},${a}`)}return t.jsx("g",{"data-testid":"marginal-violin-"+n,children:t.jsx("polygon",{points:o.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}if("ridgeline"===c.type){const e=[];if(u){const t=0,o=null!=d[0].x0?r(d[0].x0):0;e.push(`M${o},${t}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const o=t.length/h*i,s=r((t.x0+t.x1)/2);e.push(`L${s},${"top"===n?-o-4:o+4}`)}const s=null!=d[d.length-1].x1?r(d[d.length-1].x1):a;e.push(`L${s},${t}`),e.push("Z")}else{const t=0,o=null!=d[0].x0?r(d[0].x0):0;e.push(`M${t},${o}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const o=t.length/h*i,s=r((t.x0+t.x1)/2);e.push(`L${"left"===n?-o-4:o+4},${s}`)}const s=null!=d[d.length-1].x1?r(d[d.length-1].x1):a;e.push(`L${t},${s}`),e.push("Z")}return t.jsx("g",{"data-testid":"marginal-ridgeline-"+n,children:t.jsx("path",{d:e.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}return null},[o,r,c,s,a,n,u,4]);return d?t.jsx("g",{className:"marginal-"+n,"data-testid":"marginal-"+n,children:d}):null}function me(t,e=120,n=8){if(!t)return[];const i=Math.max(1,Math.floor(e/n)),o=t.split(/\s+/),r=[];let s="";for(const t of o)s&&s.length+1+t.length>i?(r.push(s),s=t):s=s?`${s} ${t}`:t;return s&&r.push(s),r}function xe(t,e,n,i){return"curly"===t?i?`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`:i?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function be(e,n,i,o){if(!e)return t.jsx("g",{className:"annotation-note"});const{label:r,title:s,orientation:l,align:a,wrap:c=120,noWrap:u}=e;if(!r&&!s)return t.jsx("g",{className:"annotation-note"});let d=l;d||(d=Math.abs(n)>Math.abs(i)?"leftRight":"topBottom");let h=a;h&&"dynamic"!==h||(h="topBottom"===d?0>n?"right":"left":0>i?"bottom":"top");let f="start";"topBottom"===d?"right"===h?f="end":"middle"===h&&(f="middle"):f=0>n?"end":"start";const g=16,y=s?u?[s]:me(s,c):[],p=r?u?[r]:me(r,c):[],v="leftRight"===d?"end"===f?-4:4:0;let m=0;const x=[],b=o||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";y.length>0&&(x.push(t.jsx("text",{className:"annotation-note-title",fill:b,textAnchor:f,fontWeight:"bold",children:y.map((e,n)=>t.jsx("tspan",{x:v,dy:0===n?0:g,children:e},n))},"annotation-note-title")),m=y.length*g),p.length>0&&x.push(t.jsx("text",{className:"annotation-note-label",fill:b,textAnchor:f,y:m,children:p.map((e,n)=>t.jsx("tspan",{x:v,dy:0===n?0:g,children:e},n))},"annotation-note-label"));let k=null;if((s||r)&&(0!==n||0!==i))if("topBottom"===d){const e=Math.min(c,120);let n=0,i=e;"end"===f?(n=-e,i=0):"middle"===f&&(n=-e/2,i=e/2),k=t.jsx("line",{className:"note-line",x1:n,x2:i,y1:0,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(y.length+p.length)*g+(p.length>0?g:0);let n=0,i=e;"bottom"===h?(n=-e,i=0):"middle"===h&&(n=-e/2,i=e/2),k=t.jsx("line",{className:"note-line",x1:0,x2:0,y1:n,y2:i,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,y.length+p.length-1)*g;let A=0;return"topBottom"===d?A=0>i?-(w+2):18:"leftRight"===d&&(A="middle"===h?-(w+g+(p.length>0&&y.length>0?2:0))/2+8:"bottom"===h||0>i?-(w+2):18),t.jsxs("g",{className:"annotation-note",transform:`translate(${n},${i})`,children:[t.jsx("g",{className:"annotation-note-content",transform:0!==A?`translate(0,${A})`:void 0,children:x}),k]})}function ke(e,n,i,o,r){var s;const l=[];switch(e){case"callout-circle":{const e=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);e>0&&l.push(t.jsx("circle",{r:e,fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=(null==n?void 0:n.width)||0,o=(null==n?void 0:n.height)||0;(e>0||o>0)&&l.push(t.jsx("rect",{width:e,height:o,fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":(null==n?void 0:n.custom)&&l.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const e=o||0,s=r||0;if(void 0!==(null==n?void 0:n.x)){const o=(n.x||0)-e;l.push(t.jsx("line",{x1:o,y1:(n.y1||0)-s,x2:o,y2:(n.y2||0)-s,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==(null==n?void 0:n.y)){const o=(n.y||0)-s;l.push(t.jsx("line",{x1:(n.x1||0)-e,y1:o,x2:(n.x2||0)-e,y2:o,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?l.push(t.jsx("line",{x1:(n.x1||0)-e,y1:0,x2:(n.x2||0)-e,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||l.push(t.jsx("line",{x1:0,y1:(n.y1||0)-s,x2:0,y2:(n.y2||0)-s,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=null!==(s=null==n?void 0:n.width)&&void 0!==s?s:null==n?void 0:n.height;void 0!==e&&l.push(t.jsx("path",{d:xe((null==n?void 0:n.type)||"curly",e,(null==n?void 0:n.depth)||30,void 0===(null==n?void 0:n.width)),fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return t.jsx("g",{className:"annotation-subject",children:l})}function we(e,n,i,o,r,s){const l=[];let a=0,c=0;if("callout-circle"!==r&&"label"!==r||!(null==s?void 0:s.radius)){if("callout-rect"===r&&s){const t=s.width||0,i=s.height||0;if(t>0||i>0){const o=t/2,r=i/2,s=e-o,l=n-r;if(0!==s||0!==l){const e=Math.abs(s),n=Math.abs(l),u=t/2,d=i/2,h=e*d>n*u?u/e:d/n;a=o+s*h,c=r+l*h}}}else if("bracket"===r&&s){const t=s.width,e=s.height,n=s.depth||30;void 0!==t?(a=t/2,c=n):void 0!==e&&(a=n,c=e/2)}}else{const t=(s.radius||0)+(s.radiusPadding||0);if(t>0&&(0!==e||0!==n)){const i=Math.atan2(n,e);a=Math.cos(i)*t,c=Math.sin(i)*t}}if(Math.sqrt(Math.pow(e-a,2)+Math.pow(n-c,2))>.5&&(l.push(t.jsx("line",{x1:a,y1:c,x2:e,y2:n,stroke:o||"var(--semiotic-text-secondary, currentColor)"},"connector-line")),"arrow"===(null==i?void 0:i.end))){const i=10,r=16/180*Math.PI,s=Math.atan2(n-c,e-a);l.push(t.jsx("path",{d:`M${a},${c}L${a+i*Math.cos(s+r)},${c+i*Math.sin(s+r)}L${a+i*Math.cos(s-r)},${c+i*Math.sin(s-r)}Z`,fill:o||"var(--semiotic-text-secondary, currentColor)",stroke:"none"},"connector-arrow"))}return t.jsx("g",{className:"annotation-connector",children:l})}function Ae(e){const{x:n=0,y:i=0,dx:o,dy:r,nx:s,ny:l,note:a,connector:c,subject:u,type:d,color:h,className:f,disable:g,events:y={},"data-testid":p}=e,v=new Set(Array.isArray(g)?g:[]);let m=o||0,x=r||0;null!=s&&(m=s-n),null!=l&&(x=l-i);const b="string"==typeof d?d:"label";if("bracket"===b&&u&&0===m&&0===x)if(void 0!==u.width){m=u.width/2;const t=u.depth||30;x=t+(0>t?-5:5)}else if(void 0!==u.height){const t=u.depth||30;m=t+(0>t?-5:5),x=u.height/2}return t.jsxs("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${n},${i})`,"data-testid":p},y,{children:[!v.has("connector")&&we(m,x,c,h,b,u),!v.has("subject")&&ke(b,u,h,n,i),!v.has("note")&&be(a,m,x,h)]}))}function Se(e){var n,i;const{noteData:o}=e,{screenCoordinates:r}=o,s="string"==typeof o.type?o.type:"label",l=o.eventListeners||o.events||{};if(o.coordinates&&r){const e=o.nx||r[0][0]+(null!==(n=o.dx)&&void 0!==n?n:0),l=o.ny||r[0][1]+(null!==(i=o.dy)&&void 0!==i?i:0),a=r.map((n,i)=>{const r=Object.assign({},o,{note:0===i?o.note:{label:""},x:n[0],y:n[1],nx:e,ny:l});return t.jsx(Ae,Object.assign({"data-testid":"semiotic-annotation"},r,{type:s}),"multi-annotation-"+i)});return t.jsx("g",{children:a})}const a=o.note||{title:"none",label:o.label},c=`${a.label}-${a.title}-${o.i}`;return t.jsx(Ae,Object.assign({"data-testid":"semiotic-annotation",events:l},o,{type:s}),c)}function Me(t,e){var n,i,o;const r=null!==(i=null===(n=e.scales)||void 0===n?void 0:n.x)&&void 0!==i?i:null===(o=e.scales)||void 0===o?void 0:o.time;return r?null!=t.x?r(t.x):e.xAccessor&&null!=t[e.xAccessor]?r(t[e.xAccessor]):null:null}function _e(t,e){var n,i,o;const r=null!==(i=null===(n=e.scales)||void 0===n?void 0:n.y)&&void 0!==i?i:null===(o=e.scales)||void 0===o?void 0:o.value;return r?null!=t.y?r(t.y):e.yAccessor&&null!=t[e.yAccessor]?r(t[e.yAccessor]):null:null}function je(t,e,n){var i,o,r,s;const l=t.anchor||"fixed";if("latest"===l){if(null!=t.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const r=n.pointNodes[o];if(r.pointId===t.pointId){const t={x:r.x,y:r.y};return null===(i=n.stickyPositionCache)||void 0===i||i.set(e,t),t}}const r=function(t){var e,n,i,o,r,s;const l=t.data;if(!l||0===l.length)return null;const a=l[l.length-1],c=null!==(n=null===(e=t.scales)||void 0===e?void 0:e.x)&&void 0!==n?n:null===(i=t.scales)||void 0===i?void 0:i.time,u=null!==(r=null===(o=t.scales)||void 0===o?void 0:o.y)&&void 0!==r?r:null===(s=t.scales)||void 0===s?void 0:s.value;if(!c||!u)return null;const d=a[t.xAccessor||"x"],h=a[t.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return r&&(null===(o=n.stickyPositionCache)||void 0===o||o.set(e,r)),r}let a=null,c=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);e&&(a=e.x,c=e.y)}if(null!=a&&null!=c||(a=Me(t,n),c=_e(t,n)),null!=a&&null!=c)return null===(r=n.stickyPositionCache)||void 0===r||r.set(e,{x:a,y:c}),{x:a,y:c};if("sticky"===l){const t=null===(s=n.stickyPositionCache)||void 0===s?void 0:s.get(e);if(t)return t}return null}function Pe(t,e,n,i=50){return!(-i>t||t>(n.width||0)+i||-i>e||e>(n.height||0)+i)}const Ce={linear:s.curveLinear,monotoneX:s.curveMonotoneX,monotoneY:s.curveMonotoneY,step:s.curveStep,stepAfter:s.curveStepAfter,stepBefore:s.curveStepBefore,basis:s.curveBasis,cardinal:s.curveCardinal,catmullRom:s.curveCatmullRom};let Ee={positions:new Map};const Le=new Set;function Oe(){for(const t of Le)t()}function Te(t,e){const n=Ee.positions.get(t);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==e)return;const i=new Map(Ee.positions);i.delete(t),Ee={positions:i},Oe()}function De(t,e){const n=Ee.positions.get(t);if(!(null==n?void 0:n.locked))return;if(e&&n.sourceId!==e)return;const i=new Map(Ee.positions);i.delete(t),Ee={positions:i},Oe()}function Re(){return Ee}function Ie(t){return Le.add(t),()=>Le.delete(t)}const $e={positions:new Map};function Ne(){return()=>{}}function We(){return $e}function ze(t){if(t)return"dashed"===t?"6,4":"dotted"===t?"2,4":t}function Ye(t,e,n){if("left"===t||"right"===t){const i="left"===t?n:0,o="left"===t?-1:1,r=Math.ceil(e/8);let s="M0,"+i;for(let t=0;r>t;t++){const n=8*(t+1);s+=`L${Math.min(8*t+4,e)},${i+4*o}`,s+=`L${Math.min(n,e)},${i}`}return s}{const i="bottom"===t?0:e,o="bottom"===t?1:-1,r=Math.ceil(n/8);let s=`M${i},0`;for(let t=0;r>t;t++){const e=8*(t+1);s+=`L${i+4*o},${Math.min(8*t+4,n)}`,s+=`L${i},${Math.min(e,n)}`}return s}}function Fe(n){const{width:i,height:o,totalWidth:r,totalHeight:s,margin:l,scales:a,showAxes:c,axes:u,showGrid:d,xFormat:h,yFormat:f}=n,g=e.useMemo(()=>{var t;if(!a)return[];const e=null==u?void 0:u.find(t=>"bottom"===t.orient),n=(null==e?void 0:e.tickFormat)||h||Be,o=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,r=a.x.ticks(Math.min(o,Math.max(2,Math.floor(i/70)))),s=r.map(t=>t.valueOf()),l=r.map((t,e)=>({value:t,pixel:a.x(t),label:n(t,e,s)})),c=l.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0);return He(l,Math.max(55,c+8))},[a,u,h,i]),y=e.useMemo(()=>{var t;if(!a)return[];const e=null==u?void 0:u.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||f||Be,i=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return He(a.y.ticks(Math.min(i,Math.max(2,Math.floor(o/30)))).map(t=>({value:t,pixel:a.y(t),label:n(t)})),22)},[a,u,f,o]),p=d&&a,v=c&&a;if(!p&&!v)return null;const m=null==u?void 0:u.find(t=>"bottom"===t.orient),x=null==u?void 0:u.find(t=>"left"===t.orient),b=v&&(!m||!1!==m.baseline),k=v&&(!x||!1!==x.baseline),w=(null==m?void 0:m.jaggedBase)||!1,A=(null==x?void 0:x.jaggedBase)||!1,S="var(--semiotic-border, #ccc)";return t.jsx("svg",{width:r,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:t.jsxs("g",{transform:`translate(${l.left},${l.top})`,children:[p&&(()=>{var e,n;const r=ze(null===(e=null==u?void 0:u.find(t=>"bottom"===t.orient))||void 0===e?void 0:e.gridStyle),s=ze(null===(n=null==u?void 0:u.find(t=>"left"===t.orient))||void 0===n?void 0:n.gridStyle);return t.jsxs("g",{className:"stream-grid",children:[g.map((e,n)=>t.jsx("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"xgrid-"+n)),y.map((e,n)=>t.jsx("line",{x1:0,y1:e.pixel,x2:i,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:s},"ygrid-"+n))]})})(),b&&!w&&t.jsx("line",{x1:0,y1:o,x2:i,y2:o,stroke:S,strokeWidth:1}),w&&t.jsx("path",{d:Ye("bottom",i,o),fill:"none",stroke:S,strokeWidth:1}),k&&!A&&t.jsx("line",{x1:0,y1:0,x2:0,y2:o,stroke:S,strokeWidth:1}),A&&t.jsx("path",{d:Ye("left",i,o),fill:"none",stroke:S,strokeWidth:1})]})})}function Be(t,e,n){return t instanceof Date?`${t.toLocaleString("en",{month:"short"})} ${t.getDate()}`:"number"==typeof t?Math.round(100*t)/100+"":t+""}function He(t,e){if(2>=t.length)return t;const n=[t[0]];for(let i=1;t.length-1>i;i++)e>Math.abs(t[i].pixel-n[n.length-1].pixel)||n.push(t[i]);const i=t[t.length-1];return e>Math.abs(i.pixel-n[n.length-1].pixel)?n[n.length-1]=i:n.push(i),n}function Xe(n){var i,o;const{width:r,height:l,totalWidth:c,totalHeight:u,margin:d,scales:h,showAxes:f,axes:g,xLabel:y,yLabel:v,yLabelRight:m,xFormat:x,yFormat:b,showGrid:k,title:w,legend:A,legendHoverBehavior:S,legendClickBehavior:M,legendHighlightedCategory:_,legendIsolatedCategories:j,legendPosition:P="right",foregroundGraphics:C,marginalGraphics:E,xValues:L,yValues:O,annotations:T,svgAnnotationRules:D,xAccessor:R,yAccessor:I,annotationData:$,pointNodes:N,curve:W,underlayRendered:z,canvasObscuresUnderlay:Y=!0,linkedCrosshairName:F,linkedCrosshairSourceId:B,children:H}=n,X=e.useMemo(()=>{var t;if(!f||!h)return[];const e=null==g?void 0:g.find(t=>"bottom"===t.orient),n=(null==e?void 0:e.tickFormat)||x||Be,i=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,o=h.x.ticks(Math.min(i,Math.max(2,Math.floor(r/70)))),s=o.map(t=>t.valueOf()),l=o.map((t,e)=>({value:t,pixel:h.x(t),label:n(t,e,s)})),a=l.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0),c=(null==e?void 0:e.autoRotate)?Math.max(20,Math.min(a+8,55)):Math.max(55,a+8);let u=He(l,c);if(u.length>1&&(u=u.filter((t,e)=>0===e||t.label+""!=u[e-1].label+"")),(null==e?void 0:e.includeMax)&&u.length>0){const t=h.x.domain()[1],e=h.x(t),i=u[u.length-1].pixel;if(Math.abs(e-i)>1){const o=n(t,u.length,s);c>e-i&&u.length>1&&(u=u.slice(0,-1)),u.push({value:t,pixel:e,label:o})}}return u},[f,h,g,x,r]),G=e.useMemo(()=>{var t;if(!f||!h)return[];const e=null==g?void 0:g.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||b||Be,i=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;let o=He(h.y.ticks(Math.min(i,Math.max(2,Math.floor(l/30)))).map(t=>({value:t,pixel:h.y(t),label:n(t)})),22);if(o.length>1&&(o=o.filter((t,e)=>0===e||t.label+""!=o[e-1].label+"")),(null==e?void 0:e.includeMax)&&o.length>0){const t=h.y.domain()[1],e=h.y(t),i=o[o.length-1].pixel;if(Math.abs(e-i)>1){const r=n(t);22>Math.abs(e-i)&&o.length>1&&(o=o.slice(0,-1)),o.push({value:t,pixel:e,label:r})}}return o},[f,h,g,b,l]),V=e.useMemo(()=>{var t;if(!f||!h)return[];const e=null==g?void 0:g.find(t=>"right"===t.orient);if(!e)return[];const n=e.tickFormat||b||Be,i=null!==(t=e.ticks)&&void 0!==t?t:5;return He(h.y.ticks(Math.min(i,Math.max(2,Math.floor(l/30)))).map(t=>({value:t,pixel:h.y(t),label:n(t)})),22)},[f,h,g,b,l]),q=e.useRef(new Map),U=e.useRef(null!==(i=null==T?void 0:T.length)&&void 0!==i?i:0),K=null!==(o=null==T?void 0:T.length)&&void 0!==o?o:0;U.current!==K&&(U.current=K,q.current=new Map);const Z=e.useMemo(()=>{if(!T||0===T.length)return null;const e=function(e,n,i){var o,r,l,c,u,d,h,f,g,y,v,m,x,b,k,w,A,S,M,_,j,P,C,E,L,O,T,D,R,I,$,N,W,z,Y,F,B,H,X,G,V,q,U,K,Z,Q,J,tt;switch(e.type){case"label":{const o=je(e,n,i);if(!o)return null;const{x:r,y:s}=o;return Pe(r,s,i)?t.jsx(Se,{noteData:{x:r,y:s,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"label",connector:e.connector||{end:"arrow"},color:e.color}},"ann-"+n):null}case"callout":{const o=je(e,n,i);if(!o)return null;const{x:r,y:s}=o;return Pe(r,s,i)?t.jsx(Se,{noteData:{x:r,y:s,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"callout-circle",subject:{radius:e.radius||12},connector:e.connector||{end:"arrow"},color:e.color}},"ann-"+n):null}case"x-threshold":{const o=Me(null!=e.value?Object.assign(Object.assign({},e),{x:e.value}):e,i);if(null==o)return null;const r=e.color||"#f97316",s=e.labelPosition||"top";let l;return l="bottom"===s?(i.height||0)-4:"center"===s?(i.height||0)/2:12,t.jsxs("g",{children:[t.jsx("line",{x1:o,y1:0,x2:o,y2:i.height||0,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.jsx("text",{x:o+4,y:l,fill:r,fontSize:12,fontWeight:"bold",children:e.label})]},"ann-"+n)}case"y-threshold":{const o=_e(null!=e.value?Object.assign(Object.assign({},e),{y:e.value}):e,i);if(null==o)return null;const r=e.color||"#f97316",s=e.labelPosition||"right";let l,a;return"left"===s?(l=4,a="start"):"center"===s?(l=(i.width||0)/2,a="middle"):(l=(i.width||0)-4,a="end"),t.jsxs("g",{children:[t.jsx("line",{x1:0,y1:o,x2:i.width||0,y2:o,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.jsx("text",{x:l,y:o-4,textAnchor:a,fill:r,fontSize:12,fontWeight:"bold",children:e.label})]},"ann-"+n)}case"enclose":{const o=(e.coordinates||[]).map(t=>({x:Me(Object.assign(Object.assign({},t),{type:"point"}),i),y:_e(Object.assign(Object.assign({},t),{type:"point"}),i),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>o.length)return null;const r=a.packEnclose(o),s=e.padding||10;return t.jsxs("g",{children:[t.jsx("circle",{cx:r.x,cy:r.y,r:r.r+s,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&t.jsx("text",{x:r.x,y:r.y-r.r-s-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:e.label})]},"ann-"+n)}case"rect-enclose":{const o=(e.coordinates||[]).map(t=>({x:Me(Object.assign(Object.assign({},t),{type:"point"}),i),y:_e(Object.assign(Object.assign({},t),{type:"point"}),i)})).filter(t=>null!=t.x&&null!=t.y);if(2>o.length)return null;const r=e.padding||10,s=o.map(t=>t.x),l=o.map(t=>t.y),a=Math.min(...s)-r,c=Math.max(...s)+r,u=Math.min(...l)-r,d=Math.max(...l)+r;return t.jsxs("g",{children:[t.jsx("rect",{x:a,y:u,width:c-a,height:d-u,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&t.jsx("text",{x:(a+c)/2,y:u-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:e.label})]},"ann-"+n)}case"highlight":{const o=i.data||[],r="function"==typeof e.filter?o.filter(e.filter):e.field&&null!=e.value?o.filter(t=>t[e.field]===e.value):[],s={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return t.jsx("g",{children:r.map((n,o)=>{const r=Me(n,i),l=_e(n,i);if(null==r||null==l)return null;const a="function"==typeof e.r?e.r(n):e.r||6,c="function"==typeof e.style?e.style(n):e.style||s;return t.jsx("circle",Object.assign({cx:r,cy:l,r:a},c),"hl-"+o)})},"ann-"+n)}case"bracket":{const o=Me(e,i),r=_e(e,i);return t.jsx(Se,{noteData:{x:null!=o?o:0,y:null!=r?r:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},"ann-"+n)}case"trend":{const s=i.data||[];if(2>s.length)return null;const a=i.xAccessor||"x",f=i.yAccessor||"y",g=s.map(t=>[t[a],t[f]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>g.length)return null;const y=null!==(r=null===(o=i.scales)||void 0===o?void 0:o.x)&&void 0!==r?r:null===(l=i.scales)||void 0===l?void 0:l.time,v=null!==(u=null===(c=i.scales)||void 0===c?void 0:c.y)&&void 0!==u?u:null===(d=i.scales)||void 0===d?void 0:d.value;if(!y||!v)return null;const m=e.method||"linear";let x;x="loess"===m?function(t,e=.3){const n=t.length;if(2>n)return t.slice();const i=t.slice().sort((t,e)=>t[0]-e[0]),o=i.map(t=>t[0]),r=i.map(t=>t[1]),s=Math.max(2,Math.ceil(e*n)),l=[];for(let t=0;n>t;t++){const e=o[t],i=o.map(t=>Math.abs(t-e)),a=i.slice().sort((t,e)=>t-e)[Math.min(s-1,n-1)]||1,c=[];for(let t=0;n>t;t++){const e=0===a?0:i[t]/a;c[t]=1>e?Math.pow(1-Math.pow(e,3),3):0}let u=0,d=0,h=0,f=0,g=0;for(let t=0;n>t;t++){const e=c[t];0!==e&&(u+=e,d+=e*o[t],h+=e*r[t],f+=e*o[t]*o[t],g+=e*o[t]*r[t])}if(0===u){l.push([e,r[t]]);continue}const y=u*f-d*d;if(1e-12>Math.abs(y))l.push([e,h/u]);else{const t=(u*g-d*h)/y;l.push([e,(h-t*d)/u+t*e])}}return l}(g,null!==(h=e.bandwidth)&&void 0!==h?h:.3):("polynomial"===m?p.default.polynomial(g,{order:e.order||2}):p.default.linear(g)).points;const b=x.map(([t,e])=>`${y(t)},${v(e)}`).join(" "),k=e.color||"#6366f1";return t.jsxs("g",{children:[t.jsx("polyline",{points:b,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.jsx("text",{x:y(x[x.length-1][0])+4,y:v(x[x.length-1][1])-4,fill:k,fontSize:11,children:e.label})]},"ann-"+n)}case"band":{const o=null!==(g=null===(f=i.scales)||void 0===f?void 0:f.y)&&void 0!==g?g:null===(y=i.scales)||void 0===y?void 0:y.value,r=null!==(v=null==o?void 0:o(e.y0))&&void 0!==v?v:0,s=null!==(m=null==o?void 0:o(e.y1))&&void 0!==m?m:i.height||0;return t.jsxs("g",{children:[t.jsx("rect",{x:0,y:Math.min(r,s),width:i.width||0,height:Math.abs(s-r),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&t.jsx("text",{x:(i.width||0)-4,y:Math.min(r,s)-4,textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,children:e.label})]},"ann-"+n)}case"envelope":{const o=i.data||[];if(2>o.length)return null;const r=i.xAccessor||"x",l=null!==(b=null===(x=i.scales)||void 0===x?void 0:x.x)&&void 0!==b?b:null===(k=i.scales)||void 0===k?void 0:k.time,a=null!==(A=null===(w=i.scales)||void 0===w?void 0:w.y)&&void 0!==A?A:null===(S=i.scales)||void 0===S?void 0:S.value;if(!l||!a)return null;const c=e.upperAccessor||"upperBounds",u=e.lowerAccessor||"lowerBounds",d=e.filter,h=o.filter(t=>null!=t[c]&&null!=t[u]&&!(d&&!d(t))).sort((t,e)=>t[r]-e[r]);if(2>h.length)return null;const f=Ce[i.curve||"linear"]||s.curveLinear,g=s.area().x(t=>l(t[r])).y0(t=>a(t[u])).y1(t=>a(t[c])).curve(f)(h);if(!g)return null;const y=e.fill||"#6366f1";return t.jsxs("g",{children:[t.jsx("path",{d:g,fill:y,fillOpacity:null!==(M=e.fillOpacity)&&void 0!==M?M:.15,stroke:"none"}),e.label&&h.length>0&&t.jsx("text",{x:l(h[h.length-1][r])+4,y:a(h[h.length-1][c])-4,fill:y,fontSize:11,children:e.label})]},"ann-"+n)}case"anomaly-band":{const o=i.data||[];if(2>o.length)return null;const r=i.yAccessor||"y",s=null!==(j=null===(_=i.scales)||void 0===_?void 0:_.x)&&void 0!==j?j:null===(P=i.scales)||void 0===P?void 0:P.time,l=null!==(E=null===(C=i.scales)||void 0===C?void 0:C.y)&&void 0!==E?E:null===(L=i.scales)||void 0===L?void 0:L.value;if(!s||!l)return null;const a=o.map(t=>t[r]).filter(t=>null!=t&&isFinite(t));if(2>a.length)return null;const c=a.reduce((t,e)=>t+e,0)/a.length,u=a.reduce((t,e)=>t+Math.pow(e-c,2),0)/a.length,d=Math.sqrt(u),h=null!==(O=e.threshold)&&void 0!==O?O:2,f=c-h*d,g=!1!==e.showBand,y=e.fill||"#6366f1",p=null!==(T=e.fillOpacity)&&void 0!==T?T:.1,v=e.anomalyColor||"#ef4444",m=null!==(D=e.anomalyRadius)&&void 0!==D?D:6,x=l(c+h*d),b=l(f),k=o.filter(t=>{const e=t[r];return null!=e&&Math.abs(e-c)>h*d});return t.jsxs("g",{children:[g&&t.jsx("rect",{x:0,y:Math.min(x,b),width:i.width||0,height:Math.abs(b-x),fill:y,fillOpacity:p}),k.map((e,n)=>{const o=Me(e,i),r=_e(e,i);return null==o||null==r?null:t.jsx("circle",{cx:o,cy:r,r:m,fill:v,fillOpacity:.7,stroke:v,strokeWidth:1.5},"anomaly-"+n)}),e.label&&t.jsx("text",{x:(i.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:y,fontSize:11,children:e.label})]},"ann-"+n)}case"forecast":{const o=i.data||[];if(3>o.length)return null;const r=i.xAccessor||"x",s=i.yAccessor||"y",l=null!==(I=null===(R=i.scales)||void 0===R?void 0:R.x)&&void 0!==I?I:null===($=i.scales)||void 0===$?void 0:$.time,a=null!==(W=null===(N=i.scales)||void 0===N?void 0:N.y)&&void 0!==W?W:null===(z=i.scales)||void 0===z?void 0:z.value;if(!l||!a)return null;const c=o.map(t=>[t[r],t[s]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>c.length)return null;let u;if("polynomial"===(e.method||"linear")){const t=p.default.polynomial(c,{order:e.order||2}).equation;u=e=>t.reduce((t,n,i)=>t+n*Math.pow(e,i),0)}else{const t=c.length;let e=0,n=0,i=0,o=0;for(const[t,r]of c)e+=t,n+=r,i+=t*t,o+=t*r;const r=t*i-e*e;if(1e-12>Math.abs(r))return null;const s=(t*o-e*n)/r,l=(n-s*e)/t;u=t=>l+s*t}const d=c.length,h=c.map(([t,e])=>e-u(t)).reduce((t,e)=>t+e*e,0),f=Math.sqrt(h/Math.max(d-2,1)),g=c.reduce((t,e)=>t+e[0],0)/d,y=c.reduce((t,e)=>t+Math.pow(e[0]-g,2),0),v=null!==(Y=e.confidence)&&void 0!==Y?Y:.95,m=.99>v?.95>v?.9>v?1:1.645:1.96:2.576,x=null!==(F=e.steps)&&void 0!==F?F:5,b=c[d-1][0],k=(b-c[0][0])/Math.max(d-1,1),w=[];for(let t=1;x>=t;t++)w.push(b+t*k);const A=[];for(const t of w){const e=u(t),n=f*Math.sqrt(1+1/d+(y>0?Math.pow(t-g,2)/y:0))*m;A.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const S=`M${A.map(t=>`${l(t.x)},${a(t.yUpper)}`).join(" L")} L${A.slice().reverse().map(t=>`${l(t.x)},${a(t.yLower)}`).join(" L")} Z`,M=A.map(t=>`${l(t.x)},${a(t.yCenter)}`).join(" "),_=`${l(b)},${a(u(b))}`,j=e.strokeColor||"#6366f1";return t.jsxs("g",{children:[t.jsx("path",{d:S,fill:e.fill||"#6366f1",fillOpacity:null!==(B=e.fillOpacity)&&void 0!==B?B:.15,stroke:"none"}),t.jsx("polyline",{points:`${_} ${M}`,fill:"none",stroke:j,strokeWidth:null!==(H=e.strokeWidth)&&void 0!==H?H:2,strokeDasharray:null!==(X=e.strokeDasharray)&&void 0!==X?X:"6,3"}),e.label&&A.length>0&&t.jsx("text",{x:l(A[A.length-1].x)+4,y:a(A[A.length-1].yCenter)-4,fill:j,fontSize:11,children:e.label})]},"ann-"+n)}case"widget":{let o=null,r=null;if(null!=e.px&&null!=e.py)o=e.px,r=e.py;else{const t=je(e,n,i);if(!t)return null;o=t.x,r=t.y}if(null==o||null==r)return null;if(!Pe(o,r,i))return null;const s=null!==(G=e.dx)&&void 0!==G?G:0,l=null!==(V=e.dy)&&void 0!==V?V:0,a=null!==(q=e.width)&&void 0!==q?q:32,c=null!==(U=e.height)&&void 0!==U?U:32,u=null!==(K=e.content)&&void 0!==K?K:t.jsx("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});return t.jsx("foreignObject",{x:o+s-a/2,y:r+l-c/2,width:a,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:t.jsx("div",{style:{width:a,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+n)}case"text":{const o=je(e,n,i);if(!o)return null;const{x:r,y:s}=o;return t.jsx("text",{x:r+(e.dx||0),y:s+(e.dy||0),fill:e.color||"var(--semiotic-text, #333)",fontSize:e.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label},"ann-text-"+n)}case"category-highlight":{const o=e.category;if(null==o)return null;const r=null===(Z=i.scales)||void 0===Z?void 0:Z.o,s=null===(Q=i.scales)||void 0===Q?void 0:Q.x,l=null===(J=i.scales)||void 0===J?void 0:J.y,a=(null==r?void 0:r.bandwidth)?r:(null==s?void 0:s.bandwidth)?s:(null==l?void 0:l.bandwidth)?l:null;if(!a)return null;const c=a(o);if(null==c)return null;const u=a.bandwidth(),d=e.color||"var(--semiotic-primary, #4589ff)",h=null!==(tt=e.opacity)&&void 0!==tt?tt:.15,f=e.label;return t.jsxs("g",(i.projection?"vertical"===i.projection:a===s)?{children:[t.jsx("rect",{x:c,y:0,width:u,height:i.height||0,fill:d,fillOpacity:h}),f&&t.jsx("text",{x:c+u/2,y:12,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold",children:f})]}:{children:[t.jsx("rect",{x:0,y:c,width:i.width||0,height:u,fill:d,fillOpacity:h}),f&&t.jsx("text",{x:12,y:c+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold",children:f})]},"ann-"+n)}default:return null}},n={scales:h?{x:h.x,y:h.y,time:h.x,value:h.y}:null,timeAxis:"x",xAccessor:R,yAccessor:I,width:r,height:l,data:$,frameType:"xy",pointNodes:N,curve:W,stickyPositionCache:q.current};return T.map((t,i)=>{if(D){const o=D(t,i,n);return null!=o?o:e(t,i,n)}return e(t,i,n)}).filter(Boolean)},[T,D,r,l,R,I,$,h,N,W]),Q=function(t){var n;const i=e.useSyncExternalStore(t?Ie:Ne,t?Re:We,t?Re:We);return t&&null!==(n=i.positions.get(t))&&void 0!==n?n:null}(F);return e.useEffect(()=>{if(!(null==Q?void 0:Q.locked)||!F)return;const t=t=>{"Escape"===t.key&&De(F)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[null==Q?void 0:Q.locked,F]),f||w||A||C||E||Z&&Z.length>0||k||H||Q?t.jsxs("svg",{role:"img",width:c,height:u,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[t.jsx("title",{children:"string"==typeof w?w:"XY Chart"}),t.jsx("desc",{children:"string"==typeof w?w+" — XY data visualization":"XY data visualization"}),t.jsxs("g",{transform:`translate(${d.left},${d.top})`,children:[k&&h&&(!z||Y)&&(()=>{var e,n;const i=ze(null===(e=null==g?void 0:g.find(t=>"bottom"===t.orient))||void 0===e?void 0:e.gridStyle),o=ze(null===(n=null==g?void 0:g.find(t=>"left"===t.orient))||void 0===n?void 0:n.gridStyle);return t.jsxs("g",{className:"stream-grid",children:[X.map((e,n)=>t.jsx("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:l,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i},"xgrid-"+n)),G.map((e,n)=>t.jsx("line",{x1:0,y1:e.pixel,x2:r,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"ygrid-"+n))]})})(),f&&h&&(()=>{const e=null==g?void 0:g.find(t=>"left"===t.orient),n=null==g?void 0:g.find(t=>"bottom"===t.orient),i=!e||!1!==e.baseline,o=!n||!1!==n.baseline,s=(null==e?void 0:e.jaggedBase)||!1,a=(null==n?void 0:n.jaggedBase)||!1,c=null==n?void 0:n.landmarkTicks,u=null==e?void 0:e.landmarkTicks,h="var(--semiotic-border, #ccc)",f="var(--semiotic-text-secondary, var(--semiotic-text, #666))",p="var(--semiotic-text, #333)",x=!!(null==n?void 0:n.autoRotate)&&X.length>1&&(()=>{const t=r/Math.max(X.length-1,1);return X.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:60),0)+8>t})();return t.jsxs("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[(!z||Y)&&o&&!a&&t.jsx("line",{x1:0,y1:l,x2:r,y2:l,stroke:h,strokeWidth:1}),(!z||Y)&&a&&t.jsx("path",{d:Ye("bottom",r,l),fill:"none",stroke:h,strokeWidth:1}),X.map((e,n)=>{const i=!!c&&("function"==typeof c?c(e.value,n):jt(e.value,n>0?X[n-1].value:void 0));return t.jsxs("g",{transform:`translate(${e.pixel},${l})`,children:[t.jsx("line",{y2:5,stroke:h,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?t.jsx("text",{y:x?10:18,textAnchor:x?"end":"middle",fontSize:i?11:10,fontWeight:i?600:400,fill:f,style:{userSelect:"none"},transform:x?"rotate(-45)":void 0,children:e.label}):t.jsx("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:t.jsx("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"},children:e.label})})]},"xtick-"+n)}),y&&t.jsx("text",{x:r/2,y:l+40,textAnchor:"middle",fontSize:12,fill:p,style:{userSelect:"none"},children:y}),(!z||Y)&&i&&!s&&t.jsx("line",{x1:0,y1:0,x2:0,y2:l,stroke:h,strokeWidth:1}),(!z||Y)&&s&&t.jsx("path",{d:Ye("left",r,l),fill:"none",stroke:h,strokeWidth:1}),G.map((e,n)=>{const i=!!u&&("function"==typeof u?u(e.value,n):jt(e.value,n>0?G[n-1].value:void 0));return t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:h,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:i?11:10,fontWeight:i?600:400,fill:f,style:{userSelect:"none"},children:e.label}):t.jsx("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:t.jsx("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"},children:e.label})})]},"ytick-"+n)}),(()=>{const n=(null==e?void 0:e.label)||v;return n?t.jsx("text",{x:15-d.left,y:l/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(-90, ${15-d.left}, ${l/2})`,style:{userSelect:"none"},children:n}):null})(),(()=>{const e=null==g?void 0:g.find(t=>"right"===t.orient);if(!e||0===V.length)return null;const n=e.landmarkTicks,i=e.label||m;return t.jsxs(t.Fragment,{children:[!1!==e.baseline&&t.jsx("line",{x1:r,y1:0,x2:r,y2:l,stroke:h,strokeWidth:1}),V.map((e,i)=>{const o=!!n&&("function"==typeof n?n(e.value,i):jt(e.value,i>0?V[i-1].value:void 0));return t.jsxs("g",{transform:`translate(${r},${e.pixel})`,children:[t.jsx("line",{x2:5,stroke:h,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?t.jsx("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:f,style:{userSelect:"none"},children:e.label}):t.jsx("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:t.jsx("div",{style:{textAlign:"left",fontSize:10,userSelect:"none"},children:e.label})})]},"ytick-r-"+i)}),i&&t.jsx("text",{x:r+d.right-15,y:l/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(90, ${r+d.right-15}, ${l/2})`,style:{userSelect:"none"},children:i})]})})()]})})(),Z,E&&h&&L&&O&&t.jsxs(t.Fragment,{children:[E.top&&t.jsx("g",{transform:"translate(0, 0)",children:t.jsx(ve,{orient:"top",config:pe(E.top),values:L,scale:h.x,size:d.top,length:r})}),E.bottom&&t.jsx("g",{transform:`translate(0, ${l})`,children:t.jsx(ve,{orient:"bottom",config:pe(E.bottom),values:L,scale:h.x,size:d.bottom,length:r})}),E.left&&t.jsx("g",{transform:"translate(0, 0)",children:t.jsx(ve,{orient:"left",config:pe(E.left),values:O,scale:h.y,size:d.left,length:l})}),E.right&&t.jsx("g",{transform:`translate(${r}, 0)`,children:t.jsx(ve,{orient:"right",config:pe(E.right),values:O,scale:h.y,size:d.right,length:l})})]}),C,Q&&Q.sourceId!==B&&(null==h?void 0:h.x)&&(()=>{const e=h.x(Q.xValue);if(null==e||0>e||e>r)return null;const n=Q.locked;return t.jsx("line",{x1:e,y1:0,x2:e,y2:l,stroke:n?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:n?1.5:1,strokeDasharray:n?"6,3":"4,4",pointerEvents:"none"})})(),H]}),w&&t.jsx("text",{x:c/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"},children:"string"==typeof w?w:null}),ye({legend:A,totalWidth:c,totalHeight:u,margin:d,legendPosition:P,title:w,legendHoverBehavior:S,legendClickBehavior:M,legendHighlightedCategory:_,legendIsolatedCategories:j})]}):null}const Ge={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function Ve(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}const qe="undefined"==typeof window||"undefined"==typeof document,Ue="undefined"!=typeof window?e.useLayoutEffect:e.useEffect;function Ke(){const[t,n]=e.useState(!1);return Ue(()=>{n(!0)},[]),t}const Ze=()=>()=>{},Qe=()=>!1,Je=()=>!0;function tn(){const t=e.useSyncExternalStore(Ze,Qe,Je);return e.useRef(t).current}function en(t){const{hydrated:n,wasHydratingFromSSR:i,storeRef:o,dirtyRef:r,renderFnRef:s,cleanup:l}=t;Ue(()=>{var t,e;n&&i&&(null===(e=null===(t=o.current)||void 0===t?void 0:t.cancelIntroAnimation)||void 0===e||e.call(t)),r.current=!0,s.current()},[n,i]);const a=e.useRef(l);a.current=l,e.useEffect(()=>()=>{var t;return null===(t=a.current)||void 0===t?void 0:t.call(a)},[])}function nn(t){const n=e.useRef(t);return function(t,e){if(Object.is(t,e))return!0;if(Array.isArray(t)&&Array.isArray(e))return rn(t,e);if(!sn(t)||!sn(e))return!1;const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const i of n){if(!Object.prototype.hasOwnProperty.call(e,i))return!1;const n=t[i],o=e[i];if(!Object.is(n,o))if(Array.isArray(n)&&Array.isArray(o)){if(!rn(n,o))return!1}else{if(!sn(n)||!sn(o))return!1;if(!on(n,o))return!1}}return!0}(n.current,t)||(n.current=t),n.current}function on(t,e){const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const i of n){if(!Object.prototype.hasOwnProperty.call(e,i))return!1;if(!Object.is(t[i],e[i]))return!1}return!0}function rn(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 sn(t){if(null===t||"object"!=typeof t)return!1;if(Array.isArray(t))return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}const ln=y.createContext(null);function an(){return y.useContext(ln)}const cn={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function un(t,e){if(!t||0===t.length)return e+", empty";const n={};for(const e of t)n[e.type]=(n[e.type]||0)+1;const i=[],o={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),i=r.indexOf(e);return(-1===n?999:n)-(-1===i?999:i)});for(const t of s)i.push(`${n[t]} ${o[t]||t}`);return`${e}, ${i.join(", ")}`}function dn(t,e,n){const i=[];return t>0&&i.push(t+" nodes"),e>0&&i.push(e+" edges"),0===i.length?n+", empty":`${n}, ${i.join(", ")}`}const hn=t=>{if(null==t)return"";const e=Math.round(100*t)/100;return Number.isNaN(e)?"":e+""},fn={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid 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-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},gn={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},yn={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},pn={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},vn={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},mn={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},xn={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function bn({scene:e,chartType:n,tableId:i,chartTitle:o}){var r;const[s,l]=y.useState(!1),a=an(),c=null!==(r=null==a?void 0:a.visible)&&void 0!==r&&r,u=s||c,d=y.useRef(null),h=o?"Data summary for "+o:i?`Data summary for ${n} ${i}`:"Data summary for "+n,f=y.useCallback(()=>{s||c||l(!0)},[s,c]),g=y.useCallback(t=>{var e;c||(null===(e=d.current)||void 0===e?void 0:e.contains(t.relatedTarget))||l(!1)},[c]);if(!e||0===e.length)return i?t.jsx("span",{id:i,tabIndex:-1,style:cn}):null;if(!u)return t.jsx("div",{id:i,tabIndex:-1,onFocus:f,style:cn,role:"region","aria-label":h,children:t.jsxs("button",{type:"button",onClick:()=>l(!0),children:["View data summary (",e.length," elements)"]})});const p=function(t){var e,n,i,o,r,s,l,a,c,u,d,h,f,g,y,p,v,m,x,b,k,w,A,S,M;const _=[];if(!Array.isArray(t))return _;for(const j of t)if(j&&"object"==typeof j)try{switch(j.type){case"point":_.push({label:"Point",values:{x:j.x,y:j.y}});break;case"line":{const t=j.path,e=Array.isArray(j.datum)?j.datum:[];if(!Array.isArray(t))break;for(let n=0;t.length>n&&e.length>n;n++){const e=t[n];Array.isArray(e)&&_.push({label:"Line point",values:{x:e[0],y:e[1]}})}break}case"area":{const t=j.topPath,e=Array.isArray(j.datum)?j.datum:[];if(!Array.isArray(t))break;for(let n=0;t.length>n&&e.length>n;n++){const e=t[n];Array.isArray(e)&&_.push({label:"Area point",values:{x:e[0],y:e[1]}})}break}case"rect":{const t=null!=j.datum&&"object"==typeof j.datum?j.datum:{},r=null!==(n=null!==(e=t.category)&&void 0!==e?e:j.group)&&void 0!==n?n:"",s=null!==(o=null!==(i=t.value)&&void 0!==i?i:t.__aggregateValue)&&void 0!==o?o:t.total;_.push({label:"Bar",values:{category:r,value:null!=s?s:""}});break}case"heatcell":_.push({label:"Cell",values:{x:j.x,y:j.y,value:j.value}});break;case"wedge":_.push({label:"Wedge",values:{category:null!==(a=null!==(s=null===(r=j.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:null===(l=j.datum)||void 0===l?void 0:l.label)&&void 0!==a?a:"",value:null!==(u=null===(c=j.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":_.push({label:"Node",values:{id:null!==(h=null===(d=j.datum)||void 0===d?void 0:d.id)&&void 0!==h?h:"",x:null!==(f=j.cx)&&void 0!==f?f:j.x,y:null!==(g=j.cy)&&void 0!==g?g:j.y}});break;case"arc":_.push({label:"Arc",values:{id:null!==(p=null===(y=j.datum)||void 0===y?void 0:y.id)&&void 0!==p?p:"",x:null!==(v=j.cx)&&void 0!==v?v:j.x,y:null!==(m=j.cy)&&void 0!==m?m:j.y}});break;case"candlestick":_.push({label:"Candlestick",values:{x:j.x,open:j.open,high:j.high,low:j.low,close:j.close}});break;case"geoarea":_.push({label:"Region",values:{name:null!==(A=null!==(k=null===(b=null===(x=j.datum)||void 0===x?void 0:x.properties)||void 0===b?void 0:b.name)&&void 0!==k?k:null===(w=j.datum)||void 0===w?void 0:w.name)&&void 0!==A?A:"",value:null!==(M=null===(S=j.datum)||void 0===S?void 0:S.value)&&void 0!==M?M:""}})}}catch(t){}return _}(e),v=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 i of e){const e=[],o=new Set;for(const n of t){if(!n||!n.values)continue;const t=n.values[i];null!=t&&""!==t&&("number"==typeof t&&!Number.isNaN(t)&&Number.isFinite(t)?e.push(t):"number"==typeof t||"object"!=typeof t&&"function"!=typeof t&&o.add(t+""))}if(e.length>0){let t=e[0],o=e[0],r=0;for(const n of e)t>n&&(t=n),n>o&&(o=n),r+=n;n.push({name:i,count:e.length,numeric:!0,min:t,max:o,mean:r/e.length})}else if(o.size>0){const t=Array.from(o);n.push({name:i,count:t.length,numeric:!1,uniqueValues:t.slice(0,5)})}}return n}(p),m=function(t,e){const n=[t+" data points."];for(const t of e)if(t.numeric)n.push(`${t.name}: ${hn(t.min)} to ${hn(t.max)}, mean ${hn(t.mean)}.`);else{const e=t.uniqueValues,i=e.length>3?`${e.slice(0,3).join(", ")}… (${t.count} unique)`:e.join(", ");n.push(`${t.name}: ${i}.`)}return n.join(" ")}(p.length,v),x=p.slice(0,5),b=new Set;for(const t of x)for(const e of Object.keys(t.values))b.add(e);const k=Array.from(b);return t.jsxs("div",{ref:d,id:i,tabIndex:-1,onBlur:g,style:fn,role:"region","aria-label":h,children:[t.jsx("button",{type:"button",onClick:()=>{c&&a&&a.setVisible(!1),l(!1)},"aria-label":"Close data summary",style:yn,children:"×"}),t.jsx("div",{role:"note",style:gn,children:m}),t.jsxs("table",{role:"table","aria-label":"Sample data for "+n,style:pn,children:[t.jsxs("caption",{style:xn,children:["First ",x.length," of ",p.length," data points"]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{style:vn,children:"type"}),k.map(e=>t.jsx("th",{style:vn,children:e},e))]})}),t.jsx("tbody",{children:x.map((e,n)=>t.jsxs("tr",{children:[t.jsx("td",{style:mn,children:e.label}),k.map(n=>{return t.jsx("td",{style:mn,children:(i=e.values[n],null==i||""===i?"—":"number"==typeof i?Number.isNaN(i)?"—":hn(i):"boolean"==typeof i?i?"true":"false":"object"==typeof i?"—":i+"")},n);var i})]},n))})]})]})}function kn({nodes:e,edges:n,chartType:i,tableId:o,chartTitle:r}){var s,l,a,c,u,d,h,f,g,p,v,m,x,b;const[k,w]=y.useState(!1),A=an(),S=null!==(s=null==A?void 0:A.visible)&&void 0!==s&&s,M=k||S,_=r?"Data summary for "+r:o?`Data summary for ${i} ${o}`:"Data summary for "+i,j=y.useRef(null),P=y.useCallback(()=>{k||S||w(!0)},[k,S]),C=y.useCallback(t=>{var e;S||(null===(e=j.current)||void 0===e?void 0:e.contains(t.relatedTarget))||w(!1)},[S]);if(!e||0===e.length)return o?t.jsx("span",{id:o,tabIndex:-1,style:cn}):null;if(!M)return t.jsx("div",{id:o,tabIndex:-1,onFocus:P,style:cn,role:"region","aria-label":_,children:t.jsxs("button",{type:"button",onClick:()=>w(!0),children:["View data summary (",e.length," nodes, ",n.length," edges)"]})});const E=Array.isArray(e)?e:[],L=Array.isArray(n)?n:[],O=new Map,T=new Map,D=new Map,R=new Map;for(const t of L){if(!t||"object"!=typeof t)continue;const e=null!==(l=t.datum)&&void 0!==l?l:t,n="object"==typeof e.source?null===(a=e.source)||void 0===a?void 0:a.id:e.source,i="object"==typeof e.target?null===(c=e.target)||void 0===c?void 0:c.id:e.target,o="number"==typeof e.value&&Number.isFinite(e.value)?e.value:0;if(null!=n&&""!==n){const t=n+"";T.set(t,(null!==(u=T.get(t))&&void 0!==u?u:0)+1),R.set(t,(null!==(d=R.get(t))&&void 0!==d?d:0)+o)}if(null!=i&&""!==i){const t=i+"";O.set(t,(null!==(h=O.get(t))&&void 0!==h?h:0)+1),D.set(t,(null!==(f=D.get(t))&&void 0!==f?f:0)+o)}}const I=[];for(let t=0;E.length>t;t++){const e=E[t];if(!e||"object"!=typeof e)continue;const n=null!==(p=null===(g=e.datum)||void 0===g?void 0:g.id)&&void 0!==p?p:e.id,i=null!=n?n+"":"node-"+t,o=null!==(v=O.get(i))&&void 0!==v?v:0,r=null!==(m=T.get(i))&&void 0!==m?m:0,s=null!==(x=D.get(i))&&void 0!==x?x:0,l=null!==(b=R.get(i))&&void 0!==b?b:0;I.push({id:i,degree:o+r,inDeg:o,outDeg:r,wDegree:s+l,wInDeg:s,wOutDeg:l})}I.sort((t,e)=>e.degree-t.degree);let $=0,N=0;if(I.length>0){let t=0;for(const e of I)t+=e.degree,e.degree>N&&(N=e.degree);$=t/I.length}const W=L.some(t=>{var e;const n=null!==(e=null==t?void 0:t.datum)&&void 0!==e?e:t;return"number"==typeof(null==n?void 0:n.value)&&Number.isFinite(n.value)}),z=[`${I.length} nodes, ${L.length} edges.`];I.length>0&&z.push(`Mean degree: ${hn($)}, max degree: ${N}.`);const Y=I.slice(0,5);return t.jsxs("div",{ref:j,id:o,tabIndex:-1,onBlur:C,style:fn,role:"region","aria-label":_,children:[t.jsx("button",{type:"button",onClick:()=>{S&&A&&A.setVisible(!1),w(!1)},"aria-label":"Close data summary",style:yn,children:"×"}),t.jsx("div",{role:"note",style:gn,children:z.join(" ")}),t.jsxs("table",{role:"table","aria-label":"Node degree summary for "+i,style:pn,children:[t.jsxs("caption",{style:xn,children:["Top ",Y.length," of ",I.length," nodes by degree"]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{style:vn,children:"id"}),t.jsx("th",{style:vn,children:"degree"}),t.jsx("th",{style:vn,children:"in"}),t.jsx("th",{style:vn,children:"out"}),W&&t.jsx("th",{style:vn,children:"w. degree"}),W&&t.jsx("th",{style:vn,children:"w. in"}),W&&t.jsx("th",{style:vn,children:"w. out"})]})}),t.jsx("tbody",{children:Y.map((e,n)=>t.jsxs("tr",{children:[t.jsx("td",{style:mn,children:e.id}),t.jsx("td",{style:mn,children:e.degree}),t.jsx("td",{style:mn,children:e.inDeg}),t.jsx("td",{style:mn,children:e.outDeg}),W&&t.jsx("td",{style:mn,children:hn(e.wDegree)}),W&&t.jsx("td",{style:mn,children:hn(e.wInDeg)}),W&&t.jsx("td",{style:mn,children:hn(e.wOutDeg)})]},n))})]})]})}function wn({summary:e}){return e?t.jsx("div",{role:"note",style:cn,children:e}):null}function An({tableId:e}){return t.jsx("a",{href:"#"+e,style:cn,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:t=>{Object.assign(t.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:t=>{const e=t.currentTarget;e.removeAttribute("style"),Object.assign(e.style,cn)},children:"Skip to data table"})}function Sn({hoverPoint:e}){let n="";if(e){const t=e.data||e;n="object"==typeof t?"Focused on data point: "+Object.entries(t).filter(([,t])=>"object"!=typeof t&&"function"!=typeof t).map(([t,e])=>`${t}: ${e}`).join(", "):"Focused on data point: "+t}return t.jsx("div",{"aria-live":"polite","aria-atomic":"true",style:cn,children:n})}const Mn="var(--semiotic-focus, #005fcc)";function _n({active:e,hoverPoint:n,margin:i,size:o,shape:r="circle",width:s,height:l}){if(!e||!n)return null;const a=n.x+i.left,c=n.y+i.top;let u;if("rect"===r&&null!=s&&null!=l){const e=Math.max(s,4),n=Math.max(l,4);u=t.jsx("rect",{x:a-e/2-3,y:c-n/2-3,width:e+6,height:n+6,rx:3,fill:"none",stroke:Mn,strokeWidth:2,strokeDasharray:"4,2"})}else u=t.jsx("circle","wedge"===r?{cx:a,cy:c,r:12,fill:"none",stroke:Mn,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:a,cy:c,r:8,fill:"none",stroke:Mn,strokeWidth:2,strokeDasharray:"4,2"});return t.jsx("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}function jn({x:e,y:n,containerWidth:i,containerHeight:o,margin:r,children:s,className:l="stream-frame-tooltip",zIndex:a=1}){const c=y.useRef(null),[u,d]=y.useState(null);y.useLayoutEffect(()=>{const t=c.current;if(!t)return;const e=t.getBoundingClientRect();d(t=>t&&t.width===e.width&&t.height===e.height?t:{width:e.width,height:e.height})},[s,l,i,o]);let h;return h=u?`translate(${u.width+12>i-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>o-n?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*i?"calc(-100% - 12px)":"12px"}, ${.3*o>n?"4px":"calc(-100% - 4px)"})`,t.jsx("div",{ref:c,className:l,style:{position:"absolute",left:r.left+e,top:r.top+n,transform:h,pointerEvents:"none",zIndex:a,width:"max-content"},children:s})}const Pn="undefined"==typeof window?e.useEffect:e.useLayoutEffect;function Cn(t,e,n){return"function"==typeof t?t({size:e,margin:n}):t}function En(t){const n=function(){const[t,n]=e.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return e.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const t=window.matchMedia("(prefers-reduced-motion: reduce)");return n(t.matches),function(t,e){return"function"==typeof t.addEventListener?(t.addEventListener("change",e),()=>t.removeEventListener("change",e)):(t.addListener(e),()=>t.removeListener(e))}(t,t=>n(t.matches))},[]),t}(),i=e.useRef(n);i.current=n;const[o,r]=function(t,n,i){const o=e.useRef(null),[r,s]=e.useState(null);return e.useEffect(()=>{if(!n&&!i)return;const t=o.current;if(!t)return;const e=new ResizeObserver(t=>{for(const e of t){const{width:t,height:n}=e.contentRect;s(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n})}});return e.observe(t),()=>e.disconnect()},[n,i]),[o,[n&&r?r.w:t[0],i&&r?r.h:t[1]]]}(t.sizeProp,t.responsiveWidth,t.responsiveHeight),s=e.useMemo(()=>Object.assign(Object.assign({},t.marginDefault),t.userMargin),[t.marginDefault,t.userMargin]),l=r[0]-s.left-s.right,a=r[1]-s.top-s.bottom,c=Cn(t.foregroundGraphics,r,s),u=Cn(t.backgroundGraphics,r,s),d=T(t=>t.theme),{transition:h,introEnabled:f}=function(t,e){var n,i;if(!1===t)return{transition:void 0,introEnabled:!1};const o="undefined"!=typeof window&&(null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-reduced-motion: reduce)").matches);return{transition:t?!0===t?{duration:300}:{duration:null!==(i=t.duration)&&void 0!==i?i:300,easing:"linear"===t.easing?"linear":"ease-out"}:e,introEnabled:!(o||!t||!0!==t&&!1===t.intro)}}(t.animate,t.transitionProp),g="semiotic-table-"+y.useId(),p=e.useRef(0),v=e.useRef(()=>{}),m=e.useCallback(()=>{p.current||(p.current=requestAnimationFrame(()=>v.current()))},[]);e.useEffect(()=>()=>{p.current&&(cancelAnimationFrame(p.current),p.current=0)},[]);const x=e.useRef(()=>{}),b=e.useRef(()=>{}),k=e.useRef(null),w=e.useRef(0),A=e.useCallback(()=>{w.current=0;const t=k.current;k.current=null,t&&x.current(t)},[]),S=e.useCallback(t=>{k.current={clientX:t.clientX,clientY:t.clientY},0===w.current&&(w.current=requestAnimationFrame(A))},[A]),M=e.useCallback(()=>{k.current=null,0!==w.current&&(cancelAnimationFrame(w.current),w.current=0),b.current()},[]);e.useEffect(()=>()=>{k.current=null,0!==w.current&&(cancelAnimationFrame(w.current),w.current=0)},[]);const _=t.themeDirtyRef;return Pn(()=>{_&&(Lt++,_.current=!0,m())},[d,m,_]),{reducedMotion:n,reducedMotionRef:i,responsiveRef:o,size:r,margin:s,adjustedWidth:l,adjustedHeight:a,resolvedForeground:c,resolvedBackground:u,currentTheme:d,transition:h,introEnabled:f,tableId:g,rafRef:p,renderFnRef:v,scheduleRender:m,hoverHandlerRef:x,hoverLeaveRef:b,onPointerMove:S,onPointerLeave:M}}function Ln(t,e,n,i){const o=t.getContext("2d");if(!o)return null;const r=e[0]*i,s=e[1]*i,l=e[0]+"px",a=e[1]+"px";return t.style.width!==l&&(t.style.width=l),t.style.height!==a&&(t.style.height=a),t.width===r&&t.height===s||(t.width=r,t.height=s),o.setTransform(i,0,0,i,0,0),o.translate(n.left,n.top),o}function On(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function Tn(t,e,n){let i=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(i=n.color):t>n.value&&(i=n.color);return i}function Dn(t,e,n,i,o,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],i=e[t][1]-e[t-1][1];s.push(s[t-1]+Math.sqrt(n*n+i*i))}const l=s[s.length-1];if(0===l)return;const a=Math.min(.2*l,40);t.strokeStyle=n,t.lineWidth=i,t.lineCap=r;for(let n=0;e.length-1>n;n++){const i=(s[n]+s[n+1])/2;let r=o;a>i&&(r*=i/a),a>l-i&&(r*=(l-i)/a),t.globalAlpha=Math.max(0,r),t.beginPath(),t.moveTo(e[n][0],e[n][1]),t.lineTo(e[n+1][0],e[n+1][1]),t.stroke()}}const Rn=(t,e,n,i)=>{var o,r;const l=e.filter(t=>"line"===t.type);for(const a of l){if(2>a.path.length)continue;const c=a._introClipFraction;void 0!==c&&1>c&&(t.save(),t.beginPath(),t.rect(0,0,i.width*c,i.height),t.clip());const u=a.style.stroke||"#007bff",d=It(t,u)||u,h=a.style.strokeWidth||2,f=a.colorThresholds,g=a.rawValues;if(t.setLineDash(a.style.strokeDasharray?a.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=a.style.opacity&&(t.globalAlpha=a.style.opacity),t.lineWidth=h,t.lineCap=a.style.strokeLinecap||"butt",a.style._edgeFade){const m=null!==(o=a.style.opacity)&&void 0!==o?o:1;Dn(t,a.path,d,h,m,a.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const y=$t(a.curve),p=f&&f.length>0&&g&&g.length===a.path.length,v=a._decayOpacities;if(v&&v.length===a.path.length&&!p){t.strokeStyle=d;const x=null!==(r=a.style.opacity)&&void 0!==r?r:1;for(let b=0;a.path.length-1>b;b++)t.globalAlpha=.5*(v[b]+v[b+1])*x,t.beginPath(),t.moveTo(a.path[b][0],a.path[b][1]),t.lineTo(a.path[b+1][0],a.path[b+1][1]),t.stroke()}else if(p){let k=null,w=null,A=null,S=null,M=!1;function _(e,n,i){t.beginPath(),t.strokeStyle=e,t.moveTo(n,i),M=!0}function j(){M&&(t.stroke(),M=!1)}for(let P=0;a.path.length>P;P++){const[C,E]=a.path[P],L=g[P],O=Tn(L,f,d);if(null!==k&&null!==S&&null!==A){if(O===S)t.lineTo(C,E);else{const T=[];for(const D of f){const R=D.value;(A>R||R>L)&&(R>A||L>R)||A===R||L===R||T.push({t:(R-A)/(L-A)})}T.sort((t,e)=>t.t-e.t);for(const I of T){const $=k+(C-k)*I.t,N=w+(E-w)*I.t,W=Tn(A+(L-A)*Math.min(I.t+1e-4,1),f,d);t.lineTo($,N),j(),_(W,$,N)}t.lineTo(C,E)}k=C,w=E,A=L,S=O}else _(O,C,E),k=C,w=E,A=L,S=O}j()}else{t.beginPath();const z=a.strokeGradient&&a.path.length>=2?zt(t,a.strokeGradient,a.path[0][0],0,a.path[a.path.length-1][0],0):null;if(t.strokeStyle=z||d,y)s.line().x(t=>t[0]).y(t=>t[1]).curve(y).context(t)(a.path);else{const[Y,F]=a.path[0];t.moveTo(Y,F);for(let B=1;a.path.length>B;B++)t.lineTo(a.path[B][0],a.path[B][1])}t.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=a.style.fillOpacity,t.fillStyle=Nt(t,a.style.fill,a.style.fill),y&&!p)s.line().x(t=>t[0]).y(t=>t[1]).curve(y).context(t)(a.path);else{const[X,G]=a.path[0];t.moveTo(X,G);for(let V=1;a.path.length>V;V++)t.lineTo(a.path[V][0],a.path[V][1])}const H=a.path[0][0];t.lineTo(a.path[a.path.length-1][0],i.height),t.lineTo(H,i.height),t.closePath(),t.fill()}void 0!==c&&1>c&&t.restore(),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}};function In(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function $n(t,e,n=.3){In(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 Nn(t,e,n=.6){var i,o,r,s,l;if(!In(e))return;const a=null!==(i=e._pulseGlowRadius)&&void 0!==i?i:4,c=e.r+a*e._pulseIntensity,u=null!==(r=null!==(o=e.cx)&&void 0!==o?o:e.x)&&void 0!==r?r:0,d=null!==(l=null!==(s=e.cy)&&void 0!==s?s:e.y)&&void 0!==l?l:0;t.beginPath(),t.arc(u,d,c,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=e._pulseIntensity*n,t.stroke()}function Wn(t,e,n,i=.35){In(e)&&(t.globalAlpha=e._pulseIntensity*i,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill())}function zn(t,e){const n=$t(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 i=s.area().x(t=>t[0]).y0((t,n)=>e.bottomPath[n][1]).y1(t=>t[1]).curve(n).context(t);t.beginPath(),i(e.topPath)}}const Yn=(t,e,n,i)=>{var o,r,l;const a=e.filter(t=>"area"===t.type);for(const e of a){if(2>e.topPath.length)continue;let n=!1;e.clipRect&&(t.save(),t.beginPath(),t.rect(e.clipRect.x,e.clipRect.y,e.clipRect.width,e.clipRect.height),t.clip(),n=!0);const a=e._introClipFraction;void 0!==a&&1>a&&(t.save(),t.beginPath(),t.rect(0,0,i.width*a,i.height),t.clip());const c=e.style.fill||"#4e79a7",u=e._decayOpacities;if(u&&u.length===e.topPath.length){const n=null!==(o=e.style.fillOpacity)&&void 0!==o?o:.7;t.fillStyle=c;for(let i=0;e.topPath.length-1>i;i++)t.globalAlpha=.5*(u[i]+u[i+1])*n,t.beginPath(),t.moveTo(e.topPath[i][0],e.topPath[i][1]),t.lineTo(e.topPath[i+1][0],e.topPath[i+1][1]),t.lineTo(e.bottomPath[i+1][0],e.bottomPath[i+1][1]),t.lineTo(e.bottomPath[i][0],e.bottomPath[i][1]),t.closePath(),t.fill();if(e.style.stroke&&"none"!==e.style.stroke){t.strokeStyle=It(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*(u[n]+u[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 d=null!==(r=e.style.opacity)&&void 0!==r?r:1;if(zn(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 i=-1/0;for(const t of e.bottomPath)t[1]>i&&(i=t[1]);const o=Wt(t,e.fillGradient,"string"==typeof c?c:"#4e79a7",0,n,0,i);t.fillStyle=o||c,t.globalAlpha=d}else{const n=null!==(l=e.style.fillOpacity)&&void 0!==l?l:.7;t.globalAlpha=n*d,t.fillStyle=c}if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(zn(t,e),Wn(t,e)),e.style.stroke&&"none"!==e.style.stroke){t.globalAlpha=d;const n=e.strokeGradient&&e.topPath.length>=2?zt(t,e.strokeGradient,e.topPath[0][0],0,e.topPath[e.topPath.length-1][0],0):null;t.strokeStyle=n||It(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);const i=$t(e.curve);if(t.beginPath(),i)s.line().x(t=>t[0]).y(t=>t[1]).curve(i).context(t)(e.topPath);else{t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1])}t.stroke()}void 0!==a&&1>a&&t.restore(),n&&t.restore(),t.globalAlpha=1}},Fn=(t,e,n,i)=>{var o;const r=e.filter(t=>"point"===t.type);if(0!==r.length){t.save();try{for(const e of r){t.beginPath(),t.arc(e.x,e.y,e.r,0,2*Math.PI);const n=null!==(o=e.style.opacity)&&void 0!==o?o:e.style.fillOpacity;null!=n&&(t.globalAlpha=n),t.fillStyle=Nt(t,e.style.fill,"#4e79a7"),t.fill(),e.style.stroke&&(t.strokeStyle=Nt(t,e.style.stroke,e.style.stroke),t.lineWidth=e.style.strokeWidth||1,t.stroke()),Nn(t,e),t.globalAlpha=1}}finally{t.restore()}}};function Bn(t){switch(t.roundedEdge){case"bottom":return{x0:t.x,y0:t.y+t.h,x1:t.x,y1:t.y};case"right":return{x0:t.x+t.w,y0:t.y,x1:t.x,y1:t.y};case"left":return{x0:t.x,y0:t.y,x1:t.x+t.w,y1:t.y};default:return{x0:t.x,y0:t.y,x1:t.x,y1:t.y+t.h}}}const Hn=(t,e,n,i)=>{const o=e.filter(t=>"rect"===t.type);for(const e of o){if(null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon)Xn(t,e);else if(e.roundedTop&&e.roundedTop>0){const n=Nt(t,e.style.fill,It(t,"var(--semiotic-primary, #007bff)")),i=Bn(e),o=e.fillGradient&&"string"==typeof n?Wt(t,e.fillGradient,n,i.x0,i.y0,i.x1,i.y1):null;t.fillStyle=o||n;const r=Math.min(e.roundedTop,e.w/2,e.h/2);t.beginPath();const{x:s,y:l,w:a,h:c}=e;switch(e.roundedEdge){case"right":t.moveTo(s,l),t.lineTo(s+a-r,l),t.arcTo(s+a,l,s+a,l+r,r),t.lineTo(s+a,l+c-r),t.arcTo(s+a,l+c,s+a-r,l+c,r),t.lineTo(s,l+c);break;case"left":t.moveTo(s+a,l),t.lineTo(s+r,l),t.arcTo(s,l,s,l+r,r),t.lineTo(s,l+c-r),t.arcTo(s,l+c,s+r,l+c,r),t.lineTo(s+a,l+c);break;case"bottom":t.moveTo(s,l),t.lineTo(s+a,l),t.lineTo(s+a,l+c-r),t.arcTo(s+a,l+c,s+a-r,l+c,r),t.lineTo(s+r,l+c),t.arcTo(s,l+c,s,l+c-r,r);break;default:t.moveTo(s,l+c),t.lineTo(s,l+r),t.arcTo(s,l,s+r,l,r),t.lineTo(s+a-r,l),t.arcTo(s+a,l,s+a,l+r,r),t.lineTo(s+a,l+c)}t.closePath(),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=It(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else{const n=Nt(t,e.style.fill,It(t,"var(--semiotic-primary, #007bff)")),i=Bn(e),o=e.fillGradient&&"string"==typeof n?Wt(t,e.fillGradient,n,i.x0,i.y0,i.x1,i.y1):null;t.fillStyle=o||n,t.fillRect(e.x,e.y,e.w,e.h),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=It(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))}$n(t,e),t.globalAlpha=1}};function Xn(t,e){const n=e.style.icon,i=e.style.iconPadding||2,o=Math.min(e.w,e.h)-i;if(0>=o)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=o+i,s=e.x+(e.w-o)/2;for(let i=e.y+e.h-o;i>=e.y-o;i-=r)t.drawImage(n,s,i,o,o)}else{const r=o+i,s=e.y+(e.h-o)/2;for(let i=e.x;e.x+e.w>i;i+=r)t.drawImage(n,i,s,o,o)}t.restore()}function Gn(t,e,n,i){return Object.assign({data:t,x:e,y:n,__semioticHoverData:!0},i)}function Vn(t){const[e,n,i]=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*i>128?"#000":"#fff"}function qn(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}const Un=(t,e,n,i)=>{const o=e.filter(t=>"heatcell"===t.type);t.save();try{for(const e of o){const n=e.style;if(null!=(null==n?void 0:n.opacity)&&(t.globalAlpha=n.opacity),t.fillStyle=e.fill,t.fillRect(e.x,e.y,e.w,e.h),t.strokeStyle=It(t,"var(--semiotic-surface, #fff)"),t.lineWidth=1,t.strokeRect(e.x,e.y,e.w,e.h),$n(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):qn(e.value),i=Math.max(10,Math.min(16,.3*Math.min(e.w,e.h))),o=e.x+e.w/2,r=e.y+e.h/2;t.fillStyle=Vn(e.fill),t.font=i+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,o,r)}}}finally{t.restore()}},Kn=(t,e,n,i)=>{var o,r,s;for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.save();const l=(null!==(o=e._decayOpacity)&&void 0!==o?o:1)*(null!==(s=null===(r=e.style)||void 0===r?void 0:r.opacity)&&void 0!==s?s:1);1!==l&&(t.globalAlpha=l);const a=It(t,e.wickColor)||e.wickColor,c=60>i.height,u=c?Math.max(e.wickWidth,2):e.wickWidth,d=()=>{t.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=a,t.lineWidth=u,t.stroke()};if(c||d(),e.isRange){const n=Math.max(2,Math.min(e.bodyWidth/2,.12*i.height));t.fillStyle=a,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),i=Math.abs(e.openY-e.closeY),o=e.isUp?e.upColor:e.downColor,r=It(t,o)||o;t.fillStyle=r,t.fillRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(i,1)),t.strokeStyle=r,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(i,1))}c&&d(),t.restore()}},Zn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Qn(t){const e=t[1]-t[0],n=3156e7;return 864e5>e?t=>{const e=new Date(t);return`${(e.getUTCHours()+"").padStart(2,"0")}:${(e.getUTCMinutes()+"").padStart(2,"0")}`}:n>e?t=>{const e=new Date(t);return`${Zn[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*n>e?t=>{const e=new Date(t);return`${Zn[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}const Jn={line:[Yn,Rn,Fn],area:[Yn,Fn],stackedarea:[Yn,Fn],scatter:[Fn],bubble:[Fn],heatmap:[Un],bar:[Hn],swarm:[Fn],waterfall:[(t,e,n,i)=>{var o,r,s;Hn(t,e);const l=e.filter(t=>"rect"===t.type);if(2>l.length)return;const a=l[0].datum,c=null==a?void 0:a._connectorStroke;if(c){t.save(),t.strokeStyle=It(t,c)||c,t.lineWidth=null!==(o=null==a?void 0:a._connectorWidth)&&void 0!==o?o:1,t.setLineDash([]);for(let e=0;l.length-1>e;e++){const i=l[e],o=l[e+1];if(!(null===(r=i.datum)||void 0===r?void 0:r.cumEnd)||!(null===(s=o.datum)||void 0===s?void 0:s.baseline))continue;const a=n.y(i.datum.cumEnd),c=i.x+i.w,u=o.x;t.beginPath(),t.moveTo(c,a),t.lineTo(u,a),t.stroke()}t.restore()}}],candlestick:[Kn],mixed:[Yn,Rn,Fn],custom:[Yn,Hn,Un,Rn,Fn,Kn]},ti={top:20,right:20,bottom:30,left:40},ei={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white",primary:"#007bff"};function ni(t,e){const n=t.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const t=n[1],i=n[2],o=n[3];return`#${t}${t}${i}${i}${o}${o}${e}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${e}`;const i=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return i?`rgba(${i[1]}, ${(parseInt(e,16)/255).toFixed(3)})`:n}const ii={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function oi({hover:e}){var n,i,o;const r=t=>null==t?"":"number"==typeof t?Number.isInteger(t)?t+"":t.toFixed(2):t instanceof Date?t.toLocaleString():t+"",s=null!==(n=e.data)&&void 0!==n?n:{},l=null!==(i=s.y)&&void 0!==i?i:s.value,a=null!==(o=s.x)&&void 0!==o?o:s.time;return t.jsxs("div",{className:"semiotic-tooltip",style:ii,children:[t.jsx("div",{style:{fontWeight:600,marginBottom:2},children:r(l)}),t.jsx("div",{style:{opacity:.7,fontSize:11},children:r(a)})]})}const ri=e.forwardRef(function(n,i){var o,r,s,l,a,c,u,d,h,f,g,p,v;const{chartType:m,runtimeMode:b,data:A,chunkThreshold:S,chunkSize:_,xAccessor:j,yAccessor:P,colorAccessor:C,sizeAccessor:E,groupAccessor:L,lineDataAccessor:O,curve:T,normalize:D,baseline:R,stackOrder:I,binSize:$,valueAccessor:N,arrowOfTime:W="right",windowMode:z="sliding",windowSize:Y=200,timeAccessor:F,xExtent:B,yExtent:H,extentPadding:X=.1,scalePadding:G,sizeRange:V,size:q=[500,300],responsiveWidth:U,responsiveHeight:K,margin:Z,className:Q,background:J,lineStyle:tt,pointStyle:et,areaStyle:nt,barStyle:it,waterfallStyle:ot,swarmStyle:rt,barColors:st,colorScheme:lt,boundsAccessor:at,boundsStyle:ct,y0Accessor:ut,gradientFill:dt,lineGradient:ht,areaGroups:ft,openAccessor:gt,highAccessor:yt,lowAccessor:pt,closeAccessor:vt,candlestickStyle:mt,showAxes:xt=!0,axes:bt,xLabel:kt,yLabel:St,yLabelRight:Mt,xFormat:_t,yFormat:jt,tickFormatTime:Pt,tickFormatValue:Ct,hoverAnnotation:Et,tooltipContent:Lt,customHoverBehavior:Ot,customClickBehavior:Tt,enableHover:Dt,hoverRadius:Rt=30,tooltipMode:$t,annotations:Nt,svgAnnotationRules:Wt,showGrid:zt,legend:Yt,legendHoverBehavior:Xt,legendClickBehavior:Gt,legendHighlightedCategory:Vt,legendIsolatedCategories:qt,legendPosition:Ut,legendCategoryAccessor:Kt,onCategoriesChange:Zt,backgroundGraphics:ne,foregroundGraphics:ie,canvasPreRenderers:se,svgPreRenderers:le,title:ae,categoryAccessor:ce,brush:ue,onBrush:de,decay:he,pulse:fe,transition:ge,animate:ye,staleness:pe,heatmapAggregation:ve,heatmapXBins:me,heatmapYBins:xe,showValues:be,heatmapValueFormat:ke,marginalGraphics:we,pointIdAccessor:Ae,xScaleType:Se,yScaleType:Me,accessibleTable:_e=!0,description:je,summary:Pe,linkedCrosshairName:Ce,linkedCrosshairSourceId:Ee,customLayout:Le,layoutConfig:Oe}=n,Te=e.useId().replace(/:/g,""),De=e.useRef(!1),Re=En({sizeProp:q,responsiveWidth:U,responsiveHeight:K,userMargin:Z,marginDefault:ti,animate:ye,transitionProp:ge,themeDirtyRef:De}),Ie=Ke(),$e=tn(),{reducedMotionRef:Ne,responsiveRef:We,size:ze,currentTheme:Ye,transition:Be,introEnabled:He,tableId:Ge,rafRef:Ue,renderFnRef:Ze,scheduleRender:Qe}=Re;let Je=Re.margin;if(we){const t=60,e=Object.assign({},Re.margin);we.top&&t>e.top&&(e.top=t),we.bottom&&t>e.bottom&&(e.bottom=t),we.left&&t>e.left&&(e.left=t),we.right&&t>e.right&&(e.right=t),Je=e}const on="function"==typeof ie?ie({size:ze,margin:Je}):ie,rn="function"==typeof ne?ne({size:ze,margin:Je}):ne,sn=ze[0]-Je.left-Je.right,ln=ze[1]-Je.top-Je.bottom,an=e.useMemo(()=>k(A),[A]),cn=null!=Et?Et:Dt,dn=e.useRef(null),hn=e.useRef(null),[fn,gn]=e.useState(0),[yn,pn]=e.useState(null),vn=e.useRef(null),mn=e.useRef(null),[xn,kn]=e.useState(null),Mn=e.useRef(ei.primary),Pn=e.useRef([]),Cn=e.useRef(Kt),Tn=e.useRef(Zt);Cn.current=Kt,Tn.current=Zt;const[Dn,Rn]=e.useState(!1),[In,$n]=e.useState([]),[Nn,Wn]=e.useState([]),zn="streaming"===b||["bar","swarm","waterfall"].includes(m),Yn=e.useMemo(()=>{var t,e,n;return{chartType:m,runtimeMode:zn?"streaming":"bounded",windowSize:Y,windowMode:z,arrowOfTime:zn?W:"right",extentPadding:X,scalePadding:G,xAccessor:j,yAccessor:P,timeAccessor:zn?F:void 0,valueAccessor:N,colorAccessor:C,sizeAccessor:E,groupAccessor:L||(O?"_lineGroup":void 0),categoryAccessor:ce,lineDataAccessor:O,xScaleType:Se,yScaleType:Me,xExtent:B,yExtent:H,sizeRange:V,binSize:$,normalize:D,baseline:R,stackOrder:I,boundsAccessor:at,boundsStyle:ct,y0Accessor:ut,gradientFill:!0===dt?{topOpacity:.8,bottomOpacity:.05}:!1===dt?void 0:dt,areaGroups:ft?new Set(ft):void 0,lineGradient:ht,openAccessor:gt,highAccessor:yt,lowAccessor:pt,closeAccessor:vt,candlestickStyle:mt,lineStyle:tt,pointStyle:et,areaStyle:nt,swarmStyle:rt,waterfallStyle:ot,colorScheme:lt,barColors:st,barStyle:it,annotations:Nt,decay:he,pulse:fe,transition:Be,introAnimation:He,staleness:pe,heatmapAggregation:ve,heatmapXBins:me,heatmapYBins:xe,showValues:be,heatmapValueFormat:ke,pointIdAccessor:Ae,curve:T,themeCategorical:null===(t=null==Ye?void 0:Ye.colors)||void 0===t?void 0:t.categorical,themeSemantic:M(Ye),themeSequential:null===(e=null==Ye?void 0:Ye.colors)||void 0===e?void 0:e.sequential,themeDiverging:null===(n=null==Ye?void 0:Ye.colors)||void 0===n?void 0:n.diverging,customLayout:Le,layoutConfig:Oe,layoutMargin:Je}},[m,Y,z,W,X,G,j,P,F,N,Se,Me,C,E,L,ce,O,B,H,V,$,D,R,I,at,ct,ut,dt,ht,ft,gt,yt,pt,vt,mt,tt,et,nt,rt,ot,it,lt,st,Nt,he,fe,null==Be?void 0:Be.duration,null==Be?void 0:Be.easing,He,pe,ve,me,xe,be,ke,zn,Ae,T,Ye,Le,Oe,Je]),Fn=nn(Yn),Bn=e.useRef(null);Bn.current||(Bn.current=new wt(Fn));const Hn=e.useCallback(()=>{var t,e;const n=Cn.current,i=Tn.current;if(!i||!n)return;const o=function(t,e){if(!e)return[];const n=new Set,i=[];for(const o of t){if(!o||"object"!=typeof o)continue;const t="function"==typeof e?e(o):o[e];if(null==t)continue;const r=t+"";n.has(r)||(n.add(r),i.push(r))}return i}(null!==(e=null===(t=Bn.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[],n);(function(t,e){if(t.length!==e.length)return!1;for(let n=0;t.length>n;n++)if(t[n]!==e[n])return!1;return!0})(o,Pn.current)||(Pn.current=o,i(o))},[]);e.useEffect(()=>{var t;null===(t=Bn.current)||void 0===t||t.updateConfig(Fn),De.current=!0,Qe()},[Fn,Qe]);const Xn=e.useRef(null);Xn.current||(Xn.current=new w(t=>{const e=Bn.current;e&&e.ingest(t)&&(De.current=!0,Qe())},{chunkThreshold:S,chunkSize:_})),e.useEffect(()=>{var t;null===(t=Xn.current)||void 0===t||t.updateChunkOptions({chunkThreshold:S,chunkSize:_})},[S,_]);const Vn=e.useCallback(t=>{var e;null===(e=Xn.current)||void 0===e||e.push(t)},[]),qn=e.useCallback(t=>{var e;null===(e=Xn.current)||void 0===e||e.pushMany(t)},[]),Un=e.useCallback(()=>{var t,e;null===(t=Xn.current)||void 0===t||t.clear(),null===(e=Bn.current)||void 0===e||e.clear(),De.current=!0,Qe()},[Qe]);e.useImperativeHandle(i,()=>({push:Vn,pushMany:qn,remove:t=>{var e,n,i;null===(e=Xn.current)||void 0===e||e.flush();const o=null!==(i=null===(n=Bn.current)||void 0===n?void 0:n.remove(t))&&void 0!==i?i:[];return o.length>0&&(vn.current&&o.some(t=>{var e;return t===(null===(e=vn.current)||void 0===e?void 0:e.data)})&&(vn.current=null,kn(null)),De.current=!0,Qe()),o},update:(t,e)=>{var n,i,o;null===(n=Xn.current)||void 0===n||n.flush();const r=null!==(o=null===(i=Bn.current)||void 0===i?void 0:i.update(t,e))&&void 0!==o?o:[];return r.length>0&&(De.current=!0,Qe()),r},clear:Un,getData:()=>{var t,e,n;return null===(t=Xn.current)||void 0===t||t.flush(),null!==(n=null===(e=Bn.current)||void 0===e?void 0:e.getData())&&void 0!==n?n:[]},getScales:()=>{var t,e;return null!==(e=null===(t=Bn.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=Bn.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[Vn,qn,Un,Qe]),e.useEffect(()=>{var t,e;if(A){if(O&&an.length>0&&"object"==typeof an[0]&&null!==an[0]){const e="string"==typeof O?O:"coordinates";if(Array.isArray(an[0][e])){const n=[];for(const t of an){const i=t[e];if(Array.isArray(i)){const e=t.label||t.id||t.key;if(null!=e)for(const t of i)n.push(Object.assign(Object.assign({},t),{_lineGroup:e}));else for(const t of i)n.push(t)}}return void(null===(t=Xn.current)||void 0===t||t.setBoundedData(n))}}null===(e=Xn.current)||void 0===e||e.setBoundedData(an)}},[A,an,O]);const{hoverHandlerRef:Kn,hoverLeaveRef:Zn,onPointerMove:ii,onPointerLeave:ri}=Re;Kn.current=t=>{var e,n,i;if(!cn)return;const o=dn.current;if(!o)return;const r=o.getBoundingClientRect(),s=t.clientX-r.left-Je.left,l=t.clientY-r.top-Je.top;if(0>s||s>sn||0>l||l>ln)return void(vn.current&&(vn.current=null,mn.current=null,kn(null),Ot&&(Ot(null),De.current=!0),Qe()));const a=Bn.current;if(!a||0===a.scene.length)return;const c=Bt(a.scene,s,l,Rt,a.quadtree,a.maxPointRadius),u="multi"===$t,d=()=>{vn.current&&(vn.current=null,mn.current=null,kn(null),Ot&&Ot(null),Qe())};if(!c&&!u)return void d();const h=u||!c?s:c.x,f=u||!c?l:c.y;let g=Gn(null!==(e=null==c?void 0:c.datum)&&void 0!==e?e:{},h,f);if(u&&a.scene.length>0&&a.scales){const t=function(t,e,n=30){const i=[];for(const o of t)if("line"===o.type){const t=o;if(2>t.path.length)continue;const r=Ht(Ft(t.path,t.curve),e,n);if(null===r)continue;const s=Qt(t.path,e);i.push({node:o,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"===o.type){const t=o;if(!1===t.interactive)continue;if(2>t.topPath.length)continue;const r=Ft(t.topPath,t.curve),s=Ft(t.bottomPath,t.curve),l=Ht(r,e,n);if(null===l)continue;const a=Ht(s,e,n),c=Qt(t.topPath,e);i.push({node:o,datum:Array.isArray(t.datum)&&t.datum[c]?t.datum[c]:t.datum,x:t.topPath[c][0],y:l,y0:null!=a?a: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 i}(a.scene,h,Math.max(Rt,sn));if(t.length>0){const e=a.scales.y.invert,n=a.scales.x.invert,i=Mn.current,o=n?n(h):h;if(c)g.xValue=o,g.xPx=h;else{const t={xValue:o};"string"==typeof j&&(t[j]=o),g=Gn(t,h,f,{xValue:o,xPx:h})}g.allSeries=t.map(t=>{const n=e?e(t.y):t.y,o=null!=t.y0?e?e(t.y0):t.y0:void 0;return{group:t.group||"",value:"stackedarea"===m&&null!=o?n-o:n,valuePx:t.y,color:t.color||i,datum:t.datum}})}}c||(null===(n=g.allSeries)||void 0===n?void 0:n.length)?(vn.current=g,mn.current=null!==(i=null==c?void 0:c.node)&&void 0!==i?i:null,kn(g),Ot&&(Ot(g),De.current=!0),Qe()):d()},Zn.current=()=>{vn.current&&(vn.current=null,mn.current=null,kn(null),Ot&&(Ot(null),De.current=!0),Qe())};const si=e.useRef(()=>{});si.current=t=>{if(!Tt)return;const e=dn.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-Je.left,o=t.clientY-n.top-Je.top;if(0>i||i>sn||0>o||o>ln)return void Tt(null);const r=Bn.current;if(!r||0===r.scene.length)return void Tt(null);const s=Bt(r.scene,i,o,Rt,r.quadtree,r.maxPointRadius);Tt(s?Gn(s.datum||{},s.x,s.y):null)};const li=e.useCallback(t=>si.current(t),[]),ai=e.useRef(-1),ci=e.useRef(null),ui=e.useRef(null),di=e.useCallback(t=>{const e=Bn.current;if(!e||0===e.scene.length)return;const n=e.version;let i;if(ui.current&&ui.current.version===n)i=ui.current.graph;else{const t=function(t){var e,n,i;const o=[];for(const r of t)switch(r.type){case"point":o.push({x:r.x,y:r.y,datum:r.datum,shape:"circle",group:"_default"});break;case"line":{const t=r,n=Array.isArray(t.datum)?t.datum:[],i=null!==(e=t.group)&&void 0!==e?e:"_default";for(let e=0;t.path.length>e&&n.length>e;e++)o.push({x:t.path[e][0],y:t.path[e][1],datum:n[e],shape:"circle",group:i});break}case"area":{const t=r,e=Array.isArray(t.datum)?t.datum:[],i=null!==(n=t.group)&&void 0!==n?n:"_default";for(let n=0;t.topPath.length>n&&e.length>n;n++)o.push({x:t.topPath[n][0],y:t.topPath[n][1],datum:e[n],shape:"circle",group:i});break}case"rect":o.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:null!==(i=r.group)&&void 0!==i?i:"_default"});break;case"heatcell":o.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:"_default"})}return o.sort((t,e)=>t.x-e.x||t.y-e.y),o}(e.scene);if(0===t.length)return;i=Jt(t),ui.current={version:n,graph:i}}const o=ai.current;if(0>o){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key))return;t.preventDefault(),ai.current=0;const e=i.flat[0];ci.current={shape:e.shape,w:e.w,h:e.h};const n=oe(e);return vn.current=n,kn(n),Ot&&Ot(n),void Qe()}const r=te(i,o),s=ee(t.key,r,i);if(null===s)return;if(t.preventDefault(),0>s)return ai.current=-1,ci.current=null,vn.current=null,mn.current=null,kn(null),Ot&&Ot(null),void Qe();ai.current=s;const l=i.flat[s];ci.current={shape:l.shape,w:l.w,h:l.h};const a=oe(l);vn.current=a,kn(a),Ot&&Ot(a),Qe()},[Ot,Qe]),hi=e.useCallback(t=>{ai.current=-1,ci.current=null,ii(t)},[ii]);Ze.current=()=>{var t,e;Ue.current=0;const n=dn.current,i=hn.current;if(!n||!i)return;const o=Bn.current;if(!o)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=o.advanceTransition(Ne.current?r+1e6:r),l=!Ne.current&&s,a=De.current||s;a&&!l&&(o.computeScene({width:sn,height:ln}),Hn());const c=On(),u=function(t){if(!t)return ei;const e=getComputedStyle(t),n=e.getPropertyValue("--semiotic-border").trim(),i=e.getPropertyValue("--semiotic-text-secondary").trim(),o=e.getPropertyValue("--semiotic-bg").trim(),r=e.getPropertyValue("--semiotic-primary").trim(),s=i||e.getPropertyValue("--text-secondary").trim(),l=e.getPropertyValue("--text-primary").trim(),a=n||e.getPropertyValue("--surface-3").trim(),c=o||e.getPropertyValue("--surface-0").trim();return s||l||n||r?{axisStroke:a||ei.axisStroke,tickText:s||ei.tickText,crosshair:s?ni(s,"66"):ei.crosshair,hoverFill:c?ni(c,"4D"):ei.hoverFill,hoverStroke:s?ni(s,"99"):ei.hoverStroke,pointRing:c||ei.pointRing,primary:r||ei.primary}:ei}(n);Mn.current=u.primary;const d=null!==(t=null==pe?void 0:pe.threshold)&&void 0!==t?t:5e3,h=pe&&o.lastIngestTime>0&&r-o.lastIngestTime>d;if(a){const t=Ln(n,ze,Je,c);if(t){if(t.clearRect(-Je.left,-Je.top,ze[0],ze[1]),h&&(t.globalAlpha=null!==(e=null==pe?void 0:pe.dimOpacity)&&void 0!==e?e:.5),"transparent"!==J&&!ne){const e=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=J||(e&&"transparent"!==e?e:null),o=i?It(t,i):null;o&&(t.fillStyle=o,t.fillRect(-Je.left,-Je.top,ze[0],ze[1]))}if(t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,sn,ln),t.clip()),se&&o.scales)for(const e of se)t.save(),e(t,o.scene,o.scales,{width:sn,height:ln}),t.restore();const i=Le?Jn.custom:Jn[m];if(i&&o.scales)for(const e of i)e(t,o.scene,o.scales,{width:sn,height:ln});t.restore(),h&&(t.globalAlpha=1)}}{const t=Ln(i,ze,Je,c);if(t&&(t.clearRect(-Je.left,-Je.top,ze[0],ze[1]),cn&&vn.current&&o.scales&&function(t,e,n,i,o,r,s){var l;if(!1===o.crosshair)return;const a=e.allSeries,c=a&&a.length>0,u=null!==(l=e.xPx)&&void 0!==l?l:e.x;t.save();const d="object"==typeof o.crosshair?o.crosshair:{};if(t.strokeStyle=d.stroke||s.crosshair,t.lineWidth=d.strokeWidth||1,t.setLineDash(d.strokeDasharray?d.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(c?u:e.x,0),t.lineTo(c?u:e.x,i),t.stroke(),c||(t.beginPath(),t.moveTo(0,e.y),t.lineTo(n,e.y),t.stroke()),t.restore(),c){t.lineWidth=2,t.strokeStyle=s.pointRing;for(const e of a)null!=e.valuePx&&(t.beginPath(),t.arc(u,e.valuePx,4,0,2*Math.PI),t.fillStyle=e.color||s.primary,t.fill(),t.stroke())}else{const n=o.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,vn.current,sn,ln,"object"==typeof cn?cn:{},mn.current,u),mn.current&&Array.isArray(Et))){const e=Et.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,n,i,o){var r;if(!n)return;const s=n.group;if(void 0!==s)for(const n of e){if("line"!==n.type)continue;if(n.group!==s)continue;if(2>n.path.length)continue;const e="function"==typeof i.style?n.datum?i.style(n.datum):{}:i.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||o.primary,t.lineWidth=e.strokeWidth||(n.style.strokeWidth||2)+2,t.globalAlpha=null!==(r=e.opacity)&&void 0!==r?r:1,t.stroke(),t.restore()}}(t,o.scene,mn.current,e,u)}}a&&n&&n.setAttribute("aria-label",un(o.scene,m+" chart"));const f=De.current;if(De.current=!1,f&&o.scales){const t=t=>"object"==typeof t&&null!==t&&"function"==typeof t.valueOf?t.valueOf():t;if((!yn||t(yn.x.domain()[0])!==t(o.scales.x.domain()[0])||t(yn.x.domain()[1])!==t(o.scales.x.domain()[1])||t(yn.y.domain()[0])!==t(o.scales.y.domain()[0])||t(yn.y.domain()[1])!==t(o.scales.y.domain()[1])||yn.x.range()[0]!==o.scales.x.range()[0]||yn.x.range()[1]!==o.scales.x.range()[1]||yn.y.range()[0]!==o.scales.y.range()[0]||yn.y.range()[1]!==o.scales.y.range()[1])&&pn(o.scales),we){const t=o.getData(),e="function"==typeof j?j:t=>t[j||"x"],n="function"==typeof P?P:t=>t[P||"y"];$n(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),Wn(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}}f&&Nt&&Nt.length>0&&gn(t=>t+1),(null==pe?void 0:pe.showBadge)&&Rn(!!h),(l||null!=o.activeTransition||o.hasActivePulses)&&(Ue.current=requestAnimationFrame(()=>Ze.current()))},en({hydrated:Ie,wasHydratingFromSSR:$e,storeRef:Bn,dirtyRef:De,renderFnRef:Ze,cleanup:()=>{var t;return null===(t=Xn.current)||void 0===t?void 0:t.clear()}}),e.useEffect(()=>{De.current=!0,Qe()},[m,sn,ln,xt,J,tt,se,Qe]),re(pe,Bn,De,Qe,Dn,Rn);const fi=e.useMemo(()=>{if(_t||Pt)return;const t=Bn.current;return(null==t?void 0:t.xIsDate)&&yn?Qn(yn.x.domain()):void 0},[_t,Pt,yn]),gi=_t||Pt||fi,yi=cn&&xn?Lt?Lt(xn):t.jsx(oi,{hover:xn}):null,pi=yi?t.jsx(jn,{x:xn.x,y:xn.y,containerWidth:sn,containerHeight:ln,margin:Je,className:"stream-frame-tooltip",children:yi}):null,vi=ci.current,mi=t.jsx(_n,{active:ai.current>=0,hoverPoint:xn,margin:Je,size:ze,shape:null==vi?void 0:vi.shape,width:null==vi?void 0:vi.w,height:null==vi?void 0:vi.h}),xi=(t,e,n,i)=>"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:i,fn:e}:{key:void 0,fn:null},bi=xi(j,F,"__semiotic_resolvedX","__semiotic_resolvedTime"),ki=xi(P,N,"__semiotic_resolvedY","__semiotic_resolvedValue"),wi=bi.key,Ai=ki.key,Si=Nt&&Nt.length>0,Mi=t=>{if(!t||!Si||!bi.fn&&!ki.fn)return t;let e=!1;const n=t.map(t=>{const n=bi.fn&&bi.key&&!(bi.key in t),i=ki.fn&&ki.key&&!(ki.key in t);if(!n&&!i)return t;e=!0;const o=Object.assign({},t);return n&&(o[bi.key]=bi.fn(t)),i&&(o[ki.key]=ki.fn(t)),o});return e?n:t};if(qe||!Ie&&$e){const e=Bn.current;e&&A&&(e.ingest({inserts:an,bounded:!0}),e.computeScene({width:sn,height:ln}));const n=null!==(o=null==e?void 0:e.scene)&&void 0!==o?o:[],i=null!==(r=null==e?void 0:e.scales)&&void 0!==r?r:null,l=gi||(()=>{if((null==e?void 0:e.xIsDate)&&i)return Qn(i.x.domain())})();return t.jsxs("div",{ref:We,className:"stream-xy-frame"+(Q?" "+Q:""),role:"img","aria-label":je||("string"==typeof ae?ae:"XY chart"),style:{position:"relative",width:U?"100%":ze[0],height:K?"100%":ze[1]},children:[t.jsx(wn,{summary:Pe}),t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:ze[0],height:ze[1],style:{position:"absolute",left:0,top:0},children:[t.jsx("g",{transform:`translate(${Je.left},${Je.top})`,children:rn}),t.jsxs("g",{transform:`translate(${Je.left},${Je.top})`,children:[J&&t.jsx("rect",{x:0,y:0,width:sn,height:ln,fill:J}),le&&i&&le.map((e,o)=>t.jsx(y.Fragment,{children:e(n,i,{width:sn,height:ln})},"svgpre-"+o)),n.map((e,n)=>function(e,n,i){var o,r,s,l,a;switch(e.type){case"line":{const i=e;if(0===i.path.length)return null;const o="M"+i.path.map(([t,e])=>`${t},${e}`).join("L");return t.jsx("path",{d:o,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth||2,strokeDasharray:i.style.strokeDasharray,opacity:i.style.opacity},"line-"+n)}case"area":{const a=e;if(0===a.topPath.length)return null;const c=`M${a.topPath.map(([t,e])=>`${t},${e}`).join("L")}L${[...a.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L")}Z`;if(a.clipRect){const e=`${i?i+"-":""}area-clip-${n}`;return t.jsxs("g",{children:[t.jsx("defs",{children:t.jsx("clipPath",{id:e,children:t.jsx("rect",{x:a.clipRect.x,y:a.clipRect.y,width:a.clipRect.width,height:a.clipRect.height})})}),t.jsx("path",{d:c,fill:Ve(a.style.fill),fillOpacity:null!==(r=null!==(o=a.style.fillOpacity)&&void 0!==o?o:a.style.opacity)&&void 0!==r?r:.7,stroke:a.style.stroke,strokeWidth:a.style.strokeWidth,clipPath:`url(#${e})`})]},"area-"+n)}return t.jsx("path",{d:c,fill:Ve(a.style.fill),fillOpacity:null!==(l=null!==(s=a.style.fillOpacity)&&void 0!==s?s:a.style.opacity)&&void 0!==l?l:.7,stroke:a.style.stroke,strokeWidth:a.style.strokeWidth},"area-"+n)}case"point":{const i=e;return t.jsx("circle",{cx:i.x,cy:i.y,r:i.r,fill:Ve(i.style.fill),opacity:null!==(a=i.style.opacity)&&void 0!==a?a:.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth},"point-"+n)}case"rect":{const i=e;return t.jsx("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:Ve(i.style.fill),opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth},"rect-"+n)}case"heatcell":{const i=e;if(i.showValues&&null!=i.value&&i.w>=20&&i.h>=20){const e=i.valueFormat?i.valueFormat(i.value):Number.isInteger(i.value)?i.value+"":100>Math.abs(i.value)?1>Math.abs(i.value)?i.value.toPrecision(3):i.value.toFixed(1):i.value.toFixed(0),[o,r,s]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(i.fill),l=.299*o+.587*r+.114*s>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(i.w,i.h)));return t.jsxs("g",{children:[t.jsx("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill}),t.jsx("text",{x:i.x+i.w/2,y:i.y+i.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:l,fontSize:a+"px",children:e})]},"heatcell-"+n)}return t.jsx("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill},"heatcell-"+n)}case"candlestick":{const i=e,o=Math.min(i.openY,i.closeY),r=Math.max(Math.abs(i.openY-i.closeY),1),s=i.isUp?i.upColor:i.downColor;return t.jsxs("g",{children:[t.jsx("line",{x1:i.x,y1:i.highY,x2:i.x,y2:i.lowY,stroke:i.wickColor,strokeWidth:i.wickWidth}),t.jsx("rect",{x:i.x-i.bodyWidth/2,y:o,width:i.bodyWidth,height:r,fill:s,stroke:s,strokeWidth:1})]},"candle-"+n)}default:return null}}(e,n,Te)).filter(Boolean)]})]}),t.jsx(Xe,{width:sn,height:ln,totalWidth:ze[0],totalHeight:ze[1],margin:Je,scales:i,showAxes:xt,axes:bt,xLabel:kt,yLabel:St,yLabelRight:Mt,xFormat:l,yFormat:jt||Ct,showGrid:zt,title:ae,legend:Yt,legendHoverBehavior:Xt,legendClickBehavior:Gt,legendHighlightedCategory:Vt,legendIsolatedCategories:qt,legendPosition:Ut,foregroundGraphics:At(on,null===(s=Bn.current)||void 0===s?void 0:s.customLayoutOverlays),marginalGraphics:we,xValues:[],yValues:[],annotations:Nt,svgAnnotationRules:Wt,annotationFrame:0,xAccessor:wi,yAccessor:Ai,annotationData:Mi(null==e?void 0:e.getData()),pointNodes:null==e?void 0:e.scene.filter(t=>"point"===t.type),curve:"string"==typeof T?T:void 0,linkedCrosshairName:Ce,linkedCrosshairSourceId:Ee})]})}return t.jsxs("div",{ref:We,className:"stream-xy-frame"+(Q?" "+Q:""),role:"group","aria-label":je||("string"==typeof ae?ae:"XY chart"),tabIndex:0,style:{position:"relative",width:U?"100%":ze[0],height:K?"100%":ze[1],overflow:"visible"},onKeyDown:di,children:[_e&&t.jsx(An,{tableId:Ge}),_e&&t.jsx(bn,{scene:null!==(a=null===(l=Bn.current)||void 0===l?void 0:l.scene)&&void 0!==a?a:[],chartType:m+" chart",tableId:Ge,chartTitle:"string"==typeof ae?ae:void 0}),t.jsx(wn,{summary:Pe}),t.jsxs("div",{role:"img","aria-label":je||("string"==typeof ae?ae:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:cn?hi:void 0,onMouseLeave:cn?ri:void 0,onClick:Tt?li:void 0,children:[rn&&t.jsx("svg",{style:{position:"absolute",left:0,top:0,width:ze[0],height:ze[1],pointerEvents:"none"},children:t.jsx("g",{transform:`translate(${Je.left},${Je.top})`,children:rn})}),t.jsx(Fe,{width:sn,height:ln,totalWidth:ze[0],totalHeight:ze[1],margin:Je,scales:yn,showAxes:xt,axes:bt,showGrid:zt,xFormat:gi,yFormat:jt||Ct}),t.jsx("canvas",{ref:dn,"aria-label":un(null!==(u=null===(c=Bn.current)||void 0===c?void 0:c.scene)&&void 0!==u?u:[],m+" chart"),style:{position:"absolute",left:0,top:0}}),t.jsx("canvas",{ref:hn,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),t.jsx(Sn,{hoverPoint:xn}),t.jsx(Xe,{width:sn,height:ln,totalWidth:ze[0],totalHeight:ze[1],margin:Je,scales:yn,showAxes:xt,axes:bt,xLabel:kt,yLabel:St,yLabelRight:Mt,xFormat:gi,yFormat:jt||Ct,showGrid:zt,title:ae,legend:Yt,legendHoverBehavior:Xt,legendClickBehavior:Gt,legendHighlightedCategory:Vt,legendIsolatedCategories:qt,legendPosition:Ut,foregroundGraphics:At(on,null===(d=Bn.current)||void 0===d?void 0:d.customLayoutOverlays),marginalGraphics:we,xValues:In,yValues:Nn,annotations:Nt,svgAnnotationRules:Wt,annotationFrame:fn,xAccessor:wi,yAccessor:Ai,annotationData:Mi(null===(h=Bn.current)||void 0===h?void 0:h.getData()),pointNodes:null===(f=Bn.current)||void 0===f?void 0:f.scene.filter(t=>"point"===t.type),curve:"string"==typeof T?T:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==J&&!ne,linkedCrosshairName:Ce,linkedCrosshairSourceId:Ee}),(ue||de)&&t.jsx(x,{width:sn,height:ln,totalWidth:ze[0],totalHeight:ze[1],margin:Je,dimension:null!==(g=null==ue?void 0:ue.dimension)&&void 0!==g?g:"xy",scales:yn,onBrush:null!=de?de:()=>{},binSize:$,snap:null==ue?void 0:ue.snap,binBoundaries:null!==(p=null==ue?void 0:ue.binBoundaries)&&void 0!==p?p:"bar"===m?null===(v=Bn.current)||void 0===v?void 0:v.getBinBoundaries():void 0,snapDuring:null==ue?void 0:ue.snapDuring,streaming:"streaming"===b}),(null==pe?void 0:pe.showBadge)&&t.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===pe.badgePosition?{top:4,left:4}:"bottom-left"===pe.badgePosition?{bottom:4,left:4}:"bottom-right"===pe.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Dn?"#dc3545":"#28a745",color:"white"}),children:Dn?"STALE":"LIVE"}),mi,pi]})]})});ri.displayName="StreamXYFrame";const si={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},li={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class ai{constructor(t){this.capacity=t,this.particles=Array(t),this._freeIndices=Array(t);for(let e=0;t>e;e++)this.particles[e]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[e]=t-1-e}spawn(t){const e=this._freeIndices.pop();if(void 0===e)return null;const n=this.particles[e];return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=t,n.x=0,n.y=0,n}step(t,e,n,i){var o;for(let r=0;this.capacity>r;r++){const s=this.particles[r];if(!s.active)continue;const l=n[s.edgeIndex];if(!l||!l.bezier){s.active=!1,this._freeIndices.push(r);continue}const a=i&&null!==(o=i[s.edgeIndex])&&void 0!==o?o:1;s.t+=t*e*a*(l.bezier.circular?.3:1),1>s.t?ci(l.bezier,s.t,s.offset,s):(s.active=!1,this._freeIndices.push(r))}}countForEdge(t){let e=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===t&&e++;return e}clear(){for(let t=0;this.capacity>t;t++)this.particles[t].active=!1;this._freeIndices.length=0;for(let t=this.capacity-1;t>=0;t--)this._freeIndices.push(t)}resize(t){if(this.capacity>=t)return;const e=this.particles;this.particles=Array(t);for(let n=0;t>n;n++)e.length>n?this.particles[n]=e[n]:(this.particles[n]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(n));this.capacity=t}}function ci(t,e,n,i){if(t.circular&&t.segments)return void function(t,e,n,i,o){const r=t.length,s=e*r,l=Math.min(Math.floor(s),r-1),a=s-l,[c,u,d,h]=t[l];ui(c,u,d,h,a,o);const f=h.x-c.x,g=h.y-c.y,y=Math.sqrt(f*f+g*g);if(y>.001){const t=f/y;o.x+=-g/y*n*i*2,o.y+=t*n*i*2}}(t.segments,e,n,t.halfWidth,i);if(!t.points)return i.x=0,void(i.y=0);const[o,r,s,l]=t.points;ui(o,r,s,l,e,i);const a=l.x-o.x,c=l.y-o.y,u=Math.sqrt(a*a+c*c);if(u>.001){const e=a/u;i.x+=-c/u*n*t.halfWidth*2,i.y+=e*n*t.halfWidth*2}}function ui(t,e,n,i,o,r){const s=1-o,l=s*s,a=l*s,c=o*o,u=c*o;r.x=a*t.x+3*l*o*e.x+3*s*c*n.x+u*i.x,r.y=a*t.y+3*l*o*e.y+3*s*c*n.y+u*i.y}function di(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function hi(t,e){var n,i=[],o=[],r=[],s={},l=[];function a(t){r[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],r[e]&&a(e)})}function c(t){var e,i,d=!1;for(o.push(t),r[t]=!0,e=0;l[t].length>e;e++)(i=l[t][e])===n?(u(n,o),d=!0):r[i]||(d=c(i));if(d)a(t);else for(e=0;l[t].length>e;e++){var h=s[i=l[t][e]];h||(s[i]=h={}),h[i]=!0}return o.pop(),d}function u(t,e){var n=[].concat(e).concat(t);i.push(n)}function d(e){!function(e){for(var n=0;t.length>n;n++)n>=e&&t[n]||(t[n]=[]),t[n]=t[n].filter(function(t){return t>=e})}(e);for(var n,i=function(t){for(var e=t.length,n=Array(e),i=Array(e),o=Array(e),r=Array(e),s=Array(e),l=Array(e),a=0;e>a;++a)n[a]=-1,i[a]=0,o[a]=!1,r[a]=0,s[a]=-1,l[a]=[];var c,u=0,d=[],h=[];function f(e){var a=[e],c=[e];for(n[e]=i[e]=u,o[e]=!0,u+=1;c.length>0;){var f=t[e=c[c.length-1]];if(f.length>r[e]){for(var g=r[e];f.length>g;++g){var y=f[g];if(0>n[y]){n[y]=i[y]=u,o[y]=!0,u+=1,a.push(y),c.push(y);break}o[y]&&(i[e]=0|Math.min(i[e],i[y])),0>s[y]||l[e].push(s[y])}r[e]=g}else{if(i[e]===n[e]){var p=[],v=[],m=0;for(g=a.length-1;g>=0;--g){var x=a[g];if(o[x]=!1,p.push(x),v.push(l[x]),m+=l[x].length,s[x]=d.length,x===e){a.length=g;break}}d.push(p);var b=Array(m);for(g=0;v.length>g;g++)for(var k=0;v[g].length>k;k++)b[--m]=v[g][k];h.push(b)}c.pop()}}}for(a=0;e>a;++a)0>n[a]&&f(a);for(a=0;h.length>a;a++){var g=h[a];if(0!==g.length){g.sort(function(t,e){return t-e}),c=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&c.push(g[y]);h[a]=c}}return{components:d,adjacencyList:h}}(t),o=i.components.filter(function(t){return t.length>1}),r=1/0,s=0;o.length>s;s++)for(var l=0;o[s].length>l;l++)r>o[s][l]&&(r=o[s][l],n=s);var a=o[n];if(!a)return!1;var c=t.map(function(t,e){return-1===a.indexOf(e)?[]:t.filter(function(t){return-1!==a.indexOf(t)})});return{leastVertex:r,adjList:c}}n=0;for(var h=t.length;h>n;){var f=d(n);if(n=f.leastVertex,l=f.adjList){for(var g=0;l.length>g;g++)for(var y=0;l[g].length>y;y++){var p=l[g][y];r[+p]=!1,s[p]={}}c(n),n+=1}else n=h}return i}function fi(t){return t.y0-t.y1>0?"up":"down"}function gi(t,e){return e(t.source)==e(t.target)}function yi(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 pi(t){return t.target.x0-t.source.x1}function vi(t,e){var n=xi(t),i=pi(e)/Math.tan(n);return"up"==fi(t)?t.y1-i:t.y1+i}function mi(t,e){var n=xi(t),i=pi(e)/Math.tan(n);return"up"==fi(t)?t.y1+i:t.y1-i}function xi(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function bi(t,e){return e(t)}function ki(t){return Ai(t.source)}function wi(t){return Ai(t.target)}function Ai(t){return(t.y0+t.y1)/2}function Si(t){return t.virtual?0:t.value}function Mi(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!gi(t,e)?n+1:n});var i=0;return t.targetLinks.forEach(function(t){i=t.circular&&!gi(t,e)?i+1:i}),n+i}function _i(t){return t.target.depth}function ji(t,e){return t.sourceLinks.length?t.depth:e-1}function Pi(t,e){return t.y0-e.y0}function Ci(t,e){return e.y0-t.y0}function Ei(t,e){return t.y1-e.y1}function Li(t,e){return e.y1-t.y1}function Oi(t,e){return Di(t.source,e.source)||t.index-e.index}function Ti(t,e){return Di(t.target,e.target)||t.index-e.index}function Di(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Ri(t,e){return Ii(t)==Ii(e)?"bottom"==t.circularLinkType?Ci(t,e):Pi(t,e):Ii(e)-Ii(t)}function Ii(t){return t.target.column-t.source.column}function $i(t,e){return Ni(t)==Ni(e)}function Ni(t){return t.y0-t.y1>0?"up":"down"}function Wi(t,e,n,i,o){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=l.min(r.links,function(t){return t.source.y0});r.links.forEach(function(t){t.circular&&(t.circularPathData={})});var c=r.links.filter(function(t){return t.circular});return c.sort(function(t,e){return e.value-t.value}),c.forEach(function(t,e){t._circularStub=e>=4}),zi(r.links.filter(function(t){return"top"==t.circularLinkType}),e,n),zi(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+i,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,gi(t,e)&&yi(t))t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+o+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-o-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?Ci:Pi);var u=0;c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2+o*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?Li:Ei),u=0,c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2+o*n+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(r.y1,t.source.y1,t.target.y1)+o+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-o-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,i=t.target.x0,o=t.y1,r=(e+i)/2;return"M"+e+","+n+"C"+r+","+n+" "+r+","+o+" "+i+","+o}(t)}),r}function zi(t,e,n){t.sort(Ri);var i=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,o){var r=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(gi(t,e)&&yi(t))t.circularPathData.verticalBuffer=r+t._circularWidth/2;else{for(var s=0;i.length>s;s++){var l=i[s];if(l!==t&&l.circularPathData&&void 0!==l.circularPathData.verticalBuffer&&Yi(t,l)){var a=l.circularPathData.verticalBuffer+(l._circularWidth||l.width)/2+n;r=a>r?a:r}}t.circularPathData.verticalBuffer=r+t._circularWidth/2}}),t}function Yi(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function Fi(t){return function(){return t}}function Bi(t){return t.index}function Hi(t){return t.nodes}function Xi(t){return t.links}function Gi(t,e,n){var i=l.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});i.forEach(function(o,r){var s=o.length;if(e)o.sort(e);else if(r>0){var l=new Map;o.forEach(function(t,e){var n,i,o,r=(i=0,o=0,(n=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=Ai(t.source)*e,i+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=Ai(t.target)*e,i+=e}}),i>0?o/i:NaN);l.set(t,{bc:r,idx:e})}),o.sort(function(t,e){var n=l.get(t),i=l.get(e),o=n.bc,r=i.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(o)||isNaN(r)?isNaN(o)?isNaN(r)?n.idx-i.idx:1:-1:o-r})}else o.sort(function(t,e){return t.circularLinkType==e.circularLinkType?Mi(e,n)-Mi(t,n):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});o.forEach(function(e,o){e.depth==i.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==Mi(e,n)?(e.y0=t.y1/2+o,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+o,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-o,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/s*o,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-s/2+o,e.y1=e.y0+e.value*t.ky)})})}function Vi(t,e,n,i,o,r){var s=l.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});d();for(var a=1,c=r;c>0;--c)u(a*=.99,n),d();function u(e,n){var i=s.length;s.forEach(function(o){var r=o.length,s=o[0].depth;o.forEach(function(o){var a;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&Mi(o,n)>0){var c=l.mean(o.sourceLinks,wi),u=l.mean(o.targetLinks,ki),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-Ai(o))*e*.3;o.y0+=h,o.y1+=h}}else if(0==s&&1==r)o.y0=t.y1/2-(a=o.y1-o.y0)/2,o.y1=t.y1/2+a/2;else if(s==i-1&&1==r)o.y0=t.y1/2-(a=o.y1-o.y0)/2,o.y1=t.y1/2+a/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)a=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+a;else{var f=l.mean(o.sourceLinks,wi),g=l.mean(o.targetLinks,ki),y=((f&&g?(f+g)/2:f||g)-Ai(o))*e;o.y0+=y,o.y1+=y}})})}function d(){s.forEach(function(n){var r,s,l,a=t.y0,c=n.length;for(n.sort(e||Di),l=0;c>l;++l)(s=a-(r=n[l]).y0)>0&&(r.y0+=s,r.y1+=s),a=r.y1+i;if((s=a-i-t.y1)>0)for(a=r.y0-=s,r.y1-=s,l=c-2;l>=0;--l)(s=(r=n[l]).y1+o-a)>0&&(r.y0-=s,r.y1-=s),a=r.y0})}}function qi(t){t.nodes.forEach(function(t){t.sourceLinks.sort(Ti),t.targetLinks.sort(Oi)}),t.nodes.forEach(function(t){var e=t.y0,n=e,i=t.y1,o=i;t.sourceLinks.forEach(function(t){t.circular?(t.y0=i-t.width/2,i-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=o-t.width/2,o-=t.width):(t.y1=n+t.width/2,n+=t.width)})})}function Ui(){var t=0,e=0,n=1,i=1,o=24,r=8,s=null,a=Bi,c=ji,u=void 0,d=32,h=2,f=Hi,g=Xi;function y(){var y={nodes:f.apply(null,arguments),links:g.apply(null,arguments)};return function(f){f.x0=t,f.y0=e,f.x1=n,f.y1=i,f.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 l.group(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 i=t.source,o=t.target;"object"!=typeof i&&(i=t.source=di(n,i)),"object"!=typeof o&&(o=t.target=di(n,o)),i.sourceLinks.push(t),o.targetLinks.push(t)})}(f,a),function(t,e){var n=0;if(null==e){for(var i=[],o=0;t.links.length>o;o++){var r=t.links[o],s=r.source.index,l=r.target.index;i[s]||(i[s]=[]),i[l]||(i[l]=[]),-1===i[s].indexOf(l)&&i[s].push(l)}var a=hi(i);a.sort(function(t,e){return t.length-e.length});var c={};for(o=0;a.length>o;o++){var u=a[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,i=t.source.index;e===i||c[i]&&c[i][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++)})}(f,u),function(t,e){var n=0,i=0;t.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:i>n?"top":"bottom","top"==o.circularLinkType?n++:i++,t.nodes.forEach(function(t){bi(t,e)!=bi(o.source,e)&&bi(t,e)!=bi(o.target,e)||(t.circularLinkType=o.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),gi(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(f,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(l.sum(t.sourceLinks,Si),l.sum(t.targetLinks,Si)),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)})})}(f),function(t,e,n){var i,o,r;if(null!=e){t.nodes.sort(function(t,n){return e(t)<e(n)?-1:1});var s=0,l=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==l?s:s+1,l=e(t)==l?l:e(t),t.column=s})}for(i=t.nodes,o=[],r=0;i.length;++r,i=o,o=[])i.forEach(function(t){t.depth=r,t.sourceLinks.forEach(function(t){0>o.indexOf(t.target)&&!t.circular&&o.push(t.target)})});for(i=t.nodes,o=[],r=0;i.length;++r,i=o,o=[])i.forEach(function(t){t.height=r,t.targetLinks.forEach(function(t){0>o.indexOf(t.source)&&!t.circular&&o.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?n(t,r):t.column})}(f,u,c);var g=r;if(null!==s){var y=l.groups(f.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=l.max(y,function(t){return t.length});p>1&&(g=Math.max(1,(i-e)*s/(p-1)))}(function(t,e,n){var i=l.groups(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 o=l.min(i,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/l.sum(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var r=l.max(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})})(f,g,o),Gi(f,u,a),Vi(f,u,a,g,g,d),qi(f),Wi(f,a,h,10,8),Gi(f,u,a),Vi(f,u,a,g,g,d),qi(f),Wi(f,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 i=n.links.filter(function(n){return bi(n.source,e)==bi(t,e)}),o=i.length;o>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!$i(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=vi(e,t);return t.y1-n}if(e.target.column>t.target.column)return vi(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;i.forEach(function(t){t.y0=r+t.width/2,r+=t.width}),i.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,s=0;o>r;r++)s+=i[r].width;e.y0=t.y1-s-e.width/2}})})}(f,a),function(t,e){let n=t;n.nodes.forEach(function(t){var i=n.links.filter(function(n){return bi(n.target,e)==bi(t,e)}),o=i.length;o>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!$i(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=mi(e,t);return t.y0-n}if(e.source.column>t.source.column)return mi(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;i.forEach(function(t){t.y1=r+t.width/2,r+=t.width}),i.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,s=0;o>r;r++)s+=i[r].width;e.y1=t.y1-s-e.width/2}})})}(f,a),function(t){var e=t.nodes,n=t.links,i=!1,o=!1;if(n.forEach(function(t){"top"==t.circularLinkType?i=!0:"bottom"==t.circularLinkType&&(o=!0)}),0==i||0==o){var r=l.min(e,function(t){return t.y0}),s=l.max(e,function(t){return t.y1}),a=(t.y1-t.y0)/(s-r);function c(e){return(e-r)/(s-r)*(t.y1-t.y0)+t.y0}1>a?(e.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1)}),n.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1),t.width=t.width*a})):e.forEach(function(t){var e=t.y1-t.y0,n=c(t.y0)-t.y0;t.y0=c(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})})}}(f),Wi(f,a,h,10,8)}(y),y}return y.update=function(t){return qi(t),Wi(t,a,h,10,8),t},y.nodeWidth=function(t){return arguments.length?(o=+t,y):o},y.nodePadding=function(t){return arguments.length?(r=+t,y):r},y.nodePaddingRatio=function(t){return arguments.length?(s=+t,y):s},y.nodes=function(t){return arguments.length?(f="function"==typeof t?t:Fi(t),y):f},y.links=function(t){return arguments.length?(g="function"==typeof t?t:Fi(t),y):g},y.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:Fi(t),y):a},y.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:Fi(t),y):c},y.nodeSort=function(t){return arguments.length?(u=t,y):u},y.iterations=function(t){return arguments.length?(d=+t,y):d},y.circularLinkGap=function(t){return arguments.length?(h=+t,y):h},y.extent=function(o){return arguments.length?(t=+o[0][0],e=+o[0][1],n=+o[1][0],i=+o[1][1],y):[[t,e],[n,i]]},y.size=function(o){return arguments.length?(t=e=0,n=+o[0],i=+o[1],y):[n-t,i-e]},y}const Ki=t=>{let e,n,i,o,r,s,l,a,c;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,i=t.y1+t.sankeyWidth/2,o=t.y0+t.sankeyWidth/2,r=t.source.x1,s=t.target.x0,l=u.interpolateNumber(r,s),a=l(.5),c=l(.5),`M${e},${r}C${e},${a} ${n},${c} ${n},${s}L${i},${s}C${i},${c} ${o},${a} ${o},${r}Z`):(e=t.source.x1,n=t.target.x0,l=u.interpolateNumber(e,n),i=l(.5),o=l(.5),r=t.y0-t.sankeyWidth/2,s=t.y1-t.sankeyWidth/2,a=t.y1+t.sankeyWidth/2,c=t.y0+t.sankeyWidth/2,`M${e},${r}C${i},${r} ${o},${s} ${n},${s}L${n},${a}C${o},${a} ${i},${c} ${e},${c}Z`)};function Zi(t){var e;const n=t.sankeyWidth/2,i=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,o=t.circularPathData;if(!o)return null;if("down"===t.direction)return null;if(t._circularStub){const e=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 l=Math.max(15,Math.min(40,.33*(o.rightFullExtent-e))),a=Math.max(15,Math.min(40,.33*(r-o.leftFullExtent)));return`M${e},${i-n}L${e+l},${i-n}L${e+l},${i+n}L${e},${i+n}ZM${r},${s-n}L${r-a},${s-n}L${r-a},${s+n}L${r},${s+n}Z`}const r=o.sourceX,s=o.sourceY,l=o.targetX,a=o.targetY,c=o.rightFullExtent,u=o.leftFullExtent,d=o.verticalFullExtent,h="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(i,15));return`M${r},${s-h*n}L${c},${s-h*n}L${c+i},${s-h*n+h*f}L${c+i},${d+h*i-h*f}L${c+i-f},${d+h*i}L${u-i+f},${d+h*i}L${u-i},${d+h*i-h*f}L${u-i},${a-h*n+h*f}L${u-i+f},${a-h*n}L${l},${a-h*n}L${l},${a+h*n}L${u+i},${a+h*n}L${u+i},${d-h*i}L${c-i},${d-h*i}L${c-i},${s+h*n}L${r},${s+h*n}Z`}const Qi=new Set,Ji=new WeakMap;function to(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let n=Ji.get(t);if(n){const t=n.get(e);if(t)return t}else n=new Map,Ji.set(t,n);const i=new Proxy(t,{get(t,n,i){if("string"==typeof n&&!(n in t)&&t.data&&n in t.data){const t=`${e}:${n}`;Qi.has(t)||(Qi.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,i)}});return n.set(e,i),i}const eo={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(_i))-1:0},justify:ji};function no(t){return"string"==typeof t?t:t.id}const io={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var o,r,s,l,a,c,u;if(0===t.length)return;const d="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",f=null!==(o=n.nodeWidth)&&void 0!==o?o:15,g=null!==(r=n.nodePaddingRatio)&&void 0!==r?r:.05,y=null!==(s=n.iterations)&&void 0!==s?s:100,p=t.map(t=>Object.assign({},t)),v=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let m;m="down"===d?[[0,0],[i[1],i[0]]]:[[0,0],[i[0],i[1]]];const x=Ui().extent(m).links(v).nodes(p).nodeAlign(eo[h]||ji).nodeId(t=>t.id).nodeWidth(f).iterations(y);x.nodePaddingRatio&&x.nodePaddingRatio(g),x();{let t=1/0,e=-1/0,n=1/0,o=-1/0;for(const i of p)t>i.x0&&(t=i.x0),i.x1>e&&(e=i.x1),n>i.y0&&(n=i.y0),i.y1>o&&(o=i.y1);for(const i of v){if(!i.circular||!i.circularPathData)continue;const r=i.circularPathData,s=(null!==(a=null!==(l=i._circularWidth)&&void 0!==l?l:i.width)&&void 0!==a?a: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>o&&(o=r.verticalFullExtent+s)}const r=e-t,s=o-n,u=i[0],d=i[1];if(r>0&&s>0&&(0>t||0>n||e>u||o>d)){const e=Math.min(u/r,d/s),i=-t*e+(u-r*e)/2,o=-n*e+(d-s*e)/2;for(const t of p)t.x0=t.x0*e+i,t.x1=t.x1*e+i,t.y0=t.y0*e+o,t.y1=t.y1*e+o;for(const t of v)if(t.y0=t.y0*e+o,t.y1=t.y1*e+o,t.width=(null!==(c=t.width)&&void 0!==c?c:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const n=t.circularPathData;n.sourceX=n.sourceX*e+i,n.targetX=n.targetX*e+i,n.sourceY=n.sourceY*e+o,n.targetY=n.targetY*e+o,n.rightFullExtent=n.rightFullExtent*e+i,n.leftFullExtent=n.leftFullExtent*e+i,n.verticalFullExtent=n.verticalFullExtent*e+o,n.rightInnerExtent=n.rightInnerExtent*e+i,n.leftInnerExtent=n.leftInnerExtent*e+i,n.verticalRightInnerExtent=n.verticalRightInnerExtent*e+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*e+o,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 b=new Map;for(const e of t)b.set(e.id,e);for(const t of p){const e=b.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const k=new Map;for(const t of e)k.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of v){const e=no(t.source),n=no(t.target),i=k.get(t._edgeKey?t._edgeKey:`${e}\0${n}`);if(i){i.y0=t.y0,i.y1=t.y1,i.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,i.circular=!!t.circular,i.circularPathData=t.circularPathData,i._circularWidth=t._circularWidth,i._circularStub=t._circularStub,i.path=t.path,i.circularLinkType=t.circularLinkType,i.direction=d;const o=b.get(e),r=b.get(n);o&&(i.source=o),r&&(i.target=r)}}},buildScene(t,e,n,i){var o,r,s,l,a,c;const u="vertical"===n.orientation?"down":"right",d=n.nodeStyle,h=n.edgeStyle,f=null!==(o=n.edgeOpacity)&&void 0!==o?o:.5,g=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:K,p=new Map;t.forEach((t,e)=>{p.set(t.id,y[e%y.length])});const v=[],m=[],x=[],b=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 i=d?d(to(e,"nodeStyle")):{},o={fill:i.fill||p.get(e.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity};b.set(e.id,("string"==typeof o.fill?o.fill:null)||p.get(e.id)||"#4d430c"),v.push("down"===u?{type:"rect",x:e.y0,y:e.x0,w:n,h:t,style:o,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:o,datum:e,id:e.id,label:e.id})}const k=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of k){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let o=(null===(r=n.themeSemantic)||void 0===r?void 0:r.border)||(null===(s=n.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";o="function"==typeof g?g(t)||o:"target"===g?b.get(i.id)||p.get(i.id)||o:b.get(e.id)||p.get(e.id)||o;const u=h?h(to(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,i=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),r=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),s=u.fill||o;m.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+i},${e.sourceY-n}L${e.sourceX+i},${e.sourceY+n}L${e.sourceX},${e.sourceY+n}Z`,style:{fill:s,fillOpacity:null!==(l=u.fillOpacity)&&void 0!==l?l:f,stroke:"none",opacity:u.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+i}}),m.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-n}L${e.targetX-r},${e.targetY-n}L${e.targetX-r},${e.targetY+n}L${e.targetX},${e.targetY+n}Z`,style:{fill:s,fillOpacity:null!==(a=u.fillOpacity)&&void 0!==a?a:f,stroke:"none",opacity:u.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-r,x1:e.targetX}});continue}let d;if(d=t.circular&&t.circularPathData?Zi(t):Ki(t),!d)continue;const y={fill:u.fill||o,fillOpacity:null!==(c=u.fillOpacity)&&void 0!==c?c:f,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};m.push({type:"bezier",pathD:d,bezierCache:t.bezier,style:y,datum:t})}if(!1!==n.showLabels){const e=(w=n.nodeLabel)?"function"==typeof w?w:t=>t[w]||t.id:null;for(const n of t){const t=n.x1-n.x0,o=n.y1-n.y0;if(0>=t||0>=o)continue;const r=e?e(n):n.id;if(!r)continue;let s,l,a;"down"===u?(s=n.y0+(n.y1-n.y0)/2,l=n.x1+14,a="start"):(i[0]/2>n.x0+t/2?(s=n.x0-6,a="end"):(s=n.x1+6,a="start"),l=n.y0+o/2),x.push({x:s,y:l,text:r+"",anchor:"down"===u?"middle":a,baseline:"middle",fontSize:11})}}var w;return{sceneNodes:v,sceneEdges:m,labels:x}}},oo={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var o,r;if(0===t.length)return;const s=null!==(o=n.forceStrength)&&void 0!==o?o:.1,l=i[0]/2,a=i[1]/2,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=null==c?void 0:c.get(e.id);t?u++:n?(e.x=n.x,e.y=n.y,u++):h.push(e)}const f=u>0&&.3>=(t.length>0?h.length/t.length:1);if(f){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of h){const i=ro(t.id,e,n);if(i.length>0){let e=0,n=0;for(const t of i)e+=t.x,n+=t.y;const o=so(t.id),r=o%360*(Math.PI/180),s=10+o%20;t.x=e/i.length+s*Math.cos(r),t.y=n/i.length+s*Math.sin(r)}else{const e=so(t.id),n=e%360*(Math.PI/180),i=15+e%30;t.x=l+i*Math.cos(n),t.y=a+i*Math.sin(n)}}}else{const e=2.399963229728653;for(let n=0;t.length>n;n++){const i=t[n];if(null==i.x||null==i.y||0===i.x&&0===i.y){const t=10*Math.sqrt(n+.5),o=n*e;i.x=l+t*Math.cos(o),i.y=a+t*Math.sin(o)}}}const g=null!==(r=n.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),y=0===n.iterations?0:f?40:g,p=lo(n.nodeSize,n.nodeSizeRange,t),v=t=>p(t);if(y>0){const n=d.forceLink().strength(t=>{const e=t.weight;return Math.min(2.5,e?e*s:s)}).id(t=>t.id),i=d.forceSimulation().force("charge",d.forceManyBody().strength(t=>-25*v(t))).force("center",d.forceCenter(l,a).strength(.8)).force("x",d.forceX(l).strength(.15)).force("y",d.forceY(a).strength(.15));if(i.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));i.force("link",n),i.force("link").links(t)}f?i.alpha(.3):.1>i.alpha()&&i.alpha(1),i.stop();for(let t=0;y>t;++t)i.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=v(e);e.x=Math.max(t,Math.min(i[0]-t,e.x)),e.y=Math.max(t,Math.min(i[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const m=new Map;for(const e of t)m.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=m.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=m.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,i){var o,r,s,l,a,c,u;const d=n.nodeStyle,h=n.edgeStyle,f=lo(n.nodeSize,n.nodeSizeRange,t),g=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:K,y=new Map;t.forEach((t,e)=>{y.set(t.id,g[e%g.length])});const p=[],v=[],m=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=f(to(e,"nodeSize")),i=d?d(to(e,"nodeStyle")):{},l={fill:i.fill||y.get(e.id)||(null===(o=n.themeSemantic)||void 0===o?void 0:o.primary)||"#007bff",stroke:i.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=i.strokeWidth)&&void 0!==s?s:2,opacity:i.opacity};p.push({type:"circle",cx:e.x,cy:e.y,r:t,style:l,datum:e,id:e.id,label:e.id})}const x=new Map;for(const e of t)x.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:x.get(t.source),i="object"==typeof t.target?t.target:x.get(t.target);if(!e||!i)continue;if(null==e.x||null==e.y)continue;if(null==i.x||null==i.y)continue;const o=h?h(to(t,"edgeStyle")):{},r={stroke:o.stroke||(null===(l=n.themeSemantic)||void 0===l?void 0:l.border)||(null===(a=n.themeSemantic)||void 0===a?void 0:a.secondary)||"#999",strokeWidth:null!==(c=o.strokeWidth)&&void 0!==c?c:1,opacity:null!==(u=o.opacity)&&void 0!==u?u:.6};v.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:r,datum:t})}if(!1!==n.showLabels){const e=(b=n.nodeLabel)?"function"==typeof b?b:t=>t[b]||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 i=f(to(n,"nodeSize"));m.push({x:n.x,y:n.y-i-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var b;return{sceneNodes:p,sceneEdges:v,labels:m}}};function ro(t,e,n){const i=[];for(const o of e){const e="string"==typeof o.source?o.source:o.source.id,r="string"==typeof o.target?o.target:o.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||i.push({x:t.x,y:t.y})}}return i}function so(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 lo(t,e,n){var i,r;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const s=e||[5,20],a=n.map(e=>{var n;return null===(n=e.data)||void 0===n?void 0:n[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===a.length)return()=>s[0];const c=null!==(i=l.min(a))&&void 0!==i?i:0,u=null!==(r=l.max(a))&&void 0!==r?r:1;if(c===u)return()=>(s[0]+s[1])/2;const d=o.scaleLinear().domain([c,u]).range(s).clamp(!0);return e=>{var n;const i=null===(n=e.data)||void 0===n?void 0:n[t];return null==i||"number"!=typeof i?s[0]:d(i)}}const ao=K,co={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,i){if(0===t.length)return;const{padAngle:o=.01,groupWidth:r=20,sortGroups:l}=n,a=Math.min(i[0],i[1])/2,c=a-r,u=i[0]/2,d=i[1]/2,f=(g=n.valueAccessor)?"function"==typeof g?g:t=>{var e;return null!==(e=t[g])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var g;const y=new Map;for(let e=0;t.length>e;e++)y.set(t[e].id,e);const p=t.length,v=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=y.get("string"==typeof t.source?t.source:t.source.id),i=y.get(e);if(void 0===n||void 0===i)continue;const o=f(t);v[n][i]=o}const m=h.chord().padAngle(o);l&&m.sortGroups(l);const x=m(v),b=x.groups,k=s.arc().innerRadius(c).outerRadius(a);for(const e of b){const n=t[e.index],i=k.centroid({innerRadius:c,outerRadius:a,startAngle:e.startAngle,endAngle:e.endAngle});n.x=i[0]+u,n.y=i[1]+d,n.__arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const w=new Map;for(const e of t)w.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=w.get("string"==typeof t.source?t.source:t.source.id),i=w.get(e);n&&(t.source=n),i&&(t.target=i)}const A=new Map;for(const t of e)A.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 x){const n=t[e.source.index].id,i=t[e.target.index].id,o=A.get(`${n}\0${i}`)||A.get(`${i}\0${n}`);o&&(o.__chordData=e)}},buildScene(t,e,n,i){var o,r,s,l;const{groupWidth:a=20,edgeOpacity:c=.5}=n,u=Math.min(i[0],i[1])/2,d=u-a,f=i[0]/2,g=i[1]/2,y=n.nodeStyle,p=n.edgeStyle,v=n.edgeColorBy||"source",m=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:ao,x=new Map;t.forEach((t,e)=>{x.set(t.id,m[e%m.length])});const b=h.ribbon().radius(d),k=[],w=[],A=[];for(let e=0;t.length>e;e++){const n=t[e],i=n.__arcData;if(!i)continue;let r;r=y?y(to(n,"nodeStyle")).fill||x.get(n.id)||m[e%m.length]:x.get(n.id)||m[e%m.length];const s=y?y(to(n,"nodeStyle")):{},l={fill:r,stroke:s.stroke||"black",strokeWidth:null!==(o=s.strokeWidth)&&void 0!==o?o:1,opacity:s.opacity};k.push({type:"arc",cx:f,cy:g,innerR:d,outerR:u,startAngle:i.startAngle-Math.PI/2,endAngle:i.endAngle-Math.PI/2,style:l,datum:n,id:n.id,label:n.id})}for(const t of e){const e=t.__chordData;if(!e)continue;const i=b(e);if(!i)continue;const o=uo(i,f,g);let a=(null===(r=n.themeSemantic)||void 0===r?void 0:r.border)||(null===(s=n.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";if(p)a=p(to(t,"edgeStyle")).fill||a;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===v&&n?a=x.get(n.id)||a:e&&(a=x.get(e.id)||a)}const u=p?p(to(t,"edgeStyle")):{},d={fill:a,fillOpacity:null!==(l=u.fillOpacity)&&void 0!==l?l:c,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};w.push({type:"ribbon",pathD:o,style:d,datum:t})}if(!1!==n.showLabels){const e=(S=n.nodeLabel)?"function"==typeof S?S:t=>t[S]||t.id:null,i=u+12;for(const n of t){const t=n.__arcData;if(!t)continue;const o=e?e(n):n.id;if(!o)continue;const r=(t.startAngle+t.endAngle)/2,s=r-Math.PI/2;A.push({x:f+Math.cos(s)*i,y:g+Math.sin(s)*i,text:o+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var S;return{sceneNodes:k,sceneEdges:w,labels:A}}};function uo(t,e,n){const i=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!i)return t;const o=[];let r=0;for(;i.length>r;){const t=i[r];if("M"===t||"L"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("C"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)for(let t=0;3>t&&i.length>r&&!isNaN(Number(i[r]));t++)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("Q"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)for(let t=0;2>t&&i.length>r&&!isNaN(Number(i[r]));t++)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("A"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&(o.push(Number(i[r])+e+""),r++),i.length>r&&(o.push(Number(i[r])+n+""),r++);else"Z"===t||"z"===t?(o.push(t),r++):(o.push(i[r]),r++)}return o.join(" ")}const ho=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function fo(t){const[e,n,i]=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*i>150?"#222":"#fff"}function go(t,e,n){const i=e.nodeIDAccessor;return"function"==typeof i?i(t.data)+"":"string"==typeof i&&void 0!==t.data[i]?t.data[i]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function yo(t){return t?"function"==typeof t?t:e=>{var n;return(null===(n=e.data)||void 0===n?void 0:n[t])||e[t]||e.id}:null}function po(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:ho}function vo(t){var e;return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)?t.themeSemantic.primary:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical[0]:"#4d430c"}function mo(t,e,n,i,o){if("horizontal"===o){const o=(t+n)/2;return`M ${t},${e} C ${o},${e} ${o},${i} ${n},${i}`}if("radial"===o){const o=(t+n)/2;return`M ${t},${e} Q ${o},${e} ${o},${(e+i)/2} T ${n},${i}`}{const o=(e+i)/2;return`M ${t},${e} C ${t},${o} ${n},${o} ${n},${i}`}}const xo={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,i){var o;const r=n.__hierarchyRoot;if(!r)return;const s=n.chartType,l=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(n.childrenAccessor),c=n.hierarchySum,u="function"==typeof c?c:"string"==typeof c?t=>Number(t[c])||0:t=>Number(t.value)||0,d=a.hierarchy(r,l);d.sum(u),d.sort((t,e)=>{var n,i;return(null!==(n=e.value)&&void 0!==n?n:0)-(null!==(i=t.value)&&void 0!==i?i:0)});const[h,f]=i;switch(s){case"tree":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=a.tree();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(d,n,h,f);break;case"cluster":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=a.cluster();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(d,n,h,f);break;case"treemap":!function(t,e,n,i){var o,r;const s=null!==(o=e.padding)&&void 0!==o?o:4,l=null!==(r=e.paddingTop)&&void 0!==r?r:0,c=a.treemap().size([n,i]).tile(a.treemapBinary).padding(s);l>0&&c.paddingTop(l),c(t)}(d,n,h,f);break;case"circlepack":!function(t,e,n,i){var o;const r=null!==(o=e.padding)&&void 0!==o?o:4;a.pack().size([n,i]).padding(r)(t)}(d,n,h,f);break;case"partition":!function(t,e,n,i){var o;a.partition().size([n,i]).padding(null!==(o=e.padding)&&void 0!==o?o:1)(t)}(d,n,h,f)}const g=d.descendants();t.length=0,e.length=0;const y=new Map;for(let e=0;g.length>e;e++){const i=g[e],r={id:go(i,n,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=i.value)&&void 0!==o?o:0,depth:i.depth,data:i.data,createdByFrame:!0};"tree"===s||"cluster"===s?bo(r,i,n):"treemap"===s||"partition"===s?ko(r,i):"circlepack"===s&&wo(r,i),r.__hierarchyNode=i,t.push(r),y.set(i,r)}if("tree"===s||"cluster"===s)for(const t of g)if(t.parent){const n=y.get(t.parent),i=y.get(t);n&&i&&e.push({source:n,target:i,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,i){const o=n.nodeStyle||(()=>({})),r=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,i,o,r){var s,l,a,c,u,d,h,f;const g=[],y=[],p=[],v=n.treeOrientation||"vertical",m="radial"===v,x=i[0]/2,b=i[1]/2,k="number"==typeof(w=n.nodeSize)?w:5;var w;for(const e of t){let t=e.x,i=e.y;m&&(t+=x,i+=b);const r=o(to(e,"nodeStyle"));let a=r.fill||vo(n);if(n.colorByDepth&&void 0!==e.depth){const t=po(n);a=t[e.depth%t.length]}const c={fill:a,stroke:r.stroke||(null===(s=n.themeSemantic)||void 0===s?void 0:s.surface)||"#fff",strokeWidth:null!==(l=r.strokeWidth)&&void 0!==l?l:1,opacity:r.opacity};g.push({type:"circle",cx:t,cy:i,r:k,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const A=null!==(a=n.edgeOpacity)&&void 0!==a?a:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let o=e.x,s=e.y,l=i.x,a=i.y;m&&(o+=x,s+=b,l+=x,a+=b);const f=mo(o,s,l,a,v),g=r(to(t,"edgeStyle")),p={fill:"none",stroke:g.stroke||(null===(c=n.themeSemantic)||void 0===c?void 0:c.border)||(null===(u=n.themeSemantic)||void 0===u?void 0:u.secondary)||"#999",strokeWidth:null!==(d=g.strokeWidth)&&void 0!==d?d:1.5,opacity:null!==(h=g.opacity)&&void 0!==h?h:A};y.push({type:"curved",pathD:f,style:p,datum:t})}if(!1!==n.showLabels){const e=yo(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let i,o,r,s=n.x,l=n.y;if(m&&(s+=x,l+=b),m){const t=s-x,e=l-b,n=Math.sqrt(t*t+e*e);n>0?(i=s+t/n*10,o=l+e/n*10,r=0>t?"end":"start"):(i=s,o=l-12,r="middle")}else"horizontal"===v?((null===(f=n.data)||void 0===f?void 0:f.children)&&0!==n.data.children.length?(i=s-k-6,r="end"):(i=s+k+6,r="start"),o=l):(i=s,o=l+k+14,r="middle");p.push({x:i,y:o,text:t+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:y,labels:p}}(t,e,n,i,o,r);case"treemap":case"partition":return function(t,e,n,i){var o,r,s,l,a;const c=[],u=[];for(const n of t){const t=n.x1-n.x0,s=n.y1-n.y0;if(0>=t||0>=s)continue;const l=i(to(n,"nodeStyle"));let a=l.fill||vo(e);if(e.colorByDepth&&void 0!==n.depth){const t=po(e);a=t[n.depth%t.length]}const u={fill:a,stroke:l.stroke||(null===(o=e.themeSemantic)||void 0===o?void 0:o.surface)||"#fff",strokeWidth:null!==(r=l.strokeWidth)&&void 0!==r?r:1,opacity:l.opacity};c.push({type:"rect",x:n.x0,y:n.y0,w:t,h:s,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=yo(e.nodeLabel),o=e.labelMode||"leaf",r="partition"===e.chartType;for(const c of t){const t=c.x1-c.x0,d=c.y1-c.y0;if(0>=t||0>=d)continue;const h=!((null===(s=c.data)||void 0===s?void 0:s.children)&&c.data.children.length>0);if(!r){if("leaf"===o&&!h)continue;if("parent"===o&&h)continue}const f=n?n(c):c.id;if(!f)continue;if((h?30:40)>t||(h?16:14)>d)continue;let g=i(to(c,"nodeStyle")).fill||vo(e);if(e.colorByDepth&&void 0!==c.depth){const t=po(e);g=t[c.depth%t.length]}const y="string"==typeof g?fo(g):null!==(a=null===(l=e.themeSemantic)||void 0===l?void 0:l.text)&&void 0!==a?a:"#000";u.push(h?{x:c.x0+t/2,y:c.y0+d/2,text:f+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,d)/6)),fill:y}:{x:c.x0+4,y:c.y0+12,text:f+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:y})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(t,n,0,o);case"circlepack":return function(t,e,n,i){var o,r,s,l,a,c,u,d,h,f;const g=[],y=[];for(const n of t){const t=null!==(o=n.__radius)&&void 0!==o?o:5;if(0>=t)continue;const a=i(to(n,"nodeStyle"));let c=a.fill||vo(e);if(e.colorByDepth&&void 0!==n.depth){const t=po(e);c=t[n.depth%t.length]}const u={fill:c,stroke:a.stroke||(null===(r=e.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=a.strokeWidth)&&void 0!==s?s:1,opacity:null!==(l=a.opacity)&&void 0!==l?l:.7};g.push({type:"circle",cx:n.x,cy:n.y,r:t,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=yo(e.nodeLabel);for(const o of t){const t=null!==(a=o.__radius)&&void 0!==a?a:5,r=n?n(o):o.id;if(!r)continue;if(15>t)continue;const s=!((null===(c=o.data)||void 0===c?void 0:c.children)&&o.data.children.length>0);let l=i(to(o,"nodeStyle")).fill||vo(e);if(e.colorByDepth&&void 0!==o.depth){const t=po(e);l=t[o.depth%t.length]}if(s){const n="string"==typeof l?fo(l):null!==(d=null===(u=e.themeSemantic)||void 0===u?void 0:u.text)&&void 0!==d?d:"#000";y.push({x:o.x,y:o.y,text:r+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:n})}else y.push({x:o.x,y:o.y-t+14,text:r+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:(null===(h=e.themeSemantic)||void 0===h?void 0:h.text)||"#000",stroke:(null===(f=e.themeSemantic)||void 0===f?void 0:f.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:g,sceneEdges:[],labels:y}}(t,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function bo(t,e,n){const i=n.treeOrientation||"vertical";if("radial"===i){const n=e.x,i=e.y;t.x=i*Math.cos(n-Math.PI/2),t.y=i*Math.sin(n-Math.PI/2)}else"horizontal"===i?(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 ko(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 wo(t,e){var n;const i=null!==(n=e.r)&&void 0!==n?n:0;t.x=e.x,t.y=e.y,t.x0=e.x-i,t.x1=e.x+i,t.y0=e.y-i,t.y1=e.y+i,t.width=2*i,t.height=2*i,t.__radius=i}function Ao(t){let e=t.__orbitState;return e||(e={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},t.__orbitState=e),e}const So={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,i){const o=n.__hierarchyRoot;o&&function(t,e,n,i,o){var r,l;const a=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(n.childrenAccessor),c=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>{var n;return(null!==(n=t[e])&&void 0!==n?n:"")+""}}(n.nodeIDAccessor),u=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),d=null!==(r=n.orbitSize)&&void 0!==r?r:2.95,h=null!==(l=n.orbitEccentricity)&&void 0!==l?l:1,f="number"==typeof d?()=>d:d,g="number"==typeof h?()=>h:h,y=Ao(n);y.metaMap.clear(),i.length=0,o.length=0;const p=new Map;function v(t){var e;const n=null!==(e=p.get(t))&&void 0!==e?e:0;return p.set(t,n+1),0===n?t:`${t}__${n}`}const m=e[0]/2,x=e[1]/2,b=Math.min(e[0],e[1])/2*.85,k=v(c(t));i.push({id:k,x:m,y:x,x0:m,x1:m,y0:x,y1:x,width:0,height:0,value:0,depth:0,data:t}),y.metaMap.set(k,{ring:b,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,n,r,l,d,h,p){const m=a(e);if(!(null==m?void 0:m.length))return;const x=m.length;let b=0,k=0,w=0;for(;x>k;)k+=u[Math.min(w,u.length-1)],w++,b++;let A=0;for(let x=0;b>x;x++){const k=u[Math.min(x,u.length-1)],w=m.slice(A,A+k);if(!w.length)break;const S=(x+1)/b,M={id:n,depth:h,data:e,parentId:n},_=p?d/f(M)*S:d*S,j=s.pie().value(t=>{var e;return(null===(e=a(t))||void 0===e?void 0:e.length)?4:1}).sort(null),P=j(w),C=g(M);for(let e=0;w.length>e;e++){const s=(P[e].startAngle+P[e].endAngle)/2,a=w[e],u=v(c(a)),d=r+_*Math.sin(s),f=l+_*Math.cos(s)*C;i.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:h,data:a}),y.metaMap.set(u,{ring:_,angle:s,depth:h,parentId:n,eccentricity:C}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),t(a,u,d,f,_,h+1,!0)}A+=k}}(t,k,m,x,b,1,!1)}(o,i,n,t,e)},buildScene(t,e,n,i){var o,r,s,l,a,c,u;const d=n.nodeStyle,h=n.nodeSize,f="number"==typeof h?()=>h:"function"==typeof h?h:()=>6,g=[],y=[],p=[];if(!1!==n.orbitShowRings){const e=Ao(n),i=new Map;for(const e of t)i.set(e.id,e);const o=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=i.get(t.parentId);if(!e)continue;const n=`${t.parentId}:${t.ring}`;o.has(n)||o.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:i}]of o)for(let o=0;r>o;o++){const l=o/r*Math.PI*2,a=(o+1)/r*Math.PI*2;y.push({type:"line",x1:t+n*Math.sin(l),y1:e+n*Math.cos(l)*i,x2:t+n*Math.sin(a),y2:e+n*Math.cos(a)*i,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=f(to(e,"nodeSize")),i=d?d(to(e,"nodeStyle")):{},c={fill:i.fill||(null===(o=n.themeSemantic)||void 0===o?void 0:o.primary)||"#6366f1",stroke:i.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=i.strokeWidth)&&void 0!==s?s:1,opacity:null!==(l=i.opacity)&&void 0!==l?l:0===(null!==(a=e.depth)&&void 0!==a?a:0)?1:.85};g.push({type:"circle",cx:e.x,cy:e.y,r:t,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const v=new Map;for(const e of t)v.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:v.get(t.source),n="object"==typeof t.target?t.target:v.get(t.target);e&&n&&(null!=e.x&&null!=n.x&&y.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(n.showLabels){const e=n.nodeLabel;for(const n of t){const t=f(to(n,"nodeSize"));if(4>=t)continue;const i="function"==typeof e?e(n):e&&null!==(u=null===(c=n.data)||void 0===c?void 0:c[e])&&void 0!==u?u:n.id;p.push({x:n.x,y:n.y+t+12,text:i+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:g,sceneEdges:y,labels:p}},tick:(t,e,n,i,o)=>!1!==n.orbitAnimated&&(function(t,e){var n,i;const o=Ao(e),r=null!==(n=e.orbitSpeed)&&void 0!==n?n:.25,s=null!==(i=e.orbitRevolution)&&void 0!==i?i:function(t){switch(t){case"decay":return t=>{var e;return Math.pow(.6,null!==(e=t.depth)&&void 0!==e?e:0)};case"alternate":return t=>{var e;const n=null!==(e=t.depth)&&void 0!==e?e:0;return(n%2==0?1:-1)/(n+1)};default:return t=>{var e;return 1/((null!==(e=t.depth)&&void 0!==e?e:0)+1)}}}(e.orbitRevolutionStyle),l=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,a=r*(Math.PI/6),c=new Map;for(const e of t)c.set(e.id,e);for(const e of t){const t=o.metaMap.get(e.id);if(!t||!t.parentId)continue;const n=c.get(t.parentId);if(!n)continue;const i=t.angle+l*a*s({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=n.x+t.ring*Math.sin(i),e.y=n.y+t.ring*Math.cos(i)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,n),!0)},Mo={sankey:io,force:oo,chord:co,tree:xo,cluster:xo,treemap:xo,circlepack:xo,partition:xo,orbit:So};function _o(t){return Mo[t]}function jo(t){return 0===t.length?()=>"#4e79a7":e=>{var n;let i=0;for(let t=0;e.length>t;t++)i=31*i+e.charCodeAt(t)|0;return null!==(n=t[Math.abs(i)%t.length])&&void 0!==n?n:"#4e79a7"}}class Po{constructor(t){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.particlePool=null,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._lastPositionSnapshot=null,this.config=t,this.tensionConfig=Object.assign(Object.assign({},si),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&(this.particlePool=new ai(2e3))}updateConfig(t){const e=this.config;e.__orbitState&&(t.__orbitState=e.__orbitState),e.__hierarchyRoot&&(t.__hierarchyRoot=e.__hierarchyRoot),this.config=t,this.tensionConfig=Object.assign(Object.assign({},si),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&!this.particlePool&&(this.particlePool=new ai(2e3))}ingestHierarchy(t,e){this._boundedPrevSnapshot=new Map;for(const[t,e]of this.nodes)0===e.x0&&0===e.x1&&0===e.y0&&0===e.y1||this._boundedPrevSnapshot.set(t,{x0:e.x0,x1:e.x1,y0:e.y0,y1:e.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.config.__hierarchyRoot=t,this.runLayout(e),this._boundedPrevSnapshot=null}ingestBounded(t,e,n){const{nodeIDAccessor:i="id",sourceAccessor:o="source",targetAccessor:r="target",valueAccessor:s="value"}=this.config,l="function"==typeof i?i:t=>t[i],a="function"==typeof o?o:t=>t[o],c="function"==typeof r?r:t=>t[r],u="function"==typeof s?s:t=>{var e;return null!==(e=t[s])&&void 0!==e?e:1};this._boundedPrevSnapshot=new Map;for(const[t,e]of this.nodes)0===e.x0&&0===e.x1&&0===e.y0&&0===e.y1||this._boundedPrevSnapshot.set(t,{x0:e.x0,x1:e.x1,y0:e.y0,y1:e.y1});this._boundedEdgeSnapshot=new Map;for(const[,t]of this.edges)t.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,{y0:t.y0,y1:t.y1,sankeyWidth:t.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of t){const t=l(e)+"";this.nodes.set(t,Object.assign(Object.assign({},Co(t)),{data:e}))}for(let t=0;e.length>t;t++){const n=e[t],i=a(n)+"",o=c(n)+"",r=Number(u(n))||1;this.nodes.has(i)||this.nodes.set(i,Object.assign(Object.assign({},Co(i)),{data:n})),this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},Co(o)),{data:n}));const s=`${i}\0${o}\0${t}`;this.edges.set(s,{source:i,target:o,value:r,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:s})}this.runLayout(n)}edgeKey(t,e){return`${t}\0${e}`}ingestEdge(t){const{source:e,target:n,value:i}=t,o=0===this.nodes.size;let r=!1;const s="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=s,this._decaySortedNodes=null,this.nodes.has(e)||(this.nodes.set(e,Co(e)),this.nodeTimestamps.set(e,s),this.tension+=this.tensionConfig.newNode,r=!0),this.nodes.has(n)||(this.nodes.set(n,Co(n)),this.nodeTimestamps.set(n,s),this.tension+=this.tensionConfig.newNode,r=!0);const l=this.edgeKey(e,n),a=this.edges.get(l);let c=!1;return a?(a.value+=i,this.edgeTimestamps.set(l,s),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(l,{source:e,target:n,value:i,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(l,s),this.tension+=this.tensionConfig.newEdge,r=!0),o||r||c||this.tension>=this.tensionConfig.threshold}runLayout(t){var e,n,i,o,r,s,l,a;if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const c=_o(this.config.chartType);if(!c)return;let u=Array.from(this.nodes.values());const d=Array.from(this.edges.values());if(0===u.length&&!c.hierarchical)return;if(this.prepareForRelayout(),c.supportsStreaming&&!c.hierarchical){const t=new Map;for(const l of u)if(void 0!==l._prevX0){const a=(null!==(e=l._prevX1)&&void 0!==e?e:0)-(null!==(n=l._prevX0)&&void 0!==n?n:0),c=(null!==(i=l._prevY1)&&void 0!==i?i:0)-(null!==(o=l._prevY0)&&void 0!==o?o:0);t.set(l.id,{x:(null!==(r=l._prevX0)&&void 0!==r?r:0)+a/2,y:(null!==(s=l._prevY0)&&void 0!==s?s:0)+c/2})}else 0===l.x&&0===l.y||t.set(l.id,{x:l.x,y:l.y});if(this._lastPositionSnapshot)for(const[e,n]of this._lastPositionSnapshot)t.has(e)||t.set(e,n);this.config.__previousPositions=t.size>0?t:void 0}if(c.computeLayout(u,d,this.config,t),this.config.__previousPositions=void 0,c.hierarchical&&u.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const t of u)this.nodes.set(t.id,t);for(let t=0;d.length>t;t++){const e=d[t],n=e._edgeKey||`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}\0${t}`;e._edgeKey=n,this.edges.set(n,e)}const t=this._boundedPrevSnapshot;if(t&&t.size>0)for(const e of this.nodes.values()){const n=t.get(e.id);n&&(e._prevX0=n.x0,e._prevX1=n.x1,e._prevY0=n.y0,e._prevY1=n.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,u=Array.from(this.nodes.values())}this.finalizeLayout();const h=new Map;for(const t of this.nodes.values())0===t.x&&0===t.y||h.set(t.id,{x:t.x,y:t.y});this._lastPositionSnapshot=h,this.saveTargetPositions();const f=u.some(t=>void 0!==t._prevX0&&(0!==t._prevX0||0!==t._prevX1||0!==t._prevY0||0!==t._prevY1)),g=null!==(a=null===(l=this.config.transition)||void 0===l?void 0:l.duration)&&void 0!==a?a:this.tensionConfig.transitionDuration;if(!this._hasRenderedOnce&&this.config.introAnimation&&["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType)&&u.length>0&&g>0){const e=t[0]/2,n=t[1]/2;for(const t of this.nodes.values())t._prevX0=e,t._prevX1=e,t._prevY0=n,t._prevY1=n;for(const t of this.edges.values())t._prevY0=n,t._prevY1=n,t._prevSankeyWidth=0,t._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:g}}else f&&g>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:g});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const t=new Set(this.nodes.keys()),e=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of t)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)t.has(e)||this.removedNodes.add(e);for(const t of e)this.previousEdgeKeys.has(t)||this.addedEdges.add(t);for(const t of this.previousEdgeKeys)e.has(t)||this.removedEdges.add(t);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=t,this.previousEdgeKeys=e}buildScene(t){var e,n,i,o,r,s;const l=Array.from(this.nodes.values()),a=Array.from(this.edges.values());if(this.config.customNetworkLayout){const c=function(t,e,n){if(Array.isArray(t)&&t.length>0)return t;if("string"==typeof t){const e=ct[t];if(Array.isArray(e)&&e.length>0)return e}return e&&e.length>0?e:n}(this.config.colorScheme,this.config.themeCategorical,K),u={nodes:l,edges:a,dimensions:{width:t[0],height:t[1],plot:{x:0,y:0,width:t[0],height:t[1]}},theme:{semantic:null!==(e=this.config.themeSemantic)&&void 0!==e?e:{},categorical:[...c]},resolveColor:jo(c),config:null!==(n=this.config.layoutConfig)&&void 0!==n?n:{}};let d;try{d=this.config.customNetworkLayout(u)}catch(t){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",t),this.sceneNodes=[],this.sceneEdges=[],this.labels=[],void(this.customLayoutOverlays=null)}return this.sceneNodes=null!==(i=d.sceneNodes)&&void 0!==i?i:[],this.sceneEdges=null!==(o=d.sceneEdges)&&void 0!==o?o:[],this.labels=null!==(r=d.labels)&&void 0!==r?r:[],void(this.customLayoutOverlays=null!==(s=d.overlays)&&void 0!==s?s:null)}this.customLayoutOverlays=null;const c=_o(this.config.chartType);if(!c)return;const{sceneNodes:u,sceneEdges:d,labels:h}=c.buildScene(l,a,this.config,t);this.sceneNodes=u,this.sceneEdges=d,this.labels=h}get isAnimating(){const t=_o(this.config.chartType);return!!(null==t?void 0:t.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(t,e){const n=_o(this.config.chartType);if(!(null==n?void 0:n.tick))return!1;const i=Array.from(this.nodes.values()),o=Array.from(this.edges.values());return n.tick(i,o,this.config,t,e)}cancelIntroAnimation(){this.transition=null;for(const t of this.nodes.values())t._prevX0=void 0,t._prevX1=void 0,t._prevY0=void 0,t._prevY1=void 0;for(const t of this.edges.values())t._prevY0=void 0,t._prevY1=void 0,t._prevSankeyWidth=void 0,t._introFromZero=!1}advanceTransition(t){if(!this.transition)return!1;const e=yt(t,this.transition),n=gt(e);for(const t of this.nodes.values())void 0===t._targetX0||void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=pt(t._prevX0,t._targetX0,n),t.x1=pt(t._prevX1,t._targetX1,n),t.y0=pt(t._prevY0,t._targetY0,n),t.y1=pt(t._prevY1,t._targetY1,n));for(const t of this.edges.values())void 0!==t._targetY0&&void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&(t._prevSankeyWidth>0||t._introFromZero)&&(t.y0=pt(t._prevY0,t._targetY0,n),t.y1=pt(t._prevY1,t._targetY1,n),t.sankeyWidth=pt(t._prevSankeyWidth,t._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>e||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const t=this._boundedPrevSnapshot;for(const e of this.nodes.values()){const n=null==t?void 0:t.get(e.id);n&&0===e.x0&&0===e.x1&&0===e.y0&&0===e.y1?(e._prevX0=n.x0,e._prevX1=n.x1,e._prevY0=n.y0,e._prevY1=n.y1):(e._prevX0=e.x0,e._prevX1=e.x1,e._prevY0=e.y0,e._prevY1=e.y1)}const e=this._boundedEdgeSnapshot;for(const t of this.edges.values()){if(e&&0===t.sankeyWidth){const n=e.get(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`);if(n){t._prevY0=n.y0,t._prevY1=n.y1,t._prevSankeyWidth=n.sankeyWidth;continue}}t._prevY0=t.y0,t._prevY1=t.y1,t._prevSankeyWidth=t.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}finalizeLayout(){const t="vertical"===this.config.orientation?"down":"right";for(const t of this.nodes.values())if(0!==t.x0||0!==t.x1||0!==t.y0||0!==t.y1)t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;else{const e=5;t.x0=t.x-e,t.x1=t.x+e,t.y0=t.y-e,t.y1=t.y+e,t.width=2*e,t.height=2*e}for(const e of this.edges.values())e.direction=t,this.updateEdgeBezier(e);this.tension=0}saveTargetPositions(){for(const t of this.nodes.values())t._targetX0=t.x0,t._targetX1=t.x1,t._targetY0=t.y0,t._targetY1=t.y1;for(const t of this.edges.values())t._targetY0=t.y0,t._targetY1=t.y1,t._targetSankeyWidth=t.sankeyWidth}restorePreviousPositions(){for(const t of this.nodes.values())void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=t._prevX0,t.x1=t._prevX1,t.y0=t._prevY0,t.y1=t._prevY1);for(const t of this.edges.values())void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&t._prevSankeyWidth>0&&(t.y0=t._prevY0,t.y1=t._prevY1,t.sankeyWidth=t._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const t of this.nodes.values())void 0!==t._targetX0&&(t.x0=t._targetX0,t.x1=t._targetX1,t.y0=t._targetY0,t.y1=t._targetY1);for(const t of this.edges.values())void 0!==t._targetY0&&(t.y0=t._targetY0,t.y1=t._targetY1,t.sankeyWidth=t._targetSankeyWidth),t._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(t){const e="string"==typeof t.source?this.nodes.get(t.source):t.source,n="string"==typeof t.target?this.nodes.get(t.target):t.target;e&&n&&(t.bezier=t.circular&&t.circularPathData?this.buildCircularBezier(t):this.buildStandardBezier(t,e,n))}buildStandardBezier(t,e,n){const i=(t.sankeyWidth||1)/2;if("down"===t.direction){const o=e.x1,r=n.x0,s=u.interpolateNumber(o,r);return{circular:!1,points:[{x:t.y0,y:o},{x:t.y0,y:s(.5)},{x:t.y1,y:s(.5)},{x:t.y1,y:r}],halfWidth:i}}const o=e.x1,r=n.x0,s=u.interpolateNumber(o,r);return{circular:!1,points:[{x:o,y:t.y0},{x:s(.5),y:t.y0},{x:s(.5),y:t.y1},{x:r,y:t.y1}],halfWidth:i}}buildCircularBezier(t){const e=(t._circularWidth||t.sankeyWidth||1)/2,n=t.circularPathData;if(!n)throw Error("buildCircularBezier requires circularPathData");if(t._circularStub){const t=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),i=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*t,y:n.sourceY},{x:n.sourceX+.66*t,y:n.sourceY},{x:n.sourceX+t,y:n.sourceY}],[{x:n.targetX-i,y:n.targetY},{x:n.targetX-.66*i,y:n.targetY},{x:n.targetX-.33*i,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:e}}let i;i="down"===t.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const o=[];for(let t=0;i.length-1>t;t++){const e=i[t],n=i[t+1],r=n.x-e.x,s=n.y-e.y;o.push([e,{x:e.x+r/3,y:e.y+s/3},{x:e.x+2*r/3,y:e.y+2*s/3},n])}return{circular:!0,segments:o,halfWidth:e}}rebuildAllBeziers(){for(const t of this.nodes.values())t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;for(const t of this.edges.values())this.updateEdgeBezier(t)}applyPulse(t){var e,n,i,o,r;const s=this.config.pulse;if(!s)return;const l=null!==(e=s.duration)&&void 0!==e?e:500,a=null!==(n=s.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(i=s.glowRadius)&&void 0!==i?i:4;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const i=this.nodeTimestamps.get(n);if(!i)continue;const o=t-i;l>o&&(e._pulseIntensity=1-o/l,e._pulseColor=a,e._pulseGlowRadius=c)}for(const e of this.sceneEdges){const n=e.datum;if(!n)continue;const i="object"==typeof n.source?null===(o=n.source)||void 0===o?void 0:o.id:n.source,s="object"==typeof n.target?null===(r=n.target)||void 0===r?void 0:r.id:n.target;if(!i||!s)continue;const c=this.edgeTimestamps.get(`${i}\0${s}`);if(!c)continue;const u=t-c;l>u&&(e._pulseIntensity=1-u/l,e._pulseColor=a)}}applyDecay(){var t,e;const n=this.config.decay;if(!n)return;const i=this.nodeTimestamps.size;if(1>=i)return;this._decaySortedNodes||(this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((t,e)=>t[1]-e[1]));const o=this._decaySortedNodes,r=new Map;for(let t=0;o.length>t;t++)r.set(o[t][0],t);for(const o of this.sceneNodes){const s=o.id;if(!s)continue;const l=r.get(s);if(void 0===l)continue;const a=ht(n,l,i),c=null!==(e=null===(t=o.style)||void 0===t?void 0:t.opacity)&&void 0!==e?e:1;o.style=Object.assign(Object.assign({},o.style),{opacity:c*a})}}applyTopologyDiff(t){var e;if(0===this.addedNodes.size)return;const n=t-this.lastTopologyChangeTime;if(n>=2e3)return;const i=1-n/2e3;for(const t of this.sceneNodes){const n=t.id;n&&this.addedNodes.has(n)&&(t._pulseIntensity=Math.max(null!==(e=t._pulseIntensity)&&void 0!==e?e:0,i),t._pulseColor="rgba(34, 197, 94, 0.7)",t._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(t){var e,n;const i=this.config.thresholds;if(!i)return;const o=null!==(e=i.warningColor)&&void 0!==e?e:"#f59e0b",r=null!==(n=i.criticalColor)&&void 0!==n?n:"#ef4444",s=!1!==i.pulse;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const l=this.nodes.get(n);if(!l)continue;const a=i.metric(l);let c=null;void 0===i.critical||i.critical>a?void 0===i.warning||i.warning>a||(c=o):c=r,c&&(e.style=Object.assign(Object.assign({},e.style),{fill:c}),s&&(e._pulseIntensity=.6+.4*Math.sin(t/300),e._pulseColor=c,e._pulseGlowRadius=6))}}get hasActiveThresholds(){const t=this.config.thresholds;if(!t)return!1;for(const e of this.nodes.values()){const n=t.metric(e);if(void 0!==t.warning&&n>=t.warning||void 0!==t.critical&&n>=t.critical)return!0}return!1}get hasActivePulses(){var t;const e=this.config.pulse;if(!e||0===this.lastIngestTime)return!1;const n="undefined"!=typeof performance?performance.now():Date.now();return(null!==(t=e.duration)&&void 0!==t?t:500)>n-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(t,e){var n;const i=this.nodes.get(t);if(!i)return null;const o=i.data?Object.assign({},i.data):{};return i.data=e(null!==(n=i.data)&&void 0!==n?n:{}),this.layoutVersion++,o}updateEdge(t,e,n){var i;const o=this.config.valueAccessor,r="function"==typeof o?o:o?t=>t[o]:t=>t.value,s=[];for(const[,o]of this.edges)if(("string"==typeof o.source?o.source:o.source.id)===t&&("string"==typeof o.target?o.target:o.target.id)===e){s.push(o.data?Object.assign({},o.data):{}),o.data=n(null!==(i=o.data)&&void 0!==i?i:{});const t=r(o.data);null!=t&&(o.value=Number(t))}return s.length>0&&this.layoutVersion++,s}removeNode(t){if(!this.nodes.has(t))return!1;this.nodes.delete(t),this.nodeTimestamps.delete(t);for(const[e,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==t&&("string"==typeof n.target?n.target:n.target.id)!==t||(this.edges.delete(e),this.edgeTimestamps.delete(e));return this.layoutVersion++,!0}removeEdge(t,e){const n=[];if(void 0===e){const e=this.config.edgeIdAccessor;if(!e)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const i="function"==typeof e?e:t=>null==t?void 0:t[e];for(const[e,o]of this.edges)o.data&&i(o.data)===t&&n.push(e)}else for(const[i,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===t&&("string"==typeof o.target?o.target:o.target.id)===e&&n.push(i);for(const t of n)this.edges.delete(t),this.edgeTimestamps.delete(t);return n.length>0&&this.layoutVersion++,n.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function Co(t){return{id:t,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function Eo(t,e,n,i,o=30){let r=null,s=o,l=1/0;for(const e of t){const t=Lo(e,n,i,o);if(t)if("rect"===e.type){const n=e.w*e.h;l>n&&(r=t,l=n)}else s>t.distance&&(r=t,s=t.distance)}if(r)return r;for(const t of e){const e=Io(t,n,i);e&&s>e.distance&&(r=e,s=e.distance)}return r}function Lo(t,e,n,i=30){switch(t.type){case"circle":return function(t,e,n,i=30){const o=e-t.cx,r=n-t.cy,s=Math.sqrt(o*o+r*r);return s>Mt(t.r,i)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:s}}(t,e,n,i);case"rect":return function(t,e,n){const i=St(e,n,t);return i.hit?{type:"node",datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}(t,e,n);case"arc":return function(t,e,n){const i=e-t.cx,o=n-t.cy,r=Math.sqrt(i*i+o*o);if(t.innerR-2>r||r>t.outerR+2)return null;const s=Pt(Math.atan2(o,i)),l=Pt(t.startAngle),a=Pt(t.endAngle);if(l>a?s>=l||a>=s:s>=l&&a>=s){const e=(t.startAngle+t.endAngle)/2,n=(t.innerR+t.outerR)/2;return{type:"node",datum:t.datum,x:t.cx+n*Math.cos(e),y:t.cy+n*Math.sin(e),distance:0}}return null}(t,e,n);default:return null}}let Oo=null,To=null;function Do(){return To||(Oo=document.createElement("canvas"),Oo.width=1,Oo.height=1,To=Oo.getContext("2d")),To}function Ro(t){if(t._cachedPath2D&&t._cachedPath2DSource===t.pathD)return t._cachedPath2D;try{return t._cachedPath2D=new Path2D(t.pathD),t._cachedPath2DSource=t.pathD,t._cachedPath2D}catch(t){return null}}function Io(t,e,n){switch(t.type){case"bezier":return function(t,e,n){var i,o;if(!t.pathD)return null;const r=Ro(t),s=Do();if(!r||!s)return null;try{if(s.isPointInPath(r,e,n)){const r="object"==typeof(null===(i=t.datum)||void 0===i?void 0:i.source)?t.datum.source:null,s="object"==typeof(null===(o=t.datum)||void 0===o?void 0:o.target)?t.datum.target:null;return{type:"edge",datum:t.datum,x:r&&s?(r.x1+s.x0)/2:e,y:t.datum?(t.datum.y0+t.datum.y1)/2:n,distance:0}}const l=s.lineWidth;s.lineWidth=10;const a=s.isPointInStroke(r,e,n);if(s.lineWidth=l,a)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch(t){}return null}(t,e,n);case"line":return function(t,e,n){const i=t.x2-t.x1,o=t.y2-t.y1,r=i*i+o*o;if(0===r)return null;let s=((e-t.x1)*i+(n-t.y1)*o)/r;s=Math.max(0,Math.min(1,s));const l=t.x1+s*i,a=t.y1+s*o,c=Math.sqrt(Math.pow(e-l,2)+Math.pow(n-a,2));return c>5?null:{type:"edge",datum:t.datum,x:l,y:a,distance:c}}(t,e,n);case"ribbon":case"curved":return function(t,e,n){if(!t.pathD)return null;const i=Ro(t),o=Do();if(!i||!o)return null;try{if(o.isPointInPath(i,e,n))return{type:"edge",datum:t.datum,x:e,y:n,distance:0};const r=o.lineWidth;o.lineWidth=10;const s=o.isPointInStroke(i,e,n);if(o.lineWidth=r,s)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch(t){}return null}(t,e,n);default:return null}}function $o(e){const{width:n,height:i,totalWidth:o,totalHeight:r,margin:s,labels:l,title:a,legend:c,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f,legendPosition:g="right",foregroundGraphics:p,sceneNodes:v,annotations:m,svgAnnotationRules:x}=e;return t.jsxs(t.Fragment,{children:[t.jsxs("svg",{role:"img",width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[t.jsx("title",{children:"string"==typeof a?a:"Network Chart"}),t.jsx("desc",{children:"string"==typeof a?a+" — network data visualization":"Network data visualization"}),t.jsxs("g",{transform:`translate(${s.left},${s.top})`,children:[l.map((e,n)=>t.jsx("text",{x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"currentColor",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"},children:e.text},"label-"+n)),m&&m.filter(t=>"widget"!==t.type).map((e,o)=>{if(x){const r=x(e,o,{width:n,height:i,sceneNodes:v});if(r)return t.jsx(y.Fragment,{children:r},"annotation-"+o)}return null}),p]}),a&&"string"==typeof a?t.jsx("text",{x:o/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor",children:a}):a?t.jsx("foreignObject",{x:0,y:0,width:o,height:s.top,children:a}):null,ye({legend:c,totalWidth:o,totalHeight:r,margin:s,legendPosition:g,title:a,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f})]}),null==m?void 0:m.filter(t=>"widget"===t.type&&t.nodeId&&v).map((e,n)=>{var i,o,r,l,a,c,u,d,h;const f=v.find(t=>{var n,i,o,r,s;return t.id===e.nodeId||(null===(n=t.datum)||void 0===n?void 0:n.id)===e.nodeId||(null===(o=null===(i=t.datum)||void 0===i?void 0:i.data)||void 0===o?void 0:o.id)===e.nodeId||(null===(s=null===(r=t.datum)||void 0===r?void 0:r.data)||void 0===s?void 0:s.name)===e.nodeId});if(!f)return null;const g=s.left+(null!==(i=f.cx)&&void 0!==i?i:null!=f.x&&null!=f.w?f.x+f.w/2:null!==(o=f.x)&&void 0!==o?o:0),y=s.top+(null!==(r=f.cy)&&void 0!==r?r:null!=f.y&&null!=f.h?f.y+f.h/2:null!==(l=f.y)&&void 0!==l?l:0),p=null!==(a=e.dx)&&void 0!==a?a:0,m=null!==(c=e.dy)&&void 0!==c?c:-16,x=null!==(u=e.width)&&void 0!==u?u:32,b=null!==(d=e.height)&&void 0!==d?d:32,k=null!==(h=e.content)&&void 0!==h?h:t.jsx("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return t.jsx("div",{style:{position:"absolute",left:g+p-x/2,top:y+m-b/2,width:x,height:b,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5},children:k},"widget-"+n)})]})}function No(t){return t._cachedPath2D&&t._cachedPath2DSource===t.pathD||(t._cachedPath2D=new Path2D(t.pathD),t._cachedPath2DSource=t.pathD),t._cachedPath2D}function Wo(t,e){var n,i,o,r,s,l;if(!e.pathD)return;t.save();const a=No(e);if(e.style.fill&&"none"!==e.style.fill){const s=e._gradient;if(s){const o=t.createLinearGradient(s.x0,0,s.x1,0),r=null!==(i=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==i?i:.5,l="string"==typeof e.style.fill?e.style.fill:"#999",a=It(t,l)||l;o.addColorStop(0,1===s.from?a:"transparent"),o.addColorStop(1,1===s.to?a:"transparent"),t.fillStyle=o,t.globalAlpha=r}else t.fillStyle="string"==typeof e.style.fill&&It(t,e.style.fill)||e.style.fill,t.globalAlpha=null!==(r=null!==(o=e.style.fillOpacity)&&void 0!==o?o:e.style.opacity)&&void 0!==r?r:.5;t.fill(a)}e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=It(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(s=e.style.strokeWidth)&&void 0!==s?s:.5,t.globalAlpha=.5*(null!==(l=e.style.opacity)&&void 0!==l?l:1),t.stroke(a)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.2*e._pulseIntensity,t.fill(a)),t.restore()}function zo(t,e){var n,i;t.save();const o=e.style.stroke||"#999";t.strokeStyle=It(t,o)||o,t.lineWidth=null!==(n=e.style.strokeWidth)&&void 0!==n?n:1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.strokeDasharray&&t.setLineDash(e.style.strokeDasharray.split(/[\s,]+/).map(Number)),t.beginPath(),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.stroke(),e._pulseIntensity&&e._pulseIntensity>0&&(t.setLineDash([]),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=(null!==(i=e.style.strokeWidth)&&void 0!==i?i:1)+3*e._pulseIntensity,t.globalAlpha=.4*e._pulseIntensity,t.beginPath(),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.stroke()),t.restore()}function Yo(t,e){var n,i,o,r;if(!e.pathD)return;t.save();const s=No(e);e.style.fill&&"none"!==e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&It(t,e.style.fill)||e.style.fill,t.globalAlpha=null!==(i=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==i?i:.5,t.fill(s)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=It(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(o=e.style.strokeWidth)&&void 0!==o?o:.5,t.globalAlpha=.3*(null!==(r=e.style.opacity)&&void 0!==r?r:1),t.stroke(s)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.25*e._pulseIntensity,t.fill(s)),t.restore()}function Fo(t,e){var n,i;if(!e.pathD)return;t.save();const o=No(e),r=e.style.stroke||"#999";t.strokeStyle=It(t,r)||r,t.lineWidth=null!==(n=e.style.strokeWidth)&&void 0!==n?n:1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.stroke(o),e.style.fill&&"none"!==e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&It(t,e.style.fill)||e.style.fill,t.globalAlpha=null!==(i=e.style.fillOpacity)&&void 0!==i?i:.1,t.fill(o)),t.restore()}$o.displayName="NetworkSVGOverlay";const Bo={top:20,right:80,bottom:20,left:80},Ho={top:40,right:40,bottom:40,left:40},Xo=new Set(["chord","force","circlepack","orbit"]),Go=[800,600],Vo={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function qo({data:e}){var n,i,o,r,s,l;if("edge"===e.nodeOrEdge){const n=e.data;return n?t.jsxs("div",{className:"semiotic-tooltip",style:Vo,children:[t.jsxs("div",{style:{fontWeight:600},children:["object"==typeof n.source?n.source.id:n.source," → ","object"==typeof n.target?n.target.id:n.target]}),null!=n.value&&t.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof n.value?n.value.toLocaleString():n.value+""]})]}):null}const a=e.data;if(!a)return null;const c=a.__hierarchyNode;if(c){const e=[];let s=c;for(;s;){const t=null!==(r=null!==(i=null===(n=s.data)||void 0===n?void 0:n.name)&&void 0!==i?i:null===(o=s.data)||void 0===o?void 0:o.id)&&void 0!==r?r:a.id;null!=t&&e.unshift(t+""),s=s.parent}e.length>1&&e.shift();const l=e.length-1;return t.jsxs("div",{className:"semiotic-tooltip",style:Vo,children:[t.jsx("div",{children:e.map((e,n)=>t.jsxs("span",{children:[n>0&&t.jsx("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),n===l?t.jsx("strong",{children:e}):t.jsx("span",{style:{opacity:.7},children:e})]},n))}),null!=a.value&&a.value>0&&t.jsx("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof a.value?a.value.toLocaleString():a.value+""})]})}const u=((null===(s=a.sourceLinks)||void 0===s?void 0:s.length)||0)+((null===(l=a.targetLinks)||void 0===l?void 0:l.length)||0),d=(a.sourceLinks||[]).reduce((t,e)=>t+(e.value||0),0)+(a.targetLinks||[]).reduce((t,e)=>t+(e.value||0),0);return t.jsxs("div",{className:"semiotic-tooltip",style:Vo,children:[t.jsx("div",{style:{fontWeight:600},children:a.id}),null!=a.value&&a.value>0&&t.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof a.value?a.value.toLocaleString():a.value+""]}),u>0&&t.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",u,d!==u&&` (weighted: ${d.toLocaleString()})`]})]})}const Uo=e.forwardRef(function(n,i){var o,r,l,a,c,u,d,h,f,g,y,p,v,m,x,b,w,A;const{chartType:S,nodes:_,edges:j,data:P,initialEdges:C,nodeIDAccessor:E="id",sourceAccessor:L="source",targetAccessor:O="target",valueAccessor:T="value",edgeIdAccessor:D,childrenAccessor:R,hierarchySum:I,orientation:$="horizontal",nodeAlign:N="justify",nodePaddingRatio:W=.05,nodeWidth:z=15,iterations:Y=300,forceStrength:F=.1,padAngle:B=.01,groupWidth:H=20,sortGroups:X,edgeSort:G,treeOrientation:V="vertical",edgeType:q="curve",padding:U,paddingTop:K,tensionConfig:Z,showParticles:Q=!1,particleStyle:J,nodeStyle:tt,edgeStyle:et,colorBy:nt,colorScheme:it="category10",edgeColorBy:ot="source",edgeOpacity:rt=.5,colorByDepth:st=!1,nodeSize:lt=8,nodeSizeRange:at=[5,20],nodeLabel:ct,showLabels:dt=!0,labelMode:ht,size:ft=Go,responsiveWidth:gt,responsiveHeight:yt,margin:pt,className:vt,background:mt,enableHover:xt=!0,tooltipContent:bt,customHoverBehavior:kt,customClickBehavior:wt,onObservation:St,chartId:Mt,onTopologyChange:_t,annotations:jt,svgAnnotationRules:Pt,legend:Ct,legendPosition:Et,legendHoverBehavior:Lt,legendClickBehavior:Ot,legendHighlightedCategory:Tt,legendIsolatedCategories:Dt,title:Rt,foregroundGraphics:$t,backgroundGraphics:Nt,decay:Wt,pulse:zt,transition:Yt,animate:Ft,staleness:Bt,thresholds:Ht,accessibleTable:Xt=!0,description:Gt,summary:Vt,orbitMode:qt,orbitSize:Ut,orbitSpeed:Kt,orbitRevolution:Zt,orbitRevolutionStyle:Qt,orbitEccentricity:ne,orbitShowRings:oe,orbitAnimated:se,customNetworkLayout:le,layoutConfig:ae}=n,ce=Xo.has(S)?Ho:Bo,ue=e.useRef(!0),de=En({sizeProp:ft,responsiveWidth:gt,responsiveHeight:yt,userMargin:pt,marginDefault:ce,foregroundGraphics:$t,backgroundGraphics:Nt,animate:Ft,transitionProp:Yt,themeDirtyRef:ue}),{reducedMotionRef:he,responsiveRef:fe,size:ge,margin:ye,adjustedWidth:pe,adjustedHeight:ve,resolvedForeground:me,resolvedBackground:xe,transition:be,introEnabled:ke,tableId:we,rafRef:Ae,renderFnRef:Se,scheduleRender:Me,currentTheme:_e}=de,je=Ke(),Pe=tn(),Ce=e.useMemo(()=>k(_),[_]),Ee=e.useMemo(()=>Array.isArray(j)?k(j):j,[j]),Le=e.useMemo(()=>Object.assign(Object.assign({},si),Z),[Z]),Oe=e.useMemo(()=>Object.assign(Object.assign({},li),J),[J]),Te=e.useMemo(()=>{var t;return{chartType:S,nodeIDAccessor:E,sourceAccessor:L,targetAccessor:O,valueAccessor:T,edgeIdAccessor:D,childrenAccessor:R,hierarchySum:I,orientation:$,nodeAlign:N,nodePaddingRatio:W,nodeWidth:z,iterations:Y,forceStrength:F,padAngle:B,groupWidth:H,sortGroups:X,edgeSort:G,treeOrientation:V,edgeType:q,padding:U,paddingTop:K,tensionConfig:Le,showParticles:Q,particleStyle:Oe,nodeStyle:tt,edgeStyle:et,nodeLabel:ct,showLabels:dt,labelMode:ht,colorBy:nt,colorScheme:it,themeCategorical:null===(t=null==_e?void 0:_e.colors)||void 0===t?void 0:t.categorical,themeSemantic:M(_e),edgeColorBy:ot,edgeOpacity:rt,colorByDepth:st,nodeSize:lt,nodeSizeRange:at,decay:Wt,pulse:zt,transition:be,introAnimation:ke,staleness:Bt,thresholds:Ht,orbitMode:qt,orbitSize:Ut,orbitSpeed:Kt,orbitRevolution:Zt,orbitRevolutionStyle:Qt,orbitEccentricity:ne,orbitShowRings:oe,orbitAnimated:se,customNetworkLayout:le,layoutConfig:ae}},[S,E,L,O,T,R,I,$,N,W,z,Y,F,B,H,X,G,V,q,U,K,Le,Q,Oe,tt,et,ct,dt,ht,nt,it,ot,rt,st,lt,at,Wt,zt,null==be?void 0:be.duration,null==be?void 0:be.easing,ke,Bt,Ht,qt,Ut,Kt,Zt,Qt,ne,oe,se,_e,le,ae]),De=nn(Te),Re=e.useRef(null),Ie=e.useRef(0),$e=e.useRef(0),Ne=e.useRef(!1),We=e.useRef(null);We.current||(We.current=new Po(De));const[ze,Ye]=e.useState(null),[Fe,Be]=e.useState(0),[He,Xe]=e.useState(0),[Ue,Ze]=e.useState(!1),[Qe,Je]=e.useState(null),on=e.useRef(null),rn=e.useRef(new Map),sn=e.useRef(0),ln=e.useCallback(t=>{if("function"==typeof nt)return nt(t)+"";if("string"==typeof nt&&t.data){const e=t.data[nt];if(void 0!==e){if(!rn.current.has(e+"")){const t=Array.isArray(it)?it:ut;rn.current.set(e+"",t[sn.current++%t.length])}return rn.current.get(e+"")}}if(rn.current.has(t.id))return rn.current.get(t.id);const e=Array.isArray(it)?it:ut,n=nt?e[sn.current++%e.length]:e[0];return rn.current.set(t.id,n),n},[nt,it]),an=(null===(o=null==_e?void 0:_e.colors)||void 0===o?void 0:o.border)||(null===(r=null==_e?void 0:_e.colors)||void 0===r?void 0:r.secondary)||(null===(l=null==_e?void 0:_e.colors)||void 0===l?void 0:l.primary)||"#999",cn=e.useCallback(t=>{if("function"==typeof ot)return ot(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===ot&&n?ln(n):e?ln(e):an},[ot,ln,an]),un=e.useCallback(t=>{if(!(null==J?void 0:J.colorBy))return cn(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===Oe.colorBy&&n?ln(n):e?ln(e):an},[null==J?void 0:J.colorBy,Oe.colorBy,ln,cn,an]),hn="sankey"===S&&Q||!!zt||null!==(c=null===(a=We.current)||void 0===a?void 0:a.isAnimating)&&void 0!==c&&c;e.useEffect(()=>{var t;null===(t=We.current)||void 0===t||t.updateConfig(De),ue.current=!0,Me()},[De,Me]);const fn=e.useCallback(()=>{var t,e;Je(null!==(e=null===(t=We.current)||void 0===t?void 0:t.customLayoutOverlays)&&void 0!==e?e:null)},[]);e.useEffect(()=>{var t;const e=We.current;if(e){e.buildScene([pe,ve]),fn();for(const n of e.sceneNodes)n.id&&"string"==typeof(null===(t=n.style)||void 0===t?void 0:t.fill)&&rn.current.set(n.id,n.style.fill);ue.current=!0,Me()}},[_e,pe,ve,Me,fn]);const gn=e.useCallback(()=>{var t;const e=We.current;if(!e)return;e.runLayout([pe,ve]),e.buildScene([pe,ve]),fn(),ue.current=!0;for(const n of e.sceneNodes)n.id&&"string"==typeof(null===(t=n.style)||void 0===t?void 0:t.fill)&&rn.current.set(n.id,n.style.fill);const n=Array.isArray(it)?it:ut,i=Array.from(e.nodes.values());for(let t=0;i.length>t;t++){const e=i[t];rn.current.has(e.id)||rn.current.set(e.id,n[t%n.length])}if(sn.current=i.length,Be(e.layoutVersion),_t){const{nodes:t,edges:n}=e.getLayoutData();_t(t,n)}},[pe,ve,_t,it,fn]),yn=e.useCallback(t=>{if(null==t||"object"!=typeof t)return;const e=We.current;e&&(e.ingestEdge(t)&&gn(),Me())},[gn,Me]),pn=e.useCallback(t=>{const e=We.current;if(!e)return;let n=!1;for(const i of t)null!=i&&"object"==typeof i&&e.ingestEdge(i)&&(n=!0);n&&gn(),Me()},[gn,Me]),vn=e.useCallback(()=>{var t;null===(t=We.current)||void 0===t||t.clear(),rn.current.clear(),sn.current=0,Be(0),Ye(null),on.current=null,ue.current=!0,Me()},[Me]),mn=e.useCallback(()=>{const t=We.current;t&&(t.tension+=999,gn(),Me())},[gn,Me]);e.useImperativeHandle(i,()=>({push:yn,pushMany:pn,removeNode:t=>{var e,n,i;const o=null!==(n=null===(e=We.current)||void 0===e?void 0:e.removeNode(t))&&void 0!==n&&n;if(o){const e=(null===(i=on.current)||void 0===i?void 0:i.data)?"function"==typeof E?E(on.current.data):on.current.data[E]:void 0;on.current&&"node"===on.current.nodeOrEdge&&e===t&&(on.current=null,Ye(null)),rn.current.delete(t),gn(),ue.current=!0,Me()}return o},removeEdge:(t,e)=>{var n,i;const o=null!==(i=null===(n=We.current)||void 0===n?void 0:n.removeEdge(t,e))&&void 0!==i&&i;if(o){if(on.current&&"edge"===on.current.nodeOrEdge){const n=on.current.data;let i;i=void 0!==e?("object"==typeof(null==n?void 0:n.source)?n.source.id:null==n?void 0:n.source)===t&&("object"==typeof(null==n?void 0:n.target)?n.target.id:null==n?void 0:n.target)===e:!D||!n||("function"==typeof D?D:t=>null==t?void 0:t[D])(n)===t,i&&(on.current=null,Ye(null))}gn(),ue.current=!0,Me()}return o},updateNode:(t,e)=>{var n,i;const o=null!==(i=null===(n=We.current)||void 0===n?void 0:n.updateNode(t,e))&&void 0!==i?i:null;return o&&(ue.current=!0,Me()),o},updateEdge:(t,e,n)=>{var i,o;const r=null!==(o=null===(i=We.current)||void 0===i?void 0:i.updateEdge(t,e,n))&&void 0!==o?o:[];return r.length>0&&(gn(),ue.current=!0,Me()),r},clear:vn,getTopology:()=>{var t,e;return null!==(e=null===(t=We.current)||void 0===t?void 0:t.getLayoutData())&&void 0!==e?e:{nodes:[],edges:[]}},getTopologyDiff:()=>{const t=We.current;return t?{addedNodes:Array.from(t.addedNodes),removedNodes:Array.from(t.removedNodes),addedEdges:Array.from(t.addedEdges),removedEdges:Array.from(t.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:mn,getTension:()=>{var t,e;return null!==(e=null===(t=We.current)||void 0===t?void 0:t.tension)&&void 0!==e?e:0}}),[yn,pn,vn,mn,gn,Me]);const xn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(S),bn=xn?P||(Array.isArray(j)?void 0:j):void 0;e.useEffect(()=>{var t;const e=We.current;if(e)if(xn&&bn)e.ingestHierarchy(bn,[pe,ve]),e.buildScene([pe,ve]),fn(),ue.current=!0,Me();else{const n=Ce,i=Array.isArray(Ee)?Ee:[];if(0===n.length&&0===i.length)return;e.ingestBounded(n,i,[pe,ve]),e.buildScene([pe,ve]),fn();for(const n of e.sceneNodes)n.id&&(null===(t=n.style)||void 0===t?void 0:t.fill)&&rn.current.set(n.id,n.style.fill+"");const o=Array.isArray(it)?it:ut,r=Array.from(e.nodes.values());for(let t=0;r.length>t;t++){const e=r[t];rn.current.has(e.id)||rn.current.set(e.id,o[t%o.length])}sn.current=r.length,ue.current=!0,Me()}},[Ce,Ee,P,bn,xn,pe,ve,De,Me,it,fn]),e.useEffect(()=>{C&&C.length>0&&pn(C)},[]);const Mn=e.useCallback(t=>{if(kt&&kt(t),St){const e=Date.now();St(t?{type:"hover",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:Mt}:{type:"hover-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:Mt})}},[kt,St,Mt]),Pn=e.useCallback(t=>{if(wt&&wt(t),St){const e=Date.now();St(t?{type:"click",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:Mt}:{type:"click-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:Mt})}},[wt,St,Mt]),{hoverHandlerRef:Cn,hoverLeaveRef:Tn,onPointerMove:Dn,onPointerLeave:Rn}=de;Cn.current=t=>{if(!xt)return;const e=Re.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-ye.left,o=t.clientY-n.top-ye.top;if(0>i||i>pe||0>o||o>ve)return void(on.current&&(on.current=null,Ye(null),Mn&&(Mn(null),ue.current=!0),Me()));const r=We.current;if(!r)return;const s=Eo(r.sceneNodes,r.sceneEdges,i,o);if(!s)return void(on.current&&(on.current=null,Ye(null),Mn&&(Mn(null),ue.current=!0),Me()));const l=Gn(s.datum||{},s.x,s.y,{nodeOrEdge:s.type});on.current=l,Ye(l),Mn&&(Mn(l),ue.current=!0),Me()},Tn.current=()=>{on.current&&(on.current=null,Ye(null),Mn&&(Mn(null),ue.current=!0),Me())};const In=e.useRef(()=>{});In.current=t=>{if(!wt&&!St)return;const e=Re.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-ye.left,o=t.clientY-n.top-ye.top;if(0>i||i>pe||0>o||o>ve)return;const r=We.current;if(!r)return;const s=Eo(r.sceneNodes,r.sceneEdges,i,o);Pn(s?Gn(s.datum||{},s.x,s.y,{nodeOrEdge:s.type}):null)};const Wn=e.useCallback(t=>In.current(t),[]),zn=e.useRef(-1),Yn=e.useRef(null),Fn=e.useRef(-1),Bn=e.useCallback(t=>{var e;const n=We.current;if(!n)return;const i=function(t){var e,n,i,o,r,s;const l=[];for(const a of t)"circle"===a.type&&null!=a.cx?l.push({x:a.cx,y:a.cy,datum:a.datum,shape:"circle",group:null!==(n=null===(e=a.datum)||void 0===e?void 0:e.id)&&void 0!==n?n:"_default"}):"rect"===a.type&&null!=a.x?l.push({x:a.x+a.w/2,y:a.y+a.h/2,datum:a.datum,shape:"rect",w:a.w,h:a.h,group:null!==(o=null===(i=a.datum)||void 0===i?void 0:i.id)&&void 0!==o?o:"_default"}):"arc"===a.type&&null!=a.cx&&l.push({x:a.cx,y:a.cy,datum:a.datum,shape:"circle",group:null!==(s=null===(r=a.datum)||void 0===r?void 0:r.id)&&void 0!==s?s:"_default"});return l.sort((t,e)=>t.x-e.x||t.y-e.y),l}(n.sceneNodes);if(0===i.length)return;const o=Jt(i),r=zn.current;if(0>r){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(t.key))return;t.preventDefault(),zn.current=0,Fn.current=-1;const e=o.flat[0];Yn.current={shape:e.shape,w:e.w,h:e.h};const n=Gn(e.datum||{},e.x,e.y,{nodeOrEdge:"node"});return on.current=n,Ye(n),Mn&&(Mn(n),ue.current=!0),void Me()}const s=te(o,r),l=function(t,e,n,i,o){var r,s,l;const a=n.flat[e.flatIndex];if(!a)return ee(t,e,n);const c=null===(r=a.datum)||void 0===r?void 0:r.id;switch(t){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const i=null!==(s=function(t,e,n){let i=null,o=1/0;for(let r=0;t.flat.length>r;r++){const s=t.flat[r];if(s===e)continue;const l=s.x-e.x,a=s.y-e.y;let c=!1;switch(n){case"right":c=l>0&&Math.abs(l)>=Math.abs(a);break;case"left":c=0>l&&Math.abs(l)>=Math.abs(a);break;case"down":c=a>0&&Math.abs(a)>=Math.abs(l);break;case"up":c=0>a&&Math.abs(a)>=Math.abs(l)}if(!c)continue;const u=l*l+a*a;o>u&&(o=u,i=r)}return i}(n,a,"ArrowRight"===t?"right":"ArrowLeft"===t?"left":"ArrowDown"===t?"down":"up"))&&void 0!==s?s:e.flatIndex;return i!==e.flatIndex&&(o.current=-1),i}case"Enter":{if(null==c)return e.flatIndex;const t=function(t,e){var n;const i=t+"",o=[];for(const t of e){const e=null!==(n=t.datum)&&void 0!==n?n:t,r=ie(e.source),s=ie(e.target),l=null!=r,a=null!=s;l&&r+""===i&&a?o.push(s+""):a&&s+""===i&&l&&o.push(r+"")}return o}(c,i);if(0===t.length)return e.flatIndex;const r=null!==(l=n.idToIdx.get(t[(o.current+1)%t.length]))&&void 0!==l?l:-1;return 0>r?e.flatIndex:(o.current=-1,r)}default:{const i=ee(t,e,n);return null!==i&&i!==e.flatIndex&&(o.current=-1),i}}}(t.key,s,o,null!==(e=n.sceneEdges)&&void 0!==e?e:[],Fn);if(null===l)return;if(t.preventDefault(),0>l)return zn.current=-1,Yn.current=null,Fn.current=-1,on.current=null,Ye(null),Mn&&(Mn(null),ue.current=!0),void Me();zn.current=l;const a=o.flat[l];Yn.current={shape:a.shape,w:a.w,h:a.h};const c={data:a.datum||{},x:a.x,y:a.y,__semioticHoverData:!0,nodeOrEdge:"node"};on.current=c,Ye(c),Mn&&(Mn(c),ue.current=!0),Me()},[Mn,Me]),Hn=e.useCallback(t=>{zn.current=-1,Yn.current=null,Dn(t)},[Dn]);Se.current=()=>{var t,e,n,i,o,r,s;Ae.current=0;const l=Re.current;if(!l)return;const a=l.getContext("2d");if(!a)return;const c=We.current;if(!c)return;const u=performance.now(),d=Ie.current?Math.min((u-Ie.current)/1e3,.1):.016;Ie.current=u;const h=c.advanceTransition(he.current?u+1e6:u),f=!he.current&&h,g=!he.current&&c.tickAnimation([pe,ve],d);(h||ue.current||g)&&c.buildScene([pe,ve]);const y=On();if(!Ln(l,ge,ye,y))return;if(a.clearRect(-ye.left,-ye.top,ge[0],ge[1]),mt){const t=It(a,mt);t&&(a.fillStyle=t,a.fillRect(0,0,pe,ve))}Wt&&c.applyDecay(),zt&&c.applyPulse(u),Ht&&c.applyThresholds(u),c.applyTopologyDiff(u);const p=null!==(t=null==Bt?void 0:Bt.threshold)&&void 0!==t?t:5e3,v=Bt&&c.lastIngestTime>0&&u-c.lastIngestTime>p;if(v&&(a.globalAlpha=null!==(e=null==Bt?void 0:Bt.dimOpacity)&&void 0!==e?e:.5),function(t,e){for(const n of e)switch(n.type){case"bezier":Wo(t,n);break;case"line":zo(t,n);break;case"ribbon":Yo(t,n);break;case"curved":Fo(t,n)}}(a,c.sceneEdges),function(t,e){var n,i,o;for(const r of e){if("rect"!==r.type)continue;const e=r;e.w>0&&e.h>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&It(t,e.style.fill)||e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fillRect(e.x,e.y,e.w,e.h)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=It(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.strokeRect(e.x,e.y,e.w,e.h)),$n(t,e),t.restore())}}(a,c.sceneNodes),function(t,e){var n,i,o;for(const r of e){if("circle"!==r.type)continue;const e=r;e.r>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.r,0,2*Math.PI),e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&It(t,e.style.fill)||e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=It(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.stroke()),Nn(t,e),t.restore())}}(a,c.sceneNodes),function(t,e){var n,i,o;for(const r of e){if("arc"!==r.type)continue;const e=r;t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.outerR,e.startAngle,e.endAngle),t.arc(e.cx,e.cy,e.innerR,e.endAngle,e.startAngle,!0),t.closePath(),e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&It(t,e.style.fill)||e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=It(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.stroke()),t.restore()}}(a,c.sceneNodes),Q&&c.particlePool&&!v){const t=Array.from(c.edges.values());if(t.length>0){!function(t,e,n,i){var o,r;const s=null!==(o=i.spawnRate)&&void 0!==o?o:li.spawnRate,l=null!==(r=i.maxPerEdge)&&void 0!==r?r:li.maxPerEdge;for(let i=0;e.length>i;i++){const o=e[i];if(!o.bezier)continue;if(t.countForEdge(i)>=l)continue;const r=o.value*s*n*(o.bezier.circular?.3:1),a=Math.floor(r),c=r-a;let u=a;Math.random()<c&&u++;for(let e=0;u>e&&t.countForEdge(i)<l;e++)t.spawn(i)}}(c.particlePool,t,d,Oe);const e=.5*(null!==(n=Oe.speedMultiplier)&&void 0!==n?n:1);let i;if(Oe.proportionalSpeed){const e=t.reduce((t,e)=>Math.max(t,e.value||1),1);i=t.map(t=>.3+(t.value||1)/e*1.7)}c.particlePool.step(d,e,t,i),function(t,e,n,i,o){var r,s;const l=null!==(r=i.radius)&&void 0!==r?r:li.radius,a=null!==(s=i.opacity)&&void 0!==s?s:li.opacity;t.globalAlpha=a;for(let r=0;e.particles.length>r;r++){const s=e.particles[r];if(!s.active)continue;const a=n[s.edgeIndex];if(a){if("function"==typeof i.color){const e="object"==typeof a.source?a.source:null;t.fillStyle=e?i.color(a,e):It(t,"var(--semiotic-secondary, #666)")}else t.fillStyle=i.color&&"inherit"!==i.color?i.color:o(a);t.beginPath(),t.arc(s.x,s.y,l,0,2*Math.PI),t.fill()}}t.globalAlpha=1}(a,c.particlePool,t,Oe,un)}}v&&(a.globalAlpha=1);const m=ue.current;if(ue.current=!1,m||f||g){const t=Re.current;t&&t.setAttribute("aria-label",dn(null!==(o=null===(i=c.sceneNodes)||void 0===i?void 0:i.length)&&void 0!==o?o:0,null!==(s=null===(r=c.sceneEdges)||void 0===r?void 0:r.length)&&void 0!==s?s:0,"Network chart"))}const x=m||f||g||Ne.current;x&&u-$e.current>=33?(Xe(t=>t+1),$e.current=u,Ne.current=!1):Ne.current=!!x,(hn||f||null!=c.transition||g||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff||Ne.current)&&(Ae.current=requestAnimationFrame(()=>Se.current()))},en({hydrated:je,wasHydratingFromSSR:Pe,storeRef:We,dirtyRef:ue,renderFnRef:Se}),e.useEffect(()=>{ue.current=!0,Me()},[S,pe,ve,mt,Me]),re(Bt,We,ue,Me,Ue,Ze);const Xn=xt&&ze?t.jsx(jn,{x:ze.x,y:ze.y,containerWidth:pe,containerHeight:ve,margin:ye,className:"stream-network-tooltip",zIndex:2,children:bt?bt(ze):t.jsx(qo,{data:ze})}):null;if(qe||!je&&Pe){const e=We.current;if(e){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(S),n=t?P||(Array.isArray(j)?void 0:j):void 0;if(t&&n)e.ingestHierarchy(n,[pe,ve]),e.buildScene([pe,ve]);else{const t=Ce,n=Array.isArray(Ee)?Ee:[];(t.length>0||n.length>0)&&(e.ingestBounded(t,n,[pe,ve]),e.buildScene([pe,ve]))}}const n=null!==(u=null==e?void 0:e.sceneNodes)&&void 0!==u?u:[],i=null!==(d=null==e?void 0:e.sceneEdges)&&void 0!==d?d:[],o=null!==(h=null==e?void 0:e.labels)&&void 0!==h?h:[];return t.jsxs("div",{ref:fe,className:"stream-network-frame"+(vt?" "+vt:""),role:"img","aria-label":Gt||("string"==typeof Rt?Rt:"Network chart"),style:{position:"relative",width:gt?"100%":ge[0],height:yt?"100%":ge[1]},children:[t.jsx(wn,{summary:Vt}),t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:ge[0],height:ge[1],style:{position:"absolute",left:0,top:0},children:[xe&&t.jsx("g",{transform:`translate(${ye.left},${ye.top})`,children:xe}),t.jsxs("g",{transform:`translate(${ye.left},${ye.top})`,children:[mt&&t.jsx("rect",{x:0,y:0,width:pe,height:ve,fill:mt}),i.map((e,n)=>function(e,n){switch(e.type){case"line":return t.jsx("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+n);case"bezier":{const i=e;return t.jsx("path",{d:i.pathD,fill:Ve(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-edge-"+n)}case"ribbon":{const i=e;return t.jsx("path",{d:i.pathD,fill:Ve(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-edge-"+n)}case"curved":{const i=e;return t.jsx("path",{d:i.pathD,fill:Ve(i.style.fill,"none"),stroke:i.style.stroke||"#999",strokeWidth:i.style.strokeWidth||1,opacity:i.style.opacity},"net-edge-"+n)}default:return null}}(e,n)).filter(Boolean),n.map((e,n)=>function(e,n){switch(e.type){case"circle":{const i=e;return t.jsx("circle",{cx:i.cx,cy:i.cy,r:i.r,fill:Ve(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-circle-"+n)}case"rect":{const i=e;return t.jsx("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:Ve(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-rect-"+n)}case"arc":{const i=e,o=s.arc().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2)(Ge)||"";return t.jsx("path",{d:o,transform:`translate(${i.cx},${i.cy})`,fill:Ve(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-arc-"+n)}default:return null}}(e,n)).filter(Boolean),o.map((e,n)=>function(e,n){return t.jsx("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"#333",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+n)}(e,n)).filter(Boolean)]})]}),t.jsx($o,{width:pe,height:ve,totalWidth:ge[0],totalHeight:ge[1],margin:ye,labels:o,sceneNodes:n,title:Rt,legend:Ct,legendPosition:Et,legendHoverBehavior:Lt,legendClickBehavior:Ot,legendHighlightedCategory:Tt,legendIsolatedCategories:Dt,foregroundGraphics:At(me,null===(f=We.current)||void 0===f?void 0:f.customLayoutOverlays),annotations:jt,svgAnnotationRules:Pt,annotationFrame:0})]})}const Vn=We.current;return t.jsxs("div",{ref:fe,className:"stream-network-frame"+(vt?" "+vt:""),role:"group","aria-label":Gt||("string"==typeof Rt?Rt:"Network chart"),tabIndex:0,style:{position:"relative",width:gt?"100%":ge[0],height:yt?"100%":ge[1],overflow:"visible"},onKeyDown:Bn,children:[Xt&&t.jsx(An,{tableId:we}),Xt&&t.jsx(kn,{nodes:null!==(g=null==Vn?void 0:Vn.sceneNodes)&&void 0!==g?g:[],edges:null!==(y=null==Vn?void 0:Vn.sceneEdges)&&void 0!==y?y:[],chartType:"Network chart",tableId:we,chartTitle:"string"==typeof Rt?Rt:void 0}),t.jsx(wn,{summary:Vt}),t.jsxs("div",{role:"img","aria-label":Gt||("string"==typeof Rt?Rt:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:xt?Hn:void 0,onMouseLeave:xt?Rn:void 0,onClick:wt||St?Wn:void 0,children:[xe&&t.jsx("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:ge[0],height:ge[1],pointerEvents:"none",overflow:"visible"},children:t.jsx("g",{transform:`translate(${ye.left},${ye.top})`,children:xe})}),t.jsx("canvas",{ref:Re,"aria-label":dn(null!==(v=null===(p=null==Vn?void 0:Vn.sceneNodes)||void 0===p?void 0:p.length)&&void 0!==v?v:0,null!==(x=null===(m=null==Vn?void 0:Vn.sceneEdges)||void 0===m?void 0:m.length)&&void 0!==x?x:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),t.jsx(Sn,{hoverPoint:ze}),t.jsx($o,{width:pe,height:ve,totalWidth:ge[0],totalHeight:ge[1],margin:ye,labels:(null==Vn?void 0:Vn.labels)||[],sceneNodes:null==Vn?void 0:Vn.sceneNodes,title:Rt,legend:Ct,legendPosition:Et,legendHoverBehavior:Lt,legendClickBehavior:Ot,legendHighlightedCategory:Tt,legendIsolatedCategories:Dt,foregroundGraphics:At(me,Qe),annotations:jt,svgAnnotationRules:Pt,annotationFrame:He}),t.jsx(_n,{active:zn.current>=0,hoverPoint:ze,margin:ye,size:ge,shape:null===(b=Yn.current)||void 0===b?void 0:b.shape,width:null===(w=Yn.current)||void 0===w?void 0:w.w,height:null===(A=Yn.current)||void 0===A?void 0:A.h}),Xn,(null==Bt?void 0:Bt.showBadge)&&t.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Bt.badgePosition?{top:4,left:4}:"bottom-left"===Bt.badgePosition?{bottom:4,left:4}:"bottom-right"===Bt.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Ue?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"}),children:Ue?"STALE":"LIVE"})]})]})});function Ko(t){const e=[];for(const[n,i]of Object.entries(t.fields))if("point"===i.type)e.push(t=>i.values.has(t[n]));else{const[t,o]=i.range;e.push(e=>{const i=e[n];return i>=t&&o>=i})}return t=>e.every(e=>e(t))}function Zo(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}Uo.displayName="StreamNetworkFrame";const[Qo,Jo]=A(t=>({selections:new Map,setClause(e,n){t(t=>{const i=new Map(t.selections),o=Zo(i,e),r=new Map(o.clauses);return r.set(n.clientId,n),i.set(e,Object.assign(Object.assign({},o),{clauses:r})),{selections:i}})},clearClause(e,n){t(t=>{const i=t.selections.get(e);if(!i)return{};const o=new Map(t.selections),r=new Map(i.clauses);return r.delete(n),o.set(e,Object.assign(Object.assign({},i),{clauses:r})),{selections:o}})},setResolution(e,n){t(t=>{const i=new Map(t.selections),o=Zo(i,e);return i.set(e,Object.assign(Object.assign({},o),{resolution:n})),{selections:i}})},clearSelection(e){t(t=>{const n=new Map(t.selections),i=n.get(e);return i&&n.set(e,Object.assign(Object.assign({},i),{clauses:new Map})),{selections:n}})}})),[tr,er]=A(t=>({observations:[],maxObservations:100,version:0,pushObservation(e){t(t=>{const n=t.observations;return n.push(e),n.length>t.maxObservations&&n.shift(),{version:t.version+1}})},clearObservations(){t(()=>({observations:[],version:0}))}}));function nr(t){const n=e.useId(),i=t.clientId||n,{name:o}=t,r=Jo(t=>t.selections.get(o)),s=Jo(t=>t.setClause),l=Jo(t=>t.clearClause),a=e.useMemo(()=>!!r&&r.clauses.size>0,[r]);return{predicate:e.useMemo(()=>r&&0!==r.clauses.size?function(t,e){const n=[];for(const[i,o]of t.clauses)"crossfilter"===t.resolution&&i===e||n.push(Ko(o));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(r,i):()=>!0,[r,i]),isActive:a,selectPoints:e.useCallback(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"point",values:new Set(i)};s(o,{clientId:i,type:"point",fields:e})},[i,o,s]),selectInterval:e.useCallback(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"interval",range:i};s(o,{clientId:i,type:"interval",fields:e})},[i,o,s]),clear:e.useCallback(()=>{l(o,i)},[l,o,i]),clientId:i}}function ir(t){return 2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]}function or(t,e,n){var i;const o=null!==(i=t.xValue)&&void 0!==i?i:null==e?void 0:e[n];if(null==o)return null;const r=Number(o);return Number.isFinite(r)?r:null}function rr(t){let e=t.data||t.datum||t;return Array.isArray(e)&&(e=e[0]),null!=t.xValue&&e&&"object"==typeof e&&!Array.isArray(e)&&null==e.xValue?Object.assign(Object.assign({},e),{xValue:t.xValue}):e||{}}function sr({selection:t,linkedHover:n,fallbackFields:i=[],unwrapData:o=!1,onObservation:r,chartType:s,chartId:l,onClick:a,hoverHighlight:c,colorByField:u}){const d=e.useId(),h=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}:null}(n,i),f=nr({name:(null==t?void 0:t.name)||"__unused__"}),g=function(t){const n=t.name||"hover",{fields:i}=t,{predicate:o,isActive:r,selectPoints:s,clear:l}=nr({name:n});return{onHover:e.useCallback(t=>{if(!t)return void l();const e={};for(const n of i){const i=t[n];void 0!==i&&(e[n]=[i])}Object.keys(e).length>0&&s(e)},[i,s,l,n]),predicate:o,isActive:r}}({name:(null==h?void 0:h.name)||"hover",fields:(null==h?void 0:h.fields)||i||[]}),y=er(t=>t.pushObservation),p=t?{isActive:f.isActive,predicate:f.predicate}:null,[v,m]=e.useState(null),x=u||i[0],b=e.useMemo(()=>{if(!c||null==v||!x)return null;const t=v,e=x;return{isActive:!0,predicate:n=>{var i;return("string"==typeof n[e]?n[e]:(null!==(i=n[e])&&void 0!==i?i:"")+"")===t}}},[c,v,x]),k=e.useCallback(t=>{var e,i;if(n)if(t){let e=t.data||t.datum||t;if(Array.isArray(e)&&(e=e[0]),"x-position"===(null==h?void 0:h.mode)&&h.xField){const n=or(t,e,h.xField);null!=n&&function(t,e,n){const i=Ee.positions.get(t);(null==i?void 0:i.locked)||i&&i.xValue===e&&i.sourceId===n||(Ee={positions:new Map(Ee.positions).set(t,{xValue:e,sourceId:n})},Oe())}(h.name||"hover",n,d)}"x-position"!==(null==h?void 0:h.mode)&&g.onHover(e)}else"x-position"===(null==h?void 0:h.mode)&&Te(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&g.onHover(null);if(c&&x)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=null==e?void 0:e[x];m(null!=n?n+"":null)}else m(null);if(r||y){const n={timestamp:Date.now(),chartType:s||"unknown",chartId:l};if(t){const o=rr(t),s=Object.assign(Object.assign({},n),{type:"hover",datum:o||{},x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(i=t.y)&&void 0!==i?i:0});r&&r(s),y&&y(s)}else{const t=Object.assign(Object.assign({},n),{type:"hover-end"});r&&r(t),y&&y(t)}}},[n,g,h,d,r,s,l,y,c,x]),w=e.useCallback(t=>{var e,n,i,o;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=or(t,e,h.xField);null!=n&&function(t,e,n){const i=Ee.positions.get(t);if(null==i?void 0:i.locked){const e=new Map(Ee.positions);return e.delete(t),Ee={positions:e},Oe(),!1}Ee={positions:new Map(Ee.positions).set(t,{xValue:e,sourceId:n,locked:!0})},Oe()}(h.name||"hover",n,d)}if(t&&a){let i=t.data||t.datum||t;Array.isArray(i)&&(i=i[0]),a(i,{x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0})}if(r||y){const e={timestamp:Date.now(),chartType:s||"unknown",chartId:l};if(t){const n=rr(t),s=Object.assign(Object.assign({},e),{type:"click",datum:n||{},x:null!==(i=t.x)&&void 0!==i?i:0,y:null!==(o=t.y)&&void 0!==o?o:0});r&&r(s),y&&y(s)}else{const t=Object.assign(Object.assign({},e),{type:"click-end"});r&&r(t),y&&y(t)}}},[a,r,y,s,l,h,d]);return e.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const t=h.name||"hover";return()=>{De(t,d),Te(t,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:p,hoverSelectionHook:b,customHoverBehavior:k,customClickBehavior:w,crosshairSourceId:d}}const lr={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function ar(t,e,n){var i,o,r,s,l,a,c;const u=lr[t||"primary"],d="context"===t||"sparkline"===t;return{width:null!==(i=e.width)&&void 0!==i?i:u.width,height:null!==(o=e.height)&&void 0!==o?o:u.height,showAxes:null!==(r=e.showAxes)&&void 0!==r?r:u.showAxes,showGrid:null!==(s=e.showGrid)&&void 0!==s?s:u.showGrid,enableHover:null!==(l=e.enableHover)&&void 0!==l?l:!!e.linkedHover||u.enableHover,showLegend:null!==(a=e.showLegend)&&void 0!==a?a:u.showLegend,showLabels:null!==(c=e.showLabels)&&void 0!==c?c:u.showLabels,title:d?void 0:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:d?void 0:e.xLabel,yLabel:d?void 0:e.yLabel,categoryLabel:d?void 0:e.categoryLabel,valueLabel:d?void 0:e.valueLabel,marginDefaults:cr(u.marginDefaults,e.showCategoryTicks,e.orientation),compactMode:d}}function cr(t,e,n){if(!1!==e)return t;const i=Object.assign({},t);return"horizontal"===n?i.left=Math.min(i.left,15):i.bottom=Math.min(i.bottom,15),i}const ur={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, #f3f4f6)",padding:"6px 10px",borderRadius:"var(--semiotic-tooltip-radius, 4px)",fontSize:"var(--semiotic-tooltip-font-size, 12px)",fontFamily:"var(--semiotic-tick-font-family, var(--semiotic-font-family, sans-serif))",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.25))",lineHeight:1.4,pointerEvents:"none",whiteSpace:"nowrap"},dr={opacity:.7,marginRight:4};function hr(t,e,n){if(null!=t)return"function"==typeof e?e(t):t["string"==typeof e?e:n]}function fr(t){return null==t?"":"number"==typeof t?Number.isInteger(t)?t+"":t.toFixed(2):t instanceof Date?t.toLocaleString():t+""}function gr(e={}){const{timeAccessor:n,valueAccessor:i,xLabel:o="x",yLabel:r="y"}=e;return e=>{var s;const l=null!==(s=null==e?void 0:e.data)&&void 0!==s?s:null,a=hr(l,n,"time"),c=hr(l,i,"value");return t.jsxs("div",{className:"semiotic-tooltip",style:ur,children:[t.jsxs("div",{children:[t.jsxs("span",{style:dr,children:[o,":"]}),fr(a)]}),t.jsxs("div",{children:[t.jsxs("span",{style:dr,children:[r,":"]}),fr(c)]})]})}}"undefined"!=typeof process&&process;const yr={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},pr={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function vr(e,n,i,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?t.jsx("div",{style:Object.assign(Object.assign({},yr),{width:n,height:i}),children:o||"No data available"}):null}function mr(e,n,i){if(!e)return null;const o=Math.min(5,Math.floor(i/40)),r=Math.max(8,Math.floor(i/(3*o))),s=Math.max(6,Math.floor(i/(2.5*o))),l=Math.floor((i-(o*(r+s)-s))/2);return t.jsx("div",{style:{width:n,height:i,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:o},(e,i)=>t.jsx("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},pr),{position:"absolute",top:l+i*(r+s),left:Math.floor(.1*n),width:30+(37*i+13)%50+"%",height:r,opacity:.5+i%2*.2})},i))})}function xr(t,e){var n;return null!=t?t:Math.max(null!==(n=null==e?void 0:e.length)&&void 0!==n?n:0,200)}const br=e.forwardRef(function(n,i){var o,r,s,l,a;const c=ar(n.mode,{width:null!==(r=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==r?r:n.width,height:null!==(l=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==l?l:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:f="right",windowMode:g="sliding",windowSize:y,data:p,timeAccessor:v,valueAccessor:m,timeExtent:x,valueExtent:b,extentPadding:k,stroke:w="#007bff",strokeWidth:A=2,strokeDasharray:S,opacity:M,background:_,tooltipContent:j,tooltip:P,onHover:C,annotations:E,svgAnnotationRules:L,tickFormatTime:O,tickFormatValue:T,decay:D,pulse:R,staleness:I,transition:$,linkedHover:N,selection:W,onObservation:z,chartId:Y,loading:F,emptyContent:B,emphasis:H,legendPosition:X}=n,G=c.showAxes,V=c.enableHover,q=null!=d?d:c.marginDefaults,U=null!=u?u:[c.width,c.height],K=null!==(a=null!=j?j:P)&&void 0!==a?a:gr({timeAccessor:v,valueAccessor:m}),Z=e.useRef(null),{customHoverBehavior:Q}=sr({selection:W,linkedHover:N,unwrapData:!0,onObservation:z,chartType:"RealtimeLineChart",chartId:Y}),J=e.useCallback(t=>{C&&C(t),Q(t)},[C,Q]);e.useImperativeHandle(i,()=>({push:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=Z.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=Z.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}),[]);const tt=mr(F,U[0],U[1]),et=tt?null:vr(p,U[0],U[1],B),nt={stroke:w,strokeWidth:A,strokeDasharray:S};null!=M&&(nt.opacity=M);const it=xr(y,p);return tt||et||t.jsx(ri,{ref:Z,chartType:"line",runtimeMode:"streaming",size:U,margin:q,className:H?`${h||""} semiotic-emphasis-${H}`.trim():h,arrowOfTime:f,windowMode:g,windowSize:it,data:p,timeAccessor:v,valueAccessor:m,xExtent:x,yExtent:b,extentPadding:k,lineStyle:nt,showAxes:G,background:_,hoverAnnotation:V,tooltipContent:K,customHoverBehavior:J,annotations:E,svgAnnotationRules:L,tickFormatTime:O,tickFormatValue:T,decay:D,pulse:R,staleness:I,transition:$,pointIdAccessor:n.pointIdAccessor,legendPosition:X})});br.displayName="RealtimeLineChart";const kr=e.forwardRef(function(n,i){var o,r,s,l,a;const c=ar(n.mode,{width:null!==(r=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==r?r:n.width,height:null!==(l=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==l?l:n.height,showAxes:n.showAxes,enableHover:null!=n.enableHover?!!n.enableHover:void 0,linkedHover:n.linkedHover}),{binSize:u,size:d,margin:h,className:f,arrowOfTime:g="right",windowMode:y="sliding",windowSize:p,data:v,timeAccessor:m,valueAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,categoryAccessor:A,colors:S,fill:M,stroke:_,strokeWidth:j,opacity:P,gap:C,background:E,tooltipContent:L,tooltip:O,onHover:T,annotations:D,svgAnnotationRules:R,tickFormatTime:I,tickFormatValue:$,linkedHover:N,selection:W,decay:z,pulse:Y,staleness:F,transition:B,onObservation:H,chartId:X,loading:G,emptyContent:V,emphasis:q,legendPosition:U,brush:K,onBrush:Z,linkedBrush:Q}=n,J=c.showAxes,tt=c.enableHover,et=null!=h?h:c.marginDefaults,nt=null!=d?d:[c.width,c.height],it=null!==(a=null!=L?L:O)&&void 0!==a?a:gr({timeAccessor:m,valueAccessor:x}),ot=e.useRef(null),{customHoverBehavior:rt}=sr({selection:W,linkedHover:N,unwrapData:!0,onObservation:H,chartType:"RealtimeTemporalHistogram",chartId:X}),st=e.useCallback(t=>{T&&T(t),rt(t)},[T,rt]),lt=!0===K?{dimension:"x",snap:"bin"}:"x"===K?{dimension:"x"}:"object"==typeof K?K:void 0,at=(ct=Q)?"string"==typeof ct?{name:ct}:ct:null;var ct;const ut=function(t){const{name:n,xField:i,yField:o}=t,{predicate:r,isActive:s,selectInterval:l,clear:a}=nr({name:n}),c=i&&o?"xyBrush":i?"xBrush":"yBrush",u=e.useCallback(t=>{if(!t)return void a();const e={};"xyBrush"===c&&function(t){return 2===t.length&&Array.isArray(t[0])&&2===t[0].length&&Array.isArray(t[1])&&2===t[1].length}(t)?(i&&(e[i]=[Math.min(t[0][0],t[1][0]),Math.max(t[0][0],t[1][0])]),o&&(e[o]=[Math.min(t[0][1],t[1][1]),Math.max(t[0][1],t[1][1])])):"xBrush"===c&&ir(t)?i&&(e[i]=[Math.min(...t),Math.max(...t)]):"yBrush"===c&&ir(t)&&o&&(e[o]=[Math.min(...t),Math.max(...t)]),Object.keys(e).length>0&&l(e)},[c,i,o,l,a]);return{brushInteraction:e.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:r,isActive:s,clear:a}}(Object.assign({name:(null==at?void 0:at.name)||"__unused_hist_brush__",xField:(null==at?void 0:at.xField)||("string"==typeof m?m:"time")},(null==at?void 0:at.yField)?{yField:at.yField}:{})),dt=e.useRef(ut.brushInteraction);dt.current=ut.brushInteraction;const ht=e.useCallback(t=>{if(Z&&Z(t),H&&H(t?{type:"brush",extent:t,timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:X}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:X}),at){const e=dt.current;e.end(t?"xBrush"===e.brush?t.x:"yBrush"===e.brush?t.y:[[t.x[0],t.y[0]],[t.x[1],t.y[1]]]:null)}},[Z,H,X,at]);e.useImperativeHandle(i,()=>({push:t=>{var e;return null===(e=ot.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=ot.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=ot.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=ot.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=ot.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=ot.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=ot.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}),[]);const ft=mr(G,nt[0],nt[1]),gt=ft?null:vr(v,nt[0],nt[1],V),yt={};null!=M&&(yt.fill=M),null!=_&&(yt.stroke=_),null!=j&&(yt.strokeWidth=j),null!=P&&(yt.opacity=P),null!=C&&(yt.gap=C);const pt=q?`${f||""} semiotic-emphasis-${q}`.trim():f,vt=xr(p,v);return ft||gt||t.jsx(ri,{ref:ot,chartType:"bar",runtimeMode:"streaming",size:nt,margin:et,className:pt,arrowOfTime:g,windowMode:y,windowSize:vt,data:v,timeAccessor:m,valueAccessor:x,xExtent:b,yExtent:k,extentPadding:w,binSize:u,categoryAccessor:A,barColors:S,barStyle:yt,showAxes:J,background:E,hoverAnnotation:tt,tooltipContent:it,customHoverBehavior:st,annotations:D,svgAnnotationRules:R,tickFormatTime:I,tickFormatValue:$,decay:z,pulse:Y,staleness:F,transition:B,pointIdAccessor:n.pointIdAccessor,legendPosition:U,brush:lt||(Q?{dimension:"x"}:void 0),onBrush:lt||Q?ht:void 0})});kr.displayName="RealtimeTemporalHistogram";const wr=kr,Ar=e.forwardRef(function(n,i){var o,r,s,l,a;const c=ar(n.mode,{width:null!==(r=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==r?r:n.width,height:null!==(l=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==l?l:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:f="right",windowMode:g="sliding",windowSize:y,data:p,timeAccessor:v,valueAccessor:m,timeExtent:x,valueExtent:b,extentPadding:k,categoryAccessor:w,colors:A,radius:S,fill:M,opacity:_,stroke:j,strokeWidth:P,background:C,tooltipContent:E,tooltip:L,onHover:O,annotations:T,svgAnnotationRules:D,tickFormatTime:R,tickFormatValue:I,linkedHover:$,selection:N,onObservation:W,chartId:z,loading:Y,emptyContent:F,emphasis:B,legendPosition:H}=n,X=c.showAxes,G=c.enableHover,V=null!=d?d:c.marginDefaults,q=null!=u?u:[c.width,c.height],U=null!==(a=null!=E?E:L)&&void 0!==a?a:gr({timeAccessor:v,valueAccessor:m}),K=e.useRef(null),{customHoverBehavior:Z}=sr({selection:N,linkedHover:$,unwrapData:!0,onObservation:W,chartType:"RealtimeSwarmChart",chartId:z}),Q=e.useCallback(t=>{O&&O(t),Z(t)},[O,Z]);e.useImperativeHandle(i,()=>({push:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=K.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=K.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=K.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}),[]);const J=mr(Y,q[0],q[1]),tt=J?null:vr(p,q[0],q[1],F),et={};null!=S&&(et.radius=S),null!=M&&(et.fill=M),null!=_&&(et.opacity=_),null!=j&&(et.stroke=j),null!=P&&(et.strokeWidth=P);const nt=B?`${h||""} semiotic-emphasis-${B}`.trim():h,it=xr(y,p);return J||tt||t.jsx(ri,{ref:K,chartType:"swarm",runtimeMode:"streaming",size:q,margin:V,className:nt,arrowOfTime:f,windowMode:g,windowSize:it,data:p,timeAccessor:v,valueAccessor:m,xExtent:x,yExtent:b,extentPadding:k,categoryAccessor:w,barColors:A,swarmStyle:et,showAxes:X,background:C,hoverAnnotation:G,tooltipContent:U,customHoverBehavior:Q,annotations:T,svgAnnotationRules:D,tickFormatTime:R,tickFormatValue:I,legendPosition:H,pointIdAccessor:n.pointIdAccessor})});Ar.displayName="RealtimeSwarmChart";const Sr=e.forwardRef(function(n,i){var o,r,s,l,a;const c=ar(n.mode,{width:null!==(r=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==r?r:n.width,height:null!==(l=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==l?l:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:f="right",windowMode:g="sliding",windowSize:y,data:p,timeAccessor:v,valueAccessor:m,timeExtent:x,valueExtent:b,extentPadding:k,positiveColor:w,negativeColor:A,connectorStroke:S,connectorWidth:M,gap:_,stroke:j,strokeWidth:P,opacity:C,background:E,tooltipContent:L,tooltip:O,onHover:T,annotations:D,svgAnnotationRules:R,tickFormatTime:I,tickFormatValue:$,linkedHover:N,selection:W,onObservation:z,chartId:Y,loading:F,emptyContent:B,emphasis:H,legendPosition:X}=n,G=c.showAxes,V=c.enableHover,q=null!=d?d:c.marginDefaults,U=null!=u?u:[c.width,c.height],K=null!==(a=null!=L?L:O)&&void 0!==a?a:function(e={}){const{timeAccessor:n,valueAccessor:i}=e;return e=>{var o,r;const s=null!==(o=null==e?void 0:e.data)&&void 0!==o?o:null,l=hr(s,n,"time"),a=null!==(r=null==s?void 0:s.delta)&&void 0!==r?r:hr(s,i,"value"),c=null==s?void 0:s.cumEnd,u="number"==typeof a?0>a?fr(a):"+"+fr(a):fr(a);return t.jsxs("div",{className:"semiotic-tooltip",style:ur,children:[t.jsxs("div",{children:[t.jsx("span",{style:dr,children:"x:"}),fr(l)]}),t.jsxs("div",{children:[t.jsx("span",{style:dr,children:"Δ:"}),u]}),null!=c&&t.jsxs("div",{children:[t.jsx("span",{style:dr,children:"total:"}),fr(c)]})]})}}({timeAccessor:v,valueAccessor:m}),Z=e.useRef(null),{customHoverBehavior:Q}=sr({selection:W,linkedHover:N,unwrapData:!0,onObservation:z,chartType:"RealtimeWaterfallChart",chartId:Y}),J=e.useCallback(t=>{T&&T(t),Q(t)},[T,Q]);e.useImperativeHandle(i,()=>({push:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=Z.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=Z.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}),[]);const tt=mr(F,U[0],U[1]),et=tt?null:vr(p,U[0],U[1],B),nt={};null!=w&&(nt.positiveColor=w),null!=A&&(nt.negativeColor=A),null!=S&&(nt.connectorStroke=S),null!=M&&(nt.connectorWidth=M),null!=_&&(nt.gap=_),null!=j&&(nt.stroke=j),null!=P&&(nt.strokeWidth=P),null!=C&&(nt.opacity=C);const it=H?`${h||""} semiotic-emphasis-${H}`.trim():h,ot=xr(y,p);return tt||et||t.jsx(ri,{ref:Z,chartType:"waterfall",runtimeMode:"streaming",size:U,margin:q,className:it,arrowOfTime:f,windowMode:g,windowSize:ot,data:p,timeAccessor:v,valueAccessor:m,xExtent:x,yExtent:b,extentPadding:k,waterfallStyle:nt,showAxes:G,background:E,hoverAnnotation:V,tooltipContent:K,customHoverBehavior:J,annotations:D,svgAnnotationRules:R,tickFormatTime:I,tickFormatValue:$,legendPosition:X,pointIdAccessor:n.pointIdAccessor})});Sr.displayName="RealtimeWaterfallChart";const Mr=e.forwardRef(function(n,i){var o,r,s,l,a;const c=ar(n.mode,{width:null!==(r=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==r?r:n.width,height:null!==(l=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==l?l:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:f="right",windowMode:g="sliding",windowSize:y,data:p,timeAccessor:v,valueAccessor:m,categoryAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,heatmapXBins:A=20,heatmapYBins:S=20,aggregation:M="count",background:_,tooltipContent:j,tooltip:P,onHover:C,annotations:E,svgAnnotationRules:L,tickFormatTime:O,tickFormatValue:T,decay:D,pulse:R,staleness:I,linkedHover:$,selection:N,onObservation:W,chartId:z,loading:Y,emptyContent:F,emphasis:B,legendPosition:H}=n,X=c.showAxes,G=c.enableHover,V=null!=d?d:c.marginDefaults,q=null!=u?u:[c.width,c.height],U=null!==(a=null!=j?j:P)&&void 0!==a?a:gr({timeAccessor:v,valueAccessor:m}),K=e.useRef(null),{customHoverBehavior:Z}=sr({selection:N,linkedHover:$,unwrapData:!0,onObservation:W,chartType:"RealtimeHeatmap",chartId:z}),Q=e.useCallback(t=>{C&&C(t),Z(t)},[C,Z]);e.useImperativeHandle(i,()=>({push:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=K.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=K.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=K.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}),[]);const J=mr(Y,q[0],q[1]),tt=J?null:vr(p,q[0],q[1],F),et=B?`${h||""} semiotic-emphasis-${B}`.trim():h,nt=xr(y,p);return J||tt||t.jsx(ri,{ref:K,chartType:"heatmap",runtimeMode:"streaming",size:q,margin:V,className:et,arrowOfTime:f,windowMode:g,windowSize:nt,data:p,timeAccessor:v,valueAccessor:m,categoryAccessor:x,xExtent:b,yExtent:k,extentPadding:w,heatmapXBins:A,heatmapYBins:S,heatmapAggregation:M,showAxes:X,background:_,hoverAnnotation:G,tooltipContent:U,customHoverBehavior:Q,annotations:E,svgAnnotationRules:L,tickFormatTime:O,tickFormatValue:T,decay:D,pulse:R,staleness:I,legendPosition:H,pointIdAccessor:n.pointIdAccessor})});Mr.displayName="RealtimeHeatmap",exports.IncrementalExtent=R,exports.RealtimeHeatmap=Mr,exports.RealtimeHistogram=wr,exports.RealtimeLineChart=br,exports.RealtimeSwarmChart=Ar,exports.RealtimeWaterfallChart=Sr,exports.RingBuffer=D,exports.StreamNetworkFrame=Uo,exports.StreamXYFrame=ri;