semiotic 3.0.0-beta.7 → 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.
- package/CLAUDE.md +24 -11
- package/README.md +67 -64
- package/ai/cli.js +34 -21
- package/ai/dist/componentRegistry.js +2 -0
- package/ai/dist/mcp-server.js +54 -0
- package/ai/examples.md +75 -0
- package/ai/schema.json +71 -0
- package/ai/system-prompt.md +3 -0
- package/dist/{ChartGrid.d.ts → components/ChartGrid.d.ts} +9 -7
- package/dist/{LinkedCharts.d.ts → components/LinkedCharts.d.ts} +34 -1
- package/dist/{Tooltip → components/Tooltip}/Tooltip.d.ts +9 -2
- package/dist/{charts → components/charts}/index.d.ts +2 -0
- package/dist/{charts → components/charts}/network/ChordDiagram.d.ts +2 -0
- package/dist/{charts → components/charts}/network/CirclePack.d.ts +2 -0
- package/dist/{charts → components/charts}/network/ForceDirectedGraph.d.ts +2 -0
- package/dist/components/charts/network/OrbitDiagram.d.ts +78 -0
- package/dist/{charts → components/charts}/network/SankeyDiagram.d.ts +2 -0
- package/dist/{charts → components/charts}/network/TreeDiagram.d.ts +2 -0
- package/dist/{charts → components/charts}/network/Treemap.d.ts +2 -0
- package/dist/{charts → components/charts}/ordinal/BarChart.d.ts +2 -0
- package/dist/{charts → components/charts}/ordinal/BoxPlot.d.ts +2 -0
- package/dist/{charts → components/charts}/ordinal/DonutChart.d.ts +2 -0
- package/dist/{charts → components/charts}/ordinal/DotPlot.d.ts +2 -0
- package/dist/{charts → components/charts}/ordinal/GroupedBarChart.d.ts +2 -0
- package/dist/{charts → components/charts}/ordinal/PieChart.d.ts +2 -0
- package/dist/{charts → components/charts}/ordinal/StackedBarChart.d.ts +2 -0
- package/dist/{charts → components/charts}/ordinal/SwarmPlot.d.ts +2 -0
- package/dist/components/charts/shared/diagnoseConfig.d.ts +23 -0
- package/dist/{charts → components/charts}/shared/hooks.d.ts +23 -1
- package/dist/components/charts/shared/stringDistance.d.ts +11 -0
- package/dist/{charts → components/charts}/shared/tooltipUtils.d.ts +1 -1
- package/dist/{charts → components/charts}/shared/types.d.ts +6 -0
- package/dist/{charts → components/charts}/shared/withChartWrapper.d.ts +10 -0
- package/dist/{charts → components/charts}/xy/AreaChart.d.ts +8 -0
- package/dist/{charts → components/charts}/xy/BubbleChart.d.ts +8 -0
- package/dist/{charts → components/charts}/xy/ConnectedScatterplot.d.ts +3 -0
- package/dist/{charts → components/charts}/xy/Heatmap.d.ts +8 -0
- package/dist/{charts → components/charts}/xy/LineChart.d.ts +26 -0
- package/dist/{charts → components/charts}/xy/Scatterplot.d.ts +3 -0
- package/dist/{charts → components/charts}/xy/StackedAreaChart.d.ts +8 -0
- package/dist/{export → components/export}/exportChart.d.ts +6 -1
- package/dist/components/semiotic-ai.d.ts +61 -0
- package/dist/components/semiotic-data.d.ts +7 -0
- package/dist/components/semiotic-network.d.ts +14 -0
- package/dist/components/semiotic-ordinal.d.ts +18 -0
- package/dist/components/semiotic-realtime.d.ts +22 -0
- package/dist/components/semiotic-server.d.ts +1 -0
- package/dist/components/semiotic-xy.d.ts +16 -0
- package/dist/components/semiotic.d.ts +57 -0
- package/dist/{server → components/server}/renderToStaticSVG.d.ts +7 -0
- package/dist/{stream → components/stream}/NetworkSVGOverlay.d.ts +20 -0
- package/dist/{stream → components/stream}/OrdinalSVGOverlay.d.ts +8 -0
- package/dist/{stream → components/stream}/PipelineStore.d.ts +7 -0
- package/dist/{stream → components/stream}/SVGOverlay.d.ts +15 -0
- package/dist/components/stream/SceneToSVG.d.ts +20 -0
- package/dist/components/stream/hitTestUtils.d.ts +23 -0
- package/dist/{stream → components/stream}/networkTypes.d.ts +10 -2
- package/dist/{stream → components/stream}/ordinalTypes.d.ts +16 -10
- package/dist/components/stream/renderers/areaCanvasRenderer.d.ts +2 -0
- package/dist/{stream → components/stream}/types.d.ts +12 -0
- package/dist/components/stream/useStalenessCheck.d.ts +16 -0
- package/dist/{types → components/types}/legendTypes.d.ts +5 -0
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai.d.ts +3 -0
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-network.d.ts +1 -0
- package/dist/semiotic-ordinal.d.ts +1 -0
- package/dist/semiotic.d.ts +3 -3
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/test/canvasMock.d.ts +2 -0
- package/dist/test-utils/canvasMock.d.ts +20 -0
- package/dist/test-utils/frameMock.d.ts +78 -0
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +9 -17
- package/dist/stream/renderers/areaCanvasRenderer.d.ts +0 -7
- /package/dist/{Annotation.d.ts → components/Annotation.d.ts} +0 -0
- /package/dist/{CategoryColors.d.ts → components/CategoryColors.d.ts} +0 -0
- /package/dist/{ChartContainer.d.ts → components/ChartContainer.d.ts} +0 -0
- /package/dist/{ChartErrorBoundary.d.ts → components/ChartErrorBoundary.d.ts} +0 -0
- /package/dist/{ContextLayout.d.ts → components/ContextLayout.d.ts} +0 -0
- /package/dist/{DetailsPanel.d.ts → components/DetailsPanel.d.ts} +0 -0
- /package/dist/{Legend.d.ts → components/Legend.d.ts} +0 -0
- /package/dist/{ThemeProvider.d.ts → components/ThemeProvider.d.ts} +0 -0
- /package/dist/{charts → components/charts}/ordinal/Histogram.d.ts +0 -0
- /package/dist/{charts → components/charts}/ordinal/RidgelinePlot.d.ts +0 -0
- /package/dist/{charts → components/charts}/ordinal/ViolinPlot.d.ts +0 -0
- /package/dist/{charts → components/charts}/realtime/RealtimeHeatmap.d.ts +0 -0
- /package/dist/{charts → components/charts}/realtime/RealtimeHistogram.d.ts +0 -0
- /package/dist/{charts → components/charts}/realtime/RealtimeLineChart.d.ts +0 -0
- /package/dist/{charts → components/charts}/realtime/RealtimeSwarmChart.d.ts +0 -0
- /package/dist/{charts → components/charts}/realtime/RealtimeWaterfallChart.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/ChartError.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/annotationRules.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/colorUtils.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/formatUtils.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/legendUtils.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/loess.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/networkUtils.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/selectionUtils.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/statisticalOverlays.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/validateChartData.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/validateProps.d.ts +0 -0
- /package/dist/{charts → components/charts}/xy/MinimapChart.d.ts +0 -0
- /package/dist/{charts → components/charts}/xy/ScatterplotMatrix.d.ts +0 -0
- /package/dist/{data → components/data}/fromVegaLite.d.ts +0 -0
- /package/dist/{data → components/data}/transforms.d.ts +0 -0
- /package/dist/{export → components/export}/chartConfig.d.ts +0 -0
- /package/dist/{export → components/export}/selectionSerializer.d.ts +0 -0
- /package/dist/{geometry → components/geometry}/sankeyLinks.d.ts +0 -0
- /package/dist/{realtime → components/realtime}/BinAccumulator.d.ts +0 -0
- /package/dist/{realtime → components/realtime}/IncrementalExtent.d.ts +0 -0
- /package/dist/{realtime → components/realtime}/RingBuffer.d.ts +0 -0
- /package/dist/{realtime → components/realtime}/renderers/types.d.ts +0 -0
- /package/dist/{realtime → components/realtime}/renderers/waterfallRenderer.d.ts +0 -0
- /package/dist/{realtime → components/realtime}/types.d.ts +0 -0
- /package/dist/{store → components/store}/ObservationStore.d.ts +0 -0
- /package/dist/{store → components/store}/SelectionStore.d.ts +0 -0
- /package/dist/{store → components/store}/ThemeStore.d.ts +0 -0
- /package/dist/{store → components/store}/TooltipStore.d.ts +0 -0
- /package/dist/{store → components/store}/createStore.d.ts +0 -0
- /package/dist/{store → components/store}/useObservation.d.ts +0 -0
- /package/dist/{store → components/store}/useSelection.d.ts +0 -0
- /package/dist/{stream → components/stream}/CanvasHitTester.d.ts +0 -0
- /package/dist/{stream → components/stream}/DataSourceAdapter.d.ts +0 -0
- /package/dist/{stream → components/stream}/MarginalGraphics.d.ts +0 -0
- /package/dist/{stream → components/stream}/NetworkCanvasHitTester.d.ts +0 -0
- /package/dist/{stream → components/stream}/NetworkPipelineStore.d.ts +0 -0
- /package/dist/{stream → components/stream}/OrdinalCanvasHitTester.d.ts +0 -0
- /package/dist/{stream → components/stream}/OrdinalPipelineStore.d.ts +0 -0
- /package/dist/{stream → components/stream}/ParticlePool.d.ts +0 -0
- /package/dist/{stream → components/stream}/SceneGraph.d.ts +0 -0
- /package/dist/{stream → components/stream}/StreamNetworkFrame.d.ts +0 -0
- /package/dist/{stream → components/stream}/StreamOrdinalFrame.d.ts +0 -0
- /package/dist/{stream → components/stream}/StreamXYFrame.d.ts +0 -0
- /package/dist/{stream → components/stream}/accessorUtils.d.ts +0 -0
- /package/dist/{stream → components/stream}/keyboardNav.d.ts +0 -0
- /package/dist/{stream → components/stream}/layouts/chordLayoutPlugin.d.ts +0 -0
- /package/dist/{stream → components/stream}/layouts/forceLayoutPlugin.d.ts +0 -0
- /package/dist/{stream → components/stream}/layouts/hierarchyLayoutPlugin.d.ts +0 -0
- /package/dist/{stream → components/stream}/layouts/index.d.ts +0 -0
- /package/dist/{stream → components/stream}/layouts/sankeyLayoutPlugin.d.ts +0 -0
- /package/dist/{stream → components/stream}/ordinalSceneBuilders/barScene.d.ts +0 -0
- /package/dist/{stream → components/stream}/ordinalSceneBuilders/connectorScene.d.ts +0 -0
- /package/dist/{stream → components/stream}/ordinalSceneBuilders/pieScene.d.ts +0 -0
- /package/dist/{stream → components/stream}/ordinalSceneBuilders/pointScene.d.ts +0 -0
- /package/dist/{stream → components/stream}/ordinalSceneBuilders/statisticalScene.d.ts +0 -0
- /package/dist/{stream → components/stream}/ordinalSceneBuilders/timelineScene.d.ts +0 -0
- /package/dist/{stream → components/stream}/ordinalSceneBuilders/types.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/barCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/boxplotCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/candlestickCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/connectorCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/heatmapCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/lineCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/networkArcRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/networkCircleRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/networkEdgeRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/networkParticleRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/networkRectRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/pointCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/swarmCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/types.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/violinCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/waterfallCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/wedgeCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/useResponsiveSize.d.ts +0 -0
- /package/dist/{types → components/types}/annotationTypes.d.ts +0 -0
- /package/dist/{types → components/types}/generalTypes.d.ts +0 -0
- /package/dist/{types → components/types}/interactionTypes.d.ts +0 -0
- /package/dist/{types → components/types}/networkTypes.d.ts +0 -0
- /package/dist/{types → components/types}/ordinalTypes.d.ts +0 -0
package/dist/semiotic.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react"),t=require("d3-brush"),n=require("d3-selection"),o=require("d3-scale"),r=require("d3-array"),i=require("d3-hierarchy"),a=require("d3-interpolate"),s=require("d3-scale-chromatic"),l=require("d3-force"),c=require("d3-chord"),u=require("d3-shape");function d(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}return t.default=e,Object.freeze(t)}const h=d(e),g=5e3;class p{constructor(e){this.lastBoundedData=null,this.chunkTimer=0,this.callback=e}clearLastData(){this.lastBoundedData=null,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),5e3>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,g),bounded:!0,totalSize:e.length});let t=g;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const o=Math.min(t+g,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}push(e){this.callback({inserts:[e],bounded:!1})}pushMany(e){0!==e.length&&this.callback({inserts:e,bounded:!1})}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null}}class f{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+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 e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}toArray(){const e=[];for(const t of this)e.push(t);return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class y{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function m(e,t,n,o,r){const i=new Map;for(const a of e){const e=t(a),s=n(a);if(null==e||null==s||Number.isNaN(e)||Number.isNaN(s))continue;const l=Math.floor(e/o)*o;let c=i.get(l);if(c||(c={start:l,end:l+o,total:0,categories:new Map},i.set(l,c)),c.total+=s,r){const e=r(a);c.categories.set(e,(c.categories.get(e)||0)+s)}}return i}function v(e,t,n,o,r,i){const a=[],s=[];for(const r of e){const e=n(r),i=o(r);null==e||null==i||Number.isNaN(e)||Number.isNaN(i)||(a.push([t.x(e),t.y(i)]),s.push(i))}return{type:"line",path:a,rawValues:s,style:r,datum:e,group:i}}function b(e,t,n,o,r,i,a,s){const l=[],c=[];for(const i of e){const e=n(i),a=o(i);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const u=t.x(e);l.push([u,t.y(a)]);const d=s?s(i):r;c.push([u,t.y(d)])}return{type:"area",topPath:l,bottomPath:c,style:i,datum:e,group:a}}function x(e,t,n,o,r,i,a){const s=n(e),l=o(e);if(null==s||null==l||Number.isNaN(s)||Number.isNaN(l))return null;const c={type:"point",x:t.x(s),y:t.y(l),r:r,style:i,datum:e};return void 0!==a&&(c.pointId=a),c}function w(e,t,n,o,r,i,a){return{type:"rect",x:e,y:t,w:n,h:o,style:r,datum:i,group:a}}function k(e,t,n,o,r,i){return{type:"heatcell",x:e,y:t,w:n,h:o,fill:r,datum:i}}function A(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function E(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}class S{constructor(e){this.xExtent=new y,this.yExtent=new y,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.scene=[],this.version=0,this.config=e,this.buffer=new f(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=A(e.timeAccessor||e.xAccessor,"time"),this.getY=A(e.valueAccessor||e.yAccessor,"value")):(this.getX=A(e.xAccessor,"x"),this.getY=A(e.yAccessor,"y")),this.getGroup=E(e.groupAccessor),this.getCategory=E(e.categoryAccessor),this.getSize=e.sizeAccessor?A(e.sizeAccessor,"size"):void 0,this.getColor=E(e.colorAccessor),this.getBounds=e.boundsAccessor?A(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?A(e.y0Accessor,"y0"):void 0,this.getPointId=E(e.pointIdAccessor),"candlestick"===e.chartType&&(this.getOpen=A(e.openAccessor,"open"),this.getHigh=A(e.highAccessor,"high"),this.getLow=A(e.lowAccessor,"low"),this.getClose=A(e.closeAccessor,"close")),e.pulse&&(this.timestampBuffer=new f(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,e.bounded){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n)))}else for(const n of e.inserts){"growing"===this.config.windowMode&&this.buffer.full&&(this.growingCap*=2,this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap));const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n))),null!=e&&(this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):this.yExtent.evict(this.getY(e)))}return!0}computeScene(e){var t,n,r,i,a,s;const{config:l,buffer:c}=this;if(this.xExtent.dirty&&this.xExtent.recalculate(c,this.getX),this.yExtent.dirty)if("candlestick"===l.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of c)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(c,this.getY);const u=this.xExtent.extent,d=this.yExtent.extent;let h=l.xExtent?[null!==(t=l.xExtent[0])&&void 0!==t?t:u[0],null!==(n=l.xExtent[1])&&void 0!==n?n:u[1]]:u,g=l.yExtent?[null!==(r=l.yExtent[0])&&void 0!==r?r:d[0],null!==(i=l.yExtent[1])&&void 0!==i?i:d[1]]:d;const p=l.yExtent&&null!=l.yExtent[0]&&null!=l.yExtent[1];if("stackedarea"===l.chartType&&!p&&c.size>0)if(l.normalize)g=[0,1+l.extentPadding];else{const e=c.toArray(),t=this.groupData(e),n=new Map;for(const e of t)for(const t of e.data){const e=this.getX(t),o=this.getY(t);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||n.set(e,(n.get(e)||0)+o)}let o=0;for(const e of n.values())e>o&&(o=e);g=[0,o+(o>0?o*l.extentPadding:1)]}else if("bar"===l.chartType&&l.binSize&&!p&&c.size>0){const[,e]=function(e,t,n,o,r){const i=m(e,t,n,o,r);if(0===i.size)return[0,0];let a=0;for(const e of i.values())e.total>a&&(a=e.total);return[0,a]}(c,this.getX,this.getY,l.binSize,this.getCategory);g=[0,e+e*l.extentPadding]}else if("waterfall"===l.chartType&&!p&&c.size>0){const[e,t]=function(e,t){let n=0,o=0,r=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(r+=e,n>r&&(n=r),r>o&&(o=r))}return[n,o]}(c,this.getY),n=t-e,o=n>0?n*l.extentPadding:1;g=[Math.min(0,e-Math.abs(o)),Math.max(0,t+Math.abs(o))]}else if(!p&&g[0]!==1/0){if(this.getBounds){const e=c.toArray();for(const t of e){const e=this.getY(t),n=this.getBounds(t);null!=e&&!Number.isNaN(e)&&n&&(e+n>g[1]&&(g[1]=e+n),g[0]>e-n&&(g[0]=e-n))}}const e=g[1]-g[0],t=e>0?e*l.extentPadding:1,n=null===(a=l.yExtent)||void 0===a?void 0:a[0],o=null===(s=l.yExtent)||void 0===s?void 0:s[1];g=[null!=n?g[0]:g[0]-t,null!=o?g[1]:g[1]+t]}if(h[0]!==1/0&&h[1]!==-1/0||(h=[0,1]),g[0]!==1/0&&g[1]!==-1/0||(g=[0,1]),void 0!==l.arrowOfTime)if("x"==("up"===(f=l.arrowOfTime)||"down"===f?"y":"x")){const t="right"===l.arrowOfTime?[0,e.width]:[e.width,0];this.scales={x:o.scaleLinear().domain(h).range(t),y:o.scaleLinear().domain(g).range([e.height,0])}}else{const t="down"===l.arrowOfTime?[0,e.height]:[e.height,0];this.scales={x:o.scaleLinear().domain(g).range([0,e.width]),y:o.scaleLinear().domain(h).range(t)}}else this.scales={x:o.scaleLinear().domain(h).range([0,e.width]),y:o.scaleLinear().domain(g).range([e.height,0])};var f;this.config.transition&&this.scene.length>0&&this.snapshotPositions();const y=c.toArray();this.scene=this.buildSceneNodes(e),this.config.decay&&this.applyDecay(this.scene,y),this.config.pulse&&this.applyPulse(this.scene,y),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}buildSceneNodes(e){const{config:t,buffer:n,scales:o}=this;if(!o||0===n.size)return[];const r=n.toArray();switch(t.chartType){case"line":return this.buildLineScene(r);case"area":return this.buildAreaScene(r);case"stackedarea":return this.buildStackedAreaScene(r);case"scatter":case"bubble":return this.buildPointScene(r);case"heatmap":return this.buildHeatmapScene(r,e);case"bar":return this.buildBarScene(r);case"swarm":return this.buildSwarmScene(r);case"waterfall":return this.buildWaterfallScene(r,e);case"candlestick":return this.buildCandlestickScene(r,e);default:return[]}}buildLineScene(e){var t;const n=this.groupData(e),o=[],r=null===(t=this.config.annotations)||void 0===t?void 0:t.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(this.getBounds)for(const e of n){const t=this.buildBoundsForGroup(e.data,e.key);t&&o.push(t)}for(const e of n){const t=this.resolveLineStyle(e.key,e.data[0]),n=v(e.data,this.scales,this.getX,this.getY,t,e.key);r&&r.length>0&&(n.colorThresholds=r),o.push(n)}return o}buildAreaScene(e){const t=this.groupData(e),n=[],o=this.scales.y.domain()[0];for(const e of t){const t=this.resolveAreaStyle(e.key,e.data[0]),r=b(e.data,this.scales,this.getX,this.getY,o,t,e.key,this.getY0);this.config.gradientFill&&(r.fillGradient=this.config.gradientFill),n.push(r)}return n}buildStackedAreaScene(e){const t=this.groupData(e);return t.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0),function(e,t,n,o,r,i){var a;const s=new Set;for(const t of e)for(const e of t.data){const t=n(e);null==t||Number.isNaN(t)||s.add(t)}const l=Array.from(s).sort((e,t)=>e-t),c=new Map;for(const t of e){const e=new Map;for(const r of t.data){const t=n(r),i=o(r);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||e.set(t,(e.get(t)||0)+i)}c.set(t.key,e)}let u;if(i){u=new Map;for(const t of l){let n=0;for(const o of e)n+=(null===(a=c.get(o.key))||void 0===a?void 0:a.get(t))||0;u.set(t,n||1)}}const d=[],h=new Map;for(const e of l)h.set(e,0);for(const n of e){const e=c.get(n.key),o=[],a=[];for(const n of l){let r=e.get(n)||0;const s=h.get(n);i&&(r/=u.get(n));const l=t.x(n);a.push([l,t.y(s)]),o.push([l,t.y(s+r)]),h.set(n,s+r)}d.push({type:"area",topPath:o,bottomPath:a,style:r(n.key,n.data[0]),datum:n.data,group:n.key})}return d}(t,this.scales,this.getX,this.getY,(e,t)=>this.resolveAreaStyle(e,t),this.config.normalize)}buildPointScene(e){const t=[],n="bubble"===this.config.chartType?10:5,o=this.config.sizeRange||[3,15];let r=null;if(this.getSize&&!this.config.pointStyle){const t=e.map(e=>this.getSize(e)).filter(e=>null!=e&&!Number.isNaN(e));if(t.length>0){const e=Math.min(...t),n=Math.max(...t);r=t=>e===n?(o[0]+o[1])/2:o[0]+(t-e)/(n-e)*(o[1]-o[0])}}let i=null;if(this.getColor&&!this.config.pointStyle){const t=new Set;for(const n of e){const e=this.getColor(n);e&&t.add(e)}const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];i=new Map;let o=0;for(const e of t)i.set(e,n[o%n.length]),o++}for(const o of e){let e=this.config.pointStyle?this.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},a=e.r||n;if(r&&this.getSize){const e=this.getSize(o);null==e||Number.isNaN(e)||(a=r(e))}if(i&&this.getColor){const t=this.getColor(o);t&&i.has(t)&&(e=Object.assign(Object.assign({},e),{fill:i.get(t)}))}const s=this.getPointId?this.getPointId(o)+"":void 0,l=x(o,this.scales,this.getX,this.getY,a,e,s);l&&t.push(l)}return t}buildHeatmapScene(e,t){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(e,t);const o=A(this.config.valueAccessor,"value"),r=new Set,i=new Set;for(const t of e)r.add(this.getX(t)),i.add(this.getY(t));const a=Array.from(r).sort((e,t)=>e-t),s=Array.from(i).sort((e,t)=>e-t);if(0===a.length||0===s.length)return n;const l=t.width/a.length,c=t.height/s.length,u=new Map;for(const t of e){const e=`${this.getX(t)}_${this.getY(t)}`;u.set(e,{val:o(t),datum:t})}let d=1/0,h=-1/0;for(const{val:e}of u.values())d>e&&(d=e),e>h&&(h=e);const g=h-d||1;for(let e=0;a.length>e;e++)for(let t=0;s.length>t;t++){const o=u.get(`${a[e]}_${s[t]}`);if(!o)continue;const r=(o.val-d)/g;n.push(k(e*l,(s.length-1-t)*c,l,c,`rgb(${Math.round(220-180*r)},${Math.round(220-100*r)},${Math.round(255-50*r)})`,o.datum))}return n}buildStreamingHeatmapScene(e,t){var n,o,r;const i=[],a=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,s=null!==(o=this.config.heatmapYBins)&&void 0!==o?o:20,l=null!==(r=this.config.heatmapAggregation)&&void 0!==r?r:"count",c=A(this.config.valueAccessor,"value");if(!this.scales||0===e.length)return i;const[u,d]=this.scales.x.domain(),[h,g]=this.scales.y.domain(),p=(d-u||1)/a,f=(g-h||1)/s,y=new Map;for(const t of e){const e=this.getX(t),n=this.getY(t),o=Math.min(Math.floor((e-u)/p),a-1),r=Math.min(Math.floor((n-h)/f),s-1);if(0>o||0>r)continue;const i=`${o}_${r}`;let l=y.get(i);l||(l={sum:0,count:0,data:[]},y.set(i,l)),l.count++,l.sum+=c(t),l.data.push(t)}let m=1/0,v=-1/0;const b=new Map;for(const[e,t]of y){let n;switch(l){case"sum":n=t.sum;break;case"mean":n=t.count>0?t.sum/t.count:0;break;default:n=t.count}b.set(e,n),m>n&&(m=n),n>v&&(v=n)}const x=v-m||1,w=t.width/a,E=t.height/s;for(const[e,t]of b){const[n,o]=e.split("_"),r=+n,a=+o,l=(t-m)/x,c=`rgb(${Math.round(220-180*l)},${Math.round(220-100*l)},${Math.round(255-50*l)})`,u=y.get(e);i.push(k(r*w,(s-1-a)*E,w,E,c,{xi:r,yi:a,value:t,count:u.count,sum:u.sum,data:u.data}))}return i}buildBarScene(e){var t;if(!this.config.binSize)return[];const n=m(e,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===n.size)return[];let o=null;if(this.getCategory){const e=new Set;for(const t of n.values())for(const n of t.categories.keys())e.add(n);const t=this.config.barColors?Object.keys(this.config.barColors):[],r=new Set(t),i=Array.from(e).filter(e=>!r.has(e)).sort();o=[...t.filter(t=>e.has(t)),...i]}const r=[],i=this.scales,[a,s]=i.x.domain();for(const e of n.values()){const n=Math.max(e.start,a),l=Math.min(e.end,s);if(n>=l)continue;const c=i.x(n),u=i.x(l),d=Math.min(c,u)+.5,h=Math.max(c,u)-.5-d;if(h>0)if(o&&e.categories.size>0){let n=0;for(const a of o){const o=e.categories.get(a)||0;if(0===o)continue;const s=i.y(n),l=i.y(n+o);r.push(w(d,Math.min(s,l),h,Math.abs(s-l),{fill:(null===(t=this.config.barColors)||void 0===t?void 0:t[a])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:a,categoryValue:o},a)),n+=o}}else{const t=i.y(0),n=i.y(e.total);r.push(w(d,Math.min(t,n),h,Math.abs(t-n),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}return r}buildSwarmScene(e){var t,n,o,r;const i=[],a=this.config.swarmStyle||{},s=null!==(t=a.radius)&&void 0!==t?t:3,l=null!==(n=a.fill)&&void 0!==n?n:"#007bff",c=null!==(o=a.opacity)&&void 0!==o?o:.7,u=a.stroke,d=a.strokeWidth;for(const t of e){const e=this.getX(t),n=this.getY(t);if(null==n||Number.isNaN(n))continue;const o=this.scales.x(e),a=this.scales.y(n);let h=l;if(this.getCategory){const e=this.getCategory(t);h=(null===(r=this.config.barColors)||void 0===r?void 0:r[e])||h}const g={type:"point",x:o,y:a,r:s,style:{fill:h,opacity:c,stroke:u,strokeWidth:d},datum:t};this.getPointId&&(g.pointId=this.getPointId(t)+""),i.push(g)}return i}buildWaterfallScene(e,t){var n,o,r;const i=[],a=this.scales,s=this.config.waterfallStyle,l=e.filter(e=>{const t=this.getY(e);return null!=t&&!Number.isNaN(t)});if(0===l.length)return i;const c=null!==(n=null==s?void 0:s.positiveColor)&&void 0!==n?n:"#28a745",u=null!==(o=null==s?void 0:s.negativeColor)&&void 0!==o?o:"#dc3545",d=null!==(r=null==s?void 0:s.gap)&&void 0!==r?r:1,h=null==s?void 0:s.stroke,g=null==s?void 0:s.strokeWidth;let p=0;for(let e=0;l.length>e;e++){const n=l[e],o=this.getX(n),r=this.getY(n),f=p+r;let y;y=l.length-1>e?this.getX(l[e+1])-o:e>0?o-this.getX(l[e-1]):0;const m=a.x(o),v=0!==y?a.x(o+y):m+t.width/10,b=Math.min(m,v)+d/2,x=Math.max(m,v)-d/2-b;if(0>=x){p=f;continue}const k=a.y(p),A=a.y(f);i.push(w(b,Math.min(k,A),x,Math.abs(k-A),{fill:0>r?u:c,stroke:h,strokeWidth:g},Object.assign(Object.assign({},n),{baseline:p,cumEnd:f,delta:r,_connectorStroke:null==s?void 0:s.connectorStroke,_connectorWidth:null==s?void 0:s.connectorWidth}))),p=f}return i}buildCandlestickScene(e,t){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],o=this.config.candlestickStyle||{},r=o.upColor||"#28a745",i=o.downColor||"#dc3545",a=o.wickColor||"#333",s=o.wickWidth||1,l=e.map(e=>this.getX(e)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let c=o.bodyWidth||6;if(!o.bodyWidth&&l.length>1){let e=1/0;for(let t=1;l.length>t;t++){const n=Math.abs(this.scales.x(l[t])-this.scales.x(l[t-1]));n>0&&e>n&&(e=n)}e!==1/0&&(c=Math.max(2,Math.min(.6*e,20)))}for(const t of e){const e=this.getX(t);if(null==e||Number.isNaN(e))continue;const o=this.getOpen(t),l=this.getHigh(t),u=this.getLow(t),d=this.getClose(t);if([o,l,u,d].some(e=>null==e||Number.isNaN(e)))continue;const h=d>=o;n.push({type:"candlestick",x:this.scales.x(e),openY:this.scales.y(o),closeY:this.scales.y(d),highY:this.scales.y(l),lowY:this.scales.y(u),bodyWidth:c,upColor:r,downColor:i,wickColor:a,wickWidth:s,isUp:h,datum:t})}return n}buildBoundsForGroup(e,t){if(!this.getBounds||!this.scales)return null;const n=[],o=[];for(const t of e){const e=this.getX(t),r=this.getY(t);if(null==e||null==r||Number.isNaN(e)||Number.isNaN(r))continue;const i=this.getBounds(t),a=this.scales.x(e);if(i&&0!==i)n.push([a,this.scales.y(r+i)]),o.push([a,this.scales.y(r-i)]);else{const e=this.scales.y(r);n.push([a,e]),o.push([a,e])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:o,style:this.resolveBoundsStyle(t,e[0]),datum:e,group:t,interactive:!1}}resolveBoundsStyle(e,t){const n=this.config.boundsStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(e,t).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){var n,o,r;const i=this.config.decay;if(!i||1>=t)return 1;const a=null!==(n=i.minOpacity)&&void 0!==n?n:.1,s=t-1-e;switch(i.type){case"linear":return a+(1-s/(t-1))*(1-a);case"exponential":{const e=null!==(o=i.halfLife)&&void 0!==o?o:t/2;return a+Math.pow(.5,s/e)*(1-a)}case"step":return(null!==(r=i.stepThreshold)&&void 0!==r?r:.5*t)>s?1:a;default:return 1}}applyDecay(e,t){var n,o;if(!this.config.decay)return;const r=t.length;if(1>=r)return;const i=new Map;for(let e=0;t.length>e;e++)i.set(t[e],e);for(const t of e){if("line"===t.type||"area"===t.type)continue;const e=i.get(t.datum);if(null==e)continue;const a=this.computeDecayOpacity(e,r);if("heatcell"===t.type)t.style={opacity:a};else if("candlestick"===t.type)t._decayOpacity=a;else{const e=null!==(o=null===(n=t.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:e*a})}}}computePulseIntensity(e,t){var n;const o=this.config.pulse;if(!o)return 0;const r=null!==(n=o.duration)&&void 0!==n?n:500,i=t-e;return r>i?1-i/r:0}applyPulse(e,t){var n,o;if(!this.config.pulse||!this.timestampBuffer)return;const r="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",a=null!==(o=this.config.pulse.glowRadius)&&void 0!==o?o:4,s=new Map;for(let e=0;t.length>e;e++)s.set(t[e],e);for(const t of e){if("line"===t.type||"area"===t.type)continue;const e=s.get(t.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const o=this.computePulseIntensity(n,r);o>0&&(t._pulseIntensity=o,t._pulseColor=i,t._pulseGlowRadius=a)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}snapshotPositions(){this.prevPositionMap.clear();for(let e=0;this.scene.length>e;e++){const t=this.scene[e],n=this.getNodeIdentity(t,e);n&&("point"===t.type?this.prevPositionMap.set(n,{x:t.x,y:t.y,r:t.r}):"rect"===t.type||"heatcell"===t.type?this.prevPositionMap.set(n,{x:t.x,y:t.y,w:t.w,h:t.h}):"candlestick"===t.type&&this.prevPositionMap.set(n,{x:t.x,y:t.openY}))}}getNodeIdentity(e,t){var n,o,r,i;switch(e.type){case"point":return`p:${void 0===e.datum?t:this.getX(e.datum)}_${this.getY(e.datum)}`;case"rect":return`r:${e.group||""}:${null!==(i=null!==(o=null===(n=e.datum)||void 0===n?void 0:n.binStart)&&void 0!==o?o:null===(r=e.datum)||void 0===r?void 0:r.category)&&void 0!==i?i:t}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return"c:"+this.getX(e.datum);default:return null}}startTransition(){var e,t,n,o,r,i;if(!this.config.transition||0===this.prevPositionMap.size)return;const a=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;let s=!1;for(let e=0;this.scene.length>e;e++){const a=this.scene[e],l=this.getNodeIdentity(a,e);if(!l)continue;const c=this.prevPositionMap.get(l);if(c)if("point"===a.type){const e={x:a.x,y:a.y,r:a.r};c.x===e.x&&c.y===e.y||(a._targetX=e.x,a._targetY=e.y,a._targetR=e.r,a.x=c.x,a.y=c.y,a.r=null!==(t=c.r)&&void 0!==t?t:a.r,s=!0)}else if("rect"===a.type){const e={x:a.x,y:a.y,w:a.w,h:a.h};c.x===e.x&&c.y===e.y&&c.w===e.w&&c.h===e.h||(a._targetX=e.x,a._targetY=e.y,a._targetW=e.w,a._targetH=e.h,a.x=c.x,a.y=c.y,a.w=null!==(n=c.w)&&void 0!==n?n:a.w,a.h=null!==(o=c.h)&&void 0!==o?o:a.h,s=!0)}else if("heatcell"===a.type){const e={x:a.x,y:a.y,w:a.w,h:a.h};c.x===e.x&&c.y===e.y||(a._targetX=e.x,a._targetY=e.y,a._targetW=e.w,a._targetH=e.h,a.x=c.x,a.y=c.y,a.w=null!==(r=c.w)&&void 0!==r?r:a.w,a.h=null!==(i=c.h)&&void 0!==i?i:a.h,s=!0)}}s&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:a})}advanceTransition(e){var t;if(!this.activeTransition)return!1;const n=Math.min((e-this.activeTransition.startTime)/this.activeTransition.duration,1),o="linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?n:1-Math.pow(1-n,3);for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==e._targetR&&void 0!==n.r&&(e.r=n.r+(e._targetR-n.r)*o)}else if("rect"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==n.w&&(e.w=n.w+(e._targetW-n.w)*o),void 0!==n.h&&(e.h=n.h+(e._targetH-n.h)*o)}else if("heatcell"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==n.w&&(e.w=n.w+(e._targetW-n.w)*o),void 0!==n.h&&(e.h=n.h+(e._targetH-n.h)*o)}if(n>=1){for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}return this.activeTransition=null,!1}return!0}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const n of e){const e=this.getGroup(n);t.has(e)||t.set(e,[]),t.get(e).push(n)}return Array.from(t.entries()).map(([e,t])=>({key:e,data:t}))}resolveLineStyle(e,t){const n=this.config.lineStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?{stroke:n.stroke||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var n;if(this.config.areaStyle)return this.config.areaStyle(t||{});const o=this.config.lineStyle;return"function"==typeof o?o(t||{},e):o&&"object"==typeof o?{fill:o.fill||o.stroke||"#4e79a7",fillOpacity:null!==(n=o.fillOpacity)&&void 0!==n?n:.7,stroke:o.stroke||"#4e79a7",strokeWidth:o.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(e){Object.assign(this.config,e)}}function O(e,t,n){const o=t-e.x,r=n-e.y,i=Math.sqrt(o*o+r*r);return i>e.r+5?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:i}}function L(e,t,n){if(0===e.path.length)return null;const o=N(e.path,t);if(0>o)return null;const[r,i]=e.path[o],a=t-r,s=n-i,l=Math.sqrt(a*a+s*s);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:r,y:i,distance:l}}function M(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{node:e,datum:e.datum,x:e.x+e.w/2,y:e.y+e.h/2,distance:0}}function j(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{node:e,datum:e.datum,x:e.x+e.w/2,y:e.y+e.h/2,distance:0}}function P(e,t,n){const o=e.bodyWidth/2,r=Math.min(e.openY,e.closeY);if(!(e.x-o-3>t||t>e.x+o+3||e.highY-3>n||n>e.lowY+3)){const o=r+Math.max(Math.max(e.openY,e.closeY)-r,1)/2,i=t-e.x,a=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(i*i+a*a)}}return null}function C(e,t,n){if(0===e.topPath.length)return null;const o=N(e.topPath,t);if(0>o)return null;const[r,i]=e.topPath[o],a=t-r,s=n-i;return{node:e,datum:e.datum,x:r,y:i,distance:Math.sqrt(a*a+s*s)}}function N(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const r=n+o>>1;t>e[r][0]?n=r+1:o=r}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}function D(e,t,n){switch(e){case"ArrowRight":case"ArrowDown":return n-1>t?t+1:t;case"ArrowLeft":case"ArrowUp":return t>0?t-1:t;case"Home":return 0;case"End":return n-1;case"Escape":return-1;default:return null}}function T(e){return{data:e.datum,x:e.x,y:e.y,time:e.x,value:e.y}}function B(t,n,o){const r=e.useRef(null),[i,a]=e.useState(null);return e.useEffect(()=>{if(!n&&!o)return;const e=r.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;a(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[n,o]),[r,[n&&i?i.w:t[0],o&&i?i.h:t[1]]]}const H={fill:e=>h.createElement("rect",{style:e,width:20,height:20}),line:e=>h.createElement("line",{style:e,x1:0,y1:0,x2:20,y2:20})};function W(e,t,n,o){let r;return r="function"==typeof n?n(e):(0,H[n])(o(e,t)),r}function R(e){const{legendGroups:t,customClickBehavior:n,title:o="Legend",width:r=100,height:i=20,orientation:a="vertical"}=e,s="vertical"===a?(({legendGroups:e,width:t,customClickBehavior:n})=>{let o=30;const r=[];return e.forEach((e,i)=>{o+=5,r.push(h.createElement("line",{key:"legend-top-line legend-symbol-"+i,stroke:"gray",x1:0,y1:o,x2:t,y2:o})),o+=10,e.label&&(o+=20,r.push(h.createElement("text",{key:"legend-text-"+i,y:o,className:"legend-group-label"},e.label)),o+=10),r.push(h.createElement("g",{key:"legend-group-"+i,className:"legend-item",transform:`translate(0,${o})`},((e,t)=>{const{type:n="fill",styleFn:o,items:r}=e,i=[];let a=0;return r.forEach((e,r)=>{const s=W(e,r,n,o);i.push(h.createElement("g",{key:"legend-item-"+r,transform:`translate(0,${a})`,onClick:t?()=>t(e):void 0,style:{cursor:t?"pointer":"default"}},s,h.createElement("text",{y:15,x:30},e.label))),a+=25}),i})(e,n))),o+=25*e.items.length+10}),r})({legendGroups:t,width:r,customClickBehavior:n}):(({legendGroups:e,title:t,height:n,customClickBehavior:o})=>{let r=0;const i=[],a=!1===t?10:40;return e.forEach((t,s)=>{t.label&&(i.push(h.createElement("text",{key:"legend-text-"+s,transform:`translate(${r},${a}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},t.label)),r+=20);const l=((e,t)=>{const{type:n="fill",styleFn:o,items:r}=e,i=[];let a=0;return r.forEach((e,r)=>{const s=W(e,r,n,o);i.push(h.createElement("g",{key:"legend-item-"+r,transform:`translate(${a},0)`,onClick:t?()=>t(e):void 0,style:{cursor:t?"pointer":"default"}},s,h.createElement("text",{y:15,x:25},e.label))),a+=35,a+=8*e.label.length}),{items:i,offset:a}})(t,o);i.push(h.createElement("g",{key:"legend-group-"+s,className:"legend-item",transform:`translate(${r},${a})`},l.items)),r+=l.offset+5,e[s+1]&&i.push(h.createElement("line",{key:"legend-top-line legend-symbol-"+s,stroke:"gray",x1:r,y1:a-10,x2:r,y2:n+a+10})),r+=15}),h.createElement("g",null,!1!==t&&h.createElement("line",{x1:0,x2:r+10,y1:a-10,y2:a-10,stroke:"gray",className:"title-neatline"}),i)})({legendGroups:t,title:o,height:i,customClickBehavior:n});return h.createElement("g",null,void 0!==o&&h.createElement("text",{className:"legend-title",y:20,x:"horizontal"===a?0:r/2,textAnchor:"horizontal"===a?"start":"middle"},o),s)}function $(e){return"string"==typeof e?{type:e}:e}function _({orient:t,config:n,values:o,scale:i,size:a,length:s}){const l=function(e){var t,n,o,r,i;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(n=e.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(o=e.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(r=e.stroke)&&void 0!==r?r:"none",strokeWidth:null!==(i=e.strokeWidth)&&void 0!==i?i:1}}(n),c="top"===t||"bottom"===t,u=e.useMemo(()=>{if(0===o.length)return null;const e=i.domain(),n=a-8;if("boxplot"===l.type){const e=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],r=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],a=i-o;return{q1:o,median:r,q3:i,whiskerLow:Math.max(t[0],o-1.5*a),whiskerHigh:Math.min(t[n-1],i+1.5*a)}}(o);if(!e)return null;const{q1:r,median:a,q3:s,whiskerLow:u,whiskerHigh:d}=e,g=Math.min(.5*n,20),p=(n-g)/2+4;if(c){const e=i(r),n=i(s),o=i(a),c=i(u),f=i(d),y="top"===t?-1:1,m=0;return h.createElement("g",{"data-testid":"marginal-boxplot-"+t},h.createElement("line",{x1:c,y1:m+y*(p+g/2),x2:f,y2:m+y*(p+g/2),stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:c,y1:m+y*p,x2:c,y2:m+y*(p+g),stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:f,y1:m+y*p,x2:f,y2:m+y*(p+g),stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("rect",{x:Math.min(e,n),y:"top"===t?m-p-g:m+p,width:Math.abs(n-e),height:g,fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:o,y1:"top"===t?m-p-g:m+p,x2:o,y2:"top"===t?m-p:m+p+g,stroke:l.fill,strokeWidth:2}))}{const e=i(r),n=i(s),o=i(a),c=i(u),f=i(d),y="left"===t?-1:1,m=0;return h.createElement("g",{"data-testid":"marginal-boxplot-"+t},h.createElement("line",{x1:m+y*(p+g/2),y1:c,x2:m+y*(p+g/2),y2:f,stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:m+y*p,y1:c,x2:m+y*(p+g),y2:c,stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:m+y*p,y1:f,x2:m+y*(p+g),y2:f,stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("rect",{x:"left"===t?m-p-g:m+p,y:Math.min(e,n),width:g,height:Math.abs(n-e),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:"left"===t?m-p-g:m+p,y1:o,x2:"left"===t?m-p:m+p+g,y2:o,stroke:l.fill,strokeWidth:2}))}}const u=r.bin().domain(e).thresholds(l.bins)(o);if(0===u.length)return null;const d=Math.max(...u.map(e=>e.length));if(0===d)return null;if("histogram"===l.type)return h.createElement("g",{"data-testid":"marginal-histogram-"+t},u.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const r=e.length/d*n;if(c){const n=i(e.x0),a=i(e.x1)-i(e.x0);return h.createElement("rect",{key:o,x:n,y:"top"===t?-4-r:4,width:Math.max(a,.5),height:r,fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}{const n=i(e.x0),a=i(e.x1)-i(e.x0);return h.createElement("rect",{key:o,x:"left"===t?-4-r:4,y:Math.min(n,n+a),width:r,height:Math.abs(a),fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}}));if("violin"===l.type){const e=n/2+4,o=[];for(const r of u){if(null==r.x0||null==r.x1)continue;const a=r.length/d*(n/2),s=i((r.x0+r.x1)/2);o.push(c?`${s},${"top"===t?-(e-a):e-a}`:`${"left"===t?-(e-a):e-a},${s}`)}for(let r=u.length-1;r>=0;r--){const a=u[r];if(null==a.x0||null==a.x1)continue;const s=a.length/d*(n/2),l=i((a.x0+a.x1)/2);o.push(c?`${l},${"top"===t?-(e+s):e+s}`:`${"left"===t?-(e+s):e+s},${l}`)}return h.createElement("g",{"data-testid":"marginal-violin-"+t},h.createElement("polygon",{points:o.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}if("ridgeline"===l.type){const e=[];if(c){const o=0,r=null!=u[0].x0?i(u[0].x0):0;e.push(`M${r},${o}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const r=o.length/d*n,a=i((o.x0+o.x1)/2);e.push(`L${a},${"top"===t?-r-4:r+4}`)}const a=null!=u[u.length-1].x1?i(u[u.length-1].x1):s;e.push(`L${a},${o}`),e.push("Z")}else{const o=0,r=null!=u[0].x0?i(u[0].x0):0;e.push(`M${o},${r}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const r=o.length/d*n,a=i((o.x0+o.x1)/2);e.push(`L${"left"===t?-r-4:r+4},${a}`)}const a=null!=u[u.length-1].x1?i(u[u.length-1].x1):s;e.push(`L${o},${a}`),e.push("Z")}return h.createElement("g",{"data-testid":"marginal-ridgeline-"+t},h.createElement("path",{d:e.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}return null},[o,i,l,a,s,t,c,4]);return u?h.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},u):null}function z(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=e.split(/\s+/),i=[];let a="";for(const e of r)a&&a.length+1+e.length>o?(i.push(a),a=e):a=a?`${a} ${e}`:e;return a&&i.push(a),i}function I(e,t,n,o){return"curly"===e?o?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:o?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function F(e){const{x:t=0,y:n=0,dx:o,dy:r,nx:i,ny:a,note:s,connector:l,subject:c,type:u,color:d,className:g,disable:p,events:f={},"data-testid":y}=e,m=new Set(Array.isArray(p)?p:[]);let v=o||0,b=r||0;null!=i&&(v=i-t),null!=a&&(b=a-n);const x="string"==typeof u?u:"label";if("bracket"===x&&c&&0===v&&0===b)if(void 0!==c.width){v=c.width/2;const e=c.depth||30;b=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;v=e+(0>e?-5:5),b=c.height/2}return h.createElement("g",Object.assign({className:("annotation "+(g||"")).trim(),transform:`translate(${t},${n})`,"data-testid":y},f),!m.has("connector")&&function(e,t,n,o,r,i){const a=[];let s=0,l=0;if("callout-circle"!==r&&"label"!==r||!(null==i?void 0:i.radius)){if("callout-rect"===r&&i){const n=i.width||0,o=i.height||0;if(n>0||o>0){const r=n/2,i=o/2,a=e-r,c=t-i;if(0!==a||0!==c){const e=Math.abs(a),t=Math.abs(c),u=n/2,d=o/2,h=e*d>t*u?u/e:d/t;s=r+a*h,l=i+c*h}}}else if("bracket"===r&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(s=e/2,l=n):void 0!==t&&(s=n,l=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const o=Math.atan2(t,e);s=Math.cos(o)*n,l=Math.sin(o)*n}}if(Math.sqrt(Math.pow(e-s,2)+Math.pow(t-l,2))>.5&&(a.push(h.createElement("line",{key:"connector-line",x1:s,y1:l,x2:e,y2:t,stroke:o||"currentColor"})),"arrow"===(null==n?void 0:n.end))){const n=10,r=16/180*Math.PI,i=Math.atan2(t-l,e-s);a.push(h.createElement("path",{key:"connector-arrow",d:`M${s},${l}L${s+n*Math.cos(i+r)},${l+n*Math.sin(i+r)}L${s+n*Math.cos(i-r)},${l+n*Math.sin(i-r)}Z`,fill:o||"currentColor",stroke:"none"}))}return h.createElement("g",{className:"annotation-connector"},a)}(v,b,l,d,x,c),!m.has("subject")&&function(e,t,n,o,r){var i;const a=[];switch(e){case"callout-circle":{const e=((null==t?void 0:t.radius)||0)+((null==t?void 0:t.radiusPadding)||0);e>0&&a.push(h.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:n||"currentColor"}));break}case"callout-rect":{const e=(null==t?void 0:t.width)||0,o=(null==t?void 0:t.height)||0;(e>0||o>0)&&a.push(h.createElement("rect",{key:"subject-rect",width:e,height:o,fill:"none",stroke:n||"currentColor"}));break}case"callout-custom":(null==t?void 0:t.custom)&&a.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=o||0,i=r||0;if(void 0!==(null==t?void 0:t.x)){const o=(t.x||0)-e;a.push(h.createElement("line",{key:"threshold-line",x1:o,y1:(t.y1||0)-i,x2:o,y2:(t.y2||0)-i,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==t?void 0:t.y)){const o=(t.y||0)-i;a.push(h.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:o,x2:(t.x2||0)-e,y2:o,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==t?void 0:t.x1)||void 0!==(null==t?void 0:t.x2)?a.push(h.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"currentColor",strokeDasharray:"5,5"})):void 0===(null==t?void 0:t.y1)&&void 0===(null==t?void 0:t.y2)||a.push(h.createElement("line",{key:"threshold-line",x1:0,y1:(t.y1||0)-i,x2:0,y2:(t.y2||0)-i,stroke:n||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(i=null==t?void 0:t.width)&&void 0!==i?i:null==t?void 0:t.height;void 0!==e&&a.push(h.createElement("path",{key:"bracket-path",d:I((null==t?void 0:t.type)||"curly",e,(null==t?void 0:t.depth)||30,void 0===(null==t?void 0:t.width)),fill:"none",stroke:n||"currentColor"}));break}}return h.createElement("g",{className:"annotation-subject"},a)}(x,c,d,t,n),!m.has("note")&&function(e,t,n,o){if(!e)return h.createElement("g",{className:"annotation-note"});const{label:r,title:i,orientation:a,align:s,wrap:l=120,noWrap:c}=e;if(!r&&!i)return h.createElement("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=s;d&&"dynamic"!==d||(d="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let g="start";"topBottom"===u?"right"===d?g="end":"middle"===d&&(g="middle"):g=0>t?"end":"start";const p=16,f=i?c?[i]:z(i,l):[],y=r?c?[r]:z(r,l):[],m="leftRight"===u?"end"===g?-4:4:0;let v=0;const b=[];f.length>0&&(b.push(h.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:o||void 0,textAnchor:g,fontWeight:"bold"},f.map((e,t)=>h.createElement("tspan",{key:t,x:m,dy:0===t?0:p},e)))),v=f.length*p),y.length>0&&b.push(h.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:o||void 0,textAnchor:g,y:v},y.map((e,t)=>h.createElement("tspan",{key:t,x:m,dy:0===t?0:p},e))));let x=null;if((i||r)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(l,120);let t=0,n=e;"end"===g?(t=-e,n=0):"middle"===g&&(t=-e/2,n=e/2),x=h.createElement("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"currentColor"})}else{const e=(f.length+y.length)*p+(y.length>0?p:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),x=h.createElement("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:o||"currentColor"})}const w=Math.max(0,f.length+y.length-1)*p;let k=0;return"topBottom"===u?k=0>n?-(w+2):18:"leftRight"===u&&(k="middle"===d?-(w+p+(y.length>0&&f.length>0?2:0))/2+8:"bottom"===d||0>n?-(w+2):18),h.createElement("g",{className:"annotation-note",transform:`translate(${t},${n})`},h.createElement("g",{className:"annotation-note-content",transform:0!==k?`translate(0,${k})`:void 0},b),x)}(s,v,b,d))}function Y(e){var t,n;const{noteData:o}=e,{screenCoordinates:r}=o,i="string"==typeof o.type?o.type:"label",a=o.eventListeners||o.events||{};if(o.coordinates&&r){const e=o.nx||r[0][0]+(null!==(t=o.dx)&&void 0!==t?t:0),a=o.ny||r[0][1]+(null!==(n=o.dy)&&void 0!==n?n:0),s=r.map((t,n)=>{const r=Object.assign({},o,{note:0===n?o.note:{label:""},x:t[0],y:t[1],nx:e,ny:a});return h.createElement(F,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},r,{type:i}))});return h.createElement("g",null,s)}const s=o.note||{title:"none",label:o.label};return h.createElement(F,Object.assign({"data-testid":"semiotic-annotation",key:`${s.label}-${s.title}-${o.i}`,events:a},o,{type:i}))}function G(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function X(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function q(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function V(e){return function(e,t,n){var o,r,a,s,l,c,u,d,g,p,f,y,m,v,b,x,w,k,A,E,S,O,L,M,j,P,C,N,D,T,B,H,W,R,$,_,z,I,F;switch(e.type){case"label":{let o=null,r=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);if(!t)return null;o=t.x,r=t.y}else o=G(e,n),r=X(e,n);return null==o||null==r?null:q(o,r,n)?h.createElement(Y,{key:"ann-"+t,noteData:{x:o,y:r,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"label",connector:e.connector||{end:"arrow"},color:e.color}}):null}case"callout":{let o=null,r=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);if(!t)return null;o=t.x,r=t.y}else o=G(e,n),r=X(e,n);return null==o||null==r?null:q(o,r,n)?h.createElement(Y,{key:"ann-"+t,noteData:{x:o,y:r,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"callout-circle",subject:{radius:e.radius||12},connector:e.connector||{end:"arrow"},color:e.color}}):null}case"x-threshold":{const o=G(e,n);if(null==o)return null;const r=e.color||"#f97316";return h.createElement("g",{key:"ann-"+t},h.createElement("line",{x1:o,y1:0,x2:o,y2:n.height||0,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&h.createElement("text",{x:o+4,y:12,fill:r,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const o=X(e,n);if(null==o)return null;const r=e.color||"#f97316";return h.createElement("g",{key:"ann-"+t},h.createElement("line",{x1:0,y1:o,x2:n.width||0,y2:o,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&h.createElement("text",{x:(n.width||0)-4,y:o-4,textAnchor:"end",fill:r,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const o=(e.coordinates||[]).map(e=>({x:G(Object.assign(Object.assign({},e),{type:"point"}),n),y:X(Object.assign(Object.assign({},e),{type:"point"}),n),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const r=i.packEnclose(o),a=e.padding||10;return h.createElement("g",{key:"ann-"+t},h.createElement("circle",{cx:r.x,cy:r.y,r:r.r+a,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&h.createElement("text",{x:r.x,y:r.y-r.r-a-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"rect-enclose":{const o=(e.coordinates||[]).map(e=>({x:G(Object.assign(Object.assign({},e),{type:"point"}),n),y:X(Object.assign(Object.assign({},e),{type:"point"}),n)})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const r=e.padding||10,i=o.map(e=>e.x),a=o.map(e=>e.y),s=Math.min(...i)-r,l=Math.max(...i)+r,c=Math.min(...a)-r,u=Math.max(...a)+r;return h.createElement("g",{key:"ann-"+t},h.createElement("rect",{x:s,y:c,width:l-s,height:u-c,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&h.createElement("text",{x:(s+l)/2,y:c-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"highlight":{const o=n.data||[],r="function"==typeof e.filter?o.filter(e.filter):e.field&&null!=e.value?o.filter(t=>t[e.field]===e.value):[],i=e.style||{stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return h.createElement("g",{key:"ann-"+t},r.map((t,o)=>{const r=G(t,n),a=X(t,n);return null==r||null==a?null:h.createElement("circle",Object.assign({key:o,cx:r,cy:a,r:e.r||6},i))}))}case"bracket":{const o=G(e,n),r=X(e,n);return h.createElement(Y,{key:"ann-"+t,noteData:{x:null!=o?o:0,y:null!=r?r:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}})}case"trend":{const i=n.data||[];if(2>i.length)return null;const d=n.xAccessor||"x",g=n.yAccessor||"y",p=i.map(e=>[e[d],e[g]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>p.length)return null;const f=null!==(r=null===(o=n.scales)||void 0===o?void 0:o.x)&&void 0!==r?r:null===(a=n.scales)||void 0===a?void 0:a.time,y=null!==(l=null===(s=n.scales)||void 0===s?void 0:s.y)&&void 0!==l?l:null===(c=n.scales)||void 0===c?void 0:c.value;if(!f||!y)return null;const m=e.method||"linear";let v;if("loess"===m)v=function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),r=o.map(e=>e[0]),i=o.map(e=>e[1]),a=Math.max(2,Math.ceil(t*n)),s=[];for(let e=0;n>e;e++){const t=r[e],o=r.map(e=>Math.abs(e-t)),l=o.slice().sort((e,t)=>e-t)[Math.min(a-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:o[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,g=0,p=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*r[e],h+=t*i[e],g+=t*r[e]*r[e],p+=t*r[e]*i[e])}if(0===u){s.push([t,i[e]]);continue}const f=u*g-d*d;if(1e-12>Math.abs(f))s.push([t,h/u]);else{const e=(u*p-d*h)/f;s.push([t,(h-e*d)/u+e*t])}}return s}(p,null!==(u=e.bandwidth)&&void 0!==u?u:.3);else{let t;try{const n=require("regression");t="polynomial"===m?n.polynomial(p,{order:e.order||2}):n.linear(p)}catch(e){return null}v=t.points}const b=v.map(([e,t])=>`${f(e)},${y(t)}`).join(" "),x=e.color||"#6366f1";return h.createElement("g",{key:"ann-"+t},h.createElement("polyline",{points:b,fill:"none",stroke:x,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&h.createElement("text",{x:f(v[v.length-1][0])+4,y:y(v[v.length-1][1])-4,fill:x,fontSize:11},e.label))}case"band":{const o=null!==(g=null===(d=n.scales)||void 0===d?void 0:d.y)&&void 0!==g?g:null===(p=n.scales)||void 0===p?void 0:p.value,r=null!==(f=null==o?void 0:o(e.y0))&&void 0!==f?f:0,i=null!==(y=null==o?void 0:o(e.y1))&&void 0!==y?y:n.height||0;return h.createElement("g",{key:"ann-"+t},h.createElement("rect",{x:0,y:Math.min(r,i),width:n.width||0,height:Math.abs(i-r),fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity||.1}),e.label&&h.createElement("text",{x:(n.width||0)-4,y:Math.min(r,i)-4,textAnchor:"end",fill:e.color||"#6366f1",fontSize:11},e.label))}case"envelope":{const o=n.data||[];if(2>o.length)return null;const r=n.xAccessor||"x",i=null!==(v=null===(m=n.scales)||void 0===m?void 0:m.x)&&void 0!==v?v:null===(b=n.scales)||void 0===b?void 0:b.time,a=null!==(w=null===(x=n.scales)||void 0===x?void 0:x.y)&&void 0!==w?w:null===(k=n.scales)||void 0===k?void 0:k.value;if(!i||!a)return null;const s=e.upperAccessor||"upperBounds",l=e.lowerAccessor||"lowerBounds",c=e.filter,u=o.filter(e=>null!=e[s]&&null!=e[l]&&!(c&&!c(e))).sort((e,t)=>e[r]-t[r]);if(2>u.length)return null;const d=u.map(e=>`${i(e[r])},${a(e[s])}`).join(" L"),g=u.slice().reverse().map(e=>`${i(e[r])},${a(e[l])}`).join(" L"),p=e.fill||"#6366f1";return h.createElement("g",{key:"ann-"+t},h.createElement("path",{d:`M${d} L${g} Z`,fill:p,fillOpacity:null!==(A=e.fillOpacity)&&void 0!==A?A:.15,stroke:"none"}),e.label&&u.length>0&&h.createElement("text",{x:i(u[u.length-1][r])+4,y:a(u[u.length-1][s])-4,fill:p,fontSize:11},e.label))}case"anomaly-band":{const o=n.data||[];if(2>o.length)return null;const r=n.yAccessor||"y",i=null!==(S=null===(E=n.scales)||void 0===E?void 0:E.x)&&void 0!==S?S:null===(O=n.scales)||void 0===O?void 0:O.time,a=null!==(M=null===(L=n.scales)||void 0===L?void 0:L.y)&&void 0!==M?M:null===(j=n.scales)||void 0===j?void 0:j.value;if(!i||!a)return null;const s=o.map(e=>e[r]).filter(e=>null!=e&&isFinite(e));if(2>s.length)return null;const l=s.reduce((e,t)=>e+t,0)/s.length,c=s.reduce((e,t)=>e+Math.pow(t-l,2),0)/s.length,u=Math.sqrt(c),d=null!==(P=e.threshold)&&void 0!==P?P:2,g=l-d*u,p=!1!==e.showBand,f=e.fill||"#6366f1",y=null!==(C=e.fillOpacity)&&void 0!==C?C:.1,m=e.anomalyColor||"#ef4444",v=null!==(N=e.anomalyRadius)&&void 0!==N?N:6,b=a(l+d*u),x=a(g),w=o.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-l)>d*u});return h.createElement("g",{key:"ann-"+t},p&&h.createElement("rect",{x:0,y:Math.min(b,x),width:n.width||0,height:Math.abs(x-b),fill:f,fillOpacity:y}),w.map((e,t)=>{const o=G(e,n),r=X(e,n);return null==o||null==r?null:h.createElement("circle",{key:t,cx:o,cy:r,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5})}),e.label&&h.createElement("text",{x:(n.width||0)-4,y:Math.min(b,x)-4,textAnchor:"end",fill:f,fontSize:11},e.label))}case"forecast":{const o=n.data||[];if(3>o.length)return null;const r=n.xAccessor||"x",i=n.yAccessor||"y",a=null!==(T=null===(D=n.scales)||void 0===D?void 0:D.x)&&void 0!==T?T:null===(B=n.scales)||void 0===B?void 0:B.time,s=null!==(W=null===(H=n.scales)||void 0===H?void 0:H.y)&&void 0!==W?W:null===(R=n.scales)||void 0===R?void 0:R.value;if(!a||!s)return null;const l=o.map(e=>[e[r],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>l.length)return null;let c;if("polynomial"===(e.method||"linear"))try{const t=require("regression").polynomial(l,{order:e.order||2}).equation;c=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}catch(e){return null}else{const e=l.length;let t=0,n=0,o=0,r=0;for(const[e,i]of l)t+=e,n+=i,o+=e*e,r+=e*i;const i=e*o-t*t;if(1e-12>Math.abs(i))return null;const a=(e*r-t*n)/i,s=(n-a*t)/e;c=e=>s+a*e}const u=l.length,d=l.map(([e,t])=>t-c(e)).reduce((e,t)=>e+t*t,0),g=Math.sqrt(d/Math.max(u-2,1)),p=l.reduce((e,t)=>e+t[0],0)/u,f=l.reduce((e,t)=>e+Math.pow(t[0]-p,2),0),y=null!==($=e.confidence)&&void 0!==$?$:.95,m=.99>y?.95>y?.9>y?1:1.645:1.96:2.576,v=null!==(_=e.steps)&&void 0!==_?_:5,b=l[u-1][0],x=(b-l[0][0])/Math.max(u-1,1),w=[];for(let e=1;v>=e;e++)w.push(b+e*x);const k=[];for(const e of w){const t=c(e),n=g*Math.sqrt(1+1/u+(f>0?Math.pow(e-p,2)/f:0))*m;k.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const A=`M${k.map(e=>`${a(e.x)},${s(e.yUpper)}`).join(" L")} L${k.slice().reverse().map(e=>`${a(e.x)},${s(e.yLower)}`).join(" L")} Z`,E=k.map(e=>`${a(e.x)},${s(e.yCenter)}`).join(" "),S=`${a(b)},${s(c(b))}`,O=e.strokeColor||"#6366f1";return h.createElement("g",{key:"ann-"+t},h.createElement("path",{d:A,fill:e.fill||"#6366f1",fillOpacity:null!==(z=e.fillOpacity)&&void 0!==z?z:.15,stroke:"none"}),h.createElement("polyline",{points:`${S} ${E}`,fill:"none",stroke:O,strokeWidth:null!==(I=e.strokeWidth)&&void 0!==I?I:2,strokeDasharray:null!==(F=e.strokeDasharray)&&void 0!==F?F:"6,3"}),e.label&&k.length>0&&h.createElement("text",{x:a(k[k.length-1].x)+4,y:s(k[k.length-1].yCenter)-4,fill:O,fontSize:11},e.label))}default:return null}}}function U(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,r="left"===e?-1:1,i=Math.ceil(t/8);let a="M0,"+o;for(let e=0;i>e;e++){const n=8*(e+1);a+=`L${Math.min(8*e+4,t)},${o+4*r}`,a+=`L${Math.min(n,t)},${o}`}return a}{const o="bottom"===e?0:t,r="bottom"===e?1:-1,i=Math.ceil(n/8);let a=`M${o},0`;for(let e=0;i>e;e++){const t=8*(e+1);a+=`L${o+4*r},${Math.min(8*e+4,n)}`,a+=`L${o},${Math.min(t,n)}`}return a}}function Z(e){return Math.round(100*e)/100+""}function Q(t){const{width:n,height:o,totalWidth:r,totalHeight:i,margin:a,scales:s,showAxes:l,axes:c,xLabel:u,yLabel:d,xFormat:g,yFormat:p,showGrid:f,title:y,legend:m,foregroundGraphics:v,marginalGraphics:b,xValues:x,yValues:w,annotations:k,svgAnnotationRules:A,annotationFrame:E,xAccessor:S,yAccessor:O,annotationData:L,pointNodes:M,children:j}=t,P=e.useMemo(()=>l&&s?s.x.ticks(5).map(e=>({value:e,pixel:s.x(e),label:(g||Z)(e)})):[],[l,s,g]),C=e.useMemo(()=>l&&s?s.y.ticks(5).map(e=>({value:e,pixel:s.y(e),label:(p||Z)(e)})):[],[l,s,p]),N=e.useMemo(()=>{if(!k||0===k.length)return null;const e=V(),t={scales:s?{x:s.x,y:s.y,time:s.x,value:s.y}:null,timeAxis:"x",xAccessor:S,yAccessor:O,width:n,height:o,data:L,frameType:"xy",pointNodes:M};return k.map((n,o)=>{if(A){const r=A(n,o,t);return null!=r?r:e(n,o,t)}return e(n,o,t)}).filter(Boolean)},[k,A,n,o,E,S,O,L]);return l||y||m||v||b||N&&N.length>0||f||j?h.createElement("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},h.createElement("g",{transform:`translate(${a.left},${a.top})`},f&&s&&h.createElement("g",{className:"stream-grid"},P.map((e,t)=>h.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),C.map((e,t)=>h.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:n,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),l&&s&&(()=>{const e=null==c?void 0:c.find(e=>"left"===e.orient),t=null==c?void 0:c.find(e=>"bottom"===e.orient),r=!e||!1!==e.baseline,i=(null==e?void 0:e.jaggedBase)||!1,s=(null==t?void 0:t.jaggedBase)||!1,l="var(--semiotic-border, #ccc)",g="var(--semiotic-text-secondary, #666)",p="var(--semiotic-text, #333)";return h.createElement("g",{className:"stream-axes"},(!t||!1!==t.baseline)&&!s&&h.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:l,strokeWidth:1}),s&&h.createElement("path",{d:U("bottom",n,o),fill:"none",stroke:l,strokeWidth:1}),P.map((e,t)=>h.createElement("g",{key:"xtick-"+t,transform:`translate(${e.pixel},${o})`},h.createElement("line",{y2:5,stroke:l,strokeWidth:1}),h.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:g,style:{userSelect:"none"}},e.label))),u&&h.createElement("text",{x:n/2,y:o+40,textAnchor:"middle",fontSize:12,fill:p,style:{userSelect:"none"}},u),r&&!i&&h.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:l,strokeWidth:1}),i&&h.createElement("path",{d:U("left",n,o),fill:"none",stroke:l,strokeWidth:1}),C.map((e,t)=>h.createElement("g",{key:"ytick-"+t,transform:`translate(0,${e.pixel})`},h.createElement("line",{x2:-5,stroke:l,strokeWidth:1}),h.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:g,style:{userSelect:"none"}},e.label))),d&&h.createElement("text",{x:15-a.left,y:o/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(-90, ${15-a.left}, ${o/2})`,style:{userSelect:"none"}},d))})(),N,b&&s&&x&&w&&h.createElement(h.Fragment,null,b.top&&h.createElement("g",{transform:"translate(0, 0)"},h.createElement(_,{orient:"top",config:$(b.top),values:x,scale:s.x,size:a.top,length:n})),b.bottom&&h.createElement("g",{transform:`translate(0, ${o})`},h.createElement(_,{orient:"bottom",config:$(b.bottom),values:x,scale:s.x,size:a.bottom,length:n})),b.left&&h.createElement("g",{transform:"translate(0, 0)"},h.createElement(_,{orient:"left",config:$(b.left),values:w,scale:s.y,size:a.left,length:o})),b.right&&h.createElement("g",{transform:`translate(${n}, 0)`},h.createElement(_,{orient:"right",config:$(b.right),values:w,scale:s.y,size:a.right,length:o}))),v,j),y&&h.createElement("text",{x:r/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof y?y:null),m&&h.createElement("g",{transform:`translate(${r-a.right+10}, ${a.top})`},function(e){return"object"==typeof e&&null!==e&&!h.isValidElement(e)&&"legendGroups"in e}(m)?h.createElement(R,{legendGroups:m.legendGroups,title:"",width:100}):m)):null}function K(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}function J(e){if(e.startsWith("#")){const t=4===e.length?e[1]+e[1]+e[2]+e[2]+e[3]+e[3]:e.slice(1,7);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[78,121,167]}const ee=(e,t,n,o)=>{var r;const i=t.filter(e=>"area"===e.type);for(const t of i){if(2>t.topPath.length)continue;e.beginPath();const[n,o]=t.topPath[0];e.moveTo(n,o);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath();const i=t.style.fill||"#4e79a7";if(t.fillGradient){const n=Math.min(...t.topPath.map(e=>e[1])),o=Math.max(...t.bottomPath.map(e=>e[1])),r=e.createLinearGradient(0,n,0,o);r.addColorStop(0,i),r.addColorStop(1,i),e.fillStyle=r;const a=J(i),s=t.fillGradient.topOpacity,l=t.fillGradient.bottomOpacity,c=e.createLinearGradient(0,n,0,o);c.addColorStop(0,`rgba(${a[0]},${a[1]},${a[2]},${s})`),c.addColorStop(1,`rgba(${a[0]},${a[1]},${a[2]},${l})`),e.fillStyle=c,e.globalAlpha=1}else{const n=null!==(r=t.style.fillOpacity)&&void 0!==r?r:.7;e.globalAlpha=n,e.fillStyle=i}if(e.fill(),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=1,e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]),e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);e.stroke()}e.globalAlpha=1}},te=(e,t,n,o)=>{var r,i;const a=t.filter(e=>"point"===e.type);for(const t of a){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(r=t.style.opacity)&&void 0!==r?r:t.style.fillOpacity;if(null!=n&&(e.globalAlpha=n),e.fillStyle=t.style.fill||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0){const n=null!==(i=t._pulseGlowRadius)&&void 0!==i?i:4,o=t.r+n*t._pulseIntensity;e.beginPath(),e.arc(t.x,t.y,o,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=.6*t._pulseIntensity,e.stroke()}e.globalAlpha=1}},ne=(e,t,n,o)=>{const r=t.filter(e=>"rect"===e.type);for(const t of r)null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon?oe(e,t):(e.fillStyle=t.style.fill||"#007bff",e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.globalAlpha=1};function oe(e,t){const n=t.style.icon,o=t.style.iconPadding||2,r=Math.min(t.w,t.w)-o;if(0>=r)return;const i=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),i){const i=r+o,a=t.x+(t.w-r)/2;for(let o=t.y+t.h-r;o>=t.y-r;o-=i)e.drawImage(n,a,o,r,r)}else{const i=r+o,a=t.y+(t.h-r)/2;for(let o=t.x;t.x+t.w>o;o+=i)e.drawImage(n,o,a,r,r)}e.restore()}const re={line:[ee,(e,t,n,o)=>{const r=t.filter(e=>"line"===e.type);for(const i of r){if(2>i.path.length)continue;const a=i.style.stroke||"#007bff",s=i.style.strokeWidth||2,l=i.colorThresholds,c=i.rawValues;if(e.setLineDash(i.style.strokeDasharray?i.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=i.style.opacity&&(e.globalAlpha=i.style.opacity),e.lineWidth=s,l&&0!==l.length&&c&&c.length===i.path.length){let u=null,d=null,h=null,g=null,p=!1;function f(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),p=!0}function y(){p&&(e.stroke(),p=!1)}for(let m=0;i.path.length>m;m++){const[v,b]=i.path[m],x=c[m],w=K(x,l,a);if(null!==u&&null!==g&&null!==h){if(w===g)e.lineTo(v,b);else{const k=[];for(const A of l){const E=A.value;(h>E||E>x)&&(E>h||x>E)||h===E||x===E||k.push({t:(E-h)/(x-h)})}k.sort((e,t)=>e.t-t.t);for(const S of k){const O=u+(v-u)*S.t,L=d+(b-d)*S.t,M=K(h+(x-h)*Math.min(S.t+1e-4,1),l,a);e.lineTo(O,L),y(),f(M,O,L)}e.lineTo(v,b)}u=v,d=b,h=x,g=w}else f(w,v,b),u=v,d=b,h=x,g=w}y()}else{e.beginPath(),e.strokeStyle=a;const[j,P]=i.path[0];e.moveTo(j,P);for(let C=1;i.path.length>C;C++)e.lineTo(i.path[C][0],i.path[C][1]);e.stroke()}if(i.style.fill&&i.style.fillOpacity&&i.style.fillOpacity>0){e.beginPath(),e.globalAlpha=i.style.fillOpacity,e.fillStyle=i.style.fill;const[N,D]=i.path[0];e.moveTo(N,D);for(let B=1;i.path.length>B;B++)e.lineTo(i.path[B][0],i.path[B][1]);const T=i.path[0][0];e.lineTo(i.path[i.path.length-1][0],o.height),e.lineTo(T,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([])}}],area:[ee],stackedarea:[ee],scatter:[te],bubble:[te],heatmap:[(e,t,n,o)=>{const r=t.filter(e=>"heatcell"===e.type);for(const t of r){const n=t.style;null!=(null==n?void 0:n.opacity)&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle="#fff",e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.globalAlpha=1}}],bar:[ne],swarm:[te],waterfall:[(e,t,n,o)=>{var r,i,a;ne(e,t);const s=t.filter(e=>"rect"===e.type);if(2>s.length)return;const l=s[0].datum,c=null==l?void 0:l._connectorStroke;if(c){e.save(),e.strokeStyle=c,e.lineWidth=null!==(r=null==l?void 0:l._connectorWidth)&&void 0!==r?r:1,e.setLineDash([]);for(let t=0;s.length-1>t;t++){const o=s[t],r=s[t+1];if(!(null===(i=o.datum)||void 0===i?void 0:i.cumEnd)||!(null===(a=r.datum)||void 0===a?void 0:a.baseline))continue;const l=n.y(o.datum.cumEnd),c=o.x+o.w,u=r.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[(e,t,n,o)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=t.wickColor,e.lineWidth=t.wickWidth,e.stroke();const o=Math.min(t.openY,t.closeY),r=Math.abs(t.openY-t.closeY),i=t.isUp?t.upColor:t.downColor;e.fillStyle=i,e.fillRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(r,1)),e.strokeStyle=i,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(r,1))}}]},ie={top:20,right:20,bottom:30,left:40},ae={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white"},se={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function le({hover:e}){const t=e=>Number.isInteger(e)?e+"":e.toFixed(2);return h.createElement("div",{className:"semiotic-tooltip",style:se},h.createElement("div",{style:{fontWeight:600,marginBottom:2}},t(e.value)),h.createElement("div",{style:{opacity:.7,fontSize:11}},t(e.time)))}function ce({width:o,height:r,totalWidth:i,totalHeight:a,margin:s,dimension:l,scales:c,onBrush:u}){const d=e.useRef(null),g=e.useRef(null);return e.useEffect(()=>{if(!d.current)return;const e=n.select(d.current).select(".brush-g"),i="x"===l?t.brushX():"y"===l?t.brushY():t.brush();return i.extent([[0,0],[o,r]]),i.on("brush end",e=>{if(!c)return;if(!e.selection)return void u(null);let t,n;if("x"===l){const[o,i]=e.selection;t=[c.x.invert(o),c.x.invert(i)],n=[c.y.invert(r),c.y.invert(0)]}else if("y"===l){const[r,i]=e.selection;t=[c.x.invert(0),c.x.invert(o)],n=[c.y.invert(i),c.y.invert(r)]}else{const[[o,r],[i,a]]=e.selection;t=[c.x.invert(o),c.x.invert(i)],n=[c.y.invert(a),c.y.invert(r)]}u({x:t,y:n})}),e.call(i),g.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),g.current=null}},[o,r,l,c,u]),h.createElement("svg",{ref:d,width:i,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},h.createElement("g",{className:"brush-g",transform:`translate(${s.left},${s.top})`}))}const ue=e.forwardRef(function(t,n){var o,r,i;const{chartType:a,runtimeMode:s,data:l,xAccessor:c,yAccessor:u,colorAccessor:d,sizeAccessor:g,groupAccessor:f,lineDataAccessor:y,normalize:m,binSize:v,valueAccessor:b,arrowOfTime:x="right",windowMode:w="sliding",windowSize:k=200,timeAccessor:A,xExtent:E,yExtent:N,extentPadding:H=.1,sizeRange:W,size:R=[500,300],responsiveWidth:$,responsiveHeight:_,margin:z,className:I,background:F,lineStyle:Y,pointStyle:G,areaStyle:X,waterfallStyle:q,swarmStyle:V,barColors:U,colorScheme:Z,boundsAccessor:K,boundsStyle:J,y0Accessor:ee,gradientFill:te,openAccessor:ne,highAccessor:oe,lowAccessor:se,closeAccessor:ue,candlestickStyle:de,showAxes:he=!0,axes:ge,xLabel:pe,yLabel:fe,xFormat:ye,yFormat:me,tickFormatTime:ve,tickFormatValue:be,hoverAnnotation:xe,tooltipContent:we,customHoverBehavior:ke,enableHover:Ae,annotations:Ee,svgAnnotationRules:Se,showGrid:Oe,legend:Le,backgroundGraphics:Me,foregroundGraphics:je,title:Pe,categoryAccessor:Ce,brush:Ne,onBrush:De,decay:Te,pulse:Be,transition:He,staleness:We,heatmapAggregation:Re,heatmapXBins:$e,heatmapYBins:_e,marginalGraphics:ze,pointIdAccessor:Ie}=t,[Fe,Ye]=B(R,$,_),Ge=Object.assign(Object.assign({},ie),z);if(ze){const e=60;ze.top&&e>Ge.top&&(Ge.top=e),ze.bottom&&e>Ge.bottom&&(Ge.bottom=e),ze.left&&e>Ge.left&&(Ge.left=e),ze.right&&e>Ge.right&&(Ge.right=e)}const Xe=Ye[0]-Ge.left-Ge.right,qe=Ye[1]-Ge.top-Ge.bottom,Ve=null!=xe?xe:Ae,Ue=e.useRef(null),Ze=e.useRef(0),Qe=e.useRef(!1),[Ke,Je]=e.useState(0),[et,tt]=e.useState(null),nt=e.useRef(null),ot=e.useRef(null),[rt,it]=e.useState(null),[at,st]=e.useState(!1),[lt,ct]=e.useState([]),[ut,dt]=e.useState([]),ht=e.useRef(()=>{}),gt="streaming"===s||["bar","swarm","waterfall"].includes(a),pt=e.useMemo(()=>({chartType:a,runtimeMode:gt?"streaming":"bounded",windowSize:k,windowMode:w,arrowOfTime:gt?x:"right",extentPadding:H,xAccessor:gt?void 0:c,yAccessor:gt?void 0:u,timeAccessor:gt?A:void 0,valueAccessor:b,colorAccessor:d,sizeAccessor:g,groupAccessor:f,categoryAccessor:Ce,lineDataAccessor:y,xExtent:E,yExtent:N,sizeRange:W,binSize:v,normalize:m,boundsAccessor:K,boundsStyle:J,y0Accessor:ee,gradientFill:"boolean"==typeof te?te?{topOpacity:.8,bottomOpacity:.05}:void 0:te,openAccessor:ne,highAccessor:oe,lowAccessor:se,closeAccessor:ue,candlestickStyle:de,lineStyle:Y,pointStyle:G,areaStyle:X,swarmStyle:V,waterfallStyle:q,colorScheme:Z,barColors:U,annotations:Ee,decay:Te,pulse:Be,transition:He,staleness:We,heatmapAggregation:Re,heatmapXBins:$e,heatmapYBins:_e,pointIdAccessor:Ie}),[a,k,w,x,H,c,u,A,b,d,g,f,Ce,y,E,N,W,v,m,K,J,ee,te,ne,oe,se,ue,de,Y,G,X,V,q,Z,U,Ee,Te,Be,He,We,Re,$e,_e,gt,Ie]),ft=e.useRef(null);ft.current||(ft.current=new S(pt));const yt=e.useCallback(()=>{Ze.current||(Ze.current=requestAnimationFrame(()=>ht.current()))},[]);e.useEffect(()=>{var e;null===(e=ft.current)||void 0===e||e.updateConfig(pt),Qe.current=!0,yt()},[pt,yt]);const mt=e.useRef(null);mt.current||(mt.current=new p(e=>{const t=ft.current;t&&t.ingest(e)&&(Qe.current=!0,yt())}));const vt=e.useCallback(e=>{var t;null===(t=mt.current)||void 0===t||t.push(e)},[]),bt=e.useCallback(e=>{var t;null===(t=mt.current)||void 0===t||t.pushMany(e)},[]),xt=e.useCallback(()=>{var e,t;null===(e=mt.current)||void 0===e||e.clear(),null===(t=ft.current)||void 0===t||t.clear(),Qe.current=!0,yt()},[yt]);e.useImperativeHandle(n,()=>({push:vt,pushMany:bt,clear:xt,getData:()=>{var e,t;return null!==(t=null===(e=ft.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=ft.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=ft.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[vt,bt,xt]),e.useEffect(()=>{var e;l&&(null===(e=mt.current)||void 0===e||e.setBoundedData(l))},[l]);const wt=e.useRef(()=>{}),kt=e.useRef(()=>{});wt.current=e=>{if(!Ve)return;const t=Ue.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Ge.left,r=e.clientY-n.top-Ge.top;if(0>o||o>Xe||0>r||r>qe)return void(nt.current&&(nt.current=null,ot.current=null,it(null),ke&&(ke(null),Qe.current=!0),yt()));const i=ft.current;if(!i||0===i.scene.length)return;const a=function(e,t,n,o=30){let r=null;for(const i of e){let e=null;switch(i.type){case"point":e=O(i,t,n);break;case"line":e=L(i,t,n);break;case"rect":e=M(i,t,n);break;case"heatcell":e=j(i,t,n);break;case"area":if(!1===i.interactive)break;e=C(i,t,n);break;case"candlestick":e=P(i,t,n)}e&&o>e.distance&&(r&&e.distance>=r.distance||(r=e))}return r}(i.scene,o,r);if(!a)return void(nt.current&&(nt.current=null,ot.current=null,it(null),ke&&ke(null),yt()));const s={data:a.datum,time:a.x,value:a.y,x:a.x,y:a.y};nt.current=s,ot.current=a.node,it(s),ke&&(ke(s),Qe.current=!0),yt()},kt.current=()=>{nt.current&&(nt.current=null,ot.current=null,it(null),ke&&(ke(null),Qe.current=!0),yt())},e.useCallback(e=>wt.current(e),[]);const At=e.useCallback(()=>kt.current(),[]),Et=e.useRef(-1),St=e.useCallback(e=>{const t=ft.current;if(!t||0===t.scene.length)return;const n=function(e){const t=[];for(const n of e)switch(n.type){case"point":t.push({x:n.x,y:n.y,datum:n.datum});break;case"line":{const e=n,o=Array.isArray(e.datum)?e.datum:[];for(let n=0;e.path.length>n&&o.length>n;n++)t.push({x:e.path[n][0],y:e.path[n][1],datum:o[n]});break}case"area":{const e=n,o=Array.isArray(e.datum)?e.datum:[];for(let n=0;e.topPath.length>n&&o.length>n;n++)t.push({x:e.topPath[n][0],y:e.topPath[n][1],datum:o[n]});break}case"rect":case"heatcell":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.scene);if(0===n.length)return;const o=0>Et.current?-1:Et.current,r=D(e.key,0>o?-1:o,n.length);if(null===r)return;if(e.preventDefault(),0>r)return Et.current=-1,nt.current=null,ot.current=null,it(null),ke&&ke(null),void yt();const i=0>o?0:r;Et.current=i;const a=T(n[i]);nt.current=a,it(a),ke&&ke(a),yt()},[ke,yt]),Ot=e.useCallback(e=>{Et.current=-1,wt.current(e)},[]);ht.current=()=>{var e,t;Ze.current=0;const n=Ue.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const r=ft.current;if(!r)return;const i="undefined"!=typeof performance?performance.now():Date.now(),s=r.advanceTransition(i);s||r.computeScene({width:Xe,height:qe});const l="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=Ye[0]*l,n.height=Ye[1]*l,n.style.width=Ye[0]+"px",n.style.height=Ye[1]+"px",o.scale(l,l),o.translate(Ge.left,Ge.top),o.clearRect(-Ge.left,-Ge.top,Ye[0],Ye[1]);const d=function(e){if(!e)return ae;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),r=t.getPropertyValue("--semiotic-bg").trim(),i=o||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),s=n||t.getPropertyValue("--surface-3").trim(),l=r||t.getPropertyValue("--surface-0").trim();return i||a||n?{axisStroke:s||ae.axisStroke,tickText:i||ae.tickText,crosshair:i?i+"66":ae.crosshair,hoverFill:l?l+"4D":ae.hoverFill,hoverStroke:i?i+"99":ae.hoverStroke,pointRing:l||ae.pointRing}:ae}(n),h=null!==(e=null==We?void 0:We.threshold)&&void 0!==e?e:5e3,g=We&&r.lastIngestTime>0&&i-r.lastIngestTime>h;g&&(o.globalAlpha=null!==(t=null==We?void 0:We.dimOpacity)&&void 0!==t?t:.5);const p=n?getComputedStyle(n).getPropertyValue("--semiotic-bg").trim():"",f=F||(p&&"transparent"!==p?p:null);f&&(o.fillStyle=f,o.fillRect(-Ge.left,-Ge.top,Ye[0],Ye[1])),o.save(),"function"==typeof o.rect&&(o.beginPath(),o.rect(0,0,Xe,qe),o.clip());const y=re[a];if(y&&r.scales)for(const e of y)e(o,r.scene,r.scales,{width:Xe,height:qe});if(o.restore(),g&&(o.globalAlpha=1),Ve&&nt.current&&r.scales&&function(e,t,n,o,r,i,a){if(!1===r.crosshair)return;e.save();const s="object"==typeof r.crosshair?r.crosshair:{};e.strokeStyle=s.stroke||a.crosshair,e.lineWidth=s.strokeWidth||1,e.setLineDash(s.strokeDasharray?s.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(t.x,0),e.lineTo(t.x,o),e.stroke(),e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke(),e.restore(),e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle="#007bff",e.fill(),e.strokeStyle=a.pointRing,e.lineWidth=2,e.stroke()}(o,nt.current,Xe,qe,"object"==typeof Ve?Ve:{},0,d),ot.current&&Array.isArray(xe)){const e=xe.find(e=>e&&"object"==typeof e&&"highlight"===e.type);e&&function(e,t,n,o){var r;if(!n)return;const i=n.group;if(void 0!==i)for(const n of t){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const t="function"==typeof o.style?o.style(n.datum):o.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||"#007bff",e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=null!==(r=t.opacity)&&void 0!==r?r:1,e.stroke(),e.restore()}}(o,r.scene,ot.current,e)}const m=Qe.current;if(Qe.current=!1,m&&r.scales&&(tt(r.scales),ze)){const e=r.getData(),t="function"==typeof c?c:e=>e[c||"x"],n="function"==typeof u?u:e=>e[u||"y"];ct(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),dt(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}m&&Ee&&Ee.length>0&&Je(e=>e+1),(null==We?void 0:We.showBadge)&&st(!!g),(s||r.hasActivePulses)&&(Ze.current=requestAnimationFrame(()=>ht.current()))},e.useEffect(()=>(yt(),()=>{Ze.current&&(cancelAnimationFrame(Ze.current),Ze.current=0)}),[yt]),e.useEffect(()=>{Qe.current=!0,yt()},[a,Xe,qe,he,F,Y,yt]),e.useEffect(()=>{if(!We)return;const e=setInterval(()=>{var e;const t=ft.current;if(!t||0===t.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=We.threshold)&&void 0!==e?e:5e3,r=n-t.lastIngestTime>o;r!==at&&(st(r),Qe.current=!0,yt())},1e3);return()=>clearInterval(e)},[We,at,yt]);const Lt=Ve&&rt?we?we(rt):h.createElement(le,{hover:rt}):null,Mt=Lt?h.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:Ge.left+rt.x,top:Ge.top+rt.y,transform:`translate(${rt.x>.7*Xe?"calc(-100% - 12px)":"12px"}, ${.3*qe>rt.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},Lt):null,jt=Et.current>=0&&rt?h.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Ye[0],height:Ye[1],pointerEvents:"none",zIndex:2}},h.createElement("circle",{cx:rt.x+Ge.left,cy:rt.y+Ge.top,r:8,fill:"none",stroke:"var(--accent, #6366f1)",strokeWidth:2,strokeDasharray:"4,2"})):null;return h.createElement("div",{ref:Fe,className:"stream-xy-frame"+(I?" "+I:""),role:"img","aria-label":"string"==typeof Pe?Pe:"XY chart",tabIndex:0,style:{position:"relative",width:$?"100%":Ye[0],height:_?"100%":Ye[1]},onMouseMove:Ve?Ot:void 0,onMouseLeave:Ve?At:void 0,onKeyDown:St},Me&&h.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Ye[0],height:Ye[1],pointerEvents:"none"}},Me),h.createElement("canvas",{ref:Ue,style:{position:"absolute",left:0,top:0}}),h.createElement(Q,{width:Xe,height:qe,totalWidth:Ye[0],totalHeight:Ye[1],margin:Ge,scales:et,showAxes:he,axes:ge,xLabel:pe,yLabel:fe,xFormat:ye||ve,yFormat:me||be,showGrid:Oe,title:Pe,legend:Le,foregroundGraphics:je,marginalGraphics:ze,xValues:lt,yValues:ut,annotations:Ee,svgAnnotationRules:Se,annotationFrame:Ke,xAccessor:"string"==typeof c?c:"string"==typeof A?A:void 0,yAccessor:"string"==typeof u?u:"string"==typeof b?b:void 0,annotationData:null===(o=ft.current)||void 0===o?void 0:o.getData(),pointNodes:null===(r=ft.current)||void 0===r?void 0:r.scene.filter(e=>"point"===e.type)}),(Ne||De)&&h.createElement(ce,{width:Xe,height:qe,totalWidth:Ye[0],totalHeight:Ye[1],margin:Ge,dimension:null!==(i=null==Ne?void 0:Ne.dimension)&&void 0!==i?i:"xy",scales:et,onBrush:null!=De?De:()=>{}}),(null==We?void 0:We.showBadge)&&h.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===We.badgePosition?{top:4,left:4}:"bottom-left"===We.badgePosition?{bottom:4,left:4}:"bottom-right"===We.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:at?"#dc3545":"#28a745",color:"white"})},at?"STALE":"LIVE"),jt,Mt)});function de(e,t){const{columns:n,config:o,resolvePieceStyle:r}=e,i=[],a=Math.min(t.width,t.height)/2-4,s="donut"===o.chartType?o.innerRadius||60:0,l=-Math.PI/2+(o.startAngle||0)*Math.PI/180,c=2*Math.PI;for(const e of Object.values(n)){const t=l+e.pctStart*c,n=l+(e.pctStart+e.pct)*c,o=r(e.pieceData[0],e.name);i.push({type:"wedge",cx:0,cy:0,innerRadius:s,outerRadius:a,startAngle:t,endAngle:n,style:o,datum:e.pieceData,category:e.name})}return i}function he(e){var t,n,o;const i=e.length,a=e[0],s=e[i-1];return{n:i,min:a,q1:null!==(t=r.quantile(e,.25))&&void 0!==t?t:a,median:null!==(n=r.quantile(e,.5))&&void 0!==n?n:(a+s)/2,q3:null!==(o=r.quantile(e,.75))&&void 0!==o?o:s,max:s,mean:e.reduce((e,t)=>e+t,0)/i}}ue.displayName="StreamXYFrame";const ge={bar:function(e,t){const{scales:n,columns:o,config:r,getR:i,getStack:a,resolvePieceStyle:s}=e,{r:l,projection:c}=n,u=[],d="vertical"===c,h="horizontal"===c,g=r.normalize;for(const e of Object.values(o)){const t=new Map;for(const n of e.pieceData){const e=a?a(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const o=t.get(e);o.total+=i(n),o.pieces.push(n)}let n=0;if(g)for(const e of t.values())n+=Math.abs(e.total);let o=0,r=0;for(const[i,c]of t){let t=c.total;g&&n>0&&(t/=n);const p=s(c.pieces[0],a?i:e.name),f=Object.assign(Object.assign({},c.pieces[0]),{__aggregateValue:c.total,__pieceCount:c.pieces.length,category:e.name});if(d){const n=l(0>t?r:o+t),a=0>t?l(r+t)-l(r):l(o)-l(o+t);u.push(w(e.x,n,e.width,Math.abs(a),p,f,i)),0>t?r+=t:o+=t}else if(h){const n=l(0>t?r+t:o),a=0>t?l(r)-l(r+t):l(o+t)-l(o);u.push(w(n,e.x,Math.abs(a),e.width,p,f,i)),0>t?r+=t:o+=t}}}return u},clusterbar:function(e,t){const{scales:n,columns:o,getR:r,getGroup:i,resolvePieceStyle:a}=e,{r:s,projection:l}=n,c=[],u="vertical"===l,d=[],h=new Set;for(const e of Object.values(o))for(const t of e.pieceData){const e=i?i(t):"_default";h.has(e)||(h.add(e),d.push(e))}const g=d.length||1;for(const e of Object.values(o)){const t=e.width/g,n=new Map;for(const t of e.pieceData){const e=i?i(t):"_default";n.has(e)||n.set(e,[]),n.get(e).push(t)}for(let o=0;d.length>o;o++){const i=n.get(d[o])||[];for(const n of i){const i=r(n),l=a(n,e.name);if(u){const r=e.x+o*t,a=s(0),u=s(i);c.push(w(r,Math.min(a,u),t,Math.abs(a-u),l,n,d[o]))}else{const r=e.x+o*t,a=s(0),u=s(i);c.push(w(Math.min(a,u),r,Math.abs(u-a),t,l,n,d[o]))}}}}return c},point:function(e,t){var n,o;const{scales:r,columns:i,getR:a,multiScales:s,resolvePieceStyle:l}=e,{r:c,projection:u}=r,d=[],h="vertical"===u,g="radial"===u,p=s.length>0,f=2*Math.PI,y=-Math.PI/2;for(const e of Object.values(i))for(const t of e.pieceData){const r=null!==(n=t.__rIndex)&&void 0!==n?n:0,i=null!==(o=t.__rValue)&&void 0!==o?o:a(t),u=p&&s[r]||c,m=l(t,e.name),v=m.r||5;let b,x;if(g){const t=y+(e.pctStart+e.pct/2)*f,n=u(i);b=Math.cos(t)*n,x=Math.sin(t)*n}else h?(b=e.middle,x=u(i)):(b=u(i),x=e.middle);d.push({type:"point",x:b,y:x,r:v,style:m,datum:t})}return d},swarm:function(e,t){const{scales:n,columns:o,getR:r,resolvePieceStyle:i}=e,{r:a,projection:s}=n,l=[],c="vertical"===s;for(const e of Object.values(o)){const t=e.width/2;for(let n=0;e.pieceData.length>n;n++){const o=e.pieceData[n],s=r(o),u=i(o,e.name),d=u.r||4,h=(7919*n%100/100-.5)*t*.8,g=c?e.middle+h:a(s),p=c?a(s):e.middle+h;l.push({type:"point",x:g,y:p,r:d,style:u,datum:o})}}return l},pie:de,donut:de,boxplot:function(e,t){var n,o,i,a,s;const{scales:l,columns:c,config:u,getR:d,resolveSummaryStyle:h}=e,{r:g,projection:p}=l,f=[],y="vertical"===p,m=!1!==u.showOutliers;for(const e of Object.values(c)){const t=e.pieceData.map(e=>d(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===t.length)continue;const l=t[0],c=t[t.length-1],u=null!==(n=r.quantile(t,.25))&&void 0!==n?n:l,p=null!==(o=r.quantile(t,.5))&&void 0!==o?o:(l+c)/2,v=null!==(i=r.quantile(t,.75))&&void 0!==i?i:c,b=v-u,x=u-1.5*b,w=v+1.5*b,k=null!==(a=t.find(e=>e>=x))&&void 0!==a?a:l,A=null!==(s=[...t].reverse().find(e=>w>=e))&&void 0!==s?s:c,E=h(e.pieceData[0],e.name),S=[];if(m)for(const t of e.pieceData){const n=d(t);if(x>n||n>w){const o=y?e.middle:g(n),r=y?g(n):e.middle;S.push({px:o,py:r,value:n,datum:t})}}if(f.push({type:"boxplot",x:y?e.middle:0,y:y?0:e.middle,projection:y?"vertical":"horizontal",columnWidth:.6*e.width,minPos:g(k),q1Pos:g(u),medianPos:g(p),q3Pos:g(v),maxPos:g(A),stats:{min:k,q1:u,median:p,q3:v,max:A},style:E,datum:e.pieceData,category:e.name,outliers:S}),m)for(const e of S)f.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:E.fill||"#999",opacity:.6},datum:e.datum})}return f},violin:function(e,t){var n,o,i;const{scales:a,columns:s,config:l,getR:c,resolveSummaryStyle:u}=e,{r:d,projection:h}=a,g=[],p="vertical"===h,f=l.bins||20,y=!1!==l.showIQR;for(const e of Object.values(s)){const t=e.pieceData.map(e=>c(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const a=t[0],s=t[t.length-1],l=(s-a)/f||1,h=Array(f).fill(0);for(const e of t)h[Math.min(Math.floor((e-a)/l),f-1)]++;const m=Math.max(...h,1),v=e.width/2*.9;let b="";if(p){for(let t=0;f>t;t++){const n=d(a+(t+.5)*l),o=h[t]/m*v;b+=0===t?`M ${e.middle+o} ${n}`:` L ${e.middle+o} ${n}`}for(let t=f-1;t>=0;t--){const n=d(a+(t+.5)*l);b+=` L ${e.middle-h[t]/m*v} ${n}`}b+=" Z"}else{for(let t=0;f>t;t++){const n=d(a+(t+.5)*l),o=h[t]/m*v;b+=0===t?`M ${n} ${e.middle-o}`:` L ${n} ${e.middle-o}`}for(let t=f-1;t>=0;t--)b+=` L ${d(a+(t+.5)*l)} ${e.middle+h[t]/m*v}`;b+=" Z"}const x=u(e.pieceData[0],e.name);let w;if(y&&t.length>=4){const l=null!==(n=r.quantile(t,.25))&&void 0!==n?n:a,c=null!==(o=r.quantile(t,.5))&&void 0!==o?o:(a+s)/2,u=null!==(i=r.quantile(t,.75))&&void 0!==i?i:s;w={q1Pos:d(l),medianPos:d(c),q3Pos:d(u),centerPos:e.middle,isVertical:p}}const k=p?{x:e.x,y:Math.min(d(s),d(a)),width:e.width,height:Math.abs(d(s)-d(a))}:{x:Math.min(d(a),d(s)),y:e.x,width:Math.abs(d(s)-d(a)),height:e.width};g.push({type:"violin",pathString:b,translateX:0,translateY:0,bounds:k,iqrLine:w,stats:he(t),style:x,datum:e.pieceData,category:e.name})}return g},histogram:function(e,t){const{scales:n,columns:o,config:r,getR:i,resolveSummaryStyle:a}=e,{r:s}=n,l=[],c=r.bins||25,u=r.normalize;for(const e of Object.values(o)){const t=e.pieceData.map(e=>i(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const n=Math.min(...t),o=(Math.max(...t)-n)/c||1,r=Array(c).fill(0);for(const e of t)r[Math.min(Math.floor((e-n)/o),c-1)]++;const d=t.length,h=Math.max(...r,1),g=a(e.pieceData[0],e.name);for(let t=0;c>t;t++){if(0===r[t])continue;const i=(u?r[t]/d:r[t]/h)*e.width*.9,a=s(n+t*o),c=s(n+(t+1)*o);l.push(w(Math.min(a,c),e.x+e.width-i,Math.abs(c-a),i,g,{bin:t,count:r[t],range:[n+t*o,n+(t+1)*o],category:e.name},e.name))}}return l},ridgeline:function(e,t){var n;const{scales:o,columns:r,config:i,getR:a,resolveSummaryStyle:s}=e,{r:l,projection:c}=o,u=[],d=i.bins||20,h="horizontal"===c,g=i.amplitude||1.5;for(const e of Object.values(r)){const t=e.pieceData.map(e=>a(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const o=t[0],r=t[t.length-1],i=(r-o)/d||1,c=Array(d).fill(0);for(const e of t)c[Math.min(Math.floor((e-o)/i),d-1)]++;const p=Math.max(...c,1),f=s(e.pieceData[0],e.name),y=e.width*g;let m="";if(h){const t=e.x+e.width;m=`M ${l(o)} ${t}`;for(let e=0;d>e;e++)m+=` L ${l(o+(e+.5)*i)} ${t-c[e]/p*y}`;m+=` L ${l(r)} ${t} Z`}else{const t=e.x;m=`M ${t} ${l(o)}`;for(let e=0;d>e;e++){const n=l(o+(e+.5)*i);m+=` L ${t+c[e]/p*y} ${n}`}m+=` L ${t} ${l(r)} Z`}const v=h?{x:Math.min(l(o),l(r)),y:e.x,width:Math.abs(l(r)-l(o)),height:e.width}:{x:e.x,y:Math.min(l(r),l(o)),width:e.width,height:Math.abs(l(r)-l(o))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:v,stats:he(t),style:Object.assign(Object.assign({},f),{fillOpacity:null!==(n=f.fillOpacity)&&void 0!==n?n:.5}),datum:e.pieceData,category:e.name})}return u},timeline:function(e,t){const{scales:n,columns:o,getRawRange:r,resolvePieceStyle:i}=e,{r:a,projection:s}=n,l=[],c="horizontal"===s;for(const e of Object.values(o))for(const t of e.pieceData){const n=r(t);if(!n)continue;const[o,s]=n,u=i(t,e.name);if(c){const n=a(Math.min(o,s)),r=a(Math.max(o,s));l.push(w(n,e.x,r-n,e.width,u,t,e.name))}else{const n=a(Math.max(o,s)),r=a(Math.min(o,s));l.push(w(e.x,n,e.width,r-n,u,t,e.name))}}return l}};class pe{constructor(e){this.rExtent=new y,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=e,this.buffer=new f(e.windowSize),this.getO=E(e.oAccessor||e.categoryAccessor,"category");const t="streaming"===e.runtimeMode,n=e.rAccessor;Array.isArray(n)?(this.rAccessors=n.map(e=>A(e,"value")),this.getR=this.rAccessors[0],this.rExtents=n.map(()=>new y)):(this.getR=A(t&&(e.timeAccessor||e.valueAccessor)&&e.valueAccessor||n,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=E(e.stackBy),this.getGroup=E(e.groupBy),this.getColor=E(e.colorAccessor),this.getConnector=E(e.connectorAccessor),e.pulse&&(this.timestampBuffer=new f(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,e.bounded){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(n)),this.pushValueExtent(n)}else for(const n of e.inserts){const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(n)),this.pushValueExtent(n),null!=e&&this.evictValueExtent(e)}return!0}pushValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.push(t[0]),this.rExtent.push(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].push(this.rAccessors[t](e));this.rExtent.push(this.getR(e))}else this.rExtent.push(this.getR(e))}evictValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.evict(t[0]),this.rExtent.evict(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].evict(this.rAccessors[t](e));this.rExtent.evict(this.getR(e))}else this.rExtent.evict(this.getR(e))}getRawRange(e){const t=this.config.rAccessor;if(!t)return null;const n="function"==typeof t?t(e):e[t];return Array.isArray(n)&&n.length>=2?[+n[0],+n[1]]:null}computeScene(e){const{config:t,buffer:n}=this;if(0===n.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(n,this.getR);const r=n.toArray(),i=t.projection||"vertical",a=t.oExtent||this.resolveCategories(r),s=this.computeValueDomain(r,a),l="horizontal"===i,c=null!=t.barPadding?t.barPadding/("vertical"===i?e.width:e.height):.1;let u,d;if("radial"===i){u=o.scaleBand().domain(a).range([0,1]).padding(0);const n=Math.min(e.width,e.height)/2,r=t.innerRadius||0;d=o.scaleLinear().domain(s).range([r,n])}else l?(u=o.scaleBand().domain(a).range([0,e.height]).padding(c),d=o.scaleLinear().domain(s).range([0,e.width])):(u=o.scaleBand().domain(a).range([0,e.width]).padding(c),d=o.scaleLinear().domain(s).range([e.height,0]));this.scales={o:u,r:d,projection:i},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((r,i)=>{const a=this.rExtents[i];a.dirty&&a.recalculate(n,r);let[s,c]=a.extent;s===1/0&&(s=0,c=1);const u=c-s,d=u>0?u*(t.extentPadding||.05):1;return s-=d,c+=d,s>0&&(s=0),l?o.scaleLinear().domain([s,c]).range([0,e.width]):o.scaleLinear().domain([s,c]).range([e.height,0])}):[];let h=r;this.rAccessors.length>1&&(h=r.flatMap(e=>this.rAccessors.map((t,n)=>Object.assign(Object.assign({},e),{__rIndex:n,__rValue:t(e),__rName:this.resolveRAccessorName(n)})))),this.columns=this.buildColumns(h,a,u,i,e),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(h,e),this.config.decay&&this.applyDecay(this.scene,r),this.config.pulse&&this.applyPulse(this.scene,r),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(e){const t=Array.isArray(this.config.rAccessor)?this.config.rAccessor[e]:this.config.rAccessor;return"string"==typeof t?t:"value"+e}resolveCategories(e){const t=Array.from(this.categories),n=this.config.oSort;if("streaming"===this.config.runtimeMode&&void 0===n)return t;if(!1===n)return t;if("function"==typeof n)return t.sort(n);const o=new Map;for(const t of e){const e=this.getO(t);o.set(e,(o.get(e)||0)+Math.abs(this.getR(t)))}return t.sort("asc"===n?(e,t)=>(o.get(e)||0)-(o.get(t)||0):(e,t)=>(o.get(t)||0)-(o.get(e)||0))}computeValueDomain(e,t){var n,o;const r=this.config.chartType,i=this.config.extentPadding||.05;if("radial"===this.config.projection&&("pie"===r||"donut"===r))return[0,1];let a=0,s=0;if("bar"===r&&this.getStack){const t=new Map,n=new Map;for(const o of e){const e=this.getO(o),r=this.getR(o);0>r?n.set(e,(n.get(e)||0)+r):t.set(e,(t.get(e)||0)+r)}for(const e of t.values())e>s&&(s=e);for(const e of n.values())a>e&&(a=e)}else if("bar"===r){const t=new Map;for(const n of e){const e=this.getO(n),o=this.getR(n);t.set(e,(t.get(e)||0)+o)}for(const e of t.values())e>s&&(s=e),a>e&&(a=e)}else if("clusterbar"===r)for(const t of e){const e=this.getR(t);e>s&&(s=e),a>e&&(a=e)}else{const e=this.rExtent.extent[0],t=this.rExtent.extent[1];e!==1/0&&(a=e),t!==-1/0&&(s=t)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(a=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(s=this.config.rExtent[1]));const l=s-a,c=l>0?l*i:1;return(null===(n=this.config.rExtent)||void 0===n?void 0:n[0])||(a-=c),(null===(o=this.config.rExtent)||void 0===o?void 0:o[1])||(s+=c),"bar"!==r&&"clusterbar"!==r||(a>0&&(a=0),0>s&&(s=0)),[a,s]}buildColumns(e,t,n,o,r){var i;const a={},s=new Map;for(const t of e){const e=this.getO(t);s.has(e)||s.set(e,[]),s.get(e).push(t)}let l=0;if("radial"===o)for(const t of e)l+=Math.abs(this.getR(t));const c=this.config.dynamicColumnWidth;let u=null;if(c&&"radial"!==o){u=new Map;let e=0;for(const n of t){const t=s.get(n)||[];let o;o="string"==typeof c?t.reduce((e,t)=>e+(Number(t[c])||0),0):c(t),u.set(n,o),e+=o}const i=("horizontal"===o?r.height:r.width)-n.padding()*n.step()*t.length;if(e>0)for(const[t,n]of u)u.set(t,n/e*i)}let d=0,h=0;for(const e of t){const t=s.get(e)||[],o=t.reduce((e,t)=>e+Math.abs(this.getR(t)),0),r=l>0?o/l:0;let c,g;u?(c=h,g=u.get(e)||n.bandwidth(),h+=g+n.padding()*n.step()):(c=null!==(i=n(e))&&void 0!==i?i:0,g=n.bandwidth()),a[e]={name:e,x:c,y:0,width:g,middle:c+g/2,padding:n.padding()*n.step(),pieceData:t,pct:r,pctStart:d},d+=r}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:(e,t)=>this.resolvePieceStyle(e,t),resolveSummaryStyle:(e,t)=>this.resolveSummaryStyle(e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];const n=this.getSceneContext(),o=ge[this.config.chartType];let r=o?o(n,t):[];if(this.getConnector&&this.scales){const e=function(e,t){const{scales:n,config:o,getConnector:r,getO:i}=e;if(!r||!n)return[];const a=[],{projection:s}=n,l=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const n=r(t);if(!n)continue;let o,a;"point"===e.type?(o=e.x,a=e.y):(o=e.x+e.w/2,a=e.y+("vertical"===s?0:e.h/2)),l.has(n)||l.set(n,[]),l.get(n).push({x:o,y:a,datum:t,category:i(t)})}const c=n.o.domain(),u=o.connectorStyle;for(const[e,t]of l)if(t.length>=2){t.sort((e,t)=>c.indexOf(e.category)-c.indexOf(t.category));for(let n=0;t.length-1>n;n++){const o=t[n],r=t[n+1],i="function"==typeof u?u(o.datum):u||{stroke:"#999",strokeWidth:1,opacity:.5};a.push({type:"connector",x1:o.x,y1:o.y,x2:r.x,y2:r.y,style:i,datum:o.datum,group:e})}}return a}(n,r);r=[...e,...r]}return r}resolvePieceStyle(e,t){return"function"==typeof this.config.pieceStyle?this.config.pieceStyle(e,t):this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&t?{fill:this.config.barColors[t]||"#007bff"}:t?{fill:this.getColorFromScheme(t)}:{fill:"#007bff"}}getColorFromScheme(e){this._colorSchemeMap||(this._colorSchemeMap=new Map);const t=this._colorSchemeMap.get(e);if(t)return t;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],o=n[this._colorSchemeIndex%n.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(e,o),o}resolveSummaryStyle(e,t){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(e,t):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(e,t){var n,o,r;const i=this.config.decay;if(!i||1>=t)return 1;const a=null!==(n=i.minOpacity)&&void 0!==n?n:.1,s=t-1-e;switch(i.type){case"linear":return a+(1-s/(t-1))*(1-a);case"exponential":{const e=null!==(o=i.halfLife)&&void 0!==o?o:t/2;return a+Math.pow(.5,s/e)*(1-a)}case"step":return(null!==(r=i.stepThreshold)&&void 0!==r?r:.5*t)>s?1:a;default:return 1}}applyDecay(e,t){var n,o;if(!this.config.decay)return;const r=t.length;if(1>=r)return;const i=new Map;for(let e=0;t.length>e;e++)i.set(t[e],e);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=i.get(t.datum);if(null==e)continue;const a=this.computeDecayOpacity(e,r),s=null!==(o=null===(n=t.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:s*a})}}applyPulse(e,t){var n,o,r;if(!this.config.pulse||!this.timestampBuffer)return;const i="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(n=this.config.pulse.duration)&&void 0!==n?n:500,s=null!==(o=this.config.pulse.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",l=null!==(r=this.config.pulse.glowRadius)&&void 0!==r?r:4,c=new Map;for(let e=0;t.length>e;e++)c.set(t[e],e);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=c.get(t.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const o=i-n;a>o&&(t._pulseIntensity=1-o/a,t._pulseColor=s,t._pulseGlowRadius=l)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}snapshotPositions(){var e,t;this.prevPositionMap.clear();for(let n=0;this.scene.length>n;n++){const o=this.scene[n];if("point"===o.type)this.prevPositionMap.set("p:"+n,{x:o.x,y:o.y,r:o.r});else if("rect"===o.type){const r=`r:${o.group||""}:${null!==(t=null===(e=o.datum)||void 0===e?void 0:e.category)&&void 0!==t?t:n}`;this.prevPositionMap.set(r,{x:o.x,y:o.y,w:o.w,h:o.h})}}}startTransition(){var e,t,n,o,r;if(!this.config.transition||0===this.prevPositionMap.size)return;const i=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;let a=!1;for(let e=0;this.scene.length>e;e++){const i=this.scene[e];let s=null;if("point"===i.type?s="p:"+e:"rect"===i.type&&(s=`r:${i.group||""}:${null!==(n=null===(t=i.datum)||void 0===t?void 0:t.category)&&void 0!==n?n:e}`),!s)continue;const l=this.prevPositionMap.get(s);l&&("point"===i.type?l.x===i.x&&l.y===i.y||(i._targetX=i.x,i._targetY=i.y,i.x=l.x,i.y=l.y,a=!0):"rect"===i.type&&(l.x===i.x&&l.y===i.y&&l.w===i.w&&l.h===i.h||(i._targetX=i.x,i._targetY=i.y,i._targetW=i.w,i._targetH=i.h,i.x=l.x,i.y=l.y,i.w=null!==(o=l.w)&&void 0!==o?o:i.w,i.h=null!==(r=l.h)&&void 0!==r?r:i.h,a=!0)))}a&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:i})}advanceTransition(e){var t,n,o;if(!this.activeTransition)return!1;const r=Math.min((e-this.activeTransition.startTime)/this.activeTransition.duration,1),i="linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?r:1-Math.pow(1-r,3);for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;const t=this.prevPositionMap.get("p:0");if(!t)continue;e.x=t.x+(e._targetX-t.x)*i,e.y=t.y+(e._targetY-t.y)*i}else if("rect"===e.type){if(void 0===e._targetX)continue;const t=`r:${e.group||""}:${null!==(o=null===(n=e.datum)||void 0===n?void 0:n.category)&&void 0!==o?o:0}`,r=this.prevPositionMap.get(t);if(!r)continue;e.x=r.x+(e._targetX-r.x)*i,e.y=r.y+(e._targetY-r.y)*i,void 0!==r.w&&(e.w=r.w+(e._targetW-r.w)*i,e.h=r.h+(e._targetH-r.h)*i)}if(r>=1){for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}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(e){e.colorScheme!==this.config.colorScheme&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),Object.assign(this.config,e)}}function fe(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{datum:e.datum,x:e.x+e.w/2,y:e.y,distance:0,category:e.group}}function ye(e,t,n){const o=t-e.x,r=n-e.y,i=Math.sqrt(o*o+r*r);return i>Math.max(e.r,5)?null:{datum:e.datum,x:e.x,y:e.y,distance:i}}function me(e,t,n){const o=t-e.cx,r=n-e.cy,i=Math.sqrt(o*o+r*r);if(e.innerRadius>i||i>e.outerRadius)return null;let a=Math.atan2(r,o);0>a&&(a+=2*Math.PI);let s=e.startAngle%(2*Math.PI),l=e.endAngle%(2*Math.PI);if(0>s&&(s+=2*Math.PI),0>l&&(l+=2*Math.PI),!(s>l?a>=s||l>=a:a>=s&&l>=a))return null;const c=(e.startAngle+e.endAngle)/2,u=(e.innerRadius+e.outerRadius)/2;return{datum:e.datum,x:e.cx+Math.cos(c)*u,y:e.cy+Math.sin(c)*u,distance:0,category:e.category}}function ve(e,t,n){const o=e.columnWidth/2,r=e.stats?Object.assign(Object.assign({},e.stats),{n:Array.isArray(e.datum)?e.datum.length:0,mean:(e.stats.q1+e.stats.median+e.stats.q3)/3}):void 0;if("vertical"===e.projection){if(!(e.x-o>t||t>e.x+o||Math.min(e.minPos,e.maxPos)>n||n>Math.max(e.minPos,e.maxPos)))return{datum:e.datum,x:e.x,y:e.medianPos,distance:0,category:e.category,stats:r}}else{const i=e.y-o,a=e.y+o;if(!(Math.min(e.minPos,e.maxPos)>t||t>Math.max(e.minPos,e.maxPos)||i>n||n>a))return{datum:e.datum,x:e.medianPos,y:e.y,distance:0,category:e.category,stats:r}}return null}function be(e,t,n){if(!e.bounds)return null;const{x:o,y:r,width:i,height:a}=e.bounds;return o>t||t>o+i||r>n||n>r+a?null:{datum:e.datum,x:o+i/2,y:r+a/2,distance:0,category:e.category,stats:e.stats}}function xe(e){return Math.round(100*e)/100+""}function we(t){const{width:n,height:o,totalWidth:r,totalHeight:i,margin:a,scales:s,showAxes:l,oLabel:c,rLabel:u,oFormat:d,rFormat:g,showGrid:p,title:f,legend:y,foregroundGraphics:m,annotations:v,svgAnnotationRules:b,annotationFrame:x,xAccessor:w,yAccessor:k,annotationData:A,children:E}=t,S="radial"===(null==s?void 0:s.projection),O="horizontal"===(null==s?void 0:s.projection),L=e.useMemo(()=>l&&s&&!S?s.o.domain().map(e=>{var t;return{value:e,pixel:(null!==(t=s.o(e))&&void 0!==t?t:0)+s.o.bandwidth()/2,label:d?d(e):e}}):[],[l,s,d,S]),M=e.useMemo(()=>l&&s&&!S?s.r.ticks(5).map(e=>({value:e,pixel:s.r(e),label:(g||xe)(e)})):[],[l,s,g,S]),j=e.useMemo(()=>{if(!v||0===v.length)return null;const e=V(),t={scales:s?{x:s.r,y:s.r,time:s.r,value:s.r}:null,timeAxis:"x",xAccessor:w,yAccessor:k,width:n,height:o,data:A,frameType:"ordinal"};return v.map((n,o)=>{if(b){const r=b(n,o,t);return null!=r?r:e(n,o,t)}return e(n,o,t)}).filter(Boolean)},[v,b,n,o,x,w,k,A]);return l||f||y||m||j&&j.length>0||p||E?h.createElement("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},h.createElement("g",{transform:`translate(${a.left},${a.top})`},p&&s&&!S&&h.createElement("g",{className:"ordinal-grid"},M.map((e,t)=>h.createElement("line",{key:"grid-"+t,x1:O?e.pixel:0,y1:O?0:e.pixel,x2:O?e.pixel:n,y2:O?o:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),l&&s&&!S&&h.createElement("g",{className:"ordinal-axes"},O?h.createElement(h.Fragment,null,h.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),L.map((e,t)=>h.createElement("g",{key:"cat-"+t,transform:`translate(0,${e.pixel})`},h.createElement("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),h.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),c&&h.createElement("text",{x:15-a.left,y:o/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-a.left}, ${o/2})`,style:{userSelect:"none"}},c),h.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),M.map((e,t)=>h.createElement("g",{key:"val-"+t,transform:`translate(${e.pixel},${o})`},h.createElement("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),h.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),u&&h.createElement("text",{x:n/2,y:o+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},u)):h.createElement(h.Fragment,null,h.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),L.map((e,t)=>h.createElement("g",{key:"cat-"+t,transform:`translate(${e.pixel},${o})`},h.createElement("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),h.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),c&&h.createElement("text",{x:n/2,y:o+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},c),h.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),M.map((e,t)=>h.createElement("g",{key:"val-"+t,transform:`translate(0,${e.pixel})`},h.createElement("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),h.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),u&&h.createElement("text",{x:15-a.left,y:o/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-a.left}, ${o/2})`,style:{userSelect:"none"}},u))),j,m,E),f&&h.createElement("text",{x:r/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof f?f:null),y&&h.createElement("g",{transform:`translate(${r-a.right+10}, ${a.top})`},function(e){return"object"==typeof e&&null!==e&&!h.isValidElement(e)&&"legendGroups"in e}(y)?h.createElement(R,{legendGroups:y.legendGroups,title:"",width:100}):y)):null}const ke=(e,t,n,o)=>{const r=t.filter(e=>"wedge"===e.type);for(const t of r)e.beginPath(),t.innerRadius>0?(e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerRadius,t.endAngle,t.startAngle,!0)):(e.moveTo(t.cx,t.cy),e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle)),e.closePath(),null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),null!=t.style.fillOpacity&&(e.globalAlpha=t.style.fillOpacity),e.fillStyle=t.style.fill||"#007bff",e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),e.globalAlpha=1},Ae=(e,t,n,o)=>{var r,i;const a=t.filter(e=>"violin"===e.type);for(const t of a){e.save(),(t.translateX||t.translateY)&&e.translate(t.translateX,t.translateY);const n=new Path2D(t.pathString);if(e.globalAlpha=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.6,e.fillStyle=t.style.fill||"#007bff",e.fill(n),e.globalAlpha=1,t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke(n)),t.iqrLine){e.strokeStyle="#333",e.lineWidth=2,e.globalAlpha=.8;const n=t.iqrLine.centerPos,o=!1!==t.iqrLine.isVertical;e.beginPath(),o?(e.moveTo(n,t.iqrLine.q1Pos),e.lineTo(n,t.iqrLine.q3Pos)):(e.moveTo(t.iqrLine.q1Pos,n),e.lineTo(t.iqrLine.q3Pos,n)),e.stroke(),e.beginPath(),o?e.arc(n,t.iqrLine.medianPos,3,0,2*Math.PI):e.arc(t.iqrLine.medianPos,n,3,0,2*Math.PI),e.fillStyle="#fff",e.fill(),e.strokeStyle="#333",e.lineWidth=1,e.stroke(),e.globalAlpha=1}e.restore()}},Ee=(e,t,n,o)=>{var r,i,a;const s=t.filter(e=>"connector"===e.type);if(0===s.length)return;const l=new Map;for(const e of s){const t=e.group||"_default";l.has(t)||l.set(t,[]),l.get(t).push(e)}for(const[,t]of l){if(0===t.length)continue;const n=t[0].style;if(n.fill&&"none"!==n.fill){e.beginPath(),e.moveTo(t[0].x1,t[0].y1);for(const n of t)e.lineTo(n.x2,n.y2);e.closePath(),e.globalAlpha=null!==(i=null!==(r=n.fillOpacity)&&void 0!==r?r:n.opacity)&&void 0!==i?i:.3,e.fillStyle=n.fill,e.fill(),e.globalAlpha=1}for(const n of t)e.beginPath(),e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.strokeStyle=n.style.stroke||n.style.fill||"#999",e.lineWidth=n.style.strokeWidth||1,e.globalAlpha=null!==(a=n.style.opacity)&&void 0!==a?a:.5,e.stroke(),e.globalAlpha=1}},Se=e=>[Ee,...e],Oe={bar:Se([ne]),clusterbar:Se([ne]),point:Se([te]),swarm:Se([te]),pie:[ke],donut:[ke],boxplot:Se([(e,t,n,o)=>{var r,i;const a=t.filter(e=>"boxplot"===e.type);for(const t of a){const n=t.columnWidth/2,o="vertical"===t.projection,a=t.style.fill||"#007bff",s=t.style.stroke||"#333",l=t.style.strokeWidth||1,c=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.6;if(e.save(),e.strokeStyle=s,e.lineWidth=l,e.beginPath(),o?(e.moveTo(t.x,t.minPos),e.lineTo(t.x,t.maxPos)):(e.moveTo(t.minPos,t.y),e.lineTo(t.maxPos,t.y)),e.stroke(),e.beginPath(),o?(e.moveTo(t.x-.4*n,t.minPos),e.lineTo(t.x+.4*n,t.minPos),e.moveTo(t.x-.4*n,t.maxPos),e.lineTo(t.x+.4*n,t.maxPos)):(e.moveTo(t.minPos,t.y-.4*n),e.lineTo(t.minPos,t.y+.4*n),e.moveTo(t.maxPos,t.y-.4*n),e.lineTo(t.maxPos,t.y+.4*n)),e.stroke(),e.globalAlpha=c,e.fillStyle=a,o){const o=Math.min(t.q1Pos,t.q3Pos),r=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(t.x-n,o,t.columnWidth,r),e.globalAlpha=1,e.strokeRect(t.x-n,o,t.columnWidth,r)}else{const o=Math.min(t.q1Pos,t.q3Pos),r=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(o,t.y-n,r,t.columnWidth),e.globalAlpha=1,e.strokeRect(o,t.y-n,r,t.columnWidth)}e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),o?(e.moveTo(t.x-n,t.medianPos),e.lineTo(t.x+n,t.medianPos)):(e.moveTo(t.medianPos,t.y-n),e.lineTo(t.medianPos,t.y+n)),e.stroke(),e.restore()}},te]),violin:Se([Ae]),histogram:Se([ne]),ridgeline:Se([Ae]),timeline:Se([ne])},Le={top:50,right:40,bottom:60,left:70},Me={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:"4px",fontSize:"13px",lineHeight:"1.4",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function je({hover:e}){var t,n,o,r;const i=e.data||{},a=e.stats,s=e.category;if(Array.isArray(i)){const e=s||(null===(t=i[0])||void 0===t?void 0:t.category)||"";if(a)return h.createElement("div",{className:"semiotic-tooltip",style:Me},e&&h.createElement("div",{style:{fontWeight:"bold"}},e+""),h.createElement("div",null,"n = ",a.n),h.createElement("div",null,"Min: ",a.min.toLocaleString()),h.createElement("div",null,"Q1: ",a.q1.toLocaleString()),h.createElement("div",null,"Median: ",a.median.toLocaleString()),h.createElement("div",null,"Q3: ",a.q3.toLocaleString()),h.createElement("div",null,"Max: ",a.max.toLocaleString()),h.createElement("div",{style:{opacity:.8}},"Mean: ",a.mean.toLocaleString(void 0,{maximumFractionDigits:2})));const n=i.length;return h.createElement("div",{className:"semiotic-tooltip",style:Me},e&&h.createElement("div",{style:{fontWeight:"bold"}},e+""),h.createElement("div",null,n," items"))}if(null!=i.bin&&null!=i.count){const e=i.range||[];return h.createElement("div",{className:"semiotic-tooltip",style:Me},i.category&&h.createElement("div",{style:{fontWeight:"bold"}},i.category+""),h.createElement("div",null,"Count: ",i.count),2===e.length&&h.createElement("div",{style:{opacity:.8}},Number(e[0]).toFixed(1)," – ",Number(e[1]).toFixed(1)))}const l=i.category||i.name||i.group||i.__rName||"",c=null!==(r=null!==(o=null!==(n=i.value)&&void 0!==n?n:i.__rValue)&&void 0!==o?o:i.pct)&&void 0!==r?r:"";if(!l&&""===c){const e=Object.entries(i).filter(([e])=>!e.startsWith("_")&&"data"!==e);return h.createElement("div",{className:"semiotic-tooltip",style:Me},e.map(([e,t])=>h.createElement("div",{key:e},h.createElement("span",{style:{opacity:.7}},e,":")," ","number"==typeof t?t.toLocaleString():t+"")))}return h.createElement("div",{className:"semiotic-tooltip",style:Me},l&&h.createElement("div",{style:{fontWeight:"bold"}},l+""),""!==c&&h.createElement("div",null,"number"==typeof c?c.toLocaleString():c+""))}const Pe=e.forwardRef(function(t,n){var o;const{chartType:r,runtimeMode:i,data:a,oAccessor:s="category",rAccessor:l="value",colorAccessor:c,stackBy:u,groupBy:d,multiAxis:g,timeAccessor:f,valueAccessor:y,categoryAccessor:m,projection:v="vertical",size:b=[600,400],responsiveWidth:x,responsiveHeight:w,margin:k,barPadding:A,innerRadius:E,normalize:S,startAngle:O,dynamicColumnWidth:L,bins:M,showOutliers:j,showIQR:P,amplitude:C,connectorAccessor:N,connectorStyle:H,rExtent:W,oExtent:R,extentPadding:$=.05,oSort:_,windowMode:z="sliding",windowSize:I=200,pieceStyle:F,summaryStyle:Y,colorScheme:G,barColors:X,showAxes:q=!0,oLabel:V,rLabel:U,oFormat:Z,rFormat:Q,enableHover:K=!0,hoverAnnotation:J,tooltipContent:ee,customHoverBehavior:te,annotations:ne,svgAnnotationRules:oe,showGrid:re=!1,legend:ie,backgroundGraphics:ae,foregroundGraphics:se,title:le,className:ce,background:ue,centerContent:de,decay:he,pulse:ge,transition:xe,staleness:ke}=t,[Ae,Ee]=B(b,x,w),Se=e.useMemo(()=>Object.assign(Object.assign({},Le),k),[k]),Me=Ee[0]-Se.left-Se.right,Pe=Ee[1]-Se.top-Se.bottom,Ce=e.useRef(null),Ne=e.useRef(!0),De=e.useRef(0),Te=e.useRef(null),Be=e.useRef(()=>{}),[He,We]=e.useState(null),[Re,$e]=e.useState(null),[_e,ze]=e.useState(0),[Ie,Fe]=e.useState(!1),Ye=K||J,Ge="streaming"===i,Xe=e.useMemo(()=>({chartType:r,runtimeMode:Ge?"streaming":"bounded",windowSize:I,windowMode:z,extentPadding:$,projection:v,oAccessor:Ge?void 0:s,rAccessor:Ge?void 0:l,colorAccessor:c,stackBy:u,groupBy:d,multiAxis:g,timeAccessor:Ge?f:void 0,valueAccessor:Ge?y||("string"==typeof l||"function"==typeof l?l:void 0):void 0,categoryAccessor:Ge?m||s:void 0,rExtent:W,oExtent:R,barPadding:A,innerRadius:E,normalize:S,startAngle:O,dynamicColumnWidth:L,bins:M,showOutliers:j,showIQR:P,amplitude:C,connectorAccessor:N,connectorStyle:H,oSort:_,pieceStyle:F,summaryStyle:Y,colorScheme:G,barColors:X,decay:he,pulse:ge,transition:xe,staleness:ke}),[r,I,z,$,v,s,l,c,u,d,g,f,y,m,W,R,A,E,S,O,L,M,j,P,C,N,H,_,F,Y,G,X,he,ge,xe,ke,Ge]),qe=e.useRef(null);qe.current||(qe.current=new pe(Xe));const Ve=e.useCallback(()=>{De.current||(De.current=requestAnimationFrame(()=>Be.current()))},[]);e.useEffect(()=>{var e;null===(e=qe.current)||void 0===e||e.updateConfig(Xe),Ne.current=!0,Ve()},[Xe,Ve]);const Ue=e.useRef(null);Ue.current||(Ue.current=new p(e=>{const t=qe.current;t&&t.ingest(e)&&(Ne.current=!0,Ve())}));const Ze=e.useCallback(e=>{var t;null===(t=Ue.current)||void 0===t||t.push(e)},[]),Qe=e.useCallback(e=>{var t;null===(t=Ue.current)||void 0===t||t.pushMany(e)},[]),Ke=e.useCallback(()=>{var e,t;null===(e=Ue.current)||void 0===e||e.clear(),null===(t=qe.current)||void 0===t||t.clear(),Ne.current=!0,Ve()},[Ve]);e.useImperativeHandle(n,()=>({push:Ze,pushMany:Qe,clear:Ke,getData:()=>{var e,t;return null!==(t=null===(e=qe.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=qe.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null}}),[Ze,Qe,Ke]),e.useEffect(()=>{var e;a&&(null===(e=Ue.current)||void 0===e||e.setBoundedData(a))},[a]);const Je=e.useRef(()=>{}),et=e.useRef(()=>{});Je.current=e=>{if(!Ye)return;const t=Ce.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Se.left,r=e.clientY-n.top-Se.top;if(0>o||o>Me||0>r||r>Pe)return void(Te.current&&(Te.current=null,We(null),te&&te(null),Ve()));const i=qe.current;if(!i||0===i.scene.length)return;const a="radial"===v,s=function(e,t,n,o=30){let r=null;for(const i of e){let e=null;switch(i.type){case"rect":e=fe(i,t,n);break;case"point":e=ye(i,t,n);break;case"wedge":e=me(i,t,n);break;case"boxplot":e=ve(i,t,n);break;case"violin":e=be(i,t,n)}e&&o>e.distance&&(r&&e.distance>=r.distance||(r=e))}return r}(i.scene,a?o-Me/2:o,a?r-Pe/2:r);if(!s)return void(Te.current&&(Te.current=null,We(null),te&&te(null),Ve()));const l=Object.assign(Object.assign({data:s.datum,time:s.x,value:s.y,x:s.x,y:s.y},s.stats&&{stats:s.stats}),s.category&&{category:s.category});Te.current=l,We(l),te&&(te(l),Ne.current=!0),Ve()},et.current=()=>{Te.current&&(Te.current=null,We(null),te&&(te(null),Ne.current=!0),Ve())},e.useCallback(e=>Je.current(e),[]);const tt=e.useCallback(()=>et.current(),[]),nt=e.useRef(-1),ot=e.useCallback(e=>{const t=qe.current;if(!t||0===t.scene.length)return;const n=function(e){const t=[];for(const n of e)if("rect"===n.type&&null!=n.x)t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum});else if("point"===n.type)t.push({x:n.x,y:n.y,datum:n.datum});else if("wedge"===n.type&&null!=n.cx){const e=((n.startAngle||0)+(n.endAngle||0))/2,o=((n.innerRadius||0)+(n.outerRadius||50))/2;t.push({x:n.cx+Math.cos(e)*o,y:n.cy+Math.sin(e)*o,datum:n.datum})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.scene);if(0===n.length)return;const o=nt.current,r=D(e.key,0>o?-1:o,n.length);if(null===r)return;if(e.preventDefault(),0>r)return nt.current=-1,Te.current=null,We(null),te&&te(null),void Ve();const i=0>o?0:r;nt.current=i;const a=T(n[i]);Te.current=a,We(a),te&&te(a),Ve()},[te,Ve]),rt=e.useCallback(e=>{nt.current=-1,Je.current(e)},[]);Be.current=()=>{var e,t;De.current=0;const n=Ce.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const i=qe.current;if(!i)return;const a="undefined"!=typeof performance?performance.now():Date.now(),s=i.advanceTransition(a),l=Ne.current;l&&!s&&(i.computeScene({width:Me,height:Pe}),Ne.current=!1);const c="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=Ee[0]*c,n.height=Ee[1]*c,n.style.width=Ee[0]+"px",n.style.height=Ee[1]+"px",o.scale(c,c),o.clearRect(0,0,Ee[0],Ee[1]);const u=null!==(e=null==ke?void 0:ke.threshold)&&void 0!==e?e:5e3,d=ke&&i.lastIngestTime>0&&a-i.lastIngestTime>u;d&&(o.globalAlpha=null!==(t=null==ke?void 0:ke.dimOpacity)&&void 0!==t?t:.5);const h=n?getComputedStyle(n).getPropertyValue("--semiotic-bg").trim():"",g=ue||(h&&"transparent"!==h?h:null);g&&(o.fillStyle=g,o.fillRect(0,0,Ee[0],Ee[1]));const p="radial"===v;p?(o.save(),o.translate(Se.left+Me/2,Se.top+Pe/2)):o.translate(Se.left,Se.top);const f=Oe[r]||[],y={width:Me,height:Pe};for(const e of f)e(o,i.scene,i.scales,y);p&&o.restore(),d&&(o.globalAlpha=1),l&&i.scales&&($e(i.scales),ze(e=>e+1)),(null==ke?void 0:ke.showBadge)&&Fe(!!d),(s||i.hasActivePulses)&&(De.current=requestAnimationFrame(()=>Be.current()))},e.useEffect(()=>(Ve(),()=>{De.current&&(cancelAnimationFrame(De.current),De.current=0)}),[Ve]),e.useEffect(()=>{Ne.current=!0,Ve()},[r,Me,Pe,q,ue,Ve]),e.useEffect(()=>{if(!ke)return;const e=setInterval(()=>{var e;const t=qe.current;if(!t||0===t.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=ke.threshold)&&void 0!==e?e:5e3,r=n-t.lastIngestTime>o;r!==Ie&&(Fe(r),Ne.current=!0,Ve())},1e3);return()=>clearInterval(e)},[ke,Ie,Ve]);const it=Ye&&He?ee?ee(He):h.createElement(je,{hover:He}):null,at="radial"===v,st=He?at?He.x+Me/2:He.x:0,lt=He?at?He.y+Pe/2:He.y:0,ct=it?h.createElement("div",{className:"stream-ordinal-tooltip",style:{position:"absolute",left:Se.left+st,top:Se.top+lt,transform:`translate(${st>.7*Me?"calc(-100% - 12px)":"12px"}, ${.3*Pe>lt?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},it):null;return h.createElement("div",{ref:Ae,className:"stream-ordinal-frame"+(ce?" "+ce:""),role:"img","aria-label":"string"==typeof le?le:"Ordinal chart",tabIndex:0,style:{position:"relative",width:x?"100%":Ee[0],height:w?"100%":Ee[1]},onMouseMove:Ye?rt:void 0,onMouseLeave:Ye?tt:void 0,onKeyDown:ot},ae&&h.createElement("svg",{style:{position:"absolute",top:0,left:0,width:Ee[0],height:Ee[1],pointerEvents:"none"}},h.createElement("g",{transform:`translate(${Se.left},${Se.top})`},ae)),h.createElement("canvas",{ref:Ce,style:{position:"absolute",top:0,left:0,width:Ee[0],height:Ee[1]}}),h.createElement(we,{width:Me,height:Pe,totalWidth:Ee[0],totalHeight:Ee[1],margin:Se,scales:Re,showAxes:q,oLabel:V,rLabel:U,oFormat:Z,rFormat:Q,showGrid:re,title:le,legend:ie,foregroundGraphics:se,annotations:ne,svgAnnotationRules:oe,annotationFrame:_e,xAccessor:"string"==typeof s?s:void 0,yAccessor:"string"==typeof l?l:void 0,annotationData:null===(o=qe.current)||void 0===o?void 0:o.getData()}),de&&"radial"===v&&h.createElement("div",{style:{position:"absolute",left:Se.left+Me/2,top:Se.top+Pe/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"}},de),(null==ke?void 0:ke.showBadge)&&h.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ke.badgePosition?{top:4,left:4}:"bottom-left"===ke.badgePosition?{bottom:4,left:4}:"bottom-right"===ke.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Ie?"#dc3545":"#28a745",color:"white"})},Ie?"STALE":"LIVE"),ct)});Pe.displayName="StreamOrdinalFrame";const Ce={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Ne={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class De{constructor(e){this.capacity=e,this.particles=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0}}spawn(e){for(let t=0;this.capacity>t;t++){const n=this.particles[t];if(!n.active)return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=e,n.x=0,n.y=0,n}return null}step(e,t,n,o){var r;for(let i=0;this.capacity>i;i++){const a=this.particles[i];if(!a.active)continue;const s=n[a.edgeIndex];if(!s||!s.bezier){a.active=!1;continue}const l=o&&null!==(r=o[a.edgeIndex])&&void 0!==r?r:1;if(a.t+=e*t*l*(s.bezier.circular?.3:1),a.t>=1){a.active=!1;continue}const c=Te(s.bezier,a.t,a.offset);a.x=c.x,a.y=c.y}}countForEdge(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let n=0;e>n;n++)this.particles[n]=t.length>n?t[n]:{t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0};this.capacity=e}}function Te(e,t,n){if(e.circular&&e.segments)return function(e,t,n,o){const r=e.length,i=t*r,a=Math.min(Math.floor(i),r-1),s=i-a,[l,c,u,d]=e[a],h=Be(l,c,u,d,s),g=d.x-l.x,p=d.y-l.y,f=Math.sqrt(g*g+p*p);if(f>.001){const e=g/f;h.x+=-p/f*n*o*2,h.y+=e*n*o*2}return h}(e.segments,t,n,e.halfWidth);if(!e.points)return{x:0,y:0};const[o,r,i,a]=e.points,s=Be(o,r,i,a,t),l=a.x-o.x,c=a.y-o.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;s.x+=-c/u*n*e.halfWidth*2,s.y+=t*n*e.halfWidth*2}return s}function Be(e,t,n,o,r){const i=1-r,a=i*i,s=a*i,l=r*r,c=l*r;return{x:s*e.x+3*a*r*t.x+3*i*l*n.x+c*o.x,y:s*e.y+3*a*r*t.y+3*i*l*n.y+c*o.y}}function He(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function We(e,t){var n,o=[],r=[],i=[],a={},s=[];function l(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&l(t)})}function c(e){var t,o,d=!1;for(r.push(e),i[e]=!0,t=0;s[e].length>t;t++)(o=s[e][t])===n?(u(n,r),d=!0):i[o]||(d=c(o));if(d)l(e);else for(t=0;s[e].length>t;t++){var h=a[o=s[e][t]];h||(a[o]=h={}),h[o]=!0}return r.pop(),d}function u(e,t){var n=[].concat(t).concat(e);o.push(n)}function d(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,o=function(e){for(var t=e.length,n=Array(t),o=Array(t),r=Array(t),i=Array(t),a=Array(t),s=Array(t),l=0;t>l;++l)n[l]=-1,o[l]=0,r[l]=!1,i[l]=0,a[l]=-1,s[l]=[];var c,u=0,d=[],h=[];function g(t){var l=[t],c=[t];for(n[t]=o[t]=u,r[t]=!0,u+=1;c.length>0;){var g=e[t=c[c.length-1]];if(g.length>i[t]){for(var p=i[t];g.length>p;++p){var f=g[p];if(0>n[f]){n[f]=o[f]=u,r[f]=!0,u+=1,l.push(f),c.push(f);break}r[f]&&(o[t]=0|Math.min(o[t],o[f])),0>a[f]||s[t].push(a[f])}i[t]=p}else{if(o[t]===n[t]){var y=[],m=[],v=0;for(p=l.length-1;p>=0;--p){var b=l[p];if(r[b]=!1,y.push(b),m.push(s[b]),v+=s[b].length,a[b]=d.length,b===t){l.length=p;break}}d.push(y);var x=Array(v);for(p=0;m.length>p;p++)for(var w=0;m[p].length>w;w++)x[--v]=m[p][w];h.push(x)}c.pop()}}}for(l=0;t>l;++l)0>n[l]&&g(l);for(l=0;h.length>l;l++){var p=h[l];if(0!==p.length){p.sort(function(e,t){return e-t}),c=[p[0]];for(var f=1;p.length>f;f++)p[f]!==p[f-1]&&c.push(p[f]);h[l]=c}}return{components:d,adjacencyList:h}}(e),r=o.components.filter(function(e){return e.length>1}),i=1/0,a=0;r.length>a;a++)for(var s=0;r[a].length>s;s++)i>r[a][s]&&(i=r[a][s],n=a);var l=r[n];if(!l)return!1;var c=e.map(function(e,t){return-1===l.indexOf(t)?[]:e.filter(function(e){return-1!==l.indexOf(e)})});return{leastVertex:i,adjList:c}}n=0;for(var h=e.length;h>n;){var g=d(n);if(n=g.leastVertex,s=g.adjList){for(var p=0;s.length>p;p++)for(var f=0;s[p].length>f;f++){var y=s[p][f];i[+y]=!1,a[y]={}}c(n),n+=1}else n=h}return o}function Re(e){return e.y0-e.y1>0?"up":"down"}function $e(e,t){return t(e.source)==t(e.target)}function _e(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function ze(e){return e.target.x0-e.source.x1}function Ie(e,t){var n=Ye(e),o=ze(t)/Math.tan(n);return"up"==Re(e)?e.y1-o:e.y1+o}function Fe(e,t){var n=Ye(e),o=ze(t)/Math.tan(n);return"up"==Re(e)?e.y1+o:e.y1-o}function Ye(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function Ge(e,t){return t(e)}function Xe(e){return Ve(e.source)}function qe(e){return Ve(e.target)}function Ve(e){return(e.y0+e.y1)/2}function Ue(e){return e.virtual?0:e.value}function Ze(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!$e(e,t)?n+1:n});var o=0;return e.targetLinks.forEach(function(e){o=e.circular&&!$e(e,t)?o+1:o}),n+o}function Qe(e){return e.target.depth}function Ke(e,t){return e.sourceLinks.length?e.depth:t-1}function Je(e,t){return e.y0-t.y0}function et(e,t){return t.y0-e.y0}function tt(e,t){return e.y1-t.y1}function nt(e,t){return t.y1-e.y1}function ot(e,t){return it(e.source,t.source)||e.index-t.index}function rt(e,t){return it(e.target,t.target)||e.index-t.index}function it(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function at(e,t){return st(e)==st(t)?"bottom"==e.circularLinkType?et(e,t):Je(e,t):st(t)-st(e)}function st(e){return e.target.column-e.source.column}function lt(e,t){return ct(e)==ct(t)}function ct(e){return e.y0-e.y1>0?"up":"down"}function ut(e,t,n,o,i){let a=e;var s=Math.max(8,.15*(a.y1-a.y0));a.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var l=r.min(a.links,function(e){return e.source.y0});a.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=a.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),dt(a.links.filter(function(e){return"top"==e.circularLinkType}),t,n),dt(a.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),a.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+o,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,$e(e,t)&&_e(e))e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var r=e.source.column,s=e.circularLinkType,c=a.links.filter(function(e){return e.source.column==r&&e.circularLinkType==s});c.sort("bottom"==e.circularLinkType?et:Je);var u=0;c.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),r=e.target.column,(c=a.links.filter(function(e){return e.target.column==r&&e.circularLinkType==s})).sort("bottom"==e.circularLinkType?nt:tt),u=0,c.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(a.y1,e.source.y1,e.target.y1)+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=l-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,n=e.y0,o=e.target.x0,r=e.y1,i=(t+o)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+r+" "+o+","+r}(e)}),a}function dt(e,t,n){e.sort(at);var o=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,r){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if($e(e,t)&&_e(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;o.length>a;a++){var s=o[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&ht(e,s)){var l=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+n;i=l>i?l:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function ht(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function gt(e){return function(){return e}}function pt(e){return e.index}function ft(e){return e.nodes}function yt(e){return e.links}function mt(e,t,n){var o=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});o.forEach(function(r){var i=r.length;r.sort(t||function(e,t){return e.circularLinkType==t.circularLinkType?Ze(t,n)-Ze(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0}),r.forEach(function(t,r){t.depth==o.length-1&&1==i||0==t.depth&&1==i?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==Ze(t,n)?(t.y0=e.y1/2+r,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+r,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-r,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/i*r,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-i/2+r,t.y1=t.y0+t.value*e.ky)})})}function vt(e,t,n,o,i,a){var s=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});d();for(var l=1,c=a;c>0;--c)u(l*=.99,n),d();function u(t,n){var o=s.length;s.forEach(function(i){var a=i.length,s=i[0].depth;i.forEach(function(i){var l;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&Ze(i,n)>0){var c=r.mean(i.sourceLinks,qe),u=r.mean(i.targetLinks,Xe),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-Ve(i))*t*.3;i.y0+=h,i.y1+=h}}else if(0==s&&1==a)i.y0=e.y1/2-(l=i.y1-i.y0)/2,i.y1=e.y1/2+l/2;else if(s==o-1&&1==a)i.y0=e.y1/2-(l=i.y1-i.y0)/2,i.y1=e.y1/2+l/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)l=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+l;else{var g=r.mean(i.sourceLinks,qe),p=r.mean(i.targetLinks,Xe),f=((g&&p?(g+p)/2:g||p)-Ve(i))*t;i.y0+=f,i.y1+=f}})})}function d(){s.forEach(function(n){var r,a,s,l=e.y0,c=n.length;for(n.sort(t||it),s=0;c>s;++s)(a=l-(r=n[s]).y0)>0&&(r.y0+=a,r.y1+=a),l=r.y1+o;if((a=l-o-e.y1)>0)for(l=r.y0-=a,r.y1-=a,s=c-2;s>=0;--s)(a=(r=n[s]).y1+i-l)>0&&(r.y0-=a,r.y1-=a),l=r.y0})}}function bt(e){e.nodes.forEach(function(e){e.sourceLinks.sort(rt),e.targetLinks.sort(ot)}),e.nodes.forEach(function(e){var t=e.y0,n=t,o=e.y1,r=o;e.sourceLinks.forEach(function(e){e.circular?(e.y0=o-e.width/2,o-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=r-e.width/2,r-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function xt(){var e=0,t=0,n=1,o=1,i=24,a=8,s=null,l=pt,c=Ke,u=void 0,d=32,h=2,g=ft,p=yt;function f(){var f={nodes:g.apply(null,arguments),links:p.apply(null,arguments)};return function(g){g.x0=e,g.y0=t,g.x1=n,g.y1=o,g.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return r.group(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var o=e.source,r=e.target;"object"!=typeof o&&(o=e.source=He(n,o)),"object"!=typeof r&&(r=e.target=He(n,r)),o.sourceLinks.push(e),r.targetLinks.push(e)})}(g,l),function(e,t){var n=0;if(null==t){for(var o=[],r=0;e.links.length>r;r++){var i=e.links[r],a=i.source.index,s=i.target.index;o[a]||(o[a]=[]),o[s]||(o[s]=[]),-1===o[a].indexOf(s)&&o[a].push(s)}var l=We(o);l.sort(function(e,t){return e.length-t.length});var c={};for(r=0;l.length>r;r++){var u=l[r].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,o=e.source.index;t===o||c[o]&&c[o][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(g,u),function(e,t){var n=0,o=0;e.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:o>n?"top":"bottom","top"==r.circularLinkType?n++:o++,e.nodes.forEach(function(e){Ge(e,t)!=Ge(r.source,t)&&Ge(e,t)!=Ge(r.target,t)||(e.circularLinkType=r.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),$e(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(g,l),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(r.sum(e.sourceLinks,Ue),r.sum(e.targetLinks,Ue)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(g),function(e,t,n){var o,r,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var a=0,s=t(e.nodes[0]);e.nodes.forEach(function(e){a=t(e)==s?a:a+1,s=t(e)==s?s:t(e),e.column=a})}for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>r.indexOf(e.target)&&!e.circular&&r.push(e.target)})});for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>r.indexOf(e.source)&&!e.circular&&r.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,i):e.column})}(g,u,c);var p=a;if(null!==s){var f=r.groups(g.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),y=r.max(f,function(e){return e.length});y>1&&(p=Math.max(1,(o-t)*s/(y-1)))}(function(e,t,n){var o=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var i=r.min(o,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/r.sum(t,function(e){return e.value})});e.ky=i,e.links.forEach(function(t){t.width=t.value*e.ky});var a=r.max(e.nodes,function(e){return e.column});e.nodes.forEach(a>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/a),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(g,p,i),mt(g,u,l),vt(g,u,l,p,p,d),bt(g),ut(g,l,h,10,8),mt(g,u,l),vt(g,u,l,p,p,d),bt(g),ut(g,l,h,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var o=n.links.filter(function(n){return Ge(n.source,t)==Ge(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!lt(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=Ie(t,e);return e.y1-n}if(t.target.column>e.target.column)return Ie(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;o.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;r>i;i++)a+=o[i].width;t.y0=e.y1-a-t.width/2}})})}(g,l),function(e,t){let n=e;n.nodes.forEach(function(e){var o=n.links.filter(function(n){return Ge(n.target,t)==Ge(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!lt(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=Fe(t,e);return e.y0-n}if(t.source.column>e.source.column)return Fe(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;o.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;r>i;i++)a+=o[i].width;t.y1=e.y1-a-t.width/2}})})}(g,l),function(e){var t=e.nodes,n=e.links,o=!1,i=!1;if(n.forEach(function(e){"top"==e.circularLinkType?o=!0:"bottom"==e.circularLinkType&&(i=!0)}),0==o||0==i){var a=r.min(t,function(e){return e.y0}),s=r.max(t,function(e){return e.y1}),l=(e.y1-e.y0)/(s-a);function c(t){return(t-a)/(s-a)*(e.y1-e.y0)+e.y0}1>l?(t.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1)}),n.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1),e.width=e.width*l})):t.forEach(function(e){var t=e.y1-e.y0,n=c(e.y0)-e.y0;e.y0=c(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(g),ut(g,l,h,10,8)}(f),f}return f.update=function(e){return bt(e),ut(e,l,h,10,8),e},f.nodeWidth=function(e){return arguments.length?(i=+e,f):i},f.nodePadding=function(e){return arguments.length?(a=+e,f):a},f.nodePaddingRatio=function(e){return arguments.length?(s=+e,f):s},f.nodes=function(e){return arguments.length?(g="function"==typeof e?e:gt(e),f):g},f.links=function(e){return arguments.length?(p="function"==typeof e?e:gt(e),f):p},f.nodeId=function(e){return arguments.length?(l="function"==typeof e?e:gt(e),f):l},f.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:gt(e),f):c},f.nodeSort=function(e){return arguments.length?(u=e,f):u},f.iterations=function(e){return arguments.length?(d=+e,f):d},f.circularLinkGap=function(e){return arguments.length?(h=+e,f):h},f.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],f):[[e,t],[n,o]]},f.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],f):[n-e,o-t]},f}const wt=e=>{let t,n,o,r,i,s,l,c,u;return"down"===e.direction?(t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,o=e.y1+e.sankeyWidth/2,r=e.y0+e.sankeyWidth/2,i=e.source.y1,s=e.target.y0,l=a.interpolateNumber(i,s),c=l(.5),u=l(.5),`M${t},${i}C${t},${c} ${n},${u} ${n},${s}L${o},${s}C${o},${u} ${r},${c} ${r},${i}Z`):(t=e.source.x1,n=e.target.x0,l=a.interpolateNumber(t,n),o=l(.5),r=l(.5),i=e.y0-e.sankeyWidth/2,s=e.y1-e.sankeyWidth/2,c=e.y1+e.sankeyWidth/2,u=e.y0+e.sankeyWidth/2,`M${t},${i}C${o},${i} ${r},${s} ${n},${s}L${n},${c}C${r},${c} ${o},${u} ${t},${u}Z`)};function kt(e){var t;const n=e.sankeyWidth/2,o=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,r=e.circularPathData;if(!r)return null;if("down"===e.direction)return null;if(e._circularStub){const t=r.sourceX,o=r.sourceY,i=r.targetX,a=r.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const s=Math.max(15,Math.min(40,.33*(r.rightFullExtent-t))),l=Math.max(15,Math.min(40,.33*(i-r.leftFullExtent)));return`M${t},${o-n}L${t+s},${o-n}L${t+s},${o+n}L${t},${o+n}ZM${i},${a-n}L${i-l},${a-n}L${i-l},${a+n}L${i},${a+n}Z`}const i=r.sourceX,a=r.sourceY,s=r.targetX,l=r.targetY,c=r.rightFullExtent,u=r.leftFullExtent,d=r.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,g=Math.max(4,Math.min(o,15));return`M${i},${a-h*n}L${c},${a-h*n}L${c+o},${a-h*n+h*g}L${c+o},${d+h*o-h*g}L${c+o-g},${d+h*o}L${u-o+g},${d+h*o}L${u-o},${d+h*o-h*g}L${u-o},${l-h*n+h*g}L${u-o+g},${l-h*n}L${s},${l-h*n}L${s},${l+h*n}L${u+o},${l+h*n}L${u+o},${d-h*o}L${c-o},${d-h*o}L${c-o},${a+h*n}L${i},${a+h*n}Z`}const At={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(Qe))-1:0},justify:Ke},Et={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){var r,i,a,s,l,c,u;if(0===e.length)return;const d="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",g=null!==(r=n.nodeWidth)&&void 0!==r?r:15,p=null!==(i=n.nodePaddingRatio)&&void 0!==i?i:.05,f=null!==(a=n.iterations)&&void 0!==a?a:100,y=e.map(e=>Object.assign({},e)),m=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let v;v="down"===d?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const b=xt().extent(v).links(m).nodes(y).nodeAlign(At[h]||Ke).nodeId(e=>e.id).nodeWidth(g).iterations(f);b.nodePaddingRatio&&b.nodePaddingRatio(p),b();{let e=1/0,t=-1/0,n=1/0,r=-1/0;for(const o of y)e>o.x0&&(e=o.x0),o.x1>t&&(t=o.x1),n>o.y0&&(n=o.y0),o.y1>r&&(r=o.y1);for(const o of m){if(!o.circular||!o.circularPathData)continue;const i=o.circularPathData,a=(null!==(l=null!==(s=o._circularWidth)&&void 0!==s?s:o.width)&&void 0!==l?l:0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),n>i.verticalFullExtent-a&&(n=i.verticalFullExtent-a),i.verticalFullExtent+a>r&&(r=i.verticalFullExtent+a)}const i=t-e,a=r-n,u=o[0],d=o[1];if(i>0&&a>0&&(0>e||0>n||t>u||r>d)){const t=Math.min(u/i,d/a),o=-e*t+(u-i*t)/2,r=-n*t+(d-a*t)/2;for(const e of y)e.x0=e.x0*t+o,e.x1=e.x1*t+o,e.y0=e.y0*t+r,e.y1=e.y1*t+r;for(const e of m)if(e.y0=e.y0*t+r,e.y1=e.y1*t+r,e.width=(null!==(c=e.width)&&void 0!==c?c:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+o,n.targetX=n.targetX*t+o,n.sourceY=n.sourceY*t+r,n.targetY=n.targetY*t+r,n.rightFullExtent=n.rightFullExtent*t+o,n.leftFullExtent=n.leftFullExtent*t+o,n.verticalFullExtent=n.verticalFullExtent*t+r,n.rightInnerExtent=n.rightInnerExtent*t+o,n.leftInnerExtent=n.leftInnerExtent*t+o,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+r,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+r,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of y){const t=x.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const w=new Map;for(const e of t)w.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of m){const t=e.source,n=e.target,o="object"==typeof t&&null!==t?t.id:t+"",r="object"==typeof n&&null!==n?n.id:n+"",i=w.get(`${o}\0${r}`);if(i){i.y0=e.y0,i.y1=e.y1,i.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,i.circular=!!e.circular,i.circularPathData=e.circularPathData,i._circularWidth=e._circularWidth,i._circularStub=e._circularStub,i.path=e.path,i.circularLinkType=e.circularLinkType,i.direction=d;const t=x.get(o),n=x.get(r);t&&(i.source=t),n&&(i.target=n)}}},buildScene(e,t,n,o){var r,i,a,l;const c="vertical"===n.orientation?"down":"right",u=n.nodeStyle,d=n.edgeStyle,h=null!==(r=n.edgeOpacity)&&void 0!==r?r:.5,g=n.edgeColorBy||"source",p=Array.isArray(n.colorScheme)?n.colorScheme:s.schemeCategory10,f=new Map;e.forEach((e,t)=>{f.set(e.id,p[t%p.length])});const y=[],m=[],v=[];for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const o=u?u(t):{},r={fill:o.fill||f.get(t.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};y.push({type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:r,datum:t,id:t.id,label:t.id})}const b=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of b){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let o="#999";d?o=d(e).fill||o:"target"===g&&n?o=f.get(n.id)||o:t&&(o=f.get(t.id)||o);const r=d?d(e):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,s=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),l=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=r.fill||o;m.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+s},${t.sourceY-n}L${t.sourceX+s},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:c,fillOpacity:null!==(i=r.fillOpacity)&&void 0!==i?i:h,stroke:"none",opacity:r.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+s}}),m.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-l},${t.targetY-n}L${t.targetX-l},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:c,fillOpacity:null!==(a=r.fillOpacity)&&void 0!==a?a:h,stroke:"none",opacity:r.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-l,x1:t.targetX}});continue}let s;if(s=e.circular&&e.circularPathData?kt(e):wt(e),!s)continue;const c={fill:r.fill||o,fillOpacity:null!==(l=r.fillOpacity)&&void 0!==l?l:h,stroke:r.stroke||"none",strokeWidth:r.strokeWidth,opacity:r.opacity};m.push({type:"bezier",pathD:s,bezierCache:e.bezier,style:c,datum:e})}if(!1!==n.showLabels){const t=(x=n.nodeLabel)?"function"==typeof x?x:e=>e[x]||e.id:null;for(const n of e){const e=n.x1-n.x0,r=n.y1-n.y0;if(0>=e||0>=r)continue;const i=t?t(n):n.id;if(!i)continue;let a,s,l;"down"===c?(a=n.x0+e/2,s=n.y1+14,l="middle"):(o[0]/2>n.x0+e/2?(a=n.x0-6,l="end"):(a=n.x1+6,l="start"),s=n.y0+r/2),v.push({x:a,y:s,text:i+"",anchor:l,baseline:"middle",fontSize:11})}}var x;return{sceneNodes:y,sceneEdges:m,labels:v}}},St={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,o){var r,i;if(0===e.length)return;const a=null!==(r=n.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),s=null!==(i=n.forceStrength)&&void 0!==i?i:.1,c=o[0]/2,u=o[1]/2;for(let t=0;e.length>t;t++){const n=e[t];if(null==n.x||null==n.y||0===n.x&&0===n.y){const e=10*Math.sqrt(t+.5),o=2.399963229728653*t;n.x=c+e*Math.cos(o),n.y=u+e*Math.sin(o)}}const d=Ot(n.nodeSize,n.nodeSizeRange,e),h=l.forceLink().strength(e=>Math.min(2.5,e.weight?e.weight*s:s)).id(e=>e.id),g=o[1]/o[0],p=l.forceSimulation().force("charge",l.forceManyBody().strength(e=>-25*(e=>d(e))(e))).force("x",l.forceX(o[0]/2).strength(.1*g)).force("y",l.forceY(o[1]/2).strength(.1));if(p.nodes(e),t.length>0){const e=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));p.force("link",h),p.force("link").links(e)}.1>p.alpha()&&p.alpha(1),p.stop();for(let e=0;a>e;++e)p.tick();const f=new Map;for(const t of e)f.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=f.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=f.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,o){var r,i,a;const l=n.nodeStyle,c=n.edgeStyle,u=Ot(n.nodeSize,n.nodeSizeRange,e),d=Array.isArray(n.colorScheme)?n.colorScheme:s.schemeCategory10,h=new Map;e.forEach((e,t)=>{h.set(e.id,d[t%d.length])});const g=[],p=[],f=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=u(t),n=l?l(t):{},o={fill:n.fill||h.get(t.id)||"#007bff",stroke:n.stroke||"#fff",strokeWidth:null!==(r=n.strokeWidth)&&void 0!==r?r:2,opacity:n.opacity};g.push({type:"circle",cx:t.x,cy:t.y,r:e,style:o,datum:t,id:t.id,label:t.id})}const y=new Map;for(const t of e)y.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:y.get(e.source),n="object"==typeof e.target?e.target:y.get(e.target);if(!t||!n)continue;if(null==t.x||null==t.y)continue;if(null==n.x||null==n.y)continue;const o=c?c(e):{},r={stroke:o.stroke||"#999",strokeWidth:null!==(i=o.strokeWidth)&&void 0!==i?i:1,opacity:null!==(a=o.opacity)&&void 0!==a?a:.6};p.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:r,datum:e})}if(!1!==n.showLabels){const t=(m=n.nodeLabel)?"function"==typeof m?m:e=>e[m]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const o=u(n);f.push({x:n.x,y:n.y-o-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var m;return{sceneNodes:g,sceneEdges:p,labels:f}}};function Ot(e,t,n){var i,a;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const s=t||[5,20],l=n.map(t=>{var n;return null===(n=t.data)||void 0===n?void 0:n[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===l.length)return()=>s[0];const c=null!==(i=r.min(l))&&void 0!==i?i:0,u=null!==(a=r.max(l))&&void 0!==a?a:1;if(c===u)return()=>(s[0]+s[1])/2;const d=o.scaleLinear().domain([c,u]).range(s).clamp(!0);return t=>{var n;const o=null===(n=t.data)||void 0===n?void 0:n[e];return null==o||"number"!=typeof o?s[0]:d(o)}}const Lt=s.schemeCategory10,Mt={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const{padAngle:r=.01,groupWidth:i=20,sortGroups:a}=n,s=Math.min(o[0],o[1])/2,l=s-i,d=o[0]/2,h=o[1]/2,g=(p=n.valueAccessor)?"function"==typeof p?p:e=>{var t;return null!==(t=e[p])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var p;const f=new Map;for(let t=0;e.length>t;t++)f.set(e[t].id,t);const y=e.length,m=Array.from({length:y},()=>Array.from({length:y},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=f.get("string"==typeof e.source?e.source:e.source.id),o=f.get(t);if(void 0===n||void 0===o)continue;const r=g(e);m[n][o]=r}const v=c.chord().padAngle(r);a&&v.sortGroups(a);const b=v(m),x=b.groups,w=u.arc().innerRadius(l).outerRadius(s);for(const t of x){const n=e[t.index],o=w.centroid(t);n.x=o[0]+d,n.y=o[1]+h,n.arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const k=new Map;for(const t of e)k.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=k.get("string"==typeof e.source?e.source:e.source.id),o=k.get(t);n&&(e.source=n),o&&(e.target=o)}const A=new Map;for(const e of t)A.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of b){const n=e[t.source.index].id,o=e[t.target.index].id,r=A.get(`${n}\0${o}`)||A.get(`${o}\0${n}`);r&&(r.chordData=t)}},buildScene(e,t,n,o){var r,i;const{groupWidth:a=20,edgeOpacity:s=.5}=n,l=Math.min(o[0],o[1])/2,u=l-a,d=o[0]/2,h=o[1]/2,g=n.nodeStyle,p=n.edgeStyle,f=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:Lt,m=new Map;e.forEach((e,t)=>{m.set(e.id,y[t%y.length])});const v=c.ribbon().radius(u),b=[],x=[],w=[];for(let t=0;e.length>t;t++){const n=e[t],o=n.arcData;if(!o)continue;let i;i=g?g(n).fill||m.get(n.id)||y[t%y.length]:m.get(n.id)||y[t%y.length];const a=g?g(n):{},s={fill:i,stroke:a.stroke||"black",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.opacity};b.push({type:"arc",cx:d,cy:h,innerR:u,outerR:l,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:s,datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.chordData;if(!t)continue;const n=v(t);if(!n)continue;const o=jt(n,d,h);let r="#999";if(p)r=p(e).fill||r;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===f&&n?r=m.get(n.id)||r:t&&(r=m.get(t.id)||r)}const a=p?p(e):{},l={fill:r,fillOpacity:null!==(i=a.fillOpacity)&&void 0!==i?i:s,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};x.push({type:"ribbon",pathD:o,style:l,datum:e})}if(!1!==n.showLabels){const t=(k=n.nodeLabel)?"function"==typeof k?k:e=>e[k]||e.id:null,o=l+12;for(const n of e){const e=n.arcData;if(!e)continue;const r=t?t(n):n.id;if(!r)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;w.push({x:d+Math.cos(a)*o,y:h+Math.sin(a)*o,text:r+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var k;return{sceneNodes:b,sceneEdges:x,labels:w}}};function jt(e,t,n){const o=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return e;const r=[];let i=0;for(;o.length>i;){const e=o[i];if("M"===e||"L"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("C"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;3>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("Q"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;2>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("A"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&(r.push(Number(o[i])+t+""),i++),o.length>i&&(r.push(Number(o[i])+n+""),i++);else"Z"===e||"z"===e?(r.push(e),i++):(r.push(o[i]),i++)}return r.join(" ")}const Pt={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,o){var r;const a=n.__hierarchyRoot;if(!a)return;const s=n.chartType,l=(c=n.childrenAccessor)?"function"==typeof c?c:e=>e[c]:void 0;var c;const u=n.hierarchySum||(e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0}),d=i.hierarchy(a,l);d.sum(u),d.sort((e,t)=>{var n,o;return(null!==(n=t.value)&&void 0!==n?n:0)-(null!==(o=e.value)&&void 0!==o?o:0)});const[h,g]=o;switch(s){case"tree":!function(e,t,n,o){const r=t.treeOrientation||"vertical",a=i.tree();a.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),a(e)}(d,n,h,g);break;case"cluster":!function(e,t,n,o){const r=t.treeOrientation||"vertical",a=i.cluster();a.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),a(e)}(d,n,h,g);break;case"treemap":!function(e,t,n,o){var r,a;const s=null!==(r=t.padding)&&void 0!==r?r:4,l=null!==(a=t.paddingTop)&&void 0!==a?a:0,c=i.treemap().size([n,o]).tile(i.treemapBinary).padding(s);l>0&&c.paddingTop(l),c(e)}(d,n,h,g);break;case"circlepack":!function(e,t,n,o){var r;const a=null!==(r=t.padding)&&void 0!==r?r:4;i.pack().size([n,o]).padding(a)(e)}(d,n,h,g);break;case"partition":!function(e,t,n,o){var r;i.partition().size([n,o]).padding(null!==(r=t.padding)&&void 0!==r?r:1)(e)}(d,n,h,g)}const p=d.descendants();e.length=0,t.length=0;const f=new Map;for(let t=0;p.length>t;t++){const o=p[t],i={id:Bt(o,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(r=o.value)&&void 0!==r?r:0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===s||"cluster"===s?Ct(i,o,n):"treemap"===s||"partition"===s?Nt(i,o):"circlepack"===s&&Dt(i,o),i.__hierarchyNode=o,e.push(i),f.set(o,i)}if("tree"===s||"cluster"===s)for(const e of p)if(e.parent){const n=f.get(e.parent),o=f.get(e);n&&o&&t.push({source:n,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,o){const r=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,o,r,i){var a,s,l,c,u;const d=[],h=[],g=[],p=n.treeOrientation||"vertical",f="radial"===p,y=o[0]/2,m=o[1]/2,v="number"==typeof(x=n.nodeSize)?x:5,b=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];var x;for(const t of e){let e=t.x,o=t.y;f&&(e+=y,o+=m);const i=r(t);let s=i.fill||"#4d430c";n.colorByDepth&&void 0!==t.depth&&(s=b[t.depth%b.length]);const l={fill:s,stroke:i.stroke||"#fff",strokeWidth:null!==(a=i.strokeWidth)&&void 0!==a?a:1,opacity:i.opacity};d.push({type:"circle",cx:e,cy:o,r:v,style:l,datum:t,id:t.id,label:t.id,depth:t.depth})}const w=null!==(s=n.edgeOpacity)&&void 0!==s?s:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let o=t.x,r=t.y,a=n.x,s=n.y;f&&(o+=y,r+=m,a+=y,s+=m);const u=Tt(o,r,a,s,p),d=i(e),g={fill:"none",stroke:d.stroke||"#999",strokeWidth:null!==(l=d.strokeWidth)&&void 0!==l?l:1.5,opacity:null!==(c=d.opacity)&&void 0!==c?c:w};h.push({type:"curved",pathD:u,style:g,datum:e})}if(!1!==n.showLabels){const t=Ht(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let o,r,i,a=n.x,s=n.y;if(f&&(a+=y,s+=m),f){const e=a-y,t=s-m,n=Math.sqrt(e*e+t*t);n>0?(o=a+e/n*10,r=s+t/n*10,i=0>e?"end":"start"):(o=a,r=s-12,i="middle")}else"horizontal"===p?((null===(u=n.data)||void 0===u?void 0:u.children)&&0!==n.data.children.length?(o=a-v-6,i="end"):(o=a+v+6,i="start"),r=s):(o=a,r=s+v+14,i="middle");g.push({x:o,y:r,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:g}}(e,t,n,o,r,i);case"treemap":case"partition":return function(e,t,n,o){var r,i;const a=[],s=[],l=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const s=o(n);let c=s.fill||"#4d430c";t.colorByDepth&&void 0!==n.depth&&(c=l[n.depth%l.length]);const u={fill:c,stroke:s.stroke||"#fff",strokeWidth:null!==(r=s.strokeWidth)&&void 0!==r?r:1,opacity:s.opacity};a.push({type:"rect",x:n.x0,y:n.y0,w:e,h:i,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Ht(t.nodeLabel);for(const o of e){const e=o.x1-o.x0,r=o.y1-o.y0;if(0>=e||0>=r)continue;if((null===(i=o.data)||void 0===i?void 0:i.children)&&o.data.children.length>0&&"partition"!==t.chartType)continue;const a=n?n(o):o.id;a&&(30>e||16>r||s.push({x:o.x0+e/2,y:o.y0+r/2,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,r)/6))}))}}return{sceneNodes:a,sceneEdges:[],labels:s}}(e,n,0,r);case"circlepack":return function(e,t,n,o){var r,i,a,s,l;const c=[],u=[],d=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of e){const e=null!==(r=n.__radius)&&void 0!==r?r:5;if(0>=e)continue;const s=o(n);let l=s.fill||"#4d430c";t.colorByDepth&&void 0!==n.depth&&(l=d[n.depth%d.length]);const u={fill:l,stroke:s.stroke||"#fff",strokeWidth:null!==(i=s.strokeWidth)&&void 0!==i?i:1,opacity:null!==(a=s.opacity)&&void 0!==a?a:.7};c.push({type:"circle",cx:n.x,cy:n.y,r:e,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Ht(t.nodeLabel);for(const t of e){const e=null!==(s=t.__radius)&&void 0!==s?s:5,o=n?n(t):t.id;if(!o)continue;if(15>e)continue;const r=!((null===(l=t.data)||void 0===l?void 0:l.children)&&t.data.children.length>0);u.push({x:t.x,y:r?t.y:t.y-e+14,text:o+"",anchor:"middle",baseline:r?"middle":"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:r?void 0:"#000",stroke:r?void 0:"#fff",strokeWidth:r?void 0:3,paintOrder:r?void 0:"stroke"})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(e,n,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Ct(e,t,n){const o=n.treeOrientation||"vertical";if("radial"===o){const n=t.x,o=t.y;e.x=o*Math.cos(n-Math.PI/2),e.y=o*Math.sin(n-Math.PI/2)}else"horizontal"===o?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function Nt(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function Dt(e,t){var n;const o=null!==(n=t.r)&&void 0!==n?n:0;e.x=t.x,e.y=t.y,e.x0=t.x-o,e.x1=t.x+o,e.y0=t.y-o,e.y1=t.y+o,e.width=2*o,e.height=2*o,e.__radius=o}function Tt(e,t,n,o,r){if("horizontal"===r){const r=(e+n)/2;return`M ${e},${t} C ${r},${t} ${r},${o} ${n},${o}`}if("radial"===r){const r=(e+n)/2;return`M ${e},${t} Q ${r},${t} ${r},${(t+o)/2} T ${n},${o}`}{const r=(t+o)/2;return`M ${e},${t} C ${e},${r} ${n},${r} ${n},${o}`}}function Bt(e,t,n){const o=t.nodeIDAccessor;return"function"==typeof o?o(e.data)+"":"string"==typeof o&&void 0!==e.data[o]?e.data[o]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function Ht(e){return e?"function"==typeof e?e:t=>{var n;return(null===(n=t.data)||void 0===n?void 0:n[e])||t[e]||t.id}:null}const Wt={sankey:Et,force:St,chord:Mt,tree:Pt,cluster:Pt,treemap:Pt,circlepack:Pt,partition:Pt};function Rt(e){return Wt[e]}class $t{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.particlePool=null,this.transition=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.config=e,this.tensionConfig=Object.assign(Object.assign({},Ce),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new De(2e3))}updateConfig(e){this.config=e,this.tensionConfig=Object.assign(Object.assign({},Ce),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&!this.particlePool&&(this.particlePool=new De(2e3))}ingestHierarchy(e,t){this.nodes.clear(),this.edges.clear(),this.config.__hierarchyRoot=e,this.runLayout(t)}ingestBounded(e,t,n){const{nodeIDAccessor:o="id",sourceAccessor:r="source",targetAccessor:i="target",valueAccessor:a="value"}=this.config,s="function"==typeof o?o:e=>e[o],l="function"==typeof r?r:e=>e[r],c="function"==typeof i?i:e=>e[i],u="function"==typeof a?a:e=>{var t;return null!==(t=e[a])&&void 0!==t?t:1};this.nodes.clear(),this.edges.clear();for(const t of e){const e=s(t)+"";this.nodes.set(e,Object.assign(Object.assign({},_t(e)),{data:t}))}for(const e of t){const t=l(e)+"",n=c(e)+"",o=Number(u(e))||1;this.nodes.has(t)||this.nodes.set(t,Object.assign(Object.assign({},_t(t)),{data:e})),this.nodes.has(n)||this.nodes.set(n,Object.assign(Object.assign({},_t(n)),{data:e})),this.edges.set(`${t}\0${n}`,{source:t,target:n,value:o,y0:0,y1:0,sankeyWidth:0,data:e})}this.runLayout(n)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:n,value:o}=e,r=0===this.nodes.size;let i=!1;const a="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=a,this.nodes.has(t)||(this.nodes.set(t,_t(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,_t(n)),this.nodeTimestamps.set(n,a),this.tension+=this.tensionConfig.newNode,i=!0);const s=this.edgeKey(t,n),l=this.edges.get(s);return l?(l.value+=o,this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.weightChange):(this.edges.set(s,{source:t,target:n,value:o,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.newEdge,i=!0),r||i||this.tension>=this.tensionConfig.threshold}runLayout(e){const t=Rt(this.config.chartType);if(!t)return;let n=Array.from(this.nodes.values()),o=Array.from(this.edges.values());if(0===n.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.computeLayout(n,o,this.config,e),t.hierarchical&&n.length>0){this.nodes.clear(),this.edges.clear();for(const e of n)this.nodes.set(e.id,e);for(const e of o)this.edges.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e)}this.finalizeLayout(),this.saveTargetPositions(),n.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1))&&this.tensionConfig.transitionDuration>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:this.tensionConfig.transitionDuration});const r=new Set(this.nodes.keys()),i=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of r)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)r.has(e)||this.removedNodes.add(e);for(const e of i)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)i.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=r,this.previousEdgeKeys=i,this.layoutVersion++}buildScene(e){const t=Rt(this.config.chartType);if(!t)return;const n=Array.from(this.nodes.values()),o=Array.from(this.edges.values()),{sceneNodes:r,sceneEdges:i,labels:a}=t.buildScene(n,o,this.config,e);this.sceneNodes=r,this.sceneEdges=i,this.labels=a}advanceTransition(e){if(!this.transition)return!1;const t=Math.min((e-this.transition.startTime)/this.transition.duration,1),n=1-Math.pow(1-t,3);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0+(e._targetX0-e._prevX0)*n,e.x1=e._prevX1+(e._targetX1-e._prevX1)*n,e.y0=e._prevY0+(e._targetY0-e._prevY0)*n,e.y1=e._prevY1+(e._targetY1-e._prevY1)*n);for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0+(e._targetY0-e._prevY0)*n,e.y1=e._prevY1+(e._targetY1-e._prevY1)*n,e.sankeyWidth=e._prevSankeyWidth+(e._targetSankeyWidth-e._prevSankeyWidth)*n);return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){for(const e of this.nodes.values())e._prevX0=e.x0,e._prevX1=e.x1,e._prevY0=e.y0,e._prevY1=e.y1;for(const e of this.edges.values())e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth);this.rebuildAllBeziers()}updateEdgeBezier(e){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,n="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&n&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,n))}buildStandardBezier(e,t,n){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const r=t.y1,i=n.y0,s=a.interpolateNumber(r,i);return{circular:!1,points:[{x:e.y0,y:r},{x:e.y0,y:s(.5)},{x:e.y1,y:s(.5)},{x:e.y1,y:i}],halfWidth:o}}const r=t.x1,i=n.x0,s=a.interpolateNumber(r,i);return{circular:!1,points:[{x:r,y:e.y0},{x:s(.5),y:e.y0},{x:s(.5),y:e.y1},{x:i,y:e.y1}],halfWidth:o}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),o=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-o,y:n.targetY},{x:n.targetX-.66*o,y:n.targetY},{x:n.targetX-.33*o,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let o;o="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const r=[];for(let e=0;o.length-1>e;e++){const t=o[e],n=o[e+1],i=n.x-t.x,a=n.y-t.y;r.push([t,{x:t.x+i/3,y:t.y+a/3},{x:t.x+2*i/3,y:t.y+2*a/3},n])}return{circular:!0,segments:r,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){var t,n,o,r,i;const a=this.config.pulse;if(!a)return;const s=null!==(t=a.duration)&&void 0!==t?t:500,l=null!==(n=a.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(o=a.glowRadius)&&void 0!==o?o:4;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const o=this.nodeTimestamps.get(n);if(!o)continue;const r=e-o;s>r&&(t._pulseIntensity=1-r/s,t._pulseColor=l,t._pulseGlowRadius=c)}for(const t of this.sceneEdges){const n=t.datum;if(!n)continue;const o="object"==typeof n.source?null===(r=n.source)||void 0===r?void 0:r.id:n.source,a="object"==typeof n.target?null===(i=n.target)||void 0===i?void 0:i.id:n.target;if(!o||!a)continue;const c=this.edgeTimestamps.get(`${o}\0${a}`);if(!c)continue;const u=e-c;s>u&&(t._pulseIntensity=1-u/s,t._pulseColor=l)}}applyDecay(){var e,t,n,o,r;const i=this.config.decay;if(!i)return;const a=null!==(e=i.minOpacity)&&void 0!==e?e:.1,s=this.nodeTimestamps.size;if(1>=s)return;const l=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]),c=new Map;for(let e=0;l.length>e;e++)c.set(l[e][0],e);for(const e of this.sceneNodes){const l=e.id;if(!l)continue;const u=c.get(l);if(void 0===u)continue;const d=s-1-u;let h;switch(i.type){case"linear":h=a+(1-d/(s-1))*(1-a);break;case"exponential":{const e=null!==(t=i.halfLife)&&void 0!==t?t:s/2;h=a+Math.pow(.5,d/e)*(1-a);break}case"step":h=(null!==(n=i.stepThreshold)&&void 0!==n?n:.5*s)>d?1:a;break;default:h=1}const g=null!==(r=null===(o=e.style)||void 0===o?void 0:o.opacity)&&void 0!==r?r:1;e.style=Object.assign(Object.assign({},e.style),{opacity:g*h})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const n=e-this.lastTopologyChangeTime;if(n>=2e3)return;const o=1-n/2e3;for(const e of this.sceneNodes){const n=e.id;n&&this.addedNodes.has(n)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,o),e._pulseColor="rgba(34, 197, 94, 0.7)",e._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(e){var t,n;const o=this.config.thresholds;if(!o)return;const r=null!==(t=o.warningColor)&&void 0!==t?t:"#f59e0b",i=null!==(n=o.criticalColor)&&void 0!==n?n:"#ef4444",a=!1!==o.pulse;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const s=this.nodes.get(n);if(!s)continue;const l=o.metric(s);let c=null;void 0===o.critical||o.critical>l?void 0===o.warning||o.warning>l||(c=r):c=i,c&&(t.style=Object.assign(Object.assign({},t.style),{fill:c}),a&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=c,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const n=e.metric(t);if(void 0!==e.warning&&n>=e.warning||void 0!==e.critical&&n>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const n="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>n-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}clear(){this.nodes.clear(),this.edges.clear(),this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.lastIngestTime=0,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function _t(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function zt(e,t,n,o,r=30){let i=null,a=r,s=1/0;for(const t of e){const e=It(t,n,o);if(e)if("rect"===t.type){const n=t.w*t.h;s>n&&(i=e,s=n)}else a>e.distance&&(i=e,a=e.distance)}if(i)return i;for(const e of t){const t=Ft(e,n,o);t&&a>t.distance&&(i=t,a=t.distance)}return i}function It(e,t,n){switch(e.type){case"circle":return function(e,t,n){const o=t-e.cx,r=n-e.cy,i=Math.sqrt(o*o+r*r);return i>Math.max(e.r,5)+5?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:i}}(e,t,n);case"rect":return function(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{type:"node",datum:e.datum,x:e.x+e.w/2,y:e.y+e.h/2,distance:0}}(e,t,n);case"arc":return function(e,t,n){const o=t-e.cx,r=n-e.cy,i=Math.sqrt(o*o+r*r);if(e.innerR-2>i||i>e.outerR+2)return null;let a=Math.atan2(r,o);0>a&&(a+=2*Math.PI);let s,l=e.startAngle,c=e.endAngle;if(0>l&&(l+=2*Math.PI),0>c&&(c+=2*Math.PI),s=l>c?a>=l||c>=a:a>=l&&c>=a,s){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(e,t,n);default:return null}}function Ft(e,t,n){switch(e.type){case"bezier":return function(e,t,n){var o,r;if(!e.pathD)return null;try{const i=new Path2D(e.pathD),a=document.createElement("canvas").getContext("2d");if(!a)return null;if(a.isPointInPath(i,t,n)){const i="object"==typeof(null===(o=e.datum)||void 0===o?void 0:o.source)?e.datum.source:null,a="object"==typeof(null===(r=e.datum)||void 0===r?void 0:r.target)?e.datum.target:null;return{type:"edge",datum:e.datum,x:i&&a?(i.x1+a.x0)/2:t,y:e.datum?(e.datum.y0+e.datum.y1)/2:n,distance:0}}}catch(e){}return null}(e,t,n);case"line":return function(e,t,n){const o=e.x2-e.x1,r=e.y2-e.y1,i=o*o+r*r;if(0===i)return null;let a=((t-e.x1)*o+(n-e.y1)*r)/i;a=Math.max(0,Math.min(1,a));const s=e.x1+a*o,l=e.y1+a*r,c=Math.sqrt(Math.pow(t-s,2)+Math.pow(n-l,2));return c>5?null:{type:"edge",datum:e.datum,x:s,y:l,distance:c}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;try{const o=new Path2D(e.pathD),r=document.createElement("canvas").getContext("2d");if(!r)return null;if(r.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0}}catch(e){}return null}(e,t,n);default:return null}}function Yt(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:i,labels:a,title:s,legend:l,foregroundGraphics:c,annotations:u,svgAnnotationRules:d}=e;return h.createElement("svg",{width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},h.createElement("g",{transform:`translate(${i.left},${i.top})`},a.map((e,t)=>h.createElement("text",{key:"label-"+t,x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"currentColor",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"}},e.text)),u&&d&&u.map((e,o)=>{const r=d(e,o,{width:t,height:n});return r?h.createElement(h.Fragment,{key:"annotation-"+o},r):null}),c),s&&"string"==typeof s?h.createElement("text",{x:o/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},s):s?h.createElement("foreignObject",{x:0,y:0,width:o,height:i.top},s):null,l&&"object"==typeof l&&"legendGroups"in l?h.createElement("g",{transform:`translate(${o-i.right+10},${i.top})`},l.legendGroups.map((e,t)=>{var n;return h.createElement("g",{key:"legend-group-"+t},null===(n=e.items)||void 0===n?void 0:n.map((e,t)=>h.createElement("g",{key:"legend-item-"+t,transform:`translate(0,${20*t})`},h.createElement("rect",{x:0,y:0,width:12,height:12,fill:e.color,rx:2}),h.createElement("text",{x:18,y:10,fontSize:11,fill:"currentColor"},e.label))))})):l?h.createElement("g",{transform:`translate(${o-i.right+10},${i.top})`},l):null)}function Gt(e,t){var n,o,r,i,a,s;if(!t.pathD)return;e.save();const l=new Path2D(t.pathD);if(t.style.fill&&"none"!==t.style.fill){const a=t._gradient;if(a){const r=e.createLinearGradient(a.x0,0,a.x1,0),i=null!==(o=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==o?o:.5,s=t.style.fill;r.addColorStop(0,1===a.from?s:"transparent"),r.addColorStop(1,1===a.to?s:"transparent"),e.fillStyle=r,e.globalAlpha=i}else e.fillStyle=t.style.fill,e.globalAlpha=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.5;e.fill(l)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(a=t.style.strokeWidth)&&void 0!==a?a:.5,e.globalAlpha=.5*(null!==(s=t.style.opacity)&&void 0!==s?s:1),e.stroke(l)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(l)),e.restore()}function Xt(e,t){var n,o;e.save(),e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(o=t.style.strokeWidth)&&void 0!==o?o:1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function qt(e,t){var n,o,r,i;if(!t.pathD)return;e.save();const a=new Path2D(t.pathD);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(o=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==o?o:.5,e.fill(a)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:.5,e.globalAlpha=.3*(null!==(i=t.style.opacity)&&void 0!==i?i:1),e.stroke(a)),e.restore()}function Vt(e,t){var n,o;if(!t.pathD)return;e.save();const r=new Path2D(t.pathD);e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(r),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(o=t.style.fillOpacity)&&void 0!==o?o:.1,e.fill(r)),e.restore()}Yt.displayName="NetworkSVGOverlay";const Ut={category10:s.schemeCategory10,tableau10:s.schemeTableau10,set3:s.schemeSet3,blues:s.interpolateBlues,reds:s.interpolateReds,greens:s.interpolateGreens,oranges:s.interpolateOranges,purples:s.interpolatePurples,viridis:s.interpolateViridis,plasma:s.interpolatePlasma},Zt=s.schemeCategory10,Qt=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"];function Kt(e,t,n){if("function"==typeof t)return t(e);const o=e[t];return n?n(o):Zt[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(o+""))%Zt.length]}function Jt(e,t,n="category10"){const r=Array.from(new Set(e.map(e=>e[t]))),i=r.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return o.scaleOrdinal().domain(r).range(n).unknown("#999");const a=Ut[n]||Ut.category10;if(i&&"function"==typeof a)return e=>a(Number(e)/Math.max(...r.map(Number)));{const e=Array.isArray(a)?a:Zt;return o.scaleOrdinal().domain(r).range(e).unknown("#999")}}function en(e,t,n=[3,20],o){let r;if(r="function"==typeof t?t(e):e[t],!o)return r;const[i,a]=o,[s,l]=n;return a===i?(s+l)/2:s+(r-i)/(a-i)*(l-s)}const tn={top:20,right:80,bottom:20,left:80},nn={top:40,right:40,bottom:40,left:40},on=new Set(["chord","force","circlepack"]),rn=[800,600],an={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function sn({data:e}){var t,n,o,r,i,a;if("edge"===e.type){const t=e.data;return h.createElement("div",{className:"semiotic-tooltip",style:an},h.createElement("div",{style:{fontWeight:600}},"object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target),null!=t.value&&h.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""))}const s=e.data,l=null==s?void 0:s.__hierarchyNode;if(l){const e=[];let i=l;for(;i;){const a=null!==(r=null!==(n=null===(t=i.data)||void 0===t?void 0:t.name)&&void 0!==n?n:null===(o=i.data)||void 0===o?void 0:o.id)&&void 0!==r?r:s.id;null!=a&&e.unshift(a+""),i=i.parent}e.length>1&&e.shift();const a=e.length-1;return h.createElement("div",{className:"semiotic-tooltip",style:an},h.createElement("div",null,e.map((e,t)=>h.createElement("span",{key:t},t>0&&h.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),t===a?h.createElement("strong",null,e):h.createElement("span",{style:{opacity:.7}},e)))),null!=s.value&&s.value>0&&h.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof s.value?s.value.toLocaleString():s.value+""))}const c=((null===(i=s.sourceLinks)||void 0===i?void 0:i.length)||0)+((null===(a=s.targetLinks)||void 0===a?void 0:a.length)||0),u=(s.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(s.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return h.createElement("div",{className:"semiotic-tooltip",style:an},h.createElement("div",{style:{fontWeight:600}},s.id),null!=s.value&&s.value>0&&h.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof s.value?s.value.toLocaleString():s.value+""),c>0&&h.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",c,u!==c&&` (weighted: ${u.toLocaleString()})`))}const ln=e.forwardRef(function(t,n){const{chartType:o,nodes:r,edges:i,data:a,initialEdges:s,nodeIDAccessor:l="id",sourceAccessor:c="source",targetAccessor:u="target",valueAccessor:d="value",childrenAccessor:g,hierarchySum:p,orientation:f="horizontal",nodeAlign:y="justify",nodePaddingRatio:m=.05,nodeWidth:v=15,iterations:b=300,forceStrength:x=.1,padAngle:w=.01,groupWidth:k=20,sortGroups:A,edgeSort:E,treeOrientation:S="vertical",edgeType:O="curve",padding:L,paddingTop:M,tensionConfig:j,showParticles:P=!1,particleStyle:C,nodeStyle:N,edgeStyle:T,colorBy:H,colorScheme:W="category10",edgeColorBy:R="source",edgeOpacity:$=.5,colorByDepth:_=!1,nodeSize:z=8,nodeSizeRange:I=[5,20],nodeLabel:F,showLabels:Y=!0,size:G=rn,responsiveWidth:X,responsiveHeight:q,margin:V,className:U,background:Z,enableHover:Q=!0,tooltipContent:K,customHoverBehavior:J,customClickBehavior:ee,onObservation:te,chartId:ne,onTopologyChange:oe,annotations:re,svgAnnotationRules:ie,legend:ae,title:se,foregroundGraphics:le,backgroundGraphics:ce,decay:ue,pulse:de,staleness:he,thresholds:ge}=t,pe=on.has(o)?nn:tn,[fe,ye]=B(G,X,q),me=Object.assign(Object.assign({},pe),V),ve=ye[0]-me.left-me.right,be=ye[1]-me.top-me.bottom,xe=e.useMemo(()=>Object.assign(Object.assign({},Ce),j),[j]),we=e.useMemo(()=>Object.assign(Object.assign({},Ne),C),[C]),ke=e.useMemo(()=>({chartType:o,nodeIDAccessor:l,sourceAccessor:c,targetAccessor:u,valueAccessor:d,childrenAccessor:g,hierarchySum:p,orientation:f,nodeAlign:y,nodePaddingRatio:m,nodeWidth:v,iterations:b,forceStrength:x,padAngle:w,groupWidth:k,sortGroups:A,edgeSort:E,treeOrientation:S,edgeType:O,padding:L,paddingTop:M,tensionConfig:xe,showParticles:P,particleStyle:we,nodeStyle:N,edgeStyle:T,nodeLabel:F,showLabels:Y,colorBy:H,colorScheme:W,edgeColorBy:R,edgeOpacity:$,colorByDepth:_,nodeSize:z,nodeSizeRange:I,decay:ue,pulse:de,staleness:he,thresholds:ge}),[o,l,c,u,d,g,p,f,y,m,v,b,x,w,k,A,E,S,O,L,M,xe,P,we,N,T,F,Y,H,W,R,$,_,z,I,ue,de,he,ge]),Ae=e.useRef(null),Ee=e.useRef(0),Se=e.useRef(0),Oe=e.useRef(!0),Le=e.useRef(()=>{}),Me=e.useRef(null);Me.current||(Me.current=new $t(ke));const[je,Pe]=e.useState(null),[De,Te]=e.useState(0),[Be,He]=e.useState(0),[We,Re]=e.useState(!1),$e=e.useRef(null),_e=e.useRef(new Map),ze=e.useRef(0),Ie=e.useCallback(e=>{if("function"==typeof H)return H(e);if("string"==typeof H&&e.data){const t=e.data[H];if(void 0!==t){if(!_e.current.has(t+"")){const e=Array.isArray(W)?W:Zt;_e.current.set(t+"",e[ze.current++%e.length])}return _e.current.get(t+"")}}if(!_e.current.has(e.id)){const t=Array.isArray(W)?W:Zt;_e.current.set(e.id,t[ze.current++%t.length])}return _e.current.get(e.id)},[H,W]),Fe=e.useCallback(e=>{if("function"==typeof R)return R(e);const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;return"target"===R&&n?Ie(n):t?Ie(t):"#999"},[R,Ie]),Ye=e.useCallback(e=>{if(!(null==C?void 0:C.colorBy))return Fe(e);const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;return"target"===we.colorBy&&n?Ie(n):t?Ie(t):"#999"},[null==C?void 0:C.colorBy,we.colorBy,Ie,Fe]),Ge="sankey"===o&&P||!!de,Xe=e.useCallback(()=>{Ee.current&&!Ge||Ee.current||(Ee.current=requestAnimationFrame(()=>Le.current()))},[Ge]);e.useEffect(()=>{var e;null===(e=Me.current)||void 0===e||e.updateConfig(ke),Oe.current=!0,Xe()},[ke,Xe]);const qe=e.useCallback(()=>{const e=Me.current;if(!e)return;e.runLayout([ve,be]),e.buildScene([ve,be]),Oe.current=!0;const t=Array.isArray(W)?W:Zt,n=Array.from(e.nodes.values());for(let e=0;n.length>e;e++){const o=n[e];_e.current.has(o.id)||_e.current.set(o.id,t[e%t.length])}if(ze.current=n.length,Te(e.layoutVersion),oe){const{nodes:t,edges:n}=e.getLayoutData();oe(t,n)}},[ve,be,oe,W]),Ve=e.useCallback(e=>{const t=Me.current;t&&(t.ingestEdge(e)&&qe(),Xe())},[qe,Xe]),Ue=e.useCallback(e=>{const t=Me.current;if(!t)return;let n=!1;for(const o of e)t.ingestEdge(o)&&(n=!0);n&&qe(),Xe()},[qe,Xe]),Ze=e.useCallback(()=>{var e;null===(e=Me.current)||void 0===e||e.clear(),_e.current.clear(),ze.current=0,Te(0),Pe(null),$e.current=null,Oe.current=!0,Xe()},[Xe]),Qe=e.useCallback(()=>{const e=Me.current;e&&(e.tension+=999,qe(),Xe())},[qe,Xe]);e.useImperativeHandle(n,()=>({push:Ve,pushMany:Ue,clear:Ze,getTopology:()=>{var e,t;return null!==(t=null===(e=Me.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=Me.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:Qe,getTension:()=>{var e,t;return null!==(t=null===(e=Me.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[Ve,Ue,Ze,Qe]);const Ke=["tree","cluster","treemap","circlepack","partition"].includes(o),Je=Ke?a||(Array.isArray(i)?void 0:i):void 0;e.useEffect(()=>{const e=Me.current;if(e)if(Ke&&Je)e.ingestHierarchy(Je,[ve,be]),e.buildScene([ve,be]),Oe.current=!0,Xe();else{const t=r||[],n=Array.isArray(i)?i:[];if(0===t.length&&0===n.length)return;e.ingestBounded(t,n,[ve,be]),e.buildScene([ve,be]);const o=Array.isArray(W)?W:Zt,a=Array.from(e.nodes.values());for(let e=0;a.length>e;e++){const t=a[e];_e.current.has(t.id)||_e.current.set(t.id,o[e%o.length])}ze.current=a.length,Oe.current=!0,Xe()}},[r,i,a,Je,Ke,ve,be,ke,Xe,W]),e.useEffect(()=>{s&&s.length>0&&Ue(s)},[]);const et=e.useCallback(e=>{if(J&&J(e),te){const t=Date.now();te(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:ne}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:ne})}},[J,te,ne]),tt=e.useCallback(e=>{if(ee&&ee(e),te){const t=Date.now();te(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:ne}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:ne})}},[ee,te,ne]),nt=e.useRef(()=>{}),ot=e.useRef(()=>{});nt.current=e=>{if(!Q)return;const t=Ae.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-me.left,r=e.clientY-n.top-me.top;if(0>o||o>ve||0>r||r>be)return void($e.current&&($e.current=null,Pe(null),et&&(et(null),Oe.current=!0),Xe()));const i=Me.current;if(!i)return;const a=zt(i.sceneNodes,i.sceneEdges,o,r);if(!a)return void($e.current&&($e.current=null,Pe(null),et&&(et(null),Oe.current=!0),Xe()));const s={type:a.type,data:a.datum,x:a.x,y:a.y};$e.current=s,Pe(s),et&&(et(s),Oe.current=!0),Xe()},ot.current=()=>{$e.current&&($e.current=null,Pe(null),et&&(et(null),Oe.current=!0),Xe())};const rt=e.useRef(()=>{});rt.current=e=>{if(!ee&&!te)return;const t=Ae.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-me.left,r=e.clientY-n.top-me.top;if(0>o||o>ve||0>r||r>be)return;const i=Me.current;if(!i)return;const a=zt(i.sceneNodes,i.sceneEdges,o,r);tt(a?{type:a.type,data:a.datum,x:a.x,y:a.y}:null)},e.useCallback(e=>nt.current(e),[]);const it=e.useCallback(()=>ot.current(),[]),at=e.useCallback(e=>rt.current(e),[]),st=e.useRef(-1),lt=e.useCallback(e=>{const t=Me.current;if(!t)return;const n=function(e){const t=[];for(const n of e)"circle"===n.type&&null!=n.cx?t.push({x:n.cx,y:n.cy,datum:n.datum}):"rect"===n.type&&null!=n.x?t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum}):"arc"===n.type&&null!=n.cx&&t.push({x:n.cx,y:n.cy,datum:n.datum});return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.sceneNodes);if(0===n.length)return;const o=st.current,r=D(e.key,0>o?-1:o,n.length);if(null===r)return;if(e.preventDefault(),0>r)return st.current=-1,$e.current=null,Pe(null),et&&(et(null),Oe.current=!0),void Xe();const i=0>o?0:r;st.current=i;const a=n[i],s={type:"node",data:a.datum,x:a.x,y:a.y};$e.current=s,Pe(s),et&&(et(s),Oe.current=!0),Xe()},[et,Xe]),ct=e.useCallback(e=>{st.current=-1,nt.current(e)},[]);Le.current=()=>{var e,t,n;Ee.current=0;const o=Ae.current;if(!o)return;const r=o.getContext("2d");if(!r)return;const i=Me.current;if(!i)return;const a=performance.now(),s=Se.current?Math.min((a-Se.current)/1e3,.1):.016;Se.current=a;const l=i.advanceTransition(a);(l||Oe.current)&&i.buildScene([ve,be]);const c="undefined"!=typeof window&&window.devicePixelRatio||1;o.width=ye[0]*c,o.height=ye[1]*c,o.style.width=ye[0]+"px",o.style.height=ye[1]+"px",r.scale(c,c),r.translate(me.left,me.top),r.clearRect(-me.left,-me.top,ye[0],ye[1]),Z&&(r.fillStyle=Z,r.fillRect(0,0,ve,be)),ue&&i.applyDecay(),de&&i.applyPulse(a),ge&&i.applyThresholds(a),i.applyTopologyDiff(a);const u=null!==(e=null==he?void 0:he.threshold)&&void 0!==e?e:5e3,d=he&&i.lastIngestTime>0&&a-i.lastIngestTime>u;if(d&&(r.globalAlpha=null!==(t=null==he?void 0:he.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const n of t)switch(n.type){case"bezier":Gt(e,n);break;case"line":Xt(e,n);break;case"ribbon":qt(e,n);break;case"curved":Vt(e,n)}}(r,i.sceneEdges),function(e,t){var n,o,r;for(const i of t){if("rect"!==i.type)continue;const t=i;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.strokeRect(t.x,t.y,t.w,t.h)),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.restore())}}(r,i.sceneNodes),function(e,t){var n,o,r,i;for(const a of t){if("circle"!==a.type)continue;const t=a;if(t.r>0){if(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0){const n=null!==(i=t._pulseGlowRadius)&&void 0!==i?i:4,o=t.r+n*t._pulseIntensity;e.beginPath(),e.arc(t.cx,t.cy,o,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=.6*t._pulseIntensity,e.stroke()}e.restore()}}}(r,i.sceneNodes),function(e,t){var n,o,r;for(const i of t){if("arc"!==i.type)continue;const t=i;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.stroke()),e.restore()}}(r,i.sceneNodes),P&&i.particlePool&&!d){const e=Array.from(i.edges.values());if(e.length>0){!function(e,t,n,o){var r,i;const a=null!==(r=o.spawnRate)&&void 0!==r?r:Ne.spawnRate,s=null!==(i=o.maxPerEdge)&&void 0!==i?i:Ne.maxPerEdge;for(let o=0;t.length>o;o++){const r=t[o];if(!r.bezier)continue;if(e.countForEdge(o)>=s)continue;const i=r.value*a*n*(r.bezier.circular?.3:1),l=Math.floor(i),c=i-l;let u=l;Math.random()<c&&u++;for(let t=0;u>t&&e.countForEdge(o)<s;t++)e.spawn(o)}}(i.particlePool,e,s,we);const t=.5*(null!==(n=we.speedMultiplier)&&void 0!==n?n:1);let o;if(we.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);o=e.map(e=>.3+(e.value||1)/t*1.7)}i.particlePool.step(s,t,e,o),function(e,t,n,o,r){var i,a;const s=null!==(i=o.radius)&&void 0!==i?i:Ne.radius,l=null!==(a=o.opacity)&&void 0!==a?a:Ne.opacity;e.globalAlpha=l;for(let i=0;t.particles.length>i;i++){const a=t.particles[i];if(!a.active)continue;const l=n[a.edgeIndex];if(l){if("function"==typeof o.color){const t="object"==typeof l.source?l.source:null;e.fillStyle=t?o.color(l,t):"#666"}else e.fillStyle=o.color&&"inherit"!==o.color?o.color:r(l);e.beginPath(),e.arc(a.x,a.y,s,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(r,i.particlePool,e,we,Ye)}}d&&(r.globalAlpha=1);const h=Oe.current;Oe.current=!1,(h||l)&&He(e=>e+1),(Ge||l||i.hasActivePulses||i.hasActiveThresholds||i.hasActiveTopologyDiff)&&(Ee.current=requestAnimationFrame(()=>Le.current()))},e.useEffect(()=>(Xe(),()=>{Ee.current&&(cancelAnimationFrame(Ee.current),Ee.current=0)}),[Xe]),e.useEffect(()=>{Oe.current=!0,Xe()},[o,ve,be,Z,Xe]),e.useEffect(()=>{if(!he)return;const e=setInterval(()=>{var e;const t=Me.current;if(!t||0===t.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=he.threshold)&&void 0!==e?e:5e3,r=n-t.lastIngestTime>o;r!==We&&(Re(r),Oe.current=!0,Xe())},1e3);return()=>clearInterval(e)},[he,We,Xe]);const ut=Q&&je?h.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:me.left+je.x,top:me.top+je.y,transform:`translate(${je.x>.6*ve?"calc(-100% - 12px)":"12px"}, ${.3*be>je.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2}},K?K(je):h.createElement(sn,{data:je})):null,dt=Me.current;return h.createElement("div",{ref:fe,className:"stream-network-frame"+(U?" "+U:""),role:"img","aria-label":"string"==typeof se?se:"Network chart",tabIndex:0,style:{position:"relative",width:X?"100%":ye[0],height:q?"100%":ye[1]},onMouseMove:Q?ct:void 0,onMouseLeave:Q?it:void 0,onClick:ee||te?at:void 0,onKeyDown:lt},ce&&h.createElement("svg",{style:{position:"absolute",top:0,left:0,width:ye[0],height:ye[1],pointerEvents:"none"}},h.createElement("g",{transform:`translate(${me.left},${me.top})`},ce)),h.createElement("canvas",{ref:Ae,style:{position:"absolute",top:0,left:0}}),h.createElement(Yt,{width:ve,height:be,totalWidth:ye[0],totalHeight:ye[1],margin:me,labels:(null==dt?void 0:dt.labels)||[],title:se,legend:ae,foregroundGraphics:le,annotations:re,svgAnnotationRules:ie,annotationFrame:Be}),ut,(null==he?void 0:he.showBadge)&&h.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===he.badgePosition?{top:4,left:4}:"bottom-left"===he.badgePosition?{bottom:4,left:4}:"bottom-right"===he.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:We?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},We?"STALE":"LIVE"))});ln.displayName="StreamNetworkFrame";const cn={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"8px 12px",borderRadius:"4px",fontSize:"14px",lineHeight:"1.5",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function un(e,t){return"function"==typeof t?t(e):e[t]}function dn(e,t){return t?t(e):null==e?"":"number"==typeof e?e.toLocaleString():e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function hn(e={}){const{fields:t,title:n,format:o,style:r={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let a;const s=[];if(n){const t=un(e,n);a=dn(t,o)}if(t&&t.length>0)t.forEach(t=>{let n,r,i;"string"==typeof t?(n=t,r=t,i=o):(n=t.label,r=t.accessor||t.key||"",i=t.format||o);const a=un(e,r);s.push({label:n,value:dn(a,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){a=dn(e[n],o);break}if(!a){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(a=dn(e[t[0]],o))}}const l=Object.assign(Object.assign({},cn),r);return h.createElement("div",{className:("semiotic-tooltip "+i).trim(),style:l},a&&h.createElement("div",{style:{fontWeight:s.length>0?"bold":"normal"}},a),s.map((e,t)=>h.createElement("div",{key:t,style:{marginTop:0===t&&a?"4px":0}},e.label&&h.createElement("span",null,e.label,": "),e.value)))}}function gn(e){return!0===e||("function"==typeof e?e:!1!==e&&void 0!==e&&("object"!=typeof e||null===e||!("fields"in e)&&!("title"in e)||hn(e)))}function pn(e){return"string"==typeof e?e:"value"}function fn(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function yn(e,t){return"function"==typeof t?t(e):e[t]}function mn(e){return t=>{const n=t.data;return n?h.createElement("div",{className:"semiotic-tooltip",style:cn},e.map((e,t)=>{const o=fn(yn(n,e.accessor));return h.createElement("div",{key:t,style:t>0?{marginTop:2}:void 0},h.createElement("span",{style:{opacity:.8}},e.label,": "),h.createElement("span",{style:{fontWeight:"color"===e.role||"group"===e.role?"bold":"normal"}},o))})):null}}function vn({categoryAccessor:e,valueAccessor:t,groupAccessor:n,groupLabel:o,pieData:r=!1}){return i=>{var a;const s=r?(null===(a=i.data)||void 0===a?void 0:a[0])||i.data||i:i.data||i,l=yn(s,e),c=yn(s,t),u=n?yn(s,n):void 0;return h.createElement("div",{className:"semiotic-tooltip",style:cn},h.createElement("div",{style:{fontWeight:"bold"}},fn(l)),h.createElement("div",{style:{marginTop:4}},fn(c)),null!=u&&h.createElement("div",{style:{marginTop:2,opacity:.8}},o||pn(n),": ",fn(u)))}}const bn=e.createContext(null);function xn({colors:t,categories:n,colorScheme:o="category10",children:r}){const i=e.useMemo(()=>{if(t)return t;if(n){const e=Array.isArray(o)?o:Ut[o]||Zt,t={};for(let o=0;n.length>o;o++)t[n[o]]=e[o%e.length];return t}return{}},[t,n,o]);return h.createElement(bn.Provider,{value:i},r)}function wn(){return e.useContext(bn)}function kn(e){return e?"string"==typeof e?{name:e}:e:null}function An(e,t,n){return t?o=>{var r;const i=Object.assign({},e(o));if(t.isActive)if(t.predicate(o))(null==n?void 0:n.selectedStyle)&&Object.assign(i,n.selectedStyle);else{const e=null!==(r=null==n?void 0:n.unselectedOpacity)&&void 0!==r?r:.2;i.opacity=e,i.fillOpacity=e,i.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(i,n.unselectedStyle)}return i}:e}function En(t){const n=e.createContext(null),o=Sn(t);return[function({children:o}){const r=e.useMemo(()=>Sn(t),[]);return h.createElement(n.Provider,{value:r,children:o})},t=>{var r;const i=null!==(r=e.useContext(n))&&void 0!==r?r:o;return function(t,n){const[o,r]=e.useState(n);return e.useLayoutEffect(()=>t(()=>r(n)),[t]),o}(i.subscribe,()=>t(i.getState()))}]}function Sn(e){const t=new EventTarget;let n=e(function(e){n=Object.assign(Object.assign({},n),e(n)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}function On(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,r]=o.range;t.push(t=>{const o=t[n];return o>=e&&r>=o})}return e=>t.every(t=>t(e))}function Ln(e,t){const n=[];for(const[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(On(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}function Mn(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}xn.displayName="CategoryColorProvider";const[jn,Pn]=En(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),r=Mn(o,t),i=new Map(r.clauses);return i.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},r),{clauses:i})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const r=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),r.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:r}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),r=Mn(o,t);return o.set(t,Object.assign(Object.assign({},r),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}}));function Cn(t){const n=e.useId(),o=t.clientId||n,{name:r}=t,i=Pn(e=>e.selections.get(r)),a=Pn(e=>e.setClause),s=Pn(e=>e.clearClause),l=e.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:e.useMemo(()=>i&&0!==i.clauses.size?Ln(i,o):()=>!0,[i,o]),isActive:l,selectPoints:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};a(r,{clientId:o,type:"point",fields:t})},[o,r,a]),selectInterval:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};a(r,{clientId:o,type:"interval",fields:t})},[o,r,a]),clear:e.useCallback(()=>{s(r,o)},[s,r,o]),clientId:o}}function Nn(t){const n=t.name||"hover",{fields:o}=t,{predicate:r,isActive:i,selectPoints:a,clear:s}=Cn({name:n});return{onHover:e.useCallback(e=>{if(!e)return void s();const t={};for(const n of o){const o=e[n];void 0!==o&&(t[n]=[o])}Object.keys(t).length>0&&a(t)},[o,a,s,n]),predicate:r,isActive:i}}function Dn(t){const{name:n,xField:o,yField:r}=t,{predicate:i,isActive:a,selectInterval:s,clear:l}=Cn({name:n}),c=o&&r?"xyBrush":o?"xBrush":"yBrush",u=e.useCallback(e=>{if(!e)return void l();const t={};"xyBrush"===c&&Array.isArray(e)&&2===e.length?(o&&(t[o]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),r&&(t[r]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&Array.isArray(e)?o&&(t[o]=[Math.min(...e),Math.max(...e)]):"yBrush"===c&&Array.isArray(e)&&r&&(t[r]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&s(t)},[c,o,r,s,l]);return{brushInteraction:e.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:i,isActive:a,clear:l}}const[Tn,Bn]=En(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}})),Hn="#007bff";function Wn(e){return"function"==typeof e?e:t=>t[e]}function Rn(t,n,o="category10"){const r=wn();return e.useMemo(()=>{if(n&&"function"!=typeof n)return r&&Object.keys(r).length>0?e=>r[e]||Jt(t,n,o)(e):Jt(t,n,o)},[t,n,o,r])}function $n(t,n,o){return e.useMemo(()=>{if(!n)return t;const e=[...t];if("function"==typeof n)return e.sort(n);const r=Wn(o);return e.sort("asc"===n?(e,t)=>r(e)-r(t):(e,t)=>r(t)-r(e))},[t,n,o])}function _n({selection:t,linkedHover:n,fallbackFields:o=[],unwrapData:r=!1,onObservation:i,chartType:a,chartId:s}){const l=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields}:null}(n,o),c=Cn({name:(null==t?void 0:t.name)||"__unused__"}),u=Nn({name:(null==l?void 0:l.name)||"hover",fields:(null==l?void 0:l.fields)||o||[]}),d=Bn(e=>e.pushObservation),h=t?{isActive:c.isActive,predicate:c.predicate}:null,g=e.useCallback(e=>{var t,o;if(n)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]),u.onHover(t)}else u.onHover(null);if(i||d){const n={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const a=Object.assign(Object.assign({},n),{type:"hover",datum:r||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(a),d&&d(a)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(e),d&&d(e)}}},[n,u,i,a,s,d]),p=e.useCallback(e=>{var t,n;if(i||d){const o={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const a=Object.assign(Object.assign({},o),{type:"click",datum:r||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});i&&i(a),d&&d(a)}else{const e=Object.assign(Object.assign({},o),{type:"click-end"});i&&i(e),d&&d(e)}}},[i,d,a,s]);return{activeSelectionHook:h,customHoverBehavior:g,customClickBehavior:p}}function zn({data:t,colorBy:n,colorScale:o,showLegend:r,userMargin:i,defaults:a={top:50,bottom:60,left:70,right:40}}){const s=void 0!==r?r:!!n,l=e.useMemo(()=>{if(s&&n)return function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:r,strokeWidth:i}){const a=Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(r=>{const i=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),a=i?o(i,t,n):n?n(r):"#000000";return{label:r+"",color:a}});return{legendGroups:[{styleFn:e=>{const t={fill:e.color,stroke:e.color};return void 0!==r&&(t.stroke=r),void 0!==i&&(t.strokeWidth=i),t},type:"fill",items:a,label:""}]}}({data:t,colorBy:n,colorScale:o,getColor:Kt})},[s,n,t,o]),c=e.useMemo(()=>{const e=Object.assign(Object.assign({},a),i);return l&&120>e.right&&(e.right=120),e},[a,i,l]);return{legend:l,margin:c}}const In={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function Fn(e,t,n){var o,r,i,a,s,l;const c=In[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:e&&"primary"!==e||!(null==n?void 0:n.width)?c.width:n.width,height:null!==(r=t.height)&&void 0!==r?r:e&&"primary"!==e||!(null==n?void 0:n.height)?c.height:n.height,showAxes:c.showAxes,showGrid:null!==(i=t.showGrid)&&void 0!==i?i:c.showGrid,enableHover:null!==(a=t.enableHover)&&void 0!==a?a:!!t.linkedHover||c.enableHover,showLegend:null!==(s=t.showLegend)&&void 0!==s?s:c.showLegend,showLabels:null!==(l=t.showLabels)&&void 0!==l?l:c.showLabels,title:u?void 0:t.title,xLabel:u?void 0:t.xLabel,yLabel:u?void 0:t.yLabel,categoryLabel:u?void 0:t.categoryLabel,valueLabel:u?void 0:t.valueLabel,marginDefaults:c.marginDefaults}}function Yn({componentName:e,message:t,width:n,height:o}){return h.createElement("div",{role:"alert",style:{width:n,height:Math.max(o,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},h.createElement("div",{style:{textAlign:"center",maxWidth:400}},h.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),h.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t)))}class Gn extends h.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:h.createElement(Yn,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}var Xn;const qn="undefined"!=typeof process&&"production"!==(null===(Xn=process.env)||void 0===Xn?void 0:Xn.NODE_ENV);function Vn({componentName:e,width:t,height:n,children:o}){return h.createElement(Gn,{fallback:o=>h.createElement(Yn,{componentName:e,message:o.message,width:t,height:n})},o)}function Un(e,t,n,o){if(!qn)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const r=t[0];if(!r||"object"!=typeof r)return;if(o in r)return;const i=Object.keys(r).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${i}`)}function Zn(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function Qn(e,t){if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||t[0]}function Kn({componentName:e,data:t,accessors:n,requiredProps:o}){if(o)for(const[t,n]of Object.entries(o))if(null==n)return`${e}: ${t} is required. Provide a field name or function.`;if(!t||!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(n){const o=Zn(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[r,i]of Object.entries(n))if(i&&"string"==typeof i&&!(i in o)){const n=Qn(i,t),o=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}function Jn({componentName:e,data:t,dataLabel:n="data"}){return null==t?`${e}: No ${n} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${n} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}function eo({componentName:e,nodes:t,edges:n,nodesRequired:o=!1,edgesRequired:r=!0,accessors:i}){if(r&&(!n||!Array.isArray(n)||0===n.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(o&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){const n=Zn(t).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[o,r]of Object.entries(i))if(r&&"string"==typeof r&&!(r in n)){const n=Qn(r,t),i=n?` Try ${o}="${n}".`:"";return`${e}: ${o} "${r}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}return null}function to(t){const n=Fn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,margin:r,className:i,xFormat:a,yFormat:s,xAccessor:l="x",yAccessor:c="y",colorBy:u,colorScheme:d="category10",sizeBy:g,sizeRange:p=[3,15],pointRadius:f=5,pointOpacity:y=.8,tooltip:m,marginalGraphics:v,pointIdAccessor:b,annotations:x,frameProps:w={},selection:k,linkedHover:A,linkedBrush:E,onObservation:S,chartId:O}=t,L=n.width,M=n.height,j=n.enableHover,P=n.showGrid,C=n.showLegend,N=n.title,D=n.xLabel,T=n.yLabel,B=o||[];Un("Scatterplot",B,"xAccessor",l),Un("Scatterplot",B,"yAccessor",c);const{activeSelectionHook:H,customHoverBehavior:W}=_n({selection:k,linkedHover:A,fallbackFields:u?["string"==typeof u?u:""]:[],onObservation:S,chartType:"Scatterplot",chartId:O}),R=kn(E);Dn({name:(null==R?void 0:R.name)||"__unused_brush__",xField:(null==R?void 0:R.xField)||("string"==typeof l?l:void 0),yField:(null==R?void 0:R.yField)||("string"==typeof c?c:void 0)});const $=Rn(B,u,d),_=e.useMemo(()=>{if(!g||0===B.length)return;const e=B.map(e=>"function"==typeof g?g(e):e[g]);return[Math.min(...e),Math.max(...e)]},[B,g]),z=e.useMemo(()=>e=>{const t={fillOpacity:y};return t.fill=u?Kt(e,u,$):Hn,t.r=g?en(e,g,p,_):f,t},[u,$,g,p,_,f,y]),I=e.useMemo(()=>An(z,H,k),[z,H,k]),{legend:F,margin:Y}=zn({data:B,colorBy:u,colorScale:$,showLegend:C,userMargin:r,defaults:n.marginDefaults}),G=e.useMemo(()=>mn([{label:D||pn(l),accessor:l,role:"x"},{label:T||pn(c),accessor:c,role:"y"},...u?[{label:pn(u),accessor:u,role:"color"}]:[],...g?[{label:pn(g),accessor:g,role:"size"}]:[]]),[l,c,D,T,u,g]),X=Kn({componentName:"Scatterplot",data:B,accessors:{xAccessor:l,yAccessor:c}});if(X)return h.createElement(Yn,{componentName:"Scatterplot",message:X,width:L,height:M});const q=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter",data:B,xAccessor:l,yAccessor:c,colorAccessor:u||void 0,sizeAccessor:g||void 0,sizeRange:p,pointStyle:I,colorScheme:d,size:[L,M],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Y,showAxes:n.showAxes,xLabel:D,yLabel:T,xFormat:a,yFormat:s,enableHover:j,showGrid:P},F&&{legend:F}),N&&{title:N}),i&&{className:i}),{tooltipContent:m?gn(m):G}),(A||S)&&{customHoverBehavior:W}),v&&{marginalGraphics:v}),b&&{pointIdAccessor:b}),x&&x.length>0&&{annotations:x}),w);return h.createElement(Vn,{componentName:"Scatterplot",width:L,height:M},h.createElement(ue,Object.assign({},q)))}function no(t){const n=Fn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,className:r,xFormat:i,yFormat:a,xAccessor:l="x",yAccessor:c="y",orderAccessor:u,orderLabel:d,pointRadius:g=4,tooltip:p,pointIdAccessor:f,annotations:y,frameProps:m={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,k=n.width,A=n.height,E=n.enableHover,S=n.showGrid,O=n.title,L=n.xLabel,M=n.yLabel,j=o||[],P=e.useMemo(()=>{if(!u||0===j.length)return j;const e="function"==typeof u?u:e=>e[u];return[...j].sort((t,n)=>{const o=e(t),r=e(n);return(o instanceof Date?o.getTime():+o)-(r instanceof Date?r.getTime():+r)})},[j,u]);Un("ConnectedScatterplot",P,"xAccessor",l),Un("ConnectedScatterplot",P,"yAccessor",c);const{activeSelectionHook:C,customHoverBehavior:N}=_n({selection:v,linkedHover:b,fallbackFields:[],onObservation:x,chartType:"ConnectedScatterplot",chartId:w}),D=P.length,T=D>0&&100>D,B=e.useMemo(()=>0===D?[]:P.map((e,t)=>s.interpolateViridis(1===D?.5:t/(D-1))),[P,D]);e.useMemo(()=>null,[D]);const H=e.useMemo(()=>{if(D>=2)return(e,t,n)=>{var o,r;if("connected-lines"!==e.type)return null;const i=n.scales;if(!i)return null;const a=null!==(o=i.x)&&void 0!==o?o:i.time,s=null!==(r=i.y)&&void 0!==r?r:i.value;if(!a||!s)return null;const u="string"==typeof l?e=>e[l]:l,d="string"==typeof c?e=>e[c]:c,p=[];for(let e=0;P.length-1>e;e++){const t=P[e],n=P[e+1],o=a(u(t)),r=s(d(t)),i=a(u(n)),l=s(d(n)),c=B[e];T&&p.push(h.createElement("line",{key:"halo-"+e,x1:o,y1:r,x2:i,y2:l,stroke:"white",strokeWidth:g+2,strokeOpacity:.5,strokeLinecap:"round"})),p.push(h.createElement("line",{key:"conn-"+e,x1:o,y1:r,x2:i,y2:l,stroke:c,strokeWidth:g,strokeLinecap:"round"}))}return h.createElement("g",{key:"ann-"+t},p)}},[P,B,g,T,l,c,D]),W=e.useMemo(()=>e=>{const t=P.indexOf(e);return{fill:t>=0&&B.length>t?B[t]:"#6366f1",stroke:"white",strokeWidth:1,r:g,fillOpacity:1}},[P,B,g]),R=e.useMemo(()=>An(W,C,v),[W,C,v]),$=Object.assign({top:50,right:40,bottom:60,left:70},t.margin),_=d||("string"==typeof u?u:"Order"),z=e.useMemo(()=>mn([{label:L||pn(l),accessor:l,role:"x"},{label:M||pn(c),accessor:c,role:"y"},...u?[{label:_,accessor:u,role:"group"}]:[]]),[l,c,L,M,u,_]),I=Kn({componentName:"ConnectedScatterplot",data:P,accessors:{xAccessor:l,yAccessor:c}});if(I)return h.createElement(Yn,{componentName:"ConnectedScatterplot",message:I,width:k,height:A});const F=e.useMemo(()=>[{type:"connected-lines"},...y||[]],[y]),Y=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter",data:P,xAccessor:l,yAccessor:c,pointStyle:R,size:[k,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:$,showAxes:n.showAxes,xLabel:L,yLabel:M,xFormat:i,yFormat:a,enableHover:E,showGrid:S},O&&{title:O}),r&&{className:r}),{tooltipContent:p?gn(p):z}),(b||x)&&{customHoverBehavior:N}),f&&{pointIdAccessor:f}),{annotations:F,svgAnnotationRules:H}),m);return h.createElement(Vn,{componentName:"ConnectedScatterplot",width:k,height:A},h.createElement(ue,Object.assign({},Y)))}to.displayName="Scatterplot",no.displayName="ConnectedScatterplot";const oo="__forecastSegment";function ro(e,t){return"function"==typeof t?t(e):!!e[t]}function io(t){var n,o;const r=Fn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:a,className:s,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:d="y",lineBy:g,lineDataAccessor:p="coordinates",colorBy:f,colorScheme:y="category10",curve:m="linear",showPoints:v=!1,pointRadius:b=3,fillArea:x=!1,areaOpacity:w=.3,lineWidth:k=2,tooltip:A,pointIdAccessor:E,annotations:S,anomaly:O,forecast:L,frameProps:M={},selection:j,linkedHover:P,onObservation:C,chartId:N}=t,D=r.width,T=r.height,B=r.enableHover,H=r.showGrid,W=r.showLegend,R=r.title,$=r.xLabel,_=r.yLabel,z=i||[];Un("LineChart",z,"xAccessor",u),Un("LineChart",z,"yAccessor",d);const I="string"==typeof u?u:"x",F="string"==typeof d?d:"y",Y=e.useMemo(()=>L?function(e,t,n,o,r){return(i=o).isTraining||i.isForecast||i.isAnomaly||i.upperBounds||i.lowerBounds?function(e,t,n,o,r){var i,a,s;const{isTraining:l,isForecast:c,isAnomaly:u,upperBounds:d,lowerBounds:h,color:g="#6366f1",bandOpacity:p=.15,anomalyColor:f="#ef4444",anomalyRadius:y=6,label:m}=o,v=e.map(e=>{let t="observed";return c&&ro(e,c)?t="forecast":l&&ro(e,l)&&(t="training"),Object.assign(Object.assign({},e),{[oo]:t})}),b=[];if(d&&h){const e="string"==typeof d?d:"__envUpper",t="string"==typeof h?h:"__envLower";if("function"==typeof d||"function"==typeof h)for(const n of v)"function"==typeof d&&(n[e]=d(n)),"function"==typeof h&&(n[t]=h(n));b.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:g,fillOpacity:p,label:m})}return u&&b.push({type:"highlight",filter:e=>ro(e,u),color:f,r:y,style:{stroke:f,strokeWidth:1.5,fill:f,fillOpacity:.7}}),r&&b.push({type:"anomaly-band",threshold:null!==(i=r.threshold)&&void 0!==i?i:2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:null!==(a=r.bandOpacity)&&void 0!==a?a:.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:null!==(s=r.anomalyRadius)&&void 0!==s?s:6,label:r.label}),{processedData:v,annotations:b}}(e,0,0,o,r):function(e,t,n,o,r){var i,a,s;const{trainEnd:l,steps:c=10,confidence:u=.95,color:d="#6366f1",bandOpacity:h=.15,label:g}=o;if(null==l)return{processedData:e,annotations:[]};const p=[],f=[];for(const n of e)n[t]>l?f.push(Object.assign(Object.assign({},n),{[oo]:"observed"})):p.push(Object.assign(Object.assign({},n),{[oo]:"training"}));const y=p.map(e=>[e[t],e[n]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),m=[],v=[];if(y.length>=3){const o=y.length;let r=0,i=0,a=0,s=0;for(const[e,t]of y)r+=e,i+=t,a+=e*e,s+=e*t;const l=o*a-r*r;if(Math.abs(l)>1e-12){const a=(o*s-r*i)/l,p=(i-a*r)/o,f=e=>p+a*e,b=y.map(([e,t])=>t-f(e)).reduce((e,t)=>e+t*t,0),x=Math.sqrt(b/Math.max(o-2,1)),w=y.reduce((e,t)=>e+t[0],0)/o,k=y.reduce((e,t)=>e+Math.pow(t[0]-w,2),0),A=.99>u?.95>u?.9>u?1:1.645:1.96:2.576,E=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),S=Math.max(...E),O=y.length>1?(y[o-1][0]-y[0][0])/(o-1):1;for(let e=1;c>=e;e++){const r=S+e*O,i=f(r),a=x*Math.sqrt(1+1/o+(k>0?Math.pow(r-w,2)/k:0))*A;v.push({[t]:r,[n]:i,[oo]:"forecast",__forecastUpper:i+a,__forecastLower:i-a})}m.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:d,fillOpacity:h,label:g})}}return m.push({type:"x-threshold",x:l,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),r&&m.push({type:"anomaly-band",threshold:null!==(i=r.threshold)&&void 0!==i?i:2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:null!==(a=r.bandOpacity)&&void 0!==a?a:.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:null!==(s=r.anomalyRadius)&&void 0!==s?s:6,label:r.label}),{processedData:[...p,...f,...v],annotations:m}}(e,t,n,o,r);var i}(z,I,F,L,O):null,[z,L,O,I,F]),G=e.useMemo(()=>Y?Y.annotations:O?function(e){var t,n,o;return[{type:"anomaly-band",threshold:null!==(t=e.threshold)&&void 0!==t?t:2,showBand:!1!==e.showBand,fill:e.bandColor||"#6366f1",fillOpacity:null!==(n=e.bandOpacity)&&void 0!==n?n:.1,anomalyColor:e.anomalyColor||"#ef4444",anomalyRadius:null!==(o=e.anomalyRadius)&&void 0!==o?o:6,label:e.label}]}(O):[],[Y,O]),X=Y?Y.processedData:z,q=L&&!g?oo:g,{activeSelectionHook:V,customHoverBehavior:U}=_n({selection:j,linkedHover:P,fallbackFields:f?["string"==typeof f?f:""]:[],onObservation:C,chartType:"LineChart",chartId:N}),Z=void 0!==(null===(n=X[0])||void 0===n?void 0:n[p]),Q=e.useMemo(()=>{if(Z)return X;if(q){const e=X.reduce((e,t)=>{const n="function"==typeof q?q(t):t[q];if(!e[n]){const t={[p]:[]};"string"==typeof q&&(t[q]=n),e[n]=t}return e[n][p].push(t),e},{});return Object.values(e)}return[{[p]:X}]},[X,q,p,Z]),K=Rn(X,f,y),J=e.useMemo(()=>e=>{const t={strokeWidth:k};return t.stroke=f?Kt(e,f,K):Hn,x&&(t.fill=t.stroke,t.fillOpacity=w),t},[f,K,k,x,w]),ee=e.useMemo(()=>L?function(e,t){var n,o;const r=null!==(n=t.trainDasharray)&&void 0!==n?n:"8,4",i=null!==(o=t.forecastDasharray)&&void 0!==o?o:"4,4",a=t.color||"#6366f1";return t=>{const n=e(t),o=t[oo];return"training"===o?Object.assign(Object.assign({},n),{strokeDasharray:r}):"forecast"===o?Object.assign(Object.assign({},n),{stroke:a,strokeDasharray:i}):n}}(J,L):J,[J,L]),te=e.useMemo(()=>An(ee,V,j),[ee,V,j]),ne=e.useMemo(()=>{if(v)return e=>{const t={r:b,fillOpacity:1};return t.fill=f?Kt(e.parentLine||e,f,K):Hn,t}},[v,b,f,K]),oe=x?"area":"line",{legend:re,margin:ie}=zn({data:Q,colorBy:f,colorScale:K,showLegend:W,userMargin:a,defaults:r.marginDefaults}),ae=g||f,se=e.useMemo(()=>mn([{label:$||pn(u),accessor:u,role:"x"},{label:_||pn(d),accessor:d,role:"y"},...ae?[{label:pn(ae),accessor:ae,role:"group"}]:[]]),[u,d,$,_,ae]),le=Kn({componentName:"LineChart",data:Z?(null===(o=X[0])||void 0===o?void 0:o[p])||[]:z,accessors:{xAccessor:u,yAccessor:d}});if(le)return h.createElement(Yn,{componentName:"LineChart",message:le,width:D,height:T});const ce=e.useMemo(()=>Z||q?Q.flatMap(e=>{const t=e[p]||[];return q&&"string"==typeof q?t.map(t=>Object.assign(Object.assign({},t),{[q]:e[q]})):t}):X,[Q,p,Z,q,X]),de=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:oe,data:ce,xAccessor:u,yAccessor:d,groupAccessor:q||void 0,curve:m,lineStyle:te},v&&{pointStyle:ne}),{size:[D,T],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ie,showAxes:r.showAxes,xLabel:$,yLabel:_,xFormat:l,yFormat:c,enableHover:B,showGrid:H}),re&&{legend:re}),R&&{title:R}),s&&{className:s}),{tooltipContent:A?gn(A):se}),(P||C)&&{customHoverBehavior:U}),E&&{pointIdAccessor:E}),((null==S?void 0:S.length)||G.length)&&{annotations:[...S||[],...G]}),M);return h.createElement(Vn,{componentName:"LineChart",width:D,height:T},h.createElement(ue,Object.assign({},de)))}function ao(t){var n;const o=Fn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:r,margin:i,className:a,xFormat:s,yFormat:l,xAccessor:c="x",yAccessor:u="y",areaBy:d,y0Accessor:g,gradientFill:p=!1,lineDataAccessor:f="coordinates",colorBy:y,colorScheme:m="category10",curve:v="monotoneX",areaOpacity:b=.7,showLine:x=!0,lineWidth:w=2,tooltip:k,annotations:A,frameProps:E={},selection:S,linkedHover:O,onObservation:L,chartId:M}=t,j=o.width,P=o.height,C=o.enableHover,N=o.showGrid,D=o.showLegend,T=o.title,B=o.xLabel,H=o.yLabel,W=r||[];Un("AreaChart",W,"xAccessor",c),Un("AreaChart",W,"yAccessor",u);const{activeSelectionHook:R,customHoverBehavior:$}=_n({selection:S,linkedHover:O,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:L,chartType:"AreaChart",chartId:M}),_=void 0!==(null===(n=W[0])||void 0===n?void 0:n[f]),z=e.useMemo(()=>{if(_)return W;if(d){const e=W.reduce((e,t)=>{const n="function"==typeof d?d(t):t[d];if(!e[n]){const t={[f]:[]};"string"==typeof d&&(t[d]=n),e[n]=t}return e[n][f].push(t),e},{});return Object.values(e)}return[{[f]:W}]},[W,d,f,_]),I=Rn(W,y,m),F=e.useMemo(()=>e=>{const t={},n=y?Kt(e,y,I):Hn;return t.fill=n,t.fillOpacity=b,x?(t.stroke=n,t.strokeWidth=w):t.stroke="none",t},[y,I,b,x,w]),Y=e.useMemo(()=>An(F,R,S),[F,R,S]),{legend:G,margin:X}=zn({data:z,colorBy:y,colorScale:I,showLegend:D,userMargin:i,defaults:o.marginDefaults}),q=d||y,V=e.useMemo(()=>mn([{label:B||pn(c),accessor:c,role:"x"},{label:H||pn(u),accessor:u,role:"y"},...q?[{label:pn(q),accessor:q,role:"group"}]:[]]),[c,u,B,H,q]),U=Kn({componentName:"AreaChart",data:W,accessors:{xAccessor:c,yAccessor:u}});if(U)return h.createElement(Yn,{componentName:"AreaChart",message:U,width:j,height:P});const Z=e.useMemo(()=>_||d?z.flatMap(e=>{const t=e[f]||[];return d&&"string"==typeof d?t.map(t=>Object.assign(Object.assign({},t),{[d]:e[d]})):t}):W,[z,f,_,d,W]),Q=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area",data:Z,xAccessor:c,yAccessor:u,groupAccessor:d||void 0},g&&{y0Accessor:g}),p&&{gradientFill:p}),{curve:v,lineStyle:Y,size:[j,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:X,showAxes:o.showAxes,xLabel:B,yLabel:H,xFormat:s,yFormat:l,enableHover:C,showGrid:N}),G&&{legend:G}),T&&{title:T}),a&&{className:a}),{tooltipContent:k?gn(k):V}),(O||L)&&{customHoverBehavior:$}),A&&A.length>0&&{annotations:A}),E);return h.createElement(Vn,{componentName:"AreaChart",width:j,height:P},h.createElement(ue,Object.assign({},Q)))}function so(t){var n;const o=Fn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:r,margin:i,className:a,xFormat:s,yFormat:l,xAccessor:c="x",yAccessor:u="y",areaBy:d,lineDataAccessor:g="coordinates",colorBy:p,colorScheme:f="category10",curve:y="monotoneX",areaOpacity:m=.7,showLine:v=!0,lineWidth:b=2,normalize:x=!1,tooltip:w,annotations:k,frameProps:A={},selection:E,linkedHover:S,onObservation:O,chartId:L}=t,M=o.width,j=o.height,P=o.enableHover,C=o.showGrid,N=o.showLegend,D=o.title,T=o.xLabel,B=o.yLabel,H=r||[],{activeSelectionHook:W,customHoverBehavior:R}=_n({selection:E,linkedHover:S,fallbackFields:p?["string"==typeof p?p:""]:[],onObservation:O,chartType:"StackedAreaChart",chartId:L}),$=void 0!==(null===(n=H[0])||void 0===n?void 0:n[g]),_=e.useMemo(()=>{if($)return H;if(d){const e=H.reduce((e,t)=>{const n="function"==typeof d?d(t):t[d];if(!e[n]){const t={[g]:[]};"string"==typeof d&&(t[d]=n),e[n]=t}return e[n][g].push(t),e},{});return Object.values(e)}return[{[g]:H}]},[H,d,g,$]),z=Rn(H,p,f),I=e.useMemo(()=>e=>{const t={},n=p?Kt(e,p,z):Hn;return t.fill=n,t.fillOpacity=m,v?(t.stroke=n,t.strokeWidth=b):t.stroke="none",t},[p,z,m,v,b]),F=e.useMemo(()=>An(I,W,E),[I,W,E]),{legend:Y,margin:G}=zn({data:_,colorBy:p,colorScale:z,showLegend:N,userMargin:i,defaults:o.marginDefaults}),X=d||p,q=e.useMemo(()=>mn([{label:T||pn(c),accessor:c,role:"x"},{label:B||pn(u),accessor:u,role:"y"},...X?[{label:pn(X),accessor:X,role:"group"}]:[]]),[c,u,T,B,X]),V=Kn({componentName:"StackedAreaChart",data:H,accessors:{xAccessor:c,yAccessor:u}});if(V)return h.createElement(Yn,{componentName:"StackedAreaChart",message:V,width:M,height:j});const U=e.useMemo(()=>$||d?_.flatMap(e=>{const t=e[g]||[];return d&&"string"==typeof d?t.map(t=>Object.assign(Object.assign({},t),{[d]:e[d]})):t}):H,[_,g,$,d,H]),Z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea",data:U,xAccessor:c,yAccessor:u,groupAccessor:d||void 0,curve:y,normalize:x,lineStyle:F,size:[M,j],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:G,showAxes:o.showAxes,xLabel:T,yLabel:B,xFormat:s,yFormat:l,enableHover:P,showGrid:C},Y&&{legend:Y}),D&&{title:D}),a&&{className:a}),{tooltipContent:w?gn(w):q}),(S||O)&&{customHoverBehavior:R}),k&&k.length>0&&{annotations:k}),A);return h.createElement(Vn,{componentName:"StackedAreaChart",width:M,height:j},h.createElement(ue,Object.assign({},Z)))}function lo(t){const n=Fn(t.mode,{width:t.width,height:t.height,showGrid:void 0,enableHover:t.enableHover,showLegend:void 0,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:r,margin:i,className:a,xAccessor:l="x",yAccessor:c="y",valueAccessor:u="value",xFormat:d,yFormat:g,colorScheme:p="blues",customColorScale:f,showValues:y=!1,valueFormat:m,cellBorderColor:v="#fff",cellBorderWidth:b=1,tooltip:x,annotations:w,frameProps:k={},selection:A,linkedHover:E,onObservation:S,chartId:O}=t,L=n.width,M=n.height,j=n.enableHover,P=n.title,C=n.xLabel,N=n.yLabel,D=r||[],{margin:T}=zn({data:D,colorBy:void 0,colorScale:void 0,showLegend:!1,userMargin:i,defaults:n.marginDefaults}),{activeSelectionHook:B,customHoverBehavior:H}=_n({selection:A,linkedHover:E,fallbackFields:[],onObservation:S,chartType:"Heatmap",chartId:O}),W=e.useMemo(()=>"function"==typeof u?e=>u(e):e=>e[u],[u]),R=e.useMemo(()=>{const e=D.map(W);return[Math.min(...e),Math.max(...e)]},[D,W]),$=e.useMemo(()=>"custom"===p&&f?f:o.scaleSequential({blues:s.interpolateBlues,reds:s.interpolateReds,greens:s.interpolateGreens,viridis:s.interpolateViridis}[p]||s.interpolateBlues).domain(R),[p,f,R]);e.useMemo(()=>{const e=Wn(l),t=Wn(c);return{xBinCount:new Set(D.map(e)).size,yBinCount:new Set(D.map(t)).size}},[D,l,c]),e.useMemo(()=>({coordinates:D}),[D]);const _=e.useMemo(()=>e=>{const t=W(e);return{fill:$(t),stroke:v,strokeWidth:b}},[W,$,v,b]);e.useMemo(()=>An(_,B,A),[_,B,A]),e.useMemo(()=>{if(!y)return;const e=(R[0]+R[1])/2;return(t,n)=>{const o=W(t),r=m?m(o):o+"";return h.createElement("text",{textAnchor:"middle",dominantBaseline:"middle",fill:W(t)>e?"#fff":"#000",fontSize:"12px"},r)}},[y,W,m,R]);const z=e.useMemo(()=>mn([{label:C||pn(l),accessor:l,role:"x"},{label:N||pn(c),accessor:c,role:"y"},{label:pn(u),accessor:u,role:"value"}]),[l,c,C,N,u]),I=Kn({componentName:"Heatmap",data:D,accessors:{xAccessor:l,yAccessor:c,valueAccessor:u}});if(I)return h.createElement(Yn,{componentName:"Heatmap",message:I,width:L,height:M});const F=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap",data:D,xAccessor:l,yAccessor:c,valueAccessor:u,size:[L,M],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:T,showAxes:n.showAxes,xLabel:C,yLabel:N,xFormat:d,yFormat:g,enableHover:j},P&&{title:P}),a&&{className:a}),{tooltipContent:x?gn(x):z}),(E||S)&&{customHoverBehavior:H}),w&&w.length>0&&{annotations:w}),k);return h.createElement(Vn,{componentName:"Heatmap",width:L,height:M},h.createElement(ue,Object.assign({},F)))}function co(t){const n=Fn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,margin:r,className:i,xFormat:a,yFormat:s,xAccessor:l="x",yAccessor:c="y",sizeBy:u,sizeRange:d=[5,40],colorBy:g,colorScheme:p="category10",bubbleOpacity:f=.6,bubbleStrokeWidth:y=1,bubbleStrokeColor:m="white",tooltip:v,marginalGraphics:b,pointIdAccessor:x,annotations:w,frameProps:k={},selection:A,linkedHover:E,linkedBrush:S,onObservation:O,chartId:L}=t,M=n.width,j=n.height,P=n.enableHover,C=n.showGrid,N=n.showLegend,D=n.title,T=n.xLabel,B=n.yLabel,H=o||[],{activeSelectionHook:W,customHoverBehavior:R}=_n({selection:A,linkedHover:E,fallbackFields:g?["string"==typeof g?g:""]:[],onObservation:O,chartType:"BubbleChart",chartId:L}),$=kn(S);Dn({name:(null==$?void 0:$.name)||"__unused_brush__",xField:(null==$?void 0:$.xField)||("string"==typeof l?l:void 0),yField:(null==$?void 0:$.yField)||("string"==typeof c?c:void 0)});const _=Rn(H,g,p),z=e.useMemo(()=>{const e=H.map(e=>"function"==typeof u?u(e):e[u]);return[Math.min(...e),Math.max(...e)]},[H,u]),I=e.useMemo(()=>e=>{const t={fillOpacity:f,strokeWidth:y,stroke:m};return t.fill=g?Kt(e,g,_):Hn,t.r=en(e,u,d,z),t},[g,_,u,d,z,f,y,m]),F=e.useMemo(()=>An(I,W,A),[I,W,A]),{legend:Y,margin:G}=zn({data:H,colorBy:g,colorScale:_,showLegend:N,userMargin:r,defaults:n.marginDefaults}),X=e.useMemo(()=>mn([{label:T||pn(l),accessor:l,role:"x"},{label:B||pn(c),accessor:c,role:"y"},{label:pn(u),accessor:u,role:"size"},...g?[{label:pn(g),accessor:g,role:"color"}]:[]]),[l,c,T,B,u,g]),q=Kn({componentName:"BubbleChart",data:H,accessors:{xAccessor:l,yAccessor:c},requiredProps:{sizeBy:u}});if(q)return h.createElement(Yn,{componentName:"BubbleChart",message:q,width:M,height:j});const V=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bubble",data:H,xAccessor:l,yAccessor:c,colorAccessor:g||void 0,sizeAccessor:u,sizeRange:d,pointStyle:F,colorScheme:p,size:[M,j],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:G,showAxes:n.showAxes,xLabel:T,yLabel:B,xFormat:a,yFormat:s,enableHover:P,showGrid:C},Y&&{legend:Y}),D&&{title:D}),i&&{className:i}),{tooltipContent:v?gn(v):X}),(E||O)&&{customHoverBehavior:R}),b&&{marginalGraphics:b}),x&&{pointIdAccessor:x}),w&&w.length>0&&{annotations:w}),k);return h.createElement(Vn,{componentName:"BubbleChart",width:M,height:j},h.createElement(ue,Object.assign({},V)))}function uo(t={}){const{limit:n=50,types:o,chartId:r}=t,i=Bn(e=>e.version),a=Bn(e=>e.observations),s=Bn(e=>e.clearObservations),l=e.useMemo(()=>{let e=a;if(o&&o.length>0){const t=new Set(o);e=e.filter(e=>t.has(e.type))}return r&&(e=e.filter(e=>e.chartId===r)),e.length>n&&(e=e.slice(e.length-n)),e},[a,o,r,n,i]);return{observations:l,latest:l.length>0?l[l.length-1]:null,clear:s}}function ho({selections:t}){const n=Pn(e=>e.setResolution);return e.useEffect(()=>{for(const[e,o]of Object.entries(t))o.resolution&&n(e,o.resolution)},[t,n]),null}function go({children:e,selections:t}){return h.createElement(jn,null,h.createElement(Tn,null,t&&h.createElement(ho,{selections:t}),e))}io.displayName="LineChart",ao.displayName="AreaChart",so.displayName="StackedAreaChart",lo.displayName="Heatmap",co.displayName="BubbleChart";const po="__splomIdx",fo={top:4,bottom:4,left:4,right:4};function yo({frameRef:o,cellSize:r,onBrush:i}){const a=e.useRef(null),s=r-fo.left-fo.right,l=r-fo.top-fo.bottom;return e.useEffect(()=>{if(!a.current)return;const e=n.select(a.current).select(".brush-g"),r=t.brush().extent([[0,0],[s,l]]).on("brush end",e=>{var t;const n=null===(t=o.current)||void 0===t?void 0:t.getScales();if(!n)return;if(!e.selection)return void i(null);const[[r,a],[s,l]]=e.selection,c=[[n.x.invert(r),n.y.invert(a)],[n.x.invert(s),n.y.invert(l)]];i(c)});return e.call(r),e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null)}},[s,l,o,i]),h.createElement("svg",{ref:a,width:r,height:r,style:{position:"absolute",top:0,left:0}},h.createElement("g",{className:"brush-g",transform:`translate(${fo.left},${fo.top})`}))}function mo({data:t,xField:n,yField:o,cellSize:r,pointRadius:i,pointOpacity:a,colorBy:s,colorScale:l,brushSelectionName:c,hoverSelectionName:u,unselectedOpacity:d,mode:g,onPointHover:p}){const f=e.useRef(null),y=Cn({name:c,clientId:`splom-${n}-${o}`}),m=Dn({name:c,xField:n,yField:o}),v=Cn({name:u,clientId:"splom-hover-source"}),b=v.selectPoints,x=e.useCallback(e=>{e?m.brushInteraction.during(e):m.brushInteraction.end(null)},[m.brushInteraction]),w=e.useCallback(e=>{if(!e)return void(null==p||p(null));const t=e.data,n=null==t?void 0:t[po];void 0!==n&&(b({[po]:[n]}),null==p||p(t,e.x+fo.left,e.y+fo.top))},[b,p]),k=e.useCallback(e=>{const t={opacity:a,r:i};return t.fill=s?Kt(e,s,l):Hn,"hover"===g?v.isActive&&v.predicate(e)?(t.opacity=1,t.r=2.5*i,t.stroke="#333",t.strokeWidth=1.5):v.isActive&&(t.opacity=.6*a):y.isActive&&!y.predicate(e)&&(t.opacity=d),t},[s,l,a,i,g,y.isActive,y.predicate,v.isActive,v.predicate,d]);return h.createElement("div",{style:{position:"relative",width:r,height:r}},h.createElement(ue,{ref:f,chartType:"scatter",data:t,size:[r,r],xAccessor:n,yAccessor:o,pointStyle:k,margin:fo,showAxes:!1,enableHover:"hover"===g,customHoverBehavior:"hover"===g?w:void 0,tooltipContent:"hover"===g?()=>null:void 0}),"brush"===g&&h.createElement(yo,{frameRef:f,cellSize:r,xField:n,yField:o,onBrush:x}))}function vo({data:t,field:n,label:o,cellSize:r,bins:i,brushSelectionName:a,hoverSelectionName:s,mode:l}){const c=Cn({name:a,clientId:"splom-diag-"+n}),u=Cn({name:s,clientId:`splom-diag-${n}-hover`}),d="hover"===l?u:c,g=d.isActive,p=d.predicate,f=e.useMemo(()=>{const e=t.map(e=>e[n]).filter(e=>null!=e&&!isNaN(e));if(0===e.length)return{bars:[],selectedBars:[],max:0};const o=Math.min(...e),a=(Math.max(...e)-o)/i||1,s=Array(i).fill(0),l=Array(i).fill(0);for(const e of t){const t=e[n];if(null==t||isNaN(t))continue;const r=Math.min(Math.floor((t-o)/a),i-1);s[r]++,g&&!p(e)||l[r]++}const c=Math.max(...s,1);return{bars:s.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/c*(r-24),count:e})),selectedBars:l.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/c*(r-24),count:e})),max:c}},[t,n,i,r,g,p]);return h.createElement("svg",{width:r,height:r,style:{overflow:"hidden"}},h.createElement("text",{x:r/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333"},o),f.bars.map((e,t)=>h.createElement("rect",{key:"bg-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:"#ccc",opacity:g?.3:.6})),g&&f.selectedBars.map((e,t)=>h.createElement("rect",{key:"sel-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:Hn,opacity:.7})))}function bo({label:e,cellSize:t}){return h.createElement("svg",{width:t,height:t},h.createElement("text",{x:t/2,y:t/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333"},e))}function xo(t){const{data:n,fields:o,fieldLabels:r={},colorBy:i,colorScheme:a="category10",cellSize:s=150,cellGap:l=4,pointRadius:c=2,pointOpacity:u=.5,diagonal:d="histogram",histogramBins:g=20,brushMode:p="crossfilter",hoverMode:f=!0,unselectedOpacity:y=.1,showGrid:m=!1,tooltip:v,showLegend:b,idAccessor:x,className:w,onObservation:k,chartId:A}=t,E="splom",S="splom-hover",O=f?"hover":p?"brush":"hover",L=Pn(e=>e.clearSelection),[M,j]=e.useState(null),P=e.useCallback(()=>{L(S),j(null)},[L,S]),C=e.useMemo(()=>(n||[]).map((e,t)=>void 0!==e[po]?e:Object.assign(Object.assign({},e),{[po]:t})),[n]),N=Rn(C,i,a),D=void 0!==b?b:!!i,T=e.useMemo(()=>{if(!D||!i)return null;const e="string"==typeof i?i:null;return e?[...new Set(C.map(t=>t[e]))].map(e=>({label:e+"",color:N?N(e+""):Hn})):null},[D,i,C,N]),B=e.useMemo(()=>({display:"grid",gridTemplateColumns:"40px "+o.map(()=>s+"px").join(" "),gridTemplateRows:o.map(()=>s+"px").join(" ")+" 40px",gap:l+"px",width:"fit-content"}),[o,s,l,40]);return h.createElement("div",{className:w,style:{position:"relative"}},T&&h.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},T.map(e=>h.createElement("div",{key:e.label,style:{display:"flex",alignItems:"center",gap:4}},h.createElement("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:e.color}}),h.createElement("span",{style:{fontSize:11}},e.label)))),h.createElement("div",{style:B,onMouseLeave:"hover"===O?P:void 0},o.map((e,t)=>h.createElement(h.Fragment,{key:"row-"+e},h.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e),o.map((n,o)=>t===o?"label"===d?h.createElement(bo,{key:"diag-"+e,label:r[e]||e,cellSize:s}):h.createElement(vo,{key:"diag-"+e,data:C,field:e,label:r[e]||e,cellSize:s,bins:g,colorBy:i,colorScale:N,brushSelectionName:E,hoverSelectionName:S,unselectedOpacity:y,mode:O}):h.createElement(mo,{key:`cell-${e}-${n}`,data:C,xField:n,yField:e,fieldLabels:r,cellSize:s,pointRadius:c,pointOpacity:u,colorBy:i,colorScale:N,brushSelectionName:E,hoverSelectionName:S,unselectedOpacity:y,showGrid:m,tooltip:v,mode:O,onPointHover:"hover"===O?(r,i,a)=>{r?(j({datum:r,xField:n,yField:e,colIndex:o,rowIndex:t,px:null!=i?i:0,py:null!=a?a:0}),k&&k({type:"hover",datum:r,x:null!=i?i:0,y:null!=a?a:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A})):(j(null),k&&k({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A}))}:void 0})))),h.createElement("div",null)," ",o.map(e=>h.createElement("div",{key:"col-label-"+e,style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e))),M&&"hover"===O&&(()=>{const e=M.datum,t=r[M.xField]||M.xField,n=r[M.yField]||M.yField,o=i?"function"==typeof i?i(e):e[i]:null,a=x?"function"==typeof x?x(e):e[x]:"Row "+e[po];return h.createElement("div",{style:{position:"absolute",left:40+M.colIndex*(s+l)+M.px,top:M.rowIndex*(s+l)+M.py-8,transform:"translate(-50%, -100%)",color:"#333",background:"rgba(255,255,255,0.95)",border:"1px solid #ddd",borderRadius:3,padding:"4px 8px",fontSize:11,lineHeight:1.4,whiteSpace:"nowrap",pointerEvents:"none",zIndex:10}},h.createElement("div",{style:{fontWeight:"bold",marginBottom:2}},a+""),h.createElement("div",null,t,": ",null!=e[M.xField]?Number(e[M.xField]).toFixed(1):"–"),h.createElement("div",null,n,": ",null!=e[M.yField]?Number(e[M.yField]).toFixed(1):"–"),null!=o&&h.createElement("div",{style:{opacity:.8}},"string"==typeof i?i:"group",": ",o+""))})())}function wo(e){const{brushMode:t="crossfilter",hoverMode:n=!0}=e,o={};return!n&&t&&(o.splom={resolution:t}),n&&(o["splom-hover"]={resolution:"union"}),h.createElement(go,{selections:o},h.createElement(xo,Object.assign({},e)))}function ko({width:o,height:r,margin:i,scales:a,brushDirection:s,extent:l,onBrush:c}){const u=e.useRef(null),d=e.useRef(null),g=e.useRef(!1),p=o+i.left+i.right,f=r+i.top+i.bottom;return e.useEffect(()=>{if(!u.current||!a)return;const e=n.select(u.current).select(".brush-group"),i="x"===s?t.brushX().extent([[0,0],[o,r]]):t.brushY().extent([[0,0],[o,r]]);return i.on("brush end",e=>{if(g.current)return;if(!e.sourceEvent)return;const t=e.selection;if(!t)return void c(null);const n=("x"===s?a.x:a.y).invert;if(!n)return;const o=[n(t[0]),n(t[1])];c(o)}),e.call(i),d.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null)}},[a,o,r,s,c]),e.useEffect(()=>{if(!d.current||!a||!u.current)return;const e=n.select(u.current).select(".brush-group"),t="x"===s?a.x:a.y;if(g.current=!0,l){const n=[t(l[0]),t(l[1])];e.call(d.current.move,n)}else e.call(d.current.move,null);g.current=!1},[l,a,s]),h.createElement("svg",{ref:u,width:p,height:f,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},h.createElement("g",{className:"brush-group",transform:`translate(${i.left},${i.top})`}))}function Ao(t){var n,o;const{data:r,width:i=600,height:a=400,margin:s,className:l,title:c,xLabel:u,yLabel:d,xFormat:g,yFormat:p,xAccessor:f="x",yAccessor:y="y",lineBy:m,lineDataAccessor:v="coordinates",colorBy:b,colorScheme:x="category10",curve:w="linear",lineWidth:k=2,fillArea:A=!1,areaOpacity:E=.3,showPoints:S=!1,pointRadius:O=3,enableHover:L=!0,showGrid:M=!1,showLegend:j,tooltip:P,minimap:C={},renderBefore:N=!1,onBrush:D,brushExtent:T,frameProps:B={}}=t,H=r||[],[W,R]=e.useState(null),$=null!=T?T:W,_=e.useCallback(e=>{T||R(e),null==D||D(e)},[T,D]),z=e.useRef(null),[I,F]=e.useState(null);e.useEffect(()=>{const e=()=>{var t,n;const o=null===(n=null===(t=z.current)||void 0===t?void 0:t.getScales)||void 0===n?void 0:n.call(t);o?F(o):requestAnimationFrame(e)};requestAnimationFrame(e)},[r]);const Y=void 0!==(null===(n=H[0])||void 0===n?void 0:n[v]),G=e.useMemo(()=>{if(Y)return H;if(m){const e=H.reduce((e,t)=>{const n="function"==typeof m?m(t):t[m];if(!e[n]){const t={[v]:[]};"string"==typeof m&&(t[m]=n),e[n]=t}return e[n][v].push(t),e},{});return Object.values(e)}return[{[v]:H}]},[H,m,v,Y]),X=e.useMemo(()=>Y||m?G.flatMap(e=>{const t=e[v]||[];return m&&"string"==typeof m?t.map(t=>Object.assign(Object.assign({},t),{[m]:e[m]})):t}):H,[G,v,Y,m,H]),q=Rn(H,b,x),V=e.useMemo(()=>e=>{const t={strokeWidth:k};return t.stroke=b?Kt(e,b,q):Hn,A&&(t.fill=t.stroke,t.fillOpacity=E),t},[b,q,k,A,E]),U=e.useMemo(()=>C.lineStyle?C.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=b?Kt(e,b,q):Hn,t},[b,q,C.lineStyle]),Z=e.useMemo(()=>{if(S)return e=>{const t={r:O,fillOpacity:1};return t.fill=b?Kt(e.parentLine||e,b,q):Hn,t}},[S,O,b,q]),{legend:Q,margin:K}=zn({data:G,colorBy:b,colorScale:q,showLegend:j,userMargin:s}),J=C.height||60,ee=e.useMemo(()=>{var e,t,n,o,r,i,a,s;return{top:null!==(t=null===(e=C.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(o=null===(n=C.margin)||void 0===n?void 0:n.bottom)&&void 0!==o?o:20,left:null!==(i=null===(r=C.margin)||void 0===r?void 0:r.left)&&void 0!==i?i:K.left,right:null!==(s=null===(a=C.margin)||void 0===a?void 0:a.right)&&void 0!==s?s:K.right}},[C.margin,K]),te=C.brushDirection||"x",ne=Kn({componentName:"MinimapChart",data:H,accessors:{xAccessor:f,yAccessor:y}});if(ne)return h.createElement(Yn,{componentName:"MinimapChart",message:ne,width:i,height:a});const oe=A?"area":"line",re=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:oe,data:X,xAccessor:f,yAccessor:y,groupAccessor:m||void 0,curve:w,lineStyle:V},S&&{pointStyle:Z}),{size:[i,a],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:K,showAxes:!0,xLabel:u,yLabel:d,xFormat:g,yFormat:p,enableHover:L,showGrid:M}),Q&&{legend:Q}),c&&{title:c}),P&&{tooltipContent:gn(P)}),$&&{xExtent:$}),B),ie={chartType:oe,data:X,xAccessor:f,yAccessor:y,groupAccessor:m||void 0,curve:w,lineStyle:U,size:[i,J+ee.top+ee.bottom],margin:ee,showAxes:null!==(o=C.showAxes)&&void 0!==o&&o,background:C.background,enableHover:!1},ae=h.createElement("div",{key:"minimap",style:{position:"relative",width:i,overflow:"hidden"}},h.createElement(ue,Object.assign({ref:z},ie)),h.createElement(ko,{width:i-ee.left-ee.right,height:J,margin:ee,scales:I,brushDirection:te,extent:$,onBrush:_})),se=h.createElement("div",{key:"main",style:{overflow:"hidden"}},h.createElement(ue,Object.assign({},re)));return h.createElement("div",{className:"minimap-chart"+(l?" "+l:"")},N?ae:se,N?se:ae)}function Eo(t){const n=Fn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:i,categoryAccessor:a="category",valueAccessor:s="value",orientation:l="vertical",valueFormat:c,colorBy:u,colorScheme:d="category10",sort:g=!1,barPadding:p=5,tooltip:f,annotations:y,frameProps:m={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,k=n.width,A=n.height,E=n.enableHover,S=n.showGrid,O=n.showLegend,L=n.title,M=n.categoryLabel,j=n.valueLabel,P=o||[];Un("BarChart",P,"categoryAccessor",a),Un("BarChart",P,"valueAccessor",s);const{activeSelectionHook:C,customHoverBehavior:N}=_n({selection:v,linkedHover:b,fallbackFields:u?["string"==typeof u?u:""]:[],unwrapData:!0,onObservation:x,chartType:"BarChart",chartId:w}),D=$n(P,g,s),T=Rn(P,u,d),B=e.useMemo(()=>e=>{const t={};return t.fill=u?Kt(e,u,T):Hn,t},[u,T]),H=e.useMemo(()=>An(B,C,v),[B,C,v]),{legend:W,margin:R}=zn({data:D,colorBy:u,colorScale:T,showLegend:O,userMargin:r,defaults:n.marginDefaults}),$=e.useMemo(()=>vn({categoryAccessor:a,valueAccessor:s,groupAccessor:u&&u!==a?u:void 0,groupLabel:"string"==typeof u?u:"group"}),[a,s,u]),_=Kn({componentName:"BarChart",data:P,accessors:{categoryAccessor:a,valueAccessor:s}});if(_)return h.createElement(Yn,{componentName:"BarChart",message:_,width:k,height:A});const z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar",data:D,oAccessor:a,rAccessor:s,projection:"horizontal"===l?"horizontal":"vertical",pieceStyle:H,size:[k,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R,barPadding:p,enableHover:E,showAxes:n.showAxes,oLabel:M,rLabel:j,rFormat:c,showGrid:S,oSort:g},W&&{legend:W}),L&&{title:L}),i&&{className:i}),{tooltipContent:f?gn(f):$}),(b||x)&&{customHoverBehavior:N}),y&&y.length>0&&{annotations:y}),m);return h.createElement(Vn,{componentName:"BarChart",width:k,height:A},h.createElement(Pe,Object.assign({},z)))}function So(t){const n=Fn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:i,categoryAccessor:a="category",stackBy:s,valueAccessor:l="value",orientation:c="vertical",valueFormat:u,colorBy:d,colorScheme:g="category10",normalize:p=!1,barPadding:f=5,tooltip:y,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:k}=t,A=n.width,E=n.height,S=n.enableHover,O=n.showGrid,L=n.showLegend,M=n.title,j=n.categoryLabel,P=n.valueLabel,C=o||[],N=d||s,{activeSelectionHook:D,customHoverBehavior:T}=_n({selection:b,linkedHover:x,fallbackFields:N?["string"==typeof N?N:""]:[],unwrapData:!0,onObservation:w,chartType:"StackedBarChart",chartId:k}),B=Rn(C,N,g),H=e.useMemo(()=>e=>N?{fill:Kt(e,N,B)}:{fill:Hn},[N,B]),W=e.useMemo(()=>An(H,D,b),[H,D,b]),{legend:R,margin:$}=zn({data:C,colorBy:N,colorScale:B,showLegend:L,userMargin:r,defaults:n.marginDefaults}),_=e.useMemo(()=>vn({categoryAccessor:s,valueAccessor:l,groupAccessor:a}),[s,a,l]),z=Kn({componentName:"StackedBarChart",data:C,accessors:{categoryAccessor:a,valueAccessor:l},requiredProps:{stackBy:s}});if(z)return h.createElement(Yn,{componentName:"StackedBarChart",message:z,width:A,height:E});const I=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar",data:C,oAccessor:a,rAccessor:l,stackBy:s,normalize:p,projection:"horizontal"===c?"horizontal":"vertical",pieceStyle:W,size:[A,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:$,barPadding:f,enableHover:S,showAxes:n.showAxes,oLabel:j,rLabel:P,rFormat:u,showGrid:O},R&&{legend:R}),M&&{title:M}),i&&{className:i}),{tooltipContent:y?gn(y):_}),(x||w)&&{customHoverBehavior:T}),m&&m.length>0&&{annotations:m}),v);return h.createElement(Vn,{componentName:"StackedBarChart",width:A,height:E},h.createElement(Pe,Object.assign({},I)))}function Oo(t){const n=Fn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:i,categoryAccessor:a="category",valueAccessor:s="value",orientation:l="vertical",valueFormat:c,colorBy:u,colorScheme:d="category10",sizeBy:g,sizeRange:p=[3,8],pointRadius:f=4,pointOpacity:y=.7,categoryPadding:m=20,tooltip:v,annotations:b,frameProps:x={},selection:w,linkedHover:k,onObservation:A,chartId:E}=t,S=n.width,O=n.height,L=n.enableHover,M=n.showGrid,j=n.showLegend,P=n.title,C=n.categoryLabel,N=n.valueLabel,D=o||[],{activeSelectionHook:T,customHoverBehavior:B}=_n({selection:w,linkedHover:k,fallbackFields:u?["string"==typeof u?u:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:A,chartType:"SwarmPlot",chartId:E}),H=Rn(D,u,d),W=e.useMemo(()=>{if(!g)return;const e=D.map(e=>"function"==typeof g?g(e):e[g]);return[Math.min(...e),Math.max(...e)]},[D,g]),R=e.useMemo(()=>e=>{const t={fillOpacity:y};return t.fill=u?Kt(e,u,H):Hn,t.r=g?en(e,g,p,W):f,t},[u,H,g,p,W,f,y]),$=e.useMemo(()=>An(R,T,w),[R,T,w]),{legend:_,margin:z}=zn({data:D,colorBy:u,colorScale:H,showLegend:j,userMargin:r,defaults:n.marginDefaults}),I=e.useMemo(()=>vn({categoryAccessor:a,valueAccessor:s,groupAccessor:u||void 0}),[a,s,u]),F=Kn({componentName:"SwarmPlot",data:D,accessors:{categoryAccessor:a,valueAccessor:s}});if(F)return h.createElement(Yn,{componentName:"SwarmPlot",message:F,width:S,height:O});const Y=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"swarm",data:D,oAccessor:a,rAccessor:s,projection:"horizontal"===l?"horizontal":"vertical",pieceStyle:$,size:[S,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:z,barPadding:m,enableHover:L,showAxes:n.showAxes,oLabel:C,rLabel:N,rFormat:c,showGrid:M},_&&{legend:_}),P&&{title:P}),i&&{className:i}),{tooltipContent:v?gn(v):I}),(k||A)&&{customHoverBehavior:B}),b&&b.length>0&&{annotations:b}),x);return h.createElement(Vn,{componentName:"SwarmPlot",width:S,height:O},h.createElement(Pe,Object.assign({},Y)))}function Lo(t){const n=Fn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:i,categoryAccessor:a="category",valueAccessor:s="value",orientation:l="vertical",valueFormat:c,colorBy:u,colorScheme:d="category10",showOutliers:g=!0,categoryPadding:p=20,tooltip:f,annotations:y,frameProps:m={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,k=n.width,A=n.height,E=n.enableHover,S=n.showGrid,O=n.showLegend,L=n.title,M=n.categoryLabel,j=n.valueLabel,P=o||[],{activeSelectionHook:C,customHoverBehavior:N}=_n({selection:v,linkedHover:b,fallbackFields:u?["string"==typeof u?u:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:x,chartType:"BoxPlot",chartId:w}),D=Rn(P,u,d),T=e.useMemo(()=>e=>{const t=u?Kt(e,u,D):Hn;return{fill:t,stroke:t,fillOpacity:.8}},[u,D]),B=e.useMemo(()=>An(T,C,v),[T,C,v]),{legend:H,margin:W}=zn({data:P,colorBy:u,colorScale:D,showLegend:O,userMargin:r,defaults:n.marginDefaults}),R=e.useMemo(()=>e=>{const t=e.stats||(e.data||e).stats||{};return h.createElement("div",{className:"semiotic-tooltip",style:cn},h.createElement("div",{style:{fontWeight:"bold",marginBottom:"4px"}},(e.category||(e.data||e).category||"")+""),null!=t.median&&h.createElement(h.Fragment,null,null!=t.n&&h.createElement("div",null,"n = ",t.n),h.createElement("div",null,"Median: ",t.median.toLocaleString()),h.createElement("div",null,"Q1: ",t.q1.toLocaleString()),h.createElement("div",null,"Q3: ",t.q3.toLocaleString()),h.createElement("div",null,"Min: ",t.min.toLocaleString()),h.createElement("div",null,"Max: ",t.max.toLocaleString())))},[]),$=Kn({componentName:"BoxPlot",data:P,accessors:{categoryAccessor:a,valueAccessor:s}});if($)return h.createElement(Yn,{componentName:"BoxPlot",message:$,width:k,height:A});const _=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"boxplot",data:P,oAccessor:a,rAccessor:s,projection:"horizontal"===l?"horizontal":"vertical",summaryStyle:B,showOutliers:g,size:[k,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:W,barPadding:p,enableHover:E,showAxes:n.showAxes,oLabel:M,rLabel:j,rFormat:c,showGrid:S},H&&{legend:H}),L&&{title:L}),i&&{className:i}),{tooltipContent:f?gn(f):R}),(b||x)&&{customHoverBehavior:N}),y&&y.length>0&&{annotations:y}),m);return h.createElement(Vn,{componentName:"BoxPlot",width:k,height:A},h.createElement(Pe,Object.assign({},_)))}function Mo(t){const n=Fn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:i,categoryAccessor:a="category",valueAccessor:s="value",bins:l=25,relative:c=!1,valueFormat:u,colorBy:d,colorScheme:g="category10",categoryPadding:p=20,tooltip:f,annotations:y,frameProps:m={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,k=n.width,A=n.height,E=n.enableHover,S=n.showGrid,O=n.showLegend,L=n.title,M=n.categoryLabel,j=n.valueLabel,P=o||[],{activeSelectionHook:C,customHoverBehavior:N}=_n({selection:v,linkedHover:b,fallbackFields:d?["string"==typeof d?d:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:x,chartType:"Histogram",chartId:w}),D=Rn(P,d,g),T=e.useMemo(()=>e=>{const t=d?Kt(e,d,D):Hn;return{fill:t,stroke:t,fillOpacity:.8}},[d,D]),B=e.useMemo(()=>An(T,C,v),[T,C,v]),{legend:H,margin:W}=zn({data:P,colorBy:d,colorScale:D,showLegend:O,userMargin:r,defaults:n.marginDefaults}),R=e.useMemo(()=>e=>{const t=e.data||e,n=t.category||e.category||"",o=t.count,r=t.range;return h.createElement("div",{className:"semiotic-tooltip",style:cn},n&&h.createElement("div",{style:{fontWeight:"bold"}},n+""),null!=o&&h.createElement("div",null,"Count: ",o),r&&2===r.length&&h.createElement("div",{style:{opacity:.8}},Number(r[0]).toFixed(1)," – ",Number(r[1]).toFixed(1)))},[]),$=Kn({componentName:"Histogram",data:P,accessors:{categoryAccessor:a,valueAccessor:s}});if($)return h.createElement(Yn,{componentName:"Histogram",message:$,width:k,height:A});const _=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"histogram",data:P,oAccessor:a,rAccessor:s,projection:"horizontal",summaryStyle:B,bins:l,normalize:c,size:[k,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:W,barPadding:p,enableHover:E,showAxes:n.showAxes,oLabel:M,rLabel:j,rFormat:u,showGrid:S},H&&{legend:H}),L&&{title:L}),i&&{className:i}),{tooltipContent:f?gn(f):R}),(b||x)&&{customHoverBehavior:N}),y&&y.length>0&&{annotations:y}),m);return h.createElement(Vn,{componentName:"Histogram",width:k,height:A},h.createElement(Pe,Object.assign({},_)))}function jo(t){const n=Fn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:i,categoryAccessor:a="category",valueAccessor:s="value",orientation:l="vertical",bins:c=25,showIQR:u=!0,valueFormat:d,colorBy:g,colorScheme:p="category10",categoryPadding:f=20,tooltip:y,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:k}=t,A=n.width,E=n.height,S=n.enableHover,O=n.showGrid,L=n.showLegend,M=n.title,j=n.categoryLabel,P=n.valueLabel,C=o||[],{activeSelectionHook:N,customHoverBehavior:D}=_n({selection:b,linkedHover:x,fallbackFields:g?["string"==typeof g?g:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:w,chartType:"ViolinPlot",chartId:k}),T=Rn(C,g,p),B=e.useMemo(()=>e=>{const t=g?Kt(e,g,T):Hn;return{fill:t,stroke:t,fillOpacity:.6}},[g,T]),H=e.useMemo(()=>An(B,N,b),[B,N,b]),{legend:W,margin:R}=zn({data:C,colorBy:g,colorScale:T,showLegend:L,userMargin:r,defaults:n.marginDefaults}),$=e.useMemo(()=>e=>{var t;const n=e.category||e.data&&(null===(t=e.data[0])||void 0===t?void 0:t.category)||"",o=e.stats;if(o)return h.createElement("div",{className:"semiotic-tooltip",style:cn},n&&h.createElement("div",{style:{fontWeight:"bold"}},n+""),h.createElement("div",null,"n = ",o.n),h.createElement("div",null,"Min: ",o.min.toLocaleString()),h.createElement("div",null,"Q1: ",o.q1.toLocaleString()),h.createElement("div",null,"Median: ",o.median.toLocaleString()),h.createElement("div",null,"Q3: ",o.q3.toLocaleString()),h.createElement("div",null,"Max: ",o.max.toLocaleString()),h.createElement("div",{style:{opacity:.8}},"Mean: ",o.mean.toLocaleString(void 0,{maximumFractionDigits:2})));const r=(Array.isArray(e.data)?e.data:[]).map(e=>{const t="function"==typeof s?s(e):e[s];return Number(t)}).filter(e=>!isNaN(e)).sort((e,t)=>e-t),i=r.length,a=i>0?r[Math.floor(i/2)]:null;return h.createElement("div",{className:"semiotic-tooltip",style:cn},n&&h.createElement("div",{style:{fontWeight:"bold"}},n+""),i>0&&h.createElement("div",null,"n = ",i),null!=a&&h.createElement("div",null,"Median: ",a.toLocaleString()))},[s]),_=Kn({componentName:"ViolinPlot",data:C,accessors:{categoryAccessor:a,valueAccessor:s}});if(_)return h.createElement(Yn,{componentName:"ViolinPlot",message:_,width:A,height:E});const z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"violin",data:C,oAccessor:a,rAccessor:s,projection:"horizontal"===l?"horizontal":"vertical",summaryStyle:H,bins:c,showIQR:u,size:[A,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R,barPadding:f,enableHover:S,showAxes:n.showAxes,oLabel:j,rLabel:P,rFormat:d,showGrid:O},W&&{legend:W}),M&&{title:M}),i&&{className:i}),{tooltipContent:y?gn(y):$}),(x||w)&&{customHoverBehavior:D}),m&&m.length>0&&{annotations:m}),v);return h.createElement(Vn,{componentName:"ViolinPlot",width:A,height:E},h.createElement(Pe,Object.assign({},z)))}function Po(t){const n=Fn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:i,categoryAccessor:a="category",valueAccessor:s="value",orientation:l="horizontal",bins:c=20,amplitude:u=1.5,valueFormat:d,colorBy:g,colorScheme:p="category10",categoryPadding:f=5,tooltip:y,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:k}=t,A=n.width,E=n.height,S=n.enableHover,O=n.showGrid,L=n.showLegend,M=n.title,j=n.categoryLabel,P=n.valueLabel,C=o||[],{activeSelectionHook:N,customHoverBehavior:D}=_n({selection:b,linkedHover:x,fallbackFields:g?["string"==typeof g?g:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:w,chartType:"RidgelinePlot",chartId:k}),T=Rn(C,g,p),B=e.useMemo(()=>e=>{const t=g?Kt(e,g,T):Hn;return{fill:t,stroke:t,fillOpacity:.5}},[g,T]),H=e.useMemo(()=>An(B,N,b),[B,N,b]),{legend:W,margin:R}=zn({data:C,colorBy:g,colorScale:T,showLegend:L,userMargin:r,defaults:n.marginDefaults}),$=e.useMemo(()=>e=>{var t;const n=e.category||e.data&&(null===(t=e.data[0])||void 0===t?void 0:t.category)||"",o=e.stats;return o?h.createElement("div",{className:"semiotic-tooltip",style:cn},n&&h.createElement("div",{style:{fontWeight:"bold"}},n+""),h.createElement("div",null,"n = ",o.n),h.createElement("div",null,"Min: ",o.min.toLocaleString()),h.createElement("div",null,"Q1: ",o.q1.toLocaleString()),h.createElement("div",null,"Median: ",o.median.toLocaleString()),h.createElement("div",null,"Q3: ",o.q3.toLocaleString()),h.createElement("div",null,"Max: ",o.max.toLocaleString()),h.createElement("div",{style:{opacity:.8}},"Mean: ",o.mean.toLocaleString(void 0,{maximumFractionDigits:2}))):h.createElement("div",{className:"semiotic-tooltip",style:cn},h.createElement("div",{style:{fontWeight:"bold"}},n+""))},[]),_=Kn({componentName:"RidgelinePlot",data:C,accessors:{categoryAccessor:a,valueAccessor:s}});if(_)return h.createElement(Yn,{componentName:"RidgelinePlot",message:_,width:A,height:E});const z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"ridgeline",data:C,oAccessor:a,rAccessor:s,projection:"horizontal"===l?"horizontal":"vertical",summaryStyle:H,bins:c,size:[A,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R,barPadding:f,enableHover:S,showAxes:n.showAxes,oLabel:j,rLabel:P,rFormat:d,showGrid:O,oSort:!1},W&&{legend:W}),M&&{title:M}),i&&{className:i}),{tooltipContent:y?gn(y):$}),(x||w)&&{customHoverBehavior:D}),m&&m.length>0&&{annotations:m}),v);return z.amplitude=u,h.createElement(Vn,{componentName:"RidgelinePlot",width:A,height:E},h.createElement(Pe,Object.assign({},z)))}function Co(t){var n;const o=Fn(t.mode,{width:t.width,height:t.height,showGrid:null===(n=t.showGrid)||void 0===n||n,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:r,margin:i,className:a,categoryAccessor:s="category",valueAccessor:l="value",orientation:c="horizontal",valueFormat:u,colorBy:d,colorScheme:g="category10",sort:p=!0,dotRadius:f=5,categoryPadding:y=10,tooltip:m,annotations:v,frameProps:b={},selection:x,linkedHover:w,onObservation:k,chartId:A}=t,E=o.width,S=o.height,O=o.enableHover,L=o.showGrid,M=o.showLegend,j=o.title,P=o.categoryLabel,C=o.valueLabel,N=r||[],{activeSelectionHook:D,customHoverBehavior:T}=_n({selection:x,linkedHover:w,fallbackFields:d?["string"==typeof d?d:""]:["string"==typeof s?s:""],unwrapData:!0,onObservation:k,chartType:"DotPlot",chartId:A}),B=$n(N,p,l),H=Rn(N,d,g),W=e.useMemo(()=>e=>{const t={r:f,fillOpacity:.8};return t.fill=d?Kt(e,d,H):Hn,t},[d,H,f]),R=e.useMemo(()=>An(W,D,x),[W,D,x]),{legend:$,margin:_}=zn({data:B,colorBy:d,colorScale:H,showLegend:M,userMargin:i,defaults:o.marginDefaults}),z=e.useMemo(()=>vn({categoryAccessor:s,valueAccessor:l}),[s,l]),I=Kn({componentName:"DotPlot",data:N,accessors:{categoryAccessor:s,valueAccessor:l}});if(I)return h.createElement(Yn,{componentName:"DotPlot",message:I,width:E,height:S});const F=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"point",data:B,oAccessor:s,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",pieceStyle:R,size:[E,S],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:_,barPadding:y,enableHover:O,showAxes:o.showAxes,oLabel:P,rLabel:C,rFormat:u,showGrid:L,oSort:p},$&&{legend:$}),j&&{title:j}),a&&{className:a}),{tooltipContent:m?gn(m):z}),(w||k)&&{customHoverBehavior:T}),v&&v.length>0&&{annotations:v}),b);return h.createElement(Vn,{componentName:"DotPlot",width:E,height:S},h.createElement(Pe,Object.assign({},F)))}function No(t){var n,o;const r=Fn(t.mode,{width:null!==(n=t.width)&&void 0!==n?n:400,height:null!==(o=t.height)&&void 0!==o?o:400,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title}),{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",colorBy:u,colorScheme:d="category10",startAngle:g=0,tooltip:p,annotations:f,frameProps:y={},selection:m,linkedHover:v,onObservation:b,chartId:x}=t,w=r.width,k=r.height,A=r.enableHover,E=r.showLegend,S=r.title,O=i||[],L=u||l,{activeSelectionHook:M,customHoverBehavior:j}=_n({selection:m,linkedHover:v,fallbackFields:L?["string"==typeof L?L:""]:[],unwrapData:!0,onObservation:b,chartType:"PieChart",chartId:x}),P=Rn(O,L,d),C=e.useMemo(()=>e=>L?{fill:Kt(e,L,P)}:{fill:Hn},[L,P]),N=e.useMemo(()=>An(C,M,m),[C,M,m]),{legend:D,margin:T}=zn({data:O,colorBy:L,colorScale:P,showLegend:E,userMargin:a,defaults:r.marginDefaults}),B=e.useMemo(()=>vn({categoryAccessor:l,valueAccessor:c,groupAccessor:u&&u!==l?u:void 0,groupLabel:"string"==typeof u?u:"group",pieData:!0}),[l,c,u]),H=Kn({componentName:"PieChart",data:O,accessors:{categoryAccessor:l,valueAccessor:c}});if(H)return h.createElement(Yn,{componentName:"PieChart",message:H,width:w,height:k});const W=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"pie",data:O,oAccessor:l,rAccessor:c,projection:"radial",pieceStyle:N,startAngle:g,size:[w,k],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:T,enableHover:A,showAxes:!1},D&&{legend:D}),S&&{title:S}),s&&{className:s}),{tooltipContent:p?gn(p):B}),(v||b)&&{customHoverBehavior:j}),f&&f.length>0&&{annotations:f}),y);return h.createElement(Vn,{componentName:"PieChart",width:w,height:k},h.createElement(Pe,Object.assign({},W)))}function Do(t){var n,o;const r=Fn(t.mode,{width:null!==(n=t.width)&&void 0!==n?n:400,height:null!==(o=t.height)&&void 0!==o?o:400,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,linkedHover:t.linkedHover}),{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",innerRadius:u=60,centerContent:d,colorBy:g,colorScheme:p="category10",startAngle:f=0,tooltip:y,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:k}=t,A=r.width,E=r.height,S=r.enableHover,O=r.showLegend,L=r.title,M=i||[],j=g||l,{activeSelectionHook:P,customHoverBehavior:C}=_n({selection:b,linkedHover:x,fallbackFields:j?["string"==typeof j?j:""]:[],unwrapData:!0,onObservation:w,chartType:"DonutChart",chartId:k}),N=Rn(M,j,p),D=e.useMemo(()=>e=>j?{fill:Kt(e,j,N)}:{fill:Hn},[j,N]),T=e.useMemo(()=>An(D,P,b),[D,P,b]),{legend:B,margin:H}=zn({data:M,colorBy:j,colorScale:N,showLegend:O,userMargin:a,defaults:r.marginDefaults}),W=e.useMemo(()=>vn({categoryAccessor:l,valueAccessor:c,groupAccessor:g&&g!==l?g:void 0,groupLabel:"string"==typeof g?g:"group",pieData:!0}),[l,c,g]),R=Kn({componentName:"DonutChart",data:M,accessors:{categoryAccessor:l,valueAccessor:c}});if(R)return h.createElement(Yn,{componentName:"DonutChart",message:R,width:A,height:E});const $=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"donut",data:M,oAccessor:l,rAccessor:c,projection:"radial",pieceStyle:T,innerRadius:u,startAngle:f,centerContent:d,size:[A,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:H,enableHover:S,showAxes:!1},B&&{legend:B}),L&&{title:L}),s&&{className:s}),{tooltipContent:y?gn(y):W}),(x||w)&&{customHoverBehavior:C}),m&&m.length>0&&{annotations:m}),v);return h.createElement(Vn,{componentName:"DonutChart",width:A,height:E},h.createElement(Pe,Object.assign({},$)))}function To(t){const n=Fn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:i,categoryAccessor:a="category",groupBy:s,valueAccessor:l="value",orientation:c="vertical",valueFormat:u,colorBy:d,colorScheme:g="category10",barPadding:p=5,tooltip:f,annotations:y,frameProps:m={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,k=n.width,A=n.height,E=n.enableHover,S=n.showGrid,O=n.showLegend,L=n.title,M=n.categoryLabel,j=n.valueLabel,P=o||[],C=d||s,{activeSelectionHook:N,customHoverBehavior:D}=_n({selection:v,linkedHover:b,fallbackFields:C?["string"==typeof C?C:""]:[],unwrapData:!0,onObservation:x,chartType:"GroupedBarChart",chartId:w}),T=Rn(P,C,g),B=e.useMemo(()=>e=>C?{fill:Kt(e,C,T)}:{fill:Hn},[C,T]),H=e.useMemo(()=>An(B,N,v),[B,N,v]),{legend:W,margin:R}=zn({data:P,colorBy:C,colorScale:T,showLegend:O,userMargin:r,defaults:n.marginDefaults}),$=e.useMemo(()=>vn({categoryAccessor:s,valueAccessor:l,groupAccessor:a}),[s,a,l]),_=Kn({componentName:"GroupedBarChart",data:P,accessors:{categoryAccessor:a,valueAccessor:l},requiredProps:{groupBy:s}});if(_)return h.createElement(Yn,{componentName:"GroupedBarChart",message:_,width:k,height:A});const z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"clusterbar",data:P,oAccessor:a,rAccessor:l,groupBy:s,projection:"horizontal"===c?"horizontal":"vertical",pieceStyle:H,size:[k,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R,barPadding:p,enableHover:E,showAxes:n.showAxes,oLabel:M,rLabel:j,rFormat:u,showGrid:S},W&&{legend:W}),L&&{title:L}),i&&{className:i}),{tooltipContent:f?gn(f):$}),(b||x)&&{customHoverBehavior:D}),y&&y.length>0&&{annotations:y}),m);return h.createElement(Vn,{componentName:"GroupedBarChart",width:k,height:A},h.createElement(Pe,Object.assign({},z)))}function Bo(t){var n;const o=Fn(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLegend:t.showLegend,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:r,edges:i,margin:a,className:s,nodeIDAccessor:l="id",sourceAccessor:c="source",targetAccessor:u="target",nodeLabel:d,colorBy:g,colorScheme:p="category10",nodeSize:f=8,nodeSizeRange:y=[5,20],edgeWidth:m=1,edgeColor:v="#999",edgeOpacity:b=.6,iterations:x=300,forceStrength:w=.1,tooltip:k,frameProps:A={},onObservation:E,chartId:S,selection:O,linkedHover:L}=t,M=o.width,j=o.height,P=o.enableHover,C=o.showLegend,N=null!==(n=o.showLabels)&&void 0!==n&&n,D=o.title,T=r||[],B=i||[],H=Rn(T,g,p),W=e.useMemo(()=>e=>{const t={};return t.fill=g?Kt(e.data||e,g,H):Hn,"number"==typeof f&&(t.r=f),t},[g,H,f]),R=e.useMemo(()=>e=>({stroke:v,strokeWidth:"number"==typeof m?m:"function"==typeof m?m(e):e[m]||1,opacity:b}),[m,v,b]),$=e.useMemo(()=>{if(N&&d)return"function"==typeof d?d:e=>e[d]},[N,d]),{legend:_,margin:z}=zn({data:T,colorBy:g,colorScale:H,showLegend:C,userMargin:a,defaults:o.marginDefaults}),{customHoverBehavior:I}=_n({selection:O,linkedHover:L,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!0,onObservation:E,chartType:"ForceDirectedGraph",chartId:S}),F=eo({componentName:"ForceDirectedGraph",nodes:r,edges:i,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:l}});return F?h.createElement(Yn,{componentName:"ForceDirectedGraph",message:F,width:M,height:j}):h.createElement(Vn,{componentName:"ForceDirectedGraph",width:M,height:j},h.createElement(ln,Object.assign({chartType:"force",nodes:T,edges:B,size:[M,j],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:z,nodeIDAccessor:l,sourceAccessor:c,targetAccessor:u,iterations:x,forceStrength:w,nodeStyle:W,edgeStyle:R,colorBy:g,colorScheme:p,nodeSize:f,nodeSizeRange:y,nodeLabel:$,showLabels:N,enableHover:P,tooltipContent:k?e=>gn(k)(e.data):void 0,customHoverBehavior:L||E?I:void 0,legend:_,className:s,title:D},A)))}function Ho(e,t){if(!e)return[];const n=[],o=e=>{n.push(e);const r="function"==typeof t?t(e):e[t];r&&Array.isArray(r)&&r.forEach(o)};return o(e),n}function Wo(e,t,n,o){if(e&&e.length>0)return e;const r=new Set;return t.forEach(e=>{const t="function"==typeof n?n(e):e[n],i="function"==typeof o?o(e):e[o];r.add(t),r.add(i)}),Array.from(r).map(e=>({id:e}))}function Ro(e){return"function"==typeof e?e:t=>t[e]||1}function $o({edgeColorBy:e,colorBy:t,colorScale:n,nodeStyleFn:o,edgeOpacity:r,baseStyle:i={}}){return a=>{const s=Object.assign({fillOpacity:r},i);if("function"==typeof e)s.fill=e(a);else if("source"===e){const e="object"==typeof a.source?a.source:null;t&&e?s.fill=Kt(e.data||e,t,n):e&&(s.fill=o(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?s.fill=Kt(e.data||e,t,n):e&&(s.fill=o(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*r);return s}}function _o(t){var n;const o=Fn(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:r,edges:i,margin:a,className:s,sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:u="value",nodeIdAccessor:d="id",colorBy:g,colorScheme:p="category10",edgeColorBy:f="source",padAngle:y=.01,groupWidth:m=20,sortGroups:v,nodeLabel:b,edgeOpacity:x=.5,tooltip:w,frameProps:k={},onObservation:A,chartId:E,selection:S,linkedHover:O}=t,L=o.width,M=o.height,j=o.enableHover,P=null===(n=o.showLabels)||void 0===n||n,C=o.title,N=i||[],D=e.useMemo(()=>Wo(r,N,l,c),[r,N,l,c]),T=Rn(D,g,p),B=e.useMemo(()=>(e,t)=>{var n,o;const r={stroke:"black",strokeWidth:1};if(g)r.fill=Kt(e.data||e,g,T);else{const i=Array.isArray(p)?p:Ut[p]||Zt,a=Array.isArray(i)?i:Zt,s=null!==(o=null!==(n=e.index)&&void 0!==n?n:t)&&void 0!==o?o:0;r.fill=a[s%a.length]}return r},[g,T,p]),H=e.useMemo(()=>$o({edgeColorBy:f,colorBy:g,colorScale:T,nodeStyleFn:B,edgeOpacity:x,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:x}}),[f,g,T,B,x]),W=e.useMemo(()=>{if(!P)return;const e=b||d;return"function"==typeof e?e:t=>t[e]},[P,b,d]),R=Object.assign(Object.assign({},o.marginDefaults),a),{customHoverBehavior:$}=_n({selection:S,linkedHover:O,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!0,onObservation:A,chartType:"ChordDiagram",chartId:E}),_=eo({componentName:"ChordDiagram",edges:i,edgesRequired:!0});return _?h.createElement(Yn,{componentName:"ChordDiagram",message:_,width:L,height:M}):h.createElement(Vn,{componentName:"ChordDiagram",width:L,height:M},h.createElement(ln,Object.assign({chartType:"chord",nodes:D,edges:N,size:[L,M],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R,nodeIDAccessor:d,sourceAccessor:l,targetAccessor:c,valueAccessor:u,padAngle:y,groupWidth:m,sortGroups:v,nodeStyle:B,edgeStyle:H,colorBy:g,colorScheme:p,edgeColorBy:f,edgeOpacity:x,nodeLabel:W,showLabels:P,enableHover:j,tooltipContent:w?e=>gn(w)(e.data):void 0,customHoverBehavior:O||A?$:void 0,className:s,title:C},k)))}function zo(t){var n;const o=Fn(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:800,height:600}),{nodes:r,edges:i,margin:a,className:s,sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:u="value",nodeIdAccessor:d="id",colorBy:g,colorScheme:p="category10",edgeColorBy:f="source",orientation:y="horizontal",nodeAlign:m="justify",nodePaddingRatio:v=.05,nodeWidth:b=15,nodeLabel:x,edgeOpacity:w=.5,edgeSort:k,tooltip:A,frameProps:E={},onObservation:S,chartId:O,selection:L,linkedHover:M}=t,j=o.width,P=o.height,C=o.enableHover,N=null===(n=o.showLabels)||void 0===n||n,D=o.title,T=i||[],B=e.useMemo(()=>Wo(r,T,l,c),[r,T,l,c]),H=Rn(B,g,p),W=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=g?Kt(e.data||e,g,H):"#4d430c",t},[g,H]),R=e.useMemo(()=>$o({edgeColorBy:f,colorBy:g,colorScale:H,nodeStyleFn:W,edgeOpacity:w,baseStyle:{stroke:"none",strokeWidth:0}}),[f,g,H,W,w]),$=e.useMemo(()=>{if(!N)return;const e=x||d;return"function"==typeof e?e:t=>t[e]},[N,x,d]),_=Object.assign(Object.assign({},o.marginDefaults),a),{customHoverBehavior:z,customClickBehavior:I}=_n({selection:L,linkedHover:M,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!0,onObservation:S,chartType:"SankeyDiagram",chartId:O}),F=eo({componentName:"SankeyDiagram",edges:i,edgesRequired:!0});return F?h.createElement(Yn,{componentName:"SankeyDiagram",message:F,width:j,height:P}):h.createElement(Vn,{componentName:"SankeyDiagram",width:j,height:P},h.createElement(ln,Object.assign({chartType:"sankey",nodes:B,edges:T,size:[j,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:_,nodeIDAccessor:d,sourceAccessor:l,targetAccessor:c,valueAccessor:u,orientation:y,nodeAlign:m,nodePaddingRatio:v,nodeWidth:b,nodeStyle:W,edgeStyle:R,colorBy:g,colorScheme:p,edgeColorBy:f,edgeOpacity:w,edgeSort:k,nodeLabel:$,showLabels:N,enableHover:C,tooltipContent:A?e=>gn(A)(e.data):void 0,customHoverBehavior:M||S?z:void 0,customClickBehavior:S?I:void 0,className:s,title:D},E)))}function Io(t){var n;const o=Fn(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:r,margin:i,className:a,layout:s="tree",orientation:l="vertical",childrenAccessor:c="children",valueAccessor:u="value",nodeIdAccessor:d="name",colorBy:g,colorScheme:p="category10",colorByDepth:f=!1,edgeStyle:y="curve",nodeLabel:m,nodeSize:v=5,tooltip:b,frameProps:x={},onObservation:w,chartId:k,selection:A,linkedHover:E}=t,S=o.width,O=o.height,L=o.enableHover,M=null===(n=o.showLabels)||void 0===n||n,j=o.title,P=Rn(e.useMemo(()=>Ho(r,c),[r,c]),f?void 0:g,p),C=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?Qt[(e.depth||0)%Qt.length]:g?Kt(e.data||e,g,P):Hn,t},[g,f,P]),N=e.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),D=e.useMemo(()=>{if("treemap"===s||"circlepack"===s||"partition"===s)return Ro(u)},[s,u]),T=Object.assign(Object.assign({},o.marginDefaults),i),{customHoverBehavior:B}=_n({selection:A,linkedHover:E,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!0,onObservation:w,chartType:"TreeDiagram",chartId:k}),H=Jn({componentName:"TreeDiagram",data:r});return H?h.createElement(Yn,{componentName:"TreeDiagram",message:H,width:S,height:O}):h.createElement(Vn,{componentName:"TreeDiagram",width:S,height:O},h.createElement(ln,Object.assign({chartType:s,data:r,size:[S,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:T,nodeIDAccessor:d,childrenAccessor:c,hierarchySum:D,treeOrientation:l,edgeType:y,nodeStyle:C,edgeStyle:N,colorBy:g,colorScheme:p,colorByDepth:f,nodeSize:v,nodeLabel:M?m||d:void 0,showLabels:M,enableHover:L,tooltipContent:b?e=>gn(b)(e.data):void 0,customHoverBehavior:E||w?B:void 0,className:a,title:j},x)))}function Fo(t){var n;const o=Fn(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,linkedHover:t.linkedHover},{width:600,height:600}),{data:r,margin:i,className:a,childrenAccessor:s="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d="category10",colorByDepth:g=!1,labelMode:p="leaf",nodeLabel:f,padding:y=4,paddingTop:m,tooltip:v,frameProps:b={},selection:x,linkedHover:w,onObservation:k,chartId:A}=t,E=o.width,S=o.height,O=o.enableHover,L=null===(n=o.showLabels)||void 0===n||n,M=o.title,{activeSelectionHook:j,customHoverBehavior:P}=_n({selection:x,linkedHover:w,fallbackFields:u?["string"==typeof u?u:""]:[],onObservation:k,chartType:"Treemap",chartId:A}),C=e.useCallback(e=>{if(!e)return P(null);const t=e.data||e;P({data:(null==t?void 0:t.data)||t})},[P]),N=Rn(e.useMemo(()=>Ho(r,s),[r,s]),g?void 0:u,d),D=e.useMemo(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=g?Qt[(e.depth||0)%Qt.length]:u?Kt(e.data||e,u,N):Hn,t},[u,g,N]),T=e.useMemo(()=>j?e=>{var t;const n=Object.assign({},D(e));if(j.isActive)if(j.predicate(e.data||e))(null==x?void 0:x.selectedStyle)&&Object.assign(n,x.selectedStyle);else{const e=null!==(t=null==x?void 0:x.unselectedOpacity)&&void 0!==t?t:.2;n.opacity=e,n.fillOpacity=e,n.strokeOpacity=e,(null==x?void 0:x.unselectedStyle)&&Object.assign(n,x.unselectedStyle)}return n}:D,[D,j,x]),B=e.useMemo(()=>Ro(l),[l]),H=void 0!==m?m:L&&"parent"===p?18:void 0,W=Object.assign(Object.assign({},o.marginDefaults),i),R=Jn({componentName:"Treemap",data:r});return R?h.createElement(Yn,{componentName:"Treemap",message:R,width:E,height:S}):h.createElement(Vn,{componentName:"Treemap",width:E,height:S},h.createElement(ln,Object.assign({chartType:"treemap",data:r,size:[E,S],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:W,nodeIDAccessor:c,childrenAccessor:s,hierarchySum:B,padding:y,paddingTop:H,nodeStyle:T,colorBy:u,colorScheme:d,colorByDepth:g,nodeLabel:L?f||c:void 0,showLabels:L,enableHover:O,tooltipContent:v?e=>gn(v)(e.data):void 0},(w||k)&&{customHoverBehavior:C},{className:a,title:M},b)))}function Yo(t){var n;const o=Fn(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:r,margin:i,className:a,childrenAccessor:s="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d="category10",colorByDepth:g=!1,nodeLabel:p,circleOpacity:f=.7,padding:y=4,tooltip:m,frameProps:v={},onObservation:b,chartId:x,selection:w,linkedHover:k}=t,A=o.width,E=o.height,S=o.enableHover,O=null===(n=o.showLabels)||void 0===n||n,L=o.title,M=Rn(e.useMemo(()=>Ho(r,s),[r,s]),g?void 0:u,d),j=e.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:f};return t.fill=g?Qt[(e.depth||0)%Qt.length]:u?Kt(e.data||e,u,M):Hn,t},[u,g,M,f]),P=e.useMemo(()=>Ro(l),[l]),C=Object.assign(Object.assign({},o.marginDefaults),i),{customHoverBehavior:N}=_n({selection:w,linkedHover:k,fallbackFields:u?["string"==typeof u?u:""]:[],unwrapData:!0,onObservation:b,chartType:"CirclePack",chartId:x}),D=Jn({componentName:"CirclePack",data:r});return D?h.createElement(Yn,{componentName:"CirclePack",message:D,width:A,height:E}):h.createElement(Vn,{componentName:"CirclePack",width:A,height:E},h.createElement(ln,Object.assign({chartType:"circlepack",data:r,size:[A,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:C,nodeIDAccessor:c,childrenAccessor:s,hierarchySum:P,padding:y,nodeStyle:j,colorBy:u,colorScheme:d,colorByDepth:g,nodeLabel:O?p||c:void 0,showLabels:O,enableHover:S,tooltipContent:m?e=>gn(m)(e.data):void 0,customHoverBehavior:k||b?N:void 0,className:a,title:L},v)))}wo.displayName="ScatterplotMatrix",Ao.displayName="MinimapChart",Eo.displayName="BarChart",So.displayName="StackedBarChart",Oo.displayName="SwarmPlot",Lo.displayName="BoxPlot",Mo.displayName="Histogram",jo.displayName="ViolinPlot",Po.displayName="RidgelinePlot",Co.displayName="DotPlot",No.displayName="PieChart",Do.displayName="DonutChart",To.displayName="GroupedBarChart",Bo.displayName="ForceDirectedGraph",_o.displayName="ChordDiagram",zo.displayName="SankeyDiagram",Io.displayName="TreeDiagram",Fo.displayName="Treemap",Yo.displayName="CirclePack";const Go=e.forwardRef(function(t,n){var o,r,i,a;const s=Fn(t.mode,{width:null!==(r=null===(o=t.size)||void 0===o?void 0:o[0])&&void 0!==r?r:t.width,height:null!==(a=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==a?a:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:l,margin:c,className:u,arrowOfTime:d="right",windowMode:g="sliding",windowSize:p=200,data:f,timeAccessor:y,valueAccessor:m,timeExtent:v,valueExtent:b,extentPadding:x,stroke:w="#007bff",strokeWidth:k=2,strokeDasharray:A,background:E,tooltipContent:S,tooltip:O,onHover:L,annotations:M,svgAnnotationRules:j,tickFormatTime:P,tickFormatValue:C,decay:N,pulse:D,staleness:T,transition:B,linkedHover:H,onObservation:W,chartId:R}=t,$=s.showAxes,_=s.enableHover,z=null!=c?c:s.marginDefaults,I=null!=l?l:[s.width,s.height],F=null!=S?S:O,Y=e.useRef(null),{customHoverBehavior:G}=_n({linkedHover:H,unwrapData:!0,onObservation:W,chartType:"RealtimeLineChart",chartId:R}),X=e.useCallback(e=>{L&&L(e),G(e)},[L,G]);return e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=Y.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=Y.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}})),h.createElement(ue,{ref:Y,chartType:"line",runtimeMode:"streaming",size:I,margin:z,className:u,arrowOfTime:d,windowMode:g,windowSize:p,data:f,timeAccessor:y,valueAccessor:m,xExtent:v,yExtent:b,extentPadding:x,lineStyle:{stroke:w,strokeWidth:k,strokeDasharray:A},showAxes:$,background:E,hoverAnnotation:_,tooltipContent:F,customHoverBehavior:X,annotations:M,svgAnnotationRules:j,tickFormatTime:P,tickFormatValue:C,decay:N,pulse:D,staleness:T,transition:B})});Go.displayName="RealtimeLineChart";const Xo=e.forwardRef(function(t,n){var o,r,i,a;const s=Fn(t.mode,{width:null!==(r=null===(o=t.size)||void 0===o?void 0:o[0])&&void 0!==r?r:t.width,height:null!==(a=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==a?a:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{binSize:l,size:c,margin:u,className:d,arrowOfTime:g="right",windowMode:p="sliding",windowSize:f=200,data:y,timeAccessor:m,valueAccessor:v,timeExtent:b,valueExtent:x,extentPadding:w,categoryAccessor:k,colors:A,fill:E,stroke:S,strokeWidth:O,gap:L,background:M,tooltipContent:j,tooltip:P,onHover:C,annotations:N,svgAnnotationRules:D,tickFormatTime:T,tickFormatValue:B,linkedHover:H,decay:W,pulse:R,staleness:$,transition:_,onObservation:z,chartId:I}=t,F=s.showAxes,Y=s.enableHover,G=null!=u?u:s.marginDefaults,X=null!=c?c:[s.width,s.height],q=null!=j?j:P,V=e.useRef(null),{customHoverBehavior:U}=_n({linkedHover:H,unwrapData:!0,onObservation:z,chartType:"RealtimeTemporalHistogram",chartId:I}),Z=e.useCallback(e=>{C&&C(e),U(e)},[C,U]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=V.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=V.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=V.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=V.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const Q={};return null!=E&&(Q.fill=E),null!=S&&(Q.stroke=S),null!=O&&(Q.strokeWidth=O),null!=L&&(Q.gap=L),h.createElement(ue,{ref:V,chartType:"bar",runtimeMode:"streaming",size:X,margin:G,className:d,arrowOfTime:g,windowMode:p,windowSize:f,data:y,timeAccessor:m,valueAccessor:v,xExtent:b,yExtent:x,extentPadding:w,binSize:l,categoryAccessor:k,barColors:A,barStyle:Q,showAxes:F,background:M,hoverAnnotation:Y,tooltipContent:q,customHoverBehavior:Z,annotations:N,svgAnnotationRules:D,tickFormatTime:T,tickFormatValue:B,decay:W,pulse:R,staleness:$,transition:_})});Xo.displayName="RealtimeTemporalHistogram";const qo=Xo,Vo=e.forwardRef(function(t,n){var o,r,i,a;const s=Fn(t.mode,{width:null!==(r=null===(o=t.size)||void 0===o?void 0:o[0])&&void 0!==r?r:t.width,height:null!==(a=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==a?a:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:l,margin:c,className:u,arrowOfTime:d="right",windowMode:g="sliding",windowSize:p=200,data:f,timeAccessor:y,valueAccessor:m,timeExtent:v,valueExtent:b,extentPadding:x,categoryAccessor:w,colors:k,radius:A,fill:E,opacity:S,stroke:O,strokeWidth:L,background:M,tooltipContent:j,tooltip:P,onHover:C,annotations:N,svgAnnotationRules:D,tickFormatTime:T,tickFormatValue:B,linkedHover:H,onObservation:W,chartId:R}=t,$=s.showAxes,_=s.enableHover,z=null!=c?c:s.marginDefaults,I=null!=l?l:[s.width,s.height],F=null!=j?j:P,Y=e.useRef(null),{customHoverBehavior:G}=_n({linkedHover:H,unwrapData:!0,onObservation:W,chartType:"RealtimeSwarmChart",chartId:R}),X=e.useCallback(e=>{C&&C(e),G(e)},[C,G]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=Y.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=Y.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const q={};return null!=A&&(q.radius=A),null!=E&&(q.fill=E),null!=S&&(q.opacity=S),null!=O&&(q.stroke=O),null!=L&&(q.strokeWidth=L),h.createElement(ue,{ref:Y,chartType:"swarm",runtimeMode:"streaming",size:I,margin:z,className:u,arrowOfTime:d,windowMode:g,windowSize:p,data:f,timeAccessor:y,valueAccessor:m,xExtent:v,yExtent:b,extentPadding:x,categoryAccessor:w,barColors:k,swarmStyle:q,showAxes:$,background:M,hoverAnnotation:_,tooltipContent:F,customHoverBehavior:X,annotations:N,svgAnnotationRules:D,tickFormatTime:T,tickFormatValue:B})});Vo.displayName="RealtimeSwarmChart";const Uo=e.forwardRef(function(t,n){var o,r,i,a;const s=Fn(t.mode,{width:null!==(r=null===(o=t.size)||void 0===o?void 0:o[0])&&void 0!==r?r:t.width,height:null!==(a=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==a?a:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:l,margin:c,className:u,arrowOfTime:d="right",windowMode:g="sliding",windowSize:p=200,data:f,timeAccessor:y,valueAccessor:m,timeExtent:v,valueExtent:b,extentPadding:x,positiveColor:w,negativeColor:k,connectorStroke:A,connectorWidth:E,gap:S,stroke:O,strokeWidth:L,background:M,tooltipContent:j,tooltip:P,onHover:C,annotations:N,svgAnnotationRules:D,tickFormatTime:T,tickFormatValue:B,linkedHover:H,onObservation:W,chartId:R}=t,$=s.showAxes,_=s.enableHover,z=null!=c?c:s.marginDefaults,I=null!=l?l:[s.width,s.height],F=null!=j?j:P,Y=e.useRef(null),{customHoverBehavior:G}=_n({linkedHover:H,unwrapData:!0,onObservation:W,chartType:"RealtimeWaterfallChart",chartId:R}),X=e.useCallback(e=>{C&&C(e),G(e)},[C,G]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=Y.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=Y.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const q={};return null!=w&&(q.positiveColor=w),null!=k&&(q.negativeColor=k),null!=A&&(q.connectorStroke=A),null!=E&&(q.connectorWidth=E),null!=S&&(q.gap=S),null!=O&&(q.stroke=O),null!=L&&(q.strokeWidth=L),h.createElement(ue,{ref:Y,chartType:"waterfall",runtimeMode:"streaming",size:I,margin:z,className:u,arrowOfTime:d,windowMode:g,windowSize:p,data:f,timeAccessor:y,valueAccessor:m,xExtent:v,yExtent:b,extentPadding:x,waterfallStyle:q,showAxes:$,background:M,hoverAnnotation:_,tooltipContent:F,customHoverBehavior:X,annotations:N,svgAnnotationRules:D,tickFormatTime:T,tickFormatValue:B})});Uo.displayName="RealtimeWaterfallChart";const Zo=e.forwardRef(function(t,n){var o,r,i,a;const s=Fn(t.mode,{width:null!==(r=null===(o=t.size)||void 0===o?void 0:o[0])&&void 0!==r?r:t.width,height:null!==(a=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==a?a:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:l,margin:c,className:u,arrowOfTime:d="right",windowMode:g="sliding",windowSize:p=200,data:f,timeAccessor:y,valueAccessor:m,categoryAccessor:v,timeExtent:b,valueExtent:x,extentPadding:w,heatmapXBins:k=20,heatmapYBins:A=20,aggregation:E="count",background:S,tooltipContent:O,tooltip:L,onHover:M,annotations:j,svgAnnotationRules:P,tickFormatTime:C,tickFormatValue:N,decay:D,pulse:T,staleness:B,linkedHover:H,onObservation:W,chartId:R}=t,$=s.showAxes,_=s.enableHover,z=null!=c?c:s.marginDefaults,I=null!=l?l:[s.width,s.height],F=null!=O?O:L,Y=e.useRef(null),{customHoverBehavior:G}=_n({linkedHover:H,unwrapData:!0,onObservation:W,chartType:"RealtimeHeatmap",chartId:R}),X=e.useCallback(e=>{M&&M(e),G(e)},[M,G]);return e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=Y.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=Y.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}})),h.createElement(ue,{ref:Y,chartType:"heatmap",runtimeMode:"streaming",size:I,margin:z,className:u,arrowOfTime:d,windowMode:g,windowSize:p,data:f,timeAccessor:y,valueAccessor:m,categoryAccessor:v,xExtent:b,yExtent:x,extentPadding:w,heatmapXBins:k,heatmapYBins:A,heatmapAggregation:E,showAxes:$,background:S,hoverAnnotation:_,tooltipContent:F,customHoverBehavior:X,annotations:j,svgAnnotationRules:P,tickFormatTime:C,tickFormatValue:N,decay:D,pulse:T,staleness:B})});Zo.displayName="RealtimeHeatmap";const Qo={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},Ko={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},[Jo,er]=En(e=>({theme:Qo,setTheme(t){e(e=>"light"===t?{theme:Qo}:"dark"===t?{theme:Ko}:{theme:Object.assign(Object.assign(Object.assign({},e.theme),t),{colors:Object.assign(Object.assign({},e.theme.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.theme.typography),t.typography||{})})})}}));function tr({theme:e}){const t=er(e=>e.setTheme);return h.useEffect(()=>{void 0!==e&&t(e)},[e,t]),null}function nr({children:e}){const t=er(e=>e.theme);return h.createElement("div",{style:{position:"relative","--semiotic-bg":t.colors.background,"--semiotic-text":t.colors.text,"--semiotic-text-secondary":t.colors.textSecondary,"--semiotic-grid":t.colors.grid,"--semiotic-border":t.colors.border,"--semiotic-primary":t.colors.primary,"--semiotic-font-family":t.typography.fontFamily}},e)}function or(e,t,n,o){return new(n||(n=Promise))(function(r,i){function a(e){try{l(o.next(e))}catch(e){i(e)}}function s(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){e.done?r(e.value):function(e){return e instanceof n?e:new n(function(t){t(e)})}(e.value).then(a,s)}l((o=o.apply(e,t||[])).next())})}function rr(e,t){return or(this,void 0,void 0,function*(){const{format:n="svg",filename:o="chart",scale:r=2,background:i="white"}=t||{},a=e.querySelector("svg");if(!a)throw Error("No SVG element found in the container");const s=a.cloneNode(!0),l=a.getBoundingClientRect();if(s.getAttribute("width")||s.setAttribute("width",l.width+""),s.getAttribute("height")||s.setAttribute("height",l.height+""),s.getAttribute("xmlns")||s.setAttribute("xmlns","http://www.w3.org/2000/svg"),ir(a,s),"svg"===n){const e=(new XMLSerializer).serializeToString(s);ar(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),o+".svg")}else{const e=l.width*r,t=l.height*r,n=(new XMLSerializer).serializeToString(s),a=new Blob([n],{type:"image/svg+xml;charset=utf-8"}),c=URL.createObjectURL(a),u=new Image;u.width=l.width,u.height=l.height,yield new Promise((n,a)=>{u.onload=()=>{const s=document.createElement("canvas");s.width=e,s.height=t;const l=s.getContext("2d");l.fillStyle=i,l.fillRect(0,0,e,t),l.scale(r,r),l.drawImage(u,0,0),s.toBlob(e=>{e?(ar(e,o+".png"),n()):a(Error("Failed to create PNG blob"))},"image/png"),URL.revokeObjectURL(c)},u.onerror=()=>{URL.revokeObjectURL(c),a(Error("Failed to load SVG image"))},u.src=c})}})}function ir(e,t){var n;const o=e.children,r=t.children,i=window.getComputedStyle(e),a=["fill","stroke","stroke-width","stroke-dasharray","opacity","fill-opacity","stroke-opacity","font-family","font-size","font-weight","text-anchor","dominant-baseline"];for(const e of a){const o=i.getPropertyValue(e);o&&"none"!==o&&""!==o&&(null===(n=t.style)||void 0===n||n.setProperty(e,o))}for(let e=0;Math.min(o.length,r.length)>e;e++)ir(o[e],r[e])}function ar(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}"function"==typeof SuppressedError&&SuppressedError;const sr={width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["function","object"]},frameProps:{type:"object"}},lr={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},cr={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"}},ur=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],dr=["vertical","horizontal"],hr={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},sr),lr),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:ur},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},fillArea:{type:"boolean"},areaOpacity:{type:"number"}})},AreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},sr),lr),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:ur},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},sr),lr),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:ur},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},normalize:{type:"boolean"}})},Scatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},sr),lr),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},BubbleChart:{required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},sr),lr),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},bubbleOpacity:{type:"number"},bubbleStrokeWidth:{type:"number"},bubbleStrokeColor:{type:"string"}})},Heatmap:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},sr),lr),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},colorScheme:{type:"string",enum:["blues","reds","greens","viridis","custom"]},customColorScale:{type:["object","function"]},showValues:{type:"boolean"},valueFormat:{type:"function"},cellBorderColor:{type:"string"},cellBorderWidth:{type:"number"}})},BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},sr),cr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:dr},sort:{type:["boolean","string","function"]},barPadding:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},sr),cr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:dr},normalize:{type:"boolean"},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},sr),cr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:dr},barPadding:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},sr),cr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:dr},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"}})},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},sr),cr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:dr},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},sr),cr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"}})},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},sr),cr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:dr},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"}})},DotPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},sr),cr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:dr},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},sr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"},slicePadding:{type:"number"}})},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},sr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"},slicePadding:{type:"number"}})},ForceDirectedGraph:{required:["nodes","edges"],dataShape:"network",dataAccessors:["nodeIDAccessor","sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},sr),{nodes:{type:"array"},edges:{type:"array"},nodeIDAccessor:{type:["string","function"]},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},nodeLabel:{type:["string","function"]},nodeSize:{type:["number","string","function"]},nodeSizeRange:{type:"array"},edgeWidth:{type:["number","string","function"]},edgeColor:{type:"string"},edgeOpacity:{type:"number"},iterations:{type:"number"},forceStrength:{type:"number"},showLabels:{type:"boolean"}})},SankeyDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},sr),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target","gradient"]},orientation:{type:"string",enum:dr},nodeAlign:{type:"string",enum:["justify","left","right","center"]},nodePaddingRatio:{type:"number"},nodeWidth:{type:"number"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"},edgeSort:{type:"function"}})},ChordDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},sr),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target"]},padAngle:{type:"number"},groupWidth:{type:"number"},sortGroups:{type:"function"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"}})},TreeDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},sr),{data:{type:"object"},layout:{type:"string",enum:["tree","cluster","partition","treemap","circlepack"]},orientation:{type:"string",enum:["vertical","horizontal","radial"]},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},edgeStyle:{type:"string",enum:["line","curve"]},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},nodeSize:{type:"number"}})},Treemap:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},sr),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]}})},CirclePack:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},sr),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]},circleOpacity:{type:"number"}})},RealtimeLineChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},stroke:{type:"string"},strokeWidth:{type:"number"},strokeDasharray:{type:"string"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHistogram:{required:["binSize"],dataShape:"realtime",dataAccessors:[],props:{binSize:{type:"number"},size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeSwarmChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},radius:{type:"number"},fill:{type:"string"},opacity:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeWaterfallChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},positiveColor:{type:"string"},negativeColor:{type:"string"},connectorStroke:{type:"string"},connectorWidth:{type:"number"},gap:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHeatmap:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},heatmapXBins:{type:"number"},heatmapYBins:{type:"number"},aggregation:{type:"string",enum:["count","sum","mean"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"}}}},gr=new Set(["tooltip","onObservation","xFormat","yFormat","valueFormat","svgAnnotationRules","tooltipContent","onHover","tickFormatTime","tickFormatValue","edgeSort","sortGroups","centerContent","frameProps","controls","oFormat","rFormat","oSort","pieceStyle","summaryStyle","nodeStyle","edgeStyle","customHoverBehavior","customClickBehavior","customDoubleClickBehavior","onBrush","onTopologyChange","backgroundGraphics","foregroundGraphics","legend"]),pr=new Set(["data","nodes","edges"]),fr="function"==typeof structuredClone?structuredClone:e=>JSON.parse(JSON.stringify(e));function yr(e){return or(this,arguments,void 0,function*(e,t="json"){const n="jsx"===t?mr(e):JSON.stringify(e,null,2);if("undefined"==typeof navigator||!navigator.clipboard)throw Error("Clipboard API not available. copyConfig requires a browser environment.");yield navigator.clipboard.writeText(n)})}function mr(e){const{component:t,props:n}=e,o=["<"+t];for(const[e,t]of Object.entries(n))if("string"==typeof t)o.push(` ${e}="${t}"`);else if("boolean"==typeof t&&!0===t)o.push(" "+e);else if("boolean"==typeof t&&!1===t)o.push(` ${e}={false}`);else if("number"==typeof t)o.push(` ${e}={${t}}`);else{const n=JSON.stringify(t);o.push(80>n.length?` ${e}={${n}}`:` ${e}={${JSON.stringify(t,null,2)}}`)}return o.push("/>"),o.join("\n")}function vr(e){return"nominal"===e||"ordinal"===e}function br(e){return"quantitative"===e||"temporal"===e}const xr={category10:"category10",category20:"category20",category20b:"category20",category20c:"category20",accent:"accent",dark2:"dark2",paired:"paired",pastel1:"pastel1",pastel2:"pastel2",set1:"set1",set2:"set2",set3:"set3",tableau10:"category10",tableau20:"category20"},wr={linear:"linear","monotone-x":"monotoneX","monotone-y":"monotoneY",monotone:"monotoneX",step:"step","step-after":"stepAfter","step-before":"stepBefore",basis:"basis",cardinal:"cardinal","catmull-rom":"catmullRom"},kr={sum:"sum",mean:"mean",average:"mean",count:"count",min:"min",max:"max",median:"mean"};function Ar(e,t,n,o,r){var i,a;(null==e?void 0:e.field)&&(n.xAccessor=o?"value":e.field),(null==t?void 0:t.field)&&(n.yAccessor=r?"value":t.field),(null===(i=null==e?void 0:e.axis)||void 0===i?void 0:i.title)&&(n.xLabel=e.axis.title),(null===(a=null==t?void 0:t.axis)||void 0===a?void 0:a.title)&&(n.yLabel=t.axis.title)}function Er(e,t,n){const o={component:e,props:t,version:"1",createdAt:(new Date).toISOString()};if(n.length>0){o.warnings=n;for(const e of n)console.warn("[semiotic/fromVegaLite] "+e)}return o}const Sr={live:{bg:"#22c55e",color:"#fff"},stale:{bg:"#ef4444",color:"#fff"},paused:{bg:"#eab308",color:"#000"},error:{bg:"#ef4444",color:"#fff"},static:{bg:"#6b7280",color:"#fff"}};function Or({height:e}){return h.createElement("div",{style:{width:"100%",height:e,background:"linear-gradient(90deg, var(--semiotic-border, #e0e0e0) 25%, var(--semiotic-bg, #f5f5f5) 50%, var(--semiotic-border, #e0e0e0) 75%)",backgroundSize:"200% 100%",animation:"semiotic-skeleton-pulse 1.5s ease-in-out infinite",borderRadius:4}})}function Lr({error:e}){return h.createElement("div",{role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:120,padding:24,boxSizing:"border-box"}},h.createElement("div",{style:{textAlign:"center",maxWidth:400,fontSize:14,color:"var(--semiotic-text-secondary, #666)",lineHeight:1.5}},e))}const Mr=h.forwardRef(function({title:e,subtitle:t,children:n,width:o="100%",height:r=400,actions:i,chartConfig:a,controls:s,loading:l=!1,error:c,errorBoundary:u=!1,status:d,detailsPanel:g,className:p,style:f},y){const m=h.useRef(null),v=h.useRef(null),[b,x]=h.useState(!1),w=!1!==(null==i?void 0:i.export)&&void 0!==(null==i?void 0:i.export),k=!1!==(null==i?void 0:i.fullscreen)&&void 0!==(null==i?void 0:i.fullscreen),A=!1!==(null==i?void 0:i.copyConfig)&&void 0!==(null==i?void 0:i.copyConfig)&&a,E="object"==typeof(null==i?void 0:i.export)?i.export:{},S="object"==typeof(null==i?void 0:i.copyConfig)?i.copyConfig.format:"json",O=h.useCallback(e=>or(this,void 0,void 0,function*(){v.current&&(yield rr(v.current,Object.assign(Object.assign({},E),e)))}),[E]),L=h.useCallback(()=>{m.current&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):m.current.requestFullscreen().catch(()=>{}))},[]),M=h.useCallback(e=>or(this,void 0,void 0,function*(){a&&(yield yr(a,e||S||"json"))}),[a,S]);h.useEffect(()=>{const e=()=>{x(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]),h.useImperativeHandle(y,()=>({export:O,toggleFullscreen:L,copyConfig:M,element:m.current}),[O,L,M]);const j=e||t||s||w||k||A||d,P=l?h.createElement(Or,{height:r}):c?h.createElement(Lr,{error:c}):u?h.createElement(Gn,null,n):n;return h.createElement(h.Fragment,null,h.createElement("style",{dangerouslySetInnerHTML:{__html:"@keyframes semiotic-skeleton-pulse {\n 0% { background-position: 200% 0; }\n 100% { background-position: -200% 0; }\n}"}}),h.createElement("div",{ref:m,className:"semiotic-chart-container"+(p?" "+p:""),style:Object.assign(Object.assign({width:o,border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:8,overflow:"hidden",background:"var(--semiotic-bg, #fff)",position:"relative"},b?{display:"flex",flexDirection:"column",width:"100%",height:"100%"}:{}),f)},j&&h.createElement("div",{className:"semiotic-chart-header",style:{padding:"12px 16px",display:"flex",justifyContent:"space-between",alignItems:"flex-start",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"}},h.createElement("div",{className:"semiotic-chart-title-area"},e&&h.createElement("div",{className:"semiotic-chart-title",style:{fontSize:14,fontWeight:600,color:"var(--semiotic-text, #333)"}},e),t&&h.createElement("div",{className:"semiotic-chart-subtitle",style:{fontSize:12,color:"var(--semiotic-text-secondary, #666)",marginTop:e?2:0}},t)),h.createElement("div",{className:"semiotic-chart-toolbar",style:{display:"flex",alignItems:"center",gap:4}},s,w&&h.createElement("button",{className:"semiotic-chart-action",onClick:()=>O(),title:"Export chart",style:jr},h.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},h.createElement("path",{d:"M7 2v8M3.5 7L7 10.5 10.5 7"}),h.createElement("path",{d:"M2 12h10"}))),k&&h.createElement("button",{className:"semiotic-chart-action",onClick:L,title:b?"Exit fullscreen":"Fullscreen",style:jr},h.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},b?h.createElement(h.Fragment,null,h.createElement("path",{d:"M9 1v4h4"}),h.createElement("path",{d:"M5 13V9H1"}),h.createElement("path",{d:"M13 5H9V1"}),h.createElement("path",{d:"M1 9h4v4"})):h.createElement(h.Fragment,null,h.createElement("path",{d:"M1 5V1h4"}),h.createElement("path",{d:"M13 9v4H9"}),h.createElement("path",{d:"M9 1h4v4"}),h.createElement("path",{d:"M5 13H1V9"})))),A&&h.createElement("button",{className:"semiotic-chart-action",onClick:()=>M(),title:"Copy config",style:jr},h.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},h.createElement("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1"}),h.createElement("path",{d:"M9 5V2a1 1 0 00-1-1H2a1 1 0 00-1 1v6a1 1 0 001 1h3"}))),d&&h.createElement("div",{className:"semiotic-chart-status",style:{padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",background:Sr[d].bg,color:Sr[d].color,lineHeight:"18px"}},d))),h.createElement("div",{className:"semiotic-chart-body",ref:v,style:Object.assign({position:"relative",overflow:"hidden"},b?{flex:1}:{height:r})},P,g)))}),jr={width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0};function Pr({children:e,columns:t="auto",minCellWidth:n=300,gap:o=16,className:r,style:i}){return h.createElement("div",{className:"semiotic-chart-grid"+(r?" "+r:""),style:Object.assign({display:"grid",gridTemplateColumns:"auto"===t?`repeat(auto-fill, minmax(${n}px, 1fr))`:`repeat(${t}, 1fr)`,gap:o,width:"100%"},i)},e)}function Cr({children:e,context:t,position:n="right",contextSize:o=250,gap:r=12,className:i,style:a}){const s="left"===n||"right"===n,l="left"===n||"top"===n,c=Object.assign({display:"flex",flexDirection:s?l?"row-reverse":"row":l?"column-reverse":"column",gap:r,width:"100%"},a),u=s?{flex:`0 0 ${o}px`,width:o,minHeight:0}:{flex:`0 0 ${o}px`,height:o,minWidth:0};return h.createElement("div",{className:"semiotic-context-layout"+(i?" "+i:""),style:c},h.createElement("div",{style:{flex:"1 1 0%",minWidth:0,minHeight:0}},e),h.createElement("div",{style:u},t))}Pr.displayName="ChartGrid",Cr.displayName="ContextLayout";function Nr({children:t,position:n="right",size:o=300,trigger:r="click",chartId:i,observation:a,dismissOnEmpty:s=!0,showClose:l=!0,onToggle:c,className:u,style:d}){const[g,p]=e.useState(null),[f,y]=e.useState(null),[m,v]=e.useState(!1),[b,x]=e.useState(!1),w=e.useRef(null),k=e.useRef(),A="click"===r?["click","click-end"]:["hover","hover-end"],{latest:E}=uo({types:A,chartId:i,limit:1}),S=void 0!==a?a:E;e.useEffect(()=>{if(S)if("click"===S.type||"hover"===S.type){const e=S;p(e.datum),y(e),m||(v(!0),x(!0),clearTimeout(k.current),k.current=setTimeout(()=>x(!1),200))}else!s||"click-end"!==S.type&&"hover-end"!==S.type||O()},[S]),e.useEffect(()=>{null==c||c(m)},[m,c]);const O=e.useCallback(()=>{x(!0),v(!1),clearTimeout(k.current),k.current=setTimeout(()=>{x(!1),p(null),y(null)},200)},[]);if(e.useEffect(()=>()=>clearTimeout(k.current),[]),!g&&!b)return null;const L=g&&f?t(g,f):null;if(null===L&&!b)return null;const M=function(e,t,n,o){const r={position:"absolute",background:"var(--semiotic-bg, #fff)",borderColor:"var(--semiotic-border, #e0e0e0)",borderStyle:"solid",borderWidth:0,boxSizing:"border-box",zIndex:10,display:"flex",flexDirection:"column",transition:o?"transform 200ms ease-out, opacity 200ms ease-out":void 0};return Object.assign(Object.assign({},r),"right"===e?{top:0,right:0,width:t,height:"100%",borderLeftWidth:1,padding:"12px 16px",transform:n?"translateX(0)":`translateX(${t}px)`,opacity:n?1:0}:"bottom"===e?{bottom:0,left:0,width:"100%",height:t,borderTopWidth:1,padding:"12px 16px",transform:n?"translateY(0)":`translateY(${t}px)`,opacity:n?1:0}:{top:"50%",left:"50%",transform:n?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0.95)",opacity:n?1:0,width:Math.min(t,400),maxHeight:"80%",borderWidth:1,borderRadius:8,padding:"16px 20px",boxShadow:"0 8px 32px rgba(0,0,0,0.12)"})}(n,o,m,b);return h.createElement("div",{ref:w,className:`semiotic-details-panel semiotic-details-${n}${u?" "+u:""}`,style:Object.assign(Object.assign({},M),d)},l&&h.createElement("button",{className:"semiotic-details-close",onClick:O,"aria-label":"Close details",style:Dr},h.createElement("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"},h.createElement("path",{d:"M2 2l8 8M10 2l-8 8"}))),h.createElement("div",{className:"semiotic-details-content",style:{overflow:"auto",flex:1}},L))}const Dr={position:"absolute",top:8,right:8,width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0,zIndex:1};Nr.displayName="DetailsPanel",exports.AreaChart=ao,exports.BarChart=Eo,exports.BoxPlot=Lo,exports.BubbleChart=co,exports.CategoryColorProvider=xn,exports.ChartContainer=Mr,exports.ChartErrorBoundary=Gn,exports.ChartGrid=Pr,exports.ChordDiagram=_o,exports.CirclePack=Yo,exports.ConnectedScatterplot=no,exports.ContextLayout=Cr,exports.DARK_THEME=Ko,exports.DetailsPanel=Nr,exports.DonutChart=Do,exports.DotPlot=Co,exports.ForceDirectedGraph=Bo,exports.GroupedBarChart=To,exports.Heatmap=lo,exports.Histogram=Mo,exports.IncrementalExtent=y,exports.LIGHT_THEME=Qo,exports.LineChart=io,exports.LinkedCharts=go,exports.MinimapChart=Ao,exports.MultiLineTooltip=function(e={}){const{fields:t=[],title:n,format:o,style:r={},className:i="",showLabels:a=!0,separator:s=": "}=e;return e=>{if(!e||"object"!=typeof e)return null;const l=[];if(n){const t=un(e,n);l.push({value:dn(t,o)})}t&&Array.isArray(t)&&t.length>0?t.forEach(t=>{let n,r,i;"string"==typeof t?(n=t,r=t,i=o):(n=t.label,r=t.accessor||t.key||"",i=t.format||o);const s=dn(un(e,r),i);l.push({label:a?n:void 0,value:s})}):Object.keys(e).filter(e=>!e.startsWith("_")&&"data"!==e).forEach(t=>{l.push({label:a?t:void 0,value:dn(e[t],o)})});const c=Object.assign(Object.assign({},cn),r);return Array.isArray(l)&&0!==l.length?h.createElement("div",{className:("semiotic-tooltip semiotic-tooltip-multiline "+i).trim(),style:c},l.map((e,t)=>h.createElement("div",{key:t,style:{marginBottom:l.length-1>t?"4px":0}},e.label&&h.createElement("strong",null,e.label,s),e.value))):null}},exports.PieChart=No,exports.RealtimeHeatmap=Zo,exports.RealtimeHistogram=qo,exports.RealtimeLineChart=Go,exports.RealtimeSwarmChart=Vo,exports.RealtimeTemporalHistogram=Xo,exports.RealtimeWaterfallChart=Uo,exports.RidgelinePlot=Po,exports.RingBuffer=f,exports.SankeyDiagram=zo,exports.Scatterplot=to,exports.ScatterplotMatrix=wo,exports.StackedAreaChart=so,exports.StackedBarChart=So,exports.StreamNetworkFrame=ln,exports.StreamOrdinalFrame=Pe,exports.StreamXYFrame=ue,exports.SwarmPlot=Oo,exports.ThemeProvider=function({theme:e,children:t}){return h.createElement(Jo,null,h.createElement(tr,{theme:e}),h.createElement(nr,null,t))},exports.Tooltip=hn,exports.TreeDiagram=Io,exports.Treemap=Fo,exports.ViolinPlot=jo,exports.configToJSX=mr,exports.copyConfig=yr,exports.deserializeSelections=function(e){const t=new Map;for(const[n,o]of Object.entries(e)){const e=new Map;for(const t of o.clauses){const n={};for(const[e,o]of Object.entries(t.fields))n[e]="point"===o.type?{type:"point",values:new Set(o.values)}:{type:"interval",range:o.range};e.set(t.clientId,{clientId:t.clientId,type:t.type,fields:n})}t.set(n,{name:o.name,resolution:o.resolution,clauses:e})}return t},exports.exportChart=rr,exports.fromConfig=function(e){if(!e.component||!e.props)throw Error("Invalid chart config: missing component or props");if(!hr[e.component])throw Error(`Unknown component "${e.component}". This config may require a newer version of semiotic.`);return{componentName:e.component,props:fr(e.props)}},exports.fromURL=function(e){const t=new URLSearchParams(e.includes("?")?e.split("?")[1]:e).get("sc");if(!t)throw Error("No chart config found in URL (missing 'sc' parameter)");const n=t.replace(/-/g,"+").replace(/_/g,"/"),o=decodeURIComponent(escape(atob(n)));return JSON.parse(o)},exports.fromVegaLite=function(e){var t,n,o,r,i,a,s,l,c,u,d,h,g,p;const f=[],{type:y,markProps:m}=function(e){if("string"==typeof e)return{type:e,markProps:{}};const{type:t}=e;return{type:t,markProps:function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&0>t.indexOf(o)&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);o.length>r;r++)0>t.indexOf(o[r])&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}(e,["type"])}}(e.mark),v=e.encoding||{},b=v.x,x=v.y,w=v.color,k=v.size,A=v.theta,E=v.opacity;let S;(null===(t=e.data)||void 0===t?void 0:t.values)?S=e.data.values:(null===(n=e.data)||void 0===n?void 0:n.url)&&f.push("data.url is not supported — only inline data.values can be translated. Provide data manually."),e.transform&&e.transform.length>0&&f.push("Vega-Lite transforms are not supported. Pre-transform your data before passing to fromVegaLite()."),e.layer&&f.push('Layered specs ("layer") are not supported. Only single-mark specs can be translated.'),(e.hconcat||e.vconcat||e.concat)&&f.push('Concatenated views ("hconcat"/"vconcat"/"concat") are not supported. Translate each sub-spec individually.'),(e.facet||e.encoding&&e.encoding.facet||e.encoding&&(e.encoding.row||e.encoding.column))&&f.push("Faceted views are not supported. Use Semiotic's LinkedCharts or render multiple charts manually."),e.repeat&&f.push('Repeated views ("repeat") are not supported. Translate each field combination individually.'),(e.params||e.selection)&&f.push("Selections/params are not supported. Use Semiotic's LinkedCharts and selection props for interactivity.");const O={};e.width&&(O.width=e.width),e.height&&(O.height=e.height);const L=function(e){if(e)return"string"==typeof e?e:e.text}(e.title);if(L&&(O.title=L),(null==w?void 0:w.field)&&(O.colorBy=w.field,null===(o=w.scale)||void 0===o?void 0:o.scheme)){const e=xr[w.scale.scheme];e&&(O.colorScheme=e)}void 0!==(null==E?void 0:E.value)&&(O.pointOpacity=E.value);const M=null==b?void 0:b.aggregate,j=null==x?void 0:x.aggregate;if(S&&(M||j)){const e=j?x:b,t=j?b:x,n=kr[e.aggregate];if(n&&(null==t?void 0:t.field)&&e.field)S=function(e,t){const{groupBy:n,value:o,agg:r="sum"}=t,i=new Map;for(const t of e){const e=t[n]+"";i.has(e)||i.set(e,[]),i.get(e).push(Number(t[o]))}const a=[];for(const[e,t]of i){let o;switch(r){case"count":o=t.length;break;case"mean":o=t.reduce((e,t)=>e+t,0)/t.length;break;case"min":o=Math.min(...t);break;case"max":o=Math.max(...t);break;default:o=t.reduce((e,t)=>e+t,0)}a.push({[n]:e,value:o})}return a}(S,{groupBy:t.field,value:e.field,agg:n});else if(("count"===n||"count"===e.aggregate)&&(null==t?void 0:t.field)&&S){const e=new Map;for(const n of S){const o=n[t.field]+"";e.set(o,(e.get(o)||0)+1)}S=Array.from(e,([e,n])=>({[t.field]:e,value:n}))}}if((null==b?void 0:b.bin)||(null==x?void 0:x.bin)){const e="Histogram";S&&(O.data=S),(null==b?void 0:b.bin)?(O.valueAccessor=b.field,(null==x?void 0:x.field)&&(O.categoryAccessor=x.field),(null===(r=b.axis)||void 0===r?void 0:r.title)&&(O.valueLabel=b.axis.title)):(null==x?void 0:x.bin)&&(O.valueAccessor=x.field,(null==b?void 0:b.field)&&(O.categoryAccessor=b.field),(null===(i=x.axis)||void 0===i?void 0:i.title)&&(O.valueLabel=x.axis.title));const t="object"==typeof((null==b?void 0:b.bin)||(null==x?void 0:x.bin))?(null===(a=null==b?void 0:b.bin)||void 0===a?void 0:a.maxbins)||(null===(s=null==x?void 0:x.bin)||void 0===s?void 0:s.maxbins):void 0;return t&&(O.bins=t),Er(e,O,f)}let P;switch(y){case"bar":P=function(e,t,n,o,r,i,a){var s,l,c,u,d,h;let g;return(null==n?void 0:n.field)&&!1!==(null==e?void 0:e.stack)&&!1!==(null==t?void 0:t.stack)&&null!==(null==e?void 0:e.stack)&&null!==(null==t?void 0:t.stack)?(g="StackedBarChart",o.stackBy=n.field):g="BarChart",vr(null==e?void 0:e.type)&&br(null==t?void 0:t.type)?(o.categoryAccessor=e.field,o.valueAccessor=a?"value":t.field,(null===(s=null==e?void 0:e.axis)||void 0===s?void 0:s.title)&&(o.categoryLabel=e.axis.title),(null===(l=null==t?void 0:t.axis)||void 0===l?void 0:l.title)&&(o.valueLabel=t.axis.title)):br(null==e?void 0:e.type)&&vr(null==t?void 0:t.type)?(o.categoryAccessor=t.field,o.valueAccessor=i?"value":e.field,o.orientation="horizontal",(null===(c=null==t?void 0:t.axis)||void 0===c?void 0:c.title)&&(o.categoryLabel=t.axis.title),(null===(u=null==e?void 0:e.axis)||void 0===u?void 0:u.title)&&(o.valueLabel=e.axis.title)):((null==e?void 0:e.field)&&(o.categoryAccessor=e.field),(null==t?void 0:t.field)&&(o.valueAccessor=a?"value":t.field),(null===(d=null==e?void 0:e.axis)||void 0===d?void 0:d.title)&&(o.categoryLabel=e.axis.title),(null===(h=null==t?void 0:t.axis)||void 0===h?void 0:h.title)&&(o.valueLabel=t.axis.title)),r&&(o.data=r),g}(b,x,w,O,S,M,j);break;case"line":if(P="LineChart",Ar(b,x,O,M,j),(null==w?void 0:w.field)&&(O.lineBy=w.field),m.interpolate){const e=wr[m.interpolate];e&&(O.curve=e)}!0===m.point&&(O.showPoints=!0),S&&(O.data=S);break;case"area":if((null==w?void 0:w.field)?(P="StackedAreaChart",O.areaBy=w.field):P="AreaChart",Ar(b,x,O,M,j),m.interpolate){const e=wr[m.interpolate];e&&(O.curve=e)}void 0!==m.opacity&&(O.areaOpacity=m.opacity),S&&(O.data=S);break;case"point":case"circle":case"square":(null==k?void 0:k.field)?(P="BubbleChart",O.sizeBy=k.field,(null===(l=k.scale)||void 0===l?void 0:l.range)&&(O.sizeRange=k.scale.range)):P="Scatterplot",Ar(b,x,O,M,j),S&&(O.data=S);break;case"rect":P="Heatmap",(null==b?void 0:b.field)&&(O.xAccessor=b.field),(null==x?void 0:x.field)&&(O.yAccessor=x.field),(null==w?void 0:w.field)&&(O.valueAccessor=w.field,delete O.colorBy),(null===(c=null==b?void 0:b.axis)||void 0===c?void 0:c.title)&&(O.xLabel=b.axis.title),(null===(u=null==x?void 0:x.axis)||void 0===u?void 0:u.title)&&(O.yLabel=x.axis.title),S&&(O.data=S);break;case"arc":m.innerRadius&&m.innerRadius>0?(P="DonutChart",O.innerRadius=m.innerRadius):P="PieChart",(null==A?void 0:A.field)?O.valueAccessor=A.field:(null==x?void 0:x.field)&&(O.valueAccessor=j?"value":x.field),(null==w?void 0:w.field)&&(O.categoryAccessor=w.field),(null==b?void 0:b.field)&&!(null==A?void 0:A.field)&&(O.categoryAccessor=b.field),S&&(O.data=S);break;case"tick":P="DotPlot",vr(null==b?void 0:b.type)?(O.categoryAccessor=b.field,(null==x?void 0:x.field)&&(O.valueAccessor=j?"value":x.field),(null===(d=null==b?void 0:b.axis)||void 0===d?void 0:d.title)&&(O.categoryLabel=b.axis.title),(null===(h=null==x?void 0:x.axis)||void 0===h?void 0:h.title)&&(O.valueLabel=x.axis.title)):vr(null==x?void 0:x.type)?(O.categoryAccessor=x.field,(null==b?void 0:b.field)&&(O.valueAccessor=M?"value":b.field),O.orientation="horizontal",(null===(g=null==x?void 0:x.axis)||void 0===g?void 0:g.title)&&(O.categoryLabel=x.axis.title),(null===(p=null==b?void 0:b.axis)||void 0===p?void 0:p.title)&&(O.valueLabel=b.axis.title)):((null==b?void 0:b.field)&&(O.categoryAccessor=b.field),(null==x?void 0:x.field)&&(O.valueAccessor=j?"value":x.field)),S&&(O.data=S);break;default:f.push(`Unsupported mark type "${y}". Defaulting to Scatterplot.`),P="Scatterplot",Ar(b,x,O,M,j),S&&(O.data=S)}return Er(P,O,f)},exports.normalizeTooltip=gn,exports.serializeSelections=function(e){const t={};for(const[n,o]of e){const e=[];for(const[,t]of o.clauses){const n={};for(const[e,o]of Object.entries(t.fields))n[e]="point"===o.type?{type:"point",values:Array.from(o.values)}:{type:"interval",range:o.range};e.push({clientId:t.clientId,type:t.type,fields:n})}t[n]={name:o.name,resolution:o.resolution,clauses:e}}return t},exports.smartTickFormat=function(e){if(null==e)return"";if("number"!=typeof e)return e+"";if(!isFinite(e))return e+"";if(0===e)return"0";const t=parseFloat(e.toPrecision(12)),n=Math.abs(t);return 1e9>n?1e6>n?1e4>n?Number.isInteger(t)?t+"":parseFloat(t.toPrecision(6))+"":parseFloat((t/1e3).toPrecision(3))+"K":parseFloat((t/1e6).toPrecision(3))+"M":parseFloat((t/1e9).toPrecision(3))+"B"},exports.toConfig=function(e,t,n){if(!hr[e])throw Error(`Unknown component "${e}". Known components: ${Object.keys(hr).join(", ")}`);const o=!1!==(null==n?void 0:n.includeData),r={};for(const[e,n]of Object.entries(t))null!=n&&(gr.has(e)||!o&&pr.has(e)||"function"!=typeof n&&((null==n?void 0:n.$$typeof)||(r[e]=fr(n))));return Object.assign({component:e,props:r,version:"1",createdAt:(new Date).toISOString()},(null==n?void 0:n.selections)?{selections:n.selections}:{})},exports.toURL=function(e){const t=JSON.stringify(e);return"sc="+btoa(unescape(encodeURIComponent(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},exports.useBrushSelection=Dn,exports.useCategoryColors=wn,exports.useChartObserver=uo,exports.useFilteredData=function(t,n,o){const r=Pn(e=>e.selections.get(n));return e.useMemo(()=>{if(!r||0===r.clauses.size)return t;const e=Ln(r,o);return t.filter(e)},[t,r,o])},exports.useLinkedHover=Nn,exports.useSelection=Cn,exports.useTheme=function(){return er(e=>e.theme)};
|
|
1
|
+
"use strict";const e=require("react"),t=require("d3-brush"),n=require("d3-selection"),o=require("d3-scale"),r=require("d3-array"),i=require("d3-hierarchy"),a=require("regression"),s=require("d3-shape"),l=require("d3-interpolate"),c=require("d3-scale-chromatic"),u=require("d3-force"),d=require("d3-chord");function h(e){return e&&e.__esModule?e:{default:e}}function g(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}return t.default=e,Object.freeze(t)}const f=g(e),y=h(a),p=5e3;class m{constructor(e){this.lastBoundedData=null,this.chunkTimer=0,this.callback=e}clearLastData(){this.lastBoundedData=null,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),5e3>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,p),bounded:!0,totalSize:e.length});let t=p;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const o=Math.min(t+p,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}push(e){this.callback({inserts:[e],bounded:!1})}pushMany(e){0!==e.length&&this.callback({inserts:e,bounded:!1})}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null}}class v{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+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 e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}toArray(){const e=[];for(const t of this)e.push(t);return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class b{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function x(e,t,n,o,r){const i=new Map;for(const a of e){const e=t(a),s=n(a);if(null==e||null==s||Number.isNaN(e)||Number.isNaN(s))continue;const l=Math.floor(e/o)*o;let c=i.get(l);if(c||(c={start:l,end:l+o,total:0,categories:new Map},i.set(l,c)),c.total+=s,r){const e=r(a);c.categories.set(e,(c.categories.get(e)||0)+s)}}return i}function k(e,t,n,o,r,i){const a=[];for(const r of e){const e=n(r),i=o(r);null==e||null==i||Number.isNaN(e)||Number.isNaN(i)||a.push({px:t.x(e),py:t.y(i),rawY:i,d:r})}a.sort((e,t)=>e.px-t.px);const s=Array(a.length),l=Array(a.length),c=Array(a.length);for(let e=0;a.length>e;e++){const t=a[e];s[e]=[t.px,t.py],l[e]=t.rawY,c[e]=t.d}return{type:"line",path:s,rawValues:l,style:r,datum:c,group:i}}function w(e,t,n,o,r,i,a,s){const l=[];for(const i of e){const e=n(i),a=o(i);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const c=t.x(e),u=s?s(i):r;l.push({px:c,topY:t.y(a),botY:t.y(u)})}l.sort((e,t)=>e.px-t.px);const c=Array(l.length),u=Array(l.length);for(let e=0;l.length>e;e++){const t=l[e];c[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:c,bottomPath:u,style:i,datum:e,group:a}}function A(e,t,n,o,r,i,a){const s=n(e),l=o(e);if(null==s||null==l||Number.isNaN(s)||Number.isNaN(l))return null;const c={type:"point",x:t.x(s),y:t.y(l),r:r,style:i,datum:e};return void 0!==a&&(c.pointId=a),c}function E(e,t,n,o,r,i,a){return{type:"rect",x:e,y:t,w:n,h:o,style:r,datum:i,group:a}}function S(e,t,n,o,r,i){return{type:"heatcell",x:e,y:t,w:n,h:o,fill:r,datum:i}}function L(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function O(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}class M{constructor(e){this.xExtent=new b,this.yExtent=new b,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=e,this.buffer=new v(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=L(e.timeAccessor||e.xAccessor,"time"),this.getY=L(e.valueAccessor||e.yAccessor,"value")):(this.getX=L(e.xAccessor,"x"),this.getY=L(e.yAccessor,"y")),this.getGroup=O(e.groupAccessor),this.getCategory=O(e.categoryAccessor),this.getSize=e.sizeAccessor?L(e.sizeAccessor,"size"):void 0,this.getColor=O(e.colorAccessor),this.getBounds=e.boundsAccessor?L(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?L(e.y0Accessor,"y0"):void 0,this.getPointId=O(e.pointIdAccessor),"candlestick"===e.chartType&&(this.getOpen=L(e.openAccessor,"open"),this.getHigh=L(e.highAccessor,"high"),this.getLow=L(e.lowAccessor,"low"),this.getClose=L(e.closeAccessor,"close")),e.pulse&&(this.timestampBuffer=new v(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,this.needsFullRebuild=!0,e.bounded){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n)))}else for(const n of e.inserts){"growing"===this.config.windowMode&&this.buffer.full&&(this.growingCap*=2,this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap));const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n))),null!=e&&(this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):this.yExtent.evict(this.getY(e)))}return!0}computeScene(e){var t,n,r,i,a,s;const{config:l,buffer:c}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);if(this.xExtent.dirty&&this.xExtent.recalculate(c,this.getX),this.yExtent.dirty)if("candlestick"===l.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of c)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(c,this.getY);const u=this.xExtent.extent,d=this.yExtent.extent;let h=l.xExtent?[null!==(t=l.xExtent[0])&&void 0!==t?t:u[0],null!==(n=l.xExtent[1])&&void 0!==n?n:u[1]]:u,g=l.yExtent?[null!==(r=l.yExtent[0])&&void 0!==r?r:d[0],null!==(i=l.yExtent[1])&&void 0!==i?i:d[1]]:d;const f=l.yExtent&&null!=l.yExtent[0]&&null!=l.yExtent[1];if("stackedarea"===l.chartType&&!f&&c.size>0)if(l.normalize)g=[0,1+l.extentPadding];else{const e=c.toArray(),t=this.groupData(e),n=new Map;for(const e of t)for(const t of e.data){const e=this.getX(t),o=this.getY(t);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||n.set(e,(n.get(e)||0)+o)}let o=0;for(const e of n.values())e>o&&(o=e);g=[0,o+(o>0?o*l.extentPadding:1)]}else if("bar"===l.chartType&&l.binSize&&!f&&c.size>0){const[,e]=function(e,t,n,o,r){const i=x(e,t,n,o,r);if(0===i.size)return[0,0];let a=0;for(const e of i.values())e.total>a&&(a=e.total);return[0,a]}(c,this.getX,this.getY,l.binSize,this.getCategory);g=[0,e+e*l.extentPadding]}else if("waterfall"===l.chartType&&!f&&c.size>0){const[e,t]=function(e,t){let n=0,o=0,r=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(r+=e,n>r&&(n=r),r>o&&(o=r))}return[n,o]}(c,this.getY),n=t-e,o=n>0?n*l.extentPadding:1;g=[Math.min(0,e-Math.abs(o)),Math.max(0,t+Math.abs(o))]}else if(!f&&g[0]!==1/0){if(this.getBounds){const e=c.toArray();for(const t of e){const e=this.getY(t),n=this.getBounds(t);null!=e&&!Number.isNaN(e)&&n&&(e+n>g[1]&&(g[1]=e+n),g[0]>e-n&&(g[0]=e-n))}}const e=g[1]-g[0],t=e>0?e*l.extentPadding:1,n=null===(a=l.yExtent)||void 0===a?void 0:a[0],o=null===(s=l.yExtent)||void 0===s?void 0:s[1];g=[null!=n?g[0]:g[0]-t,null!=o?g[1]:g[1]+t]}if(h[0]!==1/0&&h[1]!==-1/0||(h=[0,1]),g[0]!==1/0&&g[1]!==-1/0||(g=[0,1]),void 0!==l.arrowOfTime)if("x"==("up"===(y=l.arrowOfTime)||"down"===y?"y":"x")){const t="right"===l.arrowOfTime?[0,e.width]:[e.width,0];this.scales={x:o.scaleLinear().domain(h).range(t),y:o.scaleLinear().domain(g).range([e.height,0])}}else{const t="down"===l.arrowOfTime?[0,e.height]:[e.height,0];this.scales={x:o.scaleLinear().domain(g).range([0,e.width]),y:o.scaleLinear().domain(h).range(t)}}else this.scales={x:o.scaleLinear().domain(h).range([0,e.width]),y:o.scaleLinear().domain(g).range([e.height,0])};var y;this.config.transition&&this.scene.length>0&&this.snapshotPositions();const p=c.toArray();this.scene=this.buildSceneNodes(e),this.config.decay&&this.applyDecay(this.scene,p),this.config.pulse&&this.applyPulse(this.scene,p),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}remapScene(e){const t=e.width/this.lastLayout.width,n=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const o of e.path)o[0]*=t,o[1]*=n;break;case"area":for(const o of e.topPath)o[0]*=t,o[1]*=n;for(const o of e.bottomPath)o[0]*=t,o[1]*=n;break;case"point":e.x*=t,e.y*=n;break;case"rect":case"heatcell":e.x*=t,e.y*=n,e.w*=t,e.h*=n;break;case"candlestick":e.x*=t,e.openY*=n,e.closeY*=n,e.highY*=n,e.lowY*=n}const r=this.scales.x.domain(),i=this.scales.y.domain(),a=this.scales.x.range(),s=this.scales.y.range();this.scales={x:o.scaleLinear().domain(r).range([a[0]*t,a[1]*t]),y:o.scaleLinear().domain(i).range([s[0]*n,s[1]*n])},this.lastLayout={width:e.width,height:e.height},this.version++}buildSceneNodes(e){const{config:t,buffer:n,scales:o}=this;if(!o||0===n.size)return[];const r=n.toArray();switch(t.chartType){case"line":return this.buildLineScene(r);case"area":return this.buildAreaScene(r);case"stackedarea":return this.buildStackedAreaScene(r);case"scatter":case"bubble":return this.buildPointScene(r);case"heatmap":return this.buildHeatmapScene(r,e);case"bar":return this.buildBarScene(r);case"swarm":return this.buildSwarmScene(r);case"waterfall":return this.buildWaterfallScene(r,e);case"candlestick":return this.buildCandlestickScene(r,e);default:return[]}}buildLineScene(e){var t;const n=this.groupData(e),o=[],r=null===(t=this.config.annotations)||void 0===t?void 0:t.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(this.getBounds)for(const e of n){const t=this.buildBoundsForGroup(e.data,e.key);t&&o.push(t)}for(const e of n){const t=this.resolveLineStyle(e.key,e.data[0]),n=k(e.data,this.scales,this.getX,this.getY,t,e.key);r&&r.length>0&&(n.colorThresholds=r),o.push(n)}return o}buildAreaScene(e){const t=this.groupData(e),n=[],o=this.scales.y.domain()[0];for(const e of t){const t=this.resolveAreaStyle(e.key,e.data[0]),r=w(e.data,this.scales,this.getX,this.getY,o,t,e.key,this.getY0);this.config.gradientFill&&(r.fillGradient=this.config.gradientFill),n.push(r)}return n}buildStackedAreaScene(e){const t=this.groupData(e);return t.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0),function(e,t,n,o,r,i){var a;const s=new Set;for(const t of e)for(const e of t.data){const t=n(e);null==t||Number.isNaN(t)||s.add(t)}const l=Array.from(s).sort((e,t)=>e-t),c=new Map;for(const t of e){const e=new Map;for(const r of t.data){const t=n(r),i=o(r);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||e.set(t,(e.get(t)||0)+i)}c.set(t.key,e)}let u;if(i){u=new Map;for(const t of l){let n=0;for(const o of e)n+=(null===(a=c.get(o.key))||void 0===a?void 0:a.get(t))||0;u.set(t,n||1)}}const d=[],h=new Map;for(const e of l)h.set(e,0);for(const n of e){const e=c.get(n.key),o=[],a=[];for(const n of l){let r=e.get(n)||0;const s=h.get(n);i&&(r/=u.get(n));const l=t.x(n);a.push([l,t.y(s)]),o.push([l,t.y(s+r)]),h.set(n,s+r)}d.push({type:"area",topPath:o,bottomPath:a,style:r(n.key,n.data[0]),datum:n.data,group:n.key})}return d}(t,this.scales,this.getX,this.getY,(e,t)=>this.resolveAreaStyle(e,t),this.config.normalize)}buildPointScene(e){const t=[],n="bubble"===this.config.chartType?10:5,o=this.config.sizeRange||[3,15];let r=null;if(this.getSize&&!this.config.pointStyle){const t=e.map(e=>this.getSize(e)).filter(e=>null!=e&&!Number.isNaN(e));if(t.length>0){const e=Math.min(...t),n=Math.max(...t);r=t=>e===n?(o[0]+o[1])/2:o[0]+(t-e)/(n-e)*(o[1]-o[0])}}let i=null;if(this.getColor&&!this.config.pointStyle){const t=new Set;for(const n of e){const e=this.getColor(n);e&&t.add(e)}const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];i=new Map;let o=0;for(const e of t)i.set(e,n[o%n.length]),o++}for(const o of e){let e=this.config.pointStyle?this.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},a=e.r||n;if(r&&this.getSize){const e=this.getSize(o);null==e||Number.isNaN(e)||(a=r(e))}if(i&&this.getColor){const t=this.getColor(o);t&&i.has(t)&&(e=Object.assign(Object.assign({},e),{fill:i.get(t)}))}const s=this.getPointId?this.getPointId(o)+"":void 0,l=A(o,this.scales,this.getX,this.getY,a,e,s);l&&t.push(l)}return t}buildHeatmapScene(e,t){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(e,t);const o=L(this.config.valueAccessor,"value"),r=new Set,i=new Set;for(const t of e)r.add(this.getX(t)),i.add(this.getY(t));const a=Array.from(r).sort((e,t)=>e-t),s=Array.from(i).sort((e,t)=>e-t);if(0===a.length||0===s.length)return n;const l=t.width/a.length,c=t.height/s.length,u=new Map;for(const t of e){const e=`${this.getX(t)}_${this.getY(t)}`;u.set(e,{val:o(t),datum:t})}let d=1/0,h=-1/0;for(const{val:e}of u.values())d>e&&(d=e),e>h&&(h=e);const g=h-d||1;for(let e=0;a.length>e;e++)for(let t=0;s.length>t;t++){const o=u.get(`${a[e]}_${s[t]}`);if(!o)continue;const r=(o.val-d)/g;n.push(S(e*l,(s.length-1-t)*c,l,c,`rgb(${Math.round(220-180*r)},${Math.round(220-100*r)},${Math.round(255-50*r)})`,o.datum))}return n}buildStreamingHeatmapScene(e,t){var n,o,r;const i=[],a=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,s=null!==(o=this.config.heatmapYBins)&&void 0!==o?o:20,l=null!==(r=this.config.heatmapAggregation)&&void 0!==r?r:"count",c=L(this.config.valueAccessor,"value");if(!this.scales||0===e.length)return i;const[u,d]=this.scales.x.domain(),[h,g]=this.scales.y.domain(),f=(d-u||1)/a,y=(g-h||1)/s,p=new Map;for(const t of e){const e=this.getX(t),n=this.getY(t),o=Math.min(Math.floor((e-u)/f),a-1),r=Math.min(Math.floor((n-h)/y),s-1);if(0>o||0>r)continue;const i=`${o}_${r}`;let l=p.get(i);l||(l={sum:0,count:0,data:[]},p.set(i,l)),l.count++,l.sum+=c(t),l.data.push(t)}let m=1/0,v=-1/0;const b=new Map;for(const[e,t]of p){let n;switch(l){case"sum":n=t.sum;break;case"mean":n=t.count>0?t.sum/t.count:0;break;default:n=t.count}b.set(e,n),m>n&&(m=n),n>v&&(v=n)}const x=v-m||1,k=t.width/a,w=t.height/s;for(const[e,t]of b){const[n,o]=e.split("_"),r=+n,a=+o,l=(t-m)/x,c=`rgb(${Math.round(220-180*l)},${Math.round(220-100*l)},${Math.round(255-50*l)})`,u=p.get(e);i.push(S(r*k,(s-1-a)*w,k,w,c,{xi:r,yi:a,value:t,count:u.count,sum:u.sum,data:u.data}))}return i}buildBarScene(e){var t;if(!this.config.binSize)return[];const n=x(e,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===n.size)return[];let o=null;if(this.getCategory){const e=new Set;for(const t of n.values())for(const n of t.categories.keys())e.add(n);const t=this.config.barColors?Object.keys(this.config.barColors):[],r=new Set(t),i=Array.from(e).filter(e=>!r.has(e)).sort();o=[...t.filter(t=>e.has(t)),...i]}const r=[],i=this.scales,[a,s]=i.x.domain();for(const e of n.values()){const n=Math.max(e.start,a),l=Math.min(e.end,s);if(n>=l)continue;const c=i.x(n),u=i.x(l),d=Math.min(c,u)+.5,h=Math.max(c,u)-.5-d;if(h>0)if(o&&e.categories.size>0){let n=0;for(const a of o){const o=e.categories.get(a)||0;if(0===o)continue;const s=i.y(n),l=i.y(n+o);r.push(E(d,Math.min(s,l),h,Math.abs(s-l),{fill:(null===(t=this.config.barColors)||void 0===t?void 0:t[a])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:a,categoryValue:o},a)),n+=o}}else{const t=i.y(0),n=i.y(e.total);r.push(E(d,Math.min(t,n),h,Math.abs(t-n),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}return r}buildSwarmScene(e){var t,n,o,r;const i=[],a=this.config.swarmStyle||{},s=null!==(t=a.radius)&&void 0!==t?t:3,l=null!==(n=a.fill)&&void 0!==n?n:"#007bff",c=null!==(o=a.opacity)&&void 0!==o?o:.7,u=a.stroke,d=a.strokeWidth;for(const t of e){const e=this.getX(t),n=this.getY(t);if(null==n||Number.isNaN(n))continue;const o=this.scales.x(e),a=this.scales.y(n);let h=l;if(this.getCategory){const e=this.getCategory(t);h=(null===(r=this.config.barColors)||void 0===r?void 0:r[e])||h}const g={type:"point",x:o,y:a,r:s,style:{fill:h,opacity:c,stroke:u,strokeWidth:d},datum:t};this.getPointId&&(g.pointId=this.getPointId(t)+""),i.push(g)}return i}buildWaterfallScene(e,t){var n,o,r;const i=[],a=this.scales,s=this.config.waterfallStyle,l=e.filter(e=>{const t=this.getY(e);return null!=t&&!Number.isNaN(t)});if(0===l.length)return i;const c=null!==(n=null==s?void 0:s.positiveColor)&&void 0!==n?n:"#28a745",u=null!==(o=null==s?void 0:s.negativeColor)&&void 0!==o?o:"#dc3545",d=null!==(r=null==s?void 0:s.gap)&&void 0!==r?r:1,h=null==s?void 0:s.stroke,g=null==s?void 0:s.strokeWidth;let f=0;for(let e=0;l.length>e;e++){const n=l[e],o=this.getX(n),r=this.getY(n),y=f+r;let p;p=l.length-1>e?this.getX(l[e+1])-o:e>0?o-this.getX(l[e-1]):0;const m=a.x(o),v=0!==p?a.x(o+p):m+t.width/10,b=Math.min(m,v)+d/2,x=Math.max(m,v)-d/2-b;if(0>=x){f=y;continue}const k=a.y(f),w=a.y(y);i.push(E(b,Math.min(k,w),x,Math.abs(k-w),{fill:0>r?u:c,stroke:h,strokeWidth:g},Object.assign(Object.assign({},n),{baseline:f,cumEnd:y,delta:r,_connectorStroke:null==s?void 0:s.connectorStroke,_connectorWidth:null==s?void 0:s.connectorWidth}))),f=y}return i}buildCandlestickScene(e,t){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],o=this.config.candlestickStyle||{},r=o.upColor||"#28a745",i=o.downColor||"#dc3545",a=o.wickColor||"#333",s=o.wickWidth||1,l=e.map(e=>this.getX(e)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let c=o.bodyWidth||6;if(!o.bodyWidth&&l.length>1){let e=1/0;for(let t=1;l.length>t;t++){const n=Math.abs(this.scales.x(l[t])-this.scales.x(l[t-1]));n>0&&e>n&&(e=n)}e!==1/0&&(c=Math.max(2,Math.min(.6*e,20)))}for(const t of e){const e=this.getX(t);if(null==e||Number.isNaN(e))continue;const o=this.getOpen(t),l=this.getHigh(t),u=this.getLow(t),d=this.getClose(t);if([o,l,u,d].some(e=>null==e||Number.isNaN(e)))continue;const h=d>=o;n.push({type:"candlestick",x:this.scales.x(e),openY:this.scales.y(o),closeY:this.scales.y(d),highY:this.scales.y(l),lowY:this.scales.y(u),bodyWidth:c,upColor:r,downColor:i,wickColor:a,wickWidth:s,isUp:h,datum:t})}return n}buildBoundsForGroup(e,t){if(!this.getBounds||!this.scales)return null;const n=[],o=[];for(const t of e){const e=this.getX(t),r=this.getY(t);if(null==e||null==r||Number.isNaN(e)||Number.isNaN(r))continue;const i=this.getBounds(t),a=this.scales.x(e);if(i&&0!==i)n.push([a,this.scales.y(r+i)]),o.push([a,this.scales.y(r-i)]);else{const e=this.scales.y(r);n.push([a,e]),o.push([a,e])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:o,style:this.resolveBoundsStyle(t,e[0]),datum:e,group:t,interactive:!1}}resolveBoundsStyle(e,t){const n=this.config.boundsStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(e,t).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){var n,o,r;const i=this.config.decay;if(!i||1>=t)return 1;const a=null!==(n=i.minOpacity)&&void 0!==n?n:.1,s=t-1-e;switch(i.type){case"linear":return a+(1-s/(t-1))*(1-a);case"exponential":{const e=null!==(o=i.halfLife)&&void 0!==o?o:t/2;return a+Math.pow(.5,s/e)*(1-a)}case"step":return(null!==(r=i.stepThreshold)&&void 0!==r?r:.5*t)>s?1:a;default:return 1}}applyDecay(e,t){var n,o;if(!this.config.decay)return;const r=t.length;if(1>=r)return;const i=new Map;for(let e=0;t.length>e;e++)i.set(t[e],e);for(const t of e){if("line"===t.type||"area"===t.type)continue;const e=i.get(t.datum);if(null==e)continue;const a=this.computeDecayOpacity(e,r);if("heatcell"===t.type)t.style={opacity:a};else if("candlestick"===t.type)t._decayOpacity=a;else{const e=null!==(o=null===(n=t.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:e*a})}}}computePulseIntensity(e,t){var n;const o=this.config.pulse;if(!o)return 0;const r=null!==(n=o.duration)&&void 0!==n?n:500,i=t-e;return r>i?1-i/r:0}applyPulse(e,t){var n,o;if(!this.config.pulse||!this.timestampBuffer)return;const r="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",a=null!==(o=this.config.pulse.glowRadius)&&void 0!==o?o:4,s=new Map;for(let e=0;t.length>e;e++)s.set(t[e],e);for(const t of e){if("line"===t.type)continue;if("area"===t.type){const e=Array.isArray(t.datum)?t.datum:[t.datum];let n=0;for(const t of e){const e=s.get(t);if(null==e)continue;const o=this.timestampBuffer.get(e);if(null==o)continue;const i=this.computePulseIntensity(o,r);i>n&&(n=i)}n>0&&(t._pulseIntensity=n,t._pulseColor=i);continue}const e=s.get(t.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const o=this.computePulseIntensity(n,r);o>0&&(t._pulseIntensity=o,t._pulseColor=i,t._pulseGlowRadius=a)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}snapshotPositions(){this.prevPositionMap.clear();for(let e=0;this.scene.length>e;e++){const t=this.scene[e],n=this.getNodeIdentity(t,e);n&&("point"===t.type?this.prevPositionMap.set(n,{x:t.x,y:t.y,r:t.r}):"rect"===t.type||"heatcell"===t.type?this.prevPositionMap.set(n,{x:t.x,y:t.y,w:t.w,h:t.h}):"candlestick"===t.type&&this.prevPositionMap.set(n,{x:t.x,y:t.openY}))}}getNodeIdentity(e,t){var n,o,r,i;switch(e.type){case"point":return`p:${void 0===e.datum?t:this.getX(e.datum)}_${this.getY(e.datum)}`;case"rect":return`r:${e.group||""}:${null!==(i=null!==(o=null===(n=e.datum)||void 0===n?void 0:n.binStart)&&void 0!==o?o:null===(r=e.datum)||void 0===r?void 0:r.category)&&void 0!==i?i:t}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return"c:"+this.getX(e.datum);default:return null}}startTransition(){var e,t,n,o,r,i;if(!this.config.transition||0===this.prevPositionMap.size)return;const a=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;let s=!1;for(let e=0;this.scene.length>e;e++){const a=this.scene[e],l=this.getNodeIdentity(a,e);if(!l)continue;const c=this.prevPositionMap.get(l);if(c)if("point"===a.type){const e={x:a.x,y:a.y,r:a.r};c.x===e.x&&c.y===e.y||(a._targetX=e.x,a._targetY=e.y,a._targetR=e.r,a.x=c.x,a.y=c.y,a.r=null!==(t=c.r)&&void 0!==t?t:a.r,s=!0)}else if("rect"===a.type){const e={x:a.x,y:a.y,w:a.w,h:a.h};c.x===e.x&&c.y===e.y&&c.w===e.w&&c.h===e.h||(a._targetX=e.x,a._targetY=e.y,a._targetW=e.w,a._targetH=e.h,a.x=c.x,a.y=c.y,a.w=null!==(n=c.w)&&void 0!==n?n:a.w,a.h=null!==(o=c.h)&&void 0!==o?o:a.h,s=!0)}else if("heatcell"===a.type){const e={x:a.x,y:a.y,w:a.w,h:a.h};c.x===e.x&&c.y===e.y||(a._targetX=e.x,a._targetY=e.y,a._targetW=e.w,a._targetH=e.h,a.x=c.x,a.y=c.y,a.w=null!==(r=c.w)&&void 0!==r?r:a.w,a.h=null!==(i=c.h)&&void 0!==i?i:a.h,s=!0)}}s&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:a})}advanceTransition(e){var t;if(!this.activeTransition)return!1;const n=Math.min((e-this.activeTransition.startTime)/this.activeTransition.duration,1),o="linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?n:1-Math.pow(1-n,3);for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==e._targetR&&void 0!==n.r&&(e.r=n.r+(e._targetR-n.r)*o)}else if("rect"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==n.w&&(e.w=n.w+(e._targetW-n.w)*o),void 0!==n.h&&(e.h=n.h+(e._targetH-n.h)*o)}else if("heatcell"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==n.w&&(e.w=n.w+(e._targetW-n.w)*o),void 0!==n.h&&(e.h=n.h+(e._targetH-n.h)*o)}if(n>=1){for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}return this.activeTransition=null,!1}return!0}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const n of e){const e=this.getGroup(n);t.has(e)||t.set(e,[]),t.get(e).push(n)}return Array.from(t.entries()).map(([e,t])=>({key:e,data:t}))}resolveLineStyle(e,t){const n=this.config.lineStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?{stroke:n.stroke||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var n;if(this.config.areaStyle)return this.config.areaStyle(t||{});const o=this.config.lineStyle;return"function"==typeof o?o(t||{},e):o&&"object"==typeof o?{fill:o.fill||o.stroke||"#4e79a7",fillOpacity:null!==(n=o.fillOpacity)&&void 0!==n?n:.7,stroke:o.stroke||"#4e79a7",strokeWidth:o.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(e){Object.assign(this.config,e),this.needsFullRebuild=!0}}function C(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function j(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function P(e,t,n){const o=t-e.x,r=n-e.y,i=Math.sqrt(o*o+r*r);return i>e.r+5?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:i}}function H(e,t,n){if(0===e.path.length)return null;const o=T(e.path,t);if(0>o)return null;const[r,i]=e.path[o],a=t-r,s=n-i,l=Math.sqrt(a*a+s*s);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:r,y:i,distance:l}}function N(e,t,n){const o=C(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function B(e,t,n){const o=C(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function D(e,t,n){const o=e.bodyWidth/2,r=Math.min(e.openY,e.closeY);if(!(e.x-o-3>t||t>e.x+o+3||e.highY-3>n||n>e.lowY+3)){const o=r+Math.max(Math.max(e.openY,e.closeY)-r,1)/2,i=t-e.x,a=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(i*i+a*a)}}return null}function W(e,t,n){if(0===e.topPath.length)return null;const o=T(e.topPath,t);if(0>o)return null;const[r,i]=e.topPath[o],a=t-r,s=n-i;return{node:e,datum:e.datum,x:r,y:i,distance:Math.sqrt(a*a+s*s)}}function T(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const r=n+o>>1;t>e[r][0]?n=r+1:o=r}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}function I(e,t,n){switch(e){case"ArrowRight":case"ArrowDown":return n-1>t?t+1:t;case"ArrowLeft":case"ArrowUp":return t>0?t-1:t;case"Home":return 0;case"End":return n-1;case"Escape":return-1;default:return null}}function R(e){return{data:e.datum,x:e.x,y:e.y,time:e.x,value:e.y}}function $(t,n,o){const r=e.useRef(null),[i,a]=e.useState(null);return e.useEffect(()=>{if(!n&&!o)return;const e=r.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;a(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[n,o]),[r,[n&&i?i.w:t[0],o&&i?i.h:t[1]]]}function z(t,n,o,r,i,a){e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{var e;const s=n.current;if(!s||0===s.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(e=t.threshold)&&void 0!==e?e:5e3,u=l-s.lastIngestTime>c;u!==i&&(a(u),o.current=!0,r())},1e3);return()=>clearInterval(e)},[t,i,r])}const _={fill:e=>f.createElement("rect",{style:e,width:20,height:20}),line:e=>f.createElement("line",{style:e,x1:0,y1:0,x2:20,y2:20})};function F(e,t,n,o){let r;return r="function"==typeof n?n(e):(0,_[n])(o(e,t)),r}function Y(){return f.createElement("path",{d:"M2,6 L5,9 L10,3",fill:"none",stroke:"currentColor",strokeWidth:1.5,transform:"translate(-14, 5)"})}function G(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function q(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,title:a="Legend",width:s=100,height:l=20,orientation:c="vertical"}=e,u="vertical"===c?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i})=>{let a=30;const s=[];return e.forEach((e,l)=>{a+=5,s.push(f.createElement("line",{key:"legend-top-line legend-symbol-"+l,stroke:"gray",x1:0,y1:a,x2:t,y2:a})),a+=10,e.label&&(a+=20,s.push(f.createElement("text",{key:"legend-text-"+l,y:a,className:"legend-group-label"},e.label)),a+=10),s.push(f.createElement("g",{key:"legend-group-"+l,className:"legend-item",transform:`translate(0,${a})`},((e,t,n,o,r)=>{const{type:i="fill",styleFn:a,items:s}=e,l=[];let c=0;const u=!(!t&&!n);return s.forEach((e,s)=>{const d=F(e,s,i,a),h=G(e,o,r),g=r&&r.size>0&&r.has(e.label);l.push(f.createElement("g",{key:"legend-item-"+s,transform:`translate(0,${c})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,style:{cursor:u?"pointer":"default",opacity:h,transition:"opacity 150ms ease",pointerEvents:"all"}},g&&f.createElement(Y,null),d,f.createElement("text",{y:15,x:30},e.label))),c+=25}),l})(e,n,o,r,i))),a+=25*e.items.length+10}),s})({legendGroups:t,width:s,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i}):(({legendGroups:e,title:t,height:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:a})=>{let s=0;const l=[],c=!1===t?10:40;return e.forEach((t,u)=>{t.label&&(l.push(f.createElement("text",{key:"legend-text-"+u,transform:`translate(${s},${c}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},t.label)),s+=20);const d=((e,t,n,o,r)=>{const{type:i="fill",styleFn:a,items:s}=e,l=[];let c=0;const u=!(!t&&!n);return s.forEach((e,s)=>{const d=F(e,s,i,a),h=G(e,o,r),g=r&&r.size>0&&r.has(e.label);l.push(f.createElement("g",{key:"legend-item-"+s,transform:`translate(${c},0)`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,style:{cursor:u?"pointer":"default",opacity:h,transition:"opacity 150ms ease",pointerEvents:"all"}},g&&f.createElement(Y,null),d,f.createElement("text",{y:15,x:25},e.label))),c+=35,c+=8*e.label.length}),{items:l,offset:c}})(t,o,r,i,a);l.push(f.createElement("g",{key:"legend-group-"+u,className:"legend-item",transform:`translate(${s},${c})`},d.items)),s+=d.offset+5,e[u+1]&&l.push(f.createElement("line",{key:"legend-top-line legend-symbol-"+u,stroke:"gray",x1:s,y1:c-10,x2:s,y2:n+c+10})),s+=15}),f.createElement("g",null,!1!==t&&f.createElement("line",{x1:0,x2:s+10,y1:c-10,y2:c-10,stroke:"gray",className:"title-neatline"}),l)})({legendGroups:t,title:a,height:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i});return f.createElement("g",null,void 0!==a&&f.createElement("text",{className:"legend-title",y:20,x:"horizontal"===c?0:s/2,textAnchor:"horizontal"===c?"start":"middle"},a),u)}function X(e){return"string"==typeof e?{type:e}:e}function V({orient:t,config:n,values:o,scale:i,size:a,length:s}){const l=function(e){var t,n,o,r,i;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(n=e.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(o=e.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(r=e.stroke)&&void 0!==r?r:"none",strokeWidth:null!==(i=e.strokeWidth)&&void 0!==i?i:1}}(n),c="top"===t||"bottom"===t,u=e.useMemo(()=>{if(0===o.length)return null;const e=i.domain(),n=a-8;if("boxplot"===l.type){const e=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],r=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],a=i-o;return{q1:o,median:r,q3:i,whiskerLow:Math.max(t[0],o-1.5*a),whiskerHigh:Math.min(t[n-1],i+1.5*a)}}(o);if(!e)return null;const{q1:r,median:a,q3:s,whiskerLow:u,whiskerHigh:d}=e,h=Math.min(.5*n,20),g=(n-h)/2+4;if(c){const e=i(r),n=i(s),o=i(a),c=i(u),y=i(d),p="top"===t?-1:1,m=0;return f.createElement("g",{"data-testid":"marginal-boxplot-"+t},f.createElement("line",{x1:c,y1:m+p*(g+h/2),x2:y,y2:m+p*(g+h/2),stroke:l.fill,strokeWidth:l.strokeWidth}),f.createElement("line",{x1:c,y1:m+p*g,x2:c,y2:m+p*(g+h),stroke:l.fill,strokeWidth:l.strokeWidth}),f.createElement("line",{x1:y,y1:m+p*g,x2:y,y2:m+p*(g+h),stroke:l.fill,strokeWidth:l.strokeWidth}),f.createElement("rect",{x:Math.min(e,n),y:"top"===t?m-g-h:m+g,width:Math.abs(n-e),height:h,fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),f.createElement("line",{x1:o,y1:"top"===t?m-g-h:m+g,x2:o,y2:"top"===t?m-g:m+g+h,stroke:l.fill,strokeWidth:2}))}{const e=i(r),n=i(s),o=i(a),c=i(u),y=i(d),p="left"===t?-1:1,m=0;return f.createElement("g",{"data-testid":"marginal-boxplot-"+t},f.createElement("line",{x1:m+p*(g+h/2),y1:c,x2:m+p*(g+h/2),y2:y,stroke:l.fill,strokeWidth:l.strokeWidth}),f.createElement("line",{x1:m+p*g,y1:c,x2:m+p*(g+h),y2:c,stroke:l.fill,strokeWidth:l.strokeWidth}),f.createElement("line",{x1:m+p*g,y1:y,x2:m+p*(g+h),y2:y,stroke:l.fill,strokeWidth:l.strokeWidth}),f.createElement("rect",{x:"left"===t?m-g-h:m+g,y:Math.min(e,n),width:h,height:Math.abs(n-e),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),f.createElement("line",{x1:"left"===t?m-g-h:m+g,y1:o,x2:"left"===t?m-g:m+g+h,y2:o,stroke:l.fill,strokeWidth:2}))}}const u=r.bin().domain(e).thresholds(l.bins)(o);if(0===u.length)return null;const d=Math.max(...u.map(e=>e.length));if(0===d)return null;if("histogram"===l.type)return f.createElement("g",{"data-testid":"marginal-histogram-"+t},u.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const r=e.length/d*n;if(c){const n=i(e.x0),a=i(e.x1)-i(e.x0);return f.createElement("rect",{key:o,x:n,y:"top"===t?-4-r:4,width:Math.max(a,.5),height:r,fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}{const n=i(e.x0),a=i(e.x1)-i(e.x0);return f.createElement("rect",{key:o,x:"left"===t?-4-r:4,y:Math.min(n,n+a),width:r,height:Math.abs(a),fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}}));if("violin"===l.type){const e=n/2+4,o=[];for(const r of u){if(null==r.x0||null==r.x1)continue;const a=r.length/d*(n/2),s=i((r.x0+r.x1)/2);o.push(c?`${s},${"top"===t?-(e-a):e-a}`:`${"left"===t?-(e-a):e-a},${s}`)}for(let r=u.length-1;r>=0;r--){const a=u[r];if(null==a.x0||null==a.x1)continue;const s=a.length/d*(n/2),l=i((a.x0+a.x1)/2);o.push(c?`${l},${"top"===t?-(e+s):e+s}`:`${"left"===t?-(e+s):e+s},${l}`)}return f.createElement("g",{"data-testid":"marginal-violin-"+t},f.createElement("polygon",{points:o.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}if("ridgeline"===l.type){const e=[];if(c){const o=0,r=null!=u[0].x0?i(u[0].x0):0;e.push(`M${r},${o}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const r=o.length/d*n,a=i((o.x0+o.x1)/2);e.push(`L${a},${"top"===t?-r-4:r+4}`)}const a=null!=u[u.length-1].x1?i(u[u.length-1].x1):s;e.push(`L${a},${o}`),e.push("Z")}else{const o=0,r=null!=u[0].x0?i(u[0].x0):0;e.push(`M${o},${r}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const r=o.length/d*n,a=i((o.x0+o.x1)/2);e.push(`L${"left"===t?-r-4:r+4},${a}`)}const a=null!=u[u.length-1].x1?i(u[u.length-1].x1):s;e.push(`L${o},${a}`),e.push("Z")}return f.createElement("g",{"data-testid":"marginal-ridgeline-"+t},f.createElement("path",{d:e.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}return null},[o,i,l,a,s,t,c,4]);return u?f.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},u):null}function U(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=e.split(/\s+/),i=[];let a="";for(const e of r)a&&a.length+1+e.length>o?(i.push(a),a=e):a=a?`${a} ${e}`:e;return a&&i.push(a),i}function Z(e,t,n,o){return"curly"===e?o?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:o?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function Q(e){const{x:t=0,y:n=0,dx:o,dy:r,nx:i,ny:a,note:s,connector:l,subject:c,type:u,color:d,className:h,disable:g,events:y={},"data-testid":p}=e,m=new Set(Array.isArray(g)?g:[]);let v=o||0,b=r||0;null!=i&&(v=i-t),null!=a&&(b=a-n);const x="string"==typeof u?u:"label";if("bracket"===x&&c&&0===v&&0===b)if(void 0!==c.width){v=c.width/2;const e=c.depth||30;b=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;v=e+(0>e?-5:5),b=c.height/2}return f.createElement("g",Object.assign({className:("annotation "+(h||"")).trim(),transform:`translate(${t},${n})`,"data-testid":p},y),!m.has("connector")&&function(e,t,n,o,r,i){const a=[];let s=0,l=0;if("callout-circle"!==r&&"label"!==r||!(null==i?void 0:i.radius)){if("callout-rect"===r&&i){const n=i.width||0,o=i.height||0;if(n>0||o>0){const r=n/2,i=o/2,a=e-r,c=t-i;if(0!==a||0!==c){const e=Math.abs(a),t=Math.abs(c),u=n/2,d=o/2,h=e*d>t*u?u/e:d/t;s=r+a*h,l=i+c*h}}}else if("bracket"===r&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(s=e/2,l=n):void 0!==t&&(s=n,l=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const o=Math.atan2(t,e);s=Math.cos(o)*n,l=Math.sin(o)*n}}if(Math.sqrt(Math.pow(e-s,2)+Math.pow(t-l,2))>.5&&(a.push(f.createElement("line",{key:"connector-line",x1:s,y1:l,x2:e,y2:t,stroke:o||"currentColor"})),"arrow"===(null==n?void 0:n.end))){const n=10,r=16/180*Math.PI,i=Math.atan2(t-l,e-s);a.push(f.createElement("path",{key:"connector-arrow",d:`M${s},${l}L${s+n*Math.cos(i+r)},${l+n*Math.sin(i+r)}L${s+n*Math.cos(i-r)},${l+n*Math.sin(i-r)}Z`,fill:o||"currentColor",stroke:"none"}))}return f.createElement("g",{className:"annotation-connector"},a)}(v,b,l,d,x,c),!m.has("subject")&&function(e,t,n,o,r){var i;const a=[];switch(e){case"callout-circle":{const e=((null==t?void 0:t.radius)||0)+((null==t?void 0:t.radiusPadding)||0);e>0&&a.push(f.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:n||"currentColor"}));break}case"callout-rect":{const e=(null==t?void 0:t.width)||0,o=(null==t?void 0:t.height)||0;(e>0||o>0)&&a.push(f.createElement("rect",{key:"subject-rect",width:e,height:o,fill:"none",stroke:n||"currentColor"}));break}case"callout-custom":(null==t?void 0:t.custom)&&a.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=o||0,i=r||0;if(void 0!==(null==t?void 0:t.x)){const o=(t.x||0)-e;a.push(f.createElement("line",{key:"threshold-line",x1:o,y1:(t.y1||0)-i,x2:o,y2:(t.y2||0)-i,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==t?void 0:t.y)){const o=(t.y||0)-i;a.push(f.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:o,x2:(t.x2||0)-e,y2:o,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==t?void 0:t.x1)||void 0!==(null==t?void 0:t.x2)?a.push(f.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"currentColor",strokeDasharray:"5,5"})):void 0===(null==t?void 0:t.y1)&&void 0===(null==t?void 0:t.y2)||a.push(f.createElement("line",{key:"threshold-line",x1:0,y1:(t.y1||0)-i,x2:0,y2:(t.y2||0)-i,stroke:n||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(i=null==t?void 0:t.width)&&void 0!==i?i:null==t?void 0:t.height;void 0!==e&&a.push(f.createElement("path",{key:"bracket-path",d:Z((null==t?void 0:t.type)||"curly",e,(null==t?void 0:t.depth)||30,void 0===(null==t?void 0:t.width)),fill:"none",stroke:n||"currentColor"}));break}}return f.createElement("g",{className:"annotation-subject"},a)}(x,c,d,t,n),!m.has("note")&&function(e,t,n,o){if(!e)return f.createElement("g",{className:"annotation-note"});const{label:r,title:i,orientation:a,align:s,wrap:l=120,noWrap:c}=e;if(!r&&!i)return f.createElement("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=s;d&&"dynamic"!==d||(d="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let h="start";"topBottom"===u?"right"===d?h="end":"middle"===d&&(h="middle"):h=0>t?"end":"start";const g=16,y=i?c?[i]:U(i,l):[],p=r?c?[r]:U(r,l):[],m="leftRight"===u?"end"===h?-4:4:0;let v=0;const b=[];y.length>0&&(b.push(f.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:o||void 0,textAnchor:h,fontWeight:"bold"},y.map((e,t)=>f.createElement("tspan",{key:t,x:m,dy:0===t?0:g},e)))),v=y.length*g),p.length>0&&b.push(f.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:o||void 0,textAnchor:h,y:v},p.map((e,t)=>f.createElement("tspan",{key:t,x:m,dy:0===t?0:g},e))));let x=null;if((i||r)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(l,120);let t=0,n=e;"end"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),x=f.createElement("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"currentColor"})}else{const e=(y.length+p.length)*g+(p.length>0?g:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),x=f.createElement("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:o||"currentColor"})}const k=Math.max(0,y.length+p.length-1)*g;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===d?-(k+g+(p.length>0&&y.length>0?2:0))/2+8:"bottom"===d||0>n?-(k+2):18),f.createElement("g",{className:"annotation-note",transform:`translate(${t},${n})`},f.createElement("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0},b),x)}(s,v,b,d))}function K(e){var t,n;const{noteData:o}=e,{screenCoordinates:r}=o,i="string"==typeof o.type?o.type:"label",a=o.eventListeners||o.events||{};if(o.coordinates&&r){const e=o.nx||r[0][0]+(null!==(t=o.dx)&&void 0!==t?t:0),a=o.ny||r[0][1]+(null!==(n=o.dy)&&void 0!==n?n:0),s=r.map((t,n)=>{const r=Object.assign({},o,{note:0===n?o.note:{label:""},x:t[0],y:t[1],nx:e,ny:a});return f.createElement(Q,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},r,{type:i}))});return f.createElement("g",null,s)}const s=o.note||{title:"none",label:o.label};return f.createElement(Q,Object.assign({"data-testid":"semiotic-annotation",key:`${s.label}-${s.title}-${o.i}`,events:a},o,{type:i}))}function J(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function ee(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function te(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function ne(e){return function(e,t,n){var o,r,a,s,l,c,u,d,h,g,p,m,v,b,x,k,w,A,E,S,L,O,M,C,j,P,H,N,B,D,W,T,I,R,$,z,_,F,Y,G,q,X,V,U;switch(e.type){case"label":{let o=null,r=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);if(!t)return null;o=t.x,r=t.y}else o=J(e,n),r=ee(e,n);return null==o||null==r?null:te(o,r,n)?f.createElement(K,{key:"ann-"+t,noteData:{x:o,y:r,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"label",connector:e.connector||{end:"arrow"},color:e.color}}):null}case"callout":{let o=null,r=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);if(!t)return null;o=t.x,r=t.y}else o=J(e,n),r=ee(e,n);return null==o||null==r?null:te(o,r,n)?f.createElement(K,{key:"ann-"+t,noteData:{x:o,y:r,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"callout-circle",subject:{radius:e.radius||12},connector:e.connector||{end:"arrow"},color:e.color}}):null}case"x-threshold":{const o=J(e,n);if(null==o)return null;const r=e.color||"#f97316";return f.createElement("g",{key:"ann-"+t},f.createElement("line",{x1:o,y1:0,x2:o,y2:n.height||0,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&f.createElement("text",{x:o+4,y:12,fill:r,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const o=ee(e,n);if(null==o)return null;const r=e.color||"#f97316";return f.createElement("g",{key:"ann-"+t},f.createElement("line",{x1:0,y1:o,x2:n.width||0,y2:o,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&f.createElement("text",{x:(n.width||0)-4,y:o-4,textAnchor:"end",fill:r,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const o=(e.coordinates||[]).map(e=>({x:J(Object.assign(Object.assign({},e),{type:"point"}),n),y:ee(Object.assign(Object.assign({},e),{type:"point"}),n),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const r=i.packEnclose(o),a=e.padding||10;return f.createElement("g",{key:"ann-"+t},f.createElement("circle",{cx:r.x,cy:r.y,r:r.r+a,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&f.createElement("text",{x:r.x,y:r.y-r.r-a-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"rect-enclose":{const o=(e.coordinates||[]).map(e=>({x:J(Object.assign(Object.assign({},e),{type:"point"}),n),y:ee(Object.assign(Object.assign({},e),{type:"point"}),n)})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const r=e.padding||10,i=o.map(e=>e.x),a=o.map(e=>e.y),s=Math.min(...i)-r,l=Math.max(...i)+r,c=Math.min(...a)-r,u=Math.max(...a)+r;return f.createElement("g",{key:"ann-"+t},f.createElement("rect",{x:s,y:c,width:l-s,height:u-c,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&f.createElement("text",{x:(s+l)/2,y:c-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"highlight":{const o=n.data||[],r="function"==typeof e.filter?o.filter(e.filter):e.field&&null!=e.value?o.filter(t=>t[e.field]===e.value):[],i=e.style||{stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return f.createElement("g",{key:"ann-"+t},r.map((t,o)=>{const r=J(t,n),a=ee(t,n);return null==r||null==a?null:f.createElement("circle",Object.assign({key:o,cx:r,cy:a,r:e.r||6},i))}))}case"bracket":{const o=J(e,n),r=ee(e,n);return f.createElement(K,{key:"ann-"+t,noteData:{x:null!=o?o:0,y:null!=r?r:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}})}case"trend":{const i=n.data||[];if(2>i.length)return null;const d=n.xAccessor||"x",h=n.yAccessor||"y",g=i.map(e=>[e[d],e[h]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>g.length)return null;const p=null!==(r=null===(o=n.scales)||void 0===o?void 0:o.x)&&void 0!==r?r:null===(a=n.scales)||void 0===a?void 0:a.time,m=null!==(l=null===(s=n.scales)||void 0===s?void 0:s.y)&&void 0!==l?l:null===(c=n.scales)||void 0===c?void 0:c.value;if(!p||!m)return null;const v=e.method||"linear";let b;b="loess"===v?function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),r=o.map(e=>e[0]),i=o.map(e=>e[1]),a=Math.max(2,Math.ceil(t*n)),s=[];for(let e=0;n>e;e++){const t=r[e],o=r.map(e=>Math.abs(e-t)),l=o.slice().sort((e,t)=>e-t)[Math.min(a-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:o[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,g=0,f=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*r[e],h+=t*i[e],g+=t*r[e]*r[e],f+=t*r[e]*i[e])}if(0===u){s.push([t,i[e]]);continue}const y=u*g-d*d;if(1e-12>Math.abs(y))s.push([t,h/u]);else{const e=(u*f-d*h)/y;s.push([t,(h-e*d)/u+e*t])}}return s}(g,null!==(u=e.bandwidth)&&void 0!==u?u:.3):("polynomial"===v?y.default.polynomial(g,{order:e.order||2}):y.default.linear(g)).points;const x=b.map(([e,t])=>`${p(e)},${m(t)}`).join(" "),k=e.color||"#6366f1";return f.createElement("g",{key:"ann-"+t},f.createElement("polyline",{points:x,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&f.createElement("text",{x:p(b[b.length-1][0])+4,y:m(b[b.length-1][1])-4,fill:k,fontSize:11},e.label))}case"band":{const o=null!==(h=null===(d=n.scales)||void 0===d?void 0:d.y)&&void 0!==h?h:null===(g=n.scales)||void 0===g?void 0:g.value,r=null!==(p=null==o?void 0:o(e.y0))&&void 0!==p?p:0,i=null!==(m=null==o?void 0:o(e.y1))&&void 0!==m?m:n.height||0;return f.createElement("g",{key:"ann-"+t},f.createElement("rect",{x:0,y:Math.min(r,i),width:n.width||0,height:Math.abs(i-r),fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity||.1}),e.label&&f.createElement("text",{x:(n.width||0)-4,y:Math.min(r,i)-4,textAnchor:"end",fill:e.color||"#6366f1",fontSize:11},e.label))}case"envelope":{const o=n.data||[];if(2>o.length)return null;const r=n.xAccessor||"x",i=null!==(b=null===(v=n.scales)||void 0===v?void 0:v.x)&&void 0!==b?b:null===(x=n.scales)||void 0===x?void 0:x.time,a=null!==(w=null===(k=n.scales)||void 0===k?void 0:k.y)&&void 0!==w?w:null===(A=n.scales)||void 0===A?void 0:A.value;if(!i||!a)return null;const s=e.upperAccessor||"upperBounds",l=e.lowerAccessor||"lowerBounds",c=e.filter,u=o.filter(e=>null!=e[s]&&null!=e[l]&&!(c&&!c(e))).sort((e,t)=>e[r]-t[r]);if(2>u.length)return null;const d=u.map(e=>`${i(e[r])},${a(e[s])}`).join(" L"),h=u.slice().reverse().map(e=>`${i(e[r])},${a(e[l])}`).join(" L"),g=e.fill||"#6366f1";return f.createElement("g",{key:"ann-"+t},f.createElement("path",{d:`M${d} L${h} Z`,fill:g,fillOpacity:null!==(E=e.fillOpacity)&&void 0!==E?E:.15,stroke:"none"}),e.label&&u.length>0&&f.createElement("text",{x:i(u[u.length-1][r])+4,y:a(u[u.length-1][s])-4,fill:g,fontSize:11},e.label))}case"anomaly-band":{const o=n.data||[];if(2>o.length)return null;const r=n.yAccessor||"y",i=null!==(L=null===(S=n.scales)||void 0===S?void 0:S.x)&&void 0!==L?L:null===(O=n.scales)||void 0===O?void 0:O.time,a=null!==(C=null===(M=n.scales)||void 0===M?void 0:M.y)&&void 0!==C?C:null===(j=n.scales)||void 0===j?void 0:j.value;if(!i||!a)return null;const s=o.map(e=>e[r]).filter(e=>null!=e&&isFinite(e));if(2>s.length)return null;const l=s.reduce((e,t)=>e+t,0)/s.length,c=s.reduce((e,t)=>e+Math.pow(t-l,2),0)/s.length,u=Math.sqrt(c),d=null!==(P=e.threshold)&&void 0!==P?P:2,h=l-d*u,g=!1!==e.showBand,y=e.fill||"#6366f1",p=null!==(H=e.fillOpacity)&&void 0!==H?H:.1,m=e.anomalyColor||"#ef4444",v=null!==(N=e.anomalyRadius)&&void 0!==N?N:6,b=a(l+d*u),x=a(h),k=o.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-l)>d*u});return f.createElement("g",{key:"ann-"+t},g&&f.createElement("rect",{x:0,y:Math.min(b,x),width:n.width||0,height:Math.abs(x-b),fill:y,fillOpacity:p}),k.map((e,t)=>{const o=J(e,n),r=ee(e,n);return null==o||null==r?null:f.createElement("circle",{key:t,cx:o,cy:r,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5})}),e.label&&f.createElement("text",{x:(n.width||0)-4,y:Math.min(b,x)-4,textAnchor:"end",fill:y,fontSize:11},e.label))}case"forecast":{const o=n.data||[];if(3>o.length)return null;const r=n.xAccessor||"x",i=n.yAccessor||"y",a=null!==(D=null===(B=n.scales)||void 0===B?void 0:B.x)&&void 0!==D?D:null===(W=n.scales)||void 0===W?void 0:W.time,s=null!==(I=null===(T=n.scales)||void 0===T?void 0:T.y)&&void 0!==I?I:null===(R=n.scales)||void 0===R?void 0:R.value;if(!a||!s)return null;const l=o.map(e=>[e[r],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>l.length)return null;let c;if("polynomial"===(e.method||"linear")){const t=y.default.polynomial(l,{order:e.order||2}).equation;c=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}else{const e=l.length;let t=0,n=0,o=0,r=0;for(const[e,i]of l)t+=e,n+=i,o+=e*e,r+=e*i;const i=e*o-t*t;if(1e-12>Math.abs(i))return null;const a=(e*r-t*n)/i,s=(n-a*t)/e;c=e=>s+a*e}const u=l.length,d=l.map(([e,t])=>t-c(e)).reduce((e,t)=>e+t*t,0),h=Math.sqrt(d/Math.max(u-2,1)),g=l.reduce((e,t)=>e+t[0],0)/u,p=l.reduce((e,t)=>e+Math.pow(t[0]-g,2),0),m=null!==($=e.confidence)&&void 0!==$?$:.95,v=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,b=null!==(z=e.steps)&&void 0!==z?z:5,x=l[u-1][0],k=(x-l[0][0])/Math.max(u-1,1),w=[];for(let e=1;b>=e;e++)w.push(x+e*k);const A=[];for(const e of w){const t=c(e),n=h*Math.sqrt(1+1/u+(p>0?Math.pow(e-g,2)/p:0))*v;A.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const E=`M${A.map(e=>`${a(e.x)},${s(e.yUpper)}`).join(" L")} L${A.slice().reverse().map(e=>`${a(e.x)},${s(e.yLower)}`).join(" L")} Z`,S=A.map(e=>`${a(e.x)},${s(e.yCenter)}`).join(" "),L=`${a(x)},${s(c(x))}`,O=e.strokeColor||"#6366f1";return f.createElement("g",{key:"ann-"+t},f.createElement("path",{d:E,fill:e.fill||"#6366f1",fillOpacity:null!==(_=e.fillOpacity)&&void 0!==_?_:.15,stroke:"none"}),f.createElement("polyline",{points:`${L} ${S}`,fill:"none",stroke:O,strokeWidth:null!==(F=e.strokeWidth)&&void 0!==F?F:2,strokeDasharray:null!==(Y=e.strokeDasharray)&&void 0!==Y?Y:"6,3"}),e.label&&A.length>0&&f.createElement("text",{x:a(A[A.length-1].x)+4,y:s(A[A.length-1].yCenter)-4,fill:O,fontSize:11},e.label))}case"widget":{let o=null,r=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);if(!t)return null;o=t.x,r=t.y}else null!=e.px&&null!=e.py?(o=e.px,r=e.py):(o=J(e,n),r=ee(e,n));if(null==o||null==r)return null;if(!te(o,r,n))return null;const i=null!==(G=e.dx)&&void 0!==G?G:0,a=null!==(q=e.dy)&&void 0!==q?q:0,s=null!==(X=e.width)&&void 0!==X?X:32,l=null!==(V=e.height)&&void 0!==V?V:32,c=null!==(U=e.content)&&void 0!==U?U:f.createElement("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info"},"ℹ️");return f.createElement("foreignObject",{key:"ann-"+t,x:o+i-s/2,y:r+a-l/2,width:s,height:l,style:{overflow:"visible",pointerEvents:"auto"}},f.createElement("div",{style:{width:s,height:l,display:"flex",alignItems:"center",justifyContent:"center"}},c))}case"text":{const o=J(e,n),r=ee(e,n);return null==o||null==r?null:f.createElement("text",{key:"ann-text-"+t,x:o+(e.dx||0),y:r+(e.dy||0),fill:e.color||"var(--semiotic-text, #333)",fontSize:e.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},e.label)}default:return null}}}function oe(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,r="left"===e?-1:1,i=Math.ceil(t/8);let a="M0,"+o;for(let e=0;i>e;e++){const n=8*(e+1);a+=`L${Math.min(8*e+4,t)},${o+4*r}`,a+=`L${Math.min(n,t)},${o}`}return a}{const o="bottom"===e?0:t,r="bottom"===e?1:-1,i=Math.ceil(n/8);let a=`M${o},0`;for(let e=0;i>e;e++){const t=8*(e+1);a+=`L${o+4*r},${Math.min(8*e+4,n)}`,a+=`L${o},${Math.min(t,n)}`}return a}}function re(e){return Math.round(100*e)/100+""}function ie(e,t){return e instanceof Date&&(!(t&&t instanceof Date)||e.getFullYear()!==t.getFullYear()||e.getMonth()!==t.getMonth()||e.getDate()!==t.getDate())}function ae(t){const{width:n,height:o,totalWidth:r,totalHeight:i,margin:a,scales:s,showAxes:l,axes:c,xLabel:u,yLabel:d,xFormat:h,yFormat:g,showGrid:y,title:p,legend:m,legendHoverBehavior:v,legendClickBehavior:b,legendHighlightedCategory:x,legendIsolatedCategories:k,foregroundGraphics:w,marginalGraphics:A,xValues:E,yValues:S,annotations:L,svgAnnotationRules:O,annotationFrame:M,xAccessor:C,yAccessor:j,annotationData:P,pointNodes:H,children:N}=t,B=e.useMemo(()=>l&&s?s.x.ticks(5).map(e=>({value:e,pixel:s.x(e),label:(h||re)(e)})):[],[l,s,h]),D=e.useMemo(()=>l&&s?s.y.ticks(5).map(e=>({value:e,pixel:s.y(e),label:(g||re)(e)})):[],[l,s,g]),W=e.useMemo(()=>{if(!L||0===L.length)return null;const e=ne(),t={scales:s?{x:s.x,y:s.y,time:s.x,value:s.y}:null,timeAxis:"x",xAccessor:C,yAccessor:j,width:n,height:o,data:P,frameType:"xy",pointNodes:H};return L.map((n,o)=>{if(O){const r=O(n,o,t);return null!=r?r:e(n,o,t)}return e(n,o,t)}).filter(Boolean)},[L,O,n,o,M,C,j,P]);return l||p||m||w||A||W&&W.length>0||y||N?f.createElement("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},f.createElement("g",{transform:`translate(${a.left},${a.top})`},y&&s&&f.createElement("g",{className:"stream-grid"},B.map((e,t)=>f.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),D.map((e,t)=>f.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:n,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),l&&s&&(()=>{const e=null==c?void 0:c.find(e=>"left"===e.orient),t=null==c?void 0:c.find(e=>"bottom"===e.orient),r=!e||!1!==e.baseline,i=(null==e?void 0:e.jaggedBase)||!1,s=(null==t?void 0:t.jaggedBase)||!1,l=null==t?void 0:t.landmarkTicks,h=null==e?void 0:e.landmarkTicks,g="var(--semiotic-border, #ccc)",y="var(--semiotic-text-secondary, #666)",p="var(--semiotic-text, #333)";return f.createElement("g",{className:"stream-axes"},(!t||!1!==t.baseline)&&!s&&f.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:g,strokeWidth:1}),s&&f.createElement("path",{d:oe("bottom",n,o),fill:"none",stroke:g,strokeWidth:1}),B.map((e,t)=>{const n=!!l&&("function"==typeof l?l(e.value,t):ie(e.value,t>0?B[t-1].value:void 0));return f.createElement("g",{key:"xtick-"+t,transform:`translate(${e.pixel},${o})`},f.createElement("line",{y2:5,stroke:g,strokeWidth:1}),f.createElement("text",{y:18,textAnchor:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:y,style:{userSelect:"none"}},e.label))}),u&&f.createElement("text",{x:n/2,y:o+40,textAnchor:"middle",fontSize:12,fill:p,style:{userSelect:"none"}},u),r&&!i&&f.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:g,strokeWidth:1}),i&&f.createElement("path",{d:oe("left",n,o),fill:"none",stroke:g,strokeWidth:1}),D.map((e,t)=>{const n=!!h&&("function"==typeof h?h(e.value,t):ie(e.value,t>0?D[t-1].value:void 0));return f.createElement("g",{key:"ytick-"+t,transform:`translate(0,${e.pixel})`},f.createElement("line",{x2:-5,stroke:g,strokeWidth:1}),f.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:y,style:{userSelect:"none"}},e.label))}),d&&f.createElement("text",{x:15-a.left,y:o/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(-90, ${15-a.left}, ${o/2})`,style:{userSelect:"none"}},d))})(),W,A&&s&&E&&S&&f.createElement(f.Fragment,null,A.top&&f.createElement("g",{transform:"translate(0, 0)"},f.createElement(V,{orient:"top",config:X(A.top),values:E,scale:s.x,size:a.top,length:n})),A.bottom&&f.createElement("g",{transform:`translate(0, ${o})`},f.createElement(V,{orient:"bottom",config:X(A.bottom),values:E,scale:s.x,size:a.bottom,length:n})),A.left&&f.createElement("g",{transform:"translate(0, 0)"},f.createElement(V,{orient:"left",config:X(A.left),values:S,scale:s.y,size:a.left,length:o})),A.right&&f.createElement("g",{transform:`translate(${n}, 0)`},f.createElement(V,{orient:"right",config:X(A.right),values:S,scale:s.y,size:a.right,length:o}))),w,N),p&&f.createElement("text",{x:r/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof p?p:null),m&&f.createElement("g",{transform:`translate(${r-a.right+10}, ${a.top})`},function(e){return"object"==typeof e&&null!==e&&!f.isValidElement(e)&&"legendGroups"in e}(m)?f.createElement(q,{legendGroups:m.legendGroups,title:"",width:100,customHoverBehavior:v,customClickBehavior:b,highlightedCategory:x,isolatedCategories:k}):m)):null}const se="undefined"==typeof window||"undefined"==typeof document;function le(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}function ce(e){if(e.startsWith("#")){const t=4===e.length?e[1]+e[1]+e[2]+e[2]+e[3]+e[3]:e.slice(1,7);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[78,121,167]}function ue(e,t){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath()}const de=(e,t,n,o)=>{var r;const i=t.filter(e=>"area"===e.type);for(const t of i){if(2>t.topPath.length)continue;ue(e,t);const n=t.style.fill||"#4e79a7";if(t.fillGradient){const o=Math.min(...t.topPath.map(e=>e[1])),r=Math.max(...t.bottomPath.map(e=>e[1])),i=e.createLinearGradient(0,o,0,r);i.addColorStop(0,n),i.addColorStop(1,n),e.fillStyle=i;const a=ce(n),s=t.fillGradient.topOpacity,l=t.fillGradient.bottomOpacity,c=e.createLinearGradient(0,o,0,r);c.addColorStop(0,`rgba(${a[0]},${a[1]},${a[2]},${s})`),c.addColorStop(1,`rgba(${a[0]},${a[1]},${a[2]},${l})`),e.fillStyle=c,e.globalAlpha=1}else{const o=null!==(r=t.style.fillOpacity)&&void 0!==r?r:.7;e.globalAlpha=o,e.fillStyle=n}if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(ue(e,t),e.globalAlpha=.35*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill()),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=1,e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]),e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);e.stroke()}e.globalAlpha=1}},he=(e,t,n,o)=>{var r,i;const a=t.filter(e=>"point"===e.type);for(const t of a){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(r=t.style.opacity)&&void 0!==r?r:t.style.fillOpacity;if(null!=n&&(e.globalAlpha=n),e.fillStyle=t.style.fill||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0){const n=null!==(i=t._pulseGlowRadius)&&void 0!==i?i:4,o=t.r+n*t._pulseIntensity;e.beginPath(),e.arc(t.x,t.y,o,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=.6*t._pulseIntensity,e.stroke()}e.globalAlpha=1}},ge=(e,t,n,o)=>{const r=t.filter(e=>"rect"===e.type);for(const t of r)null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon?fe(e,t):(e.fillStyle=t.style.fill||"#007bff",e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.globalAlpha=1};function fe(e,t){const n=t.style.icon,o=t.style.iconPadding||2,r=Math.min(t.w,t.w)-o;if(0>=r)return;const i=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),i){const i=r+o,a=t.x+(t.w-r)/2;for(let o=t.y+t.h-r;o>=t.y-r;o-=i)e.drawImage(n,a,o,r,r)}else{const i=r+o,a=t.y+(t.h-r)/2;for(let o=t.x;t.x+t.w>o;o+=i)e.drawImage(n,o,a,r,r)}e.restore()}const ye={line:[de,(e,t,n,o)=>{const r=t.filter(e=>"line"===e.type);for(const i of r){if(2>i.path.length)continue;const a=i.style.stroke||"#007bff",s=i.style.strokeWidth||2,l=i.colorThresholds,c=i.rawValues;if(e.setLineDash(i.style.strokeDasharray?i.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=i.style.opacity&&(e.globalAlpha=i.style.opacity),e.lineWidth=s,l&&0!==l.length&&c&&c.length===i.path.length){let u=null,d=null,h=null,g=null,f=!1;function y(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),f=!0}function p(){f&&(e.stroke(),f=!1)}for(let m=0;i.path.length>m;m++){const[v,b]=i.path[m],x=c[m],k=le(x,l,a);if(null!==u&&null!==g&&null!==h){if(k===g)e.lineTo(v,b);else{const w=[];for(const A of l){const E=A.value;(h>E||E>x)&&(E>h||x>E)||h===E||x===E||w.push({t:(E-h)/(x-h)})}w.sort((e,t)=>e.t-t.t);for(const S of w){const L=u+(v-u)*S.t,O=d+(b-d)*S.t,M=le(h+(x-h)*Math.min(S.t+1e-4,1),l,a);e.lineTo(L,O),p(),y(M,L,O)}e.lineTo(v,b)}u=v,d=b,h=x,g=k}else y(k,v,b),u=v,d=b,h=x,g=k}p()}else{e.beginPath(),e.strokeStyle=a;const[C,j]=i.path[0];e.moveTo(C,j);for(let P=1;i.path.length>P;P++)e.lineTo(i.path[P][0],i.path[P][1]);e.stroke()}if(i.style.fill&&i.style.fillOpacity&&i.style.fillOpacity>0){e.beginPath(),e.globalAlpha=i.style.fillOpacity,e.fillStyle=i.style.fill;const[H,N]=i.path[0];e.moveTo(H,N);for(let D=1;i.path.length>D;D++)e.lineTo(i.path[D][0],i.path[D][1]);const B=i.path[0][0];e.lineTo(i.path[i.path.length-1][0],o.height),e.lineTo(B,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([])}}],area:[de],stackedarea:[de],scatter:[he],bubble:[he],heatmap:[(e,t,n,o)=>{const r=t.filter(e=>"heatcell"===e.type);for(const t of r){const n=t.style;null!=(null==n?void 0:n.opacity)&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle="#fff",e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.globalAlpha=1}}],bar:[ge],swarm:[he],waterfall:[(e,t,n,o)=>{var r,i,a;ge(e,t);const s=t.filter(e=>"rect"===e.type);if(2>s.length)return;const l=s[0].datum,c=null==l?void 0:l._connectorStroke;if(c){e.save(),e.strokeStyle=c,e.lineWidth=null!==(r=null==l?void 0:l._connectorWidth)&&void 0!==r?r:1,e.setLineDash([]);for(let t=0;s.length-1>t;t++){const o=s[t],r=s[t+1];if(!(null===(i=o.datum)||void 0===i?void 0:i.cumEnd)||!(null===(a=r.datum)||void 0===a?void 0:a.baseline))continue;const l=n.y(o.datum.cumEnd),c=o.x+o.w,u=r.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[(e,t,n,o)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=t.wickColor,e.lineWidth=t.wickWidth,e.stroke();const o=Math.min(t.openY,t.closeY),r=Math.abs(t.openY-t.closeY),i=t.isUp?t.upColor:t.downColor;e.fillStyle=i,e.fillRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(r,1)),e.strokeStyle=i,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(r,1))}}]},pe={top:20,right:20,bottom:30,left:40},me={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white"},ve={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function be({hover:e}){const t=e=>Number.isInteger(e)?e+"":e.toFixed(2);return f.createElement("div",{className:"semiotic-tooltip",style:ve},f.createElement("div",{style:{fontWeight:600,marginBottom:2}},t(e.value)),f.createElement("div",{style:{opacity:.7,fontSize:11}},t(e.time)))}function xe({width:o,height:r,totalWidth:i,totalHeight:a,margin:s,dimension:l,scales:c,onBrush:u}){const d=e.useRef(null),h=e.useRef(null),g=e.useRef(u);g.current=u;const y=e.useRef(c);return y.current=c,e.useEffect(()=>{if(!d.current)return;const e=n.select(d.current).select(".brush-g"),i="x"===l?t.brushX():"y"===l?t.brushY():t.brush();return i.extent([[0,0],[o,r]]),i.on("brush end",e=>{const t=y.current;if(!t)return;if(!e.selection)return void g.current(null);let n,i;if("x"===l){const[o,a]=e.selection;n=[t.x.invert(o),t.x.invert(a)],i=[t.y.invert(r),t.y.invert(0)]}else if("y"===l){const[r,a]=e.selection;n=[t.x.invert(0),t.x.invert(o)],i=[t.y.invert(a),t.y.invert(r)]}else{const[[o,r],[a,s]]=e.selection;n=[t.x.invert(o),t.x.invert(a)],i=[t.y.invert(s),t.y.invert(r)]}g.current({x:n,y:i})}),e.call(i),h.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),h.current=null}},[o,r,l]),f.createElement("svg",{ref:d,width:i,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},f.createElement("g",{className:"brush-g",transform:`translate(${s.left},${s.top})`}))}const ke=e.forwardRef(function(t,n){var o,r,i,a,s;const{chartType:l,runtimeMode:c,data:u,xAccessor:d,yAccessor:h,colorAccessor:g,sizeAccessor:y,groupAccessor:p,lineDataAccessor:v,normalize:b,binSize:x,valueAccessor:k,arrowOfTime:w="right",windowMode:A="sliding",windowSize:E=200,timeAccessor:S,xExtent:L,yExtent:O,extentPadding:C=.1,sizeRange:j,size:T=[500,300],responsiveWidth:_,responsiveHeight:F,margin:Y,className:G,background:q,lineStyle:X,pointStyle:V,areaStyle:U,waterfallStyle:Z,swarmStyle:Q,barColors:K,colorScheme:J,boundsAccessor:ee,boundsStyle:te,y0Accessor:ne,gradientFill:oe,openAccessor:re,highAccessor:ie,lowAccessor:le,closeAccessor:ce,candlestickStyle:ue,showAxes:de=!0,axes:he,xLabel:ge,yLabel:fe,xFormat:ve,yFormat:ke,tickFormatTime:we,tickFormatValue:Ae,hoverAnnotation:Ee,tooltipContent:Se,customHoverBehavior:Le,enableHover:Oe,annotations:Me,svgAnnotationRules:Ce,showGrid:je,legend:Pe,legendHoverBehavior:He,legendClickBehavior:Ne,legendHighlightedCategory:Be,legendIsolatedCategories:De,backgroundGraphics:We,foregroundGraphics:Te,title:Ie,categoryAccessor:Re,brush:$e,onBrush:ze,decay:_e,pulse:Fe,transition:Ye,staleness:Ge,heatmapAggregation:qe,heatmapXBins:Xe,heatmapYBins:Ve,marginalGraphics:Ue,pointIdAccessor:Ze}=t,[Qe,Ke]=$(T,_,F),Je=Object.assign(Object.assign({},pe),Y);if(Ue){const e=60;Ue.top&&e>Je.top&&(Je.top=e),Ue.bottom&&e>Je.bottom&&(Je.bottom=e),Ue.left&&e>Je.left&&(Je.left=e),Ue.right&&e>Je.right&&(Je.right=e)}const et=Ke[0]-Je.left-Je.right,tt=Ke[1]-Je.top-Je.bottom,nt=null!=Ee?Ee:Oe,ot=e.useRef(null),rt=e.useRef(null),it=e.useRef(0),at=e.useRef(!1),[st,lt]=e.useState(0),[ct,ut]=e.useState(null),dt=e.useRef(null),ht=e.useRef(null),[gt,ft]=e.useState(null),[yt,pt]=e.useState(!1),[mt,vt]=e.useState([]),[bt,xt]=e.useState([]),kt=e.useRef(()=>{}),wt="streaming"===c||["bar","swarm","waterfall"].includes(l),At=e.useMemo(()=>({chartType:l,runtimeMode:wt?"streaming":"bounded",windowSize:E,windowMode:A,arrowOfTime:wt?w:"right",extentPadding:C,xAccessor:wt?void 0:d,yAccessor:wt?void 0:h,timeAccessor:wt?S:void 0,valueAccessor:k,colorAccessor:g,sizeAccessor:y,groupAccessor:p,categoryAccessor:Re,lineDataAccessor:v,xExtent:L,yExtent:O,sizeRange:j,binSize:x,normalize:b,boundsAccessor:ee,boundsStyle:te,y0Accessor:ne,gradientFill:"boolean"==typeof oe?oe?{topOpacity:.8,bottomOpacity:.05}:void 0:oe,openAccessor:re,highAccessor:ie,lowAccessor:le,closeAccessor:ce,candlestickStyle:ue,lineStyle:X,pointStyle:V,areaStyle:U,swarmStyle:Q,waterfallStyle:Z,colorScheme:J,barColors:K,annotations:Me,decay:_e,pulse:Fe,transition:Ye,staleness:Ge,heatmapAggregation:qe,heatmapXBins:Xe,heatmapYBins:Ve,pointIdAccessor:Ze}),[l,E,A,w,C,d,h,S,k,g,y,p,Re,v,L,O,j,x,b,ee,te,ne,oe,re,ie,le,ce,ue,X,V,U,Q,Z,J,K,Me,_e,Fe,Ye,Ge,qe,Xe,Ve,wt,Ze]),Et=e.useRef(null);Et.current||(Et.current=new M(At));const St=e.useCallback(()=>{it.current||(it.current=requestAnimationFrame(()=>kt.current()))},[]);e.useEffect(()=>{var e;null===(e=Et.current)||void 0===e||e.updateConfig(At),at.current=!0,St()},[At,St]);const Lt=e.useRef(null);Lt.current||(Lt.current=new m(e=>{const t=Et.current;t&&t.ingest(e)&&(at.current=!0,St())}));const Ot=e.useCallback(e=>{var t;null===(t=Lt.current)||void 0===t||t.push(e)},[]),Mt=e.useCallback(e=>{var t;null===(t=Lt.current)||void 0===t||t.pushMany(e)},[]),Ct=e.useCallback(()=>{var e,t;null===(e=Lt.current)||void 0===e||e.clear(),null===(t=Et.current)||void 0===t||t.clear(),at.current=!0,St()},[St]);e.useImperativeHandle(n,()=>({push:Ot,pushMany:Mt,clear:Ct,getData:()=>{var e,t;return null!==(t=null===(e=Et.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=Et.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=Et.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[Ot,Mt,Ct]),e.useEffect(()=>{var e;u&&(null===(e=Lt.current)||void 0===e||e.setBoundedData(u))},[u]);const jt=e.useRef(()=>{}),Pt=e.useRef(()=>{});jt.current=e=>{if(!nt)return;const t=ot.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Je.left,r=e.clientY-n.top-Je.top;if(0>o||o>et||0>r||r>tt)return void(dt.current&&(dt.current=null,ht.current=null,ft(null),Le&&(Le(null),at.current=!0),St()));const i=Et.current;if(!i||0===i.scene.length)return;const a=function(e,t,n,o=30){let r=null;for(const i of e){let e=null;switch(i.type){case"point":e=P(i,t,n);break;case"line":e=H(i,t,n);break;case"rect":e=N(i,t,n);break;case"heatcell":e=B(i,t,n);break;case"area":if(!1===i.interactive)break;e=W(i,t,n);break;case"candlestick":e=D(i,t,n)}e&&o>e.distance&&(r&&e.distance>=r.distance||(r=e))}return r}(i.scene,o,r);if(!a)return void(dt.current&&(dt.current=null,ht.current=null,ft(null),Le&&Le(null),St()));const s={data:a.datum,time:a.x,value:a.y,x:a.x,y:a.y};dt.current=s,ht.current=a.node,ft(s),Le&&(Le(s),at.current=!0),St()},Pt.current=()=>{dt.current&&(dt.current=null,ht.current=null,ft(null),Le&&(Le(null),at.current=!0),St())},e.useCallback(e=>jt.current(e),[]);const Ht=e.useCallback(()=>Pt.current(),[]),Nt=e.useRef(-1),Bt=e.useCallback(e=>{const t=Et.current;if(!t||0===t.scene.length)return;const n=function(e){const t=[];for(const n of e)switch(n.type){case"point":t.push({x:n.x,y:n.y,datum:n.datum});break;case"line":{const e=n,o=Array.isArray(e.datum)?e.datum:[];for(let n=0;e.path.length>n&&o.length>n;n++)t.push({x:e.path[n][0],y:e.path[n][1],datum:o[n]});break}case"area":{const e=n,o=Array.isArray(e.datum)?e.datum:[];for(let n=0;e.topPath.length>n&&o.length>n;n++)t.push({x:e.topPath[n][0],y:e.topPath[n][1],datum:o[n]});break}case"rect":case"heatcell":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.scene);if(0===n.length)return;const o=0>Nt.current?-1:Nt.current,r=I(e.key,0>o?-1:o,n.length);if(null===r)return;if(e.preventDefault(),0>r)return Nt.current=-1,dt.current=null,ht.current=null,ft(null),Le&&Le(null),void St();const i=0>o?0:r;Nt.current=i;const a=R(n[i]);dt.current=a,ft(a),Le&&Le(a),St()},[Le,St]),Dt=e.useCallback(e=>{Nt.current=-1,jt.current(e)},[]);kt.current=()=>{var e,t;it.current=0;const n=ot.current,o=rt.current;if(!n||!o)return;const r=Et.current;if(!r)return;const i="undefined"!=typeof performance?performance.now():Date.now(),a=r.advanceTransition(i),s=at.current||a;s&&!a&&r.computeScene({width:et,height:tt});const c="undefined"!=typeof window&&window.devicePixelRatio||1,u=function(e){if(!e)return me;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),r=t.getPropertyValue("--semiotic-bg").trim(),i=o||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),s=n||t.getPropertyValue("--surface-3").trim(),l=r||t.getPropertyValue("--surface-0").trim();return i||a||n?{axisStroke:s||me.axisStroke,tickText:i||me.tickText,crosshair:i?i+"66":me.crosshair,hoverFill:l?l+"4D":me.hoverFill,hoverStroke:i?i+"99":me.hoverStroke,pointRing:l||me.pointRing}:me}(n),g=null!==(e=null==Ge?void 0:Ge.threshold)&&void 0!==e?e:5e3,f=Ge&&r.lastIngestTime>0&&i-r.lastIngestTime>g;if(s){const e=n.getContext("2d");if(e){n.width=Ke[0]*c,n.height=Ke[1]*c,n.style.width=Ke[0]+"px",n.style.height=Ke[1]+"px",e.scale(c,c),e.translate(Je.left,Je.top),e.clearRect(-Je.left,-Je.top,Ke[0],Ke[1]),f&&(e.globalAlpha=null!==(t=null==Ge?void 0:Ge.dimOpacity)&&void 0!==t?t:.5);const o=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=q||(o&&"transparent"!==o?o:null);i&&(e.fillStyle=i,e.fillRect(-Je.left,-Je.top,Ke[0],Ke[1])),e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,et,tt),e.clip());const a=ye[l];if(a&&r.scales)for(const t of a)t(e,r.scene,r.scales,{width:et,height:tt});e.restore(),f&&(e.globalAlpha=1)}}{const e=o.getContext("2d");if(e&&(o.width=Ke[0]*c,o.height=Ke[1]*c,o.style.width=Ke[0]+"px",o.style.height=Ke[1]+"px",e.scale(c,c),e.translate(Je.left,Je.top),nt&&dt.current&&r.scales&&function(e,t,n,o,r,i,a){if(!1===r.crosshair)return;e.save();const s="object"==typeof r.crosshair?r.crosshair:{};e.strokeStyle=s.stroke||a.crosshair,e.lineWidth=s.strokeWidth||1,e.setLineDash(s.strokeDasharray?s.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(t.x,0),e.lineTo(t.x,o),e.stroke(),e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke(),e.restore(),e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle="#007bff",e.fill(),e.strokeStyle=a.pointRing,e.lineWidth=2,e.stroke()}(e,dt.current,et,tt,"object"==typeof nt?nt:{},0,u),ht.current&&Array.isArray(Ee))){const t=Ee.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,o){var r;if(!n)return;const i=n.group;if(void 0!==i)for(const n of t){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const t="function"==typeof o.style?o.style(n.datum):o.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||"#007bff",e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=null!==(r=t.opacity)&&void 0!==r?r:1,e.stroke(),e.restore()}}(e,r.scene,ht.current,t)}}const y=at.current;if(at.current=!1,y&&r.scales&&(ut(r.scales),Ue)){const e=r.getData(),t="function"==typeof d?d:e=>e[d||"x"],n="function"==typeof h?h:e=>e[h||"y"];vt(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),xt(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}y&&Me&&Me.length>0&<(e=>e+1),(null==Ge?void 0:Ge.showBadge)&&pt(!!f),(a||r.hasActivePulses)&&(it.current=requestAnimationFrame(()=>kt.current()))},e.useEffect(()=>(St(),()=>{it.current&&(cancelAnimationFrame(it.current),it.current=0)}),[St]),e.useEffect(()=>{at.current=!0,St()},[l,et,tt,de,q,X,St]),z(Ge,Et,at,St,yt,pt);const Wt=nt&>?Se?Se(gt):f.createElement(be,{hover:gt}):null,Tt=Wt?f.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:Je.left+gt.x,top:Je.top+gt.y,transform:`translate(${gt.x>.7*et?"calc(-100% - 12px)":"12px"}, ${.3*tt>gt.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},Wt):null,It=Nt.current>=0&>?f.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Ke[0],height:Ke[1],pointerEvents:"none",zIndex:2}},f.createElement("circle",{cx:gt.x+Je.left,cy:gt.y+Je.top,r:8,fill:"none",stroke:"var(--accent, #6366f1)",strokeWidth:2,strokeDasharray:"4,2"})):null;if(se){const e=Et.current;e&&u&&(e.ingest({inserts:u,bounded:!0}),e.computeScene({width:et,height:tt}));const t=null!==(o=null==e?void 0:e.scene)&&void 0!==o?o:[],n=null!==(r=null==e?void 0:e.scales)&&void 0!==r?r:null;return f.createElement("div",{className:"stream-xy-frame"+(G?" "+G:""),role:"img","aria-label":"string"==typeof Ie?Ie:"XY chart",style:{position:"relative",width:Ke[0],height:Ke[1]}},f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ke[0],height:Ke[1],style:{position:"absolute",left:0,top:0}},We,f.createElement("g",{transform:`translate(${Je.left},${Je.top})`},q&&f.createElement("rect",{x:0,y:0,width:et,height:tt,fill:q}),t.map((e,t)=>function(e,t){var n,o,r;switch(e.type){case"line":{const n=e;if(0===n.path.length)return null;const o="M"+n.path.map(([e,t])=>`${e},${t}`).join("L");return f.createElement("path",{key:"line-"+t,d:o,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity})}case"area":{const r=e;if(0===r.topPath.length)return null;const i=r.topPath.map(([e,t])=>`${e},${t}`).join("L"),a=[...r.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L");return f.createElement("path",{key:"area-"+t,d:`M${i}L${a}Z`,fill:r.style.fill||"#4e79a7",fillOpacity:null!==(o=null!==(n=r.style.fillOpacity)&&void 0!==n?n:r.style.opacity)&&void 0!==o?o:.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})}case"point":return f.createElement("circle",{key:"point-"+t,cx:e.x,cy:e.y,r:e.r,fill:e.style.fill||"#4e79a7",opacity:null!==(r=e.style.opacity)&&void 0!==r?r:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth});case"rect":return f.createElement("rect",{key:"rect-"+t,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.style.fill||"#4e79a7",opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth});case"heatcell":return f.createElement("rect",{key:"heatcell-"+t,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.fill});case"candlestick":{const n=e,o=Math.min(n.openY,n.closeY),r=Math.max(Math.abs(n.openY-n.closeY),1),i=n.isUp?n.upColor:n.downColor;return f.createElement("g",{key:"candle-"+t},f.createElement("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),f.createElement("rect",{x:n.x-n.bodyWidth/2,y:o,width:n.bodyWidth,height:r,fill:i,stroke:i,strokeWidth:1}))}default:return null}}(e,t)).filter(Boolean))),f.createElement(ae,{width:et,height:tt,totalWidth:Ke[0],totalHeight:Ke[1],margin:Je,scales:n,showAxes:de,axes:he,xLabel:ge,yLabel:fe,xFormat:ve||we,yFormat:ke||Ae,showGrid:je,title:Ie,legend:Pe,legendHoverBehavior:He,legendClickBehavior:Ne,legendHighlightedCategory:Be,legendIsolatedCategories:De,foregroundGraphics:Te,marginalGraphics:Ue,xValues:[],yValues:[],annotations:Me,svgAnnotationRules:Ce,annotationFrame:0,xAccessor:"string"==typeof d?d:"string"==typeof S?S:void 0,yAccessor:"string"==typeof h?h:"string"==typeof k?k:void 0,annotationData:null==e?void 0:e.getData(),pointNodes:null==e?void 0:e.scene.filter(e=>"point"===e.type)}))}return f.createElement("div",{ref:Qe,className:"stream-xy-frame"+(G?" "+G:""),role:"img","aria-label":"string"==typeof Ie?Ie:"XY chart",tabIndex:0,style:{position:"relative",width:_?"100%":Ke[0],height:F?"100%":Ke[1]},onMouseMove:nt?Dt:void 0,onMouseLeave:nt?Ht:void 0,onKeyDown:Bt},We&&f.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Ke[0],height:Ke[1],pointerEvents:"none"}},We),f.createElement("canvas",{ref:ot,style:{position:"absolute",left:0,top:0}}),f.createElement("canvas",{ref:rt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),f.createElement(ae,{width:et,height:tt,totalWidth:Ke[0],totalHeight:Ke[1],margin:Je,scales:ct,showAxes:de,axes:he,xLabel:ge,yLabel:fe,xFormat:ve||we,yFormat:ke||Ae,showGrid:je,title:Ie,legend:Pe,legendHoverBehavior:He,legendClickBehavior:Ne,legendHighlightedCategory:Be,legendIsolatedCategories:De,foregroundGraphics:Te,marginalGraphics:Ue,xValues:mt,yValues:bt,annotations:Me,svgAnnotationRules:Ce,annotationFrame:st,xAccessor:"string"==typeof d?d:"string"==typeof S?S:void 0,yAccessor:"string"==typeof h?h:"string"==typeof k?k:void 0,annotationData:null===(i=Et.current)||void 0===i?void 0:i.getData(),pointNodes:null===(a=Et.current)||void 0===a?void 0:a.scene.filter(e=>"point"===e.type)}),($e||ze)&&f.createElement(xe,{width:et,height:tt,totalWidth:Ke[0],totalHeight:Ke[1],margin:Je,dimension:null!==(s=null==$e?void 0:$e.dimension)&&void 0!==s?s:"xy",scales:ct,onBrush:null!=ze?ze:()=>{}}),(null==Ge?void 0:Ge.showBadge)&&f.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Ge.badgePosition?{top:4,left:4}:"bottom-left"===Ge.badgePosition?{bottom:4,left:4}:"bottom-right"===Ge.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:yt?"#dc3545":"#28a745",color:"white"})},yt?"STALE":"LIVE"),It,Tt)});function we(e,t){const{columns:n,config:o,resolvePieceStyle:r}=e,i=[],a=Math.min(t.width,t.height)/2-4,s="donut"===o.chartType?o.innerRadius||60:0,l=-Math.PI/2+(o.startAngle||0)*Math.PI/180,c=2*Math.PI;for(const e of Object.values(n)){const t=l+e.pctStart*c,n=l+(e.pctStart+e.pct)*c,o=r(e.pieceData[0],e.name);i.push({type:"wedge",cx:0,cy:0,innerRadius:s,outerRadius:a,startAngle:t,endAngle:n,style:o,datum:e.pieceData,category:e.name})}return i}function Ae(e){var t,n,o;const i=e.length,a=e[0],s=e[i-1];return{n:i,min:a,q1:null!==(t=r.quantile(e,.25))&&void 0!==t?t:a,median:null!==(n=r.quantile(e,.5))&&void 0!==n?n:(a+s)/2,q3:null!==(o=r.quantile(e,.75))&&void 0!==o?o:s,max:s,mean:e.reduce((e,t)=>e+t,0)/i}}ke.displayName="StreamXYFrame";const Ee={bar:function(e,t){const{scales:n,columns:o,config:r,getR:i,getStack:a,resolvePieceStyle:s}=e,{r:l,projection:c}=n,u=[],d="vertical"===c,h="horizontal"===c,g=r.normalize;for(const e of Object.values(o)){const t=new Map;for(const n of e.pieceData){const e=a?a(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const o=t.get(e);o.total+=i(n),o.pieces.push(n)}let n=0;if(g)for(const e of t.values())n+=Math.abs(e.total);let o=0,r=0;for(const[i,c]of t){let t=c.total;g&&n>0&&(t/=n);const f=s(c.pieces[0],a?i:e.name),y=Object.assign(Object.assign({},c.pieces[0]),{__aggregateValue:c.total,__pieceCount:c.pieces.length,category:e.name});if(d){const n=l(0>t?r:o+t),a=0>t?l(r+t)-l(r):l(o)-l(o+t);u.push(E(e.x,n,e.width,Math.abs(a),f,y,i)),0>t?r+=t:o+=t}else if(h){const n=l(0>t?r+t:o),a=0>t?l(r)-l(r+t):l(o+t)-l(o);u.push(E(n,e.x,Math.abs(a),e.width,f,y,i)),0>t?r+=t:o+=t}}}return u},clusterbar:function(e,t){const{scales:n,columns:o,getR:r,getGroup:i,resolvePieceStyle:a}=e,{r:s,projection:l}=n,c=[],u="vertical"===l,d=[],h=new Set;for(const e of Object.values(o))for(const t of e.pieceData){const e=i?i(t):"_default";h.has(e)||(h.add(e),d.push(e))}const g=d.length||1;for(const e of Object.values(o)){const t=e.width/g,n=new Map;for(const t of e.pieceData){const e=i?i(t):"_default";n.has(e)||n.set(e,[]),n.get(e).push(t)}for(let o=0;d.length>o;o++){const i=n.get(d[o])||[];for(const n of i){const i=r(n),l=a(n,e.name);if(u){const r=e.x+o*t,a=s(0),u=s(i);c.push(E(r,Math.min(a,u),t,Math.abs(a-u),l,n,d[o]))}else{const r=e.x+o*t,a=s(0),u=s(i);c.push(E(Math.min(a,u),r,Math.abs(u-a),t,l,n,d[o]))}}}}return c},point:function(e,t){var n,o;const{scales:r,columns:i,getR:a,multiScales:s,resolvePieceStyle:l}=e,{r:c,projection:u}=r,d=[],h="vertical"===u,g="radial"===u,f=s.length>0,y=2*Math.PI,p=-Math.PI/2;for(const e of Object.values(i))for(const t of e.pieceData){const r=null!==(n=t.__rIndex)&&void 0!==n?n:0,i=null!==(o=t.__rValue)&&void 0!==o?o:a(t),u=f&&s[r]||c,m=l(t,e.name),v=m.r||5;let b,x;if(g){const t=p+(e.pctStart+e.pct/2)*y,n=u(i);b=Math.cos(t)*n,x=Math.sin(t)*n}else h?(b=e.middle,x=u(i)):(b=u(i),x=e.middle);d.push({type:"point",x:b,y:x,r:v,style:m,datum:t})}return d},swarm:function(e,t){const{scales:n,columns:o,getR:r,resolvePieceStyle:i}=e,{r:a,projection:s}=n,l=[],c="vertical"===s;for(const e of Object.values(o)){const t=e.width/2;for(let n=0;e.pieceData.length>n;n++){const o=e.pieceData[n],s=r(o),u=i(o,e.name),d=u.r||4,h=(7919*n%100/100-.5)*t*.8,g=c?e.middle+h:a(s),f=c?a(s):e.middle+h;l.push({type:"point",x:g,y:f,r:d,style:u,datum:o})}}return l},pie:we,donut:we,boxplot:function(e,t){var n,o,i,a,s;const{scales:l,columns:c,config:u,getR:d,resolveSummaryStyle:h}=e,{r:g,projection:f}=l,y=[],p="vertical"===f,m=!1!==u.showOutliers;for(const e of Object.values(c)){const t=e.pieceData.map(e=>d(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===t.length)continue;const l=t[0],c=t[t.length-1],u=null!==(n=r.quantile(t,.25))&&void 0!==n?n:l,f=null!==(o=r.quantile(t,.5))&&void 0!==o?o:(l+c)/2,v=null!==(i=r.quantile(t,.75))&&void 0!==i?i:c,b=v-u,x=u-1.5*b,k=v+1.5*b,w=null!==(a=t.find(e=>e>=x))&&void 0!==a?a:l,A=null!==(s=[...t].reverse().find(e=>k>=e))&&void 0!==s?s:c,E=h(e.pieceData[0],e.name),S=[];if(m)for(const t of e.pieceData){const n=d(t);if(x>n||n>k){const o=p?e.middle:g(n),r=p?g(n):e.middle;S.push({px:o,py:r,value:n,datum:t})}}if(y.push({type:"boxplot",x:p?e.middle:0,y:p?0:e.middle,projection:p?"vertical":"horizontal",columnWidth:.6*e.width,minPos:g(w),q1Pos:g(u),medianPos:g(f),q3Pos:g(v),maxPos:g(A),stats:{n:t.length,min:w,q1:u,median:f,q3:v,max:A,mean:t.reduce((e,t)=>e+t,0)/t.length},style:E,datum:e.pieceData,category:e.name,outliers:S}),m)for(const e of S)y.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:E.fill||"#999",opacity:.6},datum:e.datum})}return y},violin:function(e,t){var n,o,i;const{scales:a,columns:s,config:l,getR:c,resolveSummaryStyle:u}=e,{r:d,projection:h}=a,g=[],f="vertical"===h,y=l.bins||20,p=!1!==l.showIQR;for(const e of Object.values(s)){const t=e.pieceData.map(e=>c(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const a=t[0],s=t[t.length-1],l=(s-a)/y||1,h=Array(y).fill(0);for(const e of t)h[Math.min(Math.floor((e-a)/l),y-1)]++;const m=Math.max(...h,1),v=e.width/2*.9;let b="";if(f){for(let t=0;y>t;t++){const n=d(a+(t+.5)*l),o=h[t]/m*v;b+=0===t?`M ${e.middle+o} ${n}`:` L ${e.middle+o} ${n}`}for(let t=y-1;t>=0;t--){const n=d(a+(t+.5)*l);b+=` L ${e.middle-h[t]/m*v} ${n}`}b+=" Z"}else{for(let t=0;y>t;t++){const n=d(a+(t+.5)*l),o=h[t]/m*v;b+=0===t?`M ${n} ${e.middle-o}`:` L ${n} ${e.middle-o}`}for(let t=y-1;t>=0;t--)b+=` L ${d(a+(t+.5)*l)} ${e.middle+h[t]/m*v}`;b+=" Z"}const x=u(e.pieceData[0],e.name);let k;if(p&&t.length>=4){const l=null!==(n=r.quantile(t,.25))&&void 0!==n?n:a,c=null!==(o=r.quantile(t,.5))&&void 0!==o?o:(a+s)/2,u=null!==(i=r.quantile(t,.75))&&void 0!==i?i:s;k={q1Pos:d(l),medianPos:d(c),q3Pos:d(u),centerPos:e.middle,isVertical:f}}const w=f?{x:e.x,y:Math.min(d(s),d(a)),width:e.width,height:Math.abs(d(s)-d(a))}:{x:Math.min(d(a),d(s)),y:e.x,width:Math.abs(d(s)-d(a)),height:e.width};g.push({type:"violin",pathString:b,translateX:0,translateY:0,bounds:w,iqrLine:k,stats:Ae(t),style:x,datum:e.pieceData,category:e.name})}return g},histogram:function(e,t){const{scales:n,columns:o,config:r,getR:i,resolveSummaryStyle:a}=e,{r:s}=n,l=[],c=r.bins||25,u=r.normalize;for(const e of Object.values(o)){const t=e.pieceData.map(e=>i(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const n=Math.min(...t),o=(Math.max(...t)-n)/c||1,r=Array(c).fill(0);for(const e of t)r[Math.min(Math.floor((e-n)/o),c-1)]++;const d=t.length,h=Math.max(...r,1),g=a(e.pieceData[0],e.name);for(let t=0;c>t;t++){if(0===r[t])continue;const i=(u?r[t]/d:r[t]/h)*e.width*.9,a=s(n+t*o),c=s(n+(t+1)*o);l.push(E(Math.min(a,c),e.x+e.width-i,Math.abs(c-a),i,g,{bin:t,count:r[t],range:[n+t*o,n+(t+1)*o],category:e.name},e.name))}}return l},ridgeline:function(e,t){var n;const{scales:o,columns:r,config:i,getR:a,resolveSummaryStyle:s}=e,{r:l,projection:c}=o,u=[],d=i.bins||20,h="horizontal"===c,g=i.amplitude||1.5;for(const e of Object.values(r)){const t=e.pieceData.map(e=>a(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const o=t[0],r=t[t.length-1],i=(r-o)/d||1,c=Array(d).fill(0);for(const e of t)c[Math.min(Math.floor((e-o)/i),d-1)]++;const f=Math.max(...c,1),y=s(e.pieceData[0],e.name),p=e.width*g;let m="";if(h){const t=e.x+e.width;m=`M ${l(o)} ${t}`;for(let e=0;d>e;e++)m+=` L ${l(o+(e+.5)*i)} ${t-c[e]/f*p}`;m+=` L ${l(r)} ${t} Z`}else{const t=e.x;m=`M ${t} ${l(o)}`;for(let e=0;d>e;e++){const n=l(o+(e+.5)*i);m+=` L ${t+c[e]/f*p} ${n}`}m+=` L ${t} ${l(r)} Z`}const v=h?{x:Math.min(l(o),l(r)),y:e.x,width:Math.abs(l(r)-l(o)),height:e.width}:{x:e.x,y:Math.min(l(r),l(o)),width:e.width,height:Math.abs(l(r)-l(o))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:v,stats:Ae(t),style:Object.assign(Object.assign({},y),{fillOpacity:null!==(n=y.fillOpacity)&&void 0!==n?n:.5}),datum:e.pieceData,category:e.name})}return u},timeline:function(e,t){const{scales:n,columns:o,getRawRange:r,resolvePieceStyle:i}=e,{r:a,projection:s}=n,l=[],c="horizontal"===s;for(const e of Object.values(o))for(const t of e.pieceData){const n=r(t);if(!n)continue;const[o,s]=n,u=i(t,e.name);if(c){const n=a(Math.min(o,s)),r=a(Math.max(o,s));l.push(E(n,e.x,r-n,e.width,u,t,e.name))}else{const n=a(Math.max(o,s)),r=a(Math.min(o,s));l.push(E(e.x,n,e.width,r-n,u,t,e.name))}}return l}};class Se{constructor(e){this.rExtent=new b,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=e,this.buffer=new v(e.windowSize),this.getO=O(e.oAccessor||e.categoryAccessor,"category");const t="streaming"===e.runtimeMode,n=e.rAccessor;Array.isArray(n)?(this.rAccessors=n.map(e=>L(e,"value")),this.getR=this.rAccessors[0],this.rExtents=n.map(()=>new b)):(this.getR=L(t&&(e.timeAccessor||e.valueAccessor)&&e.valueAccessor||n,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=O(e.stackBy),this.getGroup=O(e.groupBy),this.getColor=O(e.colorAccessor),this.getConnector=O(e.connectorAccessor),e.pulse&&(this.timestampBuffer=new v(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,e.bounded){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(n)),this.pushValueExtent(n)}else for(const n of e.inserts){const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(n)),this.pushValueExtent(n),null!=e&&this.evictValueExtent(e)}return!0}pushValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.push(t[0]),this.rExtent.push(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].push(this.rAccessors[t](e));this.rExtent.push(this.getR(e))}else this.rExtent.push(this.getR(e))}evictValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.evict(t[0]),this.rExtent.evict(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].evict(this.rAccessors[t](e));this.rExtent.evict(this.getR(e))}else this.rExtent.evict(this.getR(e))}getRawRange(e){const t=this.config.rAccessor;if(!t)return null;const n="function"==typeof t?t(e):e[t];return Array.isArray(n)&&n.length>=2?[+n[0],+n[1]]:null}computeScene(e){const{config:t,buffer:n}=this;if(0===n.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(n,this.getR);const r=n.toArray(),i=t.projection||"vertical",a=t.oExtent||this.resolveCategories(r),s=this.computeValueDomain(r,a),l="horizontal"===i,c=null!=t.barPadding?t.barPadding/("vertical"===i?e.width:e.height):.1;let u,d;if("radial"===i){u=o.scaleBand().domain(a).range([0,1]).padding(0);const n=Math.min(e.width,e.height)/2,r=t.innerRadius||0;d=o.scaleLinear().domain(s).range([r,n])}else l?(u=o.scaleBand().domain(a).range([0,e.height]).padding(c),d=o.scaleLinear().domain(s).range([0,e.width])):(u=o.scaleBand().domain(a).range([0,e.width]).padding(c),d=o.scaleLinear().domain(s).range([e.height,0]));this.scales={o:u,r:d,projection:i},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((r,i)=>{const a=this.rExtents[i];a.dirty&&a.recalculate(n,r);let[s,c]=a.extent;s===1/0&&(s=0,c=1);const u=c-s,d=u>0?u*(t.extentPadding||.05):1;return s-=d,c+=d,s>0&&(s=0),l?o.scaleLinear().domain([s,c]).range([0,e.width]):o.scaleLinear().domain([s,c]).range([e.height,0])}):[];let h=r;this.rAccessors.length>1&&(h=r.flatMap(e=>this.rAccessors.map((t,n)=>Object.assign(Object.assign({},e),{__rIndex:n,__rValue:t(e),__rName:this.resolveRAccessorName(n)})))),this.columns=this.buildColumns(h,a,u,i,e),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(h,e),this.config.decay&&this.applyDecay(this.scene,r),this.config.pulse&&this.applyPulse(this.scene,r),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(e){const t=Array.isArray(this.config.rAccessor)?this.config.rAccessor[e]:this.config.rAccessor;return"string"==typeof t?t:"value"+e}resolveCategories(e){const t=Array.from(this.categories),n=this.config.oSort;if("streaming"===this.config.runtimeMode&&void 0===n)return t;if(!1===n)return t;if("function"==typeof n)return t.sort(n);const o=new Map;for(const t of e){const e=this.getO(t);o.set(e,(o.get(e)||0)+Math.abs(this.getR(t)))}return t.sort("asc"===n?(e,t)=>(o.get(e)||0)-(o.get(t)||0):(e,t)=>(o.get(t)||0)-(o.get(e)||0))}computeValueDomain(e,t){var n,o;const r=this.config.chartType,i=this.config.extentPadding||.05;if("radial"===this.config.projection&&("pie"===r||"donut"===r))return[0,1];let a=0,s=0;if("bar"===r&&this.getStack){const t=new Map,n=new Map;for(const o of e){const e=this.getO(o),r=this.getR(o);0>r?n.set(e,(n.get(e)||0)+r):t.set(e,(t.get(e)||0)+r)}for(const e of t.values())e>s&&(s=e);for(const e of n.values())a>e&&(a=e)}else if("bar"===r){const t=new Map;for(const n of e){const e=this.getO(n),o=this.getR(n);t.set(e,(t.get(e)||0)+o)}for(const e of t.values())e>s&&(s=e),a>e&&(a=e)}else if("clusterbar"===r)for(const t of e){const e=this.getR(t);e>s&&(s=e),a>e&&(a=e)}else{const e=this.rExtent.extent[0],t=this.rExtent.extent[1];e!==1/0&&(a=e),t!==-1/0&&(s=t)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(a=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(s=this.config.rExtent[1]));const l=s-a,c=l>0?l*i:1;return(null===(n=this.config.rExtent)||void 0===n?void 0:n[0])||(a-=c),(null===(o=this.config.rExtent)||void 0===o?void 0:o[1])||(s+=c),"bar"!==r&&"clusterbar"!==r||(a>0&&(a=0),0>s&&(s=0)),[a,s]}buildColumns(e,t,n,o,r){var i;const a={},s=new Map;for(const t of e){const e=this.getO(t);s.has(e)||s.set(e,[]),s.get(e).push(t)}let l=0;if("radial"===o)for(const t of e)l+=Math.abs(this.getR(t));const c=this.config.dynamicColumnWidth;let u=null;if(c&&"radial"!==o){u=new Map;let e=0;for(const n of t){const t=s.get(n)||[];let o;o="string"==typeof c?t.reduce((e,t)=>e+(Number(t[c])||0),0):c(t),u.set(n,o),e+=o}const i=("horizontal"===o?r.height:r.width)-n.padding()*n.step()*t.length;if(e>0)for(const[t,n]of u)u.set(t,n/e*i)}let d=0,h=0;for(const e of t){const t=s.get(e)||[],o=t.reduce((e,t)=>e+Math.abs(this.getR(t)),0),r=l>0?o/l:0;let c,g;u?(c=h,g=u.get(e)||n.bandwidth(),h+=g+n.padding()*n.step()):(c=null!==(i=n(e))&&void 0!==i?i:0,g=n.bandwidth()),a[e]={name:e,x:c,y:0,width:g,middle:c+g/2,padding:n.padding()*n.step(),pieceData:t,pct:r,pctStart:d},d+=r}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:(e,t)=>this.resolvePieceStyle(e,t),resolveSummaryStyle:(e,t)=>this.resolveSummaryStyle(e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];const n=this.getSceneContext(),o=Ee[this.config.chartType];let r=o?o(n,t):[];if(this.getConnector&&this.scales){const e=function(e,t){const{scales:n,config:o,getConnector:r,getO:i}=e;if(!r||!n)return[];const a=[],{projection:s}=n,l=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const n=r(t);if(!n)continue;let o,a;"point"===e.type?(o=e.x,a=e.y):(o=e.x+e.w/2,a=e.y+("vertical"===s?0:e.h/2)),l.has(n)||l.set(n,[]),l.get(n).push({x:o,y:a,datum:t,category:i(t)})}const c=n.o.domain(),u=o.connectorStyle;for(const[e,t]of l)if(t.length>=2){t.sort((e,t)=>c.indexOf(e.category)-c.indexOf(t.category));for(let n=0;t.length-1>n;n++){const o=t[n],r=t[n+1],i="function"==typeof u?u(o.datum):u||{stroke:"#999",strokeWidth:1,opacity:.5};a.push({type:"connector",x1:o.x,y1:o.y,x2:r.x,y2:r.y,style:i,datum:o.datum,group:e})}}return a}(n,r);r=[...e,...r]}return r}resolvePieceStyle(e,t){return"function"==typeof this.config.pieceStyle?this.config.pieceStyle(e,t):this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&t?{fill:this.config.barColors[t]||"#007bff"}:t?{fill:this.getColorFromScheme(t)}:{fill:"#007bff"}}getColorFromScheme(e){this._colorSchemeMap||(this._colorSchemeMap=new Map);const t=this._colorSchemeMap.get(e);if(t)return t;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],o=n[this._colorSchemeIndex%n.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(e,o),o}resolveSummaryStyle(e,t){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(e,t):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(e,t){var n,o,r;const i=this.config.decay;if(!i||1>=t)return 1;const a=null!==(n=i.minOpacity)&&void 0!==n?n:.1,s=t-1-e;switch(i.type){case"linear":return a+(1-s/(t-1))*(1-a);case"exponential":{const e=null!==(o=i.halfLife)&&void 0!==o?o:t/2;return a+Math.pow(.5,s/e)*(1-a)}case"step":return(null!==(r=i.stepThreshold)&&void 0!==r?r:.5*t)>s?1:a;default:return 1}}applyDecay(e,t){var n,o;if(!this.config.decay)return;const r=t.length;if(1>=r)return;const i=new Map;for(let e=0;t.length>e;e++)i.set(t[e],e);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=i.get(t.datum);if(null==e)continue;const a=this.computeDecayOpacity(e,r),s=null!==(o=null===(n=t.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:s*a})}}applyPulse(e,t){var n,o,r;if(!this.config.pulse||!this.timestampBuffer)return;const i="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(n=this.config.pulse.duration)&&void 0!==n?n:500,s=null!==(o=this.config.pulse.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",l=null!==(r=this.config.pulse.glowRadius)&&void 0!==r?r:4,c=new Map;for(let e=0;t.length>e;e++)c.set(t[e],e);for(const n of e){if("connector"===n.type||"violin"===n.type||"boxplot"===n.type)continue;if("wedge"===n.type){const e=n.category;if(!e)continue;let o=0;for(let n=0;t.length>n;n++){const r=t[n],s=this.config.oAccessor;if(("function"==typeof s?s(r):r[s||"category"])!==e)continue;const l=this.timestampBuffer.get(n);if(null==l)continue;const c=i-l;if(a>c){const e=1-c/a;e>o&&(o=e)}}o>0&&(n._pulseIntensity=o,n._pulseColor=s);continue}const e=c.get(n.datum);if(null==e)continue;const o=this.timestampBuffer.get(e);if(null==o)continue;const r=i-o;a>r&&(n._pulseIntensity=1-r/a,n._pulseColor=s,n._pulseGlowRadius=l)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}snapshotPositions(){var e,t;this.prevPositionMap.clear();for(let n=0;this.scene.length>n;n++){const o=this.scene[n];if("point"===o.type)this.prevPositionMap.set("p:"+n,{x:o.x,y:o.y,r:o.r});else if("rect"===o.type){const r=`r:${o.group||""}:${null!==(t=null===(e=o.datum)||void 0===e?void 0:e.category)&&void 0!==t?t:n}`;this.prevPositionMap.set(r,{x:o.x,y:o.y,w:o.w,h:o.h})}}}startTransition(){var e,t,n,o,r;if(!this.config.transition||0===this.prevPositionMap.size)return;const i=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;let a=!1;for(let e=0;this.scene.length>e;e++){const i=this.scene[e];let s=null;if("point"===i.type?s="p:"+e:"rect"===i.type&&(s=`r:${i.group||""}:${null!==(n=null===(t=i.datum)||void 0===t?void 0:t.category)&&void 0!==n?n:e}`),!s)continue;const l=this.prevPositionMap.get(s);l&&("point"===i.type?l.x===i.x&&l.y===i.y||(i._targetX=i.x,i._targetY=i.y,i.x=l.x,i.y=l.y,a=!0):"rect"===i.type&&(l.x===i.x&&l.y===i.y&&l.w===i.w&&l.h===i.h||(i._targetX=i.x,i._targetY=i.y,i._targetW=i.w,i._targetH=i.h,i.x=l.x,i.y=l.y,i.w=null!==(o=l.w)&&void 0!==o?o:i.w,i.h=null!==(r=l.h)&&void 0!==r?r:i.h,a=!0)))}a&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:i})}advanceTransition(e){var t,n,o;if(!this.activeTransition)return!1;const r=Math.min((e-this.activeTransition.startTime)/this.activeTransition.duration,1),i="linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?r:1-Math.pow(1-r,3);for(let e=0;this.scene.length>e;e++){const t=this.scene[e];if("point"===t.type){if(void 0===t._targetX)continue;const n=this.prevPositionMap.get("p:"+e);if(!n)continue;t.x=n.x+(t._targetX-n.x)*i,t.y=n.y+(t._targetY-n.y)*i}else if("rect"===t.type){if(void 0===t._targetX)continue;const r=`r:${t.group||""}:${null!==(o=null===(n=t.datum)||void 0===n?void 0:n.category)&&void 0!==o?o:e}`,a=this.prevPositionMap.get(r);if(!a)continue;t.x=a.x+(t._targetX-a.x)*i,t.y=a.y+(t._targetY-a.y)*i,void 0!==a.w&&(t.w=a.w+(t._targetW-a.w)*i,t.h=a.h+(t._targetH-a.h)*i)}}if(r>=1){for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}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(e){e.colorScheme!==this.config.colorScheme&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),Object.assign(this.config,e)}}function Le(e,t,n){const o=C(t,n,e);return o.hit?{datum:e.datum,x:o.cx,y:e.y,distance:0,category:e.group}:null}function Oe(e,t,n){const o=t-e.x,r=n-e.y,i=Math.sqrt(o*o+r*r);return i>Math.max(e.r,5)?null:{datum:e.datum,x:e.x,y:e.y,distance:i}}function Me(e,t,n){const o=t-e.cx,r=n-e.cy,i=Math.sqrt(o*o+r*r);if(e.innerRadius>i||i>e.outerRadius)return null;const a=j(Math.atan2(r,o)),s=j(e.startAngle),l=j(e.endAngle);if(!(s>l?a>=s||l>=a:a>=s&&l>=a))return null;const c=(e.startAngle+e.endAngle)/2,u=(e.innerRadius+e.outerRadius)/2;return{datum:e.datum,x:e.cx+Math.cos(c)*u,y:e.cy+Math.sin(c)*u,distance:0,category:e.category}}function Ce(e,t,n){const o=e.columnWidth/2;if("vertical"===e.projection){if(!(e.x-o>t||t>e.x+o||Math.min(e.minPos,e.maxPos)>n||n>Math.max(e.minPos,e.maxPos)))return{datum:e.datum,x:e.x,y:e.medianPos,distance:0,category:e.category,stats:e.stats}}else{const r=e.y-o,i=e.y+o;if(!(Math.min(e.minPos,e.maxPos)>t||t>Math.max(e.minPos,e.maxPos)||r>n||n>i))return{datum:e.datum,x:e.medianPos,y:e.y,distance:0,category:e.category,stats:e.stats}}return null}function je(e,t,n){if(!e.bounds)return null;const{x:o,y:r,width:i,height:a}=e.bounds;return o>t||t>o+i||r>n||n>r+a?null:{datum:e.datum,x:o+i/2,y:r+a/2,distance:0,category:e.category,stats:e.stats}}function Pe(e){return Math.round(100*e)/100+""}function He(t){const{width:n,height:o,totalWidth:r,totalHeight:i,margin:a,scales:s,showAxes:l,oLabel:c,rLabel:u,oFormat:d,rFormat:h,showGrid:g,title:y,legend:p,legendHoverBehavior:m,legendClickBehavior:v,legendHighlightedCategory:b,legendIsolatedCategories:x,foregroundGraphics:k,annotations:w,svgAnnotationRules:A,annotationFrame:E,xAccessor:S,yAccessor:L,annotationData:O,children:M}=t,C="radial"===(null==s?void 0:s.projection),j="horizontal"===(null==s?void 0:s.projection),P=e.useMemo(()=>l&&s&&!C?s.o.domain().map(e=>{var t;return{value:e,pixel:(null!==(t=s.o(e))&&void 0!==t?t:0)+s.o.bandwidth()/2,label:d?d(e):e}}):[],[l,s,d,C]),H=e.useMemo(()=>l&&s&&!C?s.r.ticks(5).map(e=>({value:e,pixel:s.r(e),label:(h||Pe)(e)})):[],[l,s,h,C]),N=e.useMemo(()=>{if(!w||0===w.length)return null;const e=ne(),t="horizontal"===(null==s?void 0:s.projection),r=(null==s?void 0:s.o)?e=>{var t;return(null!==(t=s.o(e))&&void 0!==t?t:0)+s.o.bandwidth()/2}:null,i={scales:s?{x:t?s.r:r||s.r,y:t&&r||s.r,time:s.r,value:s.r}:null,timeAxis:"x",xAccessor:S,yAccessor:L,width:n,height:o,data:O,frameType:"ordinal"};return w.map((t,n)=>{if(A){const o=A(t,n,i);return null!=o?o:e(t,n,i)}return e(t,n,i)}).filter(Boolean)},[w,A,n,o,E,S,L,O]);return l||y||p||k||N&&N.length>0||g||M?f.createElement("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},f.createElement("g",{transform:`translate(${a.left},${a.top})`},g&&s&&!C&&f.createElement("g",{className:"ordinal-grid"},H.map((e,t)=>f.createElement("line",{key:"grid-"+t,x1:j?e.pixel:0,y1:j?0:e.pixel,x2:j?e.pixel:n,y2:j?o:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),l&&s&&!C&&f.createElement("g",{className:"ordinal-axes"},j?f.createElement(f.Fragment,null,f.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),P.map((e,t)=>f.createElement("g",{key:"cat-"+t,transform:`translate(0,${e.pixel})`},f.createElement("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),f.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),c&&f.createElement("text",{x:15-a.left,y:o/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-a.left}, ${o/2})`,style:{userSelect:"none"}},c),f.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),H.map((e,t)=>f.createElement("g",{key:"val-"+t,transform:`translate(${e.pixel},${o})`},f.createElement("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),f.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),u&&f.createElement("text",{x:n/2,y:o+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},u)):f.createElement(f.Fragment,null,f.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),P.map((e,t)=>f.createElement("g",{key:"cat-"+t,transform:`translate(${e.pixel},${o})`},f.createElement("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),f.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),c&&f.createElement("text",{x:n/2,y:o+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},c),f.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),H.map((e,t)=>f.createElement("g",{key:"val-"+t,transform:`translate(0,${e.pixel})`},f.createElement("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),f.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),u&&f.createElement("text",{x:15-a.left,y:o/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-a.left}, ${o/2})`,style:{userSelect:"none"}},u))),N,k,M),y&&f.createElement("text",{x:r/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof y?y:null),p&&f.createElement("g",{transform:`translate(${r-a.right+10}, ${a.top})`},function(e){return"object"==typeof e&&null!==e&&!f.isValidElement(e)&&"legendGroups"in e}(p)?f.createElement(q,{legendGroups:p.legendGroups,title:"",width:100,customHoverBehavior:m,customClickBehavior:v,highlightedCategory:b,isolatedCategories:x}):p)):null}function Ne(e,t){e.beginPath(),t.innerRadius>0?(e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerRadius,t.endAngle,t.startAngle,!0)):(e.moveTo(t.cx,t.cy),e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle)),e.closePath()}const Be=(e,t,n,o)=>{var r,i;const a=t.filter(e=>"wedge"===e.type);for(const t of a)Ne(e,t),e.globalAlpha=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:1,e.fillStyle=t.style.fill||"#007bff",e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0&&(Ne(e,t),e.globalAlpha=.35*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill()),e.globalAlpha=1},De=(e,t,n,o)=>{var r,i;const a=t.filter(e=>"violin"===e.type);for(const t of a){e.save(),(t.translateX||t.translateY)&&e.translate(t.translateX,t.translateY);const n=new Path2D(t.pathString);if(e.globalAlpha=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.6,e.fillStyle=t.style.fill||"#007bff",e.fill(n),e.globalAlpha=1,t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke(n)),t.iqrLine){e.strokeStyle="#333",e.lineWidth=2,e.globalAlpha=.8;const n=t.iqrLine.centerPos,o=!1!==t.iqrLine.isVertical;e.beginPath(),o?(e.moveTo(n,t.iqrLine.q1Pos),e.lineTo(n,t.iqrLine.q3Pos)):(e.moveTo(t.iqrLine.q1Pos,n),e.lineTo(t.iqrLine.q3Pos,n)),e.stroke(),e.beginPath(),o?e.arc(n,t.iqrLine.medianPos,3,0,2*Math.PI):e.arc(t.iqrLine.medianPos,n,3,0,2*Math.PI),e.fillStyle="#fff",e.fill(),e.strokeStyle="#333",e.lineWidth=1,e.stroke(),e.globalAlpha=1}e.restore()}},We=(e,t,n,o)=>{var r,i,a;const s=t.filter(e=>"connector"===e.type);if(0===s.length)return;const l=new Map;for(const e of s){const t=e.group||"_default";l.has(t)||l.set(t,[]),l.get(t).push(e)}for(const[,t]of l){if(0===t.length)continue;const n=t[0].style;if(n.fill&&"none"!==n.fill){e.beginPath(),e.moveTo(t[0].x1,t[0].y1);for(const n of t)e.lineTo(n.x2,n.y2);e.closePath(),e.globalAlpha=null!==(i=null!==(r=n.fillOpacity)&&void 0!==r?r:n.opacity)&&void 0!==i?i:.3,e.fillStyle=n.fill,e.fill(),e.globalAlpha=1}for(const n of t)e.beginPath(),e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.strokeStyle=n.style.stroke||n.style.fill||"#999",e.lineWidth=n.style.strokeWidth||1,e.globalAlpha=null!==(a=n.style.opacity)&&void 0!==a?a:.5,e.stroke(),e.globalAlpha=1}},Te=e=>[We,...e],Ie={bar:Te([ge]),clusterbar:Te([ge]),point:Te([he]),swarm:Te([he]),pie:[Be],donut:[Be],boxplot:Te([(e,t,n,o)=>{var r,i;const a=t.filter(e=>"boxplot"===e.type);for(const t of a){const n=t.columnWidth/2,o="vertical"===t.projection,a=t.style.fill||"#007bff",s=t.style.stroke||"#333",l=t.style.strokeWidth||1,c=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.6;if(e.save(),e.strokeStyle=s,e.lineWidth=l,e.beginPath(),o?(e.moveTo(t.x,t.minPos),e.lineTo(t.x,t.maxPos)):(e.moveTo(t.minPos,t.y),e.lineTo(t.maxPos,t.y)),e.stroke(),e.beginPath(),o?(e.moveTo(t.x-.4*n,t.minPos),e.lineTo(t.x+.4*n,t.minPos),e.moveTo(t.x-.4*n,t.maxPos),e.lineTo(t.x+.4*n,t.maxPos)):(e.moveTo(t.minPos,t.y-.4*n),e.lineTo(t.minPos,t.y+.4*n),e.moveTo(t.maxPos,t.y-.4*n),e.lineTo(t.maxPos,t.y+.4*n)),e.stroke(),e.globalAlpha=c,e.fillStyle=a,o){const o=Math.min(t.q1Pos,t.q3Pos),r=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(t.x-n,o,t.columnWidth,r),e.globalAlpha=1,e.strokeRect(t.x-n,o,t.columnWidth,r)}else{const o=Math.min(t.q1Pos,t.q3Pos),r=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(o,t.y-n,r,t.columnWidth),e.globalAlpha=1,e.strokeRect(o,t.y-n,r,t.columnWidth)}e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),o?(e.moveTo(t.x-n,t.medianPos),e.lineTo(t.x+n,t.medianPos)):(e.moveTo(t.medianPos,t.y-n),e.lineTo(t.medianPos,t.y+n)),e.stroke(),e.restore()}},he]),violin:Te([De]),histogram:Te([ge]),ridgeline:Te([De]),timeline:Te([ge])},Re={top:50,right:40,bottom:60,left:70},$e={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:"4px",fontSize:"13px",lineHeight:"1.4",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function ze({hover:e}){var t,n,o,r;const i=e.data||{},a=e.stats,s=e.category;if(Array.isArray(i)){const e=s||(null===(t=i[0])||void 0===t?void 0:t.category)||"";if(a)return f.createElement("div",{className:"semiotic-tooltip",style:$e},e&&f.createElement("div",{style:{fontWeight:"bold"}},e+""),f.createElement("div",null,"n = ",a.n),f.createElement("div",null,"Min: ",a.min.toLocaleString()),f.createElement("div",null,"Q1: ",a.q1.toLocaleString()),f.createElement("div",null,"Median: ",a.median.toLocaleString()),f.createElement("div",null,"Q3: ",a.q3.toLocaleString()),f.createElement("div",null,"Max: ",a.max.toLocaleString()),f.createElement("div",{style:{opacity:.8}},"Mean: ",a.mean.toLocaleString(void 0,{maximumFractionDigits:2})));const n=i.length;return f.createElement("div",{className:"semiotic-tooltip",style:$e},e&&f.createElement("div",{style:{fontWeight:"bold"}},e+""),f.createElement("div",null,n," items"))}if(null!=i.bin&&null!=i.count){const e=i.range||[];return f.createElement("div",{className:"semiotic-tooltip",style:$e},i.category&&f.createElement("div",{style:{fontWeight:"bold"}},i.category+""),f.createElement("div",null,"Count: ",i.count),2===e.length&&f.createElement("div",{style:{opacity:.8}},Number(e[0]).toFixed(1)," – ",Number(e[1]).toFixed(1)))}const l=i.category||i.name||i.group||i.__rName||"",c=null!==(r=null!==(o=null!==(n=i.value)&&void 0!==n?n:i.__rValue)&&void 0!==o?o:i.pct)&&void 0!==r?r:"";if(!l&&""===c){const e=Object.entries(i).filter(([e])=>!e.startsWith("_")&&"data"!==e);return f.createElement("div",{className:"semiotic-tooltip",style:$e},e.map(([e,t])=>f.createElement("div",{key:e},f.createElement("span",{style:{opacity:.7}},e,":")," ","number"==typeof t?t.toLocaleString():t+"")))}return f.createElement("div",{className:"semiotic-tooltip",style:$e},l&&f.createElement("div",{style:{fontWeight:"bold"}},l+""),""!==c&&f.createElement("div",null,"number"==typeof c?c.toLocaleString():c+""))}const _e=e.forwardRef(function(t,n){var o,r,i;const{chartType:a,runtimeMode:l,data:c,oAccessor:u="category",rAccessor:d="value",colorAccessor:h,stackBy:g,groupBy:y,multiAxis:p,timeAccessor:v,valueAccessor:b,categoryAccessor:x,projection:k="vertical",size:w=[600,400],responsiveWidth:A,responsiveHeight:E,margin:S,barPadding:L,innerRadius:O,normalize:M,startAngle:C,dynamicColumnWidth:j,bins:P,showOutliers:H,showIQR:N,amplitude:B,connectorAccessor:D,connectorStyle:W,rExtent:T,oExtent:_,extentPadding:F=.05,oSort:Y,windowMode:G="sliding",windowSize:q=200,pieceStyle:X,summaryStyle:V,colorScheme:U,barColors:Z,showAxes:Q=!0,oLabel:K,rLabel:J,oFormat:ee,rFormat:te,enableHover:ne=!0,hoverAnnotation:oe,tooltipContent:re,customHoverBehavior:ie,annotations:ae,svgAnnotationRules:le,showGrid:ce=!1,legend:ue,legendHoverBehavior:de,legendClickBehavior:he,legendHighlightedCategory:ge,legendIsolatedCategories:fe,backgroundGraphics:ye,foregroundGraphics:pe,title:me,className:ve,background:be,centerContent:xe,decay:ke,pulse:we,transition:Ae,staleness:Ee}=t,[Pe,Ne]=$(w,A,E),Be=e.useMemo(()=>Object.assign(Object.assign({},Re),S),[S]),De=Ne[0]-Be.left-Be.right,We=Ne[1]-Be.top-Be.bottom,Te=e.useRef(null),$e=e.useRef(!0),_e=e.useRef(0),Fe=e.useRef(null),Ye=e.useRef(()=>{}),[Ge,qe]=e.useState(null),[Xe,Ve]=e.useState(null),[Ue,Ze]=e.useState(0),[Qe,Ke]=e.useState(!1),Je=ne||oe,et="streaming"===l,tt=e.useMemo(()=>({chartType:a,runtimeMode:et?"streaming":"bounded",windowSize:q,windowMode:G,extentPadding:F,projection:k,oAccessor:et?void 0:u,rAccessor:et?void 0:d,colorAccessor:h,stackBy:g,groupBy:y,multiAxis:p,timeAccessor:et?v:void 0,valueAccessor:et?b||("string"==typeof d||"function"==typeof d?d:void 0):void 0,categoryAccessor:et?x||u:void 0,rExtent:T,oExtent:_,barPadding:L,innerRadius:O,normalize:M,startAngle:C,dynamicColumnWidth:j,bins:P,showOutliers:H,showIQR:N,amplitude:B,connectorAccessor:D,connectorStyle:W,oSort:Y,pieceStyle:X,summaryStyle:V,colorScheme:U,barColors:Z,decay:ke,pulse:we,transition:Ae,staleness:Ee}),[a,q,G,F,k,u,d,h,g,y,p,v,b,x,T,_,L,O,M,C,j,P,H,N,B,D,W,Y,X,V,U,Z,ke,we,Ae,Ee,et]),nt=e.useRef(null);nt.current||(nt.current=new Se(tt));const ot=e.useCallback(()=>{_e.current||(_e.current=requestAnimationFrame(()=>Ye.current()))},[]);e.useEffect(()=>{var e;null===(e=nt.current)||void 0===e||e.updateConfig(tt),$e.current=!0,ot()},[tt,ot]);const rt=e.useRef(null);rt.current||(rt.current=new m(e=>{const t=nt.current;t&&t.ingest(e)&&($e.current=!0,ot())}));const it=e.useCallback(e=>{var t;null===(t=rt.current)||void 0===t||t.push(e)},[]),at=e.useCallback(e=>{var t;null===(t=rt.current)||void 0===t||t.pushMany(e)},[]),st=e.useCallback(()=>{var e,t;null===(e=rt.current)||void 0===e||e.clear(),null===(t=nt.current)||void 0===t||t.clear(),$e.current=!0,ot()},[ot]);e.useImperativeHandle(n,()=>({push:it,pushMany:at,clear:st,getData:()=>{var e,t;return null!==(t=null===(e=nt.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=nt.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null}}),[it,at,st]),e.useEffect(()=>{var e;c&&(null===(e=rt.current)||void 0===e||e.setBoundedData(c))},[c]);const lt=e.useRef(()=>{}),ct=e.useRef(()=>{});lt.current=e=>{if(!Je)return;const t=Te.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Be.left,r=e.clientY-n.top-Be.top;if(0>o||o>De||0>r||r>We)return void(Fe.current&&(Fe.current=null,qe(null),ie&&ie(null),ot()));const i=nt.current;if(!i||0===i.scene.length)return;const a="radial"===k,s=function(e,t,n,o=30){let r=null;for(const i of e){let e=null;switch(i.type){case"rect":e=Le(i,t,n);break;case"point":e=Oe(i,t,n);break;case"wedge":e=Me(i,t,n);break;case"boxplot":e=Ce(i,t,n);break;case"violin":e=je(i,t,n)}e&&o>e.distance&&(r&&e.distance>=r.distance||(r=e))}return r}(i.scene,a?o-De/2:o,a?r-We/2:r);if(!s)return void(Fe.current&&(Fe.current=null,qe(null),ie&&ie(null),ot()));const l=Object.assign(Object.assign({data:s.datum,time:s.x,value:s.y,x:s.x,y:s.y},s.stats&&{stats:s.stats}),s.category&&{category:s.category});Fe.current=l,qe(l),ie&&(ie(l),$e.current=!0),ot()},ct.current=()=>{Fe.current&&(Fe.current=null,qe(null),ie&&(ie(null),$e.current=!0),ot())},e.useCallback(e=>lt.current(e),[]);const ut=e.useCallback(()=>ct.current(),[]),dt=e.useRef(-1),ht=e.useCallback(e=>{const t=nt.current;if(!t||0===t.scene.length)return;const n=function(e){const t=[];for(const n of e)if("rect"===n.type&&null!=n.x)t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum});else if("point"===n.type)t.push({x:n.x,y:n.y,datum:n.datum});else if("wedge"===n.type&&null!=n.cx){const e=((n.startAngle||0)+(n.endAngle||0))/2,o=((n.innerRadius||0)+(n.outerRadius||50))/2;t.push({x:n.cx+Math.cos(e)*o,y:n.cy+Math.sin(e)*o,datum:n.datum})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.scene);if(0===n.length)return;const o=dt.current,r=I(e.key,0>o?-1:o,n.length);if(null===r)return;if(e.preventDefault(),0>r)return dt.current=-1,Fe.current=null,qe(null),ie&&ie(null),void ot();const i=0>o?0:r;dt.current=i;const a=R(n[i]);Fe.current=a,qe(a),ie&&ie(a),ot()},[ie,ot]),gt=e.useCallback(e=>{dt.current=-1,lt.current(e)},[]);Ye.current=()=>{var e,t;_e.current=0;const n=Te.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const r=nt.current;if(!r)return;const i="undefined"!=typeof performance?performance.now():Date.now(),s=r.advanceTransition(i),l=$e.current;l&&!s&&(r.computeScene({width:De,height:We}),$e.current=!1);const c="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=Ne[0]*c,n.height=Ne[1]*c,n.style.width=Ne[0]+"px",n.style.height=Ne[1]+"px",o.scale(c,c),o.clearRect(0,0,Ne[0],Ne[1]);const u=null!==(e=null==Ee?void 0:Ee.threshold)&&void 0!==e?e:5e3,d=Ee&&r.lastIngestTime>0&&i-r.lastIngestTime>u;d&&(o.globalAlpha=null!==(t=null==Ee?void 0:Ee.dimOpacity)&&void 0!==t?t:.5);const h=n?getComputedStyle(n).getPropertyValue("--semiotic-bg").trim():"",g=be||(h&&"transparent"!==h?h:null);g&&(o.fillStyle=g,o.fillRect(0,0,Ne[0],Ne[1]));const f="radial"===k;f?(o.save(),o.translate(Be.left+De/2,Be.top+We/2)):o.translate(Be.left,Be.top);const y=Ie[a]||[],p={width:De,height:We};for(const e of y)e(o,r.scene,r.scales,p);f&&o.restore(),d&&(o.globalAlpha=1),l&&r.scales&&(Ve(r.scales),Ze(e=>e+1)),(null==Ee?void 0:Ee.showBadge)&&Ke(!!d),(s||r.hasActivePulses)&&(_e.current=requestAnimationFrame(()=>Ye.current()))},e.useEffect(()=>(ot(),()=>{_e.current&&(cancelAnimationFrame(_e.current),_e.current=0)}),[ot]),e.useEffect(()=>{$e.current=!0,ot()},[a,De,We,Q,be,ot]),z(Ee,nt,$e,ot,Qe,Ke);const ft=Je&&Ge?re?re(Ge):f.createElement(ze,{hover:Ge}):null,yt="radial"===k,pt=Ge?yt?Ge.x+De/2:Ge.x:0,mt=Ge?yt?Ge.y+We/2:Ge.y:0,vt=ft?f.createElement("div",{className:"stream-ordinal-tooltip",style:{position:"absolute",left:Be.left+pt,top:Be.top+mt,transform:`translate(${pt>.7*De?"calc(-100% - 12px)":"12px"}, ${.3*We>mt?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},ft):null;if(se){const e=nt.current;e&&c&&(e.ingest({inserts:c,bounded:!0}),e.computeScene({width:De,height:We}));const t=null!==(o=null==e?void 0:e.scene)&&void 0!==o?o:[],n=null!==(r=null==e?void 0:e.scales)&&void 0!==r?r:null,i="radial"===k,a=i?Be.left+De/2:Be.left,l=i?Be.top+We/2:Be.top;return f.createElement("div",{className:"stream-ordinal-frame"+(ve?" "+ve:""),role:"img","aria-label":"string"==typeof me?me:"Ordinal chart",style:{position:"relative",width:Ne[0],height:Ne[1]}},f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ne[0],height:Ne[1],style:{position:"absolute",left:0,top:0}},ye&&f.createElement("g",{transform:`translate(${Be.left},${Be.top})`},ye),f.createElement("g",{transform:`translate(${a},${l})`},be&&f.createElement("rect",{x:0,y:0,width:De,height:We,fill:be}),t.map((e,t)=>function(e,t){var n,o,r,i,a;switch(e.type){case"rect":return f.createElement("rect",{key:"ord-rect-"+t,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.style.fill||"#4e79a7",opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth});case"point":return f.createElement("circle",{key:"ord-point-"+t,cx:e.x,cy:e.y,r:e.r,fill:e.style.fill||"#4e79a7",opacity:null!==(n=e.style.opacity)&&void 0!==n?n:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth});case"wedge":{const n=e,o=s.arc().innerRadius(n.innerRadius).outerRadius(n.outerRadius).startAngle(n.startAngle).endAngle(n.endAngle)({})||"";return f.createElement("path",{key:"ord-wedge-"+t,d:o,transform:`translate(${n.cx},${n.cy})`,fill:n.style.fill||"#4e79a7",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"boxplot":{const n=e,i=n.columnWidth/2;return"vertical"===n.projection?f.createElement("g",{key:"ord-boxplot-"+t},f.createElement("line",{x1:n.x,y1:n.minPos,x2:n.x,y2:n.maxPos,stroke:n.style.stroke||"#333",strokeWidth:1}),f.createElement("rect",{x:n.x-i,y:Math.min(n.q1Pos,n.q3Pos),width:n.columnWidth,height:Math.abs(n.q3Pos-n.q1Pos),fill:n.style.fill||"#4e79a7",fillOpacity:null!==(o=n.style.fillOpacity)&&void 0!==o?o:.6,stroke:n.style.stroke||"#333",strokeWidth:1}),f.createElement("line",{x1:n.x-i,y1:n.medianPos,x2:n.x+i,y2:n.medianPos,stroke:n.style.stroke||"#333",strokeWidth:2}),f.createElement("line",{x1:n.x-.5*i,y1:n.minPos,x2:n.x+.5*i,y2:n.minPos,stroke:n.style.stroke||"#333",strokeWidth:1}),f.createElement("line",{x1:n.x-.5*i,y1:n.maxPos,x2:n.x+.5*i,y2:n.maxPos,stroke:n.style.stroke||"#333",strokeWidth:1})):f.createElement("g",{key:"ord-boxplot-"+t},f.createElement("line",{x1:n.minPos,y1:n.y,x2:n.maxPos,y2:n.y,stroke:n.style.stroke||"#333",strokeWidth:1}),f.createElement("rect",{x:Math.min(n.q1Pos,n.q3Pos),y:n.y-i,width:Math.abs(n.q3Pos-n.q1Pos),height:n.columnWidth,fill:n.style.fill||"#4e79a7",fillOpacity:null!==(r=n.style.fillOpacity)&&void 0!==r?r:.6,stroke:n.style.stroke||"#333",strokeWidth:1}),f.createElement("line",{x1:n.medianPos,y1:n.y-i,x2:n.medianPos,y2:n.y+i,stroke:n.style.stroke||"#333",strokeWidth:2}),f.createElement("line",{x1:n.minPos,y1:n.y-.5*i,x2:n.minPos,y2:n.y+.5*i,stroke:n.style.stroke||"#333",strokeWidth:1}),f.createElement("line",{x1:n.maxPos,y1:n.y-.5*i,x2:n.maxPos,y2:n.y+.5*i,stroke:n.style.stroke||"#333",strokeWidth:1}))}case"violin":{const n=e,o=[f.createElement("path",{key:"ord-violin-path-"+t,d:n.pathString,transform:n.translateX||n.translateY?`translate(${n.translateX},${n.translateY})`:void 0,fill:n.style.fill||"#4e79a7",fillOpacity:null!==(i=n.style.fillOpacity)&&void 0!==i?i:.6,stroke:n.style.stroke||"#333",strokeWidth:n.style.strokeWidth||1})];if(n.iqrLine&&n.bounds){const e=n.bounds,r=e.x+e.width/2,i=e.y+e.height/2;e.height>e.width?o.push(f.createElement("line",{key:"ord-violin-iqr-"+t,x1:r,y1:n.iqrLine.q1Pos,x2:r,y2:n.iqrLine.q3Pos,stroke:n.style.stroke||"#333",strokeWidth:2}),f.createElement("circle",{key:"ord-violin-med-"+t,cx:r,cy:n.iqrLine.medianPos,r:3,fill:"white",stroke:n.style.stroke||"#333",strokeWidth:1})):o.push(f.createElement("line",{key:"ord-violin-iqr-"+t,x1:n.iqrLine.q1Pos,y1:i,x2:n.iqrLine.q3Pos,y2:i,stroke:n.style.stroke||"#333",strokeWidth:2}),f.createElement("circle",{key:"ord-violin-med-"+t,cx:n.iqrLine.medianPos,cy:i,r:3,fill:"white",stroke:n.style.stroke||"#333",strokeWidth:1}))}return f.createElement("g",{key:"ord-violin-"+t},o)}case"connector":return f.createElement("line",{key:"ord-conn-"+t,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:null!==(a=e.style.opacity)&&void 0!==a?a:.5});default:return null}}(e,t)).filter(Boolean))),f.createElement(He,{width:De,height:We,totalWidth:Ne[0],totalHeight:Ne[1],margin:Be,scales:n,showAxes:Q,oLabel:K,rLabel:J,oFormat:ee,rFormat:te,showGrid:ce,title:me,legend:ue,legendHoverBehavior:de,legendClickBehavior:he,legendHighlightedCategory:ge,legendIsolatedCategories:fe,foregroundGraphics:pe,annotations:ae,svgAnnotationRules:le,annotationFrame:0,xAccessor:"string"==typeof u?u:void 0,yAccessor:"string"==typeof d?d:void 0,annotationData:null==e?void 0:e.getData()}),xe&&"radial"===k&&f.createElement("div",{style:{position:"absolute",left:Be.left+De/2,top:Be.top+We/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"}},xe))}return f.createElement("div",{ref:Pe,className:"stream-ordinal-frame"+(ve?" "+ve:""),role:"img","aria-label":"string"==typeof me?me:"Ordinal chart",tabIndex:0,style:{position:"relative",width:A?"100%":Ne[0],height:E?"100%":Ne[1]},onMouseMove:Je?gt:void 0,onMouseLeave:Je?ut:void 0,onKeyDown:ht},ye&&f.createElement("svg",{style:{position:"absolute",top:0,left:0,width:Ne[0],height:Ne[1],pointerEvents:"none"}},f.createElement("g",{transform:`translate(${Be.left},${Be.top})`},ye)),f.createElement("canvas",{ref:Te,style:{position:"absolute",top:0,left:0,width:Ne[0],height:Ne[1]}}),f.createElement(He,{width:De,height:We,totalWidth:Ne[0],totalHeight:Ne[1],margin:Be,scales:Xe,showAxes:Q,oLabel:K,rLabel:J,oFormat:ee,rFormat:te,showGrid:ce,title:me,legend:ue,legendHoverBehavior:de,legendClickBehavior:he,legendHighlightedCategory:ge,legendIsolatedCategories:fe,foregroundGraphics:pe,annotations:ae,svgAnnotationRules:le,annotationFrame:Ue,xAccessor:"string"==typeof u?u:void 0,yAccessor:"string"==typeof d?d:void 0,annotationData:null===(i=nt.current)||void 0===i?void 0:i.getData()}),xe&&"radial"===k&&f.createElement("div",{style:{position:"absolute",left:Be.left+De/2,top:Be.top+We/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"}},xe),(null==Ee?void 0:Ee.showBadge)&&f.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Ee.badgePosition?{top:4,left:4}:"bottom-left"===Ee.badgePosition?{bottom:4,left:4}:"bottom-right"===Ee.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Qe?"#dc3545":"#28a745",color:"white"})},Qe?"STALE":"LIVE"),vt)});_e.displayName="StreamOrdinalFrame";const Fe={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Ye={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class Ge{constructor(e){this.capacity=e,this.particles=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0}}spawn(e){for(let t=0;this.capacity>t;t++){const n=this.particles[t];if(!n.active)return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=e,n.x=0,n.y=0,n}return null}step(e,t,n,o){var r;for(let i=0;this.capacity>i;i++){const a=this.particles[i];if(!a.active)continue;const s=n[a.edgeIndex];if(!s||!s.bezier){a.active=!1;continue}const l=o&&null!==(r=o[a.edgeIndex])&&void 0!==r?r:1;if(a.t+=e*t*l*(s.bezier.circular?.3:1),a.t>=1){a.active=!1;continue}const c=qe(s.bezier,a.t,a.offset);a.x=c.x,a.y=c.y}}countForEdge(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let n=0;e>n;n++)this.particles[n]=t.length>n?t[n]:{t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0};this.capacity=e}}function qe(e,t,n){if(e.circular&&e.segments)return function(e,t,n,o){const r=e.length,i=t*r,a=Math.min(Math.floor(i),r-1),s=i-a,[l,c,u,d]=e[a],h=Xe(l,c,u,d,s),g=d.x-l.x,f=d.y-l.y,y=Math.sqrt(g*g+f*f);if(y>.001){const e=g/y;h.x+=-f/y*n*o*2,h.y+=e*n*o*2}return h}(e.segments,t,n,e.halfWidth);if(!e.points)return{x:0,y:0};const[o,r,i,a]=e.points,s=Xe(o,r,i,a,t),l=a.x-o.x,c=a.y-o.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;s.x+=-c/u*n*e.halfWidth*2,s.y+=t*n*e.halfWidth*2}return s}function Xe(e,t,n,o,r){const i=1-r,a=i*i,s=a*i,l=r*r,c=l*r;return{x:s*e.x+3*a*r*t.x+3*i*l*n.x+c*o.x,y:s*e.y+3*a*r*t.y+3*i*l*n.y+c*o.y}}function Ve(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function Ue(e,t){var n,o=[],r=[],i=[],a={},s=[];function l(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&l(t)})}function c(e){var t,o,d=!1;for(r.push(e),i[e]=!0,t=0;s[e].length>t;t++)(o=s[e][t])===n?(u(n,r),d=!0):i[o]||(d=c(o));if(d)l(e);else for(t=0;s[e].length>t;t++){var h=a[o=s[e][t]];h||(a[o]=h={}),h[o]=!0}return r.pop(),d}function u(e,t){var n=[].concat(t).concat(e);o.push(n)}function d(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,o=function(e){for(var t=e.length,n=Array(t),o=Array(t),r=Array(t),i=Array(t),a=Array(t),s=Array(t),l=0;t>l;++l)n[l]=-1,o[l]=0,r[l]=!1,i[l]=0,a[l]=-1,s[l]=[];var c,u=0,d=[],h=[];function g(t){var l=[t],c=[t];for(n[t]=o[t]=u,r[t]=!0,u+=1;c.length>0;){var g=e[t=c[c.length-1]];if(g.length>i[t]){for(var f=i[t];g.length>f;++f){var y=g[f];if(0>n[y]){n[y]=o[y]=u,r[y]=!0,u+=1,l.push(y),c.push(y);break}r[y]&&(o[t]=0|Math.min(o[t],o[y])),0>a[y]||s[t].push(a[y])}i[t]=f}else{if(o[t]===n[t]){var p=[],m=[],v=0;for(f=l.length-1;f>=0;--f){var b=l[f];if(r[b]=!1,p.push(b),m.push(s[b]),v+=s[b].length,a[b]=d.length,b===t){l.length=f;break}}d.push(p);var x=Array(v);for(f=0;m.length>f;f++)for(var k=0;m[f].length>k;k++)x[--v]=m[f][k];h.push(x)}c.pop()}}}for(l=0;t>l;++l)0>n[l]&&g(l);for(l=0;h.length>l;l++){var f=h[l];if(0!==f.length){f.sort(function(e,t){return e-t}),c=[f[0]];for(var y=1;f.length>y;y++)f[y]!==f[y-1]&&c.push(f[y]);h[l]=c}}return{components:d,adjacencyList:h}}(e),r=o.components.filter(function(e){return e.length>1}),i=1/0,a=0;r.length>a;a++)for(var s=0;r[a].length>s;s++)i>r[a][s]&&(i=r[a][s],n=a);var l=r[n];if(!l)return!1;var c=e.map(function(e,t){return-1===l.indexOf(t)?[]:e.filter(function(e){return-1!==l.indexOf(e)})});return{leastVertex:i,adjList:c}}n=0;for(var h=e.length;h>n;){var g=d(n);if(n=g.leastVertex,s=g.adjList){for(var f=0;s.length>f;f++)for(var y=0;s[f].length>y;y++){var p=s[f][y];i[+p]=!1,a[p]={}}c(n),n+=1}else n=h}return o}function Ze(e){return e.y0-e.y1>0?"up":"down"}function Qe(e,t){return t(e.source)==t(e.target)}function Ke(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function Je(e){return e.target.x0-e.source.x1}function et(e,t){var n=nt(e),o=Je(t)/Math.tan(n);return"up"==Ze(e)?e.y1-o:e.y1+o}function tt(e,t){var n=nt(e),o=Je(t)/Math.tan(n);return"up"==Ze(e)?e.y1+o:e.y1-o}function nt(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function ot(e,t){return t(e)}function rt(e){return at(e.source)}function it(e){return at(e.target)}function at(e){return(e.y0+e.y1)/2}function st(e){return e.virtual?0:e.value}function lt(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!Qe(e,t)?n+1:n});var o=0;return e.targetLinks.forEach(function(e){o=e.circular&&!Qe(e,t)?o+1:o}),n+o}function ct(e){return e.target.depth}function ut(e,t){return e.sourceLinks.length?e.depth:t-1}function dt(e,t){return e.y0-t.y0}function ht(e,t){return t.y0-e.y0}function gt(e,t){return e.y1-t.y1}function ft(e,t){return t.y1-e.y1}function yt(e,t){return mt(e.source,t.source)||e.index-t.index}function pt(e,t){return mt(e.target,t.target)||e.index-t.index}function mt(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function vt(e,t){return bt(e)==bt(t)?"bottom"==e.circularLinkType?ht(e,t):dt(e,t):bt(t)-bt(e)}function bt(e){return e.target.column-e.source.column}function xt(e,t){return kt(e)==kt(t)}function kt(e){return e.y0-e.y1>0?"up":"down"}function wt(e,t,n,o,i){let a=e;var s=Math.max(8,.15*(a.y1-a.y0));a.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var l=r.min(a.links,function(e){return e.source.y0});a.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=a.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),At(a.links.filter(function(e){return"top"==e.circularLinkType}),t,n),At(a.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),a.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+o,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,Qe(e,t)&&Ke(e))e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var r=e.source.column,s=e.circularLinkType,c=a.links.filter(function(e){return e.source.column==r&&e.circularLinkType==s});c.sort("bottom"==e.circularLinkType?ht:dt);var u=0;c.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),r=e.target.column,(c=a.links.filter(function(e){return e.target.column==r&&e.circularLinkType==s})).sort("bottom"==e.circularLinkType?ft:gt),u=0,c.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(a.y1,e.source.y1,e.target.y1)+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=l-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,n=e.y0,o=e.target.x0,r=e.y1,i=(t+o)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+r+" "+o+","+r}(e)}),a}function At(e,t,n){e.sort(vt);var o=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,r){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(Qe(e,t)&&Ke(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;o.length>a;a++){var s=o[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&Et(e,s)){var l=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+n;i=l>i?l:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function Et(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function St(e){return function(){return e}}function Lt(e){return e.index}function Ot(e){return e.nodes}function Mt(e){return e.links}function Ct(e,t,n){var o=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});o.forEach(function(r){var i=r.length;r.sort(t||function(e,t){return e.circularLinkType==t.circularLinkType?lt(t,n)-lt(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0}),r.forEach(function(t,r){t.depth==o.length-1&&1==i||0==t.depth&&1==i?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==lt(t,n)?(t.y0=e.y1/2+r,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+r,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-r,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/i*r,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-i/2+r,t.y1=t.y0+t.value*e.ky)})})}function jt(e,t,n,o,i,a){var s=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});d();for(var l=1,c=a;c>0;--c)u(l*=.99,n),d();function u(t,n){var o=s.length;s.forEach(function(i){var a=i.length,s=i[0].depth;i.forEach(function(i){var l;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&<(i,n)>0){var c=r.mean(i.sourceLinks,it),u=r.mean(i.targetLinks,rt),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-at(i))*t*.3;i.y0+=h,i.y1+=h}}else if(0==s&&1==a)i.y0=e.y1/2-(l=i.y1-i.y0)/2,i.y1=e.y1/2+l/2;else if(s==o-1&&1==a)i.y0=e.y1/2-(l=i.y1-i.y0)/2,i.y1=e.y1/2+l/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)l=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+l;else{var g=r.mean(i.sourceLinks,it),f=r.mean(i.targetLinks,rt),y=((g&&f?(g+f)/2:g||f)-at(i))*t;i.y0+=y,i.y1+=y}})})}function d(){s.forEach(function(n){var r,a,s,l=e.y0,c=n.length;for(n.sort(t||mt),s=0;c>s;++s)(a=l-(r=n[s]).y0)>0&&(r.y0+=a,r.y1+=a),l=r.y1+o;if((a=l-o-e.y1)>0)for(l=r.y0-=a,r.y1-=a,s=c-2;s>=0;--s)(a=(r=n[s]).y1+i-l)>0&&(r.y0-=a,r.y1-=a),l=r.y0})}}function Pt(e){e.nodes.forEach(function(e){e.sourceLinks.sort(pt),e.targetLinks.sort(yt)}),e.nodes.forEach(function(e){var t=e.y0,n=t,o=e.y1,r=o;e.sourceLinks.forEach(function(e){e.circular?(e.y0=o-e.width/2,o-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=r-e.width/2,r-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function Ht(){var e=0,t=0,n=1,o=1,i=24,a=8,s=null,l=Lt,c=ut,u=void 0,d=32,h=2,g=Ot,f=Mt;function y(){var y={nodes:g.apply(null,arguments),links:f.apply(null,arguments)};return function(g){g.x0=e,g.y0=t,g.x1=n,g.y1=o,g.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return r.group(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var o=e.source,r=e.target;"object"!=typeof o&&(o=e.source=Ve(n,o)),"object"!=typeof r&&(r=e.target=Ve(n,r)),o.sourceLinks.push(e),r.targetLinks.push(e)})}(g,l),function(e,t){var n=0;if(null==t){for(var o=[],r=0;e.links.length>r;r++){var i=e.links[r],a=i.source.index,s=i.target.index;o[a]||(o[a]=[]),o[s]||(o[s]=[]),-1===o[a].indexOf(s)&&o[a].push(s)}var l=Ue(o);l.sort(function(e,t){return e.length-t.length});var c={};for(r=0;l.length>r;r++){var u=l[r].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,o=e.source.index;t===o||c[o]&&c[o][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(g,u),function(e,t){var n=0,o=0;e.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:o>n?"top":"bottom","top"==r.circularLinkType?n++:o++,e.nodes.forEach(function(e){ot(e,t)!=ot(r.source,t)&&ot(e,t)!=ot(r.target,t)||(e.circularLinkType=r.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),Qe(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(g,l),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(r.sum(e.sourceLinks,st),r.sum(e.targetLinks,st)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(g),function(e,t,n){var o,r,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var a=0,s=t(e.nodes[0]);e.nodes.forEach(function(e){a=t(e)==s?a:a+1,s=t(e)==s?s:t(e),e.column=a})}for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>r.indexOf(e.target)&&!e.circular&&r.push(e.target)})});for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>r.indexOf(e.source)&&!e.circular&&r.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,i):e.column})}(g,u,c);var f=a;if(null!==s){var y=r.groups(g.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),p=r.max(y,function(e){return e.length});p>1&&(f=Math.max(1,(o-t)*s/(p-1)))}(function(e,t,n){var o=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var i=r.min(o,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/r.sum(t,function(e){return e.value})});e.ky=i,e.links.forEach(function(t){t.width=t.value*e.ky});var a=r.max(e.nodes,function(e){return e.column});e.nodes.forEach(a>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/a),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(g,f,i),Ct(g,u,l),jt(g,u,l,f,f,d),Pt(g),wt(g,l,h,10,8),Ct(g,u,l),jt(g,u,l,f,f,d),Pt(g),wt(g,l,h,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var o=n.links.filter(function(n){return ot(n.source,t)==ot(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!xt(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=et(t,e);return e.y1-n}if(t.target.column>e.target.column)return et(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;o.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;r>i;i++)a+=o[i].width;t.y0=e.y1-a-t.width/2}})})}(g,l),function(e,t){let n=e;n.nodes.forEach(function(e){var o=n.links.filter(function(n){return ot(n.target,t)==ot(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!xt(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=tt(t,e);return e.y0-n}if(t.source.column>e.source.column)return tt(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;o.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;r>i;i++)a+=o[i].width;t.y1=e.y1-a-t.width/2}})})}(g,l),function(e){var t=e.nodes,n=e.links,o=!1,i=!1;if(n.forEach(function(e){"top"==e.circularLinkType?o=!0:"bottom"==e.circularLinkType&&(i=!0)}),0==o||0==i){var a=r.min(t,function(e){return e.y0}),s=r.max(t,function(e){return e.y1}),l=(e.y1-e.y0)/(s-a);function c(t){return(t-a)/(s-a)*(e.y1-e.y0)+e.y0}1>l?(t.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1)}),n.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1),e.width=e.width*l})):t.forEach(function(e){var t=e.y1-e.y0,n=c(e.y0)-e.y0;e.y0=c(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(g),wt(g,l,h,10,8)}(y),y}return y.update=function(e){return Pt(e),wt(e,l,h,10,8),e},y.nodeWidth=function(e){return arguments.length?(i=+e,y):i},y.nodePadding=function(e){return arguments.length?(a=+e,y):a},y.nodePaddingRatio=function(e){return arguments.length?(s=+e,y):s},y.nodes=function(e){return arguments.length?(g="function"==typeof e?e:St(e),y):g},y.links=function(e){return arguments.length?(f="function"==typeof e?e:St(e),y):f},y.nodeId=function(e){return arguments.length?(l="function"==typeof e?e:St(e),y):l},y.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:St(e),y):c},y.nodeSort=function(e){return arguments.length?(u=e,y):u},y.iterations=function(e){return arguments.length?(d=+e,y):d},y.circularLinkGap=function(e){return arguments.length?(h=+e,y):h},y.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],y):[[e,t],[n,o]]},y.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],y):[n-e,o-t]},y}const Nt=e=>{let t,n,o,r,i,a,s,c,u;return"down"===e.direction?(t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,o=e.y1+e.sankeyWidth/2,r=e.y0+e.sankeyWidth/2,i=e.source.y1,a=e.target.y0,s=l.interpolateNumber(i,a),c=s(.5),u=s(.5),`M${t},${i}C${t},${c} ${n},${u} ${n},${a}L${o},${a}C${o},${u} ${r},${c} ${r},${i}Z`):(t=e.source.x1,n=e.target.x0,s=l.interpolateNumber(t,n),o=s(.5),r=s(.5),i=e.y0-e.sankeyWidth/2,a=e.y1-e.sankeyWidth/2,c=e.y1+e.sankeyWidth/2,u=e.y0+e.sankeyWidth/2,`M${t},${i}C${o},${i} ${r},${a} ${n},${a}L${n},${c}C${r},${c} ${o},${u} ${t},${u}Z`)};function Bt(e){var t;const n=e.sankeyWidth/2,o=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,r=e.circularPathData;if(!r)return null;if("down"===e.direction)return null;if(e._circularStub){const t=r.sourceX,o=r.sourceY,i=r.targetX,a=r.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const s=Math.max(15,Math.min(40,.33*(r.rightFullExtent-t))),l=Math.max(15,Math.min(40,.33*(i-r.leftFullExtent)));return`M${t},${o-n}L${t+s},${o-n}L${t+s},${o+n}L${t},${o+n}ZM${i},${a-n}L${i-l},${a-n}L${i-l},${a+n}L${i},${a+n}Z`}const i=r.sourceX,a=r.sourceY,s=r.targetX,l=r.targetY,c=r.rightFullExtent,u=r.leftFullExtent,d=r.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,g=Math.max(4,Math.min(o,15));return`M${i},${a-h*n}L${c},${a-h*n}L${c+o},${a-h*n+h*g}L${c+o},${d+h*o-h*g}L${c+o-g},${d+h*o}L${u-o+g},${d+h*o}L${u-o},${d+h*o-h*g}L${u-o},${l-h*n+h*g}L${u-o+g},${l-h*n}L${s},${l-h*n}L${s},${l+h*n}L${u+o},${l+h*n}L${u+o},${d-h*o}L${c-o},${d-h*o}L${c-o},${a+h*n}L${i},${a+h*n}Z`}const Dt={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(ct))-1:0},justify:ut},Wt={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){var r,i,a,s,l,c,u;if(0===e.length)return;const d="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",g=null!==(r=n.nodeWidth)&&void 0!==r?r:15,f=null!==(i=n.nodePaddingRatio)&&void 0!==i?i:.05,y=null!==(a=n.iterations)&&void 0!==a?a:100,p=e.map(e=>Object.assign({},e)),m=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let v;v="down"===d?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const b=Ht().extent(v).links(m).nodes(p).nodeAlign(Dt[h]||ut).nodeId(e=>e.id).nodeWidth(g).iterations(y);b.nodePaddingRatio&&b.nodePaddingRatio(f),b();{let e=1/0,t=-1/0,n=1/0,r=-1/0;for(const o of p)e>o.x0&&(e=o.x0),o.x1>t&&(t=o.x1),n>o.y0&&(n=o.y0),o.y1>r&&(r=o.y1);for(const o of m){if(!o.circular||!o.circularPathData)continue;const i=o.circularPathData,a=(null!==(l=null!==(s=o._circularWidth)&&void 0!==s?s:o.width)&&void 0!==l?l:0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),n>i.verticalFullExtent-a&&(n=i.verticalFullExtent-a),i.verticalFullExtent+a>r&&(r=i.verticalFullExtent+a)}const i=t-e,a=r-n,u=o[0],d=o[1];if(i>0&&a>0&&(0>e||0>n||t>u||r>d)){const t=Math.min(u/i,d/a),o=-e*t+(u-i*t)/2,r=-n*t+(d-a*t)/2;for(const e of p)e.x0=e.x0*t+o,e.x1=e.x1*t+o,e.y0=e.y0*t+r,e.y1=e.y1*t+r;for(const e of m)if(e.y0=e.y0*t+r,e.y1=e.y1*t+r,e.width=(null!==(c=e.width)&&void 0!==c?c:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+o,n.targetX=n.targetX*t+o,n.sourceY=n.sourceY*t+r,n.targetY=n.targetY*t+r,n.rightFullExtent=n.rightFullExtent*t+o,n.leftFullExtent=n.leftFullExtent*t+o,n.verticalFullExtent=n.verticalFullExtent*t+r,n.rightInnerExtent=n.rightInnerExtent*t+o,n.leftInnerExtent=n.leftInnerExtent*t+o,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+r,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+r,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of p){const t=x.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const k=new Map;for(const e of t)k.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of m){const t=e.source,n=e.target,o="object"==typeof t&&null!==t?t.id:t+"",r="object"==typeof n&&null!==n?n.id:n+"",i=k.get(`${o}\0${r}`);if(i){i.y0=e.y0,i.y1=e.y1,i.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,i.circular=!!e.circular,i.circularPathData=e.circularPathData,i._circularWidth=e._circularWidth,i._circularStub=e._circularStub,i.path=e.path,i.circularLinkType=e.circularLinkType,i.direction=d;const t=x.get(o),n=x.get(r);t&&(i.source=t),n&&(i.target=n)}}},buildScene(e,t,n,o){var r,i,a,s;const l="vertical"===n.orientation?"down":"right",u=n.nodeStyle,d=n.edgeStyle,h=null!==(r=n.edgeOpacity)&&void 0!==r?r:.5,g=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:c.schemeCategory10,y=new Map;e.forEach((e,t)=>{y.set(e.id,f[t%f.length])});const p=[],m=[],v=[];for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const o=u?u(t):{},r={fill:o.fill||y.get(t.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};p.push({type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:r,datum:t,id:t.id,label:t.id})}const b=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of b){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let o="#999";d?o=d(e).fill||o:"target"===g&&n?o=y.get(n.id)||o:t&&(o=y.get(t.id)||o);const r=d?d(e):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,s=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),l=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=r.fill||o;m.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+s},${t.sourceY-n}L${t.sourceX+s},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:c,fillOpacity:null!==(i=r.fillOpacity)&&void 0!==i?i:h,stroke:"none",opacity:r.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+s}}),m.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-l},${t.targetY-n}L${t.targetX-l},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:c,fillOpacity:null!==(a=r.fillOpacity)&&void 0!==a?a:h,stroke:"none",opacity:r.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-l,x1:t.targetX}});continue}let l;if(l=e.circular&&e.circularPathData?Bt(e):Nt(e),!l)continue;const c={fill:r.fill||o,fillOpacity:null!==(s=r.fillOpacity)&&void 0!==s?s:h,stroke:r.stroke||"none",strokeWidth:r.strokeWidth,opacity:r.opacity};m.push({type:"bezier",pathD:l,bezierCache:e.bezier,style:c,datum:e})}if(!1!==n.showLabels){const t=(x=n.nodeLabel)?"function"==typeof x?x:e=>e[x]||e.id:null;for(const n of e){const e=n.x1-n.x0,r=n.y1-n.y0;if(0>=e||0>=r)continue;const i=t?t(n):n.id;if(!i)continue;let a,s,c;"down"===l?(a=n.x0+e/2,s=n.y1+14,c="middle"):(o[0]/2>n.x0+e/2?(a=n.x0-6,c="end"):(a=n.x1+6,c="start"),s=n.y0+r/2),v.push({x:a,y:s,text:i+"",anchor:c,baseline:"middle",fontSize:11})}}var x;return{sceneNodes:p,sceneEdges:m,labels:v}}},Tt={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,o){var r,i;if(0===e.length)return;const a=null!==(r=n.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),s=null!==(i=n.forceStrength)&&void 0!==i?i:.1,l=o[0]/2,c=o[1]/2;for(let t=0;e.length>t;t++){const n=e[t];if(null==n.x||null==n.y||0===n.x&&0===n.y){const e=10*Math.sqrt(t+.5),o=2.399963229728653*t;n.x=l+e*Math.cos(o),n.y=c+e*Math.sin(o)}}const d=It(n.nodeSize,n.nodeSizeRange,e),h=u.forceLink().strength(e=>Math.min(2.5,e.weight?e.weight*s:s)).id(e=>e.id),g=o[1]/o[0],f=u.forceSimulation().force("charge",u.forceManyBody().strength(e=>-25*(e=>d(e))(e))).force("x",u.forceX(o[0]/2).strength(.1*g)).force("y",u.forceY(o[1]/2).strength(.1));if(f.nodes(e),t.length>0){const e=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));f.force("link",h),f.force("link").links(e)}.1>f.alpha()&&f.alpha(1),f.stop();for(let e=0;a>e;++e)f.tick();const y=new Map;for(const t of e)y.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=y.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=y.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,o){var r,i,a;const s=n.nodeStyle,l=n.edgeStyle,u=It(n.nodeSize,n.nodeSizeRange,e),d=Array.isArray(n.colorScheme)?n.colorScheme:c.schemeCategory10,h=new Map;e.forEach((e,t)=>{h.set(e.id,d[t%d.length])});const g=[],f=[],y=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=u(t),n=s?s(t):{},o={fill:n.fill||h.get(t.id)||"#007bff",stroke:n.stroke||"#fff",strokeWidth:null!==(r=n.strokeWidth)&&void 0!==r?r:2,opacity:n.opacity};g.push({type:"circle",cx:t.x,cy:t.y,r:e,style:o,datum:t,id:t.id,label:t.id})}const p=new Map;for(const t of e)p.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:p.get(e.source),n="object"==typeof e.target?e.target:p.get(e.target);if(!t||!n)continue;if(null==t.x||null==t.y)continue;if(null==n.x||null==n.y)continue;const o=l?l(e):{},r={stroke:o.stroke||"#999",strokeWidth:null!==(i=o.strokeWidth)&&void 0!==i?i:1,opacity:null!==(a=o.opacity)&&void 0!==a?a:.6};f.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:r,datum:e})}if(!1!==n.showLabels){const t=(m=n.nodeLabel)?"function"==typeof m?m:e=>e[m]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const o=u(n);y.push({x:n.x,y:n.y-o-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var m;return{sceneNodes:g,sceneEdges:f,labels:y}}};function It(e,t,n){var i,a;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const s=t||[5,20],l=n.map(t=>{var n;return null===(n=t.data)||void 0===n?void 0:n[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===l.length)return()=>s[0];const c=null!==(i=r.min(l))&&void 0!==i?i:0,u=null!==(a=r.max(l))&&void 0!==a?a:1;if(c===u)return()=>(s[0]+s[1])/2;const d=o.scaleLinear().domain([c,u]).range(s).clamp(!0);return t=>{var n;const o=null===(n=t.data)||void 0===n?void 0:n[e];return null==o||"number"!=typeof o?s[0]:d(o)}}const Rt=c.schemeCategory10,$t={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const{padAngle:r=.01,groupWidth:i=20,sortGroups:a}=n,l=Math.min(o[0],o[1])/2,c=l-i,u=o[0]/2,h=o[1]/2,g=(f=n.valueAccessor)?"function"==typeof f?f:e=>{var t;return null!==(t=e[f])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var f;const y=new Map;for(let t=0;e.length>t;t++)y.set(e[t].id,t);const p=e.length,m=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=y.get("string"==typeof e.source?e.source:e.source.id),o=y.get(t);if(void 0===n||void 0===o)continue;const r=g(e);m[n][o]=r}const v=d.chord().padAngle(r);a&&v.sortGroups(a);const b=v(m),x=b.groups,k=s.arc().innerRadius(c).outerRadius(l);for(const t of x){const n=e[t.index],o=k.centroid(t);n.x=o[0]+u,n.y=o[1]+h,n.arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const w=new Map;for(const t of e)w.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=w.get("string"==typeof e.source?e.source:e.source.id),o=w.get(t);n&&(e.source=n),o&&(e.target=o)}const A=new Map;for(const e of t)A.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of b){const n=e[t.source.index].id,o=e[t.target.index].id,r=A.get(`${n}\0${o}`)||A.get(`${o}\0${n}`);r&&(r.chordData=t)}},buildScene(e,t,n,o){var r,i;const{groupWidth:a=20,edgeOpacity:s=.5}=n,l=Math.min(o[0],o[1])/2,c=l-a,u=o[0]/2,h=o[1]/2,g=n.nodeStyle,f=n.edgeStyle,y=n.edgeColorBy||"source",p=Array.isArray(n.colorScheme)?n.colorScheme:Rt,m=new Map;e.forEach((e,t)=>{m.set(e.id,p[t%p.length])});const v=d.ribbon().radius(c),b=[],x=[],k=[];for(let t=0;e.length>t;t++){const n=e[t],o=n.arcData;if(!o)continue;let i;i=g?g(n).fill||m.get(n.id)||p[t%p.length]:m.get(n.id)||p[t%p.length];const a=g?g(n):{},s={fill:i,stroke:a.stroke||"black",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.opacity};b.push({type:"arc",cx:u,cy:h,innerR:c,outerR:l,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:s,datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.chordData;if(!t)continue;const n=v(t);if(!n)continue;const o=zt(n,u,h);let r="#999";if(f)r=f(e).fill||r;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===y&&n?r=m.get(n.id)||r:t&&(r=m.get(t.id)||r)}const a=f?f(e):{},l={fill:r,fillOpacity:null!==(i=a.fillOpacity)&&void 0!==i?i:s,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};x.push({type:"ribbon",pathD:o,style:l,datum:e})}if(!1!==n.showLabels){const t=(w=n.nodeLabel)?"function"==typeof w?w:e=>e[w]||e.id:null,o=l+12;for(const n of e){const e=n.arcData;if(!e)continue;const r=t?t(n):n.id;if(!r)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;k.push({x:u+Math.cos(a)*o,y:h+Math.sin(a)*o,text:r+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:b,sceneEdges:x,labels:k}}};function zt(e,t,n){const o=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return e;const r=[];let i=0;for(;o.length>i;){const e=o[i];if("M"===e||"L"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("C"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;3>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("Q"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;2>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("A"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&(r.push(Number(o[i])+t+""),i++),o.length>i&&(r.push(Number(o[i])+n+""),i++);else"Z"===e||"z"===e?(r.push(e),i++):(r.push(o[i]),i++)}return r.join(" ")}const _t={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,o){var r;const a=n.__hierarchyRoot;if(!a)return;const s=n.chartType,l=(c=n.childrenAccessor)?"function"==typeof c?c:e=>e[c]:void 0;var c;const u=n.hierarchySum||(e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0}),d=i.hierarchy(a,l);d.sum(u),d.sort((e,t)=>{var n,o;return(null!==(n=t.value)&&void 0!==n?n:0)-(null!==(o=e.value)&&void 0!==o?o:0)});const[h,g]=o;switch(s){case"tree":!function(e,t,n,o){const r=t.treeOrientation||"vertical",a=i.tree();a.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),a(e)}(d,n,h,g);break;case"cluster":!function(e,t,n,o){const r=t.treeOrientation||"vertical",a=i.cluster();a.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),a(e)}(d,n,h,g);break;case"treemap":!function(e,t,n,o){var r,a;const s=null!==(r=t.padding)&&void 0!==r?r:4,l=null!==(a=t.paddingTop)&&void 0!==a?a:0,c=i.treemap().size([n,o]).tile(i.treemapBinary).padding(s);l>0&&c.paddingTop(l),c(e)}(d,n,h,g);break;case"circlepack":!function(e,t,n,o){var r;const a=null!==(r=t.padding)&&void 0!==r?r:4;i.pack().size([n,o]).padding(a)(e)}(d,n,h,g);break;case"partition":!function(e,t,n,o){var r;i.partition().size([n,o]).padding(null!==(r=t.padding)&&void 0!==r?r:1)(e)}(d,n,h,g)}const f=d.descendants();e.length=0,t.length=0;const y=new Map;for(let t=0;f.length>t;t++){const o=f[t],i={id:Xt(o,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(r=o.value)&&void 0!==r?r:0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===s||"cluster"===s?Ft(i,o,n):"treemap"===s||"partition"===s?Yt(i,o):"circlepack"===s&&Gt(i,o),i.__hierarchyNode=o,e.push(i),y.set(o,i)}if("tree"===s||"cluster"===s)for(const e of f)if(e.parent){const n=y.get(e.parent),o=y.get(e);n&&o&&t.push({source:n,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,o){const r=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,o,r,i){var a,s,l,c,u;const d=[],h=[],g=[],f=n.treeOrientation||"vertical",y="radial"===f,p=o[0]/2,m=o[1]/2,v="number"==typeof(x=n.nodeSize)?x:5,b=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];var x;for(const t of e){let e=t.x,o=t.y;y&&(e+=p,o+=m);const i=r(t);let s=i.fill||"#4d430c";n.colorByDepth&&void 0!==t.depth&&(s=b[t.depth%b.length]);const l={fill:s,stroke:i.stroke||"#fff",strokeWidth:null!==(a=i.strokeWidth)&&void 0!==a?a:1,opacity:i.opacity};d.push({type:"circle",cx:e,cy:o,r:v,style:l,datum:t,id:t.id,label:t.id,depth:t.depth})}const k=null!==(s=n.edgeOpacity)&&void 0!==s?s:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let o=t.x,r=t.y,a=n.x,s=n.y;y&&(o+=p,r+=m,a+=p,s+=m);const u=qt(o,r,a,s,f),d=i(e),g={fill:"none",stroke:d.stroke||"#999",strokeWidth:null!==(l=d.strokeWidth)&&void 0!==l?l:1.5,opacity:null!==(c=d.opacity)&&void 0!==c?c:k};h.push({type:"curved",pathD:u,style:g,datum:e})}if(!1!==n.showLabels){const t=Vt(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let o,r,i,a=n.x,s=n.y;if(y&&(a+=p,s+=m),y){const e=a-p,t=s-m,n=Math.sqrt(e*e+t*t);n>0?(o=a+e/n*10,r=s+t/n*10,i=0>e?"end":"start"):(o=a,r=s-12,i="middle")}else"horizontal"===f?((null===(u=n.data)||void 0===u?void 0:u.children)&&0!==n.data.children.length?(o=a-v-6,i="end"):(o=a+v+6,i="start"),r=s):(o=a,r=s+v+14,i="middle");g.push({x:o,y:r,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:g}}(e,t,n,o,r,i);case"treemap":case"partition":return function(e,t,n,o){var r,i;const a=[],s=[],l=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const s=o(n);let c=s.fill||"#4d430c";t.colorByDepth&&void 0!==n.depth&&(c=l[n.depth%l.length]);const u={fill:c,stroke:s.stroke||"#fff",strokeWidth:null!==(r=s.strokeWidth)&&void 0!==r?r:1,opacity:s.opacity};a.push({type:"rect",x:n.x0,y:n.y0,w:e,h:i,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Vt(t.nodeLabel);for(const o of e){const e=o.x1-o.x0,r=o.y1-o.y0;if(0>=e||0>=r)continue;if((null===(i=o.data)||void 0===i?void 0:i.children)&&o.data.children.length>0&&"partition"!==t.chartType)continue;const a=n?n(o):o.id;a&&(30>e||16>r||s.push({x:o.x0+e/2,y:o.y0+r/2,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,r)/6))}))}}return{sceneNodes:a,sceneEdges:[],labels:s}}(e,n,0,r);case"circlepack":return function(e,t,n,o){var r,i,a,s,l;const c=[],u=[],d=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of e){const e=null!==(r=n.__radius)&&void 0!==r?r:5;if(0>=e)continue;const s=o(n);let l=s.fill||"#4d430c";t.colorByDepth&&void 0!==n.depth&&(l=d[n.depth%d.length]);const u={fill:l,stroke:s.stroke||"#fff",strokeWidth:null!==(i=s.strokeWidth)&&void 0!==i?i:1,opacity:null!==(a=s.opacity)&&void 0!==a?a:.7};c.push({type:"circle",cx:n.x,cy:n.y,r:e,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Vt(t.nodeLabel);for(const t of e){const e=null!==(s=t.__radius)&&void 0!==s?s:5,o=n?n(t):t.id;if(!o)continue;if(15>e)continue;const r=!((null===(l=t.data)||void 0===l?void 0:l.children)&&t.data.children.length>0);u.push({x:t.x,y:r?t.y:t.y-e+14,text:o+"",anchor:"middle",baseline:r?"middle":"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:r?void 0:"#000",stroke:r?void 0:"#fff",strokeWidth:r?void 0:3,paintOrder:r?void 0:"stroke"})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(e,n,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Ft(e,t,n){const o=n.treeOrientation||"vertical";if("radial"===o){const n=t.x,o=t.y;e.x=o*Math.cos(n-Math.PI/2),e.y=o*Math.sin(n-Math.PI/2)}else"horizontal"===o?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function Yt(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function Gt(e,t){var n;const o=null!==(n=t.r)&&void 0!==n?n:0;e.x=t.x,e.y=t.y,e.x0=t.x-o,e.x1=t.x+o,e.y0=t.y-o,e.y1=t.y+o,e.width=2*o,e.height=2*o,e.__radius=o}function qt(e,t,n,o,r){if("horizontal"===r){const r=(e+n)/2;return`M ${e},${t} C ${r},${t} ${r},${o} ${n},${o}`}if("radial"===r){const r=(e+n)/2;return`M ${e},${t} Q ${r},${t} ${r},${(t+o)/2} T ${n},${o}`}{const r=(t+o)/2;return`M ${e},${t} C ${e},${r} ${n},${r} ${n},${o}`}}function Xt(e,t,n){const o=t.nodeIDAccessor;return"function"==typeof o?o(e.data)+"":"string"==typeof o&&void 0!==e.data[o]?e.data[o]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function Vt(e){return e?"function"==typeof e?e:t=>{var n;return(null===(n=t.data)||void 0===n?void 0:n[e])||t[e]||t.id}:null}const Ut={sankey:Wt,force:Tt,chord:$t,tree:_t,cluster:_t,treemap:_t,circlepack:_t,partition:_t};function Zt(e){return Ut[e]}class Qt{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.particlePool=null,this.transition=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.config=e,this.tensionConfig=Object.assign(Object.assign({},Fe),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new Ge(2e3))}updateConfig(e){this.config=e,this.tensionConfig=Object.assign(Object.assign({},Fe),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&!this.particlePool&&(this.particlePool=new Ge(2e3))}ingestHierarchy(e,t){this.nodes.clear(),this.edges.clear(),this.config.__hierarchyRoot=e,this.runLayout(t)}ingestBounded(e,t,n){const{nodeIDAccessor:o="id",sourceAccessor:r="source",targetAccessor:i="target",valueAccessor:a="value"}=this.config,s="function"==typeof o?o:e=>e[o],l="function"==typeof r?r:e=>e[r],c="function"==typeof i?i:e=>e[i],u="function"==typeof a?a:e=>{var t;return null!==(t=e[a])&&void 0!==t?t:1};this.nodes.clear(),this.edges.clear();for(const t of e){const e=s(t)+"";this.nodes.set(e,Object.assign(Object.assign({},Kt(e)),{data:t}))}for(const e of t){const t=l(e)+"",n=c(e)+"",o=Number(u(e))||1;this.nodes.has(t)||this.nodes.set(t,Object.assign(Object.assign({},Kt(t)),{data:e})),this.nodes.has(n)||this.nodes.set(n,Object.assign(Object.assign({},Kt(n)),{data:e})),this.edges.set(`${t}\0${n}`,{source:t,target:n,value:o,y0:0,y1:0,sankeyWidth:0,data:e})}this.runLayout(n)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:n,value:o}=e,r=0===this.nodes.size;let i=!1;const a="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=a,this.nodes.has(t)||(this.nodes.set(t,Kt(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,Kt(n)),this.nodeTimestamps.set(n,a),this.tension+=this.tensionConfig.newNode,i=!0);const s=this.edgeKey(t,n),l=this.edges.get(s);return l?(l.value+=o,this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.weightChange):(this.edges.set(s,{source:t,target:n,value:o,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.newEdge,i=!0),r||i||this.tension>=this.tensionConfig.threshold}runLayout(e){const t=Zt(this.config.chartType);if(!t)return;let n=Array.from(this.nodes.values()),o=Array.from(this.edges.values());if(0===n.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.computeLayout(n,o,this.config,e),t.hierarchical&&n.length>0){this.nodes.clear(),this.edges.clear();for(const e of n)this.nodes.set(e.id,e);for(const e of o)this.edges.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e)}this.finalizeLayout(),this.saveTargetPositions(),n.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1))&&this.tensionConfig.transitionDuration>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:this.tensionConfig.transitionDuration});const r=new Set(this.nodes.keys()),i=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of r)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)r.has(e)||this.removedNodes.add(e);for(const e of i)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)i.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=r,this.previousEdgeKeys=i,this.layoutVersion++}buildScene(e){const t=Zt(this.config.chartType);if(!t)return;const n=Array.from(this.nodes.values()),o=Array.from(this.edges.values()),{sceneNodes:r,sceneEdges:i,labels:a}=t.buildScene(n,o,this.config,e);this.sceneNodes=r,this.sceneEdges=i,this.labels=a}advanceTransition(e){if(!this.transition)return!1;const t=Math.min((e-this.transition.startTime)/this.transition.duration,1),n=1-Math.pow(1-t,3);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0+(e._targetX0-e._prevX0)*n,e.x1=e._prevX1+(e._targetX1-e._prevX1)*n,e.y0=e._prevY0+(e._targetY0-e._prevY0)*n,e.y1=e._prevY1+(e._targetY1-e._prevY1)*n);for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0+(e._targetY0-e._prevY0)*n,e.y1=e._prevY1+(e._targetY1-e._prevY1)*n,e.sankeyWidth=e._prevSankeyWidth+(e._targetSankeyWidth-e._prevSankeyWidth)*n);return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){for(const e of this.nodes.values())e._prevX0=e.x0,e._prevX1=e.x1,e._prevY0=e.y0,e._prevY1=e.y1;for(const e of this.edges.values())e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth);this.rebuildAllBeziers()}updateEdgeBezier(e){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,n="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&n&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,n))}buildStandardBezier(e,t,n){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const r=t.y1,i=n.y0,a=l.interpolateNumber(r,i);return{circular:!1,points:[{x:e.y0,y:r},{x:e.y0,y:a(.5)},{x:e.y1,y:a(.5)},{x:e.y1,y:i}],halfWidth:o}}const r=t.x1,i=n.x0,a=l.interpolateNumber(r,i);return{circular:!1,points:[{x:r,y:e.y0},{x:a(.5),y:e.y0},{x:a(.5),y:e.y1},{x:i,y:e.y1}],halfWidth:o}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),o=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-o,y:n.targetY},{x:n.targetX-.66*o,y:n.targetY},{x:n.targetX-.33*o,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let o;o="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const r=[];for(let e=0;o.length-1>e;e++){const t=o[e],n=o[e+1],i=n.x-t.x,a=n.y-t.y;r.push([t,{x:t.x+i/3,y:t.y+a/3},{x:t.x+2*i/3,y:t.y+2*a/3},n])}return{circular:!0,segments:r,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){var t,n,o,r,i;const a=this.config.pulse;if(!a)return;const s=null!==(t=a.duration)&&void 0!==t?t:500,l=null!==(n=a.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(o=a.glowRadius)&&void 0!==o?o:4;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const o=this.nodeTimestamps.get(n);if(!o)continue;const r=e-o;s>r&&(t._pulseIntensity=1-r/s,t._pulseColor=l,t._pulseGlowRadius=c)}for(const t of this.sceneEdges){const n=t.datum;if(!n)continue;const o="object"==typeof n.source?null===(r=n.source)||void 0===r?void 0:r.id:n.source,a="object"==typeof n.target?null===(i=n.target)||void 0===i?void 0:i.id:n.target;if(!o||!a)continue;const c=this.edgeTimestamps.get(`${o}\0${a}`);if(!c)continue;const u=e-c;s>u&&(t._pulseIntensity=1-u/s,t._pulseColor=l)}}applyDecay(){var e,t,n,o,r;const i=this.config.decay;if(!i)return;const a=null!==(e=i.minOpacity)&&void 0!==e?e:.1,s=this.nodeTimestamps.size;if(1>=s)return;const l=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]),c=new Map;for(let e=0;l.length>e;e++)c.set(l[e][0],e);for(const e of this.sceneNodes){const l=e.id;if(!l)continue;const u=c.get(l);if(void 0===u)continue;const d=s-1-u;let h;switch(i.type){case"linear":h=a+(1-d/(s-1))*(1-a);break;case"exponential":{const e=null!==(t=i.halfLife)&&void 0!==t?t:s/2;h=a+Math.pow(.5,d/e)*(1-a);break}case"step":h=(null!==(n=i.stepThreshold)&&void 0!==n?n:.5*s)>d?1:a;break;default:h=1}const g=null!==(r=null===(o=e.style)||void 0===o?void 0:o.opacity)&&void 0!==r?r:1;e.style=Object.assign(Object.assign({},e.style),{opacity:g*h})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const n=e-this.lastTopologyChangeTime;if(n>=2e3)return;const o=1-n/2e3;for(const e of this.sceneNodes){const n=e.id;n&&this.addedNodes.has(n)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,o),e._pulseColor="rgba(34, 197, 94, 0.7)",e._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(e){var t,n;const o=this.config.thresholds;if(!o)return;const r=null!==(t=o.warningColor)&&void 0!==t?t:"#f59e0b",i=null!==(n=o.criticalColor)&&void 0!==n?n:"#ef4444",a=!1!==o.pulse;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const s=this.nodes.get(n);if(!s)continue;const l=o.metric(s);let c=null;void 0===o.critical||o.critical>l?void 0===o.warning||o.warning>l||(c=r):c=i,c&&(t.style=Object.assign(Object.assign({},t.style),{fill:c}),a&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=c,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const n=e.metric(t);if(void 0!==e.warning&&n>=e.warning||void 0!==e.critical&&n>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const n="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>n-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}clear(){this.nodes.clear(),this.edges.clear(),this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.lastIngestTime=0,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function Kt(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function Jt(e,t,n,o,r=30){let i=null,a=r,s=1/0;for(const t of e){const e=en(t,n,o);if(e)if("rect"===t.type){const n=t.w*t.h;s>n&&(i=e,s=n)}else a>e.distance&&(i=e,a=e.distance)}if(i)return i;for(const e of t){const t=rn(e,n,o);t&&a>t.distance&&(i=t,a=t.distance)}return i}function en(e,t,n){switch(e.type){case"circle":return function(e,t,n){const o=t-e.cx,r=n-e.cy,i=Math.sqrt(o*o+r*r);return i>Math.max(e.r,5)+5?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:i}}(e,t,n);case"rect":return function(e,t,n){const o=C(t,n,e);return o.hit?{type:"node",datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}(e,t,n);case"arc":return function(e,t,n){const o=t-e.cx,r=n-e.cy,i=Math.sqrt(o*o+r*r);if(e.innerR-2>i||i>e.outerR+2)return null;const a=j(Math.atan2(r,o)),s=j(e.startAngle),l=j(e.endAngle);if(s>l?a>=s||l>=a:a>=s&&l>=a){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(e,t,n);default:return null}}let tn=null,nn=null;function on(){return nn||(tn=document.createElement("canvas"),tn.width=1,tn.height=1,nn=tn.getContext("2d")),nn}function rn(e,t,n){switch(e.type){case"bezier":return function(e,t,n){var o,r;if(!e.pathD)return null;try{const i=new Path2D(e.pathD),a=on();if(!a)return null;if(a.isPointInPath(i,t,n)){const i="object"==typeof(null===(o=e.datum)||void 0===o?void 0:o.source)?e.datum.source:null,a="object"==typeof(null===(r=e.datum)||void 0===r?void 0:r.target)?e.datum.target:null;return{type:"edge",datum:e.datum,x:i&&a?(i.x1+a.x0)/2:t,y:e.datum?(e.datum.y0+e.datum.y1)/2:n,distance:0}}}catch(e){}return null}(e,t,n);case"line":return function(e,t,n){const o=e.x2-e.x1,r=e.y2-e.y1,i=o*o+r*r;if(0===i)return null;let a=((t-e.x1)*o+(n-e.y1)*r)/i;a=Math.max(0,Math.min(1,a));const s=e.x1+a*o,l=e.y1+a*r,c=Math.sqrt(Math.pow(t-s,2)+Math.pow(n-l,2));return c>5?null:{type:"edge",datum:e.datum,x:s,y:l,distance:c}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;try{const o=new Path2D(e.pathD),r=on();if(!r)return null;if(r.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0}}catch(e){}return null}(e,t,n);default:return null}}function an(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:i,labels:a,title:s,legend:l,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h,foregroundGraphics:g,sceneNodes:y,annotations:p,svgAnnotationRules:m}=e;return f.createElement(f.Fragment,null,f.createElement("svg",{width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},f.createElement("g",{transform:`translate(${i.left},${i.top})`},a.map((e,t)=>f.createElement("text",{key:"label-"+t,x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"currentColor",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"}},e.text)),p&&p.filter(e=>"widget"!==e.type).map((e,o)=>{if(m){const r=m(e,o,{width:t,height:n,sceneNodes:y});if(r)return f.createElement(f.Fragment,{key:"annotation-"+o},r)}return null}),g),s&&"string"==typeof s?f.createElement("text",{x:o/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},s):s?f.createElement("foreignObject",{x:0,y:0,width:o,height:i.top},s):null,l&&f.createElement("g",{transform:`translate(${o-i.right+10},${i.top})`},"object"==typeof l&&!f.isValidElement(l)&&"legendGroups"in l?f.createElement(q,{legendGroups:l.legendGroups,title:"",width:100,customHoverBehavior:c,customClickBehavior:u,highlightedCategory:d,isolatedCategories:h}):l)),null==p?void 0:p.filter(e=>"widget"===e.type&&e.nodeId&&y).map((e,t)=>{var n,o,r,a,s,l,c,u,d;const h=y.find(t=>{var n,o,r,i,a;return t.id===e.nodeId||(null===(n=t.datum)||void 0===n?void 0:n.id)===e.nodeId||(null===(r=null===(o=t.datum)||void 0===o?void 0:o.data)||void 0===r?void 0:r.id)===e.nodeId||(null===(a=null===(i=t.datum)||void 0===i?void 0:i.data)||void 0===a?void 0:a.name)===e.nodeId});if(!h)return null;const g=i.left+(null!==(n=h.cx)&&void 0!==n?n:null!=h.x&&null!=h.w?h.x+h.w/2:null!==(o=h.x)&&void 0!==o?o:0),p=i.top+(null!==(r=h.cy)&&void 0!==r?r:null!=h.y&&null!=h.h?h.y+h.h/2:null!==(a=h.y)&&void 0!==a?a:0),m=null!==(s=e.dx)&&void 0!==s?s:0,v=null!==(l=e.dy)&&void 0!==l?l:-16,b=null!==(c=e.width)&&void 0!==c?c:32,x=null!==(u=e.height)&&void 0!==u?u:32,k=null!==(d=e.content)&&void 0!==d?d:f.createElement("span",{style:{fontSize:18,cursor:"default"}},"ℹ️");return f.createElement("div",{key:"widget-"+t,style:{position:"absolute",left:g+m-b/2,top:p+v-x/2,width:b,height:x,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5}},k)}))}function sn(e,t){var n,o,r,i,a,s;if(!t.pathD)return;e.save();const l=new Path2D(t.pathD);if(t.style.fill&&"none"!==t.style.fill){const a=t._gradient;if(a){const r=e.createLinearGradient(a.x0,0,a.x1,0),i=null!==(o=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==o?o:.5,s=t.style.fill;r.addColorStop(0,1===a.from?s:"transparent"),r.addColorStop(1,1===a.to?s:"transparent"),e.fillStyle=r,e.globalAlpha=i}else e.fillStyle=t.style.fill,e.globalAlpha=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.5;e.fill(l)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(a=t.style.strokeWidth)&&void 0!==a?a:.5,e.globalAlpha=.5*(null!==(s=t.style.opacity)&&void 0!==s?s:1),e.stroke(l)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(l)),e.restore()}function ln(e,t){var n,o;e.save(),e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(o=t.style.strokeWidth)&&void 0!==o?o:1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function cn(e,t){var n,o,r,i;if(!t.pathD)return;e.save();const a=new Path2D(t.pathD);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(o=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==o?o:.5,e.fill(a)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:.5,e.globalAlpha=.3*(null!==(i=t.style.opacity)&&void 0!==i?i:1),e.stroke(a)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(a)),e.restore()}function un(e,t){var n,o;if(!t.pathD)return;e.save();const r=new Path2D(t.pathD);e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(r),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(o=t.style.fillOpacity)&&void 0!==o?o:.1,e.fill(r)),e.restore()}an.displayName="NetworkSVGOverlay";const dn={category10:c.schemeCategory10,tableau10:c.schemeTableau10,set3:c.schemeSet3,blues:c.interpolateBlues,reds:c.interpolateReds,greens:c.interpolateGreens,oranges:c.interpolateOranges,purples:c.interpolatePurples,viridis:c.interpolateViridis,plasma:c.interpolatePlasma},hn=c.schemeCategory10,gn=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"];function fn(e,t,n){if("function"==typeof t)return t(e);const o=e[t];return n?n(o):hn[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(o+""))%hn.length]}function yn(e,t,n="category10"){const r=Array.from(new Set(e.map(e=>e[t]))),i=r.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return o.scaleOrdinal().domain(r).range(n).unknown("#999");const a=dn[n]||dn.category10;if(i&&"function"==typeof a)return e=>a(Number(e)/Math.max(...r.map(Number)));{const e=Array.isArray(a)?a:hn;return o.scaleOrdinal().domain(r).range(e).unknown("#999")}}function pn(e,t,n=[3,20],o){let r;if(r="function"==typeof t?t(e):e[t],!o)return r;const[i,a]=o,[s,l]=n;return a===i?(s+l)/2:s+(r-i)/(a-i)*(l-s)}const mn={top:20,right:80,bottom:20,left:80},vn={top:40,right:40,bottom:40,left:40},bn=new Set(["chord","force","circlepack"]),xn=[800,600],kn={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function wn({data:e}){var t,n,o,r,i,a;if("edge"===e.type){const t=e.data;return f.createElement("div",{className:"semiotic-tooltip",style:kn},f.createElement("div",{style:{fontWeight:600}},"object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target),null!=t.value&&f.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""))}const s=e.data,l=null==s?void 0:s.__hierarchyNode;if(l){const e=[];let i=l;for(;i;){const a=null!==(r=null!==(n=null===(t=i.data)||void 0===t?void 0:t.name)&&void 0!==n?n:null===(o=i.data)||void 0===o?void 0:o.id)&&void 0!==r?r:s.id;null!=a&&e.unshift(a+""),i=i.parent}e.length>1&&e.shift();const a=e.length-1;return f.createElement("div",{className:"semiotic-tooltip",style:kn},f.createElement("div",null,e.map((e,t)=>f.createElement("span",{key:t},t>0&&f.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),t===a?f.createElement("strong",null,e):f.createElement("span",{style:{opacity:.7}},e)))),null!=s.value&&s.value>0&&f.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof s.value?s.value.toLocaleString():s.value+""))}const c=((null===(i=s.sourceLinks)||void 0===i?void 0:i.length)||0)+((null===(a=s.targetLinks)||void 0===a?void 0:a.length)||0),u=(s.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(s.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return f.createElement("div",{className:"semiotic-tooltip",style:kn},f.createElement("div",{style:{fontWeight:600}},s.id),null!=s.value&&s.value>0&&f.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof s.value?s.value.toLocaleString():s.value+""),c>0&&f.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",c,u!==c&&` (weighted: ${u.toLocaleString()})`))}const An=e.forwardRef(function(t,n){var o,r,i;const{chartType:a,nodes:l,edges:c,data:u,initialEdges:d,nodeIDAccessor:h="id",sourceAccessor:g="source",targetAccessor:y="target",valueAccessor:p="value",childrenAccessor:m,hierarchySum:v,orientation:b="horizontal",nodeAlign:x="justify",nodePaddingRatio:k=.05,nodeWidth:w=15,iterations:A=300,forceStrength:E=.1,padAngle:S=.01,groupWidth:L=20,sortGroups:O,edgeSort:M,treeOrientation:C="vertical",edgeType:j="curve",padding:P,paddingTop:H,tensionConfig:N,showParticles:B=!1,particleStyle:D,nodeStyle:W,edgeStyle:T,colorBy:R,colorScheme:_="category10",edgeColorBy:F="source",edgeOpacity:Y=.5,colorByDepth:G=!1,nodeSize:q=8,nodeSizeRange:X=[5,20],nodeLabel:V,showLabels:U=!0,size:Z=xn,responsiveWidth:Q,responsiveHeight:K,margin:J,className:ee,background:te,enableHover:ne=!0,tooltipContent:oe,customHoverBehavior:re,customClickBehavior:ie,onObservation:ae,chartId:le,onTopologyChange:ce,annotations:ue,svgAnnotationRules:de,legend:he,legendHoverBehavior:ge,legendClickBehavior:fe,legendHighlightedCategory:ye,legendIsolatedCategories:pe,title:me,foregroundGraphics:ve,backgroundGraphics:be,decay:xe,pulse:ke,staleness:we,thresholds:Ae}=t,Ee=bn.has(a)?vn:mn,[Se,Le]=$(Z,Q,K),Oe=Object.assign(Object.assign({},Ee),J),Me=Le[0]-Oe.left-Oe.right,Ce=Le[1]-Oe.top-Oe.bottom,je=e.useMemo(()=>Object.assign(Object.assign({},Fe),N),[N]),Pe=e.useMemo(()=>Object.assign(Object.assign({},Ye),D),[D]),He=e.useMemo(()=>({chartType:a,nodeIDAccessor:h,sourceAccessor:g,targetAccessor:y,valueAccessor:p,childrenAccessor:m,hierarchySum:v,orientation:b,nodeAlign:x,nodePaddingRatio:k,nodeWidth:w,iterations:A,forceStrength:E,padAngle:S,groupWidth:L,sortGroups:O,edgeSort:M,treeOrientation:C,edgeType:j,padding:P,paddingTop:H,tensionConfig:je,showParticles:B,particleStyle:Pe,nodeStyle:W,edgeStyle:T,nodeLabel:V,showLabels:U,colorBy:R,colorScheme:_,edgeColorBy:F,edgeOpacity:Y,colorByDepth:G,nodeSize:q,nodeSizeRange:X,decay:xe,pulse:ke,staleness:we,thresholds:Ae}),[a,h,g,y,p,m,v,b,x,k,w,A,E,S,L,O,M,C,j,P,H,je,B,Pe,W,T,V,U,R,_,F,Y,G,q,X,xe,ke,we,Ae]),Ne=e.useRef(null),Be=e.useRef(0),De=e.useRef(0),We=e.useRef(!0),Te=e.useRef(()=>{}),Ie=e.useRef(null);Ie.current||(Ie.current=new Qt(He));const[Re,$e]=e.useState(null),[ze,_e]=e.useState(0),[Ge,qe]=e.useState(0),[Xe,Ve]=e.useState(!1),Ue=e.useRef(null),Ze=e.useRef(new Map),Qe=e.useRef(0),Ke=e.useCallback(e=>{if("function"==typeof R)return R(e)+"";if("string"==typeof R&&e.data){const t=e.data[R];if(void 0!==t){if(!Ze.current.has(t+"")){const e=Array.isArray(_)?_:hn;Ze.current.set(t+"",e[Qe.current++%e.length])}return Ze.current.get(t+"")}}if(!Ze.current.has(e.id)){const t=Array.isArray(_)?_:hn;Ze.current.set(e.id,t[Qe.current++%t.length])}return Ze.current.get(e.id)},[R,_]),Je=e.useCallback(e=>{if("function"==typeof F)return F(e);const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;return"target"===F&&n?Ke(n):t?Ke(t):"#999"},[F,Ke]),et=e.useCallback(e=>{if(!(null==D?void 0:D.colorBy))return Je(e);const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;return"target"===Pe.colorBy&&n?Ke(n):t?Ke(t):"#999"},[null==D?void 0:D.colorBy,Pe.colorBy,Ke,Je]),tt="sankey"===a&&B||!!ke,nt=e.useCallback(()=>{Be.current&&!tt||Be.current||(Be.current=requestAnimationFrame(()=>Te.current()))},[tt]);e.useEffect(()=>{var e;null===(e=Ie.current)||void 0===e||e.updateConfig(He),We.current=!0,nt()},[He,nt]);const ot=e.useCallback(()=>{const e=Ie.current;if(!e)return;e.runLayout([Me,Ce]),e.buildScene([Me,Ce]),We.current=!0;const t=Array.isArray(_)?_:hn,n=Array.from(e.nodes.values());for(let e=0;n.length>e;e++){const o=n[e];Ze.current.has(o.id)||Ze.current.set(o.id,t[e%t.length])}if(Qe.current=n.length,_e(e.layoutVersion),ce){const{nodes:t,edges:n}=e.getLayoutData();ce(t,n)}},[Me,Ce,ce,_]),rt=e.useCallback(e=>{const t=Ie.current;t&&(t.ingestEdge(e)&&ot(),nt())},[ot,nt]),it=e.useCallback(e=>{const t=Ie.current;if(!t)return;let n=!1;for(const o of e)t.ingestEdge(o)&&(n=!0);n&&ot(),nt()},[ot,nt]),at=e.useCallback(()=>{var e;null===(e=Ie.current)||void 0===e||e.clear(),Ze.current.clear(),Qe.current=0,_e(0),$e(null),Ue.current=null,We.current=!0,nt()},[nt]),st=e.useCallback(()=>{const e=Ie.current;e&&(e.tension+=999,ot(),nt())},[ot,nt]);e.useImperativeHandle(n,()=>({push:rt,pushMany:it,clear:at,getTopology:()=>{var e,t;return null!==(t=null===(e=Ie.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=Ie.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:st,getTension:()=>{var e,t;return null!==(t=null===(e=Ie.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[rt,it,at,st]);const lt=["tree","cluster","treemap","circlepack","partition"].includes(a),ct=lt?u||(Array.isArray(c)?void 0:c):void 0;e.useEffect(()=>{const e=Ie.current;if(e)if(lt&&ct)e.ingestHierarchy(ct,[Me,Ce]),e.buildScene([Me,Ce]),We.current=!0,nt();else{const t=l||[],n=Array.isArray(c)?c:[];if(0===t.length&&0===n.length)return;e.ingestBounded(t,n,[Me,Ce]),e.buildScene([Me,Ce]);const o=Array.isArray(_)?_:hn,r=Array.from(e.nodes.values());for(let e=0;r.length>e;e++){const t=r[e];Ze.current.has(t.id)||Ze.current.set(t.id,o[e%o.length])}Qe.current=r.length,We.current=!0,nt()}},[l,c,u,ct,lt,Me,Ce,He,nt,_]),e.useEffect(()=>{d&&d.length>0&&it(d)},[]);const ut=e.useCallback(e=>{if(re&&re(e),ae){const t=Date.now();ae(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:le}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:le})}},[re,ae,le]),dt=e.useCallback(e=>{if(ie&&ie(e),ae){const t=Date.now();ae(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:le}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:le})}},[ie,ae,le]),ht=e.useRef(()=>{}),gt=e.useRef(()=>{});ht.current=e=>{if(!ne)return;const t=Ne.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Oe.left,r=e.clientY-n.top-Oe.top;if(0>o||o>Me||0>r||r>Ce)return void(Ue.current&&(Ue.current=null,$e(null),ut&&(ut(null),We.current=!0),nt()));const i=Ie.current;if(!i)return;const a=Jt(i.sceneNodes,i.sceneEdges,o,r);if(!a)return void(Ue.current&&(Ue.current=null,$e(null),ut&&(ut(null),We.current=!0),nt()));const s={type:a.type,data:a.datum,x:a.x,y:a.y};Ue.current=s,$e(s),ut&&(ut(s),We.current=!0),nt()},gt.current=()=>{Ue.current&&(Ue.current=null,$e(null),ut&&(ut(null),We.current=!0),nt())};const ft=e.useRef(()=>{});ft.current=e=>{if(!ie&&!ae)return;const t=Ne.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Oe.left,r=e.clientY-n.top-Oe.top;if(0>o||o>Me||0>r||r>Ce)return;const i=Ie.current;if(!i)return;const a=Jt(i.sceneNodes,i.sceneEdges,o,r);dt(a?{type:a.type,data:a.datum,x:a.x,y:a.y}:null)},e.useCallback(e=>ht.current(e),[]);const yt=e.useCallback(()=>gt.current(),[]),pt=e.useCallback(e=>ft.current(e),[]),mt=e.useRef(-1),vt=e.useCallback(e=>{const t=Ie.current;if(!t)return;const n=function(e){const t=[];for(const n of e)"circle"===n.type&&null!=n.cx?t.push({x:n.cx,y:n.cy,datum:n.datum}):"rect"===n.type&&null!=n.x?t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum}):"arc"===n.type&&null!=n.cx&&t.push({x:n.cx,y:n.cy,datum:n.datum});return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.sceneNodes);if(0===n.length)return;const o=mt.current,r=I(e.key,0>o?-1:o,n.length);if(null===r)return;if(e.preventDefault(),0>r)return mt.current=-1,Ue.current=null,$e(null),ut&&(ut(null),We.current=!0),void nt();const i=0>o?0:r;mt.current=i;const a=n[i],s={type:"node",data:a.datum,x:a.x,y:a.y};Ue.current=s,$e(s),ut&&(ut(s),We.current=!0),nt()},[ut,nt]),bt=e.useCallback(e=>{mt.current=-1,ht.current(e)},[]);Te.current=()=>{var e,t,n;Be.current=0;const o=Ne.current;if(!o)return;const r=o.getContext("2d");if(!r)return;const i=Ie.current;if(!i)return;const a=performance.now(),s=De.current?Math.min((a-De.current)/1e3,.1):.016;De.current=a;const l=i.advanceTransition(a);(l||We.current)&&i.buildScene([Me,Ce]);const c="undefined"!=typeof window&&window.devicePixelRatio||1;o.width=Le[0]*c,o.height=Le[1]*c,o.style.width=Le[0]+"px",o.style.height=Le[1]+"px",r.scale(c,c),r.translate(Oe.left,Oe.top),r.clearRect(-Oe.left,-Oe.top,Le[0],Le[1]),te&&(r.fillStyle=te,r.fillRect(0,0,Me,Ce)),xe&&i.applyDecay(),ke&&i.applyPulse(a),Ae&&i.applyThresholds(a),i.applyTopologyDiff(a);const u=null!==(e=null==we?void 0:we.threshold)&&void 0!==e?e:5e3,d=we&&i.lastIngestTime>0&&a-i.lastIngestTime>u;if(d&&(r.globalAlpha=null!==(t=null==we?void 0:we.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const n of t)switch(n.type){case"bezier":sn(e,n);break;case"line":ln(e,n);break;case"ribbon":cn(e,n);break;case"curved":un(e,n)}}(r,i.sceneEdges),function(e,t){var n,o,r;for(const i of t){if("rect"!==i.type)continue;const t=i;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.strokeRect(t.x,t.y,t.w,t.h)),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.restore())}}(r,i.sceneNodes),function(e,t){var n,o,r,i;for(const a of t){if("circle"!==a.type)continue;const t=a;if(t.r>0){if(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0){const n=null!==(i=t._pulseGlowRadius)&&void 0!==i?i:4,o=t.r+n*t._pulseIntensity;e.beginPath(),e.arc(t.cx,t.cy,o,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=.6*t._pulseIntensity,e.stroke()}e.restore()}}}(r,i.sceneNodes),function(e,t){var n,o,r;for(const i of t){if("arc"!==i.type)continue;const t=i;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.stroke()),e.restore()}}(r,i.sceneNodes),B&&i.particlePool&&!d){const e=Array.from(i.edges.values());if(e.length>0){!function(e,t,n,o){var r,i;const a=null!==(r=o.spawnRate)&&void 0!==r?r:Ye.spawnRate,s=null!==(i=o.maxPerEdge)&&void 0!==i?i:Ye.maxPerEdge;for(let o=0;t.length>o;o++){const r=t[o];if(!r.bezier)continue;if(e.countForEdge(o)>=s)continue;const i=r.value*a*n*(r.bezier.circular?.3:1),l=Math.floor(i),c=i-l;let u=l;Math.random()<c&&u++;for(let t=0;u>t&&e.countForEdge(o)<s;t++)e.spawn(o)}}(i.particlePool,e,s,Pe);const t=.5*(null!==(n=Pe.speedMultiplier)&&void 0!==n?n:1);let o;if(Pe.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);o=e.map(e=>.3+(e.value||1)/t*1.7)}i.particlePool.step(s,t,e,o),function(e,t,n,o,r){var i,a;const s=null!==(i=o.radius)&&void 0!==i?i:Ye.radius,l=null!==(a=o.opacity)&&void 0!==a?a:Ye.opacity;e.globalAlpha=l;for(let i=0;t.particles.length>i;i++){const a=t.particles[i];if(!a.active)continue;const l=n[a.edgeIndex];if(l){if("function"==typeof o.color){const t="object"==typeof l.source?l.source:null;e.fillStyle=t?o.color(l,t):"#666"}else e.fillStyle=o.color&&"inherit"!==o.color?o.color:r(l);e.beginPath(),e.arc(a.x,a.y,s,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(r,i.particlePool,e,Pe,et)}}d&&(r.globalAlpha=1);const h=We.current;We.current=!1,(h||l)&&qe(e=>e+1),(tt||l||i.hasActivePulses||i.hasActiveThresholds||i.hasActiveTopologyDiff)&&(Be.current=requestAnimationFrame(()=>Te.current()))},e.useEffect(()=>(nt(),()=>{Be.current&&(cancelAnimationFrame(Be.current),Be.current=0)}),[nt]),e.useEffect(()=>{We.current=!0,nt()},[a,Me,Ce,te,nt]),z(we,Ie,We,nt,Xe,Ve);const xt=ne&&Re?f.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:Oe.left+Re.x,top:Oe.top+Re.y,transform:`translate(${Re.x>.6*Me?"calc(-100% - 12px)":"12px"}, ${.3*Ce>Re.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2}},oe?oe(Re):f.createElement(wn,{data:Re})):null;if(se){const e=Ie.current;if(e){const t=["tree","cluster","treemap","circlepack","partition"].includes(a),n=t?u||(Array.isArray(c)?void 0:c):void 0;if(t&&n)e.ingestHierarchy(n,[Me,Ce]),e.buildScene([Me,Ce]);else{const t=l||[],n=Array.isArray(c)?c:[];(t.length>0||n.length>0)&&(e.ingestBounded(t,n,[Me,Ce]),e.buildScene([Me,Ce]))}}const t=null!==(o=null==e?void 0:e.sceneNodes)&&void 0!==o?o:[],n=null!==(r=null==e?void 0:e.sceneEdges)&&void 0!==r?r:[],d=null!==(i=null==e?void 0:e.labels)&&void 0!==i?i:[];return f.createElement("div",{className:"stream-network-frame"+(ee?" "+ee:""),role:"img","aria-label":"string"==typeof me?me:"Network chart",style:{position:"relative",width:Le[0],height:Le[1]}},f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Le[0],height:Le[1],style:{position:"absolute",left:0,top:0}},be&&f.createElement("g",{transform:`translate(${Oe.left},${Oe.top})`},be),f.createElement("g",{transform:`translate(${Oe.left},${Oe.top})`},te&&f.createElement("rect",{x:0,y:0,width:Me,height:Ce,fill:te}),n.map((e,t)=>function(e,t){switch(e.type){case"line":return f.createElement("line",{key:"net-edge-"+t,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity});case"bezier":case"ribbon":return f.createElement("path",{key:"net-edge-"+t,d:e.pathD,fill:e.style.fill||"#999",fillOpacity:e.style.fillOpacity,stroke:e.style.stroke||"none",strokeWidth:e.style.strokeWidth,opacity:e.style.opacity});case"curved":return f.createElement("path",{key:"net-edge-"+t,d:e.pathD,fill:e.style.fill||"none",stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity});default:return null}}(e,t)).filter(Boolean),t.map((e,t)=>function(e,t){switch(e.type){case"circle":return f.createElement("circle",{key:"net-circle-"+t,cx:e.cx,cy:e.cy,r:e.r,fill:e.style.fill||"#4e79a7",stroke:e.style.stroke,strokeWidth:e.style.strokeWidth,opacity:e.style.opacity});case"rect":return f.createElement("rect",{key:"net-rect-"+t,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.style.fill||"#4e79a7",stroke:e.style.stroke,strokeWidth:e.style.strokeWidth,opacity:e.style.opacity});case"arc":{const n=e,o=s.arc().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle).endAngle(n.endAngle)({})||"";return f.createElement("path",{key:"net-arc-"+t,d:o,transform:`translate(${n.cx},${n.cy})`,fill:n.style.fill||"#4e79a7",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}default:return null}}(e,t)).filter(Boolean),d.map((e,t)=>function(e,t){return f.createElement("text",{key:"net-label-"+t,x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"#333",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder},e.text)}(e,t)).filter(Boolean))),f.createElement(an,{width:Me,height:Ce,totalWidth:Le[0],totalHeight:Le[1],margin:Oe,labels:d,sceneNodes:t,title:me,legend:he,legendHoverBehavior:ge,legendClickBehavior:fe,legendHighlightedCategory:ye,legendIsolatedCategories:pe,foregroundGraphics:ve,annotations:ue,svgAnnotationRules:de,annotationFrame:0}))}const kt=Ie.current;return f.createElement("div",{ref:Se,className:"stream-network-frame"+(ee?" "+ee:""),role:"img","aria-label":"string"==typeof me?me:"Network chart",tabIndex:0,style:{position:"relative",width:Q?"100%":Le[0],height:K?"100%":Le[1]},onMouseMove:ne?bt:void 0,onMouseLeave:ne?yt:void 0,onClick:ie||ae?pt:void 0,onKeyDown:vt},be&&f.createElement("svg",{style:{position:"absolute",top:0,left:0,width:Le[0],height:Le[1],pointerEvents:"none"}},f.createElement("g",{transform:`translate(${Oe.left},${Oe.top})`},be)),f.createElement("canvas",{ref:Ne,style:{position:"absolute",top:0,left:0}}),f.createElement(an,{width:Me,height:Ce,totalWidth:Le[0],totalHeight:Le[1],margin:Oe,labels:(null==kt?void 0:kt.labels)||[],sceneNodes:null==kt?void 0:kt.sceneNodes,title:me,legend:he,legendHoverBehavior:ge,legendClickBehavior:fe,legendHighlightedCategory:ye,legendIsolatedCategories:pe,foregroundGraphics:ve,annotations:ue,svgAnnotationRules:de,annotationFrame:Ge}),xt,(null==we?void 0:we.showBadge)&&f.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===we.badgePosition?{top:4,left:4}:"bottom-left"===we.badgePosition?{bottom:4,left:4}:"bottom-right"===we.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Xe?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},Xe?"STALE":"LIVE"))});An.displayName="StreamNetworkFrame";const En={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"8px 12px",borderRadius:"4px",fontSize:"14px",lineHeight:"1.5",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function Sn(e,t){return"function"==typeof t?t(e):e[t]}function Ln(e,t){return t?t(e):null==e?"":"number"==typeof e?e.toLocaleString():e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function On(e={}){const{fields:t,title:n,format:o,style:r={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let a;const s=[];if(n){const t=Sn(e,n);a=Ln(t,o)}if(t&&t.length>0)t.forEach(t=>{let n,r,i;"string"==typeof t?(n=t,r=t,i=o):(n=t.label,r=t.accessor||t.key||"",i=t.format||o);const a=Sn(e,r);s.push({label:n,value:Ln(a,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){a=Ln(e[n],o);break}if(!a){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(a=Ln(e[t[0]],o))}}const l=Object.assign(Object.assign({},En),r);return f.createElement("div",{className:("semiotic-tooltip "+i).trim(),style:l},a&&f.createElement("div",{style:{fontWeight:s.length>0?"bold":"normal"}},a),s.map((e,t)=>f.createElement("div",{key:t,style:{marginTop:0===t&&a?"4px":0}},e.label&&f.createElement("span",null,e.label,": "),e.value)))}}function Mn(e){return!0===e?On():"function"==typeof e?e:!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?On(e):On())}function Cn(e){return"string"==typeof e?e:"value"}function jn(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function Pn(e,t){return"function"==typeof t?t(e):e[t]}function Hn(e){return t=>{const n=t.data;return n?f.createElement("div",{className:"semiotic-tooltip",style:En},e.map((e,t)=>{const o=jn(Pn(n,e.accessor));return f.createElement("div",{key:t,style:t>0?{marginTop:2}:void 0},f.createElement("span",{style:{opacity:.8}},e.label,": "),f.createElement("span",{style:{fontWeight:"color"===e.role||"group"===e.role?"bold":"normal"}},o))})):null}}function Nn({categoryAccessor:e,valueAccessor:t,groupAccessor:n,groupLabel:o,pieData:r=!1}){return i=>{var a;const s=r?(null===(a=i.data)||void 0===a?void 0:a[0])||i.data||i:i.data||i,l=Pn(s,e),c=Pn(s,t),u=n?Pn(s,n):void 0;return f.createElement("div",{className:"semiotic-tooltip",style:En},f.createElement("div",{style:{fontWeight:"bold"}},jn(l)),f.createElement("div",{style:{marginTop:4}},jn(c)),null!=u&&f.createElement("div",{style:{marginTop:2,opacity:.8}},o||Cn(n),": ",jn(u)))}}const Bn=e.createContext(null);function Dn({colors:t,categories:n,colorScheme:o="category10",children:r}){const i=e.useMemo(()=>{if(t)return t;if(n){const e=Array.isArray(o)?o:dn[o]||hn,t={};for(let o=0;n.length>o;o++)t[n[o]]=e[o%e.length];return t}return{}},[t,n,o]);return f.createElement(Bn.Provider,{value:i},r)}function Wn(){return e.useContext(Bn)}Dn.displayName="CategoryColorProvider";const Tn="undefined"!=typeof window?e.useLayoutEffect:e.useEffect;function In(t){const n=e.createContext(null),o=Rn(t);return[function({children:o}){const r=e.useMemo(()=>Rn(t),[]);return f.createElement(n.Provider,{value:r,children:o})},t=>{var r;const i=null!==(r=e.useContext(n))&&void 0!==r?r:o;return function(t,n){const[o,r]=e.useState(n);return Tn(()=>t(()=>r(n)),[t]),o}(i.subscribe,()=>t(i.getState()))}]}function Rn(e){const t=new EventTarget;let n=e(function(e){n=Object.assign(Object.assign({},n),e(n)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}function $n(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,r]=o.range;t.push(t=>{const o=t[n];return o>=e&&r>=o})}return e=>t.every(t=>t(e))}function zn(e,t){const n=[];for(const[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push($n(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}function _n(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[Fn,Yn]=In(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),r=_n(o,t),i=new Map(r.clauses);return i.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},r),{clauses:i})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const r=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),r.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:r}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),r=_n(o,t);return o.set(t,Object.assign(Object.assign({},r),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}})),[Gn,qn]=In(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function Xn(t){const n=e.useId(),o=t.clientId||n,{name:r}=t,i=Yn(e=>e.selections.get(r)),a=Yn(e=>e.setClause),s=Yn(e=>e.clearClause),l=e.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:e.useMemo(()=>i&&0!==i.clauses.size?zn(i,o):()=>!0,[i,o]),isActive:l,selectPoints:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};a(r,{clientId:o,type:"point",fields:t})},[o,r,a]),selectInterval:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};a(r,{clientId:o,type:"interval",fields:t})},[o,r,a]),clear:e.useCallback(()=>{s(r,o)},[s,r,o]),clientId:o}}function Vn(t){const n=t.name||"hover",{fields:o}=t,{predicate:r,isActive:i,selectPoints:a,clear:s}=Xn({name:n});return{onHover:e.useCallback(e=>{if(!e)return void s();const t={};for(const n of o){const o=e[n];void 0!==o&&(t[n]=[o])}Object.keys(t).length>0&&a(t)},[o,a,s,n]),predicate:r,isActive:i}}function Un(t){const{name:n,xField:o,yField:r}=t,{predicate:i,isActive:a,selectInterval:s,clear:l}=Xn({name:n}),c=o&&r?"xyBrush":o?"xBrush":"yBrush",u=e.useCallback(e=>{if(!e)return void l();const t={};"xyBrush"===c&&Array.isArray(e)&&2===e.length?(o&&(t[o]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),r&&(t[r]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&Array.isArray(e)?o&&(t[o]=[Math.min(...e),Math.max(...e)]):"yBrush"===c&&Array.isArray(e)&&r&&(t[r]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&s(t)},[c,o,r,s,l]);return{brushInteraction:e.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:i,isActive:a,clear:l}}function Zn(t={}){const{limit:n=50,types:o,chartId:r}=t,i=qn(e=>e.version),a=qn(e=>e.observations),s=qn(e=>e.clearObservations),l=e.useMemo(()=>{let e=a;if(o&&o.length>0){const t=new Set(o);e=e.filter(e=>t.has(e.type))}return r&&(e=e.filter(e=>e.chartId===r)),e.length>n&&(e=e.slice(e.length-n)),e},[a,o,r,n,i]);return{observations:l,latest:l.length>0?l[l.length-1]:null,clear:s}}const Qn=e.createContext(!1);function Kn({selections:t}){const n=Yn(e=>e.setResolution);return e.useEffect(()=>{for(const[e,o]of Object.entries(t))o.resolution&&n(e,o.resolution)},[t,n]),null}function Jn({categoryColors:t,interaction:n,selectionName:o,field:r}){const i=Object.entries(t);if(0===i.length)return null;const a=i.map(([e])=>e),s=[{styleFn:e=>({fill:e.color,stroke:e.color}),type:"fill",items:i.map(([e,t])=>({label:e,color:t})),label:""}],l=Vn({name:o,fields:[r]}),c=Xn({name:o,clientId:"__linked-legend-isolate__"}),[u,d]=e.useState(new Set),[h,g]=e.useState(null),y=e.useRef(c.selectPoints);y.current=c.selectPoints;const p=e.useRef(c.clear);p.current=c.clear,e.useEffect(()=>{"isolate"===n&&(u.size>0?y.current({[r]:Array.from(u)}):p.current())},[n,u,r]);const m=e.useCallback(e=>{"highlight"===n&&(e?(g(e.label),l.onHover({[r]:e.label})):(g(null),l.onHover(null)))},[n,r,l]),v=e.useCallback(e=>{"isolate"===n&&d(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===a.length?new Set:n})},[n,a.length]);return f.createElement("svg",{width:"100%",height:30,style:{display:"block",overflow:"visible"}},f.createElement(q,{legendGroups:s,title:!1,orientation:"horizontal",height:20,customHoverBehavior:"highlight"===n?m:void 0,customClickBehavior:"isolate"===n?v:void 0,highlightedCategory:h,isolatedCategories:u}))}function eo({children:e,selections:t,showLegend:n,legendPosition:o="top",legendInteraction:r="none",legendSelectionName:i="legend",legendField:a="category"}){const s=Wn(),l=void 0!==n?n:!(!s||0>=Object.keys(s).length);return f.createElement(Fn,null,f.createElement(Gn,null,t&&f.createElement(Kn,{selections:t}),f.createElement(Qn.Provider,{value:l},l&&"top"===o&&s&&f.createElement(Jn,{categoryColors:s,interaction:r,selectionName:i,field:a}),e,l&&"bottom"===o&&s&&f.createElement(Jn,{categoryColors:s,interaction:r,selectionName:i,field:a}))))}function to(e){return e?"string"==typeof e?{name:e}:e:null}function no(e,t,n){return t?o=>{var r;const i=Object.assign({},e(o));if(t.isActive)if(t.predicate(o))(null==n?void 0:n.selectedStyle)&&Object.assign(i,n.selectedStyle);else{const e=null!==(r=null==n?void 0:n.unselectedOpacity)&&void 0!==r?r:.2;i.opacity=e,i.fillOpacity=e,i.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(i,n.unselectedStyle)}return i}:e}const oo="#007bff";function ro(e){return"function"==typeof e?e:t=>t[e]}function io(t,n,o="category10"){const r=Wn();return e.useMemo(()=>{if(n&&"function"!=typeof n)return r&&Object.keys(r).length>0?e=>r[e]||yn(t,n,o)(e):yn(t,n,o)},[t,n,o,r])}function ao(t,n,o){return e.useMemo(()=>{if(!n)return t;const e=[...t];if("function"==typeof n)return e.sort(n);const r=ro(o);return e.sort("asc"===n?(e,t)=>r(e)-r(t):(e,t)=>r(t)-r(e))},[t,n,o])}function so({selection:t,linkedHover:n,fallbackFields:o=[],unwrapData:r=!1,onObservation:i,chartType:a,chartId:s}){const l=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields}:null}(n,o),c=Xn({name:(null==t?void 0:t.name)||"__unused__"}),u=Vn({name:(null==l?void 0:l.name)||"hover",fields:(null==l?void 0:l.fields)||o||[]}),d=qn(e=>e.pushObservation),h=t?{isActive:c.isActive,predicate:c.predicate}:null,g=e.useCallback(e=>{var t,o;if(n)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]),u.onHover(t)}else u.onHover(null);if(i||d){const n={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const a=Object.assign(Object.assign({},n),{type:"hover",datum:r||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(a),d&&d(a)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(e),d&&d(e)}}},[n,u,i,a,s,d]),f=e.useCallback(e=>{var t,n;if(i||d){const o={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const a=Object.assign(Object.assign({},o),{type:"click",datum:r||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});i&&i(a),d&&d(a)}else{const e=Object.assign(Object.assign({},o),{type:"click-end"});i&&i(e),d&&d(e)}}},[i,d,a,s]);return{activeSelectionHook:h,customHoverBehavior:g,customClickBehavior:f}}function lo({data:t,colorBy:n,colorScale:o,showLegend:r,userMargin:i,defaults:a={top:50,bottom:60,left:70,right:40}}){const s=e.useContext(Qn),l=void 0!==r?r:!s&&!!n,c=e.useMemo(()=>{if(l&&n)return function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:r,strokeWidth:i}){const a=Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(r=>{const i=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),a=i?o(i,t,n):n?n(r):"#000000";return{label:r+"",color:a}});return{legendGroups:[{styleFn:e=>{const t={fill:e.color,stroke:e.color};return void 0!==r&&(t.stroke=r),void 0!==i&&(t.strokeWidth=i),t},type:"fill",items:a,label:""}]}}({data:t,colorBy:n,colorScale:o,getColor:fn})},[l,n,t,o]),u=e.useMemo(()=>{const e=Object.assign(Object.assign({},a),i);return c&&120>e.right&&(e.right=120),e},[a,i,c]);return{legend:c,margin:u}}function co(t,n,o){const[r,i]=e.useState(null),[a,s]=e.useState(new Set),l=e.useCallback(e=>{"highlight"===t&&i(e?e.label:null)},[t]),c=e.useCallback(e=>{"isolate"===t&&s(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===o.length?new Set:n})},[t,o.length]),u=e.useMemo(()=>{if(!t||"none"===t||!n)return null;const e="string"==typeof n?n:null;return"highlight"===t&&null!=r?{isActive:!0,predicate:t=>(e?t[e]:"function"==typeof n?n(t):null)===r}:"isolate"===t&&a.size>0?{isActive:!0,predicate:t=>{const o=e?t[e]:"function"==typeof n?n(t):null;return a.has(o)}}:null},[t,n,r,a]);return{highlightedCategory:"highlight"===t?r:null,isolatedCategories:"isolate"===t?a:new Set,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}const uo={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function ho(e,t,n){var o,r,i,a,s,l;const c=uo[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:e&&"primary"!==e||!(null==n?void 0:n.width)?c.width:n.width,height:null!==(r=t.height)&&void 0!==r?r:e&&"primary"!==e||!(null==n?void 0:n.height)?c.height:n.height,showAxes:c.showAxes,showGrid:null!==(i=t.showGrid)&&void 0!==i?i:c.showGrid,enableHover:null!==(a=t.enableHover)&&void 0!==a?a:!!t.linkedHover||c.enableHover,showLegend:null!==(s=t.showLegend)&&void 0!==s?s:c.showLegend,showLabels:null!==(l=t.showLabels)&&void 0!==l?l:c.showLabels,title:u?void 0:t.title,xLabel:u?void 0:t.xLabel,yLabel:u?void 0:t.yLabel,categoryLabel:u?void 0:t.categoryLabel,valueLabel:u?void 0:t.valueLabel,marginDefaults:c.marginDefaults}}function go({componentName:e,message:t,width:n,height:o}){return f.createElement("div",{role:"alert",style:{width:n,height:Math.max(o,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},f.createElement("div",{style:{textAlign:"center",maxWidth:400}},f.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),f.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t)))}class fo extends f.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:f.createElement(go,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}var yo;const po="undefined"!=typeof process&&"production"!==(null===(yo=process.env)||void 0===yo?void 0:yo.NODE_ENV);function mo({componentName:e,width:t,height:n,children:o}){return f.createElement(fo,{fallback:o=>f.createElement(go,{componentName:e,message:o.message,width:t,height:n})},o)}const vo={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},bo={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function xo(e,t,n,o){return!1===o||e&&Array.isArray(e)&&e.length>0||e&&!Array.isArray(e)?null:f.createElement("div",{style:Object.assign(Object.assign({},vo),{width:t,height:n})},o||"No data available")}function ko(e,t,n){if(!e)return null;const o=Math.min(5,Math.floor(n/40)),r=Math.max(8,Math.floor(n/(3*o))),i=Math.max(6,Math.floor(n/(2.5*o))),a=Math.floor((n-(o*(r+i)-i))/2);return f.createElement("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:o},(e,n)=>f.createElement("div",{key:n,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},bo),{position:"absolute",top:a+n*(r+i),left:Math.floor(.1*t),width:30+Math.round(50*Math.random())+"%",height:r,opacity:.5+n%2*.2})})))}function wo(e,t,n,o){if(!po)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const r=t[0];if(!r||"object"!=typeof r)return;if(o in r)return;const i=Object.keys(r).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${i}`)}function Ao(e,t){const n=e.length,o=t.length,r=Array(o+1);for(let e=0;o>=e;e++)r[e]=e;for(let i=1;n>=i;i++){let n=r[0];r[0]=i;for(let a=1;o>=a;a++){const o=r[a];r[a]=e[i-1]===t[a-1]?n:1+Math.min(n,r[a],r[a-1]),n=o}}return r[o]}function Eo(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function So(e,t){var n;if(0===t.length)return null;const o=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(o)||o.includes(e.toLowerCase()))||(null!==(n=function(e,t,n=3){let o,r=n+1;for(const n of t){const t=Ao(e.toLowerCase(),n.toLowerCase());r>t&&(r=t,o=n)}return r>n?void 0:o}(e,t,3))&&void 0!==n?n:null)}function Lo({componentName:e,data:t,accessors:n,requiredProps:o}){if(o)for(const[t,n]of Object.entries(o))if(null==n)return`${e}: ${t} is required. Provide a field name or function.`;if(!t||!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(n){const o=Eo(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[r,i]of Object.entries(n))if(i&&"string"==typeof i&&!(i in o)){const n=So(i,t),o=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}function Oo({componentName:e,data:t,dataLabel:n="data"}){return null==t?`${e}: No ${n} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${n} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}function Mo({componentName:e,nodes:t,edges:n,nodesRequired:o=!1,edgesRequired:r=!0,accessors:i}){if(r&&(!n||!Array.isArray(n)||0===n.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(o&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){const n=Eo(t).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[o,r]of Object.entries(i))if(r&&"string"==typeof r&&!(r in n)){const n=So(r,t),i=n?` Try ${o}="${n}".`:"";return`${e}: ${o} "${r}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}return null}function Co(t){const n=ho(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,margin:r,className:i,xFormat:a,yFormat:s,xAccessor:l="x",yAccessor:c="y",colorBy:u,colorScheme:d="category10",sizeBy:h,sizeRange:g=[3,15],pointRadius:y=5,pointOpacity:p=.8,tooltip:m,marginalGraphics:v,pointIdAccessor:b,annotations:x,frameProps:k={},selection:w,linkedHover:A,linkedBrush:E,onObservation:S,chartId:L,loading:O,emptyContent:M,legendInteraction:C}=t,j=n.width,P=n.height,H=n.enableHover,N=n.showGrid,B=n.showLegend,D=n.title,W=n.xLabel,T=n.yLabel,I=ko(O,j,P);if(I)return I;const R=xo(o,j,P,M);if(R)return R;const $=o||[];wo("Scatterplot",$,"xAccessor",l),wo("Scatterplot",$,"yAccessor",c);const{activeSelectionHook:z,customHoverBehavior:_}=so({selection:w,linkedHover:A,fallbackFields:u?["string"==typeof u?u:""]:[],onObservation:S,chartType:"Scatterplot",chartId:L}),F=to(E),Y=Un({name:(null==F?void 0:F.name)||"__unused_brush__",xField:(null==F?void 0:F.xField)||("string"==typeof l?l:void 0),yField:(null==F?void 0:F.yField)||("string"==typeof c?c:void 0)}),G=F?"xyBrush"===Y.brushInteraction.brush?"xy":"xBrush"===Y.brushInteraction.brush?"x":"y":void 0,q=f.useRef(Y.brushInteraction);q.current=Y.brushInteraction;const X=e.useCallback(e=>{const t=q.current;t.end(e?"xyBrush"===t.brush?[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:"xBrush"===t.brush?e.x:e.y:null)},[]),V=io($,u,d),U=e.useMemo(()=>{if(!u)return[];const e=new Set;for(const t of $){const n="function"==typeof u?u(t):t[u];null!=n&&e.add(n+"")}return Array.from(e)},[$,u]),Z=co(C,u,U),Q=e.useMemo(()=>Z.legendSelectionHook?Z.legendSelectionHook:z,[Z.legendSelectionHook,z]),K=e.useMemo(()=>{if(!h||0===$.length)return;const e=$.map(e=>"function"==typeof h?h(e):e[h]);return[Math.min(...e),Math.max(...e)]},[$,h]),J=e.useMemo(()=>e=>{const t={fillOpacity:p};return t.fill=u?fn(e,u,V):oo,t.r=h?pn(e,h,g,K):y,t},[u,V,h,g,K,y,p]),ee=e.useMemo(()=>no(J,Q,w),[J,Q,w]),{legend:te,margin:ne}=lo({data:$,colorBy:u,colorScale:V,showLegend:B,userMargin:r,defaults:n.marginDefaults}),oe=e.useMemo(()=>Hn([{label:W||Cn(l),accessor:l,role:"x"},{label:T||Cn(c),accessor:c,role:"y"},...u?[{label:Cn(u),accessor:u,role:"color"}]:[],...h?[{label:Cn(h),accessor:h,role:"size"}]:[]]),[l,c,W,T,u,h]),re=Lo({componentName:"Scatterplot",data:$,accessors:{xAccessor:l,yAccessor:c}});if(re)return f.createElement(go,{componentName:"Scatterplot",message:re,width:j,height:P});const ie=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter",data:$,xAccessor:l,yAccessor:c,colorAccessor:u||void 0,sizeAccessor:h||void 0,sizeRange:g,pointStyle:ee,colorScheme:d,size:[j,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ne,showAxes:n.showAxes,xLabel:W,yLabel:T,xFormat:a,yFormat:s,enableHover:H,showGrid:N},te&&{legend:te}),C&&"none"!==C&&{legendHoverBehavior:Z.onLegendHover,legendClickBehavior:Z.onLegendClick,legendHighlightedCategory:Z.highlightedCategory,legendIsolatedCategories:Z.isolatedCategories}),D&&{title:D}),i&&{className:i}),{tooltipContent:Mn(m)||oe}),(A||S)&&{customHoverBehavior:_}),v&&{marginalGraphics:v}),b&&{pointIdAccessor:b}),x&&x.length>0&&{annotations:x}),F&&{brush:{dimension:G},onBrush:X}),k);return f.createElement(mo,{componentName:"Scatterplot",width:j,height:P},f.createElement(ke,Object.assign({},ie)))}function jo(t){const n=ho(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,className:r,xFormat:i,yFormat:a,xAccessor:s="x",yAccessor:l="y",orderAccessor:u,orderLabel:d,pointRadius:h=4,tooltip:g,pointIdAccessor:y,annotations:p,frameProps:m={},selection:v,linkedHover:b,onObservation:x,chartId:k,loading:w,emptyContent:A,legendInteraction:E}=t,S=n.width,L=n.height,O=n.enableHover,M=n.showGrid,C=n.title,j=n.xLabel,P=n.yLabel,H=ko(w,S,L);if(H)return H;const N=xo(o,S,L,A);if(N)return N;const B=o||[],D=e.useMemo(()=>{if(!u||0===B.length)return B;const e="function"==typeof u?u:e=>e[u];return[...B].sort((t,n)=>{const o=e(t),r=e(n);return(o instanceof Date?o.getTime():+o)-(r instanceof Date?r.getTime():+r)})},[B,u]);wo("ConnectedScatterplot",D,"xAccessor",s),wo("ConnectedScatterplot",D,"yAccessor",l);const{activeSelectionHook:W,customHoverBehavior:T}=so({selection:v,linkedHover:b,fallbackFields:[],onObservation:x,chartType:"ConnectedScatterplot",chartId:k}),I=co(E,void 0,[]),R=e.useMemo(()=>I.legendSelectionHook?I.legendSelectionHook:W,[I.legendSelectionHook,W]),$=D.length,z=$>0&&100>$,_=e.useMemo(()=>0===$?[]:D.map((e,t)=>c.interpolateViridis(1===$?.5:t/($-1))),[D,$]);e.useMemo(()=>null,[$]);const F=e.useMemo(()=>{if($>=2)return(e,t,n)=>{var o,r;if("connected-lines"!==e.type)return null;const i=n.scales;if(!i)return null;const a=null!==(o=i.x)&&void 0!==o?o:i.time,c=null!==(r=i.y)&&void 0!==r?r:i.value;if(!a||!c)return null;const u="string"==typeof s?e=>e[s]:s,d="string"==typeof l?e=>e[l]:l,g=[];for(let e=0;D.length-1>e;e++){const t=D[e],n=D[e+1],o=a(u(t)),r=c(d(t)),i=a(u(n)),s=c(d(n)),l=_[e];z&&g.push(f.createElement("line",{key:"halo-"+e,x1:o,y1:r,x2:i,y2:s,stroke:"white",strokeWidth:h+2,strokeOpacity:.5,strokeLinecap:"round"})),g.push(f.createElement("line",{key:"conn-"+e,x1:o,y1:r,x2:i,y2:s,stroke:l,strokeWidth:h,strokeLinecap:"round"}))}return f.createElement("g",{key:"ann-"+t},g)}},[D,_,h,z,s,l,$]),Y=e.useMemo(()=>e=>{const t=D.indexOf(e);return{fill:t>=0&&_.length>t?_[t]:"#6366f1",stroke:"white",strokeWidth:1,r:h,fillOpacity:1}},[D,_,h]),G=e.useMemo(()=>no(Y,R,v),[Y,R,v]),q=Object.assign({top:50,right:40,bottom:60,left:70},t.margin),X=d||("string"==typeof u?u:"Order"),V=e.useMemo(()=>Hn([{label:j||Cn(s),accessor:s,role:"x"},{label:P||Cn(l),accessor:l,role:"y"},...u?[{label:X,accessor:u,role:"group"}]:[]]),[s,l,j,P,u,X]),U=Lo({componentName:"ConnectedScatterplot",data:D,accessors:{xAccessor:s,yAccessor:l}});if(U)return f.createElement(go,{componentName:"ConnectedScatterplot",message:U,width:S,height:L});const Z=e.useMemo(()=>[{type:"connected-lines"},...p||[]],[p]),Q=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter",data:D,xAccessor:s,yAccessor:l,pointStyle:G,size:[S,L],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:q,showAxes:n.showAxes,xLabel:j,yLabel:P,xFormat:i,yFormat:a,enableHover:O,showGrid:M},C&&{title:C}),r&&{className:r}),{tooltipContent:Mn(g)||V}),(b||x)&&{customHoverBehavior:T}),y&&{pointIdAccessor:y}),{annotations:Z,svgAnnotationRules:F}),m);return f.createElement(mo,{componentName:"ConnectedScatterplot",width:S,height:L},f.createElement(ke,Object.assign({},Q)))}Co.displayName="Scatterplot",jo.displayName="ConnectedScatterplot";const Po="__forecastSegment";function Ho(e,t){return"function"==typeof t?t(e):!!e[t]}function No(t){var n,o;const r=ho(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:a,className:s,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:d="y",lineBy:h,lineDataAccessor:g="coordinates",colorBy:y,colorScheme:p="category10",curve:m="linear",showPoints:v=!1,pointRadius:b=3,fillArea:x=!1,areaOpacity:k=.3,lineWidth:w=2,tooltip:A,pointIdAccessor:E,annotations:S,directLabel:L,gapStrategy:O="break",anomaly:M,forecast:C,frameProps:j={},selection:P,linkedHover:H,onObservation:N,chartId:B,loading:D,emptyContent:W,legendInteraction:T}=t,I=r.width,R=r.height,$=r.enableHover,z=r.showGrid,_=r.showLegend,F=r.title,Y=r.xLabel,G=r.yLabel,q=ko(D,I,R);if(q)return q;const X=xo(i,I,R,W);if(X)return X;const V=i||[];wo("LineChart",V,"xAccessor",u),wo("LineChart",V,"yAccessor",d);const U="string"==typeof u?u:"x",Z="string"==typeof d?d:"y",Q=e.useMemo(()=>C?function(e,t,n,o,r){return(i=o).isTraining||i.isForecast||i.isAnomaly||i.upperBounds||i.lowerBounds?function(e,t,n,o,r){var i,a,s;const{isTraining:l,isForecast:c,isAnomaly:u,upperBounds:d,lowerBounds:h,color:g="#6366f1",bandOpacity:f=.15,anomalyColor:y="#ef4444",anomalyRadius:p=6,label:m}=o,v=e.map(e=>{let t="observed";return c&&Ho(e,c)?t="forecast":l&&Ho(e,l)&&(t="training"),Object.assign(Object.assign({},e),{[Po]:t})}),b=[];for(let e=0;v.length>e;e++)b.push(v[e]),v.length-1>e&&v[e][Po]!==v[e+1][Po]&&b.push(Object.assign(Object.assign({},v[e]),{[Po]:v[e+1][Po]}));const x=[];if(d&&h){const e="string"==typeof d?d:"__envUpper",t="string"==typeof h?h:"__envLower";if("function"==typeof d||"function"==typeof h)for(const n of b)"function"==typeof d&&(n[e]=d(n)),"function"==typeof h&&(n[t]=h(n));x.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:g,fillOpacity:f,label:m})}return u&&x.push({type:"highlight",filter:e=>Ho(e,u),color:y,r:p,style:{stroke:y,strokeWidth:1.5,fill:y,fillOpacity:.7}}),r&&x.push({type:"anomaly-band",threshold:null!==(i=r.threshold)&&void 0!==i?i:2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:null!==(a=r.bandOpacity)&&void 0!==a?a:.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:null!==(s=r.anomalyRadius)&&void 0!==s?s:6,label:r.label}),{processedData:b,annotations:x}}(e,0,0,o,r):function(e,t,n,o,r){var i,a,s;const{trainEnd:l,steps:c=10,confidence:u=.95,color:d="#6366f1",bandOpacity:h=.15,label:g}=o;if(null==l)return{processedData:e,annotations:[]};const f=[],y=[];for(const n of e)n[t]>l?y.push(Object.assign(Object.assign({},n),{[Po]:"observed"})):f.push(Object.assign(Object.assign({},n),{[Po]:"training"}));const p=f.map(e=>[e[t],e[n]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),m=[],v=[];if(p.length>=3){const o=p.length;let r=0,i=0,a=0,s=0;for(const[e,t]of p)r+=e,i+=t,a+=e*e,s+=e*t;const l=o*a-r*r;if(Math.abs(l)>1e-12){const a=(o*s-r*i)/l,f=(i-a*r)/o,y=e=>f+a*e,b=p.map(([e,t])=>t-y(e)).reduce((e,t)=>e+t*t,0),x=Math.sqrt(b/Math.max(o-2,1)),k=p.reduce((e,t)=>e+t[0],0)/o,w=p.reduce((e,t)=>e+Math.pow(t[0]-k,2),0),A=.99>u?.95>u?.9>u?1:1.645:1.96:2.576,E=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),S=Math.max(...E),L=p.length>1?(p[o-1][0]-p[0][0])/(o-1):1;for(let e=1;c>=e;e++){const r=S+e*L,i=y(r),a=x*Math.sqrt(1+1/o+(w>0?Math.pow(r-k,2)/w:0))*A;v.push({[t]:r,[n]:i,[Po]:"forecast",__forecastUpper:i+a,__forecastLower:i-a})}m.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:d,fillOpacity:h,label:g})}}m.push({type:"x-threshold",x:l,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),r&&m.push({type:"anomaly-band",threshold:null!==(i=r.threshold)&&void 0!==i?i:2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:null!==(a=r.bandOpacity)&&void 0!==a?a:.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:null!==(s=r.anomalyRadius)&&void 0!==s?s:6,label:r.label});const b=[];if(b.push(...f),f.length>0&&y.length>0&&b.push(Object.assign(Object.assign({},f[f.length-1]),{[Po]:"observed"})),b.push(...y),v.length>0){const e=y.length>0?y[y.length-1]:f[f.length-1];e&&b.push(Object.assign(Object.assign({},e),{[Po]:"forecast"})),b.push(...v)}return{processedData:b,annotations:m}}(e,t,n,o,r);var i}(V,U,Z,C,M):null,[V,C,M,U,Z]),K=e.useMemo(()=>Q?Q.annotations:M?function(e){var t,n,o;return[{type:"anomaly-band",threshold:null!==(t=e.threshold)&&void 0!==t?t:2,showBand:!1!==e.showBand,fill:e.bandColor||"#6366f1",fillOpacity:null!==(n=e.bandOpacity)&&void 0!==n?n:.1,anomalyColor:e.anomalyColor||"#ef4444",anomalyRadius:null!==(o=e.anomalyRadius)&&void 0!==o?o:6,label:e.label}]}(M):[],[Q,M]),J=Q?Q.processedData:V,ee=C&&!h?Po:h,{activeSelectionHook:te,customHoverBehavior:ne}=so({selection:P,linkedHover:H,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:N,chartType:"LineChart",chartId:B}),oe=e.useCallback(e=>{const t="function"==typeof u?u(e):e[u],n="function"==typeof d?d(e):e[d];return null==t||null==n||Number.isNaN(t)||Number.isNaN(n)},[u,d]),re=void 0!==(null===(n=J[0])||void 0===n?void 0:n[g]),ie=e.useMemo(()=>{if(re)return J;if(ee){const e=J.reduce((e,t)=>{const n="function"==typeof ee?ee(t):t[ee];if(!e[n]){const t={[g]:[]};"string"==typeof ee&&(t[ee]=n),e[n]=t}return e[n][g].push(t),e},{});return Object.values(e)}return[{[g]:J}]},[J,ee,g,re]),{gapProcessedLineData:ae,hasGaps:se}=e.useMemo(()=>{if("interpolate"===O){let e=!1;const t=[];for(const n of ie){const o=(n[g]||[]).filter(t=>!oe(t)||(e=!0,!1));o.length>0&&t.push(Object.assign(Object.assign({},n),{[g]:o}))}return{gapProcessedLineData:t,hasGaps:e}}if("break"===O){let e=!1;const t=[];for(const n of ie){const o=n[g]||[];let r=[],i=0;const a=ee&&"string"==typeof ee?n[ee]:void 0;for(const s of o)if(oe(s))e=!0,r.length>0&&(t.push(Object.assign(Object.assign({},n),{[g]:r})),r=[],i++);else{const e=null!=a?`${a}__seg${i}`:"__seg"+i;r.push(Object.assign(Object.assign({},s),{_gapSegment:e}))}r.length>0&&t.push(Object.assign(Object.assign({},n),{[g]:r}))}return{gapProcessedLineData:t,hasGaps:e}}if("zero"===O){let e=!1;const t="string"==typeof d?d:"y",n=[];for(const o of ie){const r=o[g]||[],i=[];for(const n of r)oe(n)?(e=!0,i.push(Object.assign(Object.assign({},n),{[t]:0}))):i.push(n);n.push(Object.assign(Object.assign({},o),{[g]:i}))}return{gapProcessedLineData:n,hasGaps:e}}return{gapProcessedLineData:ie,hasGaps:!1}},[ie,O,g,oe,ee,d]),le=io(J,y,p),ce=e.useMemo(()=>{if(!y)return[];const e=new Set;for(const t of J){const n="function"==typeof y?y(t):t[y];null!=n&&e.add(n+"")}return Array.from(e)},[J,y]),ue=co(T,y,ce),de=e.useMemo(()=>ue.legendSelectionHook?ue.legendSelectionHook:te,[ue.legendSelectionHook,te]),he=e.useMemo(()=>e=>{const t={strokeWidth:w};return t.stroke=y?fn(e,y,le):oo,x&&(t.fill=t.stroke,t.fillOpacity=k),t},[y,le,w,x,k]),ge=e.useMemo(()=>C?function(e,t){var n,o;const r=null!==(n=t.trainDasharray)&&void 0!==n?n:"8,4",i=null!==(o=t.forecastDasharray)&&void 0!==o?o:"4,4",a=t.color||"#6366f1";return t=>{const n=e(t),o=t[Po];return"training"===o?Object.assign(Object.assign({},n),{strokeDasharray:r}):"forecast"===o?Object.assign(Object.assign({},n),{stroke:a,strokeDasharray:i}):n}}(he,C):he,[he,C]),fe=e.useMemo(()=>no(ge,de,P),[ge,de,P]),ye=e.useMemo(()=>{if(v)return e=>{const t={r:b,fillOpacity:1};return t.fill=y?fn(e.parentLine||e,y,le):oo,t}},[v,b,y,le]),pe=x?"area":"line",me="object"==typeof L?L:{},ve=me.position||"end",be=me.fontSize||11,xe=e.useMemo(()=>{var e,t;if(!L||!y)return[];const n="function"==typeof u?u:e=>e[u],o="function"==typeof d?d:e=>e[d],r="function"==typeof y?y:e=>e[y],i=new Map;for(const n of ae){const o=n[g]||[];if(0===o.length)continue;const a="end"===ve?o[o.length-1]:o[0],s=null!==(t=null!==(e=r(a))&&void 0!==e?e:r(n))&&void 0!==t?t:"";s&&!i.has(s+"")&&i.set(s+"",a)}const a=Array.from(i.entries()).map(([e,t])=>({type:"text",label:e,["string"==typeof u?u:"x"]:n(t),["string"==typeof d?d:"y"]:o(t),dx:"end"===ve?6:-6,dy:0,color:le?le(e):oo,fontSize:be}));a.sort((e,t)=>{const n="string"==typeof d?d:"y";return e[n]-t[n]});for(let e=1;a.length>e;e++){const t="string"==typeof d?d:"y",n=a[e-1],o=a[e];be+2>Math.abs(o[t]+o.dy-(n[t]+n.dy))&&(o.dy+=be+2)}return a},[L,y,le,ae,g,u,d,ve,be]),we=(!L||void 0!==_)&&_,Ae=e.useMemo(()=>{if(!L)return r.marginDefaults;const e=xe.reduce((e,t)=>{var n;const o=((null===(n=t.label)||void 0===n?void 0:n.length)||0)*(.6*be);return Math.max(e,o)},0),t=e+10,n="end"===ve?"right":"left";return Object.assign(Object.assign({},r.marginDefaults),{[n]:Math.max(r.marginDefaults[n]||0,t)})},[L,xe,be,ve,r.marginDefaults]),{legend:Ee,margin:Se}=lo({data:ae,colorBy:y,colorScale:le,showLegend:we,userMargin:a,defaults:Ae}),Le=h||y,Oe=e.useMemo(()=>Hn([{label:Y||Cn(u),accessor:u,role:"x"},{label:G||Cn(d),accessor:d,role:"y"},...Le?[{label:Cn(Le),accessor:Le,role:"group"}]:[]]),[u,d,Y,G,Le]),Me=Lo({componentName:"LineChart",data:re?(null===(o=J[0])||void 0===o?void 0:o[g])||[]:V,accessors:{xAccessor:u,yAccessor:d}});if(Me)return f.createElement(go,{componentName:"LineChart",message:Me,width:I,height:R});const Ce=e.useMemo(()=>re||ee||se?ae.flatMap(e=>{const t=e[g]||[];return ee&&"string"==typeof ee?t.map(t=>Object.assign(Object.assign({},t),{[ee]:e[ee]})):t}):J,[ae,g,re,ee,J,se]),je=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:pe,data:Ce,xAccessor:u,yAccessor:d,groupAccessor:"break"===O&&se?"_gapSegment":ee||void 0,curve:m,lineStyle:fe},v&&{pointStyle:ye}),{size:[I,R],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Se,showAxes:r.showAxes,xLabel:Y,yLabel:G,xFormat:l,yFormat:c,enableHover:$,showGrid:z}),Ee&&{legend:Ee}),T&&"none"!==T&&{legendHoverBehavior:ue.onLegendHover,legendClickBehavior:ue.onLegendClick,legendHighlightedCategory:ue.highlightedCategory,legendIsolatedCategories:ue.isolatedCategories}),F&&{title:F}),s&&{className:s}),{tooltipContent:Mn(A)||Oe}),(H||N)&&{customHoverBehavior:ne}),E&&{pointIdAccessor:E}),((null==S?void 0:S.length)||K.length||xe.length)&&{annotations:[...S||[],...K,...xe]}),j);return f.createElement(mo,{componentName:"LineChart",width:I,height:R},f.createElement(ke,Object.assign({},je)))}function Bo(t){var n;const o=ho(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:r,margin:i,className:a,xFormat:s,yFormat:l,xAccessor:c="x",yAccessor:u="y",areaBy:d,y0Accessor:h,gradientFill:g=!1,lineDataAccessor:y="coordinates",colorBy:p,colorScheme:m="category10",curve:v="monotoneX",areaOpacity:b=.7,showLine:x=!0,lineWidth:k=2,tooltip:w,annotations:A,frameProps:E={},selection:S,linkedHover:L,onObservation:O,chartId:M,loading:C,emptyContent:j,legendInteraction:P}=t,H=o.width,N=o.height,B=o.enableHover,D=o.showGrid,W=o.showLegend,T=o.title,I=o.xLabel,R=o.yLabel,$=ko(C,H,N);if($)return $;const z=xo(r,H,N,j);if(z)return z;const _=r||[];wo("AreaChart",_,"xAccessor",c),wo("AreaChart",_,"yAccessor",u);const{activeSelectionHook:F,customHoverBehavior:Y}=so({selection:S,linkedHover:L,fallbackFields:p?["string"==typeof p?p:""]:[],onObservation:O,chartType:"AreaChart",chartId:M}),G=void 0!==(null===(n=_[0])||void 0===n?void 0:n[y]),q=e.useMemo(()=>{if(G)return _;if(d){const e=_.reduce((e,t)=>{const n="function"==typeof d?d(t):t[d];if(!e[n]){const t={[y]:[]};"string"==typeof d&&(t[d]=n),e[n]=t}return e[n][y].push(t),e},{});return Object.values(e)}return[{[y]:_}]},[_,d,y,G]),X=io(_,p,m),V=e.useMemo(()=>{if(!p)return[];const e=new Set;for(const t of _){const n="function"==typeof p?p(t):t[p];null!=n&&e.add(n+"")}return Array.from(e)},[_,p]),U=co(P,p,V),Z=e.useMemo(()=>U.legendSelectionHook?U.legendSelectionHook:F,[U.legendSelectionHook,F]),Q=e.useMemo(()=>e=>{const t={},n=p?fn(e,p,X):oo;return t.fill=n,t.fillOpacity=b,x?(t.stroke=n,t.strokeWidth=k):t.stroke="none",t},[p,X,b,x,k]),K=e.useMemo(()=>no(Q,Z,S),[Q,Z,S]),{legend:J,margin:ee}=lo({data:q,colorBy:p,colorScale:X,showLegend:W,userMargin:i,defaults:o.marginDefaults}),te=d||p,ne=e.useMemo(()=>Hn([{label:I||Cn(c),accessor:c,role:"x"},{label:R||Cn(u),accessor:u,role:"y"},...te?[{label:Cn(te),accessor:te,role:"group"}]:[]]),[c,u,I,R,te]),oe=Lo({componentName:"AreaChart",data:_,accessors:{xAccessor:c,yAccessor:u}});if(oe)return f.createElement(go,{componentName:"AreaChart",message:oe,width:H,height:N});const re=e.useMemo(()=>G||d?q.flatMap(e=>{const t=e[y]||[];return d&&"string"==typeof d?t.map(t=>Object.assign(Object.assign({},t),{[d]:e[d]})):t}):_,[q,y,G,d,_]),ie=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area",data:re,xAccessor:c,yAccessor:u,groupAccessor:d||void 0},h&&{y0Accessor:h}),g&&{gradientFill:g}),{curve:v,lineStyle:K,size:[H,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ee,showAxes:o.showAxes,xLabel:I,yLabel:R,xFormat:s,yFormat:l,enableHover:B,showGrid:D}),J&&{legend:J}),P&&"none"!==P&&{legendHoverBehavior:U.onLegendHover,legendClickBehavior:U.onLegendClick,legendHighlightedCategory:U.highlightedCategory,legendIsolatedCategories:U.isolatedCategories}),T&&{title:T}),a&&{className:a}),{tooltipContent:Mn(w)||ne}),(L||O)&&{customHoverBehavior:Y}),A&&A.length>0&&{annotations:A}),E);return f.createElement(mo,{componentName:"AreaChart",width:H,height:N},f.createElement(ke,Object.assign({},ie)))}function Do(t){var n;const o=ho(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:r,margin:i,className:a,xFormat:s,yFormat:l,xAccessor:c="x",yAccessor:u="y",areaBy:d,lineDataAccessor:h="coordinates",colorBy:g,colorScheme:y="category10",curve:p="monotoneX",areaOpacity:m=.7,showLine:v=!0,lineWidth:b=2,normalize:x=!1,tooltip:k,annotations:w,frameProps:A={},selection:E,linkedHover:S,onObservation:L,chartId:O,loading:M,emptyContent:C,legendInteraction:j}=t,P=o.width,H=o.height,N=o.enableHover,B=o.showGrid,D=o.showLegend,W=o.title,T=o.xLabel,I=o.yLabel,R=ko(M,P,H);if(R)return R;const $=xo(r,P,H,C);if($)return $;const z=r||[],{activeSelectionHook:_,customHoverBehavior:F}=so({selection:E,linkedHover:S,fallbackFields:g?["string"==typeof g?g:""]:[],onObservation:L,chartType:"StackedAreaChart",chartId:O}),Y=void 0!==(null===(n=z[0])||void 0===n?void 0:n[h]),G=e.useMemo(()=>{if(Y)return z;if(d){const e=z.reduce((e,t)=>{const n="function"==typeof d?d(t):t[d];if(!e[n]){const t={[h]:[]};"string"==typeof d&&(t[d]=n),e[n]=t}return e[n][h].push(t),e},{});return Object.values(e)}return[{[h]:z}]},[z,d,h,Y]),q=io(z,g,y),X=e.useMemo(()=>{if(!g)return[];const e=new Set;for(const t of z){const n="function"==typeof g?g(t):t[g];null!=n&&e.add(n+"")}return Array.from(e)},[z,g]),V=co(j,g,X),U=e.useMemo(()=>V.legendSelectionHook?V.legendSelectionHook:_,[V.legendSelectionHook,_]),Z=e.useMemo(()=>e=>{const t={},n=g?fn(e,g,q):oo;return t.fill=n,t.fillOpacity=m,v?(t.stroke=n,t.strokeWidth=b):t.stroke="none",t},[g,q,m,v,b]),Q=e.useMemo(()=>no(Z,U,E),[Z,U,E]),{legend:K,margin:J}=lo({data:G,colorBy:g,colorScale:q,showLegend:D,userMargin:i,defaults:o.marginDefaults}),ee=d||g,te=e.useMemo(()=>Hn([{label:T||Cn(c),accessor:c,role:"x"},{label:I||Cn(u),accessor:u,role:"y"},...ee?[{label:Cn(ee),accessor:ee,role:"group"}]:[]]),[c,u,T,I,ee]),ne=Lo({componentName:"StackedAreaChart",data:z,accessors:{xAccessor:c,yAccessor:u}});if(ne)return f.createElement(go,{componentName:"StackedAreaChart",message:ne,width:P,height:H});const oe=e.useMemo(()=>Y||d?G.flatMap(e=>{const t=e[h]||[];return d&&"string"==typeof d?t.map(t=>Object.assign(Object.assign({},t),{[d]:e[d]})):t}):z,[G,h,Y,d,z]),re=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea",data:oe,xAccessor:c,yAccessor:u,groupAccessor:d||void 0,curve:p,normalize:x,lineStyle:Q,size:[P,H],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:J,showAxes:o.showAxes,xLabel:T,yLabel:I,xFormat:s,yFormat:l,enableHover:N,showGrid:B},K&&{legend:K}),j&&"none"!==j&&{legendHoverBehavior:V.onLegendHover,legendClickBehavior:V.onLegendClick,legendHighlightedCategory:V.highlightedCategory,legendIsolatedCategories:V.isolatedCategories}),W&&{title:W}),a&&{className:a}),{tooltipContent:Mn(k)||te}),(S||L)&&{customHoverBehavior:F}),w&&w.length>0&&{annotations:w}),A);return f.createElement(mo,{componentName:"StackedAreaChart",width:P,height:H},f.createElement(ke,Object.assign({},re)))}function Wo(t){const n=ho(t.mode,{width:t.width,height:t.height,showGrid:void 0,enableHover:t.enableHover,showLegend:void 0,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:r,margin:i,className:a,xAccessor:s="x",yAccessor:l="y",valueAccessor:u="value",xFormat:d,yFormat:h,colorScheme:g="blues",customColorScale:y,showValues:p=!1,valueFormat:m,cellBorderColor:v="#fff",cellBorderWidth:b=1,tooltip:x,annotations:k,frameProps:w={},selection:A,linkedHover:E,onObservation:S,chartId:L,loading:O,emptyContent:M,legendInteraction:C}=t,j=n.width,P=n.height,H=n.enableHover,N=n.title,B=n.xLabel,D=n.yLabel,W=ko(O,j,P);if(W)return W;const T=xo(r,j,P,M);if(T)return T;const I=r||[],{margin:R}=lo({data:I,colorBy:void 0,colorScale:void 0,showLegend:!1,userMargin:i,defaults:n.marginDefaults}),{activeSelectionHook:$,customHoverBehavior:z}=so({selection:A,linkedHover:E,fallbackFields:[],onObservation:S,chartType:"Heatmap",chartId:L}),_=co(C,void 0,[]),F=e.useMemo(()=>_.legendSelectionHook?_.legendSelectionHook:$,[_.legendSelectionHook,$]),Y=e.useMemo(()=>"function"==typeof u?e=>u(e):e=>e[u],[u]),G=e.useMemo(()=>{const e=I.map(Y);return[Math.min(...e),Math.max(...e)]},[I,Y]),q=e.useMemo(()=>"custom"===g&&y?y:o.scaleSequential({blues:c.interpolateBlues,reds:c.interpolateReds,greens:c.interpolateGreens,viridis:c.interpolateViridis}[g]||c.interpolateBlues).domain(G),[g,y,G]);e.useMemo(()=>{const e=ro(s),t=ro(l);return{xBinCount:new Set(I.map(e)).size,yBinCount:new Set(I.map(t)).size}},[I,s,l]),e.useMemo(()=>({coordinates:I}),[I]);const X=e.useMemo(()=>e=>{const t=Y(e);return{fill:q(t),stroke:v,strokeWidth:b}},[Y,q,v,b]);e.useMemo(()=>no(X,F,A),[X,F,A]),e.useMemo(()=>{if(!p)return;const e=(G[0]+G[1])/2;return(t,n)=>{const o=Y(t),r=m?m(o):o+"";return f.createElement("text",{textAnchor:"middle",dominantBaseline:"middle",fill:Y(t)>e?"#fff":"#000",fontSize:"12px"},r)}},[p,Y,m,G]);const V=e.useMemo(()=>Hn([{label:B||Cn(s),accessor:s,role:"x"},{label:D||Cn(l),accessor:l,role:"y"},{label:Cn(u),accessor:u,role:"value"}]),[s,l,B,D,u]),U=Lo({componentName:"Heatmap",data:I,accessors:{xAccessor:s,yAccessor:l,valueAccessor:u}});if(U)return f.createElement(go,{componentName:"Heatmap",message:U,width:j,height:P});const Z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap",data:I,xAccessor:s,yAccessor:l,valueAccessor:u,size:[j,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R,showAxes:n.showAxes,xLabel:B,yLabel:D,xFormat:d,yFormat:h,enableHover:H},N&&{title:N}),a&&{className:a}),{tooltipContent:Mn(x)||V}),(E||S)&&{customHoverBehavior:z}),k&&k.length>0&&{annotations:k}),w);return f.createElement(mo,{componentName:"Heatmap",width:j,height:P},f.createElement(ke,Object.assign({},Z)))}function To(t){const n=ho(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,margin:r,className:i,xFormat:a,yFormat:s,xAccessor:l="x",yAccessor:c="y",sizeBy:u,sizeRange:d=[5,40],colorBy:h,colorScheme:g="category10",bubbleOpacity:y=.6,bubbleStrokeWidth:p=1,bubbleStrokeColor:m="white",tooltip:v,marginalGraphics:b,pointIdAccessor:x,annotations:k,frameProps:w={},selection:A,linkedHover:E,linkedBrush:S,onObservation:L,chartId:O,loading:M,emptyContent:C,legendInteraction:j}=t,P=n.width,H=n.height,N=n.enableHover,B=n.showGrid,D=n.showLegend,W=n.title,T=n.xLabel,I=n.yLabel,R=ko(M,P,H);if(R)return R;const $=xo(o,P,H,C);if($)return $;const z=o||[],{activeSelectionHook:_,customHoverBehavior:F}=so({selection:A,linkedHover:E,fallbackFields:h?["string"==typeof h?h:""]:[],onObservation:L,chartType:"BubbleChart",chartId:O}),Y=to(S);Un({name:(null==Y?void 0:Y.name)||"__unused_brush__",xField:(null==Y?void 0:Y.xField)||("string"==typeof l?l:void 0),yField:(null==Y?void 0:Y.yField)||("string"==typeof c?c:void 0)});const G=io(z,h,g),q=e.useMemo(()=>{if(!h)return[];const e=new Set;for(const t of z){const n="function"==typeof h?h(t):t[h];null!=n&&e.add(n+"")}return Array.from(e)},[z,h]),X=co(j,h,q),V=e.useMemo(()=>X.legendSelectionHook?X.legendSelectionHook:_,[X.legendSelectionHook,_]),U=e.useMemo(()=>{const e=z.map(e=>"function"==typeof u?u(e):e[u]);return[Math.min(...e),Math.max(...e)]},[z,u]),Z=e.useMemo(()=>e=>{const t={fillOpacity:y,strokeWidth:p,stroke:m};return t.fill=h?fn(e,h,G):oo,t.r=pn(e,u,d,U),t},[h,G,u,d,U,y,p,m]),Q=e.useMemo(()=>no(Z,V,A),[Z,V,A]),{legend:K,margin:J}=lo({data:z,colorBy:h,colorScale:G,showLegend:D,userMargin:r,defaults:n.marginDefaults}),ee=e.useMemo(()=>Hn([{label:T||Cn(l),accessor:l,role:"x"},{label:I||Cn(c),accessor:c,role:"y"},{label:Cn(u),accessor:u,role:"size"},...h?[{label:Cn(h),accessor:h,role:"color"}]:[]]),[l,c,T,I,u,h]),te=Lo({componentName:"BubbleChart",data:z,accessors:{xAccessor:l,yAccessor:c},requiredProps:{sizeBy:u}});if(te)return f.createElement(go,{componentName:"BubbleChart",message:te,width:P,height:H});const ne=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bubble",data:z,xAccessor:l,yAccessor:c,colorAccessor:h||void 0,sizeAccessor:u,sizeRange:d,pointStyle:Q,colorScheme:g,size:[P,H],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:J,showAxes:n.showAxes,xLabel:T,yLabel:I,xFormat:a,yFormat:s,enableHover:N,showGrid:B},K&&{legend:K}),j&&"none"!==j&&{legendHoverBehavior:X.onLegendHover,legendClickBehavior:X.onLegendClick,legendHighlightedCategory:X.highlightedCategory,legendIsolatedCategories:X.isolatedCategories}),W&&{title:W}),i&&{className:i}),{tooltipContent:Mn(v)||ee}),(E||L)&&{customHoverBehavior:F}),b&&{marginalGraphics:b}),x&&{pointIdAccessor:x}),k&&k.length>0&&{annotations:k}),w);return f.createElement(mo,{componentName:"BubbleChart",width:P,height:H},f.createElement(ke,Object.assign({},ne)))}No.displayName="LineChart",Bo.displayName="AreaChart",Do.displayName="StackedAreaChart",Wo.displayName="Heatmap",To.displayName="BubbleChart";const Io="__splomIdx",Ro={top:4,bottom:4,left:4,right:4};function $o({frameRef:o,cellSize:r,onBrush:i}){const a=e.useRef(null),s=r-Ro.left-Ro.right,l=r-Ro.top-Ro.bottom;return e.useEffect(()=>{if(!a.current)return;const e=n.select(a.current).select(".brush-g"),r=t.brush().extent([[0,0],[s,l]]).on("brush end",e=>{var t;const n=null===(t=o.current)||void 0===t?void 0:t.getScales();if(!n)return;if(!e.selection)return void i(null);const[[r,a],[s,l]]=e.selection,c=[[n.x.invert(r),n.y.invert(a)],[n.x.invert(s),n.y.invert(l)]];i(c)});return e.call(r),e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null)}},[s,l,o,i]),f.createElement("svg",{ref:a,width:r,height:r,style:{position:"absolute",top:0,left:0}},f.createElement("g",{className:"brush-g",transform:`translate(${Ro.left},${Ro.top})`}))}function zo({data:t,xField:n,yField:o,cellSize:r,pointRadius:i,pointOpacity:a,colorBy:s,colorScale:l,brushSelectionName:c,hoverSelectionName:u,unselectedOpacity:d,mode:h,onPointHover:g}){const y=e.useRef(null),p=Xn({name:c,clientId:`splom-${n}-${o}`}),m=Un({name:c,xField:n,yField:o}),v=Xn({name:u,clientId:"splom-hover-source"}),b=v.selectPoints,x=e.useCallback(e=>{e?m.brushInteraction.during(e):m.brushInteraction.end(null)},[m.brushInteraction]),k=e.useCallback(e=>{if(!e)return void(null==g||g(null));const t=e.data,n=null==t?void 0:t[Io];void 0!==n&&(b({[Io]:[n]}),null==g||g(t,e.x+Ro.left,e.y+Ro.top))},[b,g]),w=e.useCallback(e=>{const t={opacity:a,r:i};return t.fill=s?fn(e,s,l):oo,"hover"===h?v.isActive&&v.predicate(e)?(t.opacity=1,t.r=2.5*i,t.stroke="#333",t.strokeWidth=1.5):v.isActive&&(t.opacity=.6*a):p.isActive&&!p.predicate(e)&&(t.opacity=d),t},[s,l,a,i,h,p.isActive,p.predicate,v.isActive,v.predicate,d]);return f.createElement("div",{style:{position:"relative",width:r,height:r}},f.createElement(ke,{ref:y,chartType:"scatter",data:t,size:[r,r],xAccessor:n,yAccessor:o,pointStyle:w,margin:Ro,showAxes:!1,enableHover:"hover"===h,customHoverBehavior:"hover"===h?k:void 0,tooltipContent:"hover"===h?()=>null:void 0}),"brush"===h&&f.createElement($o,{frameRef:y,cellSize:r,xField:n,yField:o,onBrush:x}))}function _o({data:t,field:n,label:o,cellSize:r,bins:i,brushSelectionName:a,hoverSelectionName:s,mode:l}){const c=Xn({name:a,clientId:"splom-diag-"+n}),u=Xn({name:s,clientId:`splom-diag-${n}-hover`}),d="hover"===l?u:c,h=d.isActive,g=d.predicate,y=e.useMemo(()=>{const e=t.map(e=>e[n]).filter(e=>null!=e&&!isNaN(e));if(0===e.length)return{bars:[],selectedBars:[],max:0};const o=Math.min(...e),a=(Math.max(...e)-o)/i||1,s=Array(i).fill(0),l=Array(i).fill(0);for(const e of t){const t=e[n];if(null==t||isNaN(t))continue;const r=Math.min(Math.floor((t-o)/a),i-1);s[r]++,h&&!g(e)||l[r]++}const c=Math.max(...s,1);return{bars:s.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/c*(r-24),count:e})),selectedBars:l.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/c*(r-24),count:e})),max:c}},[t,n,i,r,h,g]);return f.createElement("svg",{width:r,height:r,style:{overflow:"hidden"}},f.createElement("text",{x:r/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333"},o),y.bars.map((e,t)=>f.createElement("rect",{key:"bg-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:"#ccc",opacity:h?.3:.6})),h&&y.selectedBars.map((e,t)=>f.createElement("rect",{key:"sel-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:oo,opacity:.7})))}function Fo({label:e,cellSize:t}){return f.createElement("svg",{width:t,height:t},f.createElement("text",{x:t/2,y:t/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333"},e))}function Yo(t){const{data:n,fields:o,fieldLabels:r={},colorBy:i,colorScheme:a="category10",cellSize:s=150,cellGap:l=4,pointRadius:c=2,pointOpacity:u=.5,diagonal:d="histogram",histogramBins:h=20,brushMode:g="crossfilter",hoverMode:y=!0,unselectedOpacity:p=.1,showGrid:m=!1,tooltip:v,showLegend:b,idAccessor:x,className:k,onObservation:w,chartId:A}=t,E="splom",S="splom-hover",L=y?"hover":g?"brush":"hover",O=Yn(e=>e.clearSelection),[M,C]=e.useState(null),j=e.useCallback(()=>{O(S),C(null)},[O,S]),P=e.useMemo(()=>(n||[]).map((e,t)=>void 0!==e[Io]?e:Object.assign(Object.assign({},e),{[Io]:t})),[n]),H=io(P,i,a),N=void 0!==b?b:!!i,B=e.useMemo(()=>{if(!N||!i)return null;const e="string"==typeof i?i:null;return e?[...new Set(P.map(t=>t[e]))].map(e=>({label:e+"",color:H?H(e+""):oo})):null},[N,i,P,H]),D=e.useMemo(()=>({display:"grid",gridTemplateColumns:"40px "+o.map(()=>s+"px").join(" "),gridTemplateRows:o.map(()=>s+"px").join(" ")+" 40px",gap:l+"px",width:"fit-content"}),[o,s,l,40]);return f.createElement("div",{className:k,style:{position:"relative"}},B&&f.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},B.map(e=>f.createElement("div",{key:e.label,style:{display:"flex",alignItems:"center",gap:4}},f.createElement("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:e.color}}),f.createElement("span",{style:{fontSize:11}},e.label)))),f.createElement("div",{style:D,onMouseLeave:"hover"===L?j:void 0},o.map((e,t)=>f.createElement(f.Fragment,{key:"row-"+e},f.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e),o.map((n,o)=>t===o?"label"===d?f.createElement(Fo,{key:"diag-"+e,label:r[e]||e,cellSize:s}):f.createElement(_o,{key:"diag-"+e,data:P,field:e,label:r[e]||e,cellSize:s,bins:h,colorBy:i,colorScale:H,brushSelectionName:E,hoverSelectionName:S,unselectedOpacity:p,mode:L}):f.createElement(zo,{key:`cell-${e}-${n}`,data:P,xField:n,yField:e,fieldLabels:r,cellSize:s,pointRadius:c,pointOpacity:u,colorBy:i,colorScale:H,brushSelectionName:E,hoverSelectionName:S,unselectedOpacity:p,showGrid:m,tooltip:v,mode:L,onPointHover:"hover"===L?(r,i,a)=>{r?(C({datum:r,xField:n,yField:e,colIndex:o,rowIndex:t,px:null!=i?i:0,py:null!=a?a:0}),w&&w({type:"hover",datum:r,x:null!=i?i:0,y:null!=a?a:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A})):(C(null),w&&w({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A}))}:void 0})))),f.createElement("div",null)," ",o.map(e=>f.createElement("div",{key:"col-label-"+e,style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e))),M&&"hover"===L&&(()=>{const e=M.datum,t=r[M.xField]||M.xField,n=r[M.yField]||M.yField,o=i?"function"==typeof i?i(e):e[i]:null,a=x?"function"==typeof x?x(e):e[x]:"Row "+e[Io];return f.createElement("div",{style:{position:"absolute",left:40+M.colIndex*(s+l)+M.px,top:M.rowIndex*(s+l)+M.py-8,transform:"translate(-50%, -100%)",color:"#333",background:"rgba(255,255,255,0.95)",border:"1px solid #ddd",borderRadius:3,padding:"4px 8px",fontSize:11,lineHeight:1.4,whiteSpace:"nowrap",pointerEvents:"none",zIndex:10}},f.createElement("div",{style:{fontWeight:"bold",marginBottom:2}},a+""),f.createElement("div",null,t,": ",null!=e[M.xField]?Number(e[M.xField]).toFixed(1):"–"),f.createElement("div",null,n,": ",null!=e[M.yField]?Number(e[M.yField]).toFixed(1):"–"),null!=o&&f.createElement("div",{style:{opacity:.8}},"string"==typeof i?i:"group",": ",o+""))})())}function Go(e){const{brushMode:t="crossfilter",hoverMode:n=!0}=e,o={};return!n&&t&&(o.splom={resolution:t}),n&&(o["splom-hover"]={resolution:"union"}),f.createElement(eo,{selections:o},f.createElement(Yo,Object.assign({},e)))}function qo({width:o,height:r,margin:i,scales:a,brushDirection:s,extent:l,onBrush:c}){const u=e.useRef(null),d=e.useRef(null),h=e.useRef(!1),g=o+i.left+i.right,y=r+i.top+i.bottom;return e.useEffect(()=>{if(!u.current||!a)return;const e=n.select(u.current).select(".brush-group"),i="x"===s?t.brushX().extent([[0,0],[o,r]]):t.brushY().extent([[0,0],[o,r]]);return i.on("brush end",e=>{if(h.current)return;if(!e.sourceEvent)return;const t=e.selection;if(!t)return void c(null);const n=("x"===s?a.x:a.y).invert;if(!n)return;const o=[n(t[0]),n(t[1])];c(o)}),e.call(i),d.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null)}},[a,o,r,s,c]),e.useEffect(()=>{if(!d.current||!a||!u.current)return;const e=n.select(u.current).select(".brush-group"),t="x"===s?a.x:a.y;if(h.current=!0,l){const n=[t(l[0]),t(l[1])];e.call(d.current.move,n)}else e.call(d.current.move,null);h.current=!1},[l,a,s]),f.createElement("svg",{ref:u,width:g,height:y,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},f.createElement("g",{className:"brush-group",transform:`translate(${i.left},${i.top})`}))}function Xo(t){var n,o;const{data:r,width:i=600,height:a=400,margin:s,className:l,title:c,xLabel:u,yLabel:d,xFormat:h,yFormat:g,xAccessor:y="x",yAccessor:p="y",lineBy:m,lineDataAccessor:v="coordinates",colorBy:b,colorScheme:x="category10",curve:k="linear",lineWidth:w=2,fillArea:A=!1,areaOpacity:E=.3,showPoints:S=!1,pointRadius:L=3,enableHover:O=!0,showGrid:M=!1,showLegend:C,tooltip:j,minimap:P={},renderBefore:H=!1,onBrush:N,brushExtent:B,frameProps:D={},loading:W,emptyContent:T}=t,I=ko(W,i,a);if(I)return I;const R=xo(r,i,a,T);if(R)return R;const $=r||[],[z,_]=e.useState(null),F=null!=B?B:z,Y=e.useCallback(e=>{B||_(e),null==N||N(e)},[B,N]),G=e.useRef(null),[q,X]=e.useState(null);e.useEffect(()=>{const e=()=>{var t,n;const o=null===(n=null===(t=G.current)||void 0===t?void 0:t.getScales)||void 0===n?void 0:n.call(t);o?X(o):requestAnimationFrame(e)};requestAnimationFrame(e)},[r]);const V=void 0!==(null===(n=$[0])||void 0===n?void 0:n[v]),U=e.useMemo(()=>{if(V)return $;if(m){const e=$.reduce((e,t)=>{const n="function"==typeof m?m(t):t[m];if(!e[n]){const t={[v]:[]};"string"==typeof m&&(t[m]=n),e[n]=t}return e[n][v].push(t),e},{});return Object.values(e)}return[{[v]:$}]},[$,m,v,V]),Z=e.useMemo(()=>V||m?U.flatMap(e=>{const t=e[v]||[];return m&&"string"==typeof m?t.map(t=>Object.assign(Object.assign({},t),{[m]:e[m]})):t}):$,[U,v,V,m,$]),Q=io($,b,x),K=e.useMemo(()=>e=>{const t={strokeWidth:w};return t.stroke=b?fn(e,b,Q):oo,A&&(t.fill=t.stroke,t.fillOpacity=E),t},[b,Q,w,A,E]),J=e.useMemo(()=>P.lineStyle?P.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=b?fn(e,b,Q):oo,t},[b,Q,P.lineStyle]),ee=e.useMemo(()=>{if(S)return e=>{const t={r:L,fillOpacity:1};return t.fill=b?fn(e.parentLine||e,b,Q):oo,t}},[S,L,b,Q]),{legend:te,margin:ne}=lo({data:U,colorBy:b,colorScale:Q,showLegend:C,userMargin:s}),oe=P.height||60,re=e.useMemo(()=>{var e,t,n,o,r,i,a,s;return{top:null!==(t=null===(e=P.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(o=null===(n=P.margin)||void 0===n?void 0:n.bottom)&&void 0!==o?o:20,left:null!==(i=null===(r=P.margin)||void 0===r?void 0:r.left)&&void 0!==i?i:ne.left,right:null!==(s=null===(a=P.margin)||void 0===a?void 0:a.right)&&void 0!==s?s:ne.right}},[P.margin,ne]),ie=P.brushDirection||"x",ae=Lo({componentName:"MinimapChart",data:$,accessors:{xAccessor:y,yAccessor:p}});if(ae)return f.createElement(go,{componentName:"MinimapChart",message:ae,width:i,height:a});const se=A?"area":"line",le=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:se,data:Z,xAccessor:y,yAccessor:p,groupAccessor:m||void 0,curve:k,lineStyle:K},S&&{pointStyle:ee}),{size:[i,a],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ne,showAxes:!0,xLabel:u,yLabel:d,xFormat:h,yFormat:g,enableHover:O,showGrid:M}),te&&{legend:te}),c&&{title:c}),j&&{tooltipContent:Mn(j)||void 0}),F&&{xExtent:F}),D),ce={chartType:se,data:Z,xAccessor:y,yAccessor:p,groupAccessor:m||void 0,curve:k,lineStyle:J,size:[i,oe+re.top+re.bottom],margin:re,showAxes:null!==(o=P.showAxes)&&void 0!==o&&o,background:P.background,enableHover:!1},ue=f.createElement("div",{key:"minimap",style:{position:"relative",width:i,overflow:"hidden"}},f.createElement(ke,Object.assign({ref:G},ce)),f.createElement(qo,{width:i-re.left-re.right,height:oe,margin:re,scales:q,brushDirection:ie,extent:F,onBrush:Y})),de=f.createElement("div",{key:"main",style:{overflow:"hidden"}},f.createElement(ke,Object.assign({},le)));return f.createElement("div",{className:"minimap-chart"+(l?" "+l:"")},H?ue:de,H?de:ue)}function Vo(t){const n=ho(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:i,categoryAccessor:a="category",valueAccessor:s="value",orientation:l="vertical",valueFormat:c,colorBy:u,colorScheme:d="category10",sort:h=!1,barPadding:g=5,tooltip:y,annotations:p,frameProps:m={},selection:v,linkedHover:b,onObservation:x,chartId:k,loading:w,emptyContent:A,legendInteraction:E}=t,S=n.width,L=n.height,O=n.enableHover,M=n.showGrid,C=n.showLegend,j=n.title,P=n.categoryLabel,H=n.valueLabel,N=ko(w,S,L);if(N)return N;const B=xo(o,S,L,A);if(B)return B;const D=o||[];wo("BarChart",D,"categoryAccessor",a),wo("BarChart",D,"valueAccessor",s);const{activeSelectionHook:W,customHoverBehavior:T}=so({selection:v,linkedHover:b,fallbackFields:u?["string"==typeof u?u:""]:[],unwrapData:!0,onObservation:x,chartType:"BarChart",chartId:k}),I=ao(D,h,s),R=io(D,u,d),$=e.useMemo(()=>{if(!u)return[];const e=new Set;for(const t of D){const n="function"==typeof u?u(t):t[u];null!=n&&e.add(n+"")}return Array.from(e)},[D,u]),z=co(E,u,$),_=e.useMemo(()=>z.legendSelectionHook?z.legendSelectionHook:W,[z.legendSelectionHook,W]),F=e.useMemo(()=>e=>{const t={};return t.fill=u?fn(e,u,R):oo,t},[u,R]),Y=e.useMemo(()=>no(F,_,v),[F,_,v]),{legend:G,margin:q}=lo({data:I,colorBy:u,colorScale:R,showLegend:C,userMargin:r,defaults:n.marginDefaults}),X=e.useMemo(()=>Nn({categoryAccessor:a,valueAccessor:s,groupAccessor:u&&u!==a?u:void 0,groupLabel:"string"==typeof u?u:"group"}),[a,s,u]),V=Lo({componentName:"BarChart",data:D,accessors:{categoryAccessor:a,valueAccessor:s}});if(V)return f.createElement(go,{componentName:"BarChart",message:V,width:S,height:L});const U=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar",data:I,oAccessor:a,rAccessor:s,projection:"horizontal"===l?"horizontal":"vertical",pieceStyle:Y,size:[S,L],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:q,barPadding:g,enableHover:O,showAxes:n.showAxes,oLabel:P,rLabel:H,rFormat:c,showGrid:M,oSort:h},G&&{legend:G}),E&&"none"!==E&&{legendHoverBehavior:z.onLegendHover,legendClickBehavior:z.onLegendClick,legendHighlightedCategory:z.highlightedCategory,legendIsolatedCategories:z.isolatedCategories}),j&&{title:j}),i&&{className:i}),{tooltipContent:Mn(y)||X}),(b||x)&&{customHoverBehavior:T}),p&&p.length>0&&{annotations:p}),m);return f.createElement(mo,{componentName:"BarChart",width:S,height:L},f.createElement(_e,Object.assign({},U)))}function Uo(t){const n=ho(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:i,categoryAccessor:a="category",stackBy:s,valueAccessor:l="value",orientation:c="vertical",valueFormat:u,colorBy:d,colorScheme:h="category10",normalize:g=!1,barPadding:y=5,tooltip:p,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:k,chartId:w,loading:A,emptyContent:E,legendInteraction:S}=t,L=n.width,O=n.height,M=n.enableHover,C=n.showGrid,j=n.showLegend,P=n.title,H=n.categoryLabel,N=n.valueLabel,B=ko(A,L,O);if(B)return B;const D=xo(o,L,O,E);if(D)return D;const W=o||[],T=d||s,{activeSelectionHook:I,customHoverBehavior:R}=so({selection:b,linkedHover:x,fallbackFields:T?["string"==typeof T?T:""]:[],unwrapData:!0,onObservation:k,chartType:"StackedBarChart",chartId:w}),$=io(W,T,h),z=e.useMemo(()=>{if(!T)return[];const e=new Set;for(const t of W){const n="function"==typeof T?T(t):t[T];null!=n&&e.add(n+"")}return Array.from(e)},[W,T]),_=co(S,T,z),F=e.useMemo(()=>_.legendSelectionHook?_.legendSelectionHook:I,[_.legendSelectionHook,I]),Y=e.useMemo(()=>e=>T?{fill:fn(e,T,$)}:{fill:oo},[T,$]),G=e.useMemo(()=>no(Y,F,b),[Y,F,b]),{legend:q,margin:X}=lo({data:W,colorBy:T,colorScale:$,showLegend:j,userMargin:r,defaults:n.marginDefaults}),V=e.useMemo(()=>Nn({categoryAccessor:s,valueAccessor:l,groupAccessor:a}),[s,a,l]),U=Lo({componentName:"StackedBarChart",data:W,accessors:{categoryAccessor:a,valueAccessor:l},requiredProps:{stackBy:s}});if(U)return f.createElement(go,{componentName:"StackedBarChart",message:U,width:L,height:O});const Z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar",data:W,oAccessor:a,rAccessor:l,stackBy:s,normalize:g,projection:"horizontal"===c?"horizontal":"vertical",pieceStyle:G,size:[L,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:X,barPadding:y,enableHover:M,showAxes:n.showAxes,oLabel:H,rLabel:N,rFormat:u,showGrid:C},q&&{legend:q}),S&&"none"!==S&&{legendHoverBehavior:_.onLegendHover,legendClickBehavior:_.onLegendClick,legendHighlightedCategory:_.highlightedCategory,legendIsolatedCategories:_.isolatedCategories}),P&&{title:P}),i&&{className:i}),{tooltipContent:Mn(p)||V}),(x||k)&&{customHoverBehavior:R}),m&&m.length>0&&{annotations:m}),v);return f.createElement(mo,{componentName:"StackedBarChart",width:L,height:O},f.createElement(_e,Object.assign({},Z)))}function Zo(t){const n=ho(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:i,categoryAccessor:a="category",valueAccessor:s="value",orientation:l="vertical",valueFormat:c,colorBy:u,colorScheme:d="category10",sizeBy:h,sizeRange:g=[3,8],pointRadius:y=4,pointOpacity:p=.7,categoryPadding:m=20,tooltip:v,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:A,chartId:E,loading:S,emptyContent:L,legendInteraction:O}=t,M=n.width,C=n.height,j=n.enableHover,P=n.showGrid,H=n.showLegend,N=n.title,B=n.categoryLabel,D=n.valueLabel,W=ko(S,M,C);if(W)return W;const T=xo(o,M,C,L);if(T)return T;const I=o||[],{activeSelectionHook:R,customHoverBehavior:$}=so({selection:k,linkedHover:w,fallbackFields:u?["string"==typeof u?u:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:A,chartType:"SwarmPlot",chartId:E}),z=io(I,u,d),_=e.useMemo(()=>{if(!u)return[];const e=new Set;for(const t of I){const n="function"==typeof u?u(t):t[u];null!=n&&e.add(n+"")}return Array.from(e)},[I,u]),F=co(O,u,_),Y=e.useMemo(()=>F.legendSelectionHook?F.legendSelectionHook:R,[F.legendSelectionHook,R]),G=e.useMemo(()=>{if(!h)return;const e=I.map(e=>"function"==typeof h?h(e):e[h]);return[Math.min(...e),Math.max(...e)]},[I,h]),q=e.useMemo(()=>e=>{const t={fillOpacity:p};return t.fill=u?fn(e,u,z):oo,t.r=h?pn(e,h,g,G):y,t},[u,z,h,g,G,y,p]),X=e.useMemo(()=>no(q,Y,k),[q,Y,k]),{legend:V,margin:U}=lo({data:I,colorBy:u,colorScale:z,showLegend:H,userMargin:r,defaults:n.marginDefaults}),Z=e.useMemo(()=>Nn({categoryAccessor:a,valueAccessor:s,groupAccessor:u||void 0}),[a,s,u]),Q=Lo({componentName:"SwarmPlot",data:I,accessors:{categoryAccessor:a,valueAccessor:s}});if(Q)return f.createElement(go,{componentName:"SwarmPlot",message:Q,width:M,height:C});const K=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"swarm",data:I,oAccessor:a,rAccessor:s,projection:"horizontal"===l?"horizontal":"vertical",pieceStyle:X,size:[M,C],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:U,barPadding:m,enableHover:j,showAxes:n.showAxes,oLabel:B,rLabel:D,rFormat:c,showGrid:P},V&&{legend:V}),O&&"none"!==O&&{legendHoverBehavior:F.onLegendHover,legendClickBehavior:F.onLegendClick,legendHighlightedCategory:F.highlightedCategory,legendIsolatedCategories:F.isolatedCategories}),N&&{title:N}),i&&{className:i}),{tooltipContent:Mn(v)||Z}),(w||A)&&{customHoverBehavior:$}),b&&b.length>0&&{annotations:b}),x);return f.createElement(mo,{componentName:"SwarmPlot",width:M,height:C},f.createElement(_e,Object.assign({},K)))}function Qo(t){const n=ho(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:i,categoryAccessor:a="category",valueAccessor:s="value",orientation:l="vertical",valueFormat:c,colorBy:u,colorScheme:d="category10",showOutliers:h=!0,categoryPadding:g=20,tooltip:y,annotations:p,frameProps:m={},selection:v,linkedHover:b,onObservation:x,chartId:k,loading:w,emptyContent:A,legendInteraction:E}=t,S=n.width,L=n.height,O=n.enableHover,M=n.showGrid,C=n.showLegend,j=n.title,P=n.categoryLabel,H=n.valueLabel,N=ko(w,S,L);if(N)return N;const B=xo(o,S,L,A);if(B)return B;const D=o||[],{activeSelectionHook:W,customHoverBehavior:T}=so({selection:v,linkedHover:b,fallbackFields:u?["string"==typeof u?u:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:x,chartType:"BoxPlot",chartId:k}),I=io(D,u,d),R=e.useMemo(()=>{if(!u)return[];const e=new Set;for(const t of D){const n="function"==typeof u?u(t):t[u];null!=n&&e.add(n+"")}return Array.from(e)},[D,u]),$=co(E,u,R),z=e.useMemo(()=>$.legendSelectionHook?$.legendSelectionHook:W,[$.legendSelectionHook,W]),_=e.useMemo(()=>e=>{const t=u?fn(e,u,I):oo;return{fill:t,stroke:t,fillOpacity:.8}},[u,I]),F=e.useMemo(()=>no(_,z,v),[_,z,v]),{legend:Y,margin:G}=lo({data:D,colorBy:u,colorScale:I,showLegend:C,userMargin:r,defaults:n.marginDefaults}),q=e.useMemo(()=>e=>{const t=e.stats||(e.data||e).stats||{};return f.createElement("div",{className:"semiotic-tooltip",style:En},f.createElement("div",{style:{fontWeight:"bold",marginBottom:"4px"}},(e.category||(e.data||e).category||"")+""),null!=t.median&&f.createElement(f.Fragment,null,null!=t.n&&f.createElement("div",null,"n = ",t.n),f.createElement("div",null,"Median: ",t.median.toLocaleString()),f.createElement("div",null,"Q1: ",t.q1.toLocaleString()),f.createElement("div",null,"Q3: ",t.q3.toLocaleString()),f.createElement("div",null,"Min: ",t.min.toLocaleString()),f.createElement("div",null,"Max: ",t.max.toLocaleString())))},[]),X=Lo({componentName:"BoxPlot",data:D,accessors:{categoryAccessor:a,valueAccessor:s}});if(X)return f.createElement(go,{componentName:"BoxPlot",message:X,width:S,height:L});const V=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"boxplot",data:D,oAccessor:a,rAccessor:s,projection:"horizontal"===l?"horizontal":"vertical",summaryStyle:F,showOutliers:h,size:[S,L],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:G,barPadding:g,enableHover:O,showAxes:n.showAxes,oLabel:P,rLabel:H,rFormat:c,showGrid:M},Y&&{legend:Y}),E&&"none"!==E&&{legendHoverBehavior:$.onLegendHover,legendClickBehavior:$.onLegendClick,legendHighlightedCategory:$.highlightedCategory,legendIsolatedCategories:$.isolatedCategories}),j&&{title:j}),i&&{className:i}),{tooltipContent:Mn(y)||q}),(b||x)&&{customHoverBehavior:T}),p&&p.length>0&&{annotations:p}),m);return f.createElement(mo,{componentName:"BoxPlot",width:S,height:L},f.createElement(_e,Object.assign({},V)))}function Ko(t){const n=ho(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:i,categoryAccessor:a="category",valueAccessor:s="value",bins:l=25,relative:c=!1,valueFormat:u,colorBy:d,colorScheme:h="category10",categoryPadding:g=20,tooltip:y,annotations:p,frameProps:m={},selection:v,linkedHover:b,onObservation:x,chartId:k,loading:w,emptyContent:A}=t,E=n.width,S=n.height,L=n.enableHover,O=n.showGrid,M=n.showLegend,C=n.title,j=n.categoryLabel,P=n.valueLabel,H=ko(w,E,S);if(H)return H;const N=xo(o,E,S,A);if(N)return N;const B=o||[],{activeSelectionHook:D,customHoverBehavior:W}=so({selection:v,linkedHover:b,fallbackFields:d?["string"==typeof d?d:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:x,chartType:"Histogram",chartId:k}),T=io(B,d,h),I=e.useMemo(()=>e=>{const t=d?fn(e,d,T):oo;return{fill:t,stroke:t,fillOpacity:.8}},[d,T]),R=e.useMemo(()=>no(I,D,v),[I,D,v]),{legend:$,margin:z}=lo({data:B,colorBy:d,colorScale:T,showLegend:M,userMargin:r,defaults:n.marginDefaults}),_=e.useMemo(()=>e=>{const t=e.data||e,n=t.category||e.category||"",o=t.count,r=t.range;return f.createElement("div",{className:"semiotic-tooltip",style:En},n&&f.createElement("div",{style:{fontWeight:"bold"}},n+""),null!=o&&f.createElement("div",null,"Count: ",o),r&&2===r.length&&f.createElement("div",{style:{opacity:.8}},Number(r[0]).toFixed(1)," – ",Number(r[1]).toFixed(1)))},[]),F=Lo({componentName:"Histogram",data:B,accessors:{categoryAccessor:a,valueAccessor:s}});if(F)return f.createElement(go,{componentName:"Histogram",message:F,width:E,height:S});const Y=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"histogram",data:B,oAccessor:a,rAccessor:s,projection:"horizontal",summaryStyle:R,bins:l,normalize:c,size:[E,S],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:z,barPadding:g,enableHover:L,showAxes:n.showAxes,oLabel:j,rLabel:P,rFormat:u,showGrid:O},$&&{legend:$}),C&&{title:C}),i&&{className:i}),{tooltipContent:Mn(y)||_}),(b||x)&&{customHoverBehavior:W}),p&&p.length>0&&{annotations:p}),m);return f.createElement(mo,{componentName:"Histogram",width:E,height:S},f.createElement(_e,Object.assign({},Y)))}function Jo(t){const n=ho(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:i,categoryAccessor:a="category",valueAccessor:s="value",orientation:l="vertical",bins:c=25,showIQR:u=!0,valueFormat:d,colorBy:h,colorScheme:g="category10",categoryPadding:y=20,tooltip:p,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:k,chartId:w,loading:A,emptyContent:E}=t,S=n.width,L=n.height,O=n.enableHover,M=n.showGrid,C=n.showLegend,j=n.title,P=n.categoryLabel,H=n.valueLabel,N=ko(A,S,L);if(N)return N;const B=xo(o,S,L,E);if(B)return B;const D=o||[],{activeSelectionHook:W,customHoverBehavior:T}=so({selection:b,linkedHover:x,fallbackFields:h?["string"==typeof h?h:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:k,chartType:"ViolinPlot",chartId:w}),I=io(D,h,g),R=e.useMemo(()=>e=>{const t=h?fn(e,h,I):oo;return{fill:t,stroke:t,fillOpacity:.6}},[h,I]),$=e.useMemo(()=>no(R,W,b),[R,W,b]),{legend:z,margin:_}=lo({data:D,colorBy:h,colorScale:I,showLegend:C,userMargin:r,defaults:n.marginDefaults}),F=e.useMemo(()=>e=>{var t;const n=e.category||e.data&&(null===(t=e.data[0])||void 0===t?void 0:t.category)||"",o=e.stats;if(o)return f.createElement("div",{className:"semiotic-tooltip",style:En},n&&f.createElement("div",{style:{fontWeight:"bold"}},n+""),f.createElement("div",null,"n = ",o.n),f.createElement("div",null,"Min: ",o.min.toLocaleString()),f.createElement("div",null,"Q1: ",o.q1.toLocaleString()),f.createElement("div",null,"Median: ",o.median.toLocaleString()),f.createElement("div",null,"Q3: ",o.q3.toLocaleString()),f.createElement("div",null,"Max: ",o.max.toLocaleString()),f.createElement("div",{style:{opacity:.8}},"Mean: ",o.mean.toLocaleString(void 0,{maximumFractionDigits:2})));const r=(Array.isArray(e.data)?e.data:[]).map(e=>{const t="function"==typeof s?s(e):e[s];return Number(t)}).filter(e=>!isNaN(e)).sort((e,t)=>e-t),i=r.length,a=i>0?r[Math.floor(i/2)]:null;return f.createElement("div",{className:"semiotic-tooltip",style:En},n&&f.createElement("div",{style:{fontWeight:"bold"}},n+""),i>0&&f.createElement("div",null,"n = ",i),null!=a&&f.createElement("div",null,"Median: ",a.toLocaleString()))},[s]),Y=Lo({componentName:"ViolinPlot",data:D,accessors:{categoryAccessor:a,valueAccessor:s}});if(Y)return f.createElement(go,{componentName:"ViolinPlot",message:Y,width:S,height:L});const G=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"violin",data:D,oAccessor:a,rAccessor:s,projection:"horizontal"===l?"horizontal":"vertical",summaryStyle:$,bins:c,showIQR:u,size:[S,L],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:_,barPadding:y,enableHover:O,showAxes:n.showAxes,oLabel:P,rLabel:H,rFormat:d,showGrid:M},z&&{legend:z}),j&&{title:j}),i&&{className:i}),{tooltipContent:Mn(p)||F}),(x||k)&&{customHoverBehavior:T}),m&&m.length>0&&{annotations:m}),v);return f.createElement(mo,{componentName:"ViolinPlot",width:S,height:L},f.createElement(_e,Object.assign({},G)))}function er(t){const n=ho(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:i,categoryAccessor:a="category",valueAccessor:s="value",orientation:l="horizontal",bins:c=20,amplitude:u=1.5,valueFormat:d,colorBy:h,colorScheme:g="category10",categoryPadding:y=5,tooltip:p,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:k,chartId:w,loading:A,emptyContent:E}=t,S=n.width,L=n.height,O=n.enableHover,M=n.showGrid,C=n.showLegend,j=n.title,P=n.categoryLabel,H=n.valueLabel,N=ko(A,S,L);if(N)return N;const B=xo(o,S,L,E);if(B)return B;const D=o||[],{activeSelectionHook:W,customHoverBehavior:T}=so({selection:b,linkedHover:x,fallbackFields:h?["string"==typeof h?h:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:k,chartType:"RidgelinePlot",chartId:w}),I=io(D,h,g),R=e.useMemo(()=>e=>{const t=h?fn(e,h,I):oo;return{fill:t,stroke:t,fillOpacity:.5}},[h,I]),$=e.useMemo(()=>no(R,W,b),[R,W,b]),{legend:z,margin:_}=lo({data:D,colorBy:h,colorScale:I,showLegend:C,userMargin:r,defaults:n.marginDefaults}),F=e.useMemo(()=>e=>{var t;const n=e.category||e.data&&(null===(t=e.data[0])||void 0===t?void 0:t.category)||"",o=e.stats;return o?f.createElement("div",{className:"semiotic-tooltip",style:En},n&&f.createElement("div",{style:{fontWeight:"bold"}},n+""),f.createElement("div",null,"n = ",o.n),f.createElement("div",null,"Min: ",o.min.toLocaleString()),f.createElement("div",null,"Q1: ",o.q1.toLocaleString()),f.createElement("div",null,"Median: ",o.median.toLocaleString()),f.createElement("div",null,"Q3: ",o.q3.toLocaleString()),f.createElement("div",null,"Max: ",o.max.toLocaleString()),f.createElement("div",{style:{opacity:.8}},"Mean: ",o.mean.toLocaleString(void 0,{maximumFractionDigits:2}))):f.createElement("div",{className:"semiotic-tooltip",style:En},f.createElement("div",{style:{fontWeight:"bold"}},n+""))},[]),Y=Lo({componentName:"RidgelinePlot",data:D,accessors:{categoryAccessor:a,valueAccessor:s}});if(Y)return f.createElement(go,{componentName:"RidgelinePlot",message:Y,width:S,height:L});const G=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"ridgeline",data:D,oAccessor:a,rAccessor:s,projection:"horizontal"===l?"horizontal":"vertical",summaryStyle:$,bins:c,size:[S,L],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:_,barPadding:y,enableHover:O,showAxes:n.showAxes,oLabel:P,rLabel:H,rFormat:d,showGrid:M,oSort:!1,amplitude:u},z&&{legend:z}),j&&{title:j}),i&&{className:i}),{tooltipContent:Mn(p)||F}),(x||k)&&{customHoverBehavior:T}),m&&m.length>0&&{annotations:m}),v);return f.createElement(mo,{componentName:"RidgelinePlot",width:S,height:L},f.createElement(_e,Object.assign({},G)))}function tr(t){var n;const o=ho(t.mode,{width:t.width,height:t.height,showGrid:null===(n=t.showGrid)||void 0===n||n,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:r,margin:i,className:a,categoryAccessor:s="category",valueAccessor:l="value",orientation:c="horizontal",valueFormat:u,colorBy:d,colorScheme:h="category10",sort:g=!0,dotRadius:y=5,categoryPadding:p=10,tooltip:m,annotations:v,frameProps:b={},selection:x,linkedHover:k,onObservation:w,chartId:A,loading:E,emptyContent:S,legendInteraction:L}=t,O=o.width,M=o.height,C=o.enableHover,j=o.showGrid,P=o.showLegend,H=o.title,N=o.categoryLabel,B=o.valueLabel,D=ko(E,O,M);if(D)return D;const W=xo(r,O,M,S);if(W)return W;const T=r||[],{activeSelectionHook:I,customHoverBehavior:R}=so({selection:x,linkedHover:k,fallbackFields:d?["string"==typeof d?d:""]:["string"==typeof s?s:""],unwrapData:!0,onObservation:w,chartType:"DotPlot",chartId:A}),$=ao(T,g,l),z=io(T,d,h),_=e.useMemo(()=>{if(!d)return[];const e=new Set;for(const t of T){const n="function"==typeof d?d(t):t[d];null!=n&&e.add(n+"")}return Array.from(e)},[T,d]),F=co(L,d,_),Y=e.useMemo(()=>F.legendSelectionHook?F.legendSelectionHook:I,[F.legendSelectionHook,I]),G=e.useMemo(()=>e=>{const t={r:y,fillOpacity:.8};return t.fill=d?fn(e,d,z):oo,t},[d,z,y]),q=e.useMemo(()=>no(G,Y,x),[G,Y,x]),{legend:X,margin:V}=lo({data:$,colorBy:d,colorScale:z,showLegend:P,userMargin:i,defaults:o.marginDefaults}),U=e.useMemo(()=>Nn({categoryAccessor:s,valueAccessor:l}),[s,l]),Z=Lo({componentName:"DotPlot",data:T,accessors:{categoryAccessor:s,valueAccessor:l}});if(Z)return f.createElement(go,{componentName:"DotPlot",message:Z,width:O,height:M});const Q=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"point",data:$,oAccessor:s,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",pieceStyle:q,size:[O,M],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:V,barPadding:p,enableHover:C,showAxes:o.showAxes,oLabel:N,rLabel:B,rFormat:u,showGrid:j,oSort:g},X&&{legend:X}),L&&"none"!==L&&{legendHoverBehavior:F.onLegendHover,legendClickBehavior:F.onLegendClick,legendHighlightedCategory:F.highlightedCategory,legendIsolatedCategories:F.isolatedCategories}),H&&{title:H}),a&&{className:a}),{tooltipContent:Mn(m)||U}),(k||w)&&{customHoverBehavior:R}),v&&v.length>0&&{annotations:v}),b);return f.createElement(mo,{componentName:"DotPlot",width:O,height:M},f.createElement(_e,Object.assign({},Q)))}function nr(t){var n,o;const r=ho(t.mode,{width:null!==(n=t.width)&&void 0!==n?n:400,height:null!==(o=t.height)&&void 0!==o?o:400,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title}),{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",colorBy:u,colorScheme:d="category10",startAngle:h=0,tooltip:g,annotations:y,frameProps:p={},selection:m,linkedHover:v,onObservation:b,chartId:x,loading:k,emptyContent:w,legendInteraction:A}=t,E=r.width,S=r.height,L=r.enableHover,O=r.showLegend,M=r.title,C=ko(k,E,S);if(C)return C;const j=xo(i,E,S,w);if(j)return j;const P=i||[],H=u||l,{activeSelectionHook:N,customHoverBehavior:B}=so({selection:m,linkedHover:v,fallbackFields:H?["string"==typeof H?H:""]:[],unwrapData:!0,onObservation:b,chartType:"PieChart",chartId:x}),D=io(P,H,d),W=e.useMemo(()=>{if(!H)return[];const e=new Set;for(const t of P){const n="function"==typeof H?H(t):t[H];null!=n&&e.add(n+"")}return Array.from(e)},[P,H]),T=co(A,H,W),I=e.useMemo(()=>T.legendSelectionHook?T.legendSelectionHook:N,[T.legendSelectionHook,N]),R=e.useMemo(()=>e=>H?{fill:fn(e,H,D)}:{fill:oo},[H,D]),$=e.useMemo(()=>no(R,I,m),[R,I,m]),{legend:z,margin:_}=lo({data:P,colorBy:H,colorScale:D,showLegend:O,userMargin:a,defaults:r.marginDefaults}),F=e.useMemo(()=>Nn({categoryAccessor:l,valueAccessor:c,groupAccessor:u&&u!==l?u:void 0,groupLabel:"string"==typeof u?u:"group",pieData:!0}),[l,c,u]),Y=Lo({componentName:"PieChart",data:P,accessors:{categoryAccessor:l,valueAccessor:c}});if(Y)return f.createElement(go,{componentName:"PieChart",message:Y,width:E,height:S});const G=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"pie",data:P,oAccessor:l,rAccessor:c,projection:"radial",pieceStyle:$,startAngle:h,size:[E,S],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:_,enableHover:L,showAxes:!1},z&&{legend:z}),A&&"none"!==A&&{legendHoverBehavior:T.onLegendHover,legendClickBehavior:T.onLegendClick,legendHighlightedCategory:T.highlightedCategory,legendIsolatedCategories:T.isolatedCategories}),M&&{title:M}),s&&{className:s}),{tooltipContent:Mn(g)||F}),(v||b)&&{customHoverBehavior:B}),y&&y.length>0&&{annotations:y}),p);return f.createElement(mo,{componentName:"PieChart",width:E,height:S},f.createElement(_e,Object.assign({},G)))}function or(t){var n,o;const r=ho(t.mode,{width:null!==(n=t.width)&&void 0!==n?n:400,height:null!==(o=t.height)&&void 0!==o?o:400,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,linkedHover:t.linkedHover}),{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",innerRadius:u=60,centerContent:d,colorBy:h,colorScheme:g="category10",startAngle:y=0,tooltip:p,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:k,chartId:w,loading:A,emptyContent:E,legendInteraction:S}=t,L=r.width,O=r.height,M=r.enableHover,C=r.showLegend,j=r.title,P=ko(A,L,O);if(P)return P;const H=xo(i,L,O,E);if(H)return H;const N=i||[],B=h||l,{activeSelectionHook:D,customHoverBehavior:W}=so({selection:b,linkedHover:x,fallbackFields:B?["string"==typeof B?B:""]:[],unwrapData:!0,onObservation:k,chartType:"DonutChart",chartId:w}),T=io(N,B,g),I=e.useMemo(()=>{if(!B)return[];const e=new Set;for(const t of N){const n="function"==typeof B?B(t):t[B];null!=n&&e.add(n+"")}return Array.from(e)},[N,B]),R=co(S,B,I),$=e.useMemo(()=>R.legendSelectionHook?R.legendSelectionHook:D,[R.legendSelectionHook,D]),z=e.useMemo(()=>e=>B?{fill:fn(e,B,T)}:{fill:oo},[B,T]),_=e.useMemo(()=>no(z,$,b),[z,$,b]),{legend:F,margin:Y}=lo({data:N,colorBy:B,colorScale:T,showLegend:C,userMargin:a,defaults:r.marginDefaults}),G=e.useMemo(()=>Nn({categoryAccessor:l,valueAccessor:c,groupAccessor:h&&h!==l?h:void 0,groupLabel:"string"==typeof h?h:"group",pieData:!0}),[l,c,h]),q=Lo({componentName:"DonutChart",data:N,accessors:{categoryAccessor:l,valueAccessor:c}});if(q)return f.createElement(go,{componentName:"DonutChart",message:q,width:L,height:O});const X=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"donut",data:N,oAccessor:l,rAccessor:c,projection:"radial",pieceStyle:_,innerRadius:u,startAngle:y,centerContent:d,size:[L,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Y,enableHover:M,showAxes:!1},F&&{legend:F}),S&&"none"!==S&&{legendHoverBehavior:R.onLegendHover,legendClickBehavior:R.onLegendClick,legendHighlightedCategory:R.highlightedCategory,legendIsolatedCategories:R.isolatedCategories}),j&&{title:j}),s&&{className:s}),{tooltipContent:Mn(p)||G}),(x||k)&&{customHoverBehavior:W}),m&&m.length>0&&{annotations:m}),v);return f.createElement(mo,{componentName:"DonutChart",width:L,height:O},f.createElement(_e,Object.assign({},X)))}function rr(t){const n=ho(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:i,categoryAccessor:a="category",groupBy:s,valueAccessor:l="value",orientation:c="vertical",valueFormat:u,colorBy:d,colorScheme:h="category10",barPadding:g=5,tooltip:y,annotations:p,frameProps:m={},selection:v,linkedHover:b,onObservation:x,chartId:k,loading:w,emptyContent:A,legendInteraction:E}=t,S=n.width,L=n.height,O=n.enableHover,M=n.showGrid,C=n.showLegend,j=n.title,P=n.categoryLabel,H=n.valueLabel,N=ko(w,S,L);if(N)return N;const B=xo(o,S,L,A);if(B)return B;const D=o||[],W=d||s,{activeSelectionHook:T,customHoverBehavior:I}=so({selection:v,linkedHover:b,fallbackFields:W?["string"==typeof W?W:""]:[],unwrapData:!0,onObservation:x,chartType:"GroupedBarChart",chartId:k}),R=io(D,W,h),$=e.useMemo(()=>{if(!W)return[];const e=new Set;for(const t of D){const n="function"==typeof W?W(t):t[W];null!=n&&e.add(n+"")}return Array.from(e)},[D,W]),z=co(E,W,$),_=e.useMemo(()=>z.legendSelectionHook?z.legendSelectionHook:T,[z.legendSelectionHook,T]),F=e.useMemo(()=>e=>W?{fill:fn(e,W,R)}:{fill:oo},[W,R]),Y=e.useMemo(()=>no(F,_,v),[F,_,v]),{legend:G,margin:q}=lo({data:D,colorBy:W,colorScale:R,showLegend:C,userMargin:r,defaults:n.marginDefaults}),X=e.useMemo(()=>Nn({categoryAccessor:s,valueAccessor:l,groupAccessor:a}),[s,a,l]),V=Lo({componentName:"GroupedBarChart",data:D,accessors:{categoryAccessor:a,valueAccessor:l},requiredProps:{groupBy:s}});if(V)return f.createElement(go,{componentName:"GroupedBarChart",message:V,width:S,height:L});const U=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"clusterbar",data:D,oAccessor:a,rAccessor:l,groupBy:s,projection:"horizontal"===c?"horizontal":"vertical",pieceStyle:Y,size:[S,L],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:q,barPadding:g,enableHover:O,showAxes:n.showAxes,oLabel:P,rLabel:H,rFormat:u,showGrid:M},G&&{legend:G}),E&&"none"!==E&&{legendHoverBehavior:z.onLegendHover,legendClickBehavior:z.onLegendClick,legendHighlightedCategory:z.highlightedCategory,legendIsolatedCategories:z.isolatedCategories}),j&&{title:j}),i&&{className:i}),{tooltipContent:Mn(y)||X}),(b||x)&&{customHoverBehavior:I}),p&&p.length>0&&{annotations:p}),m);return f.createElement(mo,{componentName:"GroupedBarChart",width:S,height:L},f.createElement(_e,Object.assign({},U)))}function ir(t){var n;const o=ho(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLegend:t.showLegend,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:r,edges:i,margin:a,className:s,nodeIDAccessor:l="id",sourceAccessor:c="source",targetAccessor:u="target",nodeLabel:d,colorBy:h,colorScheme:g="category10",nodeSize:y=8,nodeSizeRange:p=[5,20],edgeWidth:m=1,edgeColor:v="#999",edgeOpacity:b=.6,iterations:x=300,forceStrength:k=.1,tooltip:w,frameProps:A={},onObservation:E,chartId:S,selection:L,linkedHover:O,loading:M,emptyContent:C,legendInteraction:j}=t,P=o.width,H=o.height,N=o.enableHover,B=o.showLegend,D=null!==(n=o.showLabels)&&void 0!==n&&n,W=o.title,T=ko(M,P,H);if(T)return T;const I=xo(i,P,H,C);if(I)return I;const R=r||[],$=i||[],z=io(R,h,g),_=e.useMemo(()=>{if(!h)return[];const e=new Set;for(const t of R){const n="function"==typeof h?h(t):t[h];null!=n&&e.add(n+"")}return Array.from(e)},[R,h]),F=co(j,h,_),Y=e.useMemo(()=>e=>{const t={};return t.fill=h?fn(e.data||e,h,z):oo,"number"==typeof y&&(t.r=y),t},[h,z,y]),G=e.useMemo(()=>e=>({stroke:v,strokeWidth:"number"==typeof m?m:"function"==typeof m?m(e):e[m]||1,opacity:b}),[m,v,b]),q=e.useMemo(()=>{if(D&&d)return"function"==typeof d?d:e=>e[d]},[D,d]),{legend:X,margin:V}=lo({data:R,colorBy:h,colorScale:z,showLegend:B,userMargin:a,defaults:o.marginDefaults}),{customHoverBehavior:U}=so({selection:L,linkedHover:O,fallbackFields:h?["string"==typeof h?h:""]:[],unwrapData:!0,onObservation:E,chartType:"ForceDirectedGraph",chartId:S}),Z=Mo({componentName:"ForceDirectedGraph",nodes:r,edges:i,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:l}});return Z?f.createElement(go,{componentName:"ForceDirectedGraph",message:Z,width:P,height:H}):f.createElement(mo,{componentName:"ForceDirectedGraph",width:P,height:H},f.createElement(An,Object.assign({chartType:"force",nodes:R,edges:$,size:[P,H],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:V,nodeIDAccessor:l,sourceAccessor:c,targetAccessor:u,iterations:x,forceStrength:k,nodeStyle:Y,edgeStyle:G,colorBy:h,colorScheme:g,nodeSize:y,nodeSizeRange:p,nodeLabel:q,showLabels:D,enableHover:N,tooltipContent:w?e=>Mn(w)(e.data):void 0,customHoverBehavior:O||E?U:void 0,legend:X},j&&"none"!==j&&{legendHoverBehavior:F.onLegendHover,legendClickBehavior:F.onLegendClick,legendHighlightedCategory:F.highlightedCategory,legendIsolatedCategories:F.isolatedCategories},{className:s,title:W},A)))}function ar(e,t){if(!e)return[];const n=[],o=e=>{n.push(e);const r="function"==typeof t?t(e):e[t];r&&Array.isArray(r)&&r.forEach(o)};return o(e),n}function sr(e,t,n,o){if(e&&e.length>0)return e;const r=new Set;return t.forEach(e=>{const t="function"==typeof n?n(e):e[n],i="function"==typeof o?o(e):e[o];r.add(t),r.add(i)}),Array.from(r).map(e=>({id:e}))}function lr(e){return"function"==typeof e?e:t=>t[e]||1}function cr({edgeColorBy:e,colorBy:t,colorScale:n,nodeStyleFn:o,edgeOpacity:r,baseStyle:i={}}){return a=>{const s=Object.assign({fillOpacity:r},i);if("function"==typeof e)s.fill=e(a);else if("source"===e){const e="object"==typeof a.source?a.source:null;t&&e?s.fill=fn(e.data||e,t,n):e&&(s.fill=o(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?s.fill=fn(e.data||e,t,n):e&&(s.fill=o(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*r);return s}}function ur(t){var n;const o=ho(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:r,edges:i,margin:a,className:s,sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:u="value",nodeIdAccessor:d="id",colorBy:h,colorScheme:g="category10",edgeColorBy:y="source",padAngle:p=.01,groupWidth:m=20,sortGroups:v,nodeLabel:b,edgeOpacity:x=.5,tooltip:k,frameProps:w={},onObservation:A,chartId:E,selection:S,linkedHover:L,loading:O,emptyContent:M,legendInteraction:C}=t,j=o.width,P=o.height,H=o.enableHover,N=null===(n=o.showLabels)||void 0===n||n,B=o.title,D=ko(O,j,P);if(D)return D;const W=xo(i,j,P,M);if(W)return W;const T=i||[],I=e.useMemo(()=>sr(r,T,l,c),[r,T,l,c]),R=io(I,h,g),$=e.useMemo(()=>{if(!h)return[];const e=new Set;for(const t of I){const n="function"==typeof h?h(t):t[h];null!=n&&e.add(n+"")}return Array.from(e)},[I,h]),z=co(C,h,$),_=e.useMemo(()=>(e,t)=>{var n,o;const r={stroke:"black",strokeWidth:1};if(h)r.fill=fn(e.data||e,h,R);else{const i=Array.isArray(g)?g:dn[g]||hn,a=Array.isArray(i)?i:hn,s=null!==(o=null!==(n=e.index)&&void 0!==n?n:t)&&void 0!==o?o:0;r.fill=a[s%a.length]}return r},[h,R,g]),F=e.useMemo(()=>cr({edgeColorBy:y,colorBy:h,colorScale:R,nodeStyleFn:_,edgeOpacity:x,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:x}}),[y,h,R,_,x]),Y=e.useMemo(()=>{if(!N)return;const e=b||d;return"function"==typeof e?e:t=>t[e]},[N,b,d]),G=Object.assign(Object.assign({},o.marginDefaults),a),{customHoverBehavior:q}=so({selection:S,linkedHover:L,fallbackFields:h?["string"==typeof h?h:""]:[],unwrapData:!0,onObservation:A,chartType:"ChordDiagram",chartId:E}),X=Mo({componentName:"ChordDiagram",edges:i,edgesRequired:!0});return X?f.createElement(go,{componentName:"ChordDiagram",message:X,width:j,height:P}):f.createElement(mo,{componentName:"ChordDiagram",width:j,height:P},f.createElement(An,Object.assign({chartType:"chord",nodes:I,edges:T,size:[j,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:G,nodeIDAccessor:d,sourceAccessor:l,targetAccessor:c,valueAccessor:u,padAngle:p,groupWidth:m,sortGroups:v,nodeStyle:_,edgeStyle:F,colorBy:h,colorScheme:g,edgeColorBy:y,edgeOpacity:x,nodeLabel:Y,showLabels:N,enableHover:H,tooltipContent:k?e=>Mn(k)(e.data):void 0,customHoverBehavior:L||A?q:void 0},C&&"none"!==C&&{legendHoverBehavior:z.onLegendHover,legendClickBehavior:z.onLegendClick,legendHighlightedCategory:z.highlightedCategory,legendIsolatedCategories:z.isolatedCategories},{className:s,title:B},w)))}function dr(t){var n;const o=ho(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:800,height:600}),{nodes:r,edges:i,margin:a,className:s,sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:u="value",nodeIdAccessor:d="id",colorBy:h,colorScheme:g="category10",edgeColorBy:y="source",orientation:p="horizontal",nodeAlign:m="justify",nodePaddingRatio:v=.05,nodeWidth:b=15,nodeLabel:x,edgeOpacity:k=.5,edgeSort:w,tooltip:A,frameProps:E={},onObservation:S,chartId:L,selection:O,linkedHover:M,loading:C,emptyContent:j,legendInteraction:P}=t,H=o.width,N=o.height,B=o.enableHover,D=null===(n=o.showLabels)||void 0===n||n,W=o.title,T=ko(C,H,N);if(T)return T;const I=xo(i,H,N,j);if(I)return I;const R=i||[],$=e.useMemo(()=>sr(r,R,l,c),[r,R,l,c]),z=io($,h,g),_=e.useMemo(()=>{if(!h)return[];const e=new Set;for(const t of $){const n="function"==typeof h?h(t):t[h];null!=n&&e.add(n+"")}return Array.from(e)},[$,h]),F=co(P,h,_),Y=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=h?fn(e.data||e,h,z):"#4d430c",t},[h,z]),G=e.useMemo(()=>cr({edgeColorBy:y,colorBy:h,colorScale:z,nodeStyleFn:Y,edgeOpacity:k,baseStyle:{stroke:"none",strokeWidth:0}}),[y,h,z,Y,k]),q=e.useMemo(()=>{if(!D)return;const e=x||d;return"function"==typeof e?e:t=>t[e]},[D,x,d]),X=Object.assign(Object.assign({},o.marginDefaults),a),{customHoverBehavior:V,customClickBehavior:U}=so({selection:O,linkedHover:M,fallbackFields:h?["string"==typeof h?h:""]:[],unwrapData:!0,onObservation:S,chartType:"SankeyDiagram",chartId:L}),Z=Mo({componentName:"SankeyDiagram",edges:i,edgesRequired:!0});return Z?f.createElement(go,{componentName:"SankeyDiagram",message:Z,width:H,height:N}):f.createElement(mo,{componentName:"SankeyDiagram",width:H,height:N},f.createElement(An,Object.assign({chartType:"sankey",nodes:$,edges:R,size:[H,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:X,nodeIDAccessor:d,sourceAccessor:l,targetAccessor:c,valueAccessor:u,orientation:p,nodeAlign:m,nodePaddingRatio:v,nodeWidth:b,nodeStyle:Y,edgeStyle:G,colorBy:h,colorScheme:g,edgeColorBy:y,edgeOpacity:k,edgeSort:w,nodeLabel:q,showLabels:D,enableHover:B,tooltipContent:A?e=>Mn(A)(e.data):void 0,customHoverBehavior:M||S?V:void 0,customClickBehavior:S?U:void 0},P&&"none"!==P&&{legendHoverBehavior:F.onLegendHover,legendClickBehavior:F.onLegendClick,legendHighlightedCategory:F.highlightedCategory,legendIsolatedCategories:F.isolatedCategories},{className:s,title:W},E)))}function hr(t){var n;const o=ho(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:r,margin:i,className:a,layout:s="tree",orientation:l="vertical",childrenAccessor:c="children",valueAccessor:u="value",nodeIdAccessor:d="name",colorBy:h,colorScheme:g="category10",colorByDepth:y=!1,edgeStyle:p="curve",nodeLabel:m,nodeSize:v=5,tooltip:b,frameProps:x={},onObservation:k,chartId:w,selection:A,linkedHover:E,loading:S,legendInteraction:L}=t,O=o.width,M=o.height,C=o.enableHover,j=null===(n=o.showLabels)||void 0===n||n,P=o.title,H=ko(S,O,M);if(H)return H;const N=e.useMemo(()=>ar(r,c),[r,c]),B=io(N,y?void 0:h,g),D=e.useMemo(()=>{if(!h||y)return[];const e=new Set;for(const t of N){const n="function"==typeof h?h(t):t[h];null!=n&&e.add(n+"")}return Array.from(e)},[N,h,y]),W=co(L,y?void 0:h,D),T=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=y?gn[(e.depth||0)%gn.length]:h?fn(e.data||e,h,B):oo,t},[h,y,B]),I=e.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),R=e.useMemo(()=>{if("treemap"===s||"circlepack"===s||"partition"===s)return lr(u)},[s,u]),$=Object.assign(Object.assign({},o.marginDefaults),i),{customHoverBehavior:z}=so({selection:A,linkedHover:E,fallbackFields:h?["string"==typeof h?h:""]:[],unwrapData:!0,onObservation:k,chartType:"TreeDiagram",chartId:w}),_=Oo({componentName:"TreeDiagram",data:r});return _?f.createElement(go,{componentName:"TreeDiagram",message:_,width:O,height:M}):f.createElement(mo,{componentName:"TreeDiagram",width:O,height:M},f.createElement(An,Object.assign({chartType:s,data:r,size:[O,M],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:$,nodeIDAccessor:d,childrenAccessor:c,hierarchySum:R,treeOrientation:l,edgeType:p,nodeStyle:T,edgeStyle:I,colorBy:h,colorScheme:g,colorByDepth:y,nodeSize:v,nodeLabel:j?m||d:void 0,showLabels:j,enableHover:C,tooltipContent:b?e=>Mn(b)(e.data):void 0,customHoverBehavior:E||k?z:void 0},L&&"none"!==L&&{legendHoverBehavior:W.onLegendHover,legendClickBehavior:W.onLegendClick,legendHighlightedCategory:W.highlightedCategory,legendIsolatedCategories:W.isolatedCategories},{className:a,title:P},x)))}function gr(t){var n;const o=ho(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,linkedHover:t.linkedHover},{width:600,height:600}),{data:r,margin:i,className:a,childrenAccessor:s="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d="category10",colorByDepth:h=!1,labelMode:g="leaf",nodeLabel:y,padding:p=4,paddingTop:m,tooltip:v,frameProps:b={},selection:x,linkedHover:k,onObservation:w,chartId:A,loading:E,legendInteraction:S}=t,L=o.width,O=o.height,M=o.enableHover,C=null===(n=o.showLabels)||void 0===n||n,j=o.title,P=ko(E,L,O);if(P)return P;const{activeSelectionHook:H,customHoverBehavior:N}=so({selection:x,linkedHover:k,fallbackFields:u?["string"==typeof u?u:""]:[],onObservation:w,chartType:"Treemap",chartId:A}),B=e.useCallback(e=>{if(!e)return N(null);const t=e.data||e;N({data:(null==t?void 0:t.data)||t})},[N]),D=e.useMemo(()=>ar(r,s),[r,s]),W=io(D,h?void 0:u,d),T=e.useMemo(()=>{if(!u||h)return[];const e=new Set;for(const t of D){const n="function"==typeof u?u(t):t[u];null!=n&&e.add(n+"")}return Array.from(e)},[D,u,h]),I=co(S,h?void 0:u,T),R=e.useMemo(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=h?gn[(e.depth||0)%gn.length]:u?fn(e.data||e,u,W):oo,t},[u,h,W]),$=e.useMemo(()=>H?e=>{var t;const n=Object.assign({},R(e));if(H.isActive)if(H.predicate(e.data||e))(null==x?void 0:x.selectedStyle)&&Object.assign(n,x.selectedStyle);else{const e=null!==(t=null==x?void 0:x.unselectedOpacity)&&void 0!==t?t:.2;n.opacity=e,n.fillOpacity=e,n.strokeOpacity=e,(null==x?void 0:x.unselectedStyle)&&Object.assign(n,x.unselectedStyle)}return n}:R,[R,H,x]),z=e.useMemo(()=>lr(l),[l]),_=void 0!==m?m:C&&"parent"===g?18:void 0,F=Object.assign(Object.assign({},o.marginDefaults),i),Y=Oo({componentName:"Treemap",data:r});return Y?f.createElement(go,{componentName:"Treemap",message:Y,width:L,height:O}):f.createElement(mo,{componentName:"Treemap",width:L,height:O},f.createElement(An,Object.assign({chartType:"treemap",data:r,size:[L,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:F,nodeIDAccessor:c,childrenAccessor:s,hierarchySum:z,padding:p,paddingTop:_,nodeStyle:$,colorBy:u,colorScheme:d,colorByDepth:h,nodeLabel:C?y||c:void 0,showLabels:C,enableHover:M,tooltipContent:v?e=>Mn(v)(e.data):void 0},(k||w)&&{customHoverBehavior:B},S&&"none"!==S&&{legendHoverBehavior:I.onLegendHover,legendClickBehavior:I.onLegendClick,legendHighlightedCategory:I.highlightedCategory,legendIsolatedCategories:I.isolatedCategories},{className:a,title:j},b)))}function fr(t){var n;const o=ho(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:r,margin:i,className:a,childrenAccessor:s="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d="category10",colorByDepth:h=!1,nodeLabel:g,circleOpacity:y=.7,padding:p=4,tooltip:m,frameProps:v={},onObservation:b,chartId:x,selection:k,linkedHover:w,loading:A,legendInteraction:E}=t,S=o.width,L=o.height,O=o.enableHover,M=null===(n=o.showLabels)||void 0===n||n,C=o.title,j=ko(A,S,L);if(j)return j;const P=e.useMemo(()=>ar(r,s),[r,s]),H=io(P,h?void 0:u,d),N=e.useMemo(()=>{if(!u||h)return[];const e=new Set;for(const t of P){const n="function"==typeof u?u(t):t[u];null!=n&&e.add(n+"")}return Array.from(e)},[P,u,h]),B=co(E,h?void 0:u,N),D=e.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:y};return t.fill=h?gn[(e.depth||0)%gn.length]:u?fn(e.data||e,u,H):oo,t},[u,h,H,y]),W=e.useMemo(()=>lr(l),[l]),T=Object.assign(Object.assign({},o.marginDefaults),i),{customHoverBehavior:I}=so({selection:k,linkedHover:w,fallbackFields:u?["string"==typeof u?u:""]:[],unwrapData:!0,onObservation:b,chartType:"CirclePack",chartId:x}),R=Oo({componentName:"CirclePack",data:r});return R?f.createElement(go,{componentName:"CirclePack",message:R,width:S,height:L}):f.createElement(mo,{componentName:"CirclePack",width:S,height:L},f.createElement(An,Object.assign({chartType:"circlepack",data:r,size:[S,L],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:T,nodeIDAccessor:c,childrenAccessor:s,hierarchySum:W,padding:p,nodeStyle:D,colorBy:u,colorScheme:d,colorByDepth:h,nodeLabel:M?g||c:void 0,showLabels:M,enableHover:O,tooltipContent:m?e=>Mn(m)(e.data):void 0,customHoverBehavior:w||b?I:void 0},E&&"none"!==E&&{legendHoverBehavior:B.onLegendHover,legendClickBehavior:B.onLegendClick,legendHighlightedCategory:B.highlightedCategory,legendIsolatedCategories:B.isolatedCategories},{className:a,title:C},v)))}Go.displayName="ScatterplotMatrix",Xo.displayName="MinimapChart",Vo.displayName="BarChart",Uo.displayName="StackedBarChart",Zo.displayName="SwarmPlot",Qo.displayName="BoxPlot",Ko.displayName="Histogram",Jo.displayName="ViolinPlot",er.displayName="RidgelinePlot",tr.displayName="DotPlot",nr.displayName="PieChart",or.displayName="DonutChart",rr.displayName="GroupedBarChart",ir.displayName="ForceDirectedGraph",ur.displayName="ChordDiagram",dr.displayName="SankeyDiagram",hr.displayName="TreeDiagram",gr.displayName="Treemap",fr.displayName="CirclePack";const yr=["#93c5fd","#fca5a5","#86efac","#fde68a","#c4b5fd","#f9a8d4","#a5f3fc"];function pr(t){const n=ho(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,title:t.title},{width:600,height:600}),{data:o,childrenAccessor:r="children",nodeIdAccessor:i="name",colorBy:a,colorScheme:l="category10",colorByDepth:c=!1,orbitMode:u="flat",orbitSize:d=2.95,speed:h=.25,revolution:g=e=>1/(e.depth+1),eccentricity:y=1,showRings:p=!0,nodeRadius:m=6,showLabels:v=!1,animated:b=!0,tooltip:x,foregroundGraphics:k,className:w,annotations:A,selection:E,linkedHover:S,onObservation:L,chartId:O,loading:M}=t,C=n.width,j=n.height,P=n.title,H=ko(M,C,j);if(H)return H;const N=e.useMemo(()=>"function"==typeof r?r:e=>e[r],[r]),B=e.useMemo(()=>"function"==typeof i?i:e=>{var t;return(null!==(t=e[i])&&void 0!==t?t:"")+""},[i]),D=e.useMemo(()=>"function"==typeof m?m:()=>m,[m]),{customHoverBehavior:W}=so({selection:E,linkedHover:S,fallbackFields:a?["string"==typeof a?a:""]:[],onObservation:L,chartType:"OrbitDiagram",chartId:O}),T=io(e.useMemo(()=>{const e=[];return function t(n){e.push(n);const o=N(n);o&&o.forEach(t)}(o),e},[o,N]),c?void 0:a,l),{nodes:I,rings:R,eccentricityFn:$}=e.useMemo(()=>function(e,t,n,o,r,i,a){const l=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(r),c="number"==typeof i?()=>i:i,u="number"==typeof a?()=>a:a,d=[],h=[],g={datum:e,x:t[0]/2,y:t[1]/2,ring:Math.min(t[0],t[1])/2*.85,angle:0,depth:0,id:o(e)};return d.push(g),function e(t){const r=n(t.datum);if(!(null==r?void 0:r.length))return;t.children=[];const i=r.length;let a=0,g=0,f=0;for(;i>g;)g+=l[Math.min(f,l.length-1)],f++,a++;let y=0;for(let i=0;a>i;i++){const g=l[Math.min(i,l.length-1)],f=r.slice(y,y+g);if(!f.length)break;const p=(i+1)/a,m=t.parent?t.ring/c(t)*p:t.ring*p,v=s.pie().value(e=>{var t;return(null===(t=n(e))||void 0===t?void 0:t.length)?4:1}).sort(null),b=v(f),x=u(t);h.push({source:t,x:t.x,y:t.y,r:m,ry:m*x});for(let n=0;f.length>n;n++){const r=(b[n].startAngle+b[n].endAngle)/2,i={datum:f[n],x:t.x+m*Math.sin(r),y:t.y+m*Math.cos(r)*x,ring:m,angle:r,depth:t.depth+1,parent:t,id:o(f[n])};t.children.push(i),d.push(i),e(i)}y+=g}}(g),{nodes:d,rings:h,eccentricityFn:u}}(o,[C,j],N,B,u,d,y),[o,C,j,N,B,u,d,y]),[,z]=e.useState(0),_=e.useRef(0),F=h*(Math.PI/360);e.useEffect(()=>{if(!b)return;let e;const t=()=>{_.current++,function(e,t,n,o,r,i){for(const t of e){if(!t.parent)continue;const e=t.angle+n*o*r(t),a=i(t);t.x=t.parent.x+t.ring*Math.sin(e),t.y=t.parent.y+t.ring*Math.cos(e)*a}for(const e of t)e.x=e.source.x,e.y=e.source.y}(I,R,_.current,F,g,$),z(e=>e+1),e=requestAnimationFrame(t)};return e=requestAnimationFrame(t),()=>cancelAnimationFrame(e)},[b,I,R,F,g,$]);const[Y,G]=e.useState(null),q=e.useCallback(e=>{G(e),W&&W(e?{data:e.datum,x:e.x,y:e.y}:null)},[W]),X=e.useCallback(e=>c?yr[e.depth%yr.length]:a?fn(e.datum,a,T):oo,[a,c,T]),V=Oo({componentName:"OrbitDiagram",data:o});return V?f.createElement(go,{componentName:"OrbitDiagram",message:V,width:C,height:j}):f.createElement(mo,{componentName:"OrbitDiagram",width:C,height:j},f.createElement("div",{className:"semiotic-orbit-diagram"+(w?" "+w:""),role:"img","aria-label":"string"==typeof P?P:"Orbit diagram",tabIndex:0,style:{position:"relative",width:C,height:j}},f.createElement("svg",{width:C,height:j},p&&R.map((e,t)=>f.createElement("ellipse",{key:"ring-"+t,cx:e.x,cy:e.y,rx:e.r,ry:e.ry,fill:"none",stroke:"currentColor",strokeWidth:.5,opacity:.15})),I.map((e,t)=>e.parent?f.createElement("line",{key:"edge-"+t,x1:e.parent.x,y1:e.parent.y,x2:e.x,y2:e.y,stroke:"currentColor",strokeWidth:.5,opacity:.1}):null),I.map((e,t)=>{const n=D(e),o=X(e),r=Y===e;return f.createElement("g",{key:"node-"+t},f.createElement("circle",{cx:e.x,cy:e.y,r:r?1.5*n:n,fill:o,stroke:"white",strokeWidth:r?2:1,opacity:0===e.depth?1:.85,style:{cursor:"pointer",transition:"r 0.15s"},onMouseEnter:()=>q(e),onMouseLeave:()=>q(null)}),v&&n>4&&f.createElement("text",{x:e.x,y:e.y+n+12,textAnchor:"middle",fontSize:10,fill:"currentColor",opacity:.7},B(e.datum)))}),null==A?void 0:A.map((e,t)=>{var n,o,r,i,a;if("widget"!==e.type)return null;const s=e.nodeId?I.find(t=>t.id===e.nodeId):null;if(!s)return null;const l=null!==(n=e.dx)&&void 0!==n?n:0,c=null!==(o=e.dy)&&void 0!==o?o:-16,u=null!==(r=e.width)&&void 0!==r?r:32,d=null!==(i=e.height)&&void 0!==i?i:32,h=null!==(a=e.content)&&void 0!==a?a:f.createElement("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info"},"ℹ️");return f.createElement("foreignObject",{key:"ann-"+t,x:s.x+l-u/2,y:s.y+c-d/2,width:u,height:d,style:{overflow:"visible",pointerEvents:"auto"}},f.createElement("div",{style:{width:u,height:d,display:"flex",alignItems:"center",justifyContent:"center"}},h))}),k),Y&&x&&f.createElement("div",{style:{position:"absolute",left:Y.x+12,top:Y.y-12,background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,pointerEvents:"none",zIndex:10,whiteSpace:"nowrap"}},x(Y)),Y&&!x&&f.createElement("div",{style:{position:"absolute",left:Y.x+12,top:Y.y-12,background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,pointerEvents:"none",zIndex:10,whiteSpace:"nowrap"}},f.createElement("strong",null,B(Y.datum)),Y.depth>0&&f.createElement("span",{style:{opacity:.7}}," (depth ",Y.depth,")")),P&&f.createElement("div",{style:{position:"absolute",top:8,left:0,width:"100%",textAlign:"center",fontSize:14,fontWeight:600,color:"currentColor",pointerEvents:"none"}},P)))}pr.displayName="OrbitDiagram";const mr=e.forwardRef(function(t,n){var o,r,i,a;const s=ho(t.mode,{width:null!==(r=null===(o=t.size)||void 0===o?void 0:o[0])&&void 0!==r?r:t.width,height:null!==(a=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==a?a:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:l,margin:c,className:u,arrowOfTime:d="right",windowMode:h="sliding",windowSize:g=200,data:y,timeAccessor:p,valueAccessor:m,timeExtent:v,valueExtent:b,extentPadding:x,stroke:k="#007bff",strokeWidth:w=2,strokeDasharray:A,background:E,tooltipContent:S,tooltip:L,onHover:O,annotations:M,svgAnnotationRules:C,tickFormatTime:j,tickFormatValue:P,decay:H,pulse:N,staleness:B,transition:D,linkedHover:W,onObservation:T,chartId:I}=t,R=s.showAxes,$=s.enableHover,z=null!=c?c:s.marginDefaults,_=null!=l?l:[s.width,s.height],F=null!=S?S:L,Y=e.useRef(null),{customHoverBehavior:G}=so({linkedHover:W,unwrapData:!0,onObservation:T,chartType:"RealtimeLineChart",chartId:I}),q=e.useCallback(e=>{O&&O(e),G(e)},[O,G]);return e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=Y.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=Y.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}})),f.createElement(ke,{ref:Y,chartType:"line",runtimeMode:"streaming",size:_,margin:z,className:u,arrowOfTime:d,windowMode:h,windowSize:g,data:y,timeAccessor:p,valueAccessor:m,xExtent:v,yExtent:b,extentPadding:x,lineStyle:{stroke:k,strokeWidth:w,strokeDasharray:A},showAxes:R,background:E,hoverAnnotation:$,tooltipContent:F,customHoverBehavior:q,annotations:M,svgAnnotationRules:C,tickFormatTime:j,tickFormatValue:P,decay:H,pulse:N,staleness:B,transition:D})});mr.displayName="RealtimeLineChart";const vr=e.forwardRef(function(t,n){var o,r,i,a;const s=ho(t.mode,{width:null!==(r=null===(o=t.size)||void 0===o?void 0:o[0])&&void 0!==r?r:t.width,height:null!==(a=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==a?a:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{binSize:l,size:c,margin:u,className:d,arrowOfTime:h="right",windowMode:g="sliding",windowSize:y=200,data:p,timeAccessor:m,valueAccessor:v,timeExtent:b,valueExtent:x,extentPadding:k,categoryAccessor:w,colors:A,fill:E,stroke:S,strokeWidth:L,gap:O,background:M,tooltipContent:C,tooltip:j,onHover:P,annotations:H,svgAnnotationRules:N,tickFormatTime:B,tickFormatValue:D,linkedHover:W,decay:T,pulse:I,staleness:R,transition:$,onObservation:z,chartId:_}=t,F=s.showAxes,Y=s.enableHover,G=null!=u?u:s.marginDefaults,q=null!=c?c:[s.width,s.height],X=null!=C?C:j,V=e.useRef(null),{customHoverBehavior:U}=so({linkedHover:W,unwrapData:!0,onObservation:z,chartType:"RealtimeTemporalHistogram",chartId:_}),Z=e.useCallback(e=>{P&&P(e),U(e)},[P,U]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=V.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=V.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=V.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=V.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const Q={};return null!=E&&(Q.fill=E),null!=S&&(Q.stroke=S),null!=L&&(Q.strokeWidth=L),null!=O&&(Q.gap=O),f.createElement(ke,{ref:V,chartType:"bar",runtimeMode:"streaming",size:q,margin:G,className:d,arrowOfTime:h,windowMode:g,windowSize:y,data:p,timeAccessor:m,valueAccessor:v,xExtent:b,yExtent:x,extentPadding:k,binSize:l,categoryAccessor:w,barColors:A,barStyle:Q,showAxes:F,background:M,hoverAnnotation:Y,tooltipContent:X,customHoverBehavior:Z,annotations:H,svgAnnotationRules:N,tickFormatTime:B,tickFormatValue:D,decay:T,pulse:I,staleness:R,transition:$})});vr.displayName="RealtimeTemporalHistogram";const br=vr,xr=e.forwardRef(function(t,n){var o,r,i,a;const s=ho(t.mode,{width:null!==(r=null===(o=t.size)||void 0===o?void 0:o[0])&&void 0!==r?r:t.width,height:null!==(a=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==a?a:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:l,margin:c,className:u,arrowOfTime:d="right",windowMode:h="sliding",windowSize:g=200,data:y,timeAccessor:p,valueAccessor:m,timeExtent:v,valueExtent:b,extentPadding:x,categoryAccessor:k,colors:w,radius:A,fill:E,opacity:S,stroke:L,strokeWidth:O,background:M,tooltipContent:C,tooltip:j,onHover:P,annotations:H,svgAnnotationRules:N,tickFormatTime:B,tickFormatValue:D,linkedHover:W,onObservation:T,chartId:I}=t,R=s.showAxes,$=s.enableHover,z=null!=c?c:s.marginDefaults,_=null!=l?l:[s.width,s.height],F=null!=C?C:j,Y=e.useRef(null),{customHoverBehavior:G}=so({linkedHover:W,unwrapData:!0,onObservation:T,chartType:"RealtimeSwarmChart",chartId:I}),q=e.useCallback(e=>{P&&P(e),G(e)},[P,G]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=Y.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=Y.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const X={};return null!=A&&(X.radius=A),null!=E&&(X.fill=E),null!=S&&(X.opacity=S),null!=L&&(X.stroke=L),null!=O&&(X.strokeWidth=O),f.createElement(ke,{ref:Y,chartType:"swarm",runtimeMode:"streaming",size:_,margin:z,className:u,arrowOfTime:d,windowMode:h,windowSize:g,data:y,timeAccessor:p,valueAccessor:m,xExtent:v,yExtent:b,extentPadding:x,categoryAccessor:k,barColors:w,swarmStyle:X,showAxes:R,background:M,hoverAnnotation:$,tooltipContent:F,customHoverBehavior:q,annotations:H,svgAnnotationRules:N,tickFormatTime:B,tickFormatValue:D})});xr.displayName="RealtimeSwarmChart";const kr=e.forwardRef(function(t,n){var o,r,i,a;const s=ho(t.mode,{width:null!==(r=null===(o=t.size)||void 0===o?void 0:o[0])&&void 0!==r?r:t.width,height:null!==(a=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==a?a:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:l,margin:c,className:u,arrowOfTime:d="right",windowMode:h="sliding",windowSize:g=200,data:y,timeAccessor:p,valueAccessor:m,timeExtent:v,valueExtent:b,extentPadding:x,positiveColor:k,negativeColor:w,connectorStroke:A,connectorWidth:E,gap:S,stroke:L,strokeWidth:O,background:M,tooltipContent:C,tooltip:j,onHover:P,annotations:H,svgAnnotationRules:N,tickFormatTime:B,tickFormatValue:D,linkedHover:W,onObservation:T,chartId:I}=t,R=s.showAxes,$=s.enableHover,z=null!=c?c:s.marginDefaults,_=null!=l?l:[s.width,s.height],F=null!=C?C:j,Y=e.useRef(null),{customHoverBehavior:G}=so({linkedHover:W,unwrapData:!0,onObservation:T,chartType:"RealtimeWaterfallChart",chartId:I}),q=e.useCallback(e=>{P&&P(e),G(e)},[P,G]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=Y.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=Y.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const X={};return null!=k&&(X.positiveColor=k),null!=w&&(X.negativeColor=w),null!=A&&(X.connectorStroke=A),null!=E&&(X.connectorWidth=E),null!=S&&(X.gap=S),null!=L&&(X.stroke=L),null!=O&&(X.strokeWidth=O),f.createElement(ke,{ref:Y,chartType:"waterfall",runtimeMode:"streaming",size:_,margin:z,className:u,arrowOfTime:d,windowMode:h,windowSize:g,data:y,timeAccessor:p,valueAccessor:m,xExtent:v,yExtent:b,extentPadding:x,waterfallStyle:X,showAxes:R,background:M,hoverAnnotation:$,tooltipContent:F,customHoverBehavior:q,annotations:H,svgAnnotationRules:N,tickFormatTime:B,tickFormatValue:D})});kr.displayName="RealtimeWaterfallChart";const wr=e.forwardRef(function(t,n){var o,r,i,a;const s=ho(t.mode,{width:null!==(r=null===(o=t.size)||void 0===o?void 0:o[0])&&void 0!==r?r:t.width,height:null!==(a=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==a?a:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:l,margin:c,className:u,arrowOfTime:d="right",windowMode:h="sliding",windowSize:g=200,data:y,timeAccessor:p,valueAccessor:m,categoryAccessor:v,timeExtent:b,valueExtent:x,extentPadding:k,heatmapXBins:w=20,heatmapYBins:A=20,aggregation:E="count",background:S,tooltipContent:L,tooltip:O,onHover:M,annotations:C,svgAnnotationRules:j,tickFormatTime:P,tickFormatValue:H,decay:N,pulse:B,staleness:D,linkedHover:W,onObservation:T,chartId:I}=t,R=s.showAxes,$=s.enableHover,z=null!=c?c:s.marginDefaults,_=null!=l?l:[s.width,s.height],F=null!=L?L:O,Y=e.useRef(null),{customHoverBehavior:G}=so({linkedHover:W,unwrapData:!0,onObservation:T,chartType:"RealtimeHeatmap",chartId:I}),q=e.useCallback(e=>{M&&M(e),G(e)},[M,G]);return e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=Y.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=Y.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}})),f.createElement(ke,{ref:Y,chartType:"heatmap",runtimeMode:"streaming",size:_,margin:z,className:u,arrowOfTime:d,windowMode:h,windowSize:g,data:y,timeAccessor:p,valueAccessor:m,categoryAccessor:v,xExtent:b,yExtent:x,extentPadding:k,heatmapXBins:w,heatmapYBins:A,heatmapAggregation:E,showAxes:R,background:S,hoverAnnotation:$,tooltipContent:F,customHoverBehavior:q,annotations:C,svgAnnotationRules:j,tickFormatTime:P,tickFormatValue:H,decay:N,pulse:B,staleness:D})});wr.displayName="RealtimeHeatmap";const Ar={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},Er={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},[Sr,Lr]=In(e=>({theme:Ar,setTheme(t){e(e=>"light"===t?{theme:Ar}:"dark"===t?{theme:Er}:{theme:Object.assign(Object.assign(Object.assign({},e.theme),t),{colors:Object.assign(Object.assign({},e.theme.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.theme.typography),t.typography||{})})})}}));function Or({theme:e}){const t=Lr(e=>e.setTheme);return f.useEffect(()=>{void 0!==e&&t(e)},[e,t]),null}function Mr({children:e}){const t=Lr(e=>e.theme);return f.createElement("div",{style:{position:"relative","--semiotic-bg":t.colors.background,"--semiotic-text":t.colors.text,"--semiotic-text-secondary":t.colors.textSecondary,"--semiotic-grid":t.colors.grid,"--semiotic-border":t.colors.border,"--semiotic-primary":t.colors.primary,"--semiotic-font-family":t.typography.fontFamily}},e)}function Cr(e,t,n,o){return new(n||(n=Promise))(function(r,i){function a(e){try{l(o.next(e))}catch(e){i(e)}}function s(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){e.done?r(e.value):function(e){return e instanceof n?e:new n(function(t){t(e)})}(e.value).then(a,s)}l((o=o.apply(e,t||[])).next())})}function jr(e,t){return Cr(this,void 0,void 0,function*(){const{format:n="png",filename:o="chart",scale:r=2,background:i="white"}=t||{},a=e.querySelector("svg");if(!a)throw Error("No SVG element found in the container");const s=a.cloneNode(!0),l=a.getBoundingClientRect();if(s.getAttribute("width")||s.setAttribute("width",l.width+""),s.getAttribute("height")||s.setAttribute("height",l.height+""),s.getAttribute("xmlns")||s.setAttribute("xmlns","http://www.w3.org/2000/svg"),Pr(a,s),"svg"===n){const e=(new XMLSerializer).serializeToString(s);Hr(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),o+".svg")}else{const t=l.width*r,n=l.height*r,a=document.createElement("canvas");a.width=t,a.height=n;const c=a.getContext("2d");c.fillStyle=i,c.fillRect(0,0,t,n),c.scale(r,r);const u=e.querySelector("canvas");u&&c.drawImage(u,0,0,l.width,l.height);const d=(new XMLSerializer).serializeToString(s),h=new Blob([d],{type:"image/svg+xml;charset=utf-8"}),g=URL.createObjectURL(h),f=new Image;f.width=l.width,f.height=l.height,yield new Promise((e,t)=>{f.onload=()=>{c.drawImage(f,0,0),a.toBlob(n=>{n?(Hr(n,o+".png"),e()):t(Error("Failed to create PNG blob"))},"image/png"),URL.revokeObjectURL(g)},f.onerror=()=>{URL.revokeObjectURL(g),t(Error("Failed to load SVG image"))},f.src=g})}})}function Pr(e,t){var n;const o=e.children,r=t.children,i=window.getComputedStyle(e),a=["fill","stroke","stroke-width","stroke-dasharray","opacity","fill-opacity","stroke-opacity","font-family","font-size","font-weight","text-anchor","dominant-baseline"];for(const e of a){const o=i.getPropertyValue(e);o&&"none"!==o&&""!==o&&(null===(n=t.style)||void 0===n||n.setProperty(e,o))}for(let e=0;Math.min(o.length,r.length)>e;e++)Pr(o[e],r[e])}function Hr(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}"function"==typeof SuppressedError&&SuppressedError;const Nr={width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["function","object"]},frameProps:{type:"object"}},Br={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},Dr={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"}},Wr=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],Tr=["vertical","horizontal"],Ir={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Nr),Br),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Wr},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},fillArea:{type:"boolean"},areaOpacity:{type:"number"}})},AreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Nr),Br),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Wr},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Nr),Br),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Wr},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},normalize:{type:"boolean"}})},Scatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Nr),Br),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},BubbleChart:{required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Nr),Br),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},bubbleOpacity:{type:"number"},bubbleStrokeWidth:{type:"number"},bubbleStrokeColor:{type:"string"}})},Heatmap:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Nr),Br),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},colorScheme:{type:"string",enum:["blues","reds","greens","viridis","custom"]},customColorScale:{type:["object","function"]},showValues:{type:"boolean"},valueFormat:{type:"function"},cellBorderColor:{type:"string"},cellBorderWidth:{type:"number"}})},ConnectedScatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Nr),Br),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},orderAccessor:{type:["string","function"]},orderLabel:{type:"string"},pointRadius:{type:"number"},pointIdAccessor:{type:["string","function"]},annotations:{type:"array"}})},BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Nr),Dr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Tr},sort:{type:["boolean","string","function"]},barPadding:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Nr),Dr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Tr},normalize:{type:"boolean"},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Nr),Dr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Tr},barPadding:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Nr),Dr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Tr},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"}})},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Nr),Dr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Tr},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Nr),Dr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"}})},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Nr),Dr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Tr},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"}})},DotPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Nr),Dr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Tr},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},Nr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"},slicePadding:{type:"number"}})},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},Nr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"},slicePadding:{type:"number"}})},ForceDirectedGraph:{required:["nodes","edges"],dataShape:"network",dataAccessors:["nodeIDAccessor","sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Nr),{nodes:{type:"array"},edges:{type:"array"},nodeIDAccessor:{type:["string","function"]},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},nodeLabel:{type:["string","function"]},nodeSize:{type:["number","string","function"]},nodeSizeRange:{type:"array"},edgeWidth:{type:["number","string","function"]},edgeColor:{type:"string"},edgeOpacity:{type:"number"},iterations:{type:"number"},forceStrength:{type:"number"},showLabels:{type:"boolean"}})},SankeyDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Nr),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target","gradient"]},orientation:{type:"string",enum:Tr},nodeAlign:{type:"string",enum:["justify","left","right","center"]},nodePaddingRatio:{type:"number"},nodeWidth:{type:"number"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"},edgeSort:{type:"function"}})},ChordDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Nr),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target"]},padAngle:{type:"number"},groupWidth:{type:"number"},sortGroups:{type:"function"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"}})},TreeDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Nr),{data:{type:"object"},layout:{type:"string",enum:["tree","cluster","partition","treemap","circlepack"]},orientation:{type:"string",enum:["vertical","horizontal","radial"]},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},edgeStyle:{type:"string",enum:["line","curve"]},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},nodeSize:{type:"number"}})},Treemap:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Nr),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]}})},CirclePack:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Nr),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]},circleOpacity:{type:"number"}})},OrbitDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Nr),{data:{type:"object"},childrenAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},orbitMode:{type:["string","array"]},speed:{type:"number"},revolution:{type:"function"},eccentricity:{type:["number","function"]},orbitSize:{type:["number","function"]},nodeRadius:{type:["number","function"]},showRings:{type:"boolean"},showLabels:{type:"boolean"},animated:{type:"boolean"},colorByDepth:{type:"boolean"},annotations:{type:"array"},foregroundGraphics:{type:"object"}})},RealtimeLineChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},stroke:{type:"string"},strokeWidth:{type:"number"},strokeDasharray:{type:"string"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHistogram:{required:["binSize"],dataShape:"realtime",dataAccessors:[],props:{binSize:{type:"number"},size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeSwarmChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},radius:{type:"number"},fill:{type:"string"},opacity:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeWaterfallChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},positiveColor:{type:"string"},negativeColor:{type:"string"},connectorStroke:{type:"string"},connectorWidth:{type:"number"},gap:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHeatmap:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},heatmapXBins:{type:"number"},heatmapYBins:{type:"number"},aggregation:{type:"string",enum:["count","sum","mean"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"}}}},Rr=new Set(["tooltip","onObservation","xFormat","yFormat","valueFormat","svgAnnotationRules","tooltipContent","onHover","tickFormatTime","tickFormatValue","edgeSort","sortGroups","centerContent","frameProps","controls","oFormat","rFormat","oSort","pieceStyle","summaryStyle","nodeStyle","edgeStyle","customHoverBehavior","customClickBehavior","customDoubleClickBehavior","onBrush","onTopologyChange","backgroundGraphics","foregroundGraphics","legend"]),$r=new Set(["data","nodes","edges"]),zr="function"==typeof structuredClone?structuredClone:e=>JSON.parse(JSON.stringify(e));function _r(e){return Cr(this,arguments,void 0,function*(e,t="json"){const n="jsx"===t?Fr(e):JSON.stringify(e,null,2);if("undefined"==typeof navigator||!navigator.clipboard)throw Error("Clipboard API not available. copyConfig requires a browser environment.");yield navigator.clipboard.writeText(n)})}function Fr(e){const{component:t,props:n}=e,o=["<"+t];for(const[e,t]of Object.entries(n))if("string"==typeof t)o.push(` ${e}="${t}"`);else if("boolean"==typeof t&&!0===t)o.push(" "+e);else if("boolean"==typeof t&&!1===t)o.push(` ${e}={false}`);else if("number"==typeof t)o.push(` ${e}={${t}}`);else{const n=JSON.stringify(t);o.push(80>n.length?` ${e}={${n}}`:` ${e}={${JSON.stringify(t,null,2)}}`)}return o.push("/>"),o.join("\n")}function Yr(e){return"nominal"===e||"ordinal"===e}function Gr(e){return"quantitative"===e||"temporal"===e}const qr={category10:"category10",category20:"category20",category20b:"category20",category20c:"category20",accent:"accent",dark2:"dark2",paired:"paired",pastel1:"pastel1",pastel2:"pastel2",set1:"set1",set2:"set2",set3:"set3",tableau10:"category10",tableau20:"category20"},Xr={linear:"linear","monotone-x":"monotoneX","monotone-y":"monotoneY",monotone:"monotoneX",step:"step","step-after":"stepAfter","step-before":"stepBefore",basis:"basis",cardinal:"cardinal","catmull-rom":"catmullRom"},Vr={sum:"sum",mean:"mean",average:"mean",count:"count",min:"min",max:"max",median:"mean"};function Ur(e,t,n,o,r){var i,a;(null==e?void 0:e.field)&&(n.xAccessor=o?"value":e.field),(null==t?void 0:t.field)&&(n.yAccessor=r?"value":t.field),(null===(i=null==e?void 0:e.axis)||void 0===i?void 0:i.title)&&(n.xLabel=e.axis.title),(null===(a=null==t?void 0:t.axis)||void 0===a?void 0:a.title)&&(n.yLabel=t.axis.title)}function Zr(e,t,n){const o={component:e,props:t,version:"1",createdAt:(new Date).toISOString()};if(n.length>0){o.warnings=n;for(const e of n)console.warn("[semiotic/fromVegaLite] "+e)}return o}const Qr={live:{bg:"#22c55e",color:"#fff"},stale:{bg:"#ef4444",color:"#fff"},paused:{bg:"#eab308",color:"#000"},error:{bg:"#ef4444",color:"#fff"},static:{bg:"#6b7280",color:"#fff"}};function Kr({height:e}){return f.createElement("div",{style:{width:"100%",height:e,background:"linear-gradient(90deg, var(--semiotic-border, #e0e0e0) 25%, var(--semiotic-bg, #f5f5f5) 50%, var(--semiotic-border, #e0e0e0) 75%)",backgroundSize:"200% 100%",animation:"semiotic-skeleton-pulse 1.5s ease-in-out infinite",borderRadius:4}})}function Jr({error:e}){return f.createElement("div",{role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:120,padding:24,boxSizing:"border-box"}},f.createElement("div",{style:{textAlign:"center",maxWidth:400,fontSize:14,color:"var(--semiotic-text-secondary, #666)",lineHeight:1.5}},e))}const ei=f.forwardRef(function({title:e,subtitle:t,children:n,width:o="100%",height:r=400,actions:i,chartConfig:a,controls:s,loading:l=!1,error:c,errorBoundary:u=!1,status:d,detailsPanel:h,className:g,style:y},p){const m=f.useRef(null),v=f.useRef(null),[b,x]=f.useState(!1),k=!1!==(null==i?void 0:i.export)&&void 0!==(null==i?void 0:i.export),w=!1!==(null==i?void 0:i.fullscreen)&&void 0!==(null==i?void 0:i.fullscreen),A=!1!==(null==i?void 0:i.copyConfig)&&void 0!==(null==i?void 0:i.copyConfig)&&a,E="object"==typeof(null==i?void 0:i.export)?i.export:{},S="object"==typeof(null==i?void 0:i.copyConfig)?i.copyConfig.format:"json",L=f.useCallback(e=>Cr(this,void 0,void 0,function*(){v.current&&(yield jr(v.current,Object.assign(Object.assign({},E),e)))}),[E]),O=f.useCallback(()=>{m.current&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):m.current.requestFullscreen().catch(()=>{}))},[]),M=f.useCallback(e=>Cr(this,void 0,void 0,function*(){a&&(yield _r(a,e||S||"json"))}),[a,S]);f.useEffect(()=>{const e=()=>{x(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]),f.useImperativeHandle(p,()=>({export:L,toggleFullscreen:O,copyConfig:M,element:m.current}),[L,O,M]);const C=e||t||s||k||w||A||d,j=l?f.createElement(Kr,{height:r}):c?f.createElement(Jr,{error:c}):u?f.createElement(fo,null,n):n;return f.createElement(f.Fragment,null,f.createElement("style",{dangerouslySetInnerHTML:{__html:"@keyframes semiotic-skeleton-pulse {\n 0% { background-position: 200% 0; }\n 100% { background-position: -200% 0; }\n}"}}),f.createElement("div",{ref:m,className:"semiotic-chart-container"+(g?" "+g:""),style:Object.assign(Object.assign({width:o,border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:8,overflow:"hidden",background:"var(--semiotic-bg, #fff)",position:"relative"},b?{display:"flex",flexDirection:"column",width:"100%",height:"100%"}:{}),y)},C&&f.createElement("div",{className:"semiotic-chart-header",style:{padding:"12px 16px",display:"flex",justifyContent:"space-between",alignItems:"flex-start",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"}},f.createElement("div",{className:"semiotic-chart-title-area"},e&&f.createElement("div",{className:"semiotic-chart-title",style:{fontSize:14,fontWeight:600,color:"var(--semiotic-text, #333)"}},e),t&&f.createElement("div",{className:"semiotic-chart-subtitle",style:{fontSize:12,color:"var(--semiotic-text-secondary, #666)",marginTop:e?2:0}},t)),f.createElement("div",{className:"semiotic-chart-toolbar",style:{display:"flex",alignItems:"center",gap:4}},s,k&&f.createElement("button",{className:"semiotic-chart-action",onClick:()=>L(),title:"Export chart",style:ti},f.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},f.createElement("path",{d:"M7 2v8M3.5 7L7 10.5 10.5 7"}),f.createElement("path",{d:"M2 12h10"}))),w&&f.createElement("button",{className:"semiotic-chart-action",onClick:O,title:b?"Exit fullscreen":"Fullscreen",style:ti},f.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},b?f.createElement(f.Fragment,null,f.createElement("path",{d:"M9 1v4h4"}),f.createElement("path",{d:"M5 13V9H1"}),f.createElement("path",{d:"M13 5H9V1"}),f.createElement("path",{d:"M1 9h4v4"})):f.createElement(f.Fragment,null,f.createElement("path",{d:"M1 5V1h4"}),f.createElement("path",{d:"M13 9v4H9"}),f.createElement("path",{d:"M9 1h4v4"}),f.createElement("path",{d:"M5 13H1V9"})))),A&&f.createElement("button",{className:"semiotic-chart-action",onClick:()=>M(),title:"Copy config",style:ti},f.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},f.createElement("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1"}),f.createElement("path",{d:"M9 5V2a1 1 0 00-1-1H2a1 1 0 00-1 1v6a1 1 0 001 1h3"}))),d&&f.createElement("div",{className:"semiotic-chart-status",style:{padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",background:Qr[d].bg,color:Qr[d].color,lineHeight:"18px"}},d))),f.createElement("div",{className:"semiotic-chart-body",ref:v,style:Object.assign({position:"relative",overflow:"hidden"},b?{flex:1}:{height:r})},j,h)))}),ti={width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0};function ni({children:e,columns:t="auto",minCellWidth:n=300,gap:o=16,className:r,style:i}){const a="number"==typeof t?t:void 0;return f.createElement("div",{className:"semiotic-chart-grid"+(r?" "+r:""),style:Object.assign({display:"grid",gridTemplateColumns:"auto"===t?`repeat(auto-fill, minmax(${n}px, 1fr))`:`repeat(${t}, 1fr)`,gap:o,width:"100%"},i)},f.Children.map(e,e=>f.isValidElement(e)?"primary"!==e.props.emphasis||void 0!==a&&2>a?e:f.createElement("div",{style:{gridColumn:"span 2"}},e):e))}function oi({children:e,context:t,position:n="right",contextSize:o=250,gap:r=12,className:i,style:a}){const s="left"===n||"right"===n,l="left"===n||"top"===n,c=Object.assign({display:"flex",flexDirection:s?l?"row-reverse":"row":l?"column-reverse":"column",gap:r,width:"100%"},a),u=s?{flex:`0 0 ${o}px`,width:o,minHeight:0}:{flex:`0 0 ${o}px`,height:o,minWidth:0};return f.createElement("div",{className:"semiotic-context-layout"+(i?" "+i:""),style:c},f.createElement("div",{style:{flex:"1 1 0%",minWidth:0,minHeight:0}},e),f.createElement("div",{style:u},t))}ni.displayName="ChartGrid",oi.displayName="ContextLayout";function ri({children:t,position:n="right",size:o=300,trigger:r="click",chartId:i,observation:a,dismissOnEmpty:s=!0,showClose:l=!0,onToggle:c,className:u,style:d}){const[h,g]=e.useState(null),[y,p]=e.useState(null),[m,v]=e.useState(!1),[b,x]=e.useState(!1),k=e.useRef(null),w=e.useRef(),A="click"===r?["click","click-end"]:["hover","hover-end"],{latest:E}=Zn({types:A,chartId:i,limit:1}),S=void 0!==a?a:E;e.useEffect(()=>{if(S)if("click"===S.type||"hover"===S.type){const e=S;g(e.datum),p(e),m||(v(!0),x(!0),clearTimeout(w.current),w.current=setTimeout(()=>x(!1),200))}else!s||"click-end"!==S.type&&"hover-end"!==S.type||L()},[S]),e.useEffect(()=>{null==c||c(m)},[m,c]);const L=e.useCallback(()=>{x(!0),v(!1),clearTimeout(w.current),w.current=setTimeout(()=>{x(!1),g(null),p(null)},200)},[]);if(e.useEffect(()=>()=>clearTimeout(w.current),[]),!h&&!b)return null;const O=h&&y?t(h,y):null;if(null===O&&!b)return null;const M=function(e,t,n,o){const r={position:"absolute",background:"var(--semiotic-bg, #fff)",borderColor:"var(--semiotic-border, #e0e0e0)",borderStyle:"solid",borderWidth:0,boxSizing:"border-box",zIndex:10,display:"flex",flexDirection:"column",transition:o?"transform 200ms ease-out, opacity 200ms ease-out":void 0};return Object.assign(Object.assign({},r),"right"===e?{top:0,right:0,width:t,height:"100%",borderLeftWidth:1,padding:"12px 16px",transform:n?"translateX(0)":`translateX(${t}px)`,opacity:n?1:0}:"bottom"===e?{bottom:0,left:0,width:"100%",height:t,borderTopWidth:1,padding:"12px 16px",transform:n?"translateY(0)":`translateY(${t}px)`,opacity:n?1:0}:{top:"50%",left:"50%",transform:n?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0.95)",opacity:n?1:0,width:Math.min(t,400),maxHeight:"80%",borderWidth:1,borderRadius:8,padding:"16px 20px",boxShadow:"0 8px 32px rgba(0,0,0,0.12)"})}(n,o,m,b);return f.createElement("div",{ref:k,className:`semiotic-details-panel semiotic-details-${n}${u?" "+u:""}`,style:Object.assign(Object.assign({},M),d)},l&&f.createElement("button",{className:"semiotic-details-close",onClick:L,"aria-label":"Close details",style:ii},f.createElement("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"},f.createElement("path",{d:"M2 2l8 8M10 2l-8 8"}))),f.createElement("div",{className:"semiotic-details-content",style:{overflow:"auto",flex:1}},O))}const ii={position:"absolute",top:8,right:8,width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0,zIndex:1};ri.displayName="DetailsPanel",exports.AreaChart=Bo,exports.BarChart=Vo,exports.BoxPlot=Qo,exports.BubbleChart=To,exports.CategoryColorProvider=Dn,exports.ChartContainer=ei,exports.ChartErrorBoundary=fo,exports.ChartGrid=ni,exports.ChordDiagram=ur,exports.CirclePack=fr,exports.ConnectedScatterplot=jo,exports.ContextLayout=oi,exports.DARK_THEME=Er,exports.DetailsPanel=ri,exports.DonutChart=or,exports.DotPlot=tr,exports.ForceDirectedGraph=ir,exports.GroupedBarChart=rr,exports.Heatmap=Wo,exports.Histogram=Ko,exports.IncrementalExtent=b,exports.LIGHT_THEME=Ar,exports.LineChart=No,exports.LinkedCharts=eo,exports.MinimapChart=Xo,exports.MultiLineTooltip=function(e={}){const{fields:t=[],title:n,format:o,style:r={},className:i="",showLabels:a=!0,separator:s=": "}=e;return e=>{if(!e||"object"!=typeof e)return null;const l=[];if(n){const t=Sn(e,n);l.push({value:Ln(t,o)})}t&&Array.isArray(t)&&t.length>0?t.forEach(t=>{let n,r,i;"string"==typeof t?(n=t,r=t,i=o):(n=t.label,r=t.accessor||t.key||"",i=t.format||o);const s=Ln(Sn(e,r),i);l.push({label:a?n:void 0,value:s})}):Object.keys(e).filter(e=>!e.startsWith("_")&&"data"!==e).forEach(t=>{l.push({label:a?t:void 0,value:Ln(e[t],o)})});const c=Object.assign(Object.assign({},En),r);return Array.isArray(l)&&0!==l.length?f.createElement("div",{className:("semiotic-tooltip semiotic-tooltip-multiline "+i).trim(),style:c},l.map((e,t)=>f.createElement("div",{key:t,style:{marginBottom:l.length-1>t?"4px":0}},e.label&&f.createElement("strong",null,e.label,s),e.value))):null}},exports.OrbitDiagram=pr,exports.PieChart=nr,exports.RealtimeHeatmap=wr,exports.RealtimeHistogram=br,exports.RealtimeLineChart=mr,exports.RealtimeSwarmChart=xr,exports.RealtimeTemporalHistogram=vr,exports.RealtimeWaterfallChart=kr,exports.RidgelinePlot=er,exports.RingBuffer=v,exports.SankeyDiagram=dr,exports.Scatterplot=Co,exports.ScatterplotMatrix=Go,exports.StackedAreaChart=Do,exports.StackedBarChart=Uo,exports.StreamNetworkFrame=An,exports.StreamOrdinalFrame=_e,exports.StreamXYFrame=ke,exports.SwarmPlot=Zo,exports.ThemeProvider=function({theme:e,children:t}){return f.createElement(Sr,null,f.createElement(Or,{theme:e}),f.createElement(Mr,null,t))},exports.Tooltip=On,exports.TreeDiagram=hr,exports.Treemap=gr,exports.ViolinPlot=Jo,exports.configToJSX=Fr,exports.copyConfig=_r,exports.deserializeSelections=function(e){const t=new Map;for(const[n,o]of Object.entries(e)){const e=new Map;for(const t of o.clauses){const n={};for(const[e,o]of Object.entries(t.fields))n[e]="point"===o.type?{type:"point",values:new Set(o.values)}:{type:"interval",range:o.range};e.set(t.clientId,{clientId:t.clientId,type:t.type,fields:n})}t.set(n,{name:o.name,resolution:o.resolution,clauses:e})}return t},exports.exportChart=jr,exports.fromConfig=function(e){if(!e.component||!e.props)throw Error("Invalid chart config: missing component or props");if(!Ir[e.component])throw Error(`Unknown component "${e.component}". This config may require a newer version of semiotic.`);return{componentName:e.component,props:zr(e.props)}},exports.fromURL=function(e){const t=new URLSearchParams(e.includes("?")?e.split("?")[1]:e).get("sc");if(!t)throw Error("No chart config found in URL (missing 'sc' parameter)");const n=t.replace(/-/g,"+").replace(/_/g,"/"),o=decodeURIComponent(escape(atob(n)));return JSON.parse(o)},exports.fromVegaLite=function(e){var t,n,o,r,i,a,s,l,c,u,d,h,g,f;const y=[],{type:p,markProps:m}=function(e){if("string"==typeof e)return{type:e,markProps:{}};const{type:t}=e;return{type:t,markProps:function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&0>t.indexOf(o)&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);o.length>r;r++)0>t.indexOf(o[r])&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}(e,["type"])}}(e.mark),v=e.encoding||{},b=v.x,x=v.y,k=v.color,w=v.size,A=v.theta,E=v.opacity;let S;(null===(t=e.data)||void 0===t?void 0:t.values)?S=e.data.values:(null===(n=e.data)||void 0===n?void 0:n.url)&&y.push("data.url is not supported — only inline data.values can be translated. Provide data manually."),e.transform&&e.transform.length>0&&y.push("Vega-Lite transforms are not supported. Pre-transform your data before passing to fromVegaLite()."),e.layer&&y.push('Layered specs ("layer") are not supported. Only single-mark specs can be translated.'),(e.hconcat||e.vconcat||e.concat)&&y.push('Concatenated views ("hconcat"/"vconcat"/"concat") are not supported. Translate each sub-spec individually.'),(e.facet||e.encoding&&e.encoding.facet||e.encoding&&(e.encoding.row||e.encoding.column))&&y.push("Faceted views are not supported. Use Semiotic's LinkedCharts or render multiple charts manually."),e.repeat&&y.push('Repeated views ("repeat") are not supported. Translate each field combination individually.'),(e.params||e.selection)&&y.push("Selections/params are not supported. Use Semiotic's LinkedCharts and selection props for interactivity.");const L={};e.width&&(L.width=e.width),e.height&&(L.height=e.height);const O=function(e){if(e)return"string"==typeof e?e:e.text}(e.title);if(O&&(L.title=O),(null==k?void 0:k.field)&&(L.colorBy=k.field,null===(o=k.scale)||void 0===o?void 0:o.scheme)){const e=qr[k.scale.scheme];e&&(L.colorScheme=e)}void 0!==(null==E?void 0:E.value)&&(L.pointOpacity=E.value);const M=null==b?void 0:b.aggregate,C=null==x?void 0:x.aggregate;if(S&&(M||C)){const e=C?x:b,t=C?b:x,n=Vr[e.aggregate];if(n&&(null==t?void 0:t.field)&&e.field)S=function(e,t){const{groupBy:n,value:o,agg:r="sum"}=t,i=new Map;for(const t of e){const e=t[n]+"";i.has(e)||i.set(e,[]),i.get(e).push(Number(t[o]))}const a=[];for(const[e,t]of i){let o;switch(r){case"count":o=t.length;break;case"mean":o=t.reduce((e,t)=>e+t,0)/t.length;break;case"min":o=Math.min(...t);break;case"max":o=Math.max(...t);break;default:o=t.reduce((e,t)=>e+t,0)}a.push({[n]:e,value:o})}return a}(S,{groupBy:t.field,value:e.field,agg:n});else if(("count"===n||"count"===e.aggregate)&&(null==t?void 0:t.field)&&S){const e=new Map;for(const n of S){const o=n[t.field]+"";e.set(o,(e.get(o)||0)+1)}S=Array.from(e,([e,n])=>({[t.field]:e,value:n}))}}if((null==b?void 0:b.bin)||(null==x?void 0:x.bin)){const e="Histogram";S&&(L.data=S),(null==b?void 0:b.bin)?(L.valueAccessor=b.field,(null==x?void 0:x.field)&&(L.categoryAccessor=x.field),(null===(r=b.axis)||void 0===r?void 0:r.title)&&(L.valueLabel=b.axis.title)):(null==x?void 0:x.bin)&&(L.valueAccessor=x.field,(null==b?void 0:b.field)&&(L.categoryAccessor=b.field),(null===(i=x.axis)||void 0===i?void 0:i.title)&&(L.valueLabel=x.axis.title));const t="object"==typeof((null==b?void 0:b.bin)||(null==x?void 0:x.bin))?(null===(a=null==b?void 0:b.bin)||void 0===a?void 0:a.maxbins)||(null===(s=null==x?void 0:x.bin)||void 0===s?void 0:s.maxbins):void 0;return t&&(L.bins=t),Zr(e,L,y)}let j;switch(p){case"bar":j=function(e,t,n,o,r,i,a){var s,l,c,u,d,h;let g;return(null==n?void 0:n.field)&&!1!==(null==e?void 0:e.stack)&&!1!==(null==t?void 0:t.stack)&&null!==(null==e?void 0:e.stack)&&null!==(null==t?void 0:t.stack)?(g="StackedBarChart",o.stackBy=n.field):g="BarChart",Yr(null==e?void 0:e.type)&&Gr(null==t?void 0:t.type)?(o.categoryAccessor=e.field,o.valueAccessor=a?"value":t.field,(null===(s=null==e?void 0:e.axis)||void 0===s?void 0:s.title)&&(o.categoryLabel=e.axis.title),(null===(l=null==t?void 0:t.axis)||void 0===l?void 0:l.title)&&(o.valueLabel=t.axis.title)):Gr(null==e?void 0:e.type)&&Yr(null==t?void 0:t.type)?(o.categoryAccessor=t.field,o.valueAccessor=i?"value":e.field,o.orientation="horizontal",(null===(c=null==t?void 0:t.axis)||void 0===c?void 0:c.title)&&(o.categoryLabel=t.axis.title),(null===(u=null==e?void 0:e.axis)||void 0===u?void 0:u.title)&&(o.valueLabel=e.axis.title)):((null==e?void 0:e.field)&&(o.categoryAccessor=e.field),(null==t?void 0:t.field)&&(o.valueAccessor=a?"value":t.field),(null===(d=null==e?void 0:e.axis)||void 0===d?void 0:d.title)&&(o.categoryLabel=e.axis.title),(null===(h=null==t?void 0:t.axis)||void 0===h?void 0:h.title)&&(o.valueLabel=t.axis.title)),r&&(o.data=r),g}(b,x,k,L,S,M,C);break;case"line":if(j="LineChart",Ur(b,x,L,M,C),(null==k?void 0:k.field)&&(L.lineBy=k.field),m.interpolate){const e=Xr[m.interpolate];e&&(L.curve=e)}!0===m.point&&(L.showPoints=!0),S&&(L.data=S);break;case"area":if((null==k?void 0:k.field)?(j="StackedAreaChart",L.areaBy=k.field):j="AreaChart",Ur(b,x,L,M,C),m.interpolate){const e=Xr[m.interpolate];e&&(L.curve=e)}void 0!==m.opacity&&(L.areaOpacity=m.opacity),S&&(L.data=S);break;case"point":case"circle":case"square":(null==w?void 0:w.field)?(j="BubbleChart",L.sizeBy=w.field,(null===(l=w.scale)||void 0===l?void 0:l.range)&&(L.sizeRange=w.scale.range)):j="Scatterplot",Ur(b,x,L,M,C),S&&(L.data=S);break;case"rect":j="Heatmap",(null==b?void 0:b.field)&&(L.xAccessor=b.field),(null==x?void 0:x.field)&&(L.yAccessor=x.field),(null==k?void 0:k.field)&&(L.valueAccessor=k.field,delete L.colorBy),(null===(c=null==b?void 0:b.axis)||void 0===c?void 0:c.title)&&(L.xLabel=b.axis.title),(null===(u=null==x?void 0:x.axis)||void 0===u?void 0:u.title)&&(L.yLabel=x.axis.title),S&&(L.data=S);break;case"arc":m.innerRadius&&m.innerRadius>0?(j="DonutChart",L.innerRadius=m.innerRadius):j="PieChart",(null==A?void 0:A.field)?L.valueAccessor=A.field:(null==x?void 0:x.field)&&(L.valueAccessor=C?"value":x.field),(null==k?void 0:k.field)&&(L.categoryAccessor=k.field),(null==b?void 0:b.field)&&!(null==A?void 0:A.field)&&(L.categoryAccessor=b.field),S&&(L.data=S);break;case"tick":j="DotPlot",Yr(null==b?void 0:b.type)?(L.categoryAccessor=b.field,(null==x?void 0:x.field)&&(L.valueAccessor=C?"value":x.field),(null===(d=null==b?void 0:b.axis)||void 0===d?void 0:d.title)&&(L.categoryLabel=b.axis.title),(null===(h=null==x?void 0:x.axis)||void 0===h?void 0:h.title)&&(L.valueLabel=x.axis.title)):Yr(null==x?void 0:x.type)?(L.categoryAccessor=x.field,(null==b?void 0:b.field)&&(L.valueAccessor=M?"value":b.field),L.orientation="horizontal",(null===(g=null==x?void 0:x.axis)||void 0===g?void 0:g.title)&&(L.categoryLabel=x.axis.title),(null===(f=null==b?void 0:b.axis)||void 0===f?void 0:f.title)&&(L.valueLabel=b.axis.title)):((null==b?void 0:b.field)&&(L.categoryAccessor=b.field),(null==x?void 0:x.field)&&(L.valueAccessor=C?"value":x.field)),S&&(L.data=S);break;default:y.push(`Unsupported mark type "${p}". Defaulting to Scatterplot.`),j="Scatterplot",Ur(b,x,L,M,C),S&&(L.data=S)}return Zr(j,L,y)},exports.normalizeTooltip=Mn,exports.serializeSelections=function(e){const t={};for(const[n,o]of e){const e=[];for(const[,t]of o.clauses){const n={};for(const[e,o]of Object.entries(t.fields))n[e]="point"===o.type?{type:"point",values:Array.from(o.values)}:{type:"interval",range:o.range};e.push({clientId:t.clientId,type:t.type,fields:n})}t[n]={name:o.name,resolution:o.resolution,clauses:e}}return t},exports.smartTickFormat=function(e){if(null==e)return"";if("number"!=typeof e)return e+"";if(!isFinite(e))return e+"";if(0===e)return"0";const t=parseFloat(e.toPrecision(12)),n=Math.abs(t);return 1e9>n?1e6>n?1e4>n?Number.isInteger(t)?t+"":parseFloat(t.toPrecision(6))+"":parseFloat((t/1e3).toPrecision(3))+"K":parseFloat((t/1e6).toPrecision(3))+"M":parseFloat((t/1e9).toPrecision(3))+"B"},exports.toConfig=function(e,t,n){if(!Ir[e])throw Error(`Unknown component "${e}". Known components: ${Object.keys(Ir).join(", ")}`);const o=!1!==(null==n?void 0:n.includeData),r={};for(const[e,n]of Object.entries(t))null!=n&&(Rr.has(e)||!o&&$r.has(e)||"function"!=typeof n&&((null==n?void 0:n.$$typeof)||(r[e]=zr(n))));return Object.assign({component:e,props:r,version:"1",createdAt:(new Date).toISOString()},(null==n?void 0:n.selections)?{selections:n.selections}:{})},exports.toURL=function(e){const t=JSON.stringify(e);return"sc="+btoa(unescape(encodeURIComponent(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},exports.useBrushSelection=Un,exports.useCategoryColors=Wn,exports.useChartObserver=Zn,exports.useFilteredData=function(t,n,o){const r=Yn(e=>e.selections.get(n));return e.useMemo(()=>{if(!r||0===r.clauses.size)return t;const e=zn(r,o);return t.filter(e)},[t,r,o])},exports.useLinkedHover=Vn,exports.useSelection=Xn,exports.useTheme=function(){return Lr(e=>e.theme)};
|