semiotic 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/CLAUDE.md +23 -10
  2. package/README.md +66 -63
  3. package/ai/cli.js +34 -21
  4. package/ai/dist/componentRegistry.js +2 -0
  5. package/ai/dist/mcp-server.js +54 -0
  6. package/ai/examples.md +75 -0
  7. package/ai/schema.json +71 -0
  8. package/ai/system-prompt.md +3 -0
  9. package/dist/{ChartGrid.d.ts → components/ChartGrid.d.ts} +9 -7
  10. package/dist/{LinkedCharts.d.ts → components/LinkedCharts.d.ts} +34 -1
  11. package/dist/{Tooltip → components/Tooltip}/Tooltip.d.ts +9 -2
  12. package/dist/{charts → components/charts}/index.d.ts +2 -0
  13. package/dist/{charts → components/charts}/network/ChordDiagram.d.ts +2 -0
  14. package/dist/{charts → components/charts}/network/CirclePack.d.ts +2 -0
  15. package/dist/{charts → components/charts}/network/ForceDirectedGraph.d.ts +2 -0
  16. package/dist/components/charts/network/OrbitDiagram.d.ts +78 -0
  17. package/dist/{charts → components/charts}/network/SankeyDiagram.d.ts +2 -0
  18. package/dist/{charts → components/charts}/network/TreeDiagram.d.ts +2 -0
  19. package/dist/{charts → components/charts}/network/Treemap.d.ts +2 -0
  20. package/dist/{charts → components/charts}/ordinal/BarChart.d.ts +2 -0
  21. package/dist/{charts → components/charts}/ordinal/BoxPlot.d.ts +2 -0
  22. package/dist/{charts → components/charts}/ordinal/DonutChart.d.ts +2 -0
  23. package/dist/{charts → components/charts}/ordinal/DotPlot.d.ts +2 -0
  24. package/dist/{charts → components/charts}/ordinal/GroupedBarChart.d.ts +2 -0
  25. package/dist/{charts → components/charts}/ordinal/PieChart.d.ts +2 -0
  26. package/dist/{charts → components/charts}/ordinal/StackedBarChart.d.ts +2 -0
  27. package/dist/{charts → components/charts}/ordinal/SwarmPlot.d.ts +2 -0
  28. package/dist/components/charts/shared/diagnoseConfig.d.ts +23 -0
  29. package/dist/{charts → components/charts}/shared/hooks.d.ts +23 -1
  30. package/dist/components/charts/shared/stringDistance.d.ts +11 -0
  31. package/dist/{charts → components/charts}/shared/tooltipUtils.d.ts +1 -1
  32. package/dist/{charts → components/charts}/shared/types.d.ts +6 -0
  33. package/dist/{charts → components/charts}/shared/withChartWrapper.d.ts +10 -0
  34. package/dist/{charts → components/charts}/xy/AreaChart.d.ts +8 -0
  35. package/dist/{charts → components/charts}/xy/BubbleChart.d.ts +8 -0
  36. package/dist/{charts → components/charts}/xy/ConnectedScatterplot.d.ts +3 -0
  37. package/dist/{charts → components/charts}/xy/Heatmap.d.ts +8 -0
  38. package/dist/{charts → components/charts}/xy/LineChart.d.ts +26 -0
  39. package/dist/{charts → components/charts}/xy/Scatterplot.d.ts +3 -0
  40. package/dist/{charts → components/charts}/xy/StackedAreaChart.d.ts +8 -0
  41. package/dist/{export → components/export}/exportChart.d.ts +6 -1
  42. package/dist/components/semiotic-ai.d.ts +61 -0
  43. package/dist/components/semiotic-data.d.ts +7 -0
  44. package/dist/components/semiotic-network.d.ts +14 -0
  45. package/dist/components/semiotic-ordinal.d.ts +18 -0
  46. package/dist/components/semiotic-realtime.d.ts +22 -0
  47. package/dist/components/semiotic-server.d.ts +1 -0
  48. package/dist/components/semiotic-xy.d.ts +16 -0
  49. package/dist/components/semiotic.d.ts +57 -0
  50. package/dist/{server → components/server}/renderToStaticSVG.d.ts +7 -0
  51. package/dist/{stream → components/stream}/NetworkSVGOverlay.d.ts +20 -0
  52. package/dist/{stream → components/stream}/OrdinalSVGOverlay.d.ts +8 -0
  53. package/dist/{stream → components/stream}/PipelineStore.d.ts +7 -0
  54. package/dist/{stream → components/stream}/SVGOverlay.d.ts +15 -0
  55. package/dist/components/stream/SceneToSVG.d.ts +20 -0
  56. package/dist/components/stream/hitTestUtils.d.ts +23 -0
  57. package/dist/{stream → components/stream}/networkTypes.d.ts +10 -2
  58. package/dist/{stream → components/stream}/ordinalTypes.d.ts +16 -10
  59. package/dist/components/stream/renderers/areaCanvasRenderer.d.ts +2 -0
  60. package/dist/{stream → components/stream}/types.d.ts +12 -0
  61. package/dist/components/stream/useStalenessCheck.d.ts +16 -0
  62. package/dist/{types → components/types}/legendTypes.d.ts +5 -0
  63. package/dist/network.min.js +1 -1
  64. package/dist/network.module.min.js +1 -1
  65. package/dist/ordinal.min.js +1 -1
  66. package/dist/ordinal.module.min.js +1 -1
  67. package/dist/realtime.min.js +1 -1
  68. package/dist/realtime.module.min.js +1 -1
  69. package/dist/semiotic-ai.d.ts +3 -0
  70. package/dist/semiotic-ai.min.js +1 -1
  71. package/dist/semiotic-ai.module.min.js +1 -1
  72. package/dist/semiotic-network.d.ts +1 -0
  73. package/dist/semiotic-ordinal.d.ts +1 -0
  74. package/dist/semiotic.d.ts +3 -3
  75. package/dist/semiotic.min.js +1 -1
  76. package/dist/semiotic.module.min.js +1 -1
  77. package/dist/server.min.js +1 -1
  78. package/dist/server.module.min.js +1 -1
  79. package/dist/test/canvasMock.d.ts +2 -0
  80. package/dist/test-utils/canvasMock.d.ts +20 -0
  81. package/dist/test-utils/frameMock.d.ts +78 -0
  82. package/dist/xy.min.js +1 -1
  83. package/dist/xy.module.min.js +1 -1
  84. package/package.json +7 -15
  85. package/dist/stream/renderers/areaCanvasRenderer.d.ts +0 -7
  86. /package/dist/{Annotation.d.ts → components/Annotation.d.ts} +0 -0
  87. /package/dist/{CategoryColors.d.ts → components/CategoryColors.d.ts} +0 -0
  88. /package/dist/{ChartContainer.d.ts → components/ChartContainer.d.ts} +0 -0
  89. /package/dist/{ChartErrorBoundary.d.ts → components/ChartErrorBoundary.d.ts} +0 -0
  90. /package/dist/{ContextLayout.d.ts → components/ContextLayout.d.ts} +0 -0
  91. /package/dist/{DetailsPanel.d.ts → components/DetailsPanel.d.ts} +0 -0
  92. /package/dist/{Legend.d.ts → components/Legend.d.ts} +0 -0
  93. /package/dist/{ThemeProvider.d.ts → components/ThemeProvider.d.ts} +0 -0
  94. /package/dist/{charts → components/charts}/ordinal/Histogram.d.ts +0 -0
  95. /package/dist/{charts → components/charts}/ordinal/RidgelinePlot.d.ts +0 -0
  96. /package/dist/{charts → components/charts}/ordinal/ViolinPlot.d.ts +0 -0
  97. /package/dist/{charts → components/charts}/realtime/RealtimeHeatmap.d.ts +0 -0
  98. /package/dist/{charts → components/charts}/realtime/RealtimeHistogram.d.ts +0 -0
  99. /package/dist/{charts → components/charts}/realtime/RealtimeLineChart.d.ts +0 -0
  100. /package/dist/{charts → components/charts}/realtime/RealtimeSwarmChart.d.ts +0 -0
  101. /package/dist/{charts → components/charts}/realtime/RealtimeWaterfallChart.d.ts +0 -0
  102. /package/dist/{charts → components/charts}/shared/ChartError.d.ts +0 -0
  103. /package/dist/{charts → components/charts}/shared/annotationRules.d.ts +0 -0
  104. /package/dist/{charts → components/charts}/shared/colorUtils.d.ts +0 -0
  105. /package/dist/{charts → components/charts}/shared/formatUtils.d.ts +0 -0
  106. /package/dist/{charts → components/charts}/shared/legendUtils.d.ts +0 -0
  107. /package/dist/{charts → components/charts}/shared/loess.d.ts +0 -0
  108. /package/dist/{charts → components/charts}/shared/networkUtils.d.ts +0 -0
  109. /package/dist/{charts → components/charts}/shared/selectionUtils.d.ts +0 -0
  110. /package/dist/{charts → components/charts}/shared/statisticalOverlays.d.ts +0 -0
  111. /package/dist/{charts → components/charts}/shared/validateChartData.d.ts +0 -0
  112. /package/dist/{charts → components/charts}/shared/validateProps.d.ts +0 -0
  113. /package/dist/{charts → components/charts}/xy/MinimapChart.d.ts +0 -0
  114. /package/dist/{charts → components/charts}/xy/ScatterplotMatrix.d.ts +0 -0
  115. /package/dist/{data → components/data}/fromVegaLite.d.ts +0 -0
  116. /package/dist/{data → components/data}/transforms.d.ts +0 -0
  117. /package/dist/{export → components/export}/chartConfig.d.ts +0 -0
  118. /package/dist/{export → components/export}/selectionSerializer.d.ts +0 -0
  119. /package/dist/{geometry → components/geometry}/sankeyLinks.d.ts +0 -0
  120. /package/dist/{realtime → components/realtime}/BinAccumulator.d.ts +0 -0
  121. /package/dist/{realtime → components/realtime}/IncrementalExtent.d.ts +0 -0
  122. /package/dist/{realtime → components/realtime}/RingBuffer.d.ts +0 -0
  123. /package/dist/{realtime → components/realtime}/renderers/types.d.ts +0 -0
  124. /package/dist/{realtime → components/realtime}/renderers/waterfallRenderer.d.ts +0 -0
  125. /package/dist/{realtime → components/realtime}/types.d.ts +0 -0
  126. /package/dist/{store → components/store}/ObservationStore.d.ts +0 -0
  127. /package/dist/{store → components/store}/SelectionStore.d.ts +0 -0
  128. /package/dist/{store → components/store}/ThemeStore.d.ts +0 -0
  129. /package/dist/{store → components/store}/TooltipStore.d.ts +0 -0
  130. /package/dist/{store → components/store}/createStore.d.ts +0 -0
  131. /package/dist/{store → components/store}/useObservation.d.ts +0 -0
  132. /package/dist/{store → components/store}/useSelection.d.ts +0 -0
  133. /package/dist/{stream → components/stream}/CanvasHitTester.d.ts +0 -0
  134. /package/dist/{stream → components/stream}/DataSourceAdapter.d.ts +0 -0
  135. /package/dist/{stream → components/stream}/MarginalGraphics.d.ts +0 -0
  136. /package/dist/{stream → components/stream}/NetworkCanvasHitTester.d.ts +0 -0
  137. /package/dist/{stream → components/stream}/NetworkPipelineStore.d.ts +0 -0
  138. /package/dist/{stream → components/stream}/OrdinalCanvasHitTester.d.ts +0 -0
  139. /package/dist/{stream → components/stream}/OrdinalPipelineStore.d.ts +0 -0
  140. /package/dist/{stream → components/stream}/ParticlePool.d.ts +0 -0
  141. /package/dist/{stream → components/stream}/SceneGraph.d.ts +0 -0
  142. /package/dist/{stream → components/stream}/StreamNetworkFrame.d.ts +0 -0
  143. /package/dist/{stream → components/stream}/StreamOrdinalFrame.d.ts +0 -0
  144. /package/dist/{stream → components/stream}/StreamXYFrame.d.ts +0 -0
  145. /package/dist/{stream → components/stream}/accessorUtils.d.ts +0 -0
  146. /package/dist/{stream → components/stream}/keyboardNav.d.ts +0 -0
  147. /package/dist/{stream → components/stream}/layouts/chordLayoutPlugin.d.ts +0 -0
  148. /package/dist/{stream → components/stream}/layouts/forceLayoutPlugin.d.ts +0 -0
  149. /package/dist/{stream → components/stream}/layouts/hierarchyLayoutPlugin.d.ts +0 -0
  150. /package/dist/{stream → components/stream}/layouts/index.d.ts +0 -0
  151. /package/dist/{stream → components/stream}/layouts/sankeyLayoutPlugin.d.ts +0 -0
  152. /package/dist/{stream → components/stream}/ordinalSceneBuilders/barScene.d.ts +0 -0
  153. /package/dist/{stream → components/stream}/ordinalSceneBuilders/connectorScene.d.ts +0 -0
  154. /package/dist/{stream → components/stream}/ordinalSceneBuilders/pieScene.d.ts +0 -0
  155. /package/dist/{stream → components/stream}/ordinalSceneBuilders/pointScene.d.ts +0 -0
  156. /package/dist/{stream → components/stream}/ordinalSceneBuilders/statisticalScene.d.ts +0 -0
  157. /package/dist/{stream → components/stream}/ordinalSceneBuilders/timelineScene.d.ts +0 -0
  158. /package/dist/{stream → components/stream}/ordinalSceneBuilders/types.d.ts +0 -0
  159. /package/dist/{stream → components/stream}/renderers/barCanvasRenderer.d.ts +0 -0
  160. /package/dist/{stream → components/stream}/renderers/boxplotCanvasRenderer.d.ts +0 -0
  161. /package/dist/{stream → components/stream}/renderers/candlestickCanvasRenderer.d.ts +0 -0
  162. /package/dist/{stream → components/stream}/renderers/connectorCanvasRenderer.d.ts +0 -0
  163. /package/dist/{stream → components/stream}/renderers/heatmapCanvasRenderer.d.ts +0 -0
  164. /package/dist/{stream → components/stream}/renderers/lineCanvasRenderer.d.ts +0 -0
  165. /package/dist/{stream → components/stream}/renderers/networkArcRenderer.d.ts +0 -0
  166. /package/dist/{stream → components/stream}/renderers/networkCircleRenderer.d.ts +0 -0
  167. /package/dist/{stream → components/stream}/renderers/networkEdgeRenderer.d.ts +0 -0
  168. /package/dist/{stream → components/stream}/renderers/networkParticleRenderer.d.ts +0 -0
  169. /package/dist/{stream → components/stream}/renderers/networkRectRenderer.d.ts +0 -0
  170. /package/dist/{stream → components/stream}/renderers/pointCanvasRenderer.d.ts +0 -0
  171. /package/dist/{stream → components/stream}/renderers/swarmCanvasRenderer.d.ts +0 -0
  172. /package/dist/{stream → components/stream}/renderers/types.d.ts +0 -0
  173. /package/dist/{stream → components/stream}/renderers/violinCanvasRenderer.d.ts +0 -0
  174. /package/dist/{stream → components/stream}/renderers/waterfallCanvasRenderer.d.ts +0 -0
  175. /package/dist/{stream → components/stream}/renderers/wedgeCanvasRenderer.d.ts +0 -0
  176. /package/dist/{stream → components/stream}/useResponsiveSize.d.ts +0 -0
  177. /package/dist/{types → components/types}/annotationTypes.d.ts +0 -0
  178. /package/dist/{types → components/types}/generalTypes.d.ts +0 -0
  179. /package/dist/{types → components/types}/interactionTypes.d.ts +0 -0
  180. /package/dist/{types → components/types}/networkTypes.d.ts +0 -0
  181. /package/dist/{types → components/types}/ordinalTypes.d.ts +0 -0
@@ -1 +1 @@
1
- "use strict";const t=require("react"),e=require("d3-shape"),r=require("d3-scale"),i=require("d3-array"),n=require("d3-scale-chromatic"),o=require("d3-interpolate"),a=require("d3-force"),s=require("d3-chord"),c=require("d3-hierarchy");function l(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const r in t)if("default"!==r){const i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}return e.default=t,Object.freeze(e)}const u=l(t);class h{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 r of t){const t=this.push(r);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;const e=this;return{next:()=>e._size>t?{done:!1,value:e.get(t++)}:{done:!0,value:void 0}}}toArray(){const t=[];for(const e of this)t.push(e);return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),r=[];for(;e.length>t;)r.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 r}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 f{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 r of t){const t=e?e(r):r;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 d(t,e,r,i,n){const o=new Map;for(const a of t){const t=e(a),s=r(a);if(null==t||null==s||Number.isNaN(t)||Number.isNaN(s))continue;const c=Math.floor(t/i)*i;let l=o.get(c);if(l||(l={start:c,end:c+i,total:0,categories:new Map},o.set(c,l)),l.total+=s,n){const t=n(a);l.categories.set(t,(l.categories.get(t)||0)+s)}}return o}function y(t,e,r,i,n,o){const a=[],s=[];for(const n of t){const t=r(n),o=i(n);null==t||null==o||Number.isNaN(t)||Number.isNaN(o)||(a.push([e.x(t),e.y(o)]),s.push(o))}return{type:"line",path:a,rawValues:s,style:n,datum:t,group:o}}function g(t,e,r,i,n,o,a,s){const c=[],l=[];for(const o of t){const t=r(o),a=i(o);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const u=e.x(t);c.push([u,e.y(a)]);const h=s?s(o):n;l.push([u,e.y(h)])}return{type:"area",topPath:c,bottomPath:l,style:o,datum:t,group:a}}function p(t,e,r,i,n,o,a){const s=r(t),c=i(t);if(null==s||null==c||Number.isNaN(s)||Number.isNaN(c))return null;const l={type:"point",x:e.x(s),y:e.y(c),r:n,style:o,datum:t};return void 0!==a&&(l.pointId=a),l}function m(t,e,r,i,n,o,a){return{type:"rect",x:t,y:e,w:r,h:i,style:n,datum:o,group:a}}function x(t,e,r,i,n,o){return{type:"heatcell",x:t,y:e,w:r,h:i,fill:n,datum:o}}function v(t,e){if("function"==typeof t)return e=>+t(e);const r=t||e;return t=>+t[r]}function k(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}class b{constructor(t){this.xExtent=new f,this.yExtent=new f,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.scene=[],this.version=0,this.config=t,this.buffer=new h(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=v(t.timeAccessor||t.xAccessor,"time"),this.getY=v(t.valueAccessor||t.yAccessor,"value")):(this.getX=v(t.xAccessor,"x"),this.getY=v(t.yAccessor,"y")),this.getGroup=k(t.groupAccessor),this.getCategory=k(t.categoryAccessor),this.getSize=t.sizeAccessor?v(t.sizeAccessor,"size"):void 0,this.getColor=k(t.colorAccessor),this.getBounds=t.boundsAccessor?v(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?v(t.y0Accessor,"y0"):void 0,this.getPointId=k(t.pointIdAccessor),"candlestick"===t.chartType&&(this.getOpen=v(t.openAccessor,"open"),this.getHigh=v(t.highAccessor,"high"),this.getLow=v(t.lowAccessor,"low"),this.getClose=v(t.closeAccessor,"close")),t.pulse&&(this.timestampBuffer=new h(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,t.bounded){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const r=t.totalSize||t.inserts.length;r>this.buffer.capacity&&(this.buffer.resize(r),this.timestampBuffer&&r>this.timestampBuffer.capacity&&this.timestampBuffer.resize(r));for(const r of t.inserts)this.buffer.push(r),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(r)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(r)),this.yExtent.push(this.getLow(r))):(this.yExtent.push(this.getY(r)),this.getY0&&this.yExtent.push(this.getY0(r)))}else for(const r of t.inserts){"growing"===this.config.windowMode&&this.buffer.full&&(this.growingCap*=2,this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap));const t=this.buffer.push(r);this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(r)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(r)),this.yExtent.push(this.getLow(r))):(this.yExtent.push(this.getY(r)),this.getY0&&this.yExtent.push(this.getY0(r))),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,i,n,o,a,s;const{config:c,buffer:l}=this;if(this.xExtent.dirty&&this.xExtent.recalculate(l,this.getX),this.yExtent.dirty)if("candlestick"===c.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of l)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(l,this.getY);const u=this.xExtent.extent,h=this.yExtent.extent;let f=c.xExtent?[null!==(e=c.xExtent[0])&&void 0!==e?e:u[0],null!==(i=c.xExtent[1])&&void 0!==i?i:u[1]]:u,y=c.yExtent?[null!==(n=c.yExtent[0])&&void 0!==n?n:h[0],null!==(o=c.yExtent[1])&&void 0!==o?o:h[1]]:h;const g=c.yExtent&&null!=c.yExtent[0]&&null!=c.yExtent[1];if("stackedarea"===c.chartType&&!g&&l.size>0)if(c.normalize)y=[0,1+c.extentPadding];else{const t=l.toArray(),e=this.groupData(t),r=new Map;for(const t of e)for(const e of t.data){const t=this.getX(e),i=this.getY(e);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||r.set(t,(r.get(t)||0)+i)}let i=0;for(const t of r.values())t>i&&(i=t);y=[0,i+(i>0?i*c.extentPadding:1)]}else if("bar"===c.chartType&&c.binSize&&!g&&l.size>0){const[,t]=function(t,e,r,i,n){const o=d(t,e,r,i,n);if(0===o.size)return[0,0];let a=0;for(const t of o.values())t.total>a&&(a=t.total);return[0,a]}(l,this.getX,this.getY,c.binSize,this.getCategory);y=[0,t+t*c.extentPadding]}else if("waterfall"===c.chartType&&!g&&l.size>0){const[t,e]=function(t,e){let r=0,i=0,n=0;for(const o of t){const t=e(o);null==t||Number.isNaN(t)||(n+=t,r>n&&(r=n),n>i&&(i=n))}return[r,i]}(l,this.getY),r=e-t,i=r>0?r*c.extentPadding:1;y=[Math.min(0,t-Math.abs(i)),Math.max(0,e+Math.abs(i))]}else if(!g&&y[0]!==1/0){if(this.getBounds){const t=l.toArray();for(const e of t){const t=this.getY(e),r=this.getBounds(e);null!=t&&!Number.isNaN(t)&&r&&(t+r>y[1]&&(y[1]=t+r),y[0]>t-r&&(y[0]=t-r))}}const t=y[1]-y[0],e=t>0?t*c.extentPadding:1,r=null===(a=c.yExtent)||void 0===a?void 0:a[0],i=null===(s=c.yExtent)||void 0===s?void 0:s[1];y=[null!=r?y[0]:y[0]-e,null!=i?y[1]:y[1]+e]}if(f[0]!==1/0&&f[1]!==-1/0||(f=[0,1]),y[0]!==1/0&&y[1]!==-1/0||(y=[0,1]),void 0!==c.arrowOfTime)if("x"==("up"===(p=c.arrowOfTime)||"down"===p?"y":"x")){const e="right"===c.arrowOfTime?[0,t.width]:[t.width,0];this.scales={x:r.scaleLinear().domain(f).range(e),y:r.scaleLinear().domain(y).range([t.height,0])}}else{const e="down"===c.arrowOfTime?[0,t.height]:[t.height,0];this.scales={x:r.scaleLinear().domain(y).range([0,t.width]),y:r.scaleLinear().domain(f).range(e)}}else this.scales={x:r.scaleLinear().domain(f).range([0,t.width]),y:r.scaleLinear().domain(y).range([t.height,0])};var p;this.config.transition&&this.scene.length>0&&this.snapshotPositions();const m=l.toArray();this.scene=this.buildSceneNodes(t),this.config.decay&&this.applyDecay(this.scene,m),this.config.pulse&&this.applyPulse(this.scene,m),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}buildSceneNodes(t){const{config:e,buffer:r,scales:i}=this;if(!i||0===r.size)return[];const n=r.toArray();switch(e.chartType){case"line":return this.buildLineScene(n);case"area":return this.buildAreaScene(n);case"stackedarea":return this.buildStackedAreaScene(n);case"scatter":case"bubble":return this.buildPointScene(n);case"heatmap":return this.buildHeatmapScene(n,t);case"bar":return this.buildBarScene(n);case"swarm":return this.buildSwarmScene(n);case"waterfall":return this.buildWaterfallScene(n,t);case"candlestick":return this.buildCandlestickScene(n,t);default:return[]}}buildLineScene(t){var e;const r=this.groupData(t),i=[],n=null===(e=this.config.annotations)||void 0===e?void 0:e.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(this.getBounds)for(const t of r){const e=this.buildBoundsForGroup(t.data,t.key);e&&i.push(e)}for(const t of r){const e=this.resolveLineStyle(t.key,t.data[0]),r=y(t.data,this.scales,this.getX,this.getY,e,t.key);n&&n.length>0&&(r.colorThresholds=n),i.push(r)}return i}buildAreaScene(t){const e=this.groupData(t),r=[],i=this.scales.y.domain()[0];for(const t of e){const e=this.resolveAreaStyle(t.key,t.data[0]),n=g(t.data,this.scales,this.getX,this.getY,i,e,t.key,this.getY0);this.config.gradientFill&&(n.fillGradient=this.config.gradientFill),r.push(n)}return r}buildStackedAreaScene(t){const e=this.groupData(t);return e.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0),function(t,e,r,i,n,o){var a;const s=new Set;for(const e of t)for(const t of e.data){const e=r(t);null==e||Number.isNaN(e)||s.add(e)}const c=Array.from(s).sort((t,e)=>t-e),l=new Map;for(const e of t){const t=new Map;for(const n of e.data){const e=r(n),o=i(n);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||t.set(e,(t.get(e)||0)+o)}l.set(e.key,t)}let u;if(o){u=new Map;for(const e of c){let r=0;for(const i of t)r+=(null===(a=l.get(i.key))||void 0===a?void 0:a.get(e))||0;u.set(e,r||1)}}const h=[],f=new Map;for(const t of c)f.set(t,0);for(const r of t){const t=l.get(r.key),i=[],a=[];for(const r of c){let n=t.get(r)||0;const s=f.get(r);o&&(n/=u.get(r));const c=e.x(r);a.push([c,e.y(s)]),i.push([c,e.y(s+n)]),f.set(r,s+n)}h.push({type:"area",topPath:i,bottomPath:a,style:n(r.key,r.data[0]),datum:r.data,group:r.key})}return h}(e,this.scales,this.getX,this.getY,(t,e)=>this.resolveAreaStyle(t,e),this.config.normalize)}buildPointScene(t){const e=[],r="bubble"===this.config.chartType?10:5,i=this.config.sizeRange||[3,15];let n=null;if(this.getSize&&!this.config.pointStyle){const e=t.map(t=>this.getSize(t)).filter(t=>null!=t&&!Number.isNaN(t));if(e.length>0){const t=Math.min(...e),r=Math.max(...e);n=e=>t===r?(i[0]+i[1])/2:i[0]+(e-t)/(r-t)*(i[1]-i[0])}}let o=null;if(this.getColor&&!this.config.pointStyle){const e=new Set;for(const r of t){const t=this.getColor(r);t&&e.add(t)}const r=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];o=new Map;let i=0;for(const t of e)o.set(t,r[i%r.length]),i++}for(const i of t){let t=this.config.pointStyle?this.config.pointStyle(i):{fill:"#4e79a7",opacity:.8},a=t.r||r;if(n&&this.getSize){const t=this.getSize(i);null==t||Number.isNaN(t)||(a=n(t))}if(o&&this.getColor){const e=this.getColor(i);e&&o.has(e)&&(t=Object.assign(Object.assign({},t),{fill:o.get(e)}))}const s=this.getPointId?this.getPointId(i)+"":void 0,c=p(i,this.scales,this.getX,this.getY,a,t,s);c&&e.push(c)}return e}buildHeatmapScene(t,e){const r=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(t,e);const i=v(this.config.valueAccessor,"value"),n=new Set,o=new Set;for(const e of t)n.add(this.getX(e)),o.add(this.getY(e));const a=Array.from(n).sort((t,e)=>t-e),s=Array.from(o).sort((t,e)=>t-e);if(0===a.length||0===s.length)return r;const c=e.width/a.length,l=e.height/s.length,u=new Map;for(const e of t){const t=`${this.getX(e)}_${this.getY(e)}`;u.set(t,{val:i(e),datum:e})}let h=1/0,f=-1/0;for(const{val:t}of u.values())h>t&&(h=t),t>f&&(f=t);const d=f-h||1;for(let t=0;a.length>t;t++)for(let e=0;s.length>e;e++){const i=u.get(`${a[t]}_${s[e]}`);if(!i)continue;const n=(i.val-h)/d;r.push(x(t*c,(s.length-1-e)*l,c,l,`rgb(${Math.round(220-180*n)},${Math.round(220-100*n)},${Math.round(255-50*n)})`,i.datum))}return r}buildStreamingHeatmapScene(t,e){var r,i,n;const o=[],a=null!==(r=this.config.heatmapXBins)&&void 0!==r?r:20,s=null!==(i=this.config.heatmapYBins)&&void 0!==i?i:20,c=null!==(n=this.config.heatmapAggregation)&&void 0!==n?n:"count",l=v(this.config.valueAccessor,"value");if(!this.scales||0===t.length)return o;const[u,h]=this.scales.x.domain(),[f,d]=this.scales.y.domain(),y=(h-u||1)/a,g=(d-f||1)/s,p=new Map;for(const e of t){const t=this.getX(e),r=this.getY(e),i=Math.min(Math.floor((t-u)/y),a-1),n=Math.min(Math.floor((r-f)/g),s-1);if(0>i||0>n)continue;const o=`${i}_${n}`;let c=p.get(o);c||(c={sum:0,count:0,data:[]},p.set(o,c)),c.count++,c.sum+=l(e),c.data.push(e)}let m=1/0,k=-1/0;const b=new Map;for(const[t,e]of p){let r;switch(c){case"sum":r=e.sum;break;case"mean":r=e.count>0?e.sum/e.count:0;break;default:r=e.count}b.set(t,r),m>r&&(m=r),r>k&&(k=r)}const w=k-m||1,E=e.width/a,S=e.height/s;for(const[t,e]of b){const[r,i]=t.split("_"),n=+r,a=+i,c=(e-m)/w,l=`rgb(${Math.round(220-180*c)},${Math.round(220-100*c)},${Math.round(255-50*c)})`,u=p.get(t);o.push(x(n*E,(s-1-a)*S,E,S,l,{xi:n,yi:a,value:e,count:u.count,sum:u.sum,data:u.data}))}return o}buildBarScene(t){var e;if(!this.config.binSize)return[];const r=d(t,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===r.size)return[];let i=null;if(this.getCategory){const t=new Set;for(const e of r.values())for(const r of e.categories.keys())t.add(r);const e=this.config.barColors?Object.keys(this.config.barColors):[],n=new Set(e),o=Array.from(t).filter(t=>!n.has(t)).sort();i=[...e.filter(e=>t.has(e)),...o]}const n=[],o=this.scales,[a,s]=o.x.domain();for(const t of r.values()){const r=Math.max(t.start,a),c=Math.min(t.end,s);if(r>=c)continue;const l=o.x(r),u=o.x(c),h=Math.min(l,u)+.5,f=Math.max(l,u)-.5-h;if(f>0)if(i&&t.categories.size>0){let r=0;for(const a of i){const i=t.categories.get(a)||0;if(0===i)continue;const s=o.y(r),c=o.y(r+i);n.push(m(h,Math.min(s,c),f,Math.abs(s-c),{fill:(null===(e=this.config.barColors)||void 0===e?void 0:e[a])||"#4e79a7"},{binStart:t.start,binEnd:t.end,total:t.total,category:a,categoryValue:i},a)),r+=i}}else{const e=o.y(0),r=o.y(t.total);n.push(m(h,Math.min(e,r),f,Math.abs(e-r),{fill:"#007bff"},{binStart:t.start,binEnd:t.end,total:t.total}))}}return n}buildSwarmScene(t){var e,r,i,n;const o=[],a=this.config.swarmStyle||{},s=null!==(e=a.radius)&&void 0!==e?e:3,c=null!==(r=a.fill)&&void 0!==r?r:"#007bff",l=null!==(i=a.opacity)&&void 0!==i?i:.7,u=a.stroke,h=a.strokeWidth;for(const e of t){const t=this.getX(e),r=this.getY(e);if(null==r||Number.isNaN(r))continue;const i=this.scales.x(t),a=this.scales.y(r);let f=c;if(this.getCategory){const t=this.getCategory(e);f=(null===(n=this.config.barColors)||void 0===n?void 0:n[t])||f}const d={type:"point",x:i,y:a,r:s,style:{fill:f,opacity:l,stroke:u,strokeWidth:h},datum:e};this.getPointId&&(d.pointId=this.getPointId(e)+""),o.push(d)}return o}buildWaterfallScene(t,e){var r,i,n;const o=[],a=this.scales,s=this.config.waterfallStyle,c=t.filter(t=>{const e=this.getY(t);return null!=e&&!Number.isNaN(e)});if(0===c.length)return o;const l=null!==(r=null==s?void 0:s.positiveColor)&&void 0!==r?r:"#28a745",u=null!==(i=null==s?void 0:s.negativeColor)&&void 0!==i?i:"#dc3545",h=null!==(n=null==s?void 0:s.gap)&&void 0!==n?n:1,f=null==s?void 0:s.stroke,d=null==s?void 0:s.strokeWidth;let y=0;for(let t=0;c.length>t;t++){const r=c[t],i=this.getX(r),n=this.getY(r),g=y+n;let p;p=c.length-1>t?this.getX(c[t+1])-i:t>0?i-this.getX(c[t-1]):0;const x=a.x(i),v=0!==p?a.x(i+p):x+e.width/10,k=Math.min(x,v)+h/2,b=Math.max(x,v)-h/2-k;if(0>=b){y=g;continue}const w=a.y(y),E=a.y(g);o.push(m(k,Math.min(w,E),b,Math.abs(w-E),{fill:0>n?u:l,stroke:f,strokeWidth:d},Object.assign(Object.assign({},r),{baseline:y,cumEnd:g,delta:n,_connectorStroke:null==s?void 0:s.connectorStroke,_connectorWidth:null==s?void 0:s.connectorWidth}))),y=g}return o}buildCandlestickScene(t,e){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const r=[],i=this.config.candlestickStyle||{},n=i.upColor||"#28a745",o=i.downColor||"#dc3545",a=i.wickColor||"#333",s=i.wickWidth||1,c=t.map(t=>this.getX(t)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let l=i.bodyWidth||6;if(!i.bodyWidth&&c.length>1){let t=1/0;for(let e=1;c.length>e;e++){const r=Math.abs(this.scales.x(c[e])-this.scales.x(c[e-1]));r>0&&t>r&&(t=r)}t!==1/0&&(l=Math.max(2,Math.min(.6*t,20)))}for(const e of t){const t=this.getX(e);if(null==t||Number.isNaN(t))continue;const i=this.getOpen(e),c=this.getHigh(e),u=this.getLow(e),h=this.getClose(e);if([i,c,u,h].some(t=>null==t||Number.isNaN(t)))continue;const f=h>=i;r.push({type:"candlestick",x:this.scales.x(t),openY:this.scales.y(i),closeY:this.scales.y(h),highY:this.scales.y(c),lowY:this.scales.y(u),bodyWidth:l,upColor:n,downColor:o,wickColor:a,wickWidth:s,isUp:f,datum:e})}return r}buildBoundsForGroup(t,e){if(!this.getBounds||!this.scales)return null;const r=[],i=[];for(const e of t){const t=this.getX(e),n=this.getY(e);if(null==t||null==n||Number.isNaN(t)||Number.isNaN(n))continue;const o=this.getBounds(e),a=this.scales.x(t);if(o&&0!==o)r.push([a,this.scales.y(n+o)]),i.push([a,this.scales.y(n-o)]);else{const t=this.scales.y(n);r.push([a,t]),i.push([a,t])}}return 2>r.length?null:{type:"area",topPath:r,bottomPath:i,style:this.resolveBoundsStyle(e,t[0]),datum:t,group:e,interactive:!1}}resolveBoundsStyle(t,e){const r=this.config.boundsStyle;return"function"==typeof r?r(e||{},t):r&&"object"==typeof r?r:{fill:this.resolveLineStyle(t,e).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){var r,i,n;const o=this.config.decay;if(!o||1>=e)return 1;const a=null!==(r=o.minOpacity)&&void 0!==r?r:.1,s=e-1-t;switch(o.type){case"linear":return a+(1-s/(e-1))*(1-a);case"exponential":{const t=null!==(i=o.halfLife)&&void 0!==i?i:e/2;return a+Math.pow(.5,s/t)*(1-a)}case"step":return(null!==(n=o.stepThreshold)&&void 0!==n?n:.5*e)>s?1:a;default:return 1}}applyDecay(t,e){var r,i;if(!this.config.decay)return;const n=e.length;if(1>=n)return;const o=new Map;for(let t=0;e.length>t;t++)o.set(e[t],t);for(const e of t){if("line"===e.type||"area"===e.type)continue;const t=o.get(e.datum);if(null==t)continue;const a=this.computeDecayOpacity(t,n);if("heatcell"===e.type)e.style={opacity:a};else if("candlestick"===e.type)e._decayOpacity=a;else{const t=null!==(i=null===(r=e.style)||void 0===r?void 0:r.opacity)&&void 0!==i?i:1;e.style=Object.assign(Object.assign({},e.style),{opacity:t*a})}}}computePulseIntensity(t,e){var r;const i=this.config.pulse;if(!i)return 0;const n=null!==(r=i.duration)&&void 0!==r?r:500,o=e-t;return n>o?1-o/n:0}applyPulse(t,e){var r,i;if(!this.config.pulse||!this.timestampBuffer)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(r=this.config.pulse.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",a=null!==(i=this.config.pulse.glowRadius)&&void 0!==i?i:4,s=new Map;for(let t=0;e.length>t;t++)s.set(e[t],t);for(const e of t){if("line"===e.type||"area"===e.type)continue;const t=s.get(e.datum);if(null==t)continue;const r=this.timestampBuffer.get(t);if(null==r)continue;const i=this.computePulseIntensity(r,n);i>0&&(e._pulseIntensity=i,e._pulseColor=o,e._pulseGlowRadius=a)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,i=this.timestampBuffer.peek();return null!=i&&r>e-i}snapshotPositions(){this.prevPositionMap.clear();for(let t=0;this.scene.length>t;t++){const e=this.scene[t],r=this.getNodeIdentity(e,t);r&&("point"===e.type?this.prevPositionMap.set(r,{x:e.x,y:e.y,r:e.r}):"rect"===e.type||"heatcell"===e.type?this.prevPositionMap.set(r,{x:e.x,y:e.y,w:e.w,h:e.h}):"candlestick"===e.type&&this.prevPositionMap.set(r,{x:e.x,y:e.openY}))}}getNodeIdentity(t,e){var r,i,n,o;switch(t.type){case"point":return`p:${void 0===t.datum?e:this.getX(t.datum)}_${this.getY(t.datum)}`;case"rect":return`r:${t.group||""}:${null!==(o=null!==(i=null===(r=t.datum)||void 0===r?void 0:r.binStart)&&void 0!==i?i:null===(n=t.datum)||void 0===n?void 0:n.category)&&void 0!==o?o:e}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return"c:"+this.getX(t.datum);default:return null}}startTransition(){var t,e,r,i,n,o;if(!this.config.transition||0===this.prevPositionMap.size)return;const a=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;let s=!1;for(let t=0;this.scene.length>t;t++){const a=this.scene[t],c=this.getNodeIdentity(a,t);if(!c)continue;const l=this.prevPositionMap.get(c);if(l)if("point"===a.type){const t={x:a.x,y:a.y,r:a.r};l.x===t.x&&l.y===t.y||(a._targetX=t.x,a._targetY=t.y,a._targetR=t.r,a.x=l.x,a.y=l.y,a.r=null!==(e=l.r)&&void 0!==e?e:a.r,s=!0)}else if("rect"===a.type){const t={x:a.x,y:a.y,w:a.w,h:a.h};l.x===t.x&&l.y===t.y&&l.w===t.w&&l.h===t.h||(a._targetX=t.x,a._targetY=t.y,a._targetW=t.w,a._targetH=t.h,a.x=l.x,a.y=l.y,a.w=null!==(r=l.w)&&void 0!==r?r:a.w,a.h=null!==(i=l.h)&&void 0!==i?i:a.h,s=!0)}else if("heatcell"===a.type){const t={x:a.x,y:a.y,w:a.w,h:a.h};l.x===t.x&&l.y===t.y||(a._targetX=t.x,a._targetY=t.y,a._targetW=t.w,a._targetH=t.h,a.x=l.x,a.y=l.y,a.w=null!==(n=l.w)&&void 0!==n?n:a.w,a.h=null!==(o=l.h)&&void 0!==o?o:a.h,s=!0)}}s&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:a})}advanceTransition(t){var e;if(!this.activeTransition)return!1;const r=Math.min((t-this.activeTransition.startTime)/this.activeTransition.duration,1),i="linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?r:1-Math.pow(1-r,3);for(const t of this.scene)if("point"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const r=this.prevPositionMap.get(e);if(!r)continue;t.x=r.x+(t._targetX-r.x)*i,t.y=r.y+(t._targetY-r.y)*i,void 0!==t._targetR&&void 0!==r.r&&(t.r=r.r+(t._targetR-r.r)*i)}else if("rect"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const r=this.prevPositionMap.get(e);if(!r)continue;t.x=r.x+(t._targetX-r.x)*i,t.y=r.y+(t._targetY-r.y)*i,void 0!==r.w&&(t.w=r.w+(t._targetW-r.w)*i),void 0!==r.h&&(t.h=r.h+(t._targetH-r.h)*i)}else if("heatcell"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const r=this.prevPositionMap.get(e);if(!r)continue;t.x=r.x+(t._targetX-r.x)*i,t.y=r.y+(t._targetY-r.y)*i,void 0!==r.w&&(t.w=r.w+(t._targetW-r.w)*i),void 0!==r.h&&(t.h=r.h+(t._targetH-r.h)*i)}if(r>=1){for(const t of this.scene)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}return this.activeTransition=null,!1}return!0}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const r of t){const t=this.getGroup(r);e.has(t)||e.set(t,[]),e.get(t).push(r)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveLineStyle(t,e){const r=this.config.lineStyle;return"function"==typeof r?r(e||{},t):r&&"object"==typeof r?{stroke:r.stroke||"#007bff",strokeWidth:r.strokeWidth||2,strokeDasharray:r.strokeDasharray,fill:r.fill,fillOpacity:r.fillOpacity,opacity:r.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var r;if(this.config.areaStyle)return this.config.areaStyle(e||{});const i=this.config.lineStyle;return"function"==typeof i?i(e||{},t):i&&"object"==typeof i?{fill:i.fill||i.stroke||"#4e79a7",fillOpacity:null!==(r=i.fillOpacity)&&void 0!==r?r:.7,stroke:i.stroke||"#4e79a7",strokeWidth:i.strokeWidth||2}:{fill:"#4e79a7",fillOpacity:.7,stroke:"#4e79a7",strokeWidth:2}}getData(){return this.buffer.toArray()}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.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],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){Object.assign(this.config,t)}}function w(t,e){var r=t.get(e);if(!r)throw Error("missing: "+e);return r}function E(t,e){var r,i=[],n=[],o=[],a={},s=[];function c(t){o[t]=!1,a.hasOwnProperty(t)&&Object.keys(a[t]).forEach(function(e){delete a[t][e],o[e]&&c(e)})}function l(t){var e,i,h=!1;for(n.push(t),o[t]=!0,e=0;s[t].length>e;e++)(i=s[t][e])===r?(u(r,n),h=!0):o[i]||(h=l(i));if(h)c(t);else for(e=0;s[t].length>e;e++){var f=a[i=s[t][e]];f||(a[i]=f={}),f[i]=!0}return n.pop(),h}function u(t,e){var r=[].concat(e).concat(t);i.push(r)}function h(e){!function(e){for(var r=0;t.length>r;r++)r>=e&&t[r]||(t[r]=[]),t[r]=t[r].filter(function(t){return t>=e})}(e);for(var r,i=function(t){for(var e=t.length,r=Array(e),i=Array(e),n=Array(e),o=Array(e),a=Array(e),s=Array(e),c=0;e>c;++c)r[c]=-1,i[c]=0,n[c]=!1,o[c]=0,a[c]=-1,s[c]=[];var l,u=0,h=[],f=[];function d(e){var c=[e],l=[e];for(r[e]=i[e]=u,n[e]=!0,u+=1;l.length>0;){var d=t[e=l[l.length-1]];if(d.length>o[e]){for(var y=o[e];d.length>y;++y){var g=d[y];if(0>r[g]){r[g]=i[g]=u,n[g]=!0,u+=1,c.push(g),l.push(g);break}n[g]&&(i[e]=0|Math.min(i[e],i[g])),0>a[g]||s[e].push(a[g])}o[e]=y}else{if(i[e]===r[e]){var p=[],m=[],x=0;for(y=c.length-1;y>=0;--y){var v=c[y];if(n[v]=!1,p.push(v),m.push(s[v]),x+=s[v].length,a[v]=h.length,v===e){c.length=y;break}}h.push(p);var k=Array(x);for(y=0;m.length>y;y++)for(var b=0;m[y].length>b;b++)k[--x]=m[y][b];f.push(k)}l.pop()}}}for(c=0;e>c;++c)0>r[c]&&d(c);for(c=0;f.length>c;c++){var y=f[c];if(0!==y.length){y.sort(function(t,e){return t-e}),l=[y[0]];for(var g=1;y.length>g;g++)y[g]!==y[g-1]&&l.push(y[g]);f[c]=l}}return{components:h,adjacencyList:f}}(t),n=i.components.filter(function(t){return t.length>1}),o=1/0,a=0;n.length>a;a++)for(var s=0;n[a].length>s;s++)o>n[a][s]&&(o=n[a][s],r=a);var c=n[r];if(!c)return!1;var l=t.map(function(t,e){return-1===c.indexOf(e)?[]:t.filter(function(t){return-1!==c.indexOf(t)})});return{leastVertex:o,adjList:l}}r=0;for(var f=t.length;f>r;){var d=h(r);if(r=d.leastVertex,s=d.adjList){for(var y=0;s.length>y;y++)for(var g=0;s[y].length>g;g++){var p=s[y][g];o[+p]=!1,a[p]={}}l(r),r+=1}else r=f}return i}function S(t){return t.y0-t.y1>0?"up":"down"}function A(t,e){return e(t.source)==e(t.target)}function P(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var r=0;return t.target.targetLinks.forEach(function(t){r=t.circular?r+1:r}),1>=e&&1>=r}function L(t){return t.target.x0-t.source.x1}function M(t,e){var r=_(t),i=L(e)/Math.tan(r);return"up"==S(t)?t.y1-i:t.y1+i}function D(t,e){var r=_(t),i=L(e)/Math.tan(r);return"up"==S(t)?t.y1+i:t.y1-i}function _(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function $(t,e){return e(t)}function W(t){return T(t.source)}function N(t){return T(t.target)}function T(t){return(t.y0+t.y1)/2}function R(t){return t.virtual?0:t.value}function z(t,e){var r=0;t.sourceLinks.forEach(function(t){r=t.circular&&!A(t,e)?r+1:r});var i=0;return t.targetLinks.forEach(function(t){i=t.circular&&!A(t,e)?i+1:i}),r+i}function O(t){return t.target.depth}function B(t,e){return t.sourceLinks.length?t.depth:e-1}function Y(t,e){return t.y0-e.y0}function X(t,e){return e.y0-t.y0}function C(t,e){return t.y1-e.y1}function j(t,e){return e.y1-t.y1}function I(t,e){return q(t.source,e.source)||t.index-e.index}function F(t,e){return q(t.target,e.target)||t.index-e.index}function q(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function H(t,e){return G(t)==G(e)?"bottom"==t.circularLinkType?X(t,e):Y(t,e):G(e)-G(t)}function G(t){return t.target.column-t.source.column}function V(t,e){return Z(t)==Z(e)}function Z(t){return t.y0-t.y1>0?"up":"down"}function Q(t,e,r,n,o){let a=t;var s=Math.max(8,.15*(a.y1-a.y0));a.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,s))});var c=i.min(a.links,function(t){return t.source.y0});a.links.forEach(function(t){t.circular&&(t.circularPathData={})});var l=a.links.filter(function(t){return t.circular});return l.sort(function(t,e){return e.value-t.value}),l.forEach(function(t,e){t._circularStub=e>=4}),U(a.links.filter(function(t){return"top"==t.circularLinkType}),e,r),U(a.links.filter(function(t){return"bottom"==t.circularLinkType}),e,r),a.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+n,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,A(t,e)&&P(t))t.circularPathData.rightSmallArcRadius=n+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=n+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=n+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=n+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 i=t.source.column,s=t.circularLinkType,l=a.links.filter(function(t){return t.source.column==i&&t.circularLinkType==s});l.sort("bottom"==t.circularLinkType?X:Y);var u=0;l.forEach(function(e,i){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=n+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=n+t._circularWidth/2+i*r+u),u+=e._circularWidth||e.width}),i=t.target.column,(l=a.links.filter(function(t){return t.target.column==i&&t.circularLinkType==s})).sort("bottom"==t.circularLinkType?j:C),u=0,l.forEach(function(e,i){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=n+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=n+t._circularWidth/2+i*r+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(a.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=c-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,r=t.y0,i=t.target.x0,n=t.y1,o=(e+i)/2;return"M"+e+","+r+"C"+o+","+r+" "+o+","+n+" "+i+","+n}(t)}),a}function U(t,e,r){t.sort(H);var i=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,n){var o=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(A(t,e)&&P(t))t.circularPathData.verticalBuffer=o+t._circularWidth/2;else{for(var a=0;i.length>a;a++){var s=i[a];if(s!==t&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&J(t,s)){var c=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+r;o=c>o?c:o}}t.circularPathData.verticalBuffer=o+t._circularWidth/2}}),t}function J(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function K(t){return function(){return t}}function tt(t){return t.index}function et(t){return t.nodes}function rt(t){return t.links}function it(t,e,r){var n=i.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});n.forEach(function(i){var o=i.length;i.sort(e||function(t,e){return t.circularLinkType==e.circularLinkType?z(e,r)-z(t,r):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0}),i.forEach(function(e,i){e.depth==n.length-1&&1==o||0==e.depth&&1==o?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==z(e,r)?(e.y0=t.y1/2+i,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+i,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-i,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/o*i,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-o/2+i,e.y1=e.y0+e.value*t.ky)})})}function nt(t,e,r,n,o,a){var s=i.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});h();for(var c=1,l=a;l>0;--l)u(c*=.99,r),h();function u(e,r){var n=s.length;s.forEach(function(o){var a=o.length,s=o[0].depth;o.forEach(function(o){var c;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&z(o,r)>0){var l=i.mean(o.sourceLinks,N),u=i.mean(o.targetLinks,W),h=l&&u?(l+u)/2:l||u;if(h){var f=(h-T(o))*e*.3;o.y0+=f,o.y1+=f}}else if(0==s&&1==a)o.y0=t.y1/2-(c=o.y1-o.y0)/2,o.y1=t.y1/2+c/2;else if(s==n-1&&1==a)o.y0=t.y1/2-(c=o.y1-o.y0)/2,o.y1=t.y1/2+c/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)c=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+c;else{var d=i.mean(o.sourceLinks,N),y=i.mean(o.targetLinks,W),g=((d&&y?(d+y)/2:d||y)-T(o))*e;o.y0+=g,o.y1+=g}})})}function h(){s.forEach(function(r){var i,a,s,c=t.y0,l=r.length;for(r.sort(e||q),s=0;l>s;++s)(a=c-(i=r[s]).y0)>0&&(i.y0+=a,i.y1+=a),c=i.y1+n;if((a=c-n-t.y1)>0)for(c=i.y0-=a,i.y1-=a,s=l-2;s>=0;--s)(a=(i=r[s]).y1+o-c)>0&&(i.y0-=a,i.y1-=a),c=i.y0})}}function ot(t){t.nodes.forEach(function(t){t.sourceLinks.sort(F),t.targetLinks.sort(I)}),t.nodes.forEach(function(t){var e=t.y0,r=e,i=t.y1,n=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=n-t.width/2,n-=t.width):(t.y1=r+t.width/2,r+=t.width)})})}function at(){var t=0,e=0,r=1,n=1,o=24,a=8,s=null,c=tt,l=B,u=void 0,h=32,f=2,d=et,y=rt;function g(){var g={nodes:d.apply(null,arguments),links:y.apply(null,arguments)};return function(d){d.x0=t,d.y0=e,d.x1=r,d.y1=n,d.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var r=function(t,e){var r=new Map;return i.group(t,e).forEach(function(t,e){r.set(e,t[0])}),r}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var i=t.source,n=t.target;"object"!=typeof i&&(i=t.source=w(r,i)),"object"!=typeof n&&(n=t.target=w(r,n)),i.sourceLinks.push(t),n.targetLinks.push(t)})}(d,c),function(t,e){var r=0;if(null==e){for(var i=[],n=0;t.links.length>n;n++){var o=t.links[n],a=o.source.index,s=o.target.index;i[a]||(i[a]=[]),i[s]||(i[s]=[]),-1===i[a].indexOf(s)&&i[a].push(s)}var c=E(i);c.sort(function(t,e){return t.length-e.length});var l={};for(n=0;c.length>n;n++){var u=c[n].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,i=t.source.index;e===i||l[i]&&l[i][e]?(t.circular=!0,t.circularLinkID=r++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=r++)})}(d,u),function(t,e){var r=0,i=0;t.links.forEach(function(n){n.circular&&(n.circularLinkType=n.source.circularLinkType||n.target.circularLinkType?n.source.circularLinkType?n.source.circularLinkType:n.target.circularLinkType:i>r?"top":"bottom","top"==n.circularLinkType?r++:i++,t.nodes.forEach(function(t){$(t,e)!=$(n.source,e)&&$(t,e)!=$(n.target,e)||(t.circularLinkType=n.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),A(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(d,c),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(i.sum(t.sourceLinks,R),i.sum(t.targetLinks,R)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(d),function(t,e,r){var i,n,o;if(null!=e){t.nodes.sort(function(t,r){return e(t)<e(r)?-1:1});var a=0,s=e(t.nodes[0]);t.nodes.forEach(function(t){a=e(t)==s?a:a+1,s=e(t)==s?s:e(t),t.column=a})}for(i=t.nodes,n=[],o=0;i.length;++o,i=n,n=[])i.forEach(function(t){t.depth=o,t.sourceLinks.forEach(function(t){0>n.indexOf(t.target)&&!t.circular&&n.push(t.target)})});for(i=t.nodes,n=[],o=0;i.length;++o,i=n,n=[])i.forEach(function(t){t.height=o,t.targetLinks.forEach(function(t){0>n.indexOf(t.source)&&!t.circular&&n.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?r(t,o):t.column})}(d,u,l);var y=a;if(null!==s){var g=i.groups(d.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=i.max(g,function(t){return t.length});p>1&&(y=Math.max(1,(n-e)*s/(p-1)))}(function(t,e,r){var n=i.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=i.min(n,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/i.sum(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var a=i.max(t.nodes,function(t){return t.column});t.nodes.forEach(a>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-r)/a),e.x1=e.x0+r}:function(e){e.x0=t.x0,e.x1=e.x0+r})})(d,y,o),it(d,u,c),nt(d,u,c,y,y,h),ot(d),Q(d,c,f,10,8),it(d,u,c),nt(d,u,c,y,y,h),ot(d),Q(d,c,f,10,8),function(t,e){let r=t;r.nodes.forEach(function(t){t.y+(t.y1-t.y0)>r.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-r.y1));var i=r.links.filter(function(r){return $(r.source,e)==$(t,e)}),n=i.length;n>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!V(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var r=M(e,t);return t.y1-r}if(e.target.column>t.target.column)return M(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 o=t.y0;i.forEach(function(t){t.y0=o+t.width/2,o+=t.width}),i.forEach(function(e,r){if("bottom"==e.circularLinkType){for(var o=r+1,a=0;n>o;o++)a+=i[o].width;e.y0=t.y1-a-e.width/2}})})}(d,c),function(t,e){let r=t;r.nodes.forEach(function(t){var i=r.links.filter(function(r){return $(r.target,e)==$(t,e)}),n=i.length;n>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!V(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var r=D(e,t);return t.y0-r}if(e.source.column>t.source.column)return D(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 o=t.y0;i.forEach(function(t){t.y1=o+t.width/2,o+=t.width}),i.forEach(function(e,r){if("bottom"==e.circularLinkType){for(var o=r+1,a=0;n>o;o++)a+=i[o].width;e.y1=t.y1-a-e.width/2}})})}(d,c),function(t){var e=t.nodes,r=t.links,n=!1,o=!1;if(r.forEach(function(t){"top"==t.circularLinkType?n=!0:"bottom"==t.circularLinkType&&(o=!0)}),0==n||0==o){var a=i.min(e,function(t){return t.y0}),s=i.max(e,function(t){return t.y1}),c=(t.y1-t.y0)/(s-a);function l(e){return(e-a)/(s-a)*(t.y1-t.y0)+t.y0}1>c?(e.forEach(function(t){t.y0=l(t.y0),t.y1=l(t.y1)}),r.forEach(function(t){t.y0=l(t.y0),t.y1=l(t.y1),t.width=t.width*c})):e.forEach(function(t){var e=t.y1-t.y0,r=l(t.y0)-t.y0;t.y0=l(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+r}),t.targetLinks.forEach(function(t){t.y1=t.y1+r})})}}(d),Q(d,c,f,10,8)}(g),g}return g.update=function(t){return ot(t),Q(t,c,f,10,8),t},g.nodeWidth=function(t){return arguments.length?(o=+t,g):o},g.nodePadding=function(t){return arguments.length?(a=+t,g):a},g.nodePaddingRatio=function(t){return arguments.length?(s=+t,g):s},g.nodes=function(t){return arguments.length?(d="function"==typeof t?t:K(t),g):d},g.links=function(t){return arguments.length?(y="function"==typeof t?t:K(t),g):y},g.nodeId=function(t){return arguments.length?(c="function"==typeof t?t:K(t),g):c},g.nodeAlign=function(t){return arguments.length?(l="function"==typeof t?t:K(t),g):l},g.nodeSort=function(t){return arguments.length?(u=t,g):u},g.iterations=function(t){return arguments.length?(h=+t,g):h},g.circularLinkGap=function(t){return arguments.length?(f=+t,g):f},g.extent=function(i){return arguments.length?(t=+i[0][0],e=+i[0][1],r=+i[1][0],n=+i[1][1],g):[[t,e],[r,n]]},g.size=function(i){return arguments.length?(t=e=0,r=+i[0],n=+i[1],g):[r-t,n-e]},g}const st=t=>{let e,r,i,n,a,s,c,l,u;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,r=t.y1-t.sankeyWidth/2,i=t.y1+t.sankeyWidth/2,n=t.y0+t.sankeyWidth/2,a=t.source.y1,s=t.target.y0,c=o.interpolateNumber(a,s),l=c(.5),u=c(.5),`M${e},${a}C${e},${l} ${r},${u} ${r},${s}L${i},${s}C${i},${u} ${n},${l} ${n},${a}Z`):(e=t.source.x1,r=t.target.x0,c=o.interpolateNumber(e,r),i=c(.5),n=c(.5),a=t.y0-t.sankeyWidth/2,s=t.y1-t.sankeyWidth/2,l=t.y1+t.sankeyWidth/2,u=t.y0+t.sankeyWidth/2,`M${e},${a}C${i},${a} ${n},${s} ${r},${s}L${r},${l}C${n},${l} ${i},${u} ${e},${u}Z`)};function ct(t){var e;const r=t.sankeyWidth/2,i=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,n=t.circularPathData;if(!n)return null;if("down"===t.direction)return null;if(t._circularStub){const e=n.sourceX,i=n.sourceY,o=n.targetX,a=n.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const s=Math.max(15,Math.min(40,.33*(n.rightFullExtent-e))),c=Math.max(15,Math.min(40,.33*(o-n.leftFullExtent)));return`M${e},${i-r}L${e+s},${i-r}L${e+s},${i+r}L${e},${i+r}ZM${o},${a-r}L${o-c},${a-r}L${o-c},${a+r}L${o},${a+r}Z`}const o=n.sourceX,a=n.sourceY,s=n.targetX,c=n.targetY,l=n.rightFullExtent,u=n.leftFullExtent,h=n.verticalFullExtent,f="bottom"===t.circularLinkType?1:-1,d=Math.max(4,Math.min(i,15));return`M${o},${a-f*r}L${l},${a-f*r}L${l+i},${a-f*r+f*d}L${l+i},${h+f*i-f*d}L${l+i-d},${h+f*i}L${u-i+d},${h+f*i}L${u-i},${h+f*i-f*d}L${u-i},${c-f*r+f*d}L${u-i+d},${c-f*r}L${s},${c-f*r}L${s},${c+f*r}L${u+i},${c+f*r}L${u+i},${h-f*i}L${l-i},${h-f*i}L${l-i},${a+f*r}L${o},${a+f*r}Z`}const lt={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(O))-1:0},justify:B},ut={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,r,i){var n,o,a,s,c,l,u;if(0===t.length)return;const h="vertical"===r.orientation?"down":"right",f=r.nodeAlign||"justify",d=null!==(n=r.nodeWidth)&&void 0!==n?n:15,y=null!==(o=r.nodePaddingRatio)&&void 0!==o?o:.05,g=null!==(a=r.iterations)&&void 0!==a?a:100,p=t.map(t=>Object.assign({},t)),m=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 x;x="down"===h?[[0,0],[i[1],i[0]]]:[[0,0],[i[0],i[1]]];const v=at().extent(x).links(m).nodes(p).nodeAlign(lt[f]||B).nodeId(t=>t.id).nodeWidth(d).iterations(g);v.nodePaddingRatio&&v.nodePaddingRatio(y),v();{let t=1/0,e=-1/0,r=1/0,n=-1/0;for(const i of p)t>i.x0&&(t=i.x0),i.x1>e&&(e=i.x1),r>i.y0&&(r=i.y0),i.y1>n&&(n=i.y1);for(const i of m){if(!i.circular||!i.circularPathData)continue;const o=i.circularPathData,a=(null!==(c=null!==(s=i._circularWidth)&&void 0!==s?s:i.width)&&void 0!==c?c:0)/2;t>o.leftFullExtent-a&&(t=o.leftFullExtent-a),o.rightFullExtent+a>e&&(e=o.rightFullExtent+a),r>o.verticalFullExtent-a&&(r=o.verticalFullExtent-a),o.verticalFullExtent+a>n&&(n=o.verticalFullExtent+a)}const o=e-t,a=n-r,u=i[0],h=i[1];if(o>0&&a>0&&(0>t||0>r||e>u||n>h)){const e=Math.min(u/o,h/a),i=-t*e+(u-o*e)/2,n=-r*e+(h-a*e)/2;for(const t of p)t.x0=t.x0*e+i,t.x1=t.x1*e+i,t.y0=t.y0*e+n,t.y1=t.y1*e+n;for(const t of m)if(t.y0=t.y0*e+n,t.y1=t.y1*e+n,t.width=(null!==(l=t.width)&&void 0!==l?l:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const r=t.circularPathData;r.sourceX=r.sourceX*e+i,r.targetX=r.targetX*e+i,r.sourceY=r.sourceY*e+n,r.targetY=r.targetY*e+n,r.rightFullExtent=r.rightFullExtent*e+i,r.leftFullExtent=r.leftFullExtent*e+i,r.verticalFullExtent=r.verticalFullExtent*e+n,r.rightInnerExtent=r.rightInnerExtent*e+i,r.leftInnerExtent=r.leftInnerExtent*e+i,r.verticalRightInnerExtent=r.verticalRightInnerExtent*e+n,r.verticalLeftInnerExtent=r.verticalLeftInnerExtent*e+n,r.rightSmallArcRadius*=e,r.rightLargeArcRadius*=e,r.leftSmallArcRadius*=e,r.leftLargeArcRadius*=e,r.sourceWidth*=e,r.rightNodeBuffer*=e,r.leftNodeBuffer*=e,r.arcRadius*=e}}}const k=new Map;for(const e of t)k.set(e.id,e);for(const t of p){const e=k.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 b=new Map;for(const t of e)b.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of m){const e=t.source,r=t.target,i="object"==typeof e&&null!==e?e.id:e+"",n="object"==typeof r&&null!==r?r.id:r+"",o=b.get(`${i}\0${n}`);if(o){o.y0=t.y0,o.y1=t.y1,o.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,o.circular=!!t.circular,o.circularPathData=t.circularPathData,o._circularWidth=t._circularWidth,o._circularStub=t._circularStub,o.path=t.path,o.circularLinkType=t.circularLinkType,o.direction=h;const e=k.get(i),r=k.get(n);e&&(o.source=e),r&&(o.target=r)}}},buildScene(t,e,r,i){var o,a,s,c;const l="vertical"===r.orientation?"down":"right",u=r.nodeStyle,h=r.edgeStyle,f=null!==(o=r.edgeOpacity)&&void 0!==o?o:.5,d=r.edgeColorBy||"source",y=Array.isArray(r.colorScheme)?r.colorScheme:n.schemeCategory10,g=new Map;t.forEach((t,e)=>{g.set(t.id,y[e%y.length])});const p=[],m=[],x=[];for(const e of t){const t=e.x1-e.x0,r=e.y1-e.y0;if(0>=t||0>=r)continue;const i=u?u(e):{},n={fill:i.fill||g.get(e.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity};p.push({type:"rect",x:e.x0,y:e.y0,w:t,h:r,style:n,datum:e,id:e.id,label:e.id})}const v=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of v){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,r="object"==typeof t.target?t.target:null;if(!e||!r)continue;let i="#999";h?i=h(t).fill||i:"target"===d&&r?i=g.get(r.id)||i:e&&(i=g.get(e.id)||i);const n=h?h(t):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,r=t.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),c=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),l=n.fill||i;m.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-r}L${e.sourceX+o},${e.sourceY-r}L${e.sourceX+o},${e.sourceY+r}L${e.sourceX},${e.sourceY+r}Z`,style:{fill:l,fillOpacity:null!==(a=n.fillOpacity)&&void 0!==a?a:f,stroke:"none",opacity:n.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+o}}),m.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-r}L${e.targetX-c},${e.targetY-r}L${e.targetX-c},${e.targetY+r}L${e.targetX},${e.targetY+r}Z`,style:{fill:l,fillOpacity:null!==(s=n.fillOpacity)&&void 0!==s?s:f,stroke:"none",opacity:n.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-c,x1:e.targetX}});continue}let o;if(o=t.circular&&t.circularPathData?ct(t):st(t),!o)continue;const l={fill:n.fill||i,fillOpacity:null!==(c=n.fillOpacity)&&void 0!==c?c:f,stroke:n.stroke||"none",strokeWidth:n.strokeWidth,opacity:n.opacity};m.push({type:"bezier",pathD:o,bezierCache:t.bezier,style:l,datum:t})}if(!1!==r.showLabels){const e=(k=r.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null;for(const r of t){const t=r.x1-r.x0,n=r.y1-r.y0;if(0>=t||0>=n)continue;const o=e?e(r):r.id;if(!o)continue;let a,s,c;"down"===l?(a=r.x0+t/2,s=r.y1+14,c="middle"):(i[0]/2>r.x0+t/2?(a=r.x0-6,c="end"):(a=r.x1+6,c="start"),s=r.y0+n/2),x.push({x:a,y:s,text:o+"",anchor:c,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:p,sceneEdges:m,labels:x}}},ht={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,r,i){var n,o;if(0===t.length)return;const s=null!==(n=r.iterations)&&void 0!==n?n:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),c=null!==(o=r.forceStrength)&&void 0!==o?o:.1,l=i[0]/2,u=i[1]/2;for(let e=0;t.length>e;e++){const r=t[e];if(null==r.x||null==r.y||0===r.x&&0===r.y){const t=10*Math.sqrt(e+.5),i=2.399963229728653*e;r.x=l+t*Math.cos(i),r.y=u+t*Math.sin(i)}}const h=ft(r.nodeSize,r.nodeSizeRange,t),f=a.forceLink().strength(t=>Math.min(2.5,t.weight?t.weight*c:c)).id(t=>t.id),d=i[1]/i[0],y=a.forceSimulation().force("charge",a.forceManyBody().strength(t=>-25*(t=>h(t))(t))).force("x",a.forceX(i[0]/2).strength(.1*d)).force("y",a.forceY(i[1]/2).strength(.1));if(y.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}));y.force("link",f),y.force("link").links(t)}.1>y.alpha()&&y.alpha(1),y.stop();for(let t=0;s>t;++t)y.tick();const g=new Map;for(const e of t)g.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=g.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=g.get(t.target);e&&(t.target=e)}}},buildScene(t,e,r,i){var o,a,s;const c=r.nodeStyle,l=r.edgeStyle,u=ft(r.nodeSize,r.nodeSizeRange,t),h=Array.isArray(r.colorScheme)?r.colorScheme:n.schemeCategory10,f=new Map;t.forEach((t,e)=>{f.set(t.id,h[e%h.length])});const d=[],y=[],g=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=u(e),r=c?c(e):{},i={fill:r.fill||f.get(e.id)||"#007bff",stroke:r.stroke||"#fff",strokeWidth:null!==(o=r.strokeWidth)&&void 0!==o?o:2,opacity:r.opacity};d.push({type:"circle",cx:e.x,cy:e.y,r:t,style:i,datum:e,id:e.id,label:e.id})}const p=new Map;for(const e of t)p.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:p.get(t.source),r="object"==typeof t.target?t.target:p.get(t.target);if(!e||!r)continue;if(null==e.x||null==e.y)continue;if(null==r.x||null==r.y)continue;const i=l?l(t):{},n={stroke:i.stroke||"#999",strokeWidth:null!==(a=i.strokeWidth)&&void 0!==a?a:1,opacity:null!==(s=i.opacity)&&void 0!==s?s:.6};y.push({type:"line",x1:e.x,y1:e.y,x2:r.x,y2:r.y,style:n,datum:t})}if(!1!==r.showLabels){const e=(m=r.nodeLabel)?"function"==typeof m?m:t=>t[m]||t.id:null;for(const r of t){if(null==r.x||null==r.y)continue;const t=e?e(r):r.id;if(!t)continue;const i=u(r);g.push({x:r.x,y:r.y-i-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var m;return{sceneNodes:d,sceneEdges:y,labels:g}}};function ft(t,e,n){var o,a;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],c=n.map(e=>{var r;return null===(r=e.data)||void 0===r?void 0:r[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===c.length)return()=>s[0];const l=null!==(o=i.min(c))&&void 0!==o?o:0,u=null!==(a=i.max(c))&&void 0!==a?a:1;if(l===u)return()=>(s[0]+s[1])/2;const h=r.scaleLinear().domain([l,u]).range(s).clamp(!0);return e=>{var r;const i=null===(r=e.data)||void 0===r?void 0:r[t];return null==i||"number"!=typeof i?s[0]:h(i)}}const dt=n.schemeCategory10,yt={supportsStreaming:!1,hierarchical:!1,computeLayout(t,r,i,n){if(0===t.length)return;const{padAngle:o=.01,groupWidth:a=20,sortGroups:c}=i,l=Math.min(n[0],n[1])/2,u=l-a,h=n[0]/2,f=n[1]/2,d=(y=i.valueAccessor)?"function"==typeof y?y:t=>{var e;return null!==(e=t[y])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var y;const g=new Map;for(let e=0;t.length>e;e++)g.set(t[e].id,e);const p=t.length,m=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const t of r){const e="string"==typeof t.target?t.target:t.target.id,r=g.get("string"==typeof t.source?t.source:t.source.id),i=g.get(e);if(void 0===r||void 0===i)continue;const n=d(t);m[r][i]=n}const x=s.chord().padAngle(o);c&&x.sortGroups(c);const v=x(m),k=v.groups,b=e.arc().innerRadius(u).outerRadius(l);for(const e of k){const r=t[e.index],i=b.centroid(e);r.x=i[0]+h,r.y=i[1]+f,r.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 r){const e="string"==typeof t.target?t.target:t.target.id,r=w.get("string"==typeof t.source?t.source:t.source.id),i=w.get(e);r&&(t.source=r),i&&(t.target=i)}const E=new Map;for(const t of r)E.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 v){const r=t[e.source.index].id,i=t[e.target.index].id,n=E.get(`${r}\0${i}`)||E.get(`${i}\0${r}`);n&&(n.chordData=e)}},buildScene(t,e,r,i){var n,o;const{groupWidth:a=20,edgeOpacity:c=.5}=r,l=Math.min(i[0],i[1])/2,u=l-a,h=i[0]/2,f=i[1]/2,d=r.nodeStyle,y=r.edgeStyle,g=r.edgeColorBy||"source",p=Array.isArray(r.colorScheme)?r.colorScheme:dt,m=new Map;t.forEach((t,e)=>{m.set(t.id,p[e%p.length])});const x=s.ribbon().radius(u),v=[],k=[],b=[];for(let e=0;t.length>e;e++){const r=t[e],i=r.arcData;if(!i)continue;let o;o=d?d(r).fill||m.get(r.id)||p[e%p.length]:m.get(r.id)||p[e%p.length];const a=d?d(r):{},s={fill:o,stroke:a.stroke||"black",strokeWidth:null!==(n=a.strokeWidth)&&void 0!==n?n:1,opacity:a.opacity};v.push({type:"arc",cx:h,cy:f,innerR:u,outerR:l,startAngle:i.startAngle-Math.PI/2,endAngle:i.endAngle-Math.PI/2,style:s,datum:r,id:r.id,label:r.id})}for(const t of e){const e=t.chordData;if(!e)continue;const r=x(e);if(!r)continue;const i=gt(r,h,f);let n="#999";if(y)n=y(t).fill||n;else{const e="object"==typeof t.source?t.source:null,r="object"==typeof t.target?t.target:null;"target"===g&&r?n=m.get(r.id)||n:e&&(n=m.get(e.id)||n)}const a=y?y(t):{},s={fill:n,fillOpacity:null!==(o=a.fillOpacity)&&void 0!==o?o:c,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};k.push({type:"ribbon",pathD:i,style:s,datum:t})}if(!1!==r.showLabels){const e=(w=r.nodeLabel)?"function"==typeof w?w:t=>t[w]||t.id:null,i=l+12;for(const r of t){const t=r.arcData;if(!t)continue;const n=e?e(r):r.id;if(!n)continue;const o=(t.startAngle+t.endAngle)/2,a=o-Math.PI/2;b.push({x:h+Math.cos(a)*i,y:f+Math.sin(a)*i,text:n+"",anchor:o>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:v,sceneEdges:k,labels:b}}};function gt(t,e,r){const i=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!i)return t;const n=[];let o=0;for(;i.length>o;){const t=i[o];if("M"===t||"L"===t)for(n.push(t),o++;i.length>o&&!isNaN(Number(i[o]));)n.push(Number(i[o])+e+""),o++,i.length>o&&!isNaN(Number(i[o]))&&(n.push(Number(i[o])+r+""),o++);else if("C"===t)for(n.push(t),o++;i.length>o&&!isNaN(Number(i[o]));)for(let t=0;3>t&&i.length>o&&!isNaN(Number(i[o]));t++)n.push(Number(i[o])+e+""),o++,i.length>o&&!isNaN(Number(i[o]))&&(n.push(Number(i[o])+r+""),o++);else if("Q"===t)for(n.push(t),o++;i.length>o&&!isNaN(Number(i[o]));)for(let t=0;2>t&&i.length>o&&!isNaN(Number(i[o]));t++)n.push(Number(i[o])+e+""),o++,i.length>o&&!isNaN(Number(i[o]))&&(n.push(Number(i[o])+r+""),o++);else if("A"===t)for(n.push(t),o++;i.length>o&&!isNaN(Number(i[o]));)n.push(i[o++]),i.length>o&&n.push(i[o++]),i.length>o&&n.push(i[o++]),i.length>o&&n.push(i[o++]),i.length>o&&n.push(i[o++]),i.length>o&&(n.push(Number(i[o])+e+""),o++),i.length>o&&(n.push(Number(i[o])+r+""),o++);else"Z"===t||"z"===t?(n.push(t),o++):(n.push(i[o]),o++)}return n.join(" ")}const pt={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,r,i){var n;const o=r.__hierarchyRoot;if(!o)return;const a=r.chartType,s=(l=r.childrenAccessor)?"function"==typeof l?l:t=>t[l]:void 0;var l;const u=r.hierarchySum||(t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0}),h=c.hierarchy(o,s);h.sum(u),h.sort((t,e)=>{var r,i;return(null!==(r=e.value)&&void 0!==r?r:0)-(null!==(i=t.value)&&void 0!==i?i:0)});const[f,d]=i;switch(a){case"tree":!function(t,e,r,i){const n=e.treeOrientation||"vertical",o=c.tree();o.size("horizontal"===n?[i,r]:"radial"===n?[2*Math.PI,Math.min(r,i)/2*.8]:[r,i]),o(t)}(h,r,f,d);break;case"cluster":!function(t,e,r,i){const n=e.treeOrientation||"vertical",o=c.cluster();o.size("horizontal"===n?[i,r]:"radial"===n?[2*Math.PI,Math.min(r,i)/2*.8]:[r,i]),o(t)}(h,r,f,d);break;case"treemap":!function(t,e,r,i){var n,o;const a=null!==(n=e.padding)&&void 0!==n?n:4,s=null!==(o=e.paddingTop)&&void 0!==o?o:0,l=c.treemap().size([r,i]).tile(c.treemapBinary).padding(a);s>0&&l.paddingTop(s),l(t)}(h,r,f,d);break;case"circlepack":!function(t,e,r,i){var n;const o=null!==(n=e.padding)&&void 0!==n?n:4;c.pack().size([r,i]).padding(o)(t)}(h,r,f,d);break;case"partition":!function(t,e,r,i){var n;c.partition().size([r,i]).padding(null!==(n=e.padding)&&void 0!==n?n:1)(t)}(h,r,f,d)}const y=h.descendants();t.length=0,e.length=0;const g=new Map;for(let e=0;y.length>e;e++){const i=y[e],o={id:bt(i,r,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(n=i.value)&&void 0!==n?n:0,depth:i.depth,data:i.data,createdByFrame:!0};"tree"===a||"cluster"===a?mt(o,i,r):"treemap"===a||"partition"===a?xt(o,i):"circlepack"===a&&vt(o,i),o.__hierarchyNode=i,t.push(o),g.set(i,o)}if("tree"===a||"cluster"===a)for(const t of y)if(t.parent){const r=g.get(t.parent),i=g.get(t);r&&i&&e.push({source:r,target:i,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,r,i){const n=r.nodeStyle||(()=>({})),o=r.edgeStyle||(()=>({}));switch(r.chartType){case"tree":case"cluster":return function(t,e,r,i,n,o){var a,s,c,l,u;const h=[],f=[],d=[],y=r.treeOrientation||"vertical",g="radial"===y,p=i[0]/2,m=i[1]/2,x="number"==typeof(k=r.nodeSize)?k:5,v=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];var k;for(const e of t){let t=e.x,i=e.y;g&&(t+=p,i+=m);const o=n(e);let s=o.fill||"#4d430c";r.colorByDepth&&void 0!==e.depth&&(s=v[e.depth%v.length]);const c={fill:s,stroke:o.stroke||"#fff",strokeWidth:null!==(a=o.strokeWidth)&&void 0!==a?a:1,opacity:o.opacity};h.push({type:"circle",cx:t,cy:i,r:x,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const b=null!==(s=r.edgeOpacity)&&void 0!==s?s:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,r="object"==typeof t.target?t.target:null;if(!e||!r)continue;let i=e.x,n=e.y,a=r.x,s=r.y;g&&(i+=p,n+=m,a+=p,s+=m);const u=kt(i,n,a,s,y),h=o(t),d={fill:"none",stroke:h.stroke||"#999",strokeWidth:null!==(c=h.strokeWidth)&&void 0!==c?c:1.5,opacity:null!==(l=h.opacity)&&void 0!==l?l:b};f.push({type:"curved",pathD:u,style:d,datum:t})}if(!1!==r.showLabels){const e=wt(r.nodeLabel);for(const r of t){const t=e?e(r):r.id;if(!t)continue;let i,n,o,a=r.x,s=r.y;if(g&&(a+=p,s+=m),g){const t=a-p,e=s-m,r=Math.sqrt(t*t+e*e);r>0?(i=a+t/r*10,n=s+e/r*10,o=0>t?"end":"start"):(i=a,n=s-12,o="middle")}else"horizontal"===y?((null===(u=r.data)||void 0===u?void 0:u.children)&&0!==r.data.children.length?(i=a-x-6,o="end"):(i=a+x+6,o="start"),n=s):(i=a,n=s+x+14,o="middle");d.push({x:i,y:n,text:t+"",anchor:o,baseline:"middle",fontSize:11})}}return{sceneNodes:h,sceneEdges:f,labels:d}}(t,e,r,i,n,o);case"treemap":case"partition":return function(t,e,r,i){var n,o;const a=[],s=[],c=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const r of t){const t=r.x1-r.x0,o=r.y1-r.y0;if(0>=t||0>=o)continue;const s=i(r);let l=s.fill||"#4d430c";e.colorByDepth&&void 0!==r.depth&&(l=c[r.depth%c.length]);const u={fill:l,stroke:s.stroke||"#fff",strokeWidth:null!==(n=s.strokeWidth)&&void 0!==n?n:1,opacity:s.opacity};a.push({type:"rect",x:r.x0,y:r.y0,w:t,h:o,style:u,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==e.showLabels){const r=wt(e.nodeLabel);for(const i of t){const t=i.x1-i.x0,n=i.y1-i.y0;if(0>=t||0>=n)continue;if((null===(o=i.data)||void 0===o?void 0:o.children)&&i.data.children.length>0&&"partition"!==e.chartType)continue;const a=r?r(i):i.id;a&&(30>t||16>n||s.push({x:i.x0+t/2,y:i.y0+n/2,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,n)/6))}))}}return{sceneNodes:a,sceneEdges:[],labels:s}}(t,r,0,n);case"circlepack":return function(t,e,r,i){var n,o,a,s,c;const l=[],u=[],h=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const r of t){const t=null!==(n=r.__radius)&&void 0!==n?n:5;if(0>=t)continue;const s=i(r);let c=s.fill||"#4d430c";e.colorByDepth&&void 0!==r.depth&&(c=h[r.depth%h.length]);const u={fill:c,stroke:s.stroke||"#fff",strokeWidth:null!==(o=s.strokeWidth)&&void 0!==o?o:1,opacity:null!==(a=s.opacity)&&void 0!==a?a:.7};l.push({type:"circle",cx:r.x,cy:r.y,r:t,style:u,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==e.showLabels){const r=wt(e.nodeLabel);for(const e of t){const t=null!==(s=e.__radius)&&void 0!==s?s:5,i=r?r(e):e.id;if(!i)continue;if(15>t)continue;const n=!((null===(c=e.data)||void 0===c?void 0:c.children)&&e.data.children.length>0);u.push({x:e.x,y:n?e.y:e.y-t+14,text:i+"",anchor:"middle",baseline:n?"middle":"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:n?void 0:"#000",stroke:n?void 0:"#fff",strokeWidth:n?void 0:3,paintOrder:n?void 0:"stroke"})}}return{sceneNodes:l,sceneEdges:[],labels:u}}(t,r,0,n);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function mt(t,e,r){const i=r.treeOrientation||"vertical";if("radial"===i){const r=e.x,i=e.y;t.x=i*Math.cos(r-Math.PI/2),t.y=i*Math.sin(r-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 xt(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 vt(t,e){var r;const i=null!==(r=e.r)&&void 0!==r?r: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 kt(t,e,r,i,n){if("horizontal"===n){const n=(t+r)/2;return`M ${t},${e} C ${n},${e} ${n},${i} ${r},${i}`}if("radial"===n){const n=(t+r)/2;return`M ${t},${e} Q ${n},${e} ${n},${(e+i)/2} T ${r},${i}`}{const n=(e+i)/2;return`M ${t},${e} C ${t},${n} ${r},${n} ${r},${i}`}}function bt(t,e,r){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-"+r}function wt(t){return t?"function"==typeof t?t:e=>{var r;return(null===(r=e.data)||void 0===r?void 0:r[t])||e[t]||e.id}:null}const Et={sankey:ut,force:ht,chord:yt,tree:pt,cluster:pt,treemap:pt,circlepack:pt,partition:pt};function St(t,e){const{columns:r,config:i,resolvePieceStyle:n}=t,o=[],a=Math.min(e.width,e.height)/2-4,s="donut"===i.chartType?i.innerRadius||60:0,c=-Math.PI/2+(i.startAngle||0)*Math.PI/180,l=2*Math.PI;for(const t of Object.values(r)){const e=c+t.pctStart*l,r=c+(t.pctStart+t.pct)*l,i=n(t.pieceData[0],t.name);o.push({type:"wedge",cx:0,cy:0,innerRadius:s,outerRadius:a,startAngle:e,endAngle:r,style:i,datum:t.pieceData,category:t.name})}return o}function At(t){var e,r,n;const o=t.length,a=t[0],s=t[o-1];return{n:o,min:a,q1:null!==(e=i.quantile(t,.25))&&void 0!==e?e:a,median:null!==(r=i.quantile(t,.5))&&void 0!==r?r:(a+s)/2,q3:null!==(n=i.quantile(t,.75))&&void 0!==n?n:s,max:s,mean:t.reduce((t,e)=>t+e,0)/o}}const Pt={bar:function(t,e){const{scales:r,columns:i,config:n,getR:o,getStack:a,resolvePieceStyle:s}=t,{r:c,projection:l}=r,u=[],h="vertical"===l,f="horizontal"===l,d=n.normalize;for(const t of Object.values(i)){const e=new Map;for(const r of t.pieceData){const t=a?a(r):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const i=e.get(t);i.total+=o(r),i.pieces.push(r)}let r=0;if(d)for(const t of e.values())r+=Math.abs(t.total);let i=0,n=0;for(const[o,l]of e){let e=l.total;d&&r>0&&(e/=r);const y=s(l.pieces[0],a?o:t.name),g=Object.assign(Object.assign({},l.pieces[0]),{__aggregateValue:l.total,__pieceCount:l.pieces.length,category:t.name});if(h){const r=c(0>e?n:i+e),a=0>e?c(n+e)-c(n):c(i)-c(i+e);u.push(m(t.x,r,t.width,Math.abs(a),y,g,o)),0>e?n+=e:i+=e}else if(f){const r=c(0>e?n+e:i),a=0>e?c(n)-c(n+e):c(i+e)-c(i);u.push(m(r,t.x,Math.abs(a),t.width,y,g,o)),0>e?n+=e:i+=e}}}return u},clusterbar:function(t,e){const{scales:r,columns:i,getR:n,getGroup:o,resolvePieceStyle:a}=t,{r:s,projection:c}=r,l=[],u="vertical"===c,h=[],f=new Set;for(const t of Object.values(i))for(const e of t.pieceData){const t=o?o(e):"_default";f.has(t)||(f.add(t),h.push(t))}const d=h.length||1;for(const t of Object.values(i)){const e=t.width/d,r=new Map;for(const e of t.pieceData){const t=o?o(e):"_default";r.has(t)||r.set(t,[]),r.get(t).push(e)}for(let i=0;h.length>i;i++){const o=r.get(h[i])||[];for(const r of o){const o=n(r),c=a(r,t.name);if(u){const n=t.x+i*e,a=s(0),u=s(o);l.push(m(n,Math.min(a,u),e,Math.abs(a-u),c,r,h[i]))}else{const n=t.x+i*e,a=s(0),u=s(o);l.push(m(Math.min(a,u),n,Math.abs(u-a),e,c,r,h[i]))}}}}return l},point:function(t,e){var r,i;const{scales:n,columns:o,getR:a,multiScales:s,resolvePieceStyle:c}=t,{r:l,projection:u}=n,h=[],f="vertical"===u,d="radial"===u,y=s.length>0,g=2*Math.PI,p=-Math.PI/2;for(const t of Object.values(o))for(const e of t.pieceData){const n=null!==(r=e.__rIndex)&&void 0!==r?r:0,o=null!==(i=e.__rValue)&&void 0!==i?i:a(e),u=y&&s[n]||l,m=c(e,t.name),x=m.r||5;let v,k;if(d){const e=p+(t.pctStart+t.pct/2)*g,r=u(o);v=Math.cos(e)*r,k=Math.sin(e)*r}else f?(v=t.middle,k=u(o)):(v=u(o),k=t.middle);h.push({type:"point",x:v,y:k,r:x,style:m,datum:e})}return h},swarm:function(t,e){const{scales:r,columns:i,getR:n,resolvePieceStyle:o}=t,{r:a,projection:s}=r,c=[],l="vertical"===s;for(const t of Object.values(i)){const e=t.width/2;for(let r=0;t.pieceData.length>r;r++){const i=t.pieceData[r],s=n(i),u=o(i,t.name),h=u.r||4,f=(7919*r%100/100-.5)*e*.8,d=l?t.middle+f:a(s),y=l?a(s):t.middle+f;c.push({type:"point",x:d,y:y,r:h,style:u,datum:i})}}return c},pie:St,donut:St,boxplot:function(t,e){var r,n,o,a,s;const{scales:c,columns:l,config:u,getR:h,resolveSummaryStyle:f}=t,{r:d,projection:y}=c,g=[],p="vertical"===y,m=!1!==u.showOutliers;for(const t of Object.values(l)){const e=t.pieceData.map(t=>h(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===e.length)continue;const c=e[0],l=e[e.length-1],u=null!==(r=i.quantile(e,.25))&&void 0!==r?r:c,y=null!==(n=i.quantile(e,.5))&&void 0!==n?n:(c+l)/2,x=null!==(o=i.quantile(e,.75))&&void 0!==o?o:l,v=x-u,k=u-1.5*v,b=x+1.5*v,w=null!==(a=e.find(t=>t>=k))&&void 0!==a?a:c,E=null!==(s=[...e].reverse().find(t=>b>=t))&&void 0!==s?s:l,S=f(t.pieceData[0],t.name),A=[];if(m)for(const e of t.pieceData){const r=h(e);if(k>r||r>b){const i=p?t.middle:d(r),n=p?d(r):t.middle;A.push({px:i,py:n,value:r,datum:e})}}if(g.push({type:"boxplot",x:p?t.middle:0,y:p?0:t.middle,projection:p?"vertical":"horizontal",columnWidth:.6*t.width,minPos:d(w),q1Pos:d(u),medianPos:d(y),q3Pos:d(x),maxPos:d(E),stats:{min:w,q1:u,median:y,q3:x,max:E},style:S,datum:t.pieceData,category:t.name,outliers:A}),m)for(const t of A)g.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:S.fill||"#999",opacity:.6},datum:t.datum})}return g},violin:function(t,e){var r,n,o;const{scales:a,columns:s,config:c,getR:l,resolveSummaryStyle:u}=t,{r:h,projection:f}=a,d=[],y="vertical"===f,g=c.bins||20,p=!1!==c.showIQR;for(const t of Object.values(s)){const e=t.pieceData.map(t=>l(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const a=e[0],s=e[e.length-1],c=(s-a)/g||1,f=Array(g).fill(0);for(const t of e)f[Math.min(Math.floor((t-a)/c),g-1)]++;const m=Math.max(...f,1),x=t.width/2*.9;let v="";if(y){for(let e=0;g>e;e++){const r=h(a+(e+.5)*c),i=f[e]/m*x;v+=0===e?`M ${t.middle+i} ${r}`:` L ${t.middle+i} ${r}`}for(let e=g-1;e>=0;e--){const r=h(a+(e+.5)*c);v+=` L ${t.middle-f[e]/m*x} ${r}`}v+=" Z"}else{for(let e=0;g>e;e++){const r=h(a+(e+.5)*c),i=f[e]/m*x;v+=0===e?`M ${r} ${t.middle-i}`:` L ${r} ${t.middle-i}`}for(let e=g-1;e>=0;e--)v+=` L ${h(a+(e+.5)*c)} ${t.middle+f[e]/m*x}`;v+=" Z"}const k=u(t.pieceData[0],t.name);let b;if(p&&e.length>=4){const c=null!==(r=i.quantile(e,.25))&&void 0!==r?r:a,l=null!==(n=i.quantile(e,.5))&&void 0!==n?n:(a+s)/2,u=null!==(o=i.quantile(e,.75))&&void 0!==o?o:s;b={q1Pos:h(c),medianPos:h(l),q3Pos:h(u),centerPos:t.middle,isVertical:y}}const w=y?{x:t.x,y:Math.min(h(s),h(a)),width:t.width,height:Math.abs(h(s)-h(a))}:{x:Math.min(h(a),h(s)),y:t.x,width:Math.abs(h(s)-h(a)),height:t.width};d.push({type:"violin",pathString:v,translateX:0,translateY:0,bounds:w,iqrLine:b,stats:At(e),style:k,datum:t.pieceData,category:t.name})}return d},histogram:function(t,e){const{scales:r,columns:i,config:n,getR:o,resolveSummaryStyle:a}=t,{r:s}=r,c=[],l=n.bins||25,u=n.normalize;for(const t of Object.values(i)){const e=t.pieceData.map(t=>o(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const r=Math.min(...e),i=(Math.max(...e)-r)/l||1,n=Array(l).fill(0);for(const t of e)n[Math.min(Math.floor((t-r)/i),l-1)]++;const h=e.length,f=Math.max(...n,1),d=a(t.pieceData[0],t.name);for(let e=0;l>e;e++){if(0===n[e])continue;const o=(u?n[e]/h:n[e]/f)*t.width*.9,a=s(r+e*i),l=s(r+(e+1)*i);c.push(m(Math.min(a,l),t.x+t.width-o,Math.abs(l-a),o,d,{bin:e,count:n[e],range:[r+e*i,r+(e+1)*i],category:t.name},t.name))}}return c},ridgeline:function(t,e){var r;const{scales:i,columns:n,config:o,getR:a,resolveSummaryStyle:s}=t,{r:c,projection:l}=i,u=[],h=o.bins||20,f="horizontal"===l,d=o.amplitude||1.5;for(const t of Object.values(n)){const e=t.pieceData.map(t=>a(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const i=e[0],n=e[e.length-1],o=(n-i)/h||1,l=Array(h).fill(0);for(const t of e)l[Math.min(Math.floor((t-i)/o),h-1)]++;const y=Math.max(...l,1),g=s(t.pieceData[0],t.name),p=t.width*d;let m="";if(f){const e=t.x+t.width;m=`M ${c(i)} ${e}`;for(let t=0;h>t;t++)m+=` L ${c(i+(t+.5)*o)} ${e-l[t]/y*p}`;m+=` L ${c(n)} ${e} Z`}else{const e=t.x;m=`M ${e} ${c(i)}`;for(let t=0;h>t;t++){const r=c(i+(t+.5)*o);m+=` L ${e+l[t]/y*p} ${r}`}m+=` L ${e} ${c(n)} Z`}const x=f?{x:Math.min(c(i),c(n)),y:t.x,width:Math.abs(c(n)-c(i)),height:t.width}:{x:t.x,y:Math.min(c(n),c(i)),width:t.width,height:Math.abs(c(n)-c(i))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:x,stats:At(e),style:Object.assign(Object.assign({},g),{fillOpacity:null!==(r=g.fillOpacity)&&void 0!==r?r:.5}),datum:t.pieceData,category:t.name})}return u},timeline:function(t,e){const{scales:r,columns:i,getRawRange:n,resolvePieceStyle:o}=t,{r:a,projection:s}=r,c=[],l="horizontal"===s;for(const t of Object.values(i))for(const e of t.pieceData){const r=n(e);if(!r)continue;const[i,s]=r,u=o(e,t.name);if(l){const r=a(Math.min(i,s)),n=a(Math.max(i,s));c.push(m(r,t.x,n-r,t.width,u,e,t.name))}else{const r=a(Math.max(i,s)),n=a(Math.min(i,s));c.push(m(t.x,r,t.width,n-r,u,e,t.name))}}return c}};class Lt{constructor(t){this.rExtent=new f,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.version=0,this.config=t,this.buffer=new h(t.windowSize),this.getO=k(t.oAccessor||t.categoryAccessor,"category");const e="streaming"===t.runtimeMode,r=t.rAccessor;Array.isArray(r)?(this.rAccessors=r.map(t=>v(t,"value")),this.getR=this.rAccessors[0],this.rExtents=r.map(()=>new f)):(this.getR=v(e&&(t.timeAccessor||t.valueAccessor)&&t.valueAccessor||r,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=k(t.stackBy),this.getGroup=k(t.groupBy),this.getColor=k(t.colorAccessor),this.getConnector=k(t.connectorAccessor),t.pulse&&(this.timestampBuffer=new h(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,t.bounded){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const r=t.totalSize||t.inserts.length;r>this.buffer.capacity&&(this.buffer.resize(r),this.timestampBuffer&&r>this.timestampBuffer.capacity&&this.timestampBuffer.resize(r));for(const r of t.inserts)this.buffer.push(r),this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(r)),this.pushValueExtent(r)}else for(const r of t.inserts){const t=this.buffer.push(r);this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(r)),this.pushValueExtent(r),null!=t&&this.evictValueExtent(t)}return!0}pushValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.push(e[0]),this.rExtent.push(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].push(this.rAccessors[e](t));this.rExtent.push(this.getR(t))}else this.rExtent.push(this.getR(t))}evictValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.evict(e[0]),this.rExtent.evict(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].evict(this.rAccessors[e](t));this.rExtent.evict(this.getR(t))}else this.rExtent.evict(this.getR(t))}getRawRange(t){const e=this.config.rAccessor;if(!e)return null;const r="function"==typeof e?e(t):t[e];return Array.isArray(r)&&r.length>=2?[+r[0],+r[1]]:null}computeScene(t){const{config:e,buffer:i}=this;if(0===i.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(i,this.getR);const n=i.toArray(),o=e.projection||"vertical",a=e.oExtent||this.resolveCategories(n),s=this.computeValueDomain(n,a),c="horizontal"===o,l=null!=e.barPadding?e.barPadding/("vertical"===o?t.width:t.height):.1;let u,h;if("radial"===o){u=r.scaleBand().domain(a).range([0,1]).padding(0);const i=Math.min(t.width,t.height)/2,n=e.innerRadius||0;h=r.scaleLinear().domain(s).range([n,i])}else c?(u=r.scaleBand().domain(a).range([0,t.height]).padding(l),h=r.scaleLinear().domain(s).range([0,t.width])):(u=r.scaleBand().domain(a).range([0,t.width]).padding(l),h=r.scaleLinear().domain(s).range([t.height,0]));this.scales={o:u,r:h,projection:o},this.multiScales=this.rAccessors.length>1&&e.multiAxis?this.rAccessors.map((n,o)=>{const a=this.rExtents[o];a.dirty&&a.recalculate(i,n);let[s,l]=a.extent;s===1/0&&(s=0,l=1);const u=l-s,h=u>0?u*(e.extentPadding||.05):1;return s-=h,l+=h,s>0&&(s=0),c?r.scaleLinear().domain([s,l]).range([0,t.width]):r.scaleLinear().domain([s,l]).range([t.height,0])}):[];let f=n;this.rAccessors.length>1&&(f=n.flatMap(t=>this.rAccessors.map((e,r)=>Object.assign(Object.assign({},t),{__rIndex:r,__rValue:e(t),__rName:this.resolveRAccessorName(r)})))),this.columns=this.buildColumns(f,a,u,o,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(f,t),this.config.decay&&this.applyDecay(this.scene,n),this.config.pulse&&this.applyPulse(this.scene,n),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(t){const e=Array.isArray(this.config.rAccessor)?this.config.rAccessor[t]:this.config.rAccessor;return"string"==typeof e?e:"value"+t}resolveCategories(t){const e=Array.from(this.categories),r=this.config.oSort;if("streaming"===this.config.runtimeMode&&void 0===r)return e;if(!1===r)return e;if("function"==typeof r)return e.sort(r);const i=new Map;for(const e of t){const t=this.getO(e);i.set(t,(i.get(t)||0)+Math.abs(this.getR(e)))}return e.sort("asc"===r?(t,e)=>(i.get(t)||0)-(i.get(e)||0):(t,e)=>(i.get(e)||0)-(i.get(t)||0))}computeValueDomain(t,e){var r,i;const n=this.config.chartType,o=this.config.extentPadding||.05;if("radial"===this.config.projection&&("pie"===n||"donut"===n))return[0,1];let a=0,s=0;if("bar"===n&&this.getStack){const e=new Map,r=new Map;for(const i of t){const t=this.getO(i),n=this.getR(i);0>n?r.set(t,(r.get(t)||0)+n):e.set(t,(e.get(t)||0)+n)}for(const t of e.values())t>s&&(s=t);for(const t of r.values())a>t&&(a=t)}else if("bar"===n){const e=new Map;for(const r of t){const t=this.getO(r),i=this.getR(r);e.set(t,(e.get(t)||0)+i)}for(const t of e.values())t>s&&(s=t),a>t&&(a=t)}else if("clusterbar"===n)for(const e of t){const t=this.getR(e);t>s&&(s=t),a>t&&(a=t)}else{const t=this.rExtent.extent[0],e=this.rExtent.extent[1];t!==1/0&&(a=t),e!==-1/0&&(s=e)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(a=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(s=this.config.rExtent[1]));const c=s-a,l=c>0?c*o:1;return(null===(r=this.config.rExtent)||void 0===r?void 0:r[0])||(a-=l),(null===(i=this.config.rExtent)||void 0===i?void 0:i[1])||(s+=l),"bar"!==n&&"clusterbar"!==n||(a>0&&(a=0),0>s&&(s=0)),[a,s]}buildColumns(t,e,r,i,n){var o;const a={},s=new Map;for(const e of t){const t=this.getO(e);s.has(t)||s.set(t,[]),s.get(t).push(e)}let c=0;if("radial"===i)for(const e of t)c+=Math.abs(this.getR(e));const l=this.config.dynamicColumnWidth;let u=null;if(l&&"radial"!==i){u=new Map;let t=0;for(const r of e){const e=s.get(r)||[];let i;i="string"==typeof l?e.reduce((t,e)=>t+(Number(e[l])||0),0):l(e),u.set(r,i),t+=i}const o=("horizontal"===i?n.height:n.width)-r.padding()*r.step()*e.length;if(t>0)for(const[e,r]of u)u.set(e,r/t*o)}let h=0,f=0;for(const t of e){const e=s.get(t)||[],i=e.reduce((t,e)=>t+Math.abs(this.getR(e)),0),n=c>0?i/c:0;let l,d;u?(l=f,d=u.get(t)||r.bandwidth(),f+=d+r.padding()*r.step()):(l=null!==(o=r(t))&&void 0!==o?o:0,d=r.bandwidth()),a[t]={name:t,x:l,y:0,width:d,middle:l+d/2,padding:r.padding()*r.step(),pieceData:e,pct:n,pctStart:h},h+=n}return a}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(t,e)=>this.resolvePieceStyle(t,e),resolveSummaryStyle:(t,e)=>this.resolveSummaryStyle(t,e),getRawRange:t=>this.getRawRange(t)}}buildSceneNodes(t,e){if(!this.scales)return[];const r=this.getSceneContext(),i=Pt[this.config.chartType];let n=i?i(r,e):[];if(this.getConnector&&this.scales){const t=function(t,e){const{scales:r,config:i,getConnector:n,getO:o}=t;if(!n||!r)return[];const a=[],{projection:s}=r,c=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const r=n(e);if(!r)continue;let i,a;"point"===t.type?(i=t.x,a=t.y):(i=t.x+t.w/2,a=t.y+("vertical"===s?0:t.h/2)),c.has(r)||c.set(r,[]),c.get(r).push({x:i,y:a,datum:e,category:o(e)})}const l=r.o.domain(),u=i.connectorStyle;for(const[t,e]of c)if(e.length>=2){e.sort((t,e)=>l.indexOf(t.category)-l.indexOf(e.category));for(let r=0;e.length-1>r;r++){const i=e[r],n=e[r+1],o="function"==typeof u?u(i.datum):u||{stroke:"#999",strokeWidth:1,opacity:.5};a.push({type:"connector",x1:i.x,y1:i.y,x2:n.x,y2:n.y,style:o,datum:i.datum,group:t})}}return a}(r,n);n=[...t,...n]}return n}resolvePieceStyle(t,e){return"function"==typeof this.config.pieceStyle?this.config.pieceStyle(t,e):this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&e?{fill:this.config.barColors[e]||"#007bff"}:e?{fill:this.getColorFromScheme(e)}:{fill:"#007bff"}}getColorFromScheme(t){this._colorSchemeMap||(this._colorSchemeMap=new Map);const e=this._colorSchemeMap.get(t);if(e)return e;const r=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],i=r[this._colorSchemeIndex%r.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(t,i),i}resolveSummaryStyle(t,e){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(t,e):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(t,e){var r,i,n;const o=this.config.decay;if(!o||1>=e)return 1;const a=null!==(r=o.minOpacity)&&void 0!==r?r:.1,s=e-1-t;switch(o.type){case"linear":return a+(1-s/(e-1))*(1-a);case"exponential":{const t=null!==(i=o.halfLife)&&void 0!==i?i:e/2;return a+Math.pow(.5,s/t)*(1-a)}case"step":return(null!==(n=o.stepThreshold)&&void 0!==n?n:.5*e)>s?1:a;default:return 1}}applyDecay(t,e){var r,i;if(!this.config.decay)return;const n=e.length;if(1>=n)return;const o=new Map;for(let t=0;e.length>t;t++)o.set(e[t],t);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;const t=o.get(e.datum);if(null==t)continue;const a=this.computeDecayOpacity(t,n),s=null!==(i=null===(r=e.style)||void 0===r?void 0:r.opacity)&&void 0!==i?i:1;e.style=Object.assign(Object.assign({},e.style),{opacity:s*a})}}applyPulse(t,e){var r,i,n;if(!this.config.pulse||!this.timestampBuffer)return;const o="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(r=this.config.pulse.duration)&&void 0!==r?r:500,s=null!==(i=this.config.pulse.color)&&void 0!==i?i:"rgba(255,255,255,0.6)",c=null!==(n=this.config.pulse.glowRadius)&&void 0!==n?n:4,l=new Map;for(let t=0;e.length>t;t++)l.set(e[t],t);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;const t=l.get(e.datum);if(null==t)continue;const r=this.timestampBuffer.get(t);if(null==r)continue;const i=o-r;a>i&&(e._pulseIntensity=1-i/a,e._pulseColor=s,e._pulseGlowRadius=c)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,i=this.timestampBuffer.peek();return null!=i&&r>e-i}snapshotPositions(){var t,e;this.prevPositionMap.clear();for(let r=0;this.scene.length>r;r++){const i=this.scene[r];if("point"===i.type)this.prevPositionMap.set("p:"+r,{x:i.x,y:i.y,r:i.r});else if("rect"===i.type){const n=`r:${i.group||""}:${null!==(e=null===(t=i.datum)||void 0===t?void 0:t.category)&&void 0!==e?e:r}`;this.prevPositionMap.set(n,{x:i.x,y:i.y,w:i.w,h:i.h})}}}startTransition(){var t,e,r,i,n;if(!this.config.transition||0===this.prevPositionMap.size)return;const o=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;let a=!1;for(let t=0;this.scene.length>t;t++){const o=this.scene[t];let s=null;if("point"===o.type?s="p:"+t:"rect"===o.type&&(s=`r:${o.group||""}:${null!==(r=null===(e=o.datum)||void 0===e?void 0:e.category)&&void 0!==r?r:t}`),!s)continue;const c=this.prevPositionMap.get(s);c&&("point"===o.type?c.x===o.x&&c.y===o.y||(o._targetX=o.x,o._targetY=o.y,o.x=c.x,o.y=c.y,a=!0):"rect"===o.type&&(c.x===o.x&&c.y===o.y&&c.w===o.w&&c.h===o.h||(o._targetX=o.x,o._targetY=o.y,o._targetW=o.w,o._targetH=o.h,o.x=c.x,o.y=c.y,o.w=null!==(i=c.w)&&void 0!==i?i:o.w,o.h=null!==(n=c.h)&&void 0!==n?n:o.h,a=!0)))}a&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:o})}advanceTransition(t){var e,r,i;if(!this.activeTransition)return!1;const n=Math.min((t-this.activeTransition.startTime)/this.activeTransition.duration,1),o="linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?n:1-Math.pow(1-n,3);for(const t of this.scene)if("point"===t.type){if(void 0===t._targetX)continue;const e=this.prevPositionMap.get("p:0");if(!e)continue;t.x=e.x+(t._targetX-e.x)*o,t.y=e.y+(t._targetY-e.y)*o}else if("rect"===t.type){if(void 0===t._targetX)continue;const e=`r:${t.group||""}:${null!==(i=null===(r=t.datum)||void 0===r?void 0:r.category)&&void 0!==i?i:0}`,n=this.prevPositionMap.get(e);if(!n)continue;t.x=n.x+(t._targetX-n.x)*o,t.y=n.y+(t._targetY-n.y)*o,void 0!==n.w&&(t.w=n.w+(t._targetW-n.w)*o,t.h=n.h+(t._targetH-n.h)*o)}if(n>=1){for(const t of this.scene)if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=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}return this.activeTransition=null,!1}return!0}getData(){return this.buffer.toArray()}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}updateConfig(t){t.colorScheme!==this.config.colorScheme&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),Object.assign(this.config,t)}}const Mt=require("react-dom/server");function Dt(t){return Math.round(100*t)/100+""}function _t(t){var e,r,i,n;const o=t.size||[500,300],a=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),t.margin),s=o[0]-a.left-a.right,c=o[1]-a.top-a.bottom,l="streaming"===t.runtimeMode||["bar","swarm","waterfall"].includes(t.chartType),h={chartType:t.chartType,windowSize:null!==(e=t.windowSize)&&void 0!==e?e:200,windowMode:null!==(r=t.windowMode)&&void 0!==r?r:"sliding",arrowOfTime:l&&null!==(i=t.arrowOfTime)&&void 0!==i?i:"right",extentPadding:null!==(n=t.extentPadding)&&void 0!==n?n:.1,xAccessor:l?void 0:t.xAccessor,yAccessor:l?void 0:t.yAccessor,timeAccessor:l?t.timeAccessor:void 0,valueAccessor:t.valueAccessor,colorAccessor:t.colorAccessor,sizeAccessor:t.sizeAccessor,groupAccessor:t.groupAccessor,categoryAccessor:t.categoryAccessor,lineDataAccessor:t.lineDataAccessor,xExtent:t.xExtent,yExtent:t.yExtent,sizeRange:t.sizeRange,binSize:t.binSize,normalize:t.normalize,boundsAccessor:t.boundsAccessor,boundsStyle:t.boundsStyle,openAccessor:t.openAccessor,highAccessor:t.highAccessor,lowAccessor:t.lowAccessor,closeAccessor:t.closeAccessor,candlestickStyle:t.candlestickStyle,lineStyle:t.lineStyle,pointStyle:t.pointStyle,areaStyle:t.areaStyle,colorScheme:t.colorScheme,barColors:t.barColors},f=new b(h);if(t.data&&f.ingest({inserts:t.data,bounded:!0}),f.computeScene({width:s,height:c}),!f.scales||0===f.scene.length)return Mt.renderToStaticMarkup(u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-xy-frame",width:o[0],height:o[1]}));const d=f.scene.map((t,e)=>function(t,e){var r,i,n;switch(t.type){case"line":{const r=t;if(0===r.path.length)return null;const i="M"+r.path.map(([t,e])=>`${t},${e}`).join("L");return u.createElement("path",{key:"line-"+e,d:i,fill:"none",stroke:r.style.stroke||"#4e79a7",strokeWidth:r.style.strokeWidth||2,strokeDasharray:r.style.strokeDasharray,opacity:r.style.opacity})}case"area":{const n=t;if(0===n.topPath.length)return null;const o=n.topPath.map(([t,e])=>`${t},${e}`).join("L"),a=[...n.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return u.createElement("path",{key:"area-"+e,d:`M${o}L${a}Z`,fill:n.style.fill||"#4e79a7",fillOpacity:null!==(i=null!==(r=n.style.fillOpacity)&&void 0!==r?r:n.style.opacity)&&void 0!==i?i:.7,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})}case"point":return u.createElement("circle",{key:"point-"+e,cx:t.x,cy:t.y,r:t.r,fill:t.style.fill||"#4e79a7",opacity:null!==(n=t.style.opacity)&&void 0!==n?n:.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth});case"rect":return u.createElement("rect",{key:"rect-"+e,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.style.fill||"#4e79a7",opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth});case"heatcell":return u.createElement("rect",{key:"heatcell-"+e,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.fill});case"candlestick":{const r=t,i=Math.min(r.openY,r.closeY),n=Math.max(Math.abs(r.openY-r.closeY),1),o=r.isUp?r.upColor:r.downColor;return u.createElement("g",{key:"candle-"+e},u.createElement("line",{x1:r.x,y1:r.highY,x2:r.x,y2:r.lowY,stroke:r.wickColor,strokeWidth:r.wickWidth}),u.createElement("rect",{x:r.x-r.bodyWidth/2,y:i,width:r.bodyWidth,height:n,fill:o,stroke:o,strokeWidth:1}))}default:return null}}(t,e)).filter(Boolean),y=!1!==t.showAxes?function(t,e,r){var i,n,o,a;const s=t.x.ticks(5).map(e=>({pixel:t.x(e),label:(r.xFormat||r.tickFormatTime||Dt)(e)})),c=t.y.ticks(5).map(e=>({pixel:t.y(e),label:(r.yFormat||r.tickFormatValue||Dt)(e)}));return u.createElement("g",{className:"stream-axes"},u.createElement("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:"#ccc",strokeWidth:1}),s.map((t,r)=>u.createElement("g",{key:"xtick-"+r,transform:`translate(${t.pixel},${e.height})`},u.createElement("line",{y2:5,stroke:"#ccc",strokeWidth:1}),u.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"#666"},t.label))),r.xLabel&&u.createElement("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:12,fill:"#333"},r.xLabel),u.createElement("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:"#ccc",strokeWidth:1}),c.map((t,e)=>u.createElement("g",{key:"ytick-"+e,transform:`translate(0,${t.pixel})`},u.createElement("line",{x2:-5,stroke:"#ccc",strokeWidth:1}),u.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"#666"},t.label))),r.yLabel&&u.createElement("text",{x:15-(null!==(n=null===(i=r.margin)||void 0===i?void 0:i.left)&&void 0!==n?n:40),y:e.height/2,textAnchor:"middle",fontSize:12,fill:"#333",transform:`rotate(-90, ${15-(null!==(a=null===(o=r.margin)||void 0===o?void 0:o.left)&&void 0!==a?a:40)}, ${e.height/2})`},r.yLabel))}(f.scales,{width:s,height:c},t):null,g=t.title&&"string"==typeof t.title?u.createElement("text",{x:o[0]/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333"},t.title):null,p=t.background?u.createElement("rect",{x:0,y:0,width:s,height:c,fill:t.background}):null,m=u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-xy-frame"+(t.className?" "+t.className:""),width:o[0],height:o[1]},u.createElement("g",{transform:`translate(${a.left},${a.top})`},p,d,y),g);return Mt.renderToStaticMarkup(m)}function $t(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const Wt=new Set(["tree","cluster","treemap","circlepack","partition"]);function Nt(t){const r=t.chartType||"force",i=t.size||[500,500],n=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),t.margin),o=i[0]-n.left-n.right,a=i[1]-n.top-n.bottom,s=function(t){return Et[t]}(r);if(!s)throw Error(`No layout plugin found for chart type: "${r}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const c={chartType:r,nodeIDAccessor:t.nodeIDAccessor,sourceAccessor:t.sourceAccessor,targetAccessor:t.targetAccessor,valueAccessor:t.valueAccessor,childrenAccessor:t.childrenAccessor,hierarchySum:t.hierarchySum,orientation:t.orientation,nodeAlign:t.nodeAlign,nodePaddingRatio:t.nodePaddingRatio,nodeWidth:t.nodeWidth,iterations:t.iterations,forceStrength:t.forceStrength,padAngle:t.padAngle,groupWidth:t.groupWidth,sortGroups:t.sortGroups,edgeSort:t.edgeSort,treeOrientation:t.treeOrientation,edgeType:t.edgeType,padding:t.padding,paddingTop:t.paddingTop,nodeStyle:t.nodeStyle,edgeStyle:t.edgeStyle,nodeLabel:t.nodeLabel,showLabels:t.showLabels,colorBy:t.colorBy,colorScheme:t.colorScheme,edgeColorBy:t.edgeColorBy,edgeOpacity:t.edgeOpacity,colorByDepth:t.colorByDepth,nodeSize:t.nodeSize,nodeSizeRange:t.nodeSizeRange};let l,h;if(Wt.has(r)){const e=t.data||t.edges;if(!e||Array.isArray(e))return Mt.renderToStaticMarkup(u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-network-frame",width:i[0],height:i[1]}));c.__hierarchyRoot=e,l=[],h=[]}else{const e=t.nodes||[],r=Array.isArray(t.edges)?t.edges:[];if(0===e.length&&0===r.length)return Mt.renderToStaticMarkup(u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-network-frame",width:i[0],height:i[1]}));l=function(t,e){const r=$t(e.nodeIDAccessor,"id");return t.map(t=>({id:r(t)+"",x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}))}(e,c),h=function(t,e){const r=$t(e.sourceAccessor,"source"),i=$t(e.targetAccessor,"target"),n=$t(e.valueAccessor,"value");return t.map(t=>({source:r(t)+"",target:i(t)+"",value:Number(n(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(r,c)}s.computeLayout(l,h,c,[o,a]);const{sceneNodes:f,sceneEdges:d,labels:y}=s.buildScene(l,h,c,[o,a]),g=d.map((t,e)=>function(t,e){switch(t.type){case"line":return u.createElement("line",{key:"net-edge-line-"+e,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity});case"bezier":return u.createElement("path",{key:"net-edge-bezier-"+e,d:t.pathD,fill:t.style.fill||"#999",fillOpacity:t.style.fillOpacity,stroke:t.style.stroke||"none",strokeWidth:t.style.strokeWidth,opacity:t.style.opacity});case"ribbon":return u.createElement("path",{key:"net-edge-ribbon-"+e,d:t.pathD,fill:t.style.fill||"#999",fillOpacity:t.style.fillOpacity,stroke:t.style.stroke||"none",strokeWidth:t.style.strokeWidth,opacity:t.style.opacity});case"curved":return u.createElement("path",{key:"net-edge-curved-"+e,d:t.pathD,fill:t.style.fill||"none",stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity});default:return null}}(t,e)).filter(Boolean),p=f.map((t,r)=>function(t,r){switch(t.type){case"circle":return u.createElement("circle",{key:"net-circle-"+r,cx:t.cx,cy:t.cy,r:t.r,fill:t.style.fill||"#4e79a7",stroke:t.style.stroke,strokeWidth:t.style.strokeWidth,opacity:t.style.opacity});case"rect":return u.createElement("rect",{key:"net-rect-"+r,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.style.fill||"#4e79a7",stroke:t.style.stroke,strokeWidth:t.style.strokeWidth,opacity:t.style.opacity});case"arc":{const i=t,n=e.arc().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle).endAngle(i.endAngle)({})||"";return u.createElement("path",{key:"net-arc-"+r,d:n,transform:`translate(${i.cx},${i.cy})`,fill:i.style.fill||"#4e79a7",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}default:return null}}(t,r)).filter(Boolean),m=y.map((t,e)=>function(t,e){return u.createElement("text",{key:"net-label-"+e,x:t.x,y:t.y,textAnchor:t.anchor||"middle",dominantBaseline:t.baseline||"auto",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"#333",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder},t.text)}(t,e)).filter(Boolean),x=t.title&&"string"==typeof t.title?u.createElement("text",{x:i[0]/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333"},t.title):null,v=t.background?u.createElement("rect",{x:0,y:0,width:o,height:a,fill:t.background}):null,k=u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-network-frame"+(t.className?" "+t.className:""),width:i[0],height:i[1]},u.createElement("g",{transform:`translate(${n.left},${n.top})`},v,g,p,m),x);return Mt.renderToStaticMarkup(k)}function Tt(t){var r,i,n;const o=t.size||[500,400],a=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),t.margin),s=o[0]-a.left-a.right,c=o[1]-a.top-a.bottom,l=t.projection||"vertical",h="radial"===l,f={chartType:t.chartType,windowSize:null!==(r=t.windowSize)&&void 0!==r?r:1e4,windowMode:null!==(i=t.windowMode)&&void 0!==i?i:"sliding",extentPadding:null!==(n=t.extentPadding)&&void 0!==n?n:.05,projection:l,oAccessor:t.oAccessor,rAccessor:t.rAccessor,colorAccessor:t.colorAccessor,stackBy:t.stackBy,groupBy:t.groupBy,categoryAccessor:t.categoryAccessor,valueAccessor:t.valueAccessor,timeAccessor:t.timeAccessor,rExtent:t.rExtent,oExtent:t.oExtent,barPadding:t.barPadding,innerRadius:t.innerRadius,normalize:t.normalize,startAngle:t.startAngle,bins:t.bins,showOutliers:t.showOutliers,showIQR:t.showIQR,amplitude:t.amplitude,oSort:t.oSort,connectorAccessor:t.connectorAccessor,connectorStyle:t.connectorStyle,dynamicColumnWidth:t.dynamicColumnWidth,pieceStyle:t.pieceStyle,summaryStyle:t.summaryStyle,colorScheme:t.colorScheme,barColors:t.barColors},d=new Lt(f);if(t.data&&d.ingest({inserts:t.data,bounded:!0}),d.computeScene({width:s,height:c}),!d.scales||0===d.scene.length)return Mt.renderToStaticMarkup(u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-ordinal-frame",width:o[0],height:o[1]}));const y=d.scene.map((t,r)=>function(t,r){var i,n,o,a,s;switch(t.type){case"rect":return u.createElement("rect",{key:"ord-rect-"+r,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.style.fill||"#4e79a7",opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth});case"point":return u.createElement("circle",{key:"ord-point-"+r,cx:t.x,cy:t.y,r:t.r,fill:t.style.fill||"#4e79a7",opacity:null!==(i=t.style.opacity)&&void 0!==i?i:.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth});case"wedge":{const i=t,n=e.arc().innerRadius(i.innerRadius).outerRadius(i.outerRadius).startAngle(i.startAngle).endAngle(i.endAngle)({})||"";return u.createElement("path",{key:"ord-wedge-"+r,d:n,transform:`translate(${i.cx},${i.cy})`,fill:i.style.fill||"#4e79a7",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}case"boxplot":{const e=t,i=e.columnWidth/2;return"vertical"===e.projection?u.createElement("g",{key:"ord-boxplot-"+r},u.createElement("line",{x1:e.x,y1:e.minPos,x2:e.x,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:1}),u.createElement("rect",{x:e.x-i,y:Math.min(e.q1Pos,e.q3Pos),width:e.columnWidth,height:Math.abs(e.q3Pos-e.q1Pos),fill:e.style.fill||"#4e79a7",fillOpacity:null!==(n=e.style.fillOpacity)&&void 0!==n?n:.6,stroke:e.style.stroke||"#333",strokeWidth:1}),u.createElement("line",{x1:e.x-i,y1:e.medianPos,x2:e.x+i,y2:e.medianPos,stroke:e.style.stroke||"#333",strokeWidth:2}),u.createElement("line",{x1:e.x-.5*i,y1:e.minPos,x2:e.x+.5*i,y2:e.minPos,stroke:e.style.stroke||"#333",strokeWidth:1}),u.createElement("line",{x1:e.x-.5*i,y1:e.maxPos,x2:e.x+.5*i,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:1})):u.createElement("g",{key:"ord-boxplot-"+r},u.createElement("line",{x1:e.minPos,y1:e.y,x2:e.maxPos,y2:e.y,stroke:e.style.stroke||"#333",strokeWidth:1}),u.createElement("rect",{x:Math.min(e.q1Pos,e.q3Pos),y:e.y-i,width:Math.abs(e.q3Pos-e.q1Pos),height:e.columnWidth,fill:e.style.fill||"#4e79a7",fillOpacity:null!==(o=e.style.fillOpacity)&&void 0!==o?o:.6,stroke:e.style.stroke||"#333",strokeWidth:1}),u.createElement("line",{x1:e.medianPos,y1:e.y-i,x2:e.medianPos,y2:e.y+i,stroke:e.style.stroke||"#333",strokeWidth:2}),u.createElement("line",{x1:e.minPos,y1:e.y-.5*i,x2:e.minPos,y2:e.y+.5*i,stroke:e.style.stroke||"#333",strokeWidth:1}),u.createElement("line",{x1:e.maxPos,y1:e.y-.5*i,x2:e.maxPos,y2:e.y+.5*i,stroke:e.style.stroke||"#333",strokeWidth:1}))}case"violin":{const e=t,i=[u.createElement("path",{key:"ord-violin-path-"+r,d:e.pathString,transform:e.translateX||e.translateY?`translate(${e.translateX},${e.translateY})`:void 0,fill:e.style.fill||"#4e79a7",fillOpacity:null!==(a=e.style.fillOpacity)&&void 0!==a?a:.6,stroke:e.style.stroke||"#333",strokeWidth:e.style.strokeWidth||1})];if(e.iqrLine&&e.bounds){const t=e.bounds,n=t.x+t.width/2,o=t.y+t.height/2;t.height>t.width?i.push(u.createElement("line",{key:"ord-violin-iqr-"+r,x1:n,y1:e.iqrLine.q1Pos,x2:n,y2:e.iqrLine.q3Pos,stroke:e.style.stroke||"#333",strokeWidth:2}),u.createElement("circle",{key:"ord-violin-med-"+r,cx:n,cy:e.iqrLine.medianPos,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1})):i.push(u.createElement("line",{key:"ord-violin-iqr-"+r,x1:e.iqrLine.q1Pos,y1:o,x2:e.iqrLine.q3Pos,y2:o,stroke:e.style.stroke||"#333",strokeWidth:2}),u.createElement("circle",{key:"ord-violin-med-"+r,cx:e.iqrLine.medianPos,cy:o,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1}))}return u.createElement("g",{key:"ord-violin-"+r},i)}case"connector":return u.createElement("line",{key:"ord-conn-"+r,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:null!==(s=t.style.opacity)&&void 0!==s?s:.5});default:return null}}(t,r)).filter(Boolean),g=!1!==t.showAxes?function(t,e,r){var i,n,o,a,s,c,l,h;const f=t.scales;if(!f)return null;if("radial"===f.projection)return null;const d="vertical"===f.projection,y=Object.values(t.columns).map(t=>({pixel:t.middle,label:(r.oFormat||String)(t.name)})),g=f.r.ticks(5).map(t=>({pixel:f.r(t),label:(r.rFormat||Dt)(t)}));return d?u.createElement("g",{className:"ordinal-axes"},u.createElement("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:"#ccc",strokeWidth:1}),y.map((t,r)=>u.createElement("g",{key:"oxtick-"+r,transform:`translate(${t.pixel},${e.height})`},u.createElement("line",{y2:5,stroke:"#ccc",strokeWidth:1}),u.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"#666"},t.label))),r.oLabel&&u.createElement("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:12,fill:"#333"},r.oLabel),u.createElement("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:"#ccc",strokeWidth:1}),g.map((t,e)=>u.createElement("g",{key:"oytick-"+e,transform:`translate(0,${t.pixel})`},u.createElement("line",{x2:-5,stroke:"#ccc",strokeWidth:1}),u.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"#666"},t.label))),r.rLabel&&u.createElement("text",{x:15-(null!==(n=null===(i=r.margin)||void 0===i?void 0:i.left)&&void 0!==n?n:40),y:e.height/2,textAnchor:"middle",fontSize:12,fill:"#333",transform:`rotate(-90, ${15-(null!==(a=null===(o=r.margin)||void 0===o?void 0:o.left)&&void 0!==a?a:40)}, ${e.height/2})`},r.rLabel)):u.createElement("g",{className:"ordinal-axes"},u.createElement("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:"#ccc",strokeWidth:1}),g.map((t,r)=>u.createElement("g",{key:"oxtick-"+r,transform:`translate(${t.pixel},${e.height})`},u.createElement("line",{y2:5,stroke:"#ccc",strokeWidth:1}),u.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"#666"},t.label))),r.rLabel&&u.createElement("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:12,fill:"#333"},r.rLabel),u.createElement("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:"#ccc",strokeWidth:1}),y.map((t,e)=>u.createElement("g",{key:"oytick-"+e,transform:`translate(0,${t.pixel})`},u.createElement("line",{x2:-5,stroke:"#ccc",strokeWidth:1}),u.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"#666"},t.label))),r.oLabel&&u.createElement("text",{x:15-(null!==(c=null===(s=r.margin)||void 0===s?void 0:s.left)&&void 0!==c?c:40),y:e.height/2,textAnchor:"middle",fontSize:12,fill:"#333",transform:`rotate(-90, ${15-(null!==(h=null===(l=r.margin)||void 0===l?void 0:l.left)&&void 0!==h?h:40)}, ${e.height/2})`},r.oLabel))}(d,{width:s,height:c},t):null,p=t.title&&"string"==typeof t.title?u.createElement("text",{x:o[0]/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333"},t.title):null,m=t.background?u.createElement("rect",{x:0,y:0,width:s,height:c,fill:t.background}):null,x=u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-ordinal-frame"+(t.className?" "+t.className:""),width:o[0],height:o[1]},u.createElement("g",{transform:`translate(${h?a.left+s/2:a.left},${h?a.top+c/2:a.top})`},m,y,g),p);return Mt.renderToStaticMarkup(x)}exports.renderNetworkToStaticSVG=function(t){return Nt(t)},exports.renderOrdinalToStaticSVG=function(t){return Tt(t)},exports.renderToStaticSVG=function(t,e){switch(t){case"xy":return _t(e);case"ordinal":return Tt(e);case"network":return Nt(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", or "network".`)}},exports.renderXYToStaticSVG=function(t){return _t(t)};
1
+ "use strict";const t=require("react"),e=require("d3-scale"),i=require("d3-array"),r=require("d3-scale-chromatic"),n=require("d3-interpolate"),o=require("d3-force"),a=require("d3-chord"),s=require("d3-shape"),c=require("d3-hierarchy");function l(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const i in t)if("default"!==i){const r=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,r.get?r:{enumerable:!0,get:function(){return t[i]}})}return e.default=t,Object.freeze(e)}const u=l(t);class h{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 i of t){const t=this.push(i);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;const e=this;return{next:()=>e._size>t?{done:!1,value:e.get(t++)}:{done:!0,value:void 0}}}toArray(){const t=[];for(const e of this)t.push(e);return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),i=[];for(;e.length>t;)i.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 i}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 f{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 i of t){const t=e?e(i):i;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 d(t,e,i,r,n){const o=new Map;for(const a of t){const t=e(a),s=i(a);if(null==t||null==s||Number.isNaN(t)||Number.isNaN(s))continue;const c=Math.floor(t/r)*r;let l=o.get(c);if(l||(l={start:c,end:c+r,total:0,categories:new Map},o.set(c,l)),l.total+=s,n){const t=n(a);l.categories.set(t,(l.categories.get(t)||0)+s)}}return o}function y(t,e,i,r,n,o){const a=[];for(const n of t){const t=i(n),o=r(n);null==t||null==o||Number.isNaN(t)||Number.isNaN(o)||a.push({px:e.x(t),py:e.y(o),rawY:o,d:n})}a.sort((t,e)=>t.px-e.px);const s=Array(a.length),c=Array(a.length),l=Array(a.length);for(let t=0;a.length>t;t++){const e=a[t];s[t]=[e.px,e.py],c[t]=e.rawY,l[t]=e.d}return{type:"line",path:s,rawValues:c,style:n,datum:l,group:o}}function g(t,e,i,r,n,o,a,s){const c=[];for(const o of t){const t=i(o),a=r(o);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const l=e.x(t),u=s?s(o):n;c.push({px:l,topY:e.y(a),botY:e.y(u)})}c.sort((t,e)=>t.px-e.px);const l=Array(c.length),u=Array(c.length);for(let t=0;c.length>t;t++){const e=c[t];l[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:l,bottomPath:u,style:o,datum:t,group:a}}function p(t,e,i,r,n,o,a){const s=i(t),c=r(t);if(null==s||null==c||Number.isNaN(s)||Number.isNaN(c))return null;const l={type:"point",x:e.x(s),y:e.y(c),r:n,style:o,datum:t};return void 0!==a&&(l.pointId=a),l}function m(t,e,i,r,n,o,a){return{type:"rect",x:t,y:e,w:i,h:r,style:n,datum:o,group:a}}function x(t,e,i,r,n,o){return{type:"heatcell",x:t,y:e,w:i,h:r,fill:n,datum:o}}function v(t,e){if("function"==typeof t)return e=>+t(e);const i=t||e;return t=>+t[i]}function k(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}class b{constructor(t){this.xExtent=new f,this.yExtent=new f,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.config=t,this.buffer=new h(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=v(t.timeAccessor||t.xAccessor,"time"),this.getY=v(t.valueAccessor||t.yAccessor,"value")):(this.getX=v(t.xAccessor,"x"),this.getY=v(t.yAccessor,"y")),this.getGroup=k(t.groupAccessor),this.getCategory=k(t.categoryAccessor),this.getSize=t.sizeAccessor?v(t.sizeAccessor,"size"):void 0,this.getColor=k(t.colorAccessor),this.getBounds=t.boundsAccessor?v(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?v(t.y0Accessor,"y0"):void 0,this.getPointId=k(t.pointIdAccessor),"candlestick"===t.chartType&&(this.getOpen=v(t.openAccessor,"open"),this.getHigh=v(t.highAccessor,"high"),this.getLow=v(t.lowAccessor,"low"),this.getClose=v(t.closeAccessor,"close")),t.pulse&&(this.timestampBuffer=new h(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this.needsFullRebuild=!0,t.bounded){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=t.totalSize||t.inserts.length;i>this.buffer.capacity&&(this.buffer.resize(i),this.timestampBuffer&&i>this.timestampBuffer.capacity&&this.timestampBuffer.resize(i));for(const i of t.inserts)this.buffer.push(i),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(i)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(i)),this.yExtent.push(this.getLow(i))):(this.yExtent.push(this.getY(i)),this.getY0&&this.yExtent.push(this.getY0(i)))}else for(const i of t.inserts){"growing"===this.config.windowMode&&this.buffer.full&&(this.growingCap*=2,this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap));const t=this.buffer.push(i);this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(i)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(i)),this.yExtent.push(this.getLow(i))):(this.yExtent.push(this.getY(i)),this.getY0&&this.yExtent.push(this.getY0(i))),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 i,r,n,o,a,s;const{config:c,buffer:l}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);if(this.xExtent.dirty&&this.xExtent.recalculate(l,this.getX),this.yExtent.dirty)if("candlestick"===c.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of l)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(l,this.getY);const u=this.xExtent.extent,h=this.yExtent.extent;let f=c.xExtent?[null!==(i=c.xExtent[0])&&void 0!==i?i:u[0],null!==(r=c.xExtent[1])&&void 0!==r?r:u[1]]:u,y=c.yExtent?[null!==(n=c.yExtent[0])&&void 0!==n?n:h[0],null!==(o=c.yExtent[1])&&void 0!==o?o:h[1]]:h;const g=c.yExtent&&null!=c.yExtent[0]&&null!=c.yExtent[1];if("stackedarea"===c.chartType&&!g&&l.size>0)if(c.normalize)y=[0,1+c.extentPadding];else{const t=l.toArray(),e=this.groupData(t),i=new Map;for(const t of e)for(const e of t.data){const t=this.getX(e),r=this.getY(e);null==t||null==r||Number.isNaN(t)||Number.isNaN(r)||i.set(t,(i.get(t)||0)+r)}let r=0;for(const t of i.values())t>r&&(r=t);y=[0,r+(r>0?r*c.extentPadding:1)]}else if("bar"===c.chartType&&c.binSize&&!g&&l.size>0){const[,t]=function(t,e,i,r,n){const o=d(t,e,i,r,n);if(0===o.size)return[0,0];let a=0;for(const t of o.values())t.total>a&&(a=t.total);return[0,a]}(l,this.getX,this.getY,c.binSize,this.getCategory);y=[0,t+t*c.extentPadding]}else if("waterfall"===c.chartType&&!g&&l.size>0){const[t,e]=function(t,e){let i=0,r=0,n=0;for(const o of t){const t=e(o);null==t||Number.isNaN(t)||(n+=t,i>n&&(i=n),n>r&&(r=n))}return[i,r]}(l,this.getY),i=e-t,r=i>0?i*c.extentPadding:1;y=[Math.min(0,t-Math.abs(r)),Math.max(0,e+Math.abs(r))]}else if(!g&&y[0]!==1/0){if(this.getBounds){const t=l.toArray();for(const e of t){const t=this.getY(e),i=this.getBounds(e);null!=t&&!Number.isNaN(t)&&i&&(t+i>y[1]&&(y[1]=t+i),y[0]>t-i&&(y[0]=t-i))}}const t=y[1]-y[0],e=t>0?t*c.extentPadding:1,i=null===(a=c.yExtent)||void 0===a?void 0:a[0],r=null===(s=c.yExtent)||void 0===s?void 0:s[1];y=[null!=i?y[0]:y[0]-e,null!=r?y[1]:y[1]+e]}if(f[0]!==1/0&&f[1]!==-1/0||(f=[0,1]),y[0]!==1/0&&y[1]!==-1/0||(y=[0,1]),void 0!==c.arrowOfTime)if("x"==("up"===(p=c.arrowOfTime)||"down"===p?"y":"x")){const i="right"===c.arrowOfTime?[0,t.width]:[t.width,0];this.scales={x:e.scaleLinear().domain(f).range(i),y:e.scaleLinear().domain(y).range([t.height,0])}}else{const i="down"===c.arrowOfTime?[0,t.height]:[t.height,0];this.scales={x:e.scaleLinear().domain(y).range([0,t.width]),y:e.scaleLinear().domain(f).range(i)}}else this.scales={x:e.scaleLinear().domain(f).range([0,t.width]),y:e.scaleLinear().domain(y).range([t.height,0])};var p;this.config.transition&&this.scene.length>0&&this.snapshotPositions();const m=l.toArray();this.scene=this.buildSceneNodes(t),this.config.decay&&this.applyDecay(this.scene,m),this.config.pulse&&this.applyPulse(this.scene,m),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}remapScene(t){const i=t.width/this.lastLayout.width,r=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const e of t.path)e[0]*=i,e[1]*=r;break;case"area":for(const e of t.topPath)e[0]*=i,e[1]*=r;for(const e of t.bottomPath)e[0]*=i,e[1]*=r;break;case"point":t.x*=i,t.y*=r;break;case"rect":case"heatcell":t.x*=i,t.y*=r,t.w*=i,t.h*=r;break;case"candlestick":t.x*=i,t.openY*=r,t.closeY*=r,t.highY*=r,t.lowY*=r}const n=this.scales.x.domain(),o=this.scales.y.domain(),a=this.scales.x.range(),s=this.scales.y.range();this.scales={x:e.scaleLinear().domain(n).range([a[0]*i,a[1]*i]),y:e.scaleLinear().domain(o).range([s[0]*r,s[1]*r])},this.lastLayout={width:t.width,height:t.height},this.version++}buildSceneNodes(t){const{config:e,buffer:i,scales:r}=this;if(!r||0===i.size)return[];const n=i.toArray();switch(e.chartType){case"line":return this.buildLineScene(n);case"area":return this.buildAreaScene(n);case"stackedarea":return this.buildStackedAreaScene(n);case"scatter":case"bubble":return this.buildPointScene(n);case"heatmap":return this.buildHeatmapScene(n,t);case"bar":return this.buildBarScene(n);case"swarm":return this.buildSwarmScene(n);case"waterfall":return this.buildWaterfallScene(n,t);case"candlestick":return this.buildCandlestickScene(n,t);default:return[]}}buildLineScene(t){var e;const i=this.groupData(t),r=[],n=null===(e=this.config.annotations)||void 0===e?void 0:e.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(this.getBounds)for(const t of i){const e=this.buildBoundsForGroup(t.data,t.key);e&&r.push(e)}for(const t of i){const e=this.resolveLineStyle(t.key,t.data[0]),i=y(t.data,this.scales,this.getX,this.getY,e,t.key);n&&n.length>0&&(i.colorThresholds=n),r.push(i)}return r}buildAreaScene(t){const e=this.groupData(t),i=[],r=this.scales.y.domain()[0];for(const t of e){const e=this.resolveAreaStyle(t.key,t.data[0]),n=g(t.data,this.scales,this.getX,this.getY,r,e,t.key,this.getY0);this.config.gradientFill&&(n.fillGradient=this.config.gradientFill),i.push(n)}return i}buildStackedAreaScene(t){const e=this.groupData(t);return e.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0),function(t,e,i,r,n,o){var a;const s=new Set;for(const e of t)for(const t of e.data){const e=i(t);null==e||Number.isNaN(e)||s.add(e)}const c=Array.from(s).sort((t,e)=>t-e),l=new Map;for(const e of t){const t=new Map;for(const n of e.data){const e=i(n),o=r(n);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||t.set(e,(t.get(e)||0)+o)}l.set(e.key,t)}let u;if(o){u=new Map;for(const e of c){let i=0;for(const r of t)i+=(null===(a=l.get(r.key))||void 0===a?void 0:a.get(e))||0;u.set(e,i||1)}}const h=[],f=new Map;for(const t of c)f.set(t,0);for(const i of t){const t=l.get(i.key),r=[],a=[];for(const i of c){let n=t.get(i)||0;const s=f.get(i);o&&(n/=u.get(i));const c=e.x(i);a.push([c,e.y(s)]),r.push([c,e.y(s+n)]),f.set(i,s+n)}h.push({type:"area",topPath:r,bottomPath:a,style:n(i.key,i.data[0]),datum:i.data,group:i.key})}return h}(e,this.scales,this.getX,this.getY,(t,e)=>this.resolveAreaStyle(t,e),this.config.normalize)}buildPointScene(t){const e=[],i="bubble"===this.config.chartType?10:5,r=this.config.sizeRange||[3,15];let n=null;if(this.getSize&&!this.config.pointStyle){const e=t.map(t=>this.getSize(t)).filter(t=>null!=t&&!Number.isNaN(t));if(e.length>0){const t=Math.min(...e),i=Math.max(...e);n=e=>t===i?(r[0]+r[1])/2:r[0]+(e-t)/(i-t)*(r[1]-r[0])}}let o=null;if(this.getColor&&!this.config.pointStyle){const e=new Set;for(const i of t){const t=this.getColor(i);t&&e.add(t)}const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];o=new Map;let r=0;for(const t of e)o.set(t,i[r%i.length]),r++}for(const r of t){let t=this.config.pointStyle?this.config.pointStyle(r):{fill:"#4e79a7",opacity:.8},a=t.r||i;if(n&&this.getSize){const t=this.getSize(r);null==t||Number.isNaN(t)||(a=n(t))}if(o&&this.getColor){const e=this.getColor(r);e&&o.has(e)&&(t=Object.assign(Object.assign({},t),{fill:o.get(e)}))}const s=this.getPointId?this.getPointId(r)+"":void 0,c=p(r,this.scales,this.getX,this.getY,a,t,s);c&&e.push(c)}return e}buildHeatmapScene(t,e){const i=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(t,e);const r=v(this.config.valueAccessor,"value"),n=new Set,o=new Set;for(const e of t)n.add(this.getX(e)),o.add(this.getY(e));const a=Array.from(n).sort((t,e)=>t-e),s=Array.from(o).sort((t,e)=>t-e);if(0===a.length||0===s.length)return i;const c=e.width/a.length,l=e.height/s.length,u=new Map;for(const e of t){const t=`${this.getX(e)}_${this.getY(e)}`;u.set(t,{val:r(e),datum:e})}let h=1/0,f=-1/0;for(const{val:t}of u.values())h>t&&(h=t),t>f&&(f=t);const d=f-h||1;for(let t=0;a.length>t;t++)for(let e=0;s.length>e;e++){const r=u.get(`${a[t]}_${s[e]}`);if(!r)continue;const n=(r.val-h)/d;i.push(x(t*c,(s.length-1-e)*l,c,l,`rgb(${Math.round(220-180*n)},${Math.round(220-100*n)},${Math.round(255-50*n)})`,r.datum))}return i}buildStreamingHeatmapScene(t,e){var i,r,n;const o=[],a=null!==(i=this.config.heatmapXBins)&&void 0!==i?i:20,s=null!==(r=this.config.heatmapYBins)&&void 0!==r?r:20,c=null!==(n=this.config.heatmapAggregation)&&void 0!==n?n:"count",l=v(this.config.valueAccessor,"value");if(!this.scales||0===t.length)return o;const[u,h]=this.scales.x.domain(),[f,d]=this.scales.y.domain(),y=(h-u||1)/a,g=(d-f||1)/s,p=new Map;for(const e of t){const t=this.getX(e),i=this.getY(e),r=Math.min(Math.floor((t-u)/y),a-1),n=Math.min(Math.floor((i-f)/g),s-1);if(0>r||0>n)continue;const o=`${r}_${n}`;let c=p.get(o);c||(c={sum:0,count:0,data:[]},p.set(o,c)),c.count++,c.sum+=l(e),c.data.push(e)}let m=1/0,k=-1/0;const b=new Map;for(const[t,e]of p){let i;switch(c){case"sum":i=e.sum;break;case"mean":i=e.count>0?e.sum/e.count:0;break;default:i=e.count}b.set(t,i),m>i&&(m=i),i>k&&(k=i)}const w=k-m||1,E=e.width/a,S=e.height/s;for(const[t,e]of b){const[i,r]=t.split("_"),n=+i,a=+r,c=(e-m)/w,l=`rgb(${Math.round(220-180*c)},${Math.round(220-100*c)},${Math.round(255-50*c)})`,u=p.get(t);o.push(x(n*E,(s-1-a)*S,E,S,l,{xi:n,yi:a,value:e,count:u.count,sum:u.sum,data:u.data}))}return o}buildBarScene(t){var e;if(!this.config.binSize)return[];const i=d(t,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===i.size)return[];let r=null;if(this.getCategory){const t=new Set;for(const e of i.values())for(const i of e.categories.keys())t.add(i);const e=this.config.barColors?Object.keys(this.config.barColors):[],n=new Set(e),o=Array.from(t).filter(t=>!n.has(t)).sort();r=[...e.filter(e=>t.has(e)),...o]}const n=[],o=this.scales,[a,s]=o.x.domain();for(const t of i.values()){const i=Math.max(t.start,a),c=Math.min(t.end,s);if(i>=c)continue;const l=o.x(i),u=o.x(c),h=Math.min(l,u)+.5,f=Math.max(l,u)-.5-h;if(f>0)if(r&&t.categories.size>0){let i=0;for(const a of r){const r=t.categories.get(a)||0;if(0===r)continue;const s=o.y(i),c=o.y(i+r);n.push(m(h,Math.min(s,c),f,Math.abs(s-c),{fill:(null===(e=this.config.barColors)||void 0===e?void 0:e[a])||"#4e79a7"},{binStart:t.start,binEnd:t.end,total:t.total,category:a,categoryValue:r},a)),i+=r}}else{const e=o.y(0),i=o.y(t.total);n.push(m(h,Math.min(e,i),f,Math.abs(e-i),{fill:"#007bff"},{binStart:t.start,binEnd:t.end,total:t.total}))}}return n}buildSwarmScene(t){var e,i,r,n;const o=[],a=this.config.swarmStyle||{},s=null!==(e=a.radius)&&void 0!==e?e:3,c=null!==(i=a.fill)&&void 0!==i?i:"#007bff",l=null!==(r=a.opacity)&&void 0!==r?r:.7,u=a.stroke,h=a.strokeWidth;for(const e of t){const t=this.getX(e),i=this.getY(e);if(null==i||Number.isNaN(i))continue;const r=this.scales.x(t),a=this.scales.y(i);let f=c;if(this.getCategory){const t=this.getCategory(e);f=(null===(n=this.config.barColors)||void 0===n?void 0:n[t])||f}const d={type:"point",x:r,y:a,r:s,style:{fill:f,opacity:l,stroke:u,strokeWidth:h},datum:e};this.getPointId&&(d.pointId=this.getPointId(e)+""),o.push(d)}return o}buildWaterfallScene(t,e){var i,r,n;const o=[],a=this.scales,s=this.config.waterfallStyle,c=t.filter(t=>{const e=this.getY(t);return null!=e&&!Number.isNaN(e)});if(0===c.length)return o;const l=null!==(i=null==s?void 0:s.positiveColor)&&void 0!==i?i:"#28a745",u=null!==(r=null==s?void 0:s.negativeColor)&&void 0!==r?r:"#dc3545",h=null!==(n=null==s?void 0:s.gap)&&void 0!==n?n:1,f=null==s?void 0:s.stroke,d=null==s?void 0:s.strokeWidth;let y=0;for(let t=0;c.length>t;t++){const i=c[t],r=this.getX(i),n=this.getY(i),g=y+n;let p;p=c.length-1>t?this.getX(c[t+1])-r:t>0?r-this.getX(c[t-1]):0;const x=a.x(r),v=0!==p?a.x(r+p):x+e.width/10,k=Math.min(x,v)+h/2,b=Math.max(x,v)-h/2-k;if(0>=b){y=g;continue}const w=a.y(y),E=a.y(g);o.push(m(k,Math.min(w,E),b,Math.abs(w-E),{fill:0>n?u:l,stroke:f,strokeWidth:d},Object.assign(Object.assign({},i),{baseline:y,cumEnd:g,delta:n,_connectorStroke:null==s?void 0:s.connectorStroke,_connectorWidth:null==s?void 0:s.connectorWidth}))),y=g}return o}buildCandlestickScene(t,e){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const i=[],r=this.config.candlestickStyle||{},n=r.upColor||"#28a745",o=r.downColor||"#dc3545",a=r.wickColor||"#333",s=r.wickWidth||1,c=t.map(t=>this.getX(t)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let l=r.bodyWidth||6;if(!r.bodyWidth&&c.length>1){let t=1/0;for(let e=1;c.length>e;e++){const i=Math.abs(this.scales.x(c[e])-this.scales.x(c[e-1]));i>0&&t>i&&(t=i)}t!==1/0&&(l=Math.max(2,Math.min(.6*t,20)))}for(const e of t){const t=this.getX(e);if(null==t||Number.isNaN(t))continue;const r=this.getOpen(e),c=this.getHigh(e),u=this.getLow(e),h=this.getClose(e);if([r,c,u,h].some(t=>null==t||Number.isNaN(t)))continue;const f=h>=r;i.push({type:"candlestick",x:this.scales.x(t),openY:this.scales.y(r),closeY:this.scales.y(h),highY:this.scales.y(c),lowY:this.scales.y(u),bodyWidth:l,upColor:n,downColor:o,wickColor:a,wickWidth:s,isUp:f,datum:e})}return i}buildBoundsForGroup(t,e){if(!this.getBounds||!this.scales)return null;const i=[],r=[];for(const e of t){const t=this.getX(e),n=this.getY(e);if(null==t||null==n||Number.isNaN(t)||Number.isNaN(n))continue;const o=this.getBounds(e),a=this.scales.x(t);if(o&&0!==o)i.push([a,this.scales.y(n+o)]),r.push([a,this.scales.y(n-o)]);else{const t=this.scales.y(n);i.push([a,t]),r.push([a,t])}}return 2>i.length?null:{type:"area",topPath:i,bottomPath:r,style:this.resolveBoundsStyle(e,t[0]),datum:t,group:e,interactive:!1}}resolveBoundsStyle(t,e){const i=this.config.boundsStyle;return"function"==typeof i?i(e||{},t):i&&"object"==typeof i?i:{fill:this.resolveLineStyle(t,e).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){var i,r,n;const o=this.config.decay;if(!o||1>=e)return 1;const a=null!==(i=o.minOpacity)&&void 0!==i?i:.1,s=e-1-t;switch(o.type){case"linear":return a+(1-s/(e-1))*(1-a);case"exponential":{const t=null!==(r=o.halfLife)&&void 0!==r?r:e/2;return a+Math.pow(.5,s/t)*(1-a)}case"step":return(null!==(n=o.stepThreshold)&&void 0!==n?n:.5*e)>s?1:a;default:return 1}}applyDecay(t,e){var i,r;if(!this.config.decay)return;const n=e.length;if(1>=n)return;const o=new Map;for(let t=0;e.length>t;t++)o.set(e[t],t);for(const e of t){if("line"===e.type||"area"===e.type)continue;const t=o.get(e.datum);if(null==t)continue;const a=this.computeDecayOpacity(t,n);if("heatcell"===e.type)e.style={opacity:a};else if("candlestick"===e.type)e._decayOpacity=a;else{const t=null!==(r=null===(i=e.style)||void 0===i?void 0:i.opacity)&&void 0!==r?r:1;e.style=Object.assign(Object.assign({},e.style),{opacity:t*a})}}}computePulseIntensity(t,e){var i;const r=this.config.pulse;if(!r)return 0;const n=null!==(i=r.duration)&&void 0!==i?i:500,o=e-t;return n>o?1-o/n:0}applyPulse(t,e){var i,r;if(!this.config.pulse||!this.timestampBuffer)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(i=this.config.pulse.color)&&void 0!==i?i:"rgba(255,255,255,0.6)",a=null!==(r=this.config.pulse.glowRadius)&&void 0!==r?r:4,s=new Map;for(let t=0;e.length>t;t++)s.set(e[t],t);for(const e of t){if("line"===e.type)continue;if("area"===e.type){const t=Array.isArray(e.datum)?e.datum:[e.datum];let i=0;for(const e of t){const t=s.get(e);if(null==t)continue;const r=this.timestampBuffer.get(t);if(null==r)continue;const o=this.computePulseIntensity(r,n);o>i&&(i=o)}i>0&&(e._pulseIntensity=i,e._pulseColor=o);continue}const t=s.get(e.datum);if(null==t)continue;const i=this.timestampBuffer.get(t);if(null==i)continue;const r=this.computePulseIntensity(i,n);r>0&&(e._pulseIntensity=r,e._pulseColor=o,e._pulseGlowRadius=a)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,r=this.timestampBuffer.peek();return null!=r&&i>e-r}snapshotPositions(){this.prevPositionMap.clear();for(let t=0;this.scene.length>t;t++){const e=this.scene[t],i=this.getNodeIdentity(e,t);i&&("point"===e.type?this.prevPositionMap.set(i,{x:e.x,y:e.y,r:e.r}):"rect"===e.type||"heatcell"===e.type?this.prevPositionMap.set(i,{x:e.x,y:e.y,w:e.w,h:e.h}):"candlestick"===e.type&&this.prevPositionMap.set(i,{x:e.x,y:e.openY}))}}getNodeIdentity(t,e){var i,r,n,o;switch(t.type){case"point":return`p:${void 0===t.datum?e:this.getX(t.datum)}_${this.getY(t.datum)}`;case"rect":return`r:${t.group||""}:${null!==(o=null!==(r=null===(i=t.datum)||void 0===i?void 0:i.binStart)&&void 0!==r?r:null===(n=t.datum)||void 0===n?void 0:n.category)&&void 0!==o?o:e}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return"c:"+this.getX(t.datum);default:return null}}startTransition(){var t,e,i,r,n,o;if(!this.config.transition||0===this.prevPositionMap.size)return;const a=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;let s=!1;for(let t=0;this.scene.length>t;t++){const a=this.scene[t],c=this.getNodeIdentity(a,t);if(!c)continue;const l=this.prevPositionMap.get(c);if(l)if("point"===a.type){const t={x:a.x,y:a.y,r:a.r};l.x===t.x&&l.y===t.y||(a._targetX=t.x,a._targetY=t.y,a._targetR=t.r,a.x=l.x,a.y=l.y,a.r=null!==(e=l.r)&&void 0!==e?e:a.r,s=!0)}else if("rect"===a.type){const t={x:a.x,y:a.y,w:a.w,h:a.h};l.x===t.x&&l.y===t.y&&l.w===t.w&&l.h===t.h||(a._targetX=t.x,a._targetY=t.y,a._targetW=t.w,a._targetH=t.h,a.x=l.x,a.y=l.y,a.w=null!==(i=l.w)&&void 0!==i?i:a.w,a.h=null!==(r=l.h)&&void 0!==r?r:a.h,s=!0)}else if("heatcell"===a.type){const t={x:a.x,y:a.y,w:a.w,h:a.h};l.x===t.x&&l.y===t.y||(a._targetX=t.x,a._targetY=t.y,a._targetW=t.w,a._targetH=t.h,a.x=l.x,a.y=l.y,a.w=null!==(n=l.w)&&void 0!==n?n:a.w,a.h=null!==(o=l.h)&&void 0!==o?o:a.h,s=!0)}}s&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:a})}advanceTransition(t){var e;if(!this.activeTransition)return!1;const i=Math.min((t-this.activeTransition.startTime)/this.activeTransition.duration,1),r="linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?i:1-Math.pow(1-i,3);for(const t of this.scene)if("point"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=i.x+(t._targetX-i.x)*r,t.y=i.y+(t._targetY-i.y)*r,void 0!==t._targetR&&void 0!==i.r&&(t.r=i.r+(t._targetR-i.r)*r)}else if("rect"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=i.x+(t._targetX-i.x)*r,t.y=i.y+(t._targetY-i.y)*r,void 0!==i.w&&(t.w=i.w+(t._targetW-i.w)*r),void 0!==i.h&&(t.h=i.h+(t._targetH-i.h)*r)}else if("heatcell"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=i.x+(t._targetX-i.x)*r,t.y=i.y+(t._targetY-i.y)*r,void 0!==i.w&&(t.w=i.w+(t._targetW-i.w)*r),void 0!==i.h&&(t.h=i.h+(t._targetH-i.h)*r)}if(i>=1){for(const t of this.scene)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}return this.activeTransition=null,!1}return!0}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const i of t){const t=this.getGroup(i);e.has(t)||e.set(t,[]),e.get(t).push(i)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveLineStyle(t,e){const i=this.config.lineStyle;return"function"==typeof i?i(e||{},t):i&&"object"==typeof i?{stroke:i.stroke||"#007bff",strokeWidth:i.strokeWidth||2,strokeDasharray:i.strokeDasharray,fill:i.fill,fillOpacity:i.fillOpacity,opacity:i.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var i;if(this.config.areaStyle)return this.config.areaStyle(e||{});const r=this.config.lineStyle;return"function"==typeof r?r(e||{},t):r&&"object"==typeof r?{fill:r.fill||r.stroke||"#4e79a7",fillOpacity:null!==(i=r.fillOpacity)&&void 0!==i?i:.7,stroke:r.stroke||"#4e79a7",strokeWidth:r.strokeWidth||2}:{fill:"#4e79a7",fillOpacity:.7,stroke:"#4e79a7",strokeWidth:2}}getData(){return this.buffer.toArray()}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.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],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){Object.assign(this.config,t),this.needsFullRebuild=!0}}function w(t,e){var i=t.get(e);if(!i)throw Error("missing: "+e);return i}function E(t,e){var i,r=[],n=[],o=[],a={},s=[];function c(t){o[t]=!1,a.hasOwnProperty(t)&&Object.keys(a[t]).forEach(function(e){delete a[t][e],o[e]&&c(e)})}function l(t){var e,r,h=!1;for(n.push(t),o[t]=!0,e=0;s[t].length>e;e++)(r=s[t][e])===i?(u(i,n),h=!0):o[r]||(h=l(r));if(h)c(t);else for(e=0;s[t].length>e;e++){var f=a[r=s[t][e]];f||(a[r]=f={}),f[r]=!0}return n.pop(),h}function u(t,e){var i=[].concat(e).concat(t);r.push(i)}function h(e){!function(e){for(var i=0;t.length>i;i++)i>=e&&t[i]||(t[i]=[]),t[i]=t[i].filter(function(t){return t>=e})}(e);for(var i,r=function(t){for(var e=t.length,i=Array(e),r=Array(e),n=Array(e),o=Array(e),a=Array(e),s=Array(e),c=0;e>c;++c)i[c]=-1,r[c]=0,n[c]=!1,o[c]=0,a[c]=-1,s[c]=[];var l,u=0,h=[],f=[];function d(e){var c=[e],l=[e];for(i[e]=r[e]=u,n[e]=!0,u+=1;l.length>0;){var d=t[e=l[l.length-1]];if(d.length>o[e]){for(var y=o[e];d.length>y;++y){var g=d[y];if(0>i[g]){i[g]=r[g]=u,n[g]=!0,u+=1,c.push(g),l.push(g);break}n[g]&&(r[e]=0|Math.min(r[e],r[g])),0>a[g]||s[e].push(a[g])}o[e]=y}else{if(r[e]===i[e]){var p=[],m=[],x=0;for(y=c.length-1;y>=0;--y){var v=c[y];if(n[v]=!1,p.push(v),m.push(s[v]),x+=s[v].length,a[v]=h.length,v===e){c.length=y;break}}h.push(p);var k=Array(x);for(y=0;m.length>y;y++)for(var b=0;m[y].length>b;b++)k[--x]=m[y][b];f.push(k)}l.pop()}}}for(c=0;e>c;++c)0>i[c]&&d(c);for(c=0;f.length>c;c++){var y=f[c];if(0!==y.length){y.sort(function(t,e){return t-e}),l=[y[0]];for(var g=1;y.length>g;g++)y[g]!==y[g-1]&&l.push(y[g]);f[c]=l}}return{components:h,adjacencyList:f}}(t),n=r.components.filter(function(t){return t.length>1}),o=1/0,a=0;n.length>a;a++)for(var s=0;n[a].length>s;s++)o>n[a][s]&&(o=n[a][s],i=a);var c=n[i];if(!c)return!1;var l=t.map(function(t,e){return-1===c.indexOf(e)?[]:t.filter(function(t){return-1!==c.indexOf(t)})});return{leastVertex:o,adjList:l}}i=0;for(var f=t.length;f>i;){var d=h(i);if(i=d.leastVertex,s=d.adjList){for(var y=0;s.length>y;y++)for(var g=0;s[y].length>g;g++){var p=s[y][g];o[+p]=!1,a[p]={}}l(i),i+=1}else i=f}return r}function S(t){return t.y0-t.y1>0?"up":"down"}function A(t,e){return e(t.source)==e(t.target)}function L(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var i=0;return t.target.targetLinks.forEach(function(t){i=t.circular?i+1:i}),1>=e&&1>=i}function P(t){return t.target.x0-t.source.x1}function M(t,e){var i=D(t),r=P(e)/Math.tan(i);return"up"==S(t)?t.y1-r:t.y1+r}function _(t,e){var i=D(t),r=P(e)/Math.tan(i);return"up"==S(t)?t.y1+r:t.y1-r}function D(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function $(t,e){return e(t)}function W(t){return T(t.source)}function N(t){return T(t.target)}function T(t){return(t.y0+t.y1)/2}function R(t){return t.virtual?0:t.value}function z(t,e){var i=0;t.sourceLinks.forEach(function(t){i=t.circular&&!A(t,e)?i+1:i});var r=0;return t.targetLinks.forEach(function(t){r=t.circular&&!A(t,e)?r+1:r}),i+r}function O(t){return t.target.depth}function Y(t,e){return t.sourceLinks.length?t.depth:e-1}function B(t,e){return t.y0-e.y0}function X(t,e){return e.y0-t.y0}function C(t,e){return t.y1-e.y1}function j(t,e){return e.y1-t.y1}function I(t,e){return q(t.source,e.source)||t.index-e.index}function F(t,e){return q(t.target,e.target)||t.index-e.index}function q(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function H(t,e){return G(t)==G(e)?"bottom"==t.circularLinkType?X(t,e):B(t,e):G(e)-G(t)}function G(t){return t.target.column-t.source.column}function V(t,e){return Z(t)==Z(e)}function Z(t){return t.y0-t.y1>0?"up":"down"}function Q(t,e,r,n,o){let a=t;var s=Math.max(8,.15*(a.y1-a.y0));a.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,s))});var c=i.min(a.links,function(t){return t.source.y0});a.links.forEach(function(t){t.circular&&(t.circularPathData={})});var l=a.links.filter(function(t){return t.circular});return l.sort(function(t,e){return e.value-t.value}),l.forEach(function(t,e){t._circularStub=e>=4}),U(a.links.filter(function(t){return"top"==t.circularLinkType}),e,r),U(a.links.filter(function(t){return"bottom"==t.circularLinkType}),e,r),a.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+n,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,A(t,e)&&L(t))t.circularPathData.rightSmallArcRadius=n+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=n+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=n+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=n+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 i=t.source.column,s=t.circularLinkType,l=a.links.filter(function(t){return t.source.column==i&&t.circularLinkType==s});l.sort("bottom"==t.circularLinkType?X:B);var u=0;l.forEach(function(e,i){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=n+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=n+t._circularWidth/2+i*r+u),u+=e._circularWidth||e.width}),i=t.target.column,(l=a.links.filter(function(t){return t.target.column==i&&t.circularLinkType==s})).sort("bottom"==t.circularLinkType?j:C),u=0,l.forEach(function(e,i){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=n+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=n+t._circularWidth/2+i*r+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(a.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=c-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,i=t.y0,r=t.target.x0,n=t.y1,o=(e+r)/2;return"M"+e+","+i+"C"+o+","+i+" "+o+","+n+" "+r+","+n}(t)}),a}function U(t,e,i){t.sort(H);var r=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,n){var o=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(A(t,e)&&L(t))t.circularPathData.verticalBuffer=o+t._circularWidth/2;else{for(var a=0;r.length>a;a++){var s=r[a];if(s!==t&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&J(t,s)){var c=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+i;o=c>o?c:o}}t.circularPathData.verticalBuffer=o+t._circularWidth/2}}),t}function J(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function K(t){return function(){return t}}function tt(t){return t.index}function et(t){return t.nodes}function it(t){return t.links}function rt(t,e,r){var n=i.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});n.forEach(function(i){var o=i.length;i.sort(e||function(t,e){return t.circularLinkType==e.circularLinkType?z(e,r)-z(t,r):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0}),i.forEach(function(e,i){e.depth==n.length-1&&1==o||0==e.depth&&1==o?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==z(e,r)?(e.y0=t.y1/2+i,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+i,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-i,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/o*i,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-o/2+i,e.y1=e.y0+e.value*t.ky)})})}function nt(t,e,r,n,o,a){var s=i.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});h();for(var c=1,l=a;l>0;--l)u(c*=.99,r),h();function u(e,r){var n=s.length;s.forEach(function(o){var a=o.length,s=o[0].depth;o.forEach(function(o){var c;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&z(o,r)>0){var l=i.mean(o.sourceLinks,N),u=i.mean(o.targetLinks,W),h=l&&u?(l+u)/2:l||u;if(h){var f=(h-T(o))*e*.3;o.y0+=f,o.y1+=f}}else if(0==s&&1==a)o.y0=t.y1/2-(c=o.y1-o.y0)/2,o.y1=t.y1/2+c/2;else if(s==n-1&&1==a)o.y0=t.y1/2-(c=o.y1-o.y0)/2,o.y1=t.y1/2+c/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)c=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+c;else{var d=i.mean(o.sourceLinks,N),y=i.mean(o.targetLinks,W),g=((d&&y?(d+y)/2:d||y)-T(o))*e;o.y0+=g,o.y1+=g}})})}function h(){s.forEach(function(i){var r,a,s,c=t.y0,l=i.length;for(i.sort(e||q),s=0;l>s;++s)(a=c-(r=i[s]).y0)>0&&(r.y0+=a,r.y1+=a),c=r.y1+n;if((a=c-n-t.y1)>0)for(c=r.y0-=a,r.y1-=a,s=l-2;s>=0;--s)(a=(r=i[s]).y1+o-c)>0&&(r.y0-=a,r.y1-=a),c=r.y0})}}function ot(t){t.nodes.forEach(function(t){t.sourceLinks.sort(F),t.targetLinks.sort(I)}),t.nodes.forEach(function(t){var e=t.y0,i=e,r=t.y1,n=r;t.sourceLinks.forEach(function(t){t.circular?(t.y0=r-t.width/2,r-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=n-t.width/2,n-=t.width):(t.y1=i+t.width/2,i+=t.width)})})}function at(){var t=0,e=0,r=1,n=1,o=24,a=8,s=null,c=tt,l=Y,u=void 0,h=32,f=2,d=et,y=it;function g(){var g={nodes:d.apply(null,arguments),links:y.apply(null,arguments)};return function(d){d.x0=t,d.y0=e,d.x1=r,d.y1=n,d.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var r=function(t,e){var r=new Map;return i.group(t,e).forEach(function(t,e){r.set(e,t[0])}),r}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var i=t.source,n=t.target;"object"!=typeof i&&(i=t.source=w(r,i)),"object"!=typeof n&&(n=t.target=w(r,n)),i.sourceLinks.push(t),n.targetLinks.push(t)})}(d,c),function(t,e){var i=0;if(null==e){for(var r=[],n=0;t.links.length>n;n++){var o=t.links[n],a=o.source.index,s=o.target.index;r[a]||(r[a]=[]),r[s]||(r[s]=[]),-1===r[a].indexOf(s)&&r[a].push(s)}var c=E(r);c.sort(function(t,e){return t.length-e.length});var l={};for(n=0;c.length>n;n++){var u=c[n].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,r=t.source.index;e===r||l[r]&&l[r][e]?(t.circular=!0,t.circularLinkID=i++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=i++)})}(d,u),function(t,e){var i=0,r=0;t.links.forEach(function(n){n.circular&&(n.circularLinkType=n.source.circularLinkType||n.target.circularLinkType?n.source.circularLinkType?n.source.circularLinkType:n.target.circularLinkType:r>i?"top":"bottom","top"==n.circularLinkType?i++:r++,t.nodes.forEach(function(t){$(t,e)!=$(n.source,e)&&$(t,e)!=$(n.target,e)||(t.circularLinkType=n.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),A(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(d,c),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(i.sum(t.sourceLinks,R),i.sum(t.targetLinks,R)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(d),function(t,e,i){var r,n,o;if(null!=e){t.nodes.sort(function(t,i){return e(t)<e(i)?-1:1});var a=0,s=e(t.nodes[0]);t.nodes.forEach(function(t){a=e(t)==s?a:a+1,s=e(t)==s?s:e(t),t.column=a})}for(r=t.nodes,n=[],o=0;r.length;++o,r=n,n=[])r.forEach(function(t){t.depth=o,t.sourceLinks.forEach(function(t){0>n.indexOf(t.target)&&!t.circular&&n.push(t.target)})});for(r=t.nodes,n=[],o=0;r.length;++o,r=n,n=[])r.forEach(function(t){t.height=o,t.targetLinks.forEach(function(t){0>n.indexOf(t.source)&&!t.circular&&n.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?i(t,o):t.column})}(d,u,l);var y=a;if(null!==s){var g=i.groups(d.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=i.max(g,function(t){return t.length});p>1&&(y=Math.max(1,(n-e)*s/(p-1)))}(function(t,e,r){var n=i.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=i.min(n,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/i.sum(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var a=i.max(t.nodes,function(t){return t.column});t.nodes.forEach(a>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-r)/a),e.x1=e.x0+r}:function(e){e.x0=t.x0,e.x1=e.x0+r})})(d,y,o),rt(d,u,c),nt(d,u,c,y,y,h),ot(d),Q(d,c,f,10,8),rt(d,u,c),nt(d,u,c,y,y,h),ot(d),Q(d,c,f,10,8),function(t,e){let i=t;i.nodes.forEach(function(t){t.y+(t.y1-t.y0)>i.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-i.y1));var r=i.links.filter(function(i){return $(i.source,e)==$(t,e)}),n=r.length;n>1&&r.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!V(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var i=M(e,t);return t.y1-i}if(e.target.column>t.target.column)return M(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 o=t.y0;r.forEach(function(t){t.y0=o+t.width/2,o+=t.width}),r.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var o=i+1,a=0;n>o;o++)a+=r[o].width;e.y0=t.y1-a-e.width/2}})})}(d,c),function(t,e){let i=t;i.nodes.forEach(function(t){var r=i.links.filter(function(i){return $(i.target,e)==$(t,e)}),n=r.length;n>1&&r.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!V(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var i=_(e,t);return t.y0-i}if(e.source.column>t.source.column)return _(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 o=t.y0;r.forEach(function(t){t.y1=o+t.width/2,o+=t.width}),r.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var o=i+1,a=0;n>o;o++)a+=r[o].width;e.y1=t.y1-a-e.width/2}})})}(d,c),function(t){var e=t.nodes,r=t.links,n=!1,o=!1;if(r.forEach(function(t){"top"==t.circularLinkType?n=!0:"bottom"==t.circularLinkType&&(o=!0)}),0==n||0==o){var a=i.min(e,function(t){return t.y0}),s=i.max(e,function(t){return t.y1}),c=(t.y1-t.y0)/(s-a);function l(e){return(e-a)/(s-a)*(t.y1-t.y0)+t.y0}1>c?(e.forEach(function(t){t.y0=l(t.y0),t.y1=l(t.y1)}),r.forEach(function(t){t.y0=l(t.y0),t.y1=l(t.y1),t.width=t.width*c})):e.forEach(function(t){var e=t.y1-t.y0,i=l(t.y0)-t.y0;t.y0=l(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+i}),t.targetLinks.forEach(function(t){t.y1=t.y1+i})})}}(d),Q(d,c,f,10,8)}(g),g}return g.update=function(t){return ot(t),Q(t,c,f,10,8),t},g.nodeWidth=function(t){return arguments.length?(o=+t,g):o},g.nodePadding=function(t){return arguments.length?(a=+t,g):a},g.nodePaddingRatio=function(t){return arguments.length?(s=+t,g):s},g.nodes=function(t){return arguments.length?(d="function"==typeof t?t:K(t),g):d},g.links=function(t){return arguments.length?(y="function"==typeof t?t:K(t),g):y},g.nodeId=function(t){return arguments.length?(c="function"==typeof t?t:K(t),g):c},g.nodeAlign=function(t){return arguments.length?(l="function"==typeof t?t:K(t),g):l},g.nodeSort=function(t){return arguments.length?(u=t,g):u},g.iterations=function(t){return arguments.length?(h=+t,g):h},g.circularLinkGap=function(t){return arguments.length?(f=+t,g):f},g.extent=function(i){return arguments.length?(t=+i[0][0],e=+i[0][1],r=+i[1][0],n=+i[1][1],g):[[t,e],[r,n]]},g.size=function(i){return arguments.length?(t=e=0,r=+i[0],n=+i[1],g):[r-t,n-e]},g}const st=t=>{let e,i,r,o,a,s,c,l,u;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,i=t.y1-t.sankeyWidth/2,r=t.y1+t.sankeyWidth/2,o=t.y0+t.sankeyWidth/2,a=t.source.y1,s=t.target.y0,c=n.interpolateNumber(a,s),l=c(.5),u=c(.5),`M${e},${a}C${e},${l} ${i},${u} ${i},${s}L${r},${s}C${r},${u} ${o},${l} ${o},${a}Z`):(e=t.source.x1,i=t.target.x0,c=n.interpolateNumber(e,i),r=c(.5),o=c(.5),a=t.y0-t.sankeyWidth/2,s=t.y1-t.sankeyWidth/2,l=t.y1+t.sankeyWidth/2,u=t.y0+t.sankeyWidth/2,`M${e},${a}C${r},${a} ${o},${s} ${i},${s}L${i},${l}C${o},${l} ${r},${u} ${e},${u}Z`)};function ct(t){var e;const i=t.sankeyWidth/2,r=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,n=t.circularPathData;if(!n)return null;if("down"===t.direction)return null;if(t._circularStub){const e=n.sourceX,r=n.sourceY,o=n.targetX,a=n.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const s=Math.max(15,Math.min(40,.33*(n.rightFullExtent-e))),c=Math.max(15,Math.min(40,.33*(o-n.leftFullExtent)));return`M${e},${r-i}L${e+s},${r-i}L${e+s},${r+i}L${e},${r+i}ZM${o},${a-i}L${o-c},${a-i}L${o-c},${a+i}L${o},${a+i}Z`}const o=n.sourceX,a=n.sourceY,s=n.targetX,c=n.targetY,l=n.rightFullExtent,u=n.leftFullExtent,h=n.verticalFullExtent,f="bottom"===t.circularLinkType?1:-1,d=Math.max(4,Math.min(r,15));return`M${o},${a-f*i}L${l},${a-f*i}L${l+r},${a-f*i+f*d}L${l+r},${h+f*r-f*d}L${l+r-d},${h+f*r}L${u-r+d},${h+f*r}L${u-r},${h+f*r-f*d}L${u-r},${c-f*i+f*d}L${u-r+d},${c-f*i}L${s},${c-f*i}L${s},${c+f*i}L${u+r},${c+f*i}L${u+r},${h-f*r}L${l-r},${h-f*r}L${l-r},${a+f*i}L${o},${a+f*i}Z`}const lt={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(O))-1:0},justify:Y},ut={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,r){var n,o,a,s,c,l,u;if(0===t.length)return;const h="vertical"===i.orientation?"down":"right",f=i.nodeAlign||"justify",d=null!==(n=i.nodeWidth)&&void 0!==n?n:15,y=null!==(o=i.nodePaddingRatio)&&void 0!==o?o:.05,g=null!==(a=i.iterations)&&void 0!==a?a:100,p=t.map(t=>Object.assign({},t)),m=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 x;x="down"===h?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const v=at().extent(x).links(m).nodes(p).nodeAlign(lt[f]||Y).nodeId(t=>t.id).nodeWidth(d).iterations(g);v.nodePaddingRatio&&v.nodePaddingRatio(y),v();{let t=1/0,e=-1/0,i=1/0,n=-1/0;for(const r of p)t>r.x0&&(t=r.x0),r.x1>e&&(e=r.x1),i>r.y0&&(i=r.y0),r.y1>n&&(n=r.y1);for(const r of m){if(!r.circular||!r.circularPathData)continue;const o=r.circularPathData,a=(null!==(c=null!==(s=r._circularWidth)&&void 0!==s?s:r.width)&&void 0!==c?c:0)/2;t>o.leftFullExtent-a&&(t=o.leftFullExtent-a),o.rightFullExtent+a>e&&(e=o.rightFullExtent+a),i>o.verticalFullExtent-a&&(i=o.verticalFullExtent-a),o.verticalFullExtent+a>n&&(n=o.verticalFullExtent+a)}const o=e-t,a=n-i,u=r[0],h=r[1];if(o>0&&a>0&&(0>t||0>i||e>u||n>h)){const e=Math.min(u/o,h/a),r=-t*e+(u-o*e)/2,n=-i*e+(h-a*e)/2;for(const t of p)t.x0=t.x0*e+r,t.x1=t.x1*e+r,t.y0=t.y0*e+n,t.y1=t.y1*e+n;for(const t of m)if(t.y0=t.y0*e+n,t.y1=t.y1*e+n,t.width=(null!==(l=t.width)&&void 0!==l?l:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const i=t.circularPathData;i.sourceX=i.sourceX*e+r,i.targetX=i.targetX*e+r,i.sourceY=i.sourceY*e+n,i.targetY=i.targetY*e+n,i.rightFullExtent=i.rightFullExtent*e+r,i.leftFullExtent=i.leftFullExtent*e+r,i.verticalFullExtent=i.verticalFullExtent*e+n,i.rightInnerExtent=i.rightInnerExtent*e+r,i.leftInnerExtent=i.leftInnerExtent*e+r,i.verticalRightInnerExtent=i.verticalRightInnerExtent*e+n,i.verticalLeftInnerExtent=i.verticalLeftInnerExtent*e+n,i.rightSmallArcRadius*=e,i.rightLargeArcRadius*=e,i.leftSmallArcRadius*=e,i.leftLargeArcRadius*=e,i.sourceWidth*=e,i.rightNodeBuffer*=e,i.leftNodeBuffer*=e,i.arcRadius*=e}}}const k=new Map;for(const e of t)k.set(e.id,e);for(const t of p){const e=k.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 b=new Map;for(const t of e)b.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of m){const e=t.source,i=t.target,r="object"==typeof e&&null!==e?e.id:e+"",n="object"==typeof i&&null!==i?i.id:i+"",o=b.get(`${r}\0${n}`);if(o){o.y0=t.y0,o.y1=t.y1,o.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,o.circular=!!t.circular,o.circularPathData=t.circularPathData,o._circularWidth=t._circularWidth,o._circularStub=t._circularStub,o.path=t.path,o.circularLinkType=t.circularLinkType,o.direction=h;const e=k.get(r),i=k.get(n);e&&(o.source=e),i&&(o.target=i)}}},buildScene(t,e,i,n){var o,a,s,c;const l="vertical"===i.orientation?"down":"right",u=i.nodeStyle,h=i.edgeStyle,f=null!==(o=i.edgeOpacity)&&void 0!==o?o:.5,d=i.edgeColorBy||"source",y=Array.isArray(i.colorScheme)?i.colorScheme:r.schemeCategory10,g=new Map;t.forEach((t,e)=>{g.set(t.id,y[e%y.length])});const p=[],m=[],x=[];for(const e of t){const t=e.x1-e.x0,i=e.y1-e.y0;if(0>=t||0>=i)continue;const r=u?u(e):{},n={fill:r.fill||g.get(e.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};p.push({type:"rect",x:e.x0,y:e.y0,w:t,h:i,style:n,datum:e,id:e.id,label:e.id})}const v=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of v){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 r="#999";h?r=h(t).fill||r:"target"===d&&i?r=g.get(i.id)||r:e&&(r=g.get(e.id)||r);const n=h?h(t):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,i=t.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),c=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),l=n.fill||r;m.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-i}L${e.sourceX+o},${e.sourceY-i}L${e.sourceX+o},${e.sourceY+i}L${e.sourceX},${e.sourceY+i}Z`,style:{fill:l,fillOpacity:null!==(a=n.fillOpacity)&&void 0!==a?a:f,stroke:"none",opacity:n.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+o}}),m.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-i}L${e.targetX-c},${e.targetY-i}L${e.targetX-c},${e.targetY+i}L${e.targetX},${e.targetY+i}Z`,style:{fill:l,fillOpacity:null!==(s=n.fillOpacity)&&void 0!==s?s:f,stroke:"none",opacity:n.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-c,x1:e.targetX}});continue}let o;if(o=t.circular&&t.circularPathData?ct(t):st(t),!o)continue;const l={fill:n.fill||r,fillOpacity:null!==(c=n.fillOpacity)&&void 0!==c?c:f,stroke:n.stroke||"none",strokeWidth:n.strokeWidth,opacity:n.opacity};m.push({type:"bezier",pathD:o,bezierCache:t.bezier,style:l,datum:t})}if(!1!==i.showLabels){const e=(k=i.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null;for(const i of t){const t=i.x1-i.x0,r=i.y1-i.y0;if(0>=t||0>=r)continue;const o=e?e(i):i.id;if(!o)continue;let a,s,c;"down"===l?(a=i.x0+t/2,s=i.y1+14,c="middle"):(n[0]/2>i.x0+t/2?(a=i.x0-6,c="end"):(a=i.x1+6,c="start"),s=i.y0+r/2),x.push({x:a,y:s,text:o+"",anchor:c,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:p,sceneEdges:m,labels:x}}},ht={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,i,r){var n,a;if(0===t.length)return;const s=null!==(n=i.iterations)&&void 0!==n?n:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),c=null!==(a=i.forceStrength)&&void 0!==a?a:.1,l=r[0]/2,u=r[1]/2;for(let e=0;t.length>e;e++){const i=t[e];if(null==i.x||null==i.y||0===i.x&&0===i.y){const t=10*Math.sqrt(e+.5),r=2.399963229728653*e;i.x=l+t*Math.cos(r),i.y=u+t*Math.sin(r)}}const h=ft(i.nodeSize,i.nodeSizeRange,t),f=o.forceLink().strength(t=>Math.min(2.5,t.weight?t.weight*c:c)).id(t=>t.id),d=r[1]/r[0],y=o.forceSimulation().force("charge",o.forceManyBody().strength(t=>-25*(t=>h(t))(t))).force("x",o.forceX(r[0]/2).strength(.1*d)).force("y",o.forceY(r[1]/2).strength(.1));if(y.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}));y.force("link",f),y.force("link").links(t)}.1>y.alpha()&&y.alpha(1),y.stop();for(let t=0;s>t;++t)y.tick();const g=new Map;for(const e of t)g.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=g.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=g.get(t.target);e&&(t.target=e)}}},buildScene(t,e,i,n){var o,a,s;const c=i.nodeStyle,l=i.edgeStyle,u=ft(i.nodeSize,i.nodeSizeRange,t),h=Array.isArray(i.colorScheme)?i.colorScheme:r.schemeCategory10,f=new Map;t.forEach((t,e)=>{f.set(t.id,h[e%h.length])});const d=[],y=[],g=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=u(e),i=c?c(e):{},r={fill:i.fill||f.get(e.id)||"#007bff",stroke:i.stroke||"#fff",strokeWidth:null!==(o=i.strokeWidth)&&void 0!==o?o:2,opacity:i.opacity};d.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id})}const p=new Map;for(const e of t)p.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:p.get(t.source),i="object"==typeof t.target?t.target:p.get(t.target);if(!e||!i)continue;if(null==e.x||null==e.y)continue;if(null==i.x||null==i.y)continue;const r=l?l(t):{},n={stroke:r.stroke||"#999",strokeWidth:null!==(a=r.strokeWidth)&&void 0!==a?a:1,opacity:null!==(s=r.opacity)&&void 0!==s?s:.6};y.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:n,datum:t})}if(!1!==i.showLabels){const e=(m=i.nodeLabel)?"function"==typeof m?m:t=>t[m]||t.id:null;for(const i of t){if(null==i.x||null==i.y)continue;const t=e?e(i):i.id;if(!t)continue;const r=u(i);g.push({x:i.x,y:i.y-r-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var m;return{sceneNodes:d,sceneEdges:y,labels:g}}};function ft(t,r,n){var o,a;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const s=r||[5,20],c=n.map(e=>{var i;return null===(i=e.data)||void 0===i?void 0:i[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===c.length)return()=>s[0];const l=null!==(o=i.min(c))&&void 0!==o?o:0,u=null!==(a=i.max(c))&&void 0!==a?a:1;if(l===u)return()=>(s[0]+s[1])/2;const h=e.scaleLinear().domain([l,u]).range(s).clamp(!0);return e=>{var i;const r=null===(i=e.data)||void 0===i?void 0:i[t];return null==r||"number"!=typeof r?s[0]:h(r)}}const dt=r.schemeCategory10,yt={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,i,r){if(0===t.length)return;const{padAngle:n=.01,groupWidth:o=20,sortGroups:c}=i,l=Math.min(r[0],r[1])/2,u=l-o,h=r[0]/2,f=r[1]/2,d=(y=i.valueAccessor)?"function"==typeof y?y:t=>{var e;return null!==(e=t[y])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var y;const g=new Map;for(let e=0;t.length>e;e++)g.set(t[e].id,e);const p=t.length,m=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,i=g.get("string"==typeof t.source?t.source:t.source.id),r=g.get(e);if(void 0===i||void 0===r)continue;const n=d(t);m[i][r]=n}const x=a.chord().padAngle(n);c&&x.sortGroups(c);const v=x(m),k=v.groups,b=s.arc().innerRadius(u).outerRadius(l);for(const e of k){const i=t[e.index],r=b.centroid(e);i.x=r[0]+h,i.y=r[1]+f,i.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,i=w.get("string"==typeof t.source?t.source:t.source.id),r=w.get(e);i&&(t.source=i),r&&(t.target=r)}const E=new Map;for(const t of e)E.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 v){const i=t[e.source.index].id,r=t[e.target.index].id,n=E.get(`${i}\0${r}`)||E.get(`${r}\0${i}`);n&&(n.chordData=e)}},buildScene(t,e,i,r){var n,o;const{groupWidth:s=20,edgeOpacity:c=.5}=i,l=Math.min(r[0],r[1])/2,u=l-s,h=r[0]/2,f=r[1]/2,d=i.nodeStyle,y=i.edgeStyle,g=i.edgeColorBy||"source",p=Array.isArray(i.colorScheme)?i.colorScheme:dt,m=new Map;t.forEach((t,e)=>{m.set(t.id,p[e%p.length])});const x=a.ribbon().radius(u),v=[],k=[],b=[];for(let e=0;t.length>e;e++){const i=t[e],r=i.arcData;if(!r)continue;let o;o=d?d(i).fill||m.get(i.id)||p[e%p.length]:m.get(i.id)||p[e%p.length];const a=d?d(i):{},s={fill:o,stroke:a.stroke||"black",strokeWidth:null!==(n=a.strokeWidth)&&void 0!==n?n:1,opacity:a.opacity};v.push({type:"arc",cx:h,cy:f,innerR:u,outerR:l,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:s,datum:i,id:i.id,label:i.id})}for(const t of e){const e=t.chordData;if(!e)continue;const i=x(e);if(!i)continue;const r=gt(i,h,f);let n="#999";if(y)n=y(t).fill||n;else{const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;"target"===g&&i?n=m.get(i.id)||n:e&&(n=m.get(e.id)||n)}const a=y?y(t):{},s={fill:n,fillOpacity:null!==(o=a.fillOpacity)&&void 0!==o?o:c,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};k.push({type:"ribbon",pathD:r,style:s,datum:t})}if(!1!==i.showLabels){const e=(w=i.nodeLabel)?"function"==typeof w?w:t=>t[w]||t.id:null,r=l+12;for(const i of t){const t=i.arcData;if(!t)continue;const n=e?e(i):i.id;if(!n)continue;const o=(t.startAngle+t.endAngle)/2,a=o-Math.PI/2;b.push({x:h+Math.cos(a)*r,y:f+Math.sin(a)*r,text:n+"",anchor:o>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:v,sceneEdges:k,labels:b}}};function gt(t,e,i){const r=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return t;const n=[];let o=0;for(;r.length>o;){const t=r[o];if("M"===t||"L"===t)for(n.push(t),o++;r.length>o&&!isNaN(Number(r[o]));)n.push(Number(r[o])+e+""),o++,r.length>o&&!isNaN(Number(r[o]))&&(n.push(Number(r[o])+i+""),o++);else if("C"===t)for(n.push(t),o++;r.length>o&&!isNaN(Number(r[o]));)for(let t=0;3>t&&r.length>o&&!isNaN(Number(r[o]));t++)n.push(Number(r[o])+e+""),o++,r.length>o&&!isNaN(Number(r[o]))&&(n.push(Number(r[o])+i+""),o++);else if("Q"===t)for(n.push(t),o++;r.length>o&&!isNaN(Number(r[o]));)for(let t=0;2>t&&r.length>o&&!isNaN(Number(r[o]));t++)n.push(Number(r[o])+e+""),o++,r.length>o&&!isNaN(Number(r[o]))&&(n.push(Number(r[o])+i+""),o++);else if("A"===t)for(n.push(t),o++;r.length>o&&!isNaN(Number(r[o]));)n.push(r[o++]),r.length>o&&n.push(r[o++]),r.length>o&&n.push(r[o++]),r.length>o&&n.push(r[o++]),r.length>o&&n.push(r[o++]),r.length>o&&(n.push(Number(r[o])+e+""),o++),r.length>o&&(n.push(Number(r[o])+i+""),o++);else"Z"===t||"z"===t?(n.push(t),o++):(n.push(r[o]),o++)}return n.join(" ")}const pt={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,i,r){var n;const o=i.__hierarchyRoot;if(!o)return;const a=i.chartType,s=(l=i.childrenAccessor)?"function"==typeof l?l:t=>t[l]:void 0;var l;const u=i.hierarchySum||(t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0}),h=c.hierarchy(o,s);h.sum(u),h.sort((t,e)=>{var i,r;return(null!==(i=e.value)&&void 0!==i?i:0)-(null!==(r=t.value)&&void 0!==r?r:0)});const[f,d]=r;switch(a){case"tree":!function(t,e,i,r){const n=e.treeOrientation||"vertical",o=c.tree();o.size("horizontal"===n?[r,i]:"radial"===n?[2*Math.PI,Math.min(i,r)/2*.8]:[i,r]),o(t)}(h,i,f,d);break;case"cluster":!function(t,e,i,r){const n=e.treeOrientation||"vertical",o=c.cluster();o.size("horizontal"===n?[r,i]:"radial"===n?[2*Math.PI,Math.min(i,r)/2*.8]:[i,r]),o(t)}(h,i,f,d);break;case"treemap":!function(t,e,i,r){var n,o;const a=null!==(n=e.padding)&&void 0!==n?n:4,s=null!==(o=e.paddingTop)&&void 0!==o?o:0,l=c.treemap().size([i,r]).tile(c.treemapBinary).padding(a);s>0&&l.paddingTop(s),l(t)}(h,i,f,d);break;case"circlepack":!function(t,e,i,r){var n;const o=null!==(n=e.padding)&&void 0!==n?n:4;c.pack().size([i,r]).padding(o)(t)}(h,i,f,d);break;case"partition":!function(t,e,i,r){var n;c.partition().size([i,r]).padding(null!==(n=e.padding)&&void 0!==n?n:1)(t)}(h,i,f,d)}const y=h.descendants();t.length=0,e.length=0;const g=new Map;for(let e=0;y.length>e;e++){const r=y[e],o={id:bt(r,i,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(n=r.value)&&void 0!==n?n:0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===a||"cluster"===a?mt(o,r,i):"treemap"===a||"partition"===a?xt(o,r):"circlepack"===a&&vt(o,r),o.__hierarchyNode=r,t.push(o),g.set(r,o)}if("tree"===a||"cluster"===a)for(const t of y)if(t.parent){const i=g.get(t.parent),r=g.get(t);i&&r&&e.push({source:i,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,i,r){const n=i.nodeStyle||(()=>({})),o=i.edgeStyle||(()=>({}));switch(i.chartType){case"tree":case"cluster":return function(t,e,i,r,n,o){var a,s,c,l,u;const h=[],f=[],d=[],y=i.treeOrientation||"vertical",g="radial"===y,p=r[0]/2,m=r[1]/2,x="number"==typeof(k=i.nodeSize)?k:5,v=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];var k;for(const e of t){let t=e.x,r=e.y;g&&(t+=p,r+=m);const o=n(e);let s=o.fill||"#4d430c";i.colorByDepth&&void 0!==e.depth&&(s=v[e.depth%v.length]);const c={fill:s,stroke:o.stroke||"#fff",strokeWidth:null!==(a=o.strokeWidth)&&void 0!==a?a:1,opacity:o.opacity};h.push({type:"circle",cx:t,cy:r,r:x,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const b=null!==(s=i.edgeOpacity)&&void 0!==s?s:.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 r=e.x,n=e.y,a=i.x,s=i.y;g&&(r+=p,n+=m,a+=p,s+=m);const u=kt(r,n,a,s,y),h=o(t),d={fill:"none",stroke:h.stroke||"#999",strokeWidth:null!==(c=h.strokeWidth)&&void 0!==c?c:1.5,opacity:null!==(l=h.opacity)&&void 0!==l?l:b};f.push({type:"curved",pathD:u,style:d,datum:t})}if(!1!==i.showLabels){const e=wt(i.nodeLabel);for(const i of t){const t=e?e(i):i.id;if(!t)continue;let r,n,o,a=i.x,s=i.y;if(g&&(a+=p,s+=m),g){const t=a-p,e=s-m,i=Math.sqrt(t*t+e*e);i>0?(r=a+t/i*10,n=s+e/i*10,o=0>t?"end":"start"):(r=a,n=s-12,o="middle")}else"horizontal"===y?((null===(u=i.data)||void 0===u?void 0:u.children)&&0!==i.data.children.length?(r=a-x-6,o="end"):(r=a+x+6,o="start"),n=s):(r=a,n=s+x+14,o="middle");d.push({x:r,y:n,text:t+"",anchor:o,baseline:"middle",fontSize:11})}}return{sceneNodes:h,sceneEdges:f,labels:d}}(t,e,i,r,n,o);case"treemap":case"partition":return function(t,e,i,r){var n,o;const a=[],s=[],c=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const i of t){const t=i.x1-i.x0,o=i.y1-i.y0;if(0>=t||0>=o)continue;const s=r(i);let l=s.fill||"#4d430c";e.colorByDepth&&void 0!==i.depth&&(l=c[i.depth%c.length]);const u={fill:l,stroke:s.stroke||"#fff",strokeWidth:null!==(n=s.strokeWidth)&&void 0!==n?n:1,opacity:s.opacity};a.push({type:"rect",x:i.x0,y:i.y0,w:t,h:o,style:u,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=wt(e.nodeLabel);for(const r of t){const t=r.x1-r.x0,n=r.y1-r.y0;if(0>=t||0>=n)continue;if((null===(o=r.data)||void 0===o?void 0:o.children)&&r.data.children.length>0&&"partition"!==e.chartType)continue;const a=i?i(r):r.id;a&&(30>t||16>n||s.push({x:r.x0+t/2,y:r.y0+n/2,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,n)/6))}))}}return{sceneNodes:a,sceneEdges:[],labels:s}}(t,i,0,n);case"circlepack":return function(t,e,i,r){var n,o,a,s,c;const l=[],u=[],h=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const i of t){const t=null!==(n=i.__radius)&&void 0!==n?n:5;if(0>=t)continue;const s=r(i);let c=s.fill||"#4d430c";e.colorByDepth&&void 0!==i.depth&&(c=h[i.depth%h.length]);const u={fill:c,stroke:s.stroke||"#fff",strokeWidth:null!==(o=s.strokeWidth)&&void 0!==o?o:1,opacity:null!==(a=s.opacity)&&void 0!==a?a:.7};l.push({type:"circle",cx:i.x,cy:i.y,r:t,style:u,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=wt(e.nodeLabel);for(const e of t){const t=null!==(s=e.__radius)&&void 0!==s?s:5,r=i?i(e):e.id;if(!r)continue;if(15>t)continue;const n=!((null===(c=e.data)||void 0===c?void 0:c.children)&&e.data.children.length>0);u.push({x:e.x,y:n?e.y:e.y-t+14,text:r+"",anchor:"middle",baseline:n?"middle":"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:n?void 0:"#000",stroke:n?void 0:"#fff",strokeWidth:n?void 0:3,paintOrder:n?void 0:"stroke"})}}return{sceneNodes:l,sceneEdges:[],labels:u}}(t,i,0,n);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function mt(t,e,i){const r=i.treeOrientation||"vertical";if("radial"===r){const i=e.x,r=e.y;t.x=r*Math.cos(i-Math.PI/2),t.y=r*Math.sin(i-Math.PI/2)}else"horizontal"===r?(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 xt(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 vt(t,e){var i;const r=null!==(i=e.r)&&void 0!==i?i:0;t.x=e.x,t.y=e.y,t.x0=e.x-r,t.x1=e.x+r,t.y0=e.y-r,t.y1=e.y+r,t.width=2*r,t.height=2*r,t.__radius=r}function kt(t,e,i,r,n){if("horizontal"===n){const n=(t+i)/2;return`M ${t},${e} C ${n},${e} ${n},${r} ${i},${r}`}if("radial"===n){const n=(t+i)/2;return`M ${t},${e} Q ${n},${e} ${n},${(e+r)/2} T ${i},${r}`}{const n=(e+r)/2;return`M ${t},${e} C ${t},${n} ${i},${n} ${i},${r}`}}function bt(t,e,i){const r=e.nodeIDAccessor;return"function"==typeof r?r(t.data)+"":"string"==typeof r&&void 0!==t.data[r]?t.data[r]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+i}function wt(t){return t?"function"==typeof t?t:e=>{var i;return(null===(i=e.data)||void 0===i?void 0:i[t])||e[t]||e.id}:null}const Et={sankey:ut,force:ht,chord:yt,tree:pt,cluster:pt,treemap:pt,circlepack:pt,partition:pt};function St(t,e){const{columns:i,config:r,resolvePieceStyle:n}=t,o=[],a=Math.min(e.width,e.height)/2-4,s="donut"===r.chartType?r.innerRadius||60:0,c=-Math.PI/2+(r.startAngle||0)*Math.PI/180,l=2*Math.PI;for(const t of Object.values(i)){const e=c+t.pctStart*l,i=c+(t.pctStart+t.pct)*l,r=n(t.pieceData[0],t.name);o.push({type:"wedge",cx:0,cy:0,innerRadius:s,outerRadius:a,startAngle:e,endAngle:i,style:r,datum:t.pieceData,category:t.name})}return o}function At(t){var e,r,n;const o=t.length,a=t[0],s=t[o-1];return{n:o,min:a,q1:null!==(e=i.quantile(t,.25))&&void 0!==e?e:a,median:null!==(r=i.quantile(t,.5))&&void 0!==r?r:(a+s)/2,q3:null!==(n=i.quantile(t,.75))&&void 0!==n?n:s,max:s,mean:t.reduce((t,e)=>t+e,0)/o}}const Lt={bar:function(t,e){const{scales:i,columns:r,config:n,getR:o,getStack:a,resolvePieceStyle:s}=t,{r:c,projection:l}=i,u=[],h="vertical"===l,f="horizontal"===l,d=n.normalize;for(const t of Object.values(r)){const e=new Map;for(const i of t.pieceData){const t=a?a(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const r=e.get(t);r.total+=o(i),r.pieces.push(i)}let i=0;if(d)for(const t of e.values())i+=Math.abs(t.total);let r=0,n=0;for(const[o,l]of e){let e=l.total;d&&i>0&&(e/=i);const y=s(l.pieces[0],a?o:t.name),g=Object.assign(Object.assign({},l.pieces[0]),{__aggregateValue:l.total,__pieceCount:l.pieces.length,category:t.name});if(h){const i=c(0>e?n:r+e),a=0>e?c(n+e)-c(n):c(r)-c(r+e);u.push(m(t.x,i,t.width,Math.abs(a),y,g,o)),0>e?n+=e:r+=e}else if(f){const i=c(0>e?n+e:r),a=0>e?c(n)-c(n+e):c(r+e)-c(r);u.push(m(i,t.x,Math.abs(a),t.width,y,g,o)),0>e?n+=e:r+=e}}}return u},clusterbar:function(t,e){const{scales:i,columns:r,getR:n,getGroup:o,resolvePieceStyle:a}=t,{r:s,projection:c}=i,l=[],u="vertical"===c,h=[],f=new Set;for(const t of Object.values(r))for(const e of t.pieceData){const t=o?o(e):"_default";f.has(t)||(f.add(t),h.push(t))}const d=h.length||1;for(const t of Object.values(r)){const e=t.width/d,i=new Map;for(const e of t.pieceData){const t=o?o(e):"_default";i.has(t)||i.set(t,[]),i.get(t).push(e)}for(let r=0;h.length>r;r++){const o=i.get(h[r])||[];for(const i of o){const o=n(i),c=a(i,t.name);if(u){const n=t.x+r*e,a=s(0),u=s(o);l.push(m(n,Math.min(a,u),e,Math.abs(a-u),c,i,h[r]))}else{const n=t.x+r*e,a=s(0),u=s(o);l.push(m(Math.min(a,u),n,Math.abs(u-a),e,c,i,h[r]))}}}}return l},point:function(t,e){var i,r;const{scales:n,columns:o,getR:a,multiScales:s,resolvePieceStyle:c}=t,{r:l,projection:u}=n,h=[],f="vertical"===u,d="radial"===u,y=s.length>0,g=2*Math.PI,p=-Math.PI/2;for(const t of Object.values(o))for(const e of t.pieceData){const n=null!==(i=e.__rIndex)&&void 0!==i?i:0,o=null!==(r=e.__rValue)&&void 0!==r?r:a(e),u=y&&s[n]||l,m=c(e,t.name),x=m.r||5;let v,k;if(d){const e=p+(t.pctStart+t.pct/2)*g,i=u(o);v=Math.cos(e)*i,k=Math.sin(e)*i}else f?(v=t.middle,k=u(o)):(v=u(o),k=t.middle);h.push({type:"point",x:v,y:k,r:x,style:m,datum:e})}return h},swarm:function(t,e){const{scales:i,columns:r,getR:n,resolvePieceStyle:o}=t,{r:a,projection:s}=i,c=[],l="vertical"===s;for(const t of Object.values(r)){const e=t.width/2;for(let i=0;t.pieceData.length>i;i++){const r=t.pieceData[i],s=n(r),u=o(r,t.name),h=u.r||4,f=(7919*i%100/100-.5)*e*.8,d=l?t.middle+f:a(s),y=l?a(s):t.middle+f;c.push({type:"point",x:d,y:y,r:h,style:u,datum:r})}}return c},pie:St,donut:St,boxplot:function(t,e){var r,n,o,a,s;const{scales:c,columns:l,config:u,getR:h,resolveSummaryStyle:f}=t,{r:d,projection:y}=c,g=[],p="vertical"===y,m=!1!==u.showOutliers;for(const t of Object.values(l)){const e=t.pieceData.map(t=>h(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===e.length)continue;const c=e[0],l=e[e.length-1],u=null!==(r=i.quantile(e,.25))&&void 0!==r?r:c,y=null!==(n=i.quantile(e,.5))&&void 0!==n?n:(c+l)/2,x=null!==(o=i.quantile(e,.75))&&void 0!==o?o:l,v=x-u,k=u-1.5*v,b=x+1.5*v,w=null!==(a=e.find(t=>t>=k))&&void 0!==a?a:c,E=null!==(s=[...e].reverse().find(t=>b>=t))&&void 0!==s?s:l,S=f(t.pieceData[0],t.name),A=[];if(m)for(const e of t.pieceData){const i=h(e);if(k>i||i>b){const r=p?t.middle:d(i),n=p?d(i):t.middle;A.push({px:r,py:n,value:i,datum:e})}}if(g.push({type:"boxplot",x:p?t.middle:0,y:p?0:t.middle,projection:p?"vertical":"horizontal",columnWidth:.6*t.width,minPos:d(w),q1Pos:d(u),medianPos:d(y),q3Pos:d(x),maxPos:d(E),stats:{n:e.length,min:w,q1:u,median:y,q3:x,max:E,mean:e.reduce((t,e)=>t+e,0)/e.length},style:S,datum:t.pieceData,category:t.name,outliers:A}),m)for(const t of A)g.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:S.fill||"#999",opacity:.6},datum:t.datum})}return g},violin:function(t,e){var r,n,o;const{scales:a,columns:s,config:c,getR:l,resolveSummaryStyle:u}=t,{r:h,projection:f}=a,d=[],y="vertical"===f,g=c.bins||20,p=!1!==c.showIQR;for(const t of Object.values(s)){const e=t.pieceData.map(t=>l(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const a=e[0],s=e[e.length-1],c=(s-a)/g||1,f=Array(g).fill(0);for(const t of e)f[Math.min(Math.floor((t-a)/c),g-1)]++;const m=Math.max(...f,1),x=t.width/2*.9;let v="";if(y){for(let e=0;g>e;e++){const i=h(a+(e+.5)*c),r=f[e]/m*x;v+=0===e?`M ${t.middle+r} ${i}`:` L ${t.middle+r} ${i}`}for(let e=g-1;e>=0;e--){const i=h(a+(e+.5)*c);v+=` L ${t.middle-f[e]/m*x} ${i}`}v+=" Z"}else{for(let e=0;g>e;e++){const i=h(a+(e+.5)*c),r=f[e]/m*x;v+=0===e?`M ${i} ${t.middle-r}`:` L ${i} ${t.middle-r}`}for(let e=g-1;e>=0;e--)v+=` L ${h(a+(e+.5)*c)} ${t.middle+f[e]/m*x}`;v+=" Z"}const k=u(t.pieceData[0],t.name);let b;if(p&&e.length>=4){const c=null!==(r=i.quantile(e,.25))&&void 0!==r?r:a,l=null!==(n=i.quantile(e,.5))&&void 0!==n?n:(a+s)/2,u=null!==(o=i.quantile(e,.75))&&void 0!==o?o:s;b={q1Pos:h(c),medianPos:h(l),q3Pos:h(u),centerPos:t.middle,isVertical:y}}const w=y?{x:t.x,y:Math.min(h(s),h(a)),width:t.width,height:Math.abs(h(s)-h(a))}:{x:Math.min(h(a),h(s)),y:t.x,width:Math.abs(h(s)-h(a)),height:t.width};d.push({type:"violin",pathString:v,translateX:0,translateY:0,bounds:w,iqrLine:b,stats:At(e),style:k,datum:t.pieceData,category:t.name})}return d},histogram:function(t,e){const{scales:i,columns:r,config:n,getR:o,resolveSummaryStyle:a}=t,{r:s}=i,c=[],l=n.bins||25,u=n.normalize;for(const t of Object.values(r)){const e=t.pieceData.map(t=>o(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const i=Math.min(...e),r=(Math.max(...e)-i)/l||1,n=Array(l).fill(0);for(const t of e)n[Math.min(Math.floor((t-i)/r),l-1)]++;const h=e.length,f=Math.max(...n,1),d=a(t.pieceData[0],t.name);for(let e=0;l>e;e++){if(0===n[e])continue;const o=(u?n[e]/h:n[e]/f)*t.width*.9,a=s(i+e*r),l=s(i+(e+1)*r);c.push(m(Math.min(a,l),t.x+t.width-o,Math.abs(l-a),o,d,{bin:e,count:n[e],range:[i+e*r,i+(e+1)*r],category:t.name},t.name))}}return c},ridgeline:function(t,e){var i;const{scales:r,columns:n,config:o,getR:a,resolveSummaryStyle:s}=t,{r:c,projection:l}=r,u=[],h=o.bins||20,f="horizontal"===l,d=o.amplitude||1.5;for(const t of Object.values(n)){const e=t.pieceData.map(t=>a(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const r=e[0],n=e[e.length-1],o=(n-r)/h||1,l=Array(h).fill(0);for(const t of e)l[Math.min(Math.floor((t-r)/o),h-1)]++;const y=Math.max(...l,1),g=s(t.pieceData[0],t.name),p=t.width*d;let m="";if(f){const e=t.x+t.width;m=`M ${c(r)} ${e}`;for(let t=0;h>t;t++)m+=` L ${c(r+(t+.5)*o)} ${e-l[t]/y*p}`;m+=` L ${c(n)} ${e} Z`}else{const e=t.x;m=`M ${e} ${c(r)}`;for(let t=0;h>t;t++){const i=c(r+(t+.5)*o);m+=` L ${e+l[t]/y*p} ${i}`}m+=` L ${e} ${c(n)} Z`}const x=f?{x:Math.min(c(r),c(n)),y:t.x,width:Math.abs(c(n)-c(r)),height:t.width}:{x:t.x,y:Math.min(c(n),c(r)),width:t.width,height:Math.abs(c(n)-c(r))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:x,stats:At(e),style:Object.assign(Object.assign({},g),{fillOpacity:null!==(i=g.fillOpacity)&&void 0!==i?i:.5}),datum:t.pieceData,category:t.name})}return u},timeline:function(t,e){const{scales:i,columns:r,getRawRange:n,resolvePieceStyle:o}=t,{r:a,projection:s}=i,c=[],l="horizontal"===s;for(const t of Object.values(r))for(const e of t.pieceData){const i=n(e);if(!i)continue;const[r,s]=i,u=o(e,t.name);if(l){const i=a(Math.min(r,s)),n=a(Math.max(r,s));c.push(m(i,t.x,n-i,t.width,u,e,t.name))}else{const i=a(Math.max(r,s)),n=a(Math.min(r,s));c.push(m(t.x,i,t.width,n-i,u,e,t.name))}}return c}};class Pt{constructor(t){this.rExtent=new f,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.version=0,this.config=t,this.buffer=new h(t.windowSize),this.getO=k(t.oAccessor||t.categoryAccessor,"category");const e="streaming"===t.runtimeMode,i=t.rAccessor;Array.isArray(i)?(this.rAccessors=i.map(t=>v(t,"value")),this.getR=this.rAccessors[0],this.rExtents=i.map(()=>new f)):(this.getR=v(e&&(t.timeAccessor||t.valueAccessor)&&t.valueAccessor||i,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=k(t.stackBy),this.getGroup=k(t.groupBy),this.getColor=k(t.colorAccessor),this.getConnector=k(t.connectorAccessor),t.pulse&&(this.timestampBuffer=new h(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,t.bounded){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=t.totalSize||t.inserts.length;i>this.buffer.capacity&&(this.buffer.resize(i),this.timestampBuffer&&i>this.timestampBuffer.capacity&&this.timestampBuffer.resize(i));for(const i of t.inserts)this.buffer.push(i),this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i)}else for(const i of t.inserts){const t=this.buffer.push(i);this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i),null!=t&&this.evictValueExtent(t)}return!0}pushValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.push(e[0]),this.rExtent.push(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].push(this.rAccessors[e](t));this.rExtent.push(this.getR(t))}else this.rExtent.push(this.getR(t))}evictValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.evict(e[0]),this.rExtent.evict(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].evict(this.rAccessors[e](t));this.rExtent.evict(this.getR(t))}else this.rExtent.evict(this.getR(t))}getRawRange(t){const e=this.config.rAccessor;if(!e)return null;const i="function"==typeof e?e(t):t[e];return Array.isArray(i)&&i.length>=2?[+i[0],+i[1]]:null}computeScene(t){const{config:i,buffer:r}=this;if(0===r.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(r,this.getR);const n=r.toArray(),o=i.projection||"vertical",a=i.oExtent||this.resolveCategories(n),s=this.computeValueDomain(n,a),c="horizontal"===o,l=null!=i.barPadding?i.barPadding/("vertical"===o?t.width:t.height):.1;let u,h;if("radial"===o){u=e.scaleBand().domain(a).range([0,1]).padding(0);const r=Math.min(t.width,t.height)/2,n=i.innerRadius||0;h=e.scaleLinear().domain(s).range([n,r])}else c?(u=e.scaleBand().domain(a).range([0,t.height]).padding(l),h=e.scaleLinear().domain(s).range([0,t.width])):(u=e.scaleBand().domain(a).range([0,t.width]).padding(l),h=e.scaleLinear().domain(s).range([t.height,0]));this.scales={o:u,r:h,projection:o},this.multiScales=this.rAccessors.length>1&&i.multiAxis?this.rAccessors.map((n,o)=>{const a=this.rExtents[o];a.dirty&&a.recalculate(r,n);let[s,l]=a.extent;s===1/0&&(s=0,l=1);const u=l-s,h=u>0?u*(i.extentPadding||.05):1;return s-=h,l+=h,s>0&&(s=0),c?e.scaleLinear().domain([s,l]).range([0,t.width]):e.scaleLinear().domain([s,l]).range([t.height,0])}):[];let f=n;this.rAccessors.length>1&&(f=n.flatMap(t=>this.rAccessors.map((e,i)=>Object.assign(Object.assign({},t),{__rIndex:i,__rValue:e(t),__rName:this.resolveRAccessorName(i)})))),this.columns=this.buildColumns(f,a,u,o,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(f,t),this.config.decay&&this.applyDecay(this.scene,n),this.config.pulse&&this.applyPulse(this.scene,n),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(t){const e=Array.isArray(this.config.rAccessor)?this.config.rAccessor[t]:this.config.rAccessor;return"string"==typeof e?e:"value"+t}resolveCategories(t){const e=Array.from(this.categories),i=this.config.oSort;if("streaming"===this.config.runtimeMode&&void 0===i)return e;if(!1===i)return e;if("function"==typeof i)return e.sort(i);const r=new Map;for(const e of t){const t=this.getO(e);r.set(t,(r.get(t)||0)+Math.abs(this.getR(e)))}return e.sort("asc"===i?(t,e)=>(r.get(t)||0)-(r.get(e)||0):(t,e)=>(r.get(e)||0)-(r.get(t)||0))}computeValueDomain(t,e){var i,r;const n=this.config.chartType,o=this.config.extentPadding||.05;if("radial"===this.config.projection&&("pie"===n||"donut"===n))return[0,1];let a=0,s=0;if("bar"===n&&this.getStack){const e=new Map,i=new Map;for(const r of t){const t=this.getO(r),n=this.getR(r);0>n?i.set(t,(i.get(t)||0)+n):e.set(t,(e.get(t)||0)+n)}for(const t of e.values())t>s&&(s=t);for(const t of i.values())a>t&&(a=t)}else if("bar"===n){const e=new Map;for(const i of t){const t=this.getO(i),r=this.getR(i);e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>s&&(s=t),a>t&&(a=t)}else if("clusterbar"===n)for(const e of t){const t=this.getR(e);t>s&&(s=t),a>t&&(a=t)}else{const t=this.rExtent.extent[0],e=this.rExtent.extent[1];t!==1/0&&(a=t),e!==-1/0&&(s=e)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(a=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(s=this.config.rExtent[1]));const c=s-a,l=c>0?c*o:1;return(null===(i=this.config.rExtent)||void 0===i?void 0:i[0])||(a-=l),(null===(r=this.config.rExtent)||void 0===r?void 0:r[1])||(s+=l),"bar"!==n&&"clusterbar"!==n||(a>0&&(a=0),0>s&&(s=0)),[a,s]}buildColumns(t,e,i,r,n){var o;const a={},s=new Map;for(const e of t){const t=this.getO(e);s.has(t)||s.set(t,[]),s.get(t).push(e)}let c=0;if("radial"===r)for(const e of t)c+=Math.abs(this.getR(e));const l=this.config.dynamicColumnWidth;let u=null;if(l&&"radial"!==r){u=new Map;let t=0;for(const i of e){const e=s.get(i)||[];let r;r="string"==typeof l?e.reduce((t,e)=>t+(Number(e[l])||0),0):l(e),u.set(i,r),t+=r}const o=("horizontal"===r?n.height:n.width)-i.padding()*i.step()*e.length;if(t>0)for(const[e,i]of u)u.set(e,i/t*o)}let h=0,f=0;for(const t of e){const e=s.get(t)||[],r=e.reduce((t,e)=>t+Math.abs(this.getR(e)),0),n=c>0?r/c:0;let l,d;u?(l=f,d=u.get(t)||i.bandwidth(),f+=d+i.padding()*i.step()):(l=null!==(o=i(t))&&void 0!==o?o:0,d=i.bandwidth()),a[t]={name:t,x:l,y:0,width:d,middle:l+d/2,padding:i.padding()*i.step(),pieceData:e,pct:n,pctStart:h},h+=n}return a}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(t,e)=>this.resolvePieceStyle(t,e),resolveSummaryStyle:(t,e)=>this.resolveSummaryStyle(t,e),getRawRange:t=>this.getRawRange(t)}}buildSceneNodes(t,e){if(!this.scales)return[];const i=this.getSceneContext(),r=Lt[this.config.chartType];let n=r?r(i,e):[];if(this.getConnector&&this.scales){const t=function(t,e){const{scales:i,config:r,getConnector:n,getO:o}=t;if(!n||!i)return[];const a=[],{projection:s}=i,c=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const i=n(e);if(!i)continue;let r,a;"point"===t.type?(r=t.x,a=t.y):(r=t.x+t.w/2,a=t.y+("vertical"===s?0:t.h/2)),c.has(i)||c.set(i,[]),c.get(i).push({x:r,y:a,datum:e,category:o(e)})}const l=i.o.domain(),u=r.connectorStyle;for(const[t,e]of c)if(e.length>=2){e.sort((t,e)=>l.indexOf(t.category)-l.indexOf(e.category));for(let i=0;e.length-1>i;i++){const r=e[i],n=e[i+1],o="function"==typeof u?u(r.datum):u||{stroke:"#999",strokeWidth:1,opacity:.5};a.push({type:"connector",x1:r.x,y1:r.y,x2:n.x,y2:n.y,style:o,datum:r.datum,group:t})}}return a}(i,n);n=[...t,...n]}return n}resolvePieceStyle(t,e){return"function"==typeof this.config.pieceStyle?this.config.pieceStyle(t,e):this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&e?{fill:this.config.barColors[e]||"#007bff"}:e?{fill:this.getColorFromScheme(e)}:{fill:"#007bff"}}getColorFromScheme(t){this._colorSchemeMap||(this._colorSchemeMap=new Map);const e=this._colorSchemeMap.get(t);if(e)return e;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],r=i[this._colorSchemeIndex%i.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(t,r),r}resolveSummaryStyle(t,e){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(t,e):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(t,e){var i,r,n;const o=this.config.decay;if(!o||1>=e)return 1;const a=null!==(i=o.minOpacity)&&void 0!==i?i:.1,s=e-1-t;switch(o.type){case"linear":return a+(1-s/(e-1))*(1-a);case"exponential":{const t=null!==(r=o.halfLife)&&void 0!==r?r:e/2;return a+Math.pow(.5,s/t)*(1-a)}case"step":return(null!==(n=o.stepThreshold)&&void 0!==n?n:.5*e)>s?1:a;default:return 1}}applyDecay(t,e){var i,r;if(!this.config.decay)return;const n=e.length;if(1>=n)return;const o=new Map;for(let t=0;e.length>t;t++)o.set(e[t],t);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;const t=o.get(e.datum);if(null==t)continue;const a=this.computeDecayOpacity(t,n),s=null!==(r=null===(i=e.style)||void 0===i?void 0:i.opacity)&&void 0!==r?r:1;e.style=Object.assign(Object.assign({},e.style),{opacity:s*a})}}applyPulse(t,e){var i,r,n;if(!this.config.pulse||!this.timestampBuffer)return;const o="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(i=this.config.pulse.duration)&&void 0!==i?i:500,s=null!==(r=this.config.pulse.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",c=null!==(n=this.config.pulse.glowRadius)&&void 0!==n?n:4,l=new Map;for(let t=0;e.length>t;t++)l.set(e[t],t);for(const i of t){if("connector"===i.type||"violin"===i.type||"boxplot"===i.type)continue;if("wedge"===i.type){const t=i.category;if(!t)continue;let r=0;for(let i=0;e.length>i;i++){const n=e[i],s=this.config.oAccessor;if(("function"==typeof s?s(n):n[s||"category"])!==t)continue;const c=this.timestampBuffer.get(i);if(null==c)continue;const l=o-c;if(a>l){const t=1-l/a;t>r&&(r=t)}}r>0&&(i._pulseIntensity=r,i._pulseColor=s);continue}const t=l.get(i.datum);if(null==t)continue;const r=this.timestampBuffer.get(t);if(null==r)continue;const n=o-r;a>n&&(i._pulseIntensity=1-n/a,i._pulseColor=s,i._pulseGlowRadius=c)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,r=this.timestampBuffer.peek();return null!=r&&i>e-r}snapshotPositions(){var t,e;this.prevPositionMap.clear();for(let i=0;this.scene.length>i;i++){const r=this.scene[i];if("point"===r.type)this.prevPositionMap.set("p:"+i,{x:r.x,y:r.y,r:r.r});else if("rect"===r.type){const n=`r:${r.group||""}:${null!==(e=null===(t=r.datum)||void 0===t?void 0:t.category)&&void 0!==e?e:i}`;this.prevPositionMap.set(n,{x:r.x,y:r.y,w:r.w,h:r.h})}}}startTransition(){var t,e,i,r,n;if(!this.config.transition||0===this.prevPositionMap.size)return;const o=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;let a=!1;for(let t=0;this.scene.length>t;t++){const o=this.scene[t];let s=null;if("point"===o.type?s="p:"+t:"rect"===o.type&&(s=`r:${o.group||""}:${null!==(i=null===(e=o.datum)||void 0===e?void 0:e.category)&&void 0!==i?i:t}`),!s)continue;const c=this.prevPositionMap.get(s);c&&("point"===o.type?c.x===o.x&&c.y===o.y||(o._targetX=o.x,o._targetY=o.y,o.x=c.x,o.y=c.y,a=!0):"rect"===o.type&&(c.x===o.x&&c.y===o.y&&c.w===o.w&&c.h===o.h||(o._targetX=o.x,o._targetY=o.y,o._targetW=o.w,o._targetH=o.h,o.x=c.x,o.y=c.y,o.w=null!==(r=c.w)&&void 0!==r?r:o.w,o.h=null!==(n=c.h)&&void 0!==n?n:o.h,a=!0)))}a&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:o})}advanceTransition(t){var e,i,r;if(!this.activeTransition)return!1;const n=Math.min((t-this.activeTransition.startTime)/this.activeTransition.duration,1),o="linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?n:1-Math.pow(1-n,3);for(let t=0;this.scene.length>t;t++){const e=this.scene[t];if("point"===e.type){if(void 0===e._targetX)continue;const i=this.prevPositionMap.get("p:"+t);if(!i)continue;e.x=i.x+(e._targetX-i.x)*o,e.y=i.y+(e._targetY-i.y)*o}else if("rect"===e.type){if(void 0===e._targetX)continue;const n=`r:${e.group||""}:${null!==(r=null===(i=e.datum)||void 0===i?void 0:i.category)&&void 0!==r?r:t}`,a=this.prevPositionMap.get(n);if(!a)continue;e.x=a.x+(e._targetX-a.x)*o,e.y=a.y+(e._targetY-a.y)*o,void 0!==a.w&&(e.w=a.w+(e._targetW-a.w)*o,e.h=a.h+(e._targetH-a.h)*o)}}if(n>=1){for(const t of this.scene)if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=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}return this.activeTransition=null,!1}return!0}getData(){return this.buffer.toArray()}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}updateConfig(t){t.colorScheme!==this.config.colorScheme&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),Object.assign(this.config,t)}}const Mt=require("react-dom/server");function _t(t){return Math.round(100*t)/100+""}function Dt(t){var e,i,r,n;const o=t.size||[500,300],a=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),t.margin),s=o[0]-a.left-a.right,c=o[1]-a.top-a.bottom,l="streaming"===t.runtimeMode||["bar","swarm","waterfall"].includes(t.chartType),h={chartType:t.chartType,windowSize:null!==(e=t.windowSize)&&void 0!==e?e:200,windowMode:null!==(i=t.windowMode)&&void 0!==i?i:"sliding",arrowOfTime:l&&null!==(r=t.arrowOfTime)&&void 0!==r?r:"right",extentPadding:null!==(n=t.extentPadding)&&void 0!==n?n:.1,xAccessor:l?void 0:t.xAccessor,yAccessor:l?void 0:t.yAccessor,timeAccessor:l?t.timeAccessor:void 0,valueAccessor:t.valueAccessor,colorAccessor:t.colorAccessor,sizeAccessor:t.sizeAccessor,groupAccessor:t.groupAccessor,categoryAccessor:t.categoryAccessor,lineDataAccessor:t.lineDataAccessor,xExtent:t.xExtent,yExtent:t.yExtent,sizeRange:t.sizeRange,binSize:t.binSize,normalize:t.normalize,boundsAccessor:t.boundsAccessor,boundsStyle:t.boundsStyle,openAccessor:t.openAccessor,highAccessor:t.highAccessor,lowAccessor:t.lowAccessor,closeAccessor:t.closeAccessor,candlestickStyle:t.candlestickStyle,lineStyle:t.lineStyle,pointStyle:t.pointStyle,areaStyle:t.areaStyle,colorScheme:t.colorScheme,barColors:t.barColors},f=new b(h);if(t.data&&f.ingest({inserts:t.data,bounded:!0}),f.computeScene({width:s,height:c}),!f.scales||0===f.scene.length)return Mt.renderToStaticMarkup(u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-xy-frame",width:o[0],height:o[1]}));const d=f.scene.map((t,e)=>function(t,e){var i,r,n;switch(t.type){case"line":{const i=t;if(0===i.path.length)return null;const r="M"+i.path.map(([t,e])=>`${t},${e}`).join("L");return u.createElement("path",{key:"line-"+e,d:r,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth||2,strokeDasharray:i.style.strokeDasharray,opacity:i.style.opacity})}case"area":{const n=t;if(0===n.topPath.length)return null;const o=n.topPath.map(([t,e])=>`${t},${e}`).join("L"),a=[...n.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return u.createElement("path",{key:"area-"+e,d:`M${o}L${a}Z`,fill:n.style.fill||"#4e79a7",fillOpacity:null!==(r=null!==(i=n.style.fillOpacity)&&void 0!==i?i:n.style.opacity)&&void 0!==r?r:.7,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})}case"point":return u.createElement("circle",{key:"point-"+e,cx:t.x,cy:t.y,r:t.r,fill:t.style.fill||"#4e79a7",opacity:null!==(n=t.style.opacity)&&void 0!==n?n:.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth});case"rect":return u.createElement("rect",{key:"rect-"+e,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.style.fill||"#4e79a7",opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth});case"heatcell":return u.createElement("rect",{key:"heatcell-"+e,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.fill});case"candlestick":{const i=t,r=Math.min(i.openY,i.closeY),n=Math.max(Math.abs(i.openY-i.closeY),1),o=i.isUp?i.upColor:i.downColor;return u.createElement("g",{key:"candle-"+e},u.createElement("line",{x1:i.x,y1:i.highY,x2:i.x,y2:i.lowY,stroke:i.wickColor,strokeWidth:i.wickWidth}),u.createElement("rect",{x:i.x-i.bodyWidth/2,y:r,width:i.bodyWidth,height:n,fill:o,stroke:o,strokeWidth:1}))}default:return null}}(t,e)).filter(Boolean),y=!1!==t.showAxes?function(t,e,i){var r,n,o,a;const s=t.x.ticks(5).map(e=>({pixel:t.x(e),label:(i.xFormat||i.tickFormatTime||_t)(e)})),c=t.y.ticks(5).map(e=>({pixel:t.y(e),label:(i.yFormat||i.tickFormatValue||_t)(e)}));return u.createElement("g",{className:"stream-axes"},u.createElement("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:"#ccc",strokeWidth:1}),s.map((t,i)=>u.createElement("g",{key:"xtick-"+i,transform:`translate(${t.pixel},${e.height})`},u.createElement("line",{y2:5,stroke:"#ccc",strokeWidth:1}),u.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"#666"},t.label))),i.xLabel&&u.createElement("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:12,fill:"#333"},i.xLabel),u.createElement("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:"#ccc",strokeWidth:1}),c.map((t,e)=>u.createElement("g",{key:"ytick-"+e,transform:`translate(0,${t.pixel})`},u.createElement("line",{x2:-5,stroke:"#ccc",strokeWidth:1}),u.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"#666"},t.label))),i.yLabel&&u.createElement("text",{x:15-(null!==(n=null===(r=i.margin)||void 0===r?void 0:r.left)&&void 0!==n?n:40),y:e.height/2,textAnchor:"middle",fontSize:12,fill:"#333",transform:`rotate(-90, ${15-(null!==(a=null===(o=i.margin)||void 0===o?void 0:o.left)&&void 0!==a?a:40)}, ${e.height/2})`},i.yLabel))}(f.scales,{width:s,height:c},t):null,g=t.title&&"string"==typeof t.title?u.createElement("text",{x:o[0]/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333"},t.title):null,p=t.background?u.createElement("rect",{x:0,y:0,width:s,height:c,fill:t.background}):null,m=u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-xy-frame"+(t.className?" "+t.className:""),width:o[0],height:o[1]},u.createElement("g",{transform:`translate(${a.left},${a.top})`},p,d,y),g);return Mt.renderToStaticMarkup(m)}function $t(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const Wt=new Set(["tree","cluster","treemap","circlepack","partition"]);function Nt(t){const e=t.chartType||"force",i=t.size||[500,500],r=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),t.margin),n=i[0]-r.left-r.right,o=i[1]-r.top-r.bottom,a=function(t){return Et[t]}(e);if(!a)throw Error(`No layout plugin found for chart type: "${e}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const c={chartType:e,nodeIDAccessor:t.nodeIDAccessor,sourceAccessor:t.sourceAccessor,targetAccessor:t.targetAccessor,valueAccessor:t.valueAccessor,childrenAccessor:t.childrenAccessor,hierarchySum:t.hierarchySum,orientation:t.orientation,nodeAlign:t.nodeAlign,nodePaddingRatio:t.nodePaddingRatio,nodeWidth:t.nodeWidth,iterations:t.iterations,forceStrength:t.forceStrength,padAngle:t.padAngle,groupWidth:t.groupWidth,sortGroups:t.sortGroups,edgeSort:t.edgeSort,treeOrientation:t.treeOrientation,edgeType:t.edgeType,padding:t.padding,paddingTop:t.paddingTop,nodeStyle:t.nodeStyle,edgeStyle:t.edgeStyle,nodeLabel:t.nodeLabel,showLabels:t.showLabels,colorBy:t.colorBy,colorScheme:t.colorScheme,edgeColorBy:t.edgeColorBy,edgeOpacity:t.edgeOpacity,colorByDepth:t.colorByDepth,nodeSize:t.nodeSize,nodeSizeRange:t.nodeSizeRange};let l,h;if(Wt.has(e)){const e=t.data||t.edges;if(!e||Array.isArray(e))return Mt.renderToStaticMarkup(u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-network-frame",width:i[0],height:i[1]}));c.__hierarchyRoot=e,l=[],h=[]}else{const e=t.nodes||[],r=Array.isArray(t.edges)?t.edges:[];if(0===e.length&&0===r.length)return Mt.renderToStaticMarkup(u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-network-frame",width:i[0],height:i[1]}));if(h=function(t,e){const i=$t(e.sourceAccessor,"source"),r=$t(e.targetAccessor,"target"),n=$t(e.valueAccessor,"value");return t.map(t=>({source:i(t)+"",target:r(t)+"",value:Number(n(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(r,c),0===e.length&&h.length>0){const t=new Set;for(const e of h){const i="string"==typeof e.target?e.target:e.target.id;t.add("string"==typeof e.source?e.source:e.source.id),t.add(i)}l=Array.from(t).map(t=>({id:t,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:t}}))}else l=function(t,e){const i=$t(e.nodeIDAccessor,"id");return t.map(t=>({id:i(t)+"",x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}))}(e,c)}a.computeLayout(l,h,c,[n,o]);const{sceneNodes:f,sceneEdges:d,labels:y}=a.buildScene(l,h,c,[n,o]),g=d.map((t,e)=>function(t,e){switch(t.type){case"line":return u.createElement("line",{key:"net-edge-"+e,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity});case"bezier":case"ribbon":return u.createElement("path",{key:"net-edge-"+e,d:t.pathD,fill:t.style.fill||"#999",fillOpacity:t.style.fillOpacity,stroke:t.style.stroke||"none",strokeWidth:t.style.strokeWidth,opacity:t.style.opacity});case"curved":return u.createElement("path",{key:"net-edge-"+e,d:t.pathD,fill:t.style.fill||"none",stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity});default:return null}}(t,e)).filter(Boolean),p=f.map((t,e)=>function(t,e){switch(t.type){case"circle":return u.createElement("circle",{key:"net-circle-"+e,cx:t.cx,cy:t.cy,r:t.r,fill:t.style.fill||"#4e79a7",stroke:t.style.stroke,strokeWidth:t.style.strokeWidth,opacity:t.style.opacity});case"rect":return u.createElement("rect",{key:"net-rect-"+e,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.style.fill||"#4e79a7",stroke:t.style.stroke,strokeWidth:t.style.strokeWidth,opacity:t.style.opacity});case"arc":{const i=t,r=s.arc().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle).endAngle(i.endAngle)({})||"";return u.createElement("path",{key:"net-arc-"+e,d:r,transform:`translate(${i.cx},${i.cy})`,fill:i.style.fill||"#4e79a7",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}default:return null}}(t,e)).filter(Boolean),m=y.map((t,e)=>function(t,e){return u.createElement("text",{key:"net-label-"+e,x:t.x,y:t.y,textAnchor:t.anchor||"middle",dominantBaseline:t.baseline||"auto",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"#333",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder},t.text)}(t,e)).filter(Boolean),x=t.title&&"string"==typeof t.title?u.createElement("text",{x:i[0]/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333"},t.title):null,v=t.background?u.createElement("rect",{x:0,y:0,width:n,height:o,fill:t.background}):null,k=u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-network-frame"+(t.className?" "+t.className:""),width:i[0],height:i[1]},u.createElement("g",{transform:`translate(${r.left},${r.top})`},v,g,p,m),x);return Mt.renderToStaticMarkup(k)}function Tt(t){var e,i,r;const n=t.size||[500,400],o=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),t.margin),a=n[0]-o.left-o.right,c=n[1]-o.top-o.bottom,l=t.projection||"vertical",h="radial"===l,f={chartType:t.chartType,windowSize:null!==(e=t.windowSize)&&void 0!==e?e:1e4,windowMode:null!==(i=t.windowMode)&&void 0!==i?i:"sliding",extentPadding:null!==(r=t.extentPadding)&&void 0!==r?r:.05,projection:l,oAccessor:t.oAccessor,rAccessor:t.rAccessor,colorAccessor:t.colorAccessor,stackBy:t.stackBy,groupBy:t.groupBy,categoryAccessor:t.categoryAccessor,valueAccessor:t.valueAccessor,timeAccessor:t.timeAccessor,rExtent:t.rExtent,oExtent:t.oExtent,barPadding:t.barPadding,innerRadius:t.innerRadius,normalize:t.normalize,startAngle:t.startAngle,bins:t.bins,showOutliers:t.showOutliers,showIQR:t.showIQR,amplitude:t.amplitude,oSort:t.oSort,connectorAccessor:t.connectorAccessor,connectorStyle:t.connectorStyle,dynamicColumnWidth:t.dynamicColumnWidth,pieceStyle:t.pieceStyle,summaryStyle:t.summaryStyle,colorScheme:t.colorScheme,barColors:t.barColors},d=new Pt(f);if(t.data&&d.ingest({inserts:t.data,bounded:!0}),d.computeScene({width:a,height:c}),!d.scales||0===d.scene.length)return Mt.renderToStaticMarkup(u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-ordinal-frame",width:n[0],height:n[1]}));const y=d.scene.map((t,e)=>function(t,e){var i,r,n,o,a;switch(t.type){case"rect":return u.createElement("rect",{key:"ord-rect-"+e,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.style.fill||"#4e79a7",opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth});case"point":return u.createElement("circle",{key:"ord-point-"+e,cx:t.x,cy:t.y,r:t.r,fill:t.style.fill||"#4e79a7",opacity:null!==(i=t.style.opacity)&&void 0!==i?i:.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth});case"wedge":{const i=t,r=s.arc().innerRadius(i.innerRadius).outerRadius(i.outerRadius).startAngle(i.startAngle).endAngle(i.endAngle)({})||"";return u.createElement("path",{key:"ord-wedge-"+e,d:r,transform:`translate(${i.cx},${i.cy})`,fill:i.style.fill||"#4e79a7",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}case"boxplot":{const i=t,o=i.columnWidth/2;return"vertical"===i.projection?u.createElement("g",{key:"ord-boxplot-"+e},u.createElement("line",{x1:i.x,y1:i.minPos,x2:i.x,y2:i.maxPos,stroke:i.style.stroke||"#333",strokeWidth:1}),u.createElement("rect",{x:i.x-o,y:Math.min(i.q1Pos,i.q3Pos),width:i.columnWidth,height:Math.abs(i.q3Pos-i.q1Pos),fill:i.style.fill||"#4e79a7",fillOpacity:null!==(r=i.style.fillOpacity)&&void 0!==r?r:.6,stroke:i.style.stroke||"#333",strokeWidth:1}),u.createElement("line",{x1:i.x-o,y1:i.medianPos,x2:i.x+o,y2:i.medianPos,stroke:i.style.stroke||"#333",strokeWidth:2}),u.createElement("line",{x1:i.x-.5*o,y1:i.minPos,x2:i.x+.5*o,y2:i.minPos,stroke:i.style.stroke||"#333",strokeWidth:1}),u.createElement("line",{x1:i.x-.5*o,y1:i.maxPos,x2:i.x+.5*o,y2:i.maxPos,stroke:i.style.stroke||"#333",strokeWidth:1})):u.createElement("g",{key:"ord-boxplot-"+e},u.createElement("line",{x1:i.minPos,y1:i.y,x2:i.maxPos,y2:i.y,stroke:i.style.stroke||"#333",strokeWidth:1}),u.createElement("rect",{x:Math.min(i.q1Pos,i.q3Pos),y:i.y-o,width:Math.abs(i.q3Pos-i.q1Pos),height:i.columnWidth,fill:i.style.fill||"#4e79a7",fillOpacity:null!==(n=i.style.fillOpacity)&&void 0!==n?n:.6,stroke:i.style.stroke||"#333",strokeWidth:1}),u.createElement("line",{x1:i.medianPos,y1:i.y-o,x2:i.medianPos,y2:i.y+o,stroke:i.style.stroke||"#333",strokeWidth:2}),u.createElement("line",{x1:i.minPos,y1:i.y-.5*o,x2:i.minPos,y2:i.y+.5*o,stroke:i.style.stroke||"#333",strokeWidth:1}),u.createElement("line",{x1:i.maxPos,y1:i.y-.5*o,x2:i.maxPos,y2:i.y+.5*o,stroke:i.style.stroke||"#333",strokeWidth:1}))}case"violin":{const i=t,r=[u.createElement("path",{key:"ord-violin-path-"+e,d:i.pathString,transform:i.translateX||i.translateY?`translate(${i.translateX},${i.translateY})`:void 0,fill:i.style.fill||"#4e79a7",fillOpacity:null!==(o=i.style.fillOpacity)&&void 0!==o?o:.6,stroke:i.style.stroke||"#333",strokeWidth:i.style.strokeWidth||1})];if(i.iqrLine&&i.bounds){const t=i.bounds,n=t.x+t.width/2,o=t.y+t.height/2;t.height>t.width?r.push(u.createElement("line",{key:"ord-violin-iqr-"+e,x1:n,y1:i.iqrLine.q1Pos,x2:n,y2:i.iqrLine.q3Pos,stroke:i.style.stroke||"#333",strokeWidth:2}),u.createElement("circle",{key:"ord-violin-med-"+e,cx:n,cy:i.iqrLine.medianPos,r:3,fill:"white",stroke:i.style.stroke||"#333",strokeWidth:1})):r.push(u.createElement("line",{key:"ord-violin-iqr-"+e,x1:i.iqrLine.q1Pos,y1:o,x2:i.iqrLine.q3Pos,y2:o,stroke:i.style.stroke||"#333",strokeWidth:2}),u.createElement("circle",{key:"ord-violin-med-"+e,cx:i.iqrLine.medianPos,cy:o,r:3,fill:"white",stroke:i.style.stroke||"#333",strokeWidth:1}))}return u.createElement("g",{key:"ord-violin-"+e},r)}case"connector":return u.createElement("line",{key:"ord-conn-"+e,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:null!==(a=t.style.opacity)&&void 0!==a?a:.5});default:return null}}(t,e)).filter(Boolean),g=!1!==t.showAxes?function(t,e,i){var r,n,o,a,s,c,l,h;const f=t.scales;if(!f)return null;if("radial"===f.projection)return null;const d="vertical"===f.projection,y=Object.values(t.columns).map(t=>({pixel:t.middle,label:(i.oFormat||String)(t.name)})),g=f.r.ticks(5).map(t=>({pixel:f.r(t),label:(i.rFormat||_t)(t)}));return d?u.createElement("g",{className:"ordinal-axes"},u.createElement("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:"#ccc",strokeWidth:1}),y.map((t,i)=>u.createElement("g",{key:"oxtick-"+i,transform:`translate(${t.pixel},${e.height})`},u.createElement("line",{y2:5,stroke:"#ccc",strokeWidth:1}),u.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"#666"},t.label))),i.oLabel&&u.createElement("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:12,fill:"#333"},i.oLabel),u.createElement("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:"#ccc",strokeWidth:1}),g.map((t,e)=>u.createElement("g",{key:"oytick-"+e,transform:`translate(0,${t.pixel})`},u.createElement("line",{x2:-5,stroke:"#ccc",strokeWidth:1}),u.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"#666"},t.label))),i.rLabel&&u.createElement("text",{x:15-(null!==(n=null===(r=i.margin)||void 0===r?void 0:r.left)&&void 0!==n?n:40),y:e.height/2,textAnchor:"middle",fontSize:12,fill:"#333",transform:`rotate(-90, ${15-(null!==(a=null===(o=i.margin)||void 0===o?void 0:o.left)&&void 0!==a?a:40)}, ${e.height/2})`},i.rLabel)):u.createElement("g",{className:"ordinal-axes"},u.createElement("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:"#ccc",strokeWidth:1}),g.map((t,i)=>u.createElement("g",{key:"oxtick-"+i,transform:`translate(${t.pixel},${e.height})`},u.createElement("line",{y2:5,stroke:"#ccc",strokeWidth:1}),u.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"#666"},t.label))),i.rLabel&&u.createElement("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:12,fill:"#333"},i.rLabel),u.createElement("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:"#ccc",strokeWidth:1}),y.map((t,e)=>u.createElement("g",{key:"oytick-"+e,transform:`translate(0,${t.pixel})`},u.createElement("line",{x2:-5,stroke:"#ccc",strokeWidth:1}),u.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"#666"},t.label))),i.oLabel&&u.createElement("text",{x:15-(null!==(c=null===(s=i.margin)||void 0===s?void 0:s.left)&&void 0!==c?c:40),y:e.height/2,textAnchor:"middle",fontSize:12,fill:"#333",transform:`rotate(-90, ${15-(null!==(h=null===(l=i.margin)||void 0===l?void 0:l.left)&&void 0!==h?h:40)}, ${e.height/2})`},i.oLabel))}(d,{width:a,height:c},t):null,p=t.title&&"string"==typeof t.title?u.createElement("text",{x:n[0]/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333"},t.title):null,m=t.background?u.createElement("rect",{x:0,y:0,width:a,height:c,fill:t.background}):null,x=u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-ordinal-frame"+(t.className?" "+t.className:""),width:n[0],height:n[1]},u.createElement("g",{transform:`translate(${h?o.left+a/2:o.left},${h?o.top+c/2:o.top})`},m,y,g),p);return Mt.renderToStaticMarkup(x)}exports.renderNetworkToStaticSVG=function(t){return Nt(t)},exports.renderOrdinalToStaticSVG=function(t){return Tt(t)},exports.renderToStaticSVG=function(t,e){switch(t){case"xy":return Dt(e);case"ordinal":return Tt(e);case"network":return Nt(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", or "network".`)}},exports.renderXYToStaticSVG=function(t){return Dt(t)};