semiotic 3.0.1 → 3.1.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 +227 -27
- package/README.md +147 -11
- package/ai/dist/componentRegistry.js +5 -0
- package/ai/dist/mcp-server.js +305 -30
- package/ai/examples.md +358 -18
- package/ai/schema.json +64 -2
- package/ai/system-prompt.md +50 -12
- package/dist/components/Legend.d.ts +7 -1
- package/dist/components/charts/geo/ChoroplethMap.d.ts +53 -0
- package/dist/components/charts/geo/DistanceCartogram.d.ts +90 -0
- package/dist/components/charts/geo/FlowMap.d.ts +83 -0
- package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +67 -0
- package/dist/components/charts/geo/index.d.ts +8 -0
- package/dist/components/charts/index.d.ts +2 -0
- package/dist/components/charts/network/ChordDiagram.d.ts +6 -5
- package/dist/components/charts/network/CirclePack.d.ts +2 -2
- package/dist/components/charts/network/ForceDirectedGraph.d.ts +9 -7
- package/dist/components/charts/network/OrbitDiagram.d.ts +21 -20
- package/dist/components/charts/network/SankeyDiagram.d.ts +6 -5
- package/dist/components/charts/network/TreeDiagram.d.ts +2 -2
- package/dist/components/charts/network/Treemap.d.ts +2 -2
- package/dist/components/charts/ordinal/BarChart.d.ts +7 -5
- package/dist/components/charts/ordinal/BoxPlot.d.ts +8 -6
- package/dist/components/charts/ordinal/DonutChart.d.ts +8 -6
- package/dist/components/charts/ordinal/DotPlot.d.ts +8 -6
- package/dist/components/charts/ordinal/GroupedBarChart.d.ts +7 -5
- package/dist/components/charts/ordinal/Histogram.d.ts +8 -5
- package/dist/components/charts/ordinal/PieChart.d.ts +8 -6
- package/dist/components/charts/ordinal/RidgelinePlot.d.ts +2 -0
- package/dist/components/charts/ordinal/StackedBarChart.d.ts +7 -5
- package/dist/components/charts/ordinal/SwarmPlot.d.ts +8 -6
- package/dist/components/charts/ordinal/ViolinPlot.d.ts +8 -5
- package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +24 -6
- package/dist/components/charts/realtime/RealtimeHistogram.d.ts +28 -7
- package/dist/components/charts/realtime/RealtimeLineChart.d.ts +23 -5
- package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +24 -6
- package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +23 -5
- package/dist/components/charts/shared/ChartError.d.ts +3 -1
- package/dist/components/charts/shared/colorUtils.d.ts +5 -0
- package/dist/components/charts/shared/hooks.d.ts +13 -1
- package/dist/components/charts/shared/legendUtils.d.ts +2 -3
- package/dist/components/charts/shared/statisticalOverlays.d.ts +1 -2
- package/dist/components/charts/shared/statisticalOverlaysLazy.d.ts +10 -0
- package/dist/components/charts/shared/tooltipUtils.d.ts +1 -1
- package/dist/components/charts/shared/types.d.ts +10 -4
- package/dist/components/charts/shared/useChartSetup.d.ts +112 -0
- package/dist/components/charts/shared/useStreamingLegend.d.ts +65 -0
- package/dist/components/charts/shared/withChartWrapper.d.ts +4 -3
- package/dist/components/charts/xy/AreaChart.d.ts +11 -6
- package/dist/components/charts/xy/BubbleChart.d.ts +11 -6
- package/dist/components/charts/xy/ConnectedScatterplot.d.ts +7 -6
- package/dist/components/charts/xy/Heatmap.d.ts +16 -5
- package/dist/components/charts/xy/LineChart.d.ts +21 -5
- package/dist/components/charts/xy/MinimapChart.d.ts +3 -0
- package/dist/components/charts/xy/QuadrantChart.d.ts +120 -0
- package/dist/components/charts/xy/Scatterplot.d.ts +9 -6
- package/dist/components/charts/xy/StackedAreaChart.d.ts +11 -6
- package/dist/components/geo/mergeData.d.ts +18 -0
- package/dist/components/geo/referenceGeography.d.ts +10 -0
- package/dist/components/geo/useReferenceAreas.d.ts +13 -0
- package/dist/components/realtime/RingBuffer.d.ts +1 -0
- package/dist/components/realtime/types.d.ts +17 -0
- package/dist/components/semiotic-data.d.ts +1 -0
- package/dist/components/semiotic-geo.d.ts +16 -0
- package/dist/components/semiotic-server.d.ts +1 -1
- package/dist/components/semiotic-xy.d.ts +1 -0
- package/dist/components/semiotic.d.ts +4 -4
- package/dist/components/server/renderToStaticSVG.d.ts +4 -2
- package/dist/components/stream/AccessibleDataTable.d.ts +50 -0
- package/dist/components/stream/CanvasHitTester.d.ts +8 -2
- package/dist/components/stream/DataSourceAdapter.d.ts +33 -4
- package/dist/components/stream/GeoCanvasHitTester.d.ts +19 -0
- package/dist/components/stream/GeoParticlePool.d.ts +46 -0
- package/dist/components/stream/GeoPipelineStore.d.ts +81 -0
- package/dist/components/stream/GeoTileRenderer.d.ts +31 -0
- package/dist/components/stream/NetworkPipelineStore.d.ts +16 -4
- package/dist/components/stream/NetworkSVGOverlay.d.ts +4 -1
- package/dist/components/stream/OrdinalPipelineStore.d.ts +8 -4
- package/dist/components/stream/OrdinalSVGOverlay.d.ts +23 -1
- package/dist/components/stream/PipelineStore.d.ts +57 -5
- package/dist/components/stream/SVGOverlay.d.ts +28 -1
- package/dist/components/stream/SceneGraph.d.ts +7 -3
- package/dist/components/stream/SceneToSVG.d.ts +2 -0
- package/dist/components/stream/StreamGeoFrame.d.ts +4 -0
- package/dist/components/stream/accessorUtils.d.ts +1 -0
- package/dist/components/stream/canvasSetup.d.ts +26 -0
- package/dist/components/stream/geoTypes.d.ts +186 -0
- package/dist/components/stream/layouts/forceLayoutPlugin.d.ts +0 -7
- package/dist/components/stream/layouts/index.d.ts +2 -1
- package/dist/components/stream/layouts/orbitLayoutPlugin.d.ts +2 -0
- package/dist/components/stream/legendRenderer.d.ts +33 -0
- package/dist/components/stream/networkTypes.d.ts +49 -1
- package/dist/components/stream/ordinalTypes.d.ts +10 -0
- package/dist/components/stream/pipelineTransitionUtils.d.ts +42 -0
- package/dist/components/stream/renderers/geoCanvasRenderer.d.ts +9 -0
- package/dist/components/stream/renderers/heatmapCanvasRenderer.d.ts +2 -1
- package/dist/components/stream/renderers/lineCanvasRenderer.d.ts +1 -0
- package/dist/components/stream/renderers/renderPulse.d.ts +50 -0
- package/dist/components/stream/types.d.ts +77 -3
- package/dist/components/types/legendTypes.d.ts +27 -3
- package/dist/geo.min.js +1 -0
- package/dist/geo.module.min.js +1 -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-statisticalOverlays-C1f7TYyD.js +1 -0
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-data.d.ts +1 -0
- package/dist/semiotic-data.min.js +1 -1
- package/dist/semiotic-data.module.min.js +1 -1
- package/dist/semiotic-geo.d.ts +16 -0
- package/dist/semiotic-server.d.ts +1 -1
- package/dist/semiotic-statisticalOverlays-C1f7TYyD.js +1 -0
- package/dist/semiotic-xy.d.ts +1 -0
- package/dist/semiotic.d.ts +4 -4
- 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-utils/canvasMock.d.ts +3 -0
- package/dist/xy-statisticalOverlays-C1f7TYyD.js +1 -0
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +76 -8
- package/dist/test/canvasMock.d.ts +0 -2
package/dist/semiotic-ai.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("regression"),s=require("d3-shape"),l=require("d3-scale-chromatic"),c=require("d3-interpolate"),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 S(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 E(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(E(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(E(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(S(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(S(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(S(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 D(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=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 _(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 z={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,z[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,S,E,L,O,M,C,j,P,H,N,D,B,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!==(S=e.fillOpacity)&&void 0!==S?S:.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===(E=n.scales)||void 0===E?void 0:E.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!==(B=null===(D=n.scales)||void 0===D?void 0:D.x)&&void 0!==B?B: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!==(_=e.steps)&&void 0!==_?_: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 S=`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`,E=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:S,fill:e.fill||"#6366f1",fillOpacity:null!==(z=e.fillOpacity)&&void 0!==z?z:.15,stroke:"none"}),f.createElement("polyline",{points:`${L} ${E}`,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:S,yValues:E,annotations:L,svgAnnotationRules:O,annotationFrame:M,xAccessor:C,yAccessor:j,annotationData:P,pointNodes:H,children:N}=t,D=e.useMemo(()=>l&&s?s.x.ticks(5).map(e=>({value:e,pixel:s.x(e),label:(h||re)(e)})):[],[l,s,h]),B=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"},D.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})),B.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}),D.map((e,t)=>{const n=!!l&&("function"==typeof l?l(e.value,t):ie(e.value,t>0?D[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}),B.map((e,t)=>{const n=!!h&&("function"==typeof h?h(e.value,t):ie(e.value,t>0?B[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&&S&&E&&f.createElement(f.Fragment,null,A.top&&f.createElement("g",{transform:"translate(0, 0)"},f.createElement(V,{orient:"top",config:X(A.top),values:S,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:S,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:E,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:E,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 S=A.value;(h>S||S>x)&&(S>h||x>S)||h===S||x===S||w.push({t:(S-h)/(x-h)})}w.sort((e,t)=>e.t-t.t);for(const E of w){const L=u+(v-u)*E.t,O=d+(b-d)*E.t,M=le(h+(x-h)*Math.min(E.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 B=1;i.path.length>B;B++)e.lineTo(i.path[B][0],i.path[B][1]);const D=i.path[0][0];e.lineTo(i.path[i.path.length-1][0],o.height),e.lineTo(D,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:S=200,timeAccessor:E,xExtent:L,yExtent:O,extentPadding:C=.1,sizeRange:j,size:T=[500,300],responsiveWidth:z,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:Se,tooltipContent:Ee,customHoverBehavior:Le,enableHover:Oe,annotations:Me,svgAnnotationRules:Ce,showGrid:je,legend:Pe,legendHoverBehavior:He,legendClickBehavior:Ne,legendHighlightedCategory:De,legendIsolatedCategories:Be,backgroundGraphics:We,foregroundGraphics:Te,title:Ie,categoryAccessor:Re,brush:$e,onBrush:_e,decay:ze,pulse:Fe,transition:Ye,staleness:Ge,heatmapAggregation:qe,heatmapXBins:Xe,heatmapYBins:Ve,marginalGraphics:Ue,pointIdAccessor:Ze}=t,[Qe,Ke]=$(T,z,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!=Se?Se: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:S,windowMode:A,arrowOfTime:wt?w:"right",extentPadding:C,xAccessor:wt?void 0:d,yAccessor:wt?void 0:h,timeAccessor:wt?E: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:ze,pulse:Fe,transition:Ye,staleness:Ge,heatmapAggregation:qe,heatmapXBins:Xe,heatmapYBins:Ve,pointIdAccessor:Ze}),[l,S,A,w,C,d,h,E,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,ze,Fe,Ye,Ge,qe,Xe,Ve,wt,Ze]),St=e.useRef(null);St.current||(St.current=new M(At));const Et=e.useCallback(()=>{it.current||(it.current=requestAnimationFrame(()=>kt.current()))},[]);e.useEffect(()=>{var e;null===(e=St.current)||void 0===e||e.updateConfig(At),at.current=!0,Et()},[At,Et]);const Lt=e.useRef(null);Lt.current||(Lt.current=new m(e=>{const t=St.current;t&&t.ingest(e)&&(at.current=!0,Et())}));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=St.current)||void 0===t||t.clear(),at.current=!0,Et()},[Et]);e.useImperativeHandle(n,()=>({push:Ot,pushMany:Mt,clear:Ct,getData:()=>{var e,t;return null!==(t=null===(e=St.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=St.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=St.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),Et()));const i=St.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=D(i,t,n);break;case"area":if(!1===i.interactive)break;e=W(i,t,n);break;case"candlestick":e=B(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),Et()));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),Et()},Pt.current=()=>{dt.current&&(dt.current=null,ht.current=null,ft(null),Le&&(Le(null),at.current=!0),Et())},e.useCallback(e=>jt.current(e),[]);const Ht=e.useCallback(()=>Pt.current(),[]),Nt=e.useRef(-1),Dt=e.useCallback(e=>{const t=St.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 Et();const i=0>o?0:r;Nt.current=i;const a=R(n[i]);dt.current=a,ft(a),Le&&Le(a),Et()},[Le,Et]),Bt=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=St.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(Se))){const t=Se.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(()=>(Et(),()=>{it.current&&(cancelAnimationFrame(it.current),it.current=0)}),[Et]),e.useEffect(()=>{at.current=!0,Et()},[l,et,tt,de,q,X,Et]),_(Ge,St,at,Et,yt,pt);const Wt=nt&>?Ee?Ee(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=St.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:De,legendIsolatedCategories:Be,foregroundGraphics:Te,marginalGraphics:Ue,xValues:[],yValues:[],annotations:Me,svgAnnotationRules:Ce,annotationFrame:0,xAccessor:"string"==typeof d?d:"string"==typeof E?E: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:z?"100%":Ke[0],height:F?"100%":Ke[1]},onMouseMove:nt?Bt:void 0,onMouseLeave:nt?Ht:void 0,onKeyDown:Dt},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:De,legendIsolatedCategories:Be,foregroundGraphics:Te,marginalGraphics:Ue,xValues:mt,yValues:bt,annotations:Me,svgAnnotationRules:Ce,annotationFrame:st,xAccessor:"string"==typeof d?d:"string"==typeof E?E:void 0,yAccessor:"string"==typeof h?h:"string"==typeof k?k:void 0,annotationData:null===(i=St.current)||void 0===i?void 0:i.getData(),pointNodes:null===(a=St.current)||void 0===a?void 0:a.scene.filter(e=>"point"===e.type)}),($e||_e)&&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!=_e?_e:()=>{}}),(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)});ke.displayName="StreamXYFrame";const we={category10:l.schemeCategory10,tableau10:l.schemeTableau10,set3:l.schemeSet3,blues:l.interpolateBlues,reds:l.interpolateReds,greens:l.interpolateGreens,oranges:l.interpolateOranges,purples:l.interpolatePurples,viridis:l.interpolateViridis,plasma:l.interpolatePlasma},Ae=l.schemeCategory10,Se=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"];function Ee(e,t,n){if("function"==typeof t)return t(e);const o=e[t];return n?n(o):Ae[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+""))%Ae.length]}function Le(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=we[n]||we.category10;if(i&&"function"==typeof a)return e=>a(Number(e)/Math.max(...r.map(Number)));{const e=Array.isArray(a)?a:Ae;return o.scaleOrdinal().domain(r).range(e).unknown("#999")}}function Oe(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 Me=e.createContext(null);function Ce({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:we[o]||Ae,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(Me.Provider,{value:i},r)}function je(){return e.useContext(Me)}Ce.displayName="CategoryColorProvider";const Pe="undefined"!=typeof window?e.useLayoutEffect:e.useEffect;function He(t){const n=e.createContext(null),o=Ne(t);return[function({children:o}){const r=e.useMemo(()=>Ne(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 Pe(()=>t(()=>r(n)),[t]),o}(i.subscribe,()=>t(i.getState()))}]}function Ne(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 De(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 Be(e,t){const n=[];for(const[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(De(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}function We(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[Te,Ie]=He(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),r=We(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=We(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}})}})),[Re,$e]=He(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 _e(t){const n=e.useId(),o=t.clientId||n,{name:r}=t,i=Ie(e=>e.selections.get(r)),a=Ie(e=>e.setClause),s=Ie(e=>e.clearClause),l=e.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:e.useMemo(()=>i&&0!==i.clauses.size?Be(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 ze(t){const n=t.name||"hover",{fields:o}=t,{predicate:r,isActive:i,selectPoints:a,clear:s}=_e({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 Fe(t){const{name:n,xField:o,yField:r}=t,{predicate:i,isActive:a,selectInterval:s,clear:l}=_e({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 Ye(t={}){const{limit:n=50,types:o,chartId:r}=t,i=$e(e=>e.version),a=$e(e=>e.observations),s=$e(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 Ge=e.createContext(!1);function qe({selections:t}){const n=Ie(e=>e.setResolution);return e.useEffect(()=>{for(const[e,o]of Object.entries(t))o.resolution&&n(e,o.resolution)},[t,n]),null}function Xe({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=ze({name:o,fields:[r]}),c=_e({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 Ve({children:e,selections:t,showLegend:n,legendPosition:o="top",legendInteraction:r="none",legendSelectionName:i="legend",legendField:a="category"}){const s=je(),l=void 0!==n?n:!(!s||0>=Object.keys(s).length);return f.createElement(Te,null,f.createElement(Re,null,t&&f.createElement(qe,{selections:t}),f.createElement(Ge.Provider,{value:l},l&&"top"===o&&s&&f.createElement(Xe,{categoryColors:s,interaction:r,selectionName:i,field:a}),e,l&&"bottom"===o&&s&&f.createElement(Xe,{categoryColors:s,interaction:r,selectionName:i,field:a}))))}function Ue(e){return e?"string"==typeof e?{name:e}:e:null}function Ze(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 Qe="#007bff";function Ke(e){return"function"==typeof e?e:t=>t[e]}function Je(t,n,o="category10"){const r=je();return e.useMemo(()=>{if(n&&"function"!=typeof n)return r&&Object.keys(r).length>0?e=>r[e]||Le(t,n,o)(e):Le(t,n,o)},[t,n,o,r])}function et(t,n,o){return e.useMemo(()=>{if(!n)return t;const e=[...t];if("function"==typeof n)return e.sort(n);const r=Ke(o);return e.sort("asc"===n?(e,t)=>r(e)-r(t):(e,t)=>r(t)-r(e))},[t,n,o])}function tt({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=_e({name:(null==t?void 0:t.name)||"__unused__"}),u=ze({name:(null==l?void 0:l.name)||"hover",fields:(null==l?void 0:l.fields)||o||[]}),d=$e(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 nt({data:t,colorBy:n,colorScale:o,showLegend:r,userMargin:i,defaults:a={top:50,bottom:60,left:70,right:40}}){const s=e.useContext(Ge),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:Ee})},[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 ot(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 rt={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 it(e,t,n){var o,r,i,a,s,l;const c=rt[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}}const at={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 st(e,t){return"function"==typeof t?t(e):e[t]}function lt(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 ct(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=st(e,n);a=lt(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=st(e,r);s.push({label:n,value:lt(a,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){a=lt(e[n],o);break}if(!a){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(a=lt(e[t[0]],o))}}const l=Object.assign(Object.assign({},at),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 ut(e){return!0===e?ct():"function"==typeof e?e:!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?ct(e):ct())}function dt(e){return"string"==typeof e?e:"value"}function ht(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function gt(e,t){return"function"==typeof t?t(e):e[t]}function ft(e){return t=>{const n=t.data;return n?f.createElement("div",{className:"semiotic-tooltip",style:at},e.map((e,t)=>{const o=ht(gt(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 yt({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=gt(s,e),c=gt(s,t),u=n?gt(s,n):void 0;return f.createElement("div",{className:"semiotic-tooltip",style:at},f.createElement("div",{style:{fontWeight:"bold"}},ht(l)),f.createElement("div",{style:{marginTop:4}},ht(c)),null!=u&&f.createElement("div",{style:{marginTop:2,opacity:.8}},o||dt(n),": ",ht(u)))}}function pt({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 mt 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(pt,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}var vt;const bt="undefined"!=typeof process&&"production"!==(null===(vt=process.env)||void 0===vt?void 0:vt.NODE_ENV);function xt({componentName:e,width:t,height:n,children:o}){return f.createElement(mt,{fallback:o=>f.createElement(pt,{componentName:e,message:o.message,width:t,height:n})},o)}const kt={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"},wt={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function At(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({},kt),{width:t,height:n})},o||"No data available")}function St(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({},wt),{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 Et(e,t,n,o){if(!bt)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 Lt(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 Ot(e,t,n=3){let o,r=n+1;for(const n of t){const t=Lt(e.toLowerCase(),n.toLowerCase());r>t&&(r=t,o=n)}return r>n?void 0:o}function Mt(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function Ct(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=Ot(e,t,3))&&void 0!==n?n:null)}function jt({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=Mt(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=Ct(i,t),o=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}function Pt({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 Ht({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=Mt(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=Ct(r,t),i=n?` Try ${o}="${n}".`:"";return`${e}: ${o} "${r}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}return null}const Nt="__forecastSegment";function Dt(e,t){return"function"==typeof t?t(e):!!e[t]}function Bt(t){var n,o;const r=it(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:S,annotations:E,directLabel:L,gapStrategy:O="break",anomaly:M,forecast:C,frameProps:j={},selection:P,linkedHover:H,onObservation:N,chartId:D,loading:B,emptyContent:W,legendInteraction:T}=t,I=r.width,R=r.height,$=r.enableHover,_=r.showGrid,z=r.showLegend,F=r.title,Y=r.xLabel,G=r.yLabel,q=St(B,I,R);if(q)return q;const X=At(i,I,R,W);if(X)return X;const V=i||[];Et("LineChart",V,"xAccessor",u),Et("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&&Dt(e,c)?t="forecast":l&&Dt(e,l)&&(t="training"),Object.assign(Object.assign({},e),{[Nt]:t})}),b=[];for(let e=0;v.length>e;e++)b.push(v[e]),v.length-1>e&&v[e][Nt]!==v[e+1][Nt]&&b.push(Object.assign(Object.assign({},v[e]),{[Nt]:v[e+1][Nt]}));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=>Dt(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),{[Nt]:"observed"})):f.push(Object.assign(Object.assign({},n),{[Nt]:"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,S=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),E=Math.max(...S),L=p.length>1?(p[o-1][0]-p[0][0])/(o-1):1;for(let e=1;c>=e;e++){const r=E+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,[Nt]:"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]),{[Nt]:"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),{[Nt]:"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?Nt:h,{activeSelectionHook:te,customHoverBehavior:ne}=tt({selection:P,linkedHover:H,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:N,chartType:"LineChart",chartId:D}),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=Je(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=ot(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?Ee(e,y,le):Qe,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[Nt];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(()=>Ze(ge,de,P),[ge,de,P]),ye=e.useMemo(()=>{if(v)return e=>{const t={r:b,fillOpacity:1};return t.fill=y?Ee(e.parentLine||e,y,le):Qe,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):Qe,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!==z)&&z,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:Se,margin:Le}=nt({data:ae,colorBy:y,colorScale:le,showLegend:we,userMargin:a,defaults:Ae}),Oe=h||y,Me=e.useMemo(()=>ft([{label:Y||dt(u),accessor:u,role:"x"},{label:G||dt(d),accessor:d,role:"y"},...Oe?[{label:dt(Oe),accessor:Oe,role:"group"}]:[]]),[u,d,Y,G,Oe]),Ce=jt({componentName:"LineChart",data:re?(null===(o=J[0])||void 0===o?void 0:o[g])||[]:V,accessors:{xAccessor:u,yAccessor:d}});if(Ce)return f.createElement(pt,{componentName:"LineChart",message:Ce,width:I,height:R});const je=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]),Pe=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:je,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:Le,showAxes:r.showAxes,xLabel:Y,yLabel:G,xFormat:l,yFormat:c,enableHover:$,showGrid:_}),Se&&{legend:Se}),T&&"none"!==T&&{legendHoverBehavior:ue.onLegendHover,legendClickBehavior:ue.onLegendClick,legendHighlightedCategory:ue.highlightedCategory,legendIsolatedCategories:ue.isolatedCategories}),F&&{title:F}),s&&{className:s}),{tooltipContent:ut(A)||Me}),(H||N)&&{customHoverBehavior:ne}),S&&{pointIdAccessor:S}),((null==E?void 0:E.length)||K.length||xe.length)&&{annotations:[...E||[],...K,...xe]}),j);return f.createElement(xt,{componentName:"LineChart",width:I,height:R},f.createElement(ke,Object.assign({},Pe)))}function Wt(t){var n;const o=it(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:S={},selection:E,linkedHover:L,onObservation:O,chartId:M,loading:C,emptyContent:j,legendInteraction:P}=t,H=o.width,N=o.height,D=o.enableHover,B=o.showGrid,W=o.showLegend,T=o.title,I=o.xLabel,R=o.yLabel,$=St(C,H,N);if($)return $;const _=At(r,H,N,j);if(_)return _;const z=r||[];Et("AreaChart",z,"xAccessor",c),Et("AreaChart",z,"yAccessor",u);const{activeSelectionHook:F,customHoverBehavior:Y}=tt({selection:E,linkedHover:L,fallbackFields:p?["string"==typeof p?p:""]:[],onObservation:O,chartType:"AreaChart",chartId:M}),G=void 0!==(null===(n=z[0])||void 0===n?void 0:n[y]),q=e.useMemo(()=>{if(G)return z;if(d){const e=z.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]:z}]},[z,d,y,G]),X=Je(z,p,m),V=e.useMemo(()=>{if(!p)return[];const e=new Set;for(const t of z){const n="function"==typeof p?p(t):t[p];null!=n&&e.add(n+"")}return Array.from(e)},[z,p]),U=ot(P,p,V),Z=e.useMemo(()=>U.legendSelectionHook?U.legendSelectionHook:F,[U.legendSelectionHook,F]),Q=e.useMemo(()=>e=>{const t={},n=p?Ee(e,p,X):Qe;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(()=>Ze(Q,Z,E),[Q,Z,E]),{legend:J,margin:ee}=nt({data:q,colorBy:p,colorScale:X,showLegend:W,userMargin:i,defaults:o.marginDefaults}),te=d||p,ne=e.useMemo(()=>ft([{label:I||dt(c),accessor:c,role:"x"},{label:R||dt(u),accessor:u,role:"y"},...te?[{label:dt(te),accessor:te,role:"group"}]:[]]),[c,u,I,R,te]),oe=jt({componentName:"AreaChart",data:z,accessors:{xAccessor:c,yAccessor:u}});if(oe)return f.createElement(pt,{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}):z,[q,y,G,d,z]),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:D,showGrid:B}),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:ut(w)||ne}),(L||O)&&{customHoverBehavior:Y}),A&&A.length>0&&{annotations:A}),S);return f.createElement(xt,{componentName:"AreaChart",width:H,height:N},f.createElement(ke,Object.assign({},ie)))}function Tt(t){var n;const o=it(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:S,linkedHover:E,onObservation:L,chartId:O,loading:M,emptyContent:C,legendInteraction:j}=t,P=o.width,H=o.height,N=o.enableHover,D=o.showGrid,B=o.showLegend,W=o.title,T=o.xLabel,I=o.yLabel,R=St(M,P,H);if(R)return R;const $=At(r,P,H,C);if($)return $;const _=r||[],{activeSelectionHook:z,customHoverBehavior:F}=tt({selection:S,linkedHover:E,fallbackFields:g?["string"==typeof g?g:""]:[],onObservation:L,chartType:"StackedAreaChart",chartId:O}),Y=void 0!==(null===(n=_[0])||void 0===n?void 0:n[h]),G=e.useMemo(()=>{if(Y)return _;if(d){const e=_.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]:_}]},[_,d,h,Y]),q=Je(_,g,y),X=e.useMemo(()=>{if(!g)return[];const e=new Set;for(const t of _){const n="function"==typeof g?g(t):t[g];null!=n&&e.add(n+"")}return Array.from(e)},[_,g]),V=ot(j,g,X),U=e.useMemo(()=>V.legendSelectionHook?V.legendSelectionHook:z,[V.legendSelectionHook,z]),Z=e.useMemo(()=>e=>{const t={},n=g?Ee(e,g,q):Qe;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(()=>Ze(Z,U,S),[Z,U,S]),{legend:K,margin:J}=nt({data:G,colorBy:g,colorScale:q,showLegend:B,userMargin:i,defaults:o.marginDefaults}),ee=d||g,te=e.useMemo(()=>ft([{label:T||dt(c),accessor:c,role:"x"},{label:I||dt(u),accessor:u,role:"y"},...ee?[{label:dt(ee),accessor:ee,role:"group"}]:[]]),[c,u,T,I,ee]),ne=jt({componentName:"StackedAreaChart",data:_,accessors:{xAccessor:c,yAccessor:u}});if(ne)return f.createElement(pt,{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}):_,[G,h,Y,d,_]),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:D},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:ut(k)||te}),(E||L)&&{customHoverBehavior:F}),w&&w.length>0&&{annotations:w}),A);return f.createElement(xt,{componentName:"StackedAreaChart",width:P,height:H},f.createElement(ke,Object.assign({},re)))}function It(t){const n=it(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:S,onObservation:E,chartId:L,loading:O,emptyContent:M,legendInteraction:C}=t,j=n.width,P=n.height,H=n.enableHover,N=n.showGrid,D=n.showLegend,B=n.title,W=n.xLabel,T=n.yLabel,I=St(O,j,P);if(I)return I;const R=At(o,j,P,M);if(R)return R;const $=o||[];Et("Scatterplot",$,"xAccessor",l),Et("Scatterplot",$,"yAccessor",c);const{activeSelectionHook:_,customHoverBehavior:z}=tt({selection:w,linkedHover:A,fallbackFields:u?["string"==typeof u?u:""]:[],onObservation:E,chartType:"Scatterplot",chartId:L}),F=Ue(S),Y=Fe({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=Je($,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=ot(C,u,U),Q=e.useMemo(()=>Z.legendSelectionHook?Z.legendSelectionHook:_,[Z.legendSelectionHook,_]),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?Ee(e,u,V):Qe,t.r=h?Oe(e,h,g,K):y,t},[u,V,h,g,K,y,p]),ee=e.useMemo(()=>Ze(J,Q,w),[J,Q,w]),{legend:te,margin:ne}=nt({data:$,colorBy:u,colorScale:V,showLegend:D,userMargin:r,defaults:n.marginDefaults}),oe=e.useMemo(()=>ft([{label:W||dt(l),accessor:l,role:"x"},{label:T||dt(c),accessor:c,role:"y"},...u?[{label:dt(u),accessor:u,role:"color"}]:[],...h?[{label:dt(h),accessor:h,role:"size"}]:[]]),[l,c,W,T,u,h]),re=jt({componentName:"Scatterplot",data:$,accessors:{xAccessor:l,yAccessor:c}});if(re)return f.createElement(pt,{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}),B&&{title:B}),i&&{className:i}),{tooltipContent:ut(m)||oe}),(A||E)&&{customHoverBehavior:z}),v&&{marginalGraphics:v}),b&&{pointIdAccessor:b}),x&&x.length>0&&{annotations:x}),F&&{brush:{dimension:G},onBrush:X}),k);return f.createElement(xt,{componentName:"Scatterplot",width:j,height:P},f.createElement(ke,Object.assign({},ie)))}function Rt(t){const n=it(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:c="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:S}=t,E=n.width,L=n.height,O=n.enableHover,M=n.showGrid,C=n.title,j=n.xLabel,P=n.yLabel,H=St(w,E,L);if(H)return H;const N=At(o,E,L,A);if(N)return N;const D=o||[],B=e.useMemo(()=>{if(!u||0===D.length)return D;const e="function"==typeof u?u:e=>e[u];return[...D].sort((t,n)=>{const o=e(t),r=e(n);return(o instanceof Date?o.getTime():+o)-(r instanceof Date?r.getTime():+r)})},[D,u]);Et("ConnectedScatterplot",B,"xAccessor",s),Et("ConnectedScatterplot",B,"yAccessor",c);const{activeSelectionHook:W,customHoverBehavior:T}=tt({selection:v,linkedHover:b,fallbackFields:[],onObservation:x,chartType:"ConnectedScatterplot",chartId:k}),I=ot(S,void 0,[]),R=e.useMemo(()=>I.legendSelectionHook?I.legendSelectionHook:W,[I.legendSelectionHook,W]),$=B.length,_=$>0&&100>$,z=e.useMemo(()=>0===$?[]:B.map((e,t)=>l.interpolateViridis(1===$?.5:t/($-1))),[B,$]);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,l=null!==(r=i.y)&&void 0!==r?r:i.value;if(!a||!l)return null;const u="string"==typeof s?e=>e[s]:s,d="string"==typeof c?e=>e[c]:c,g=[];for(let e=0;B.length-1>e;e++){const t=B[e],n=B[e+1],o=a(u(t)),r=l(d(t)),i=a(u(n)),s=l(d(n)),c=z[e];_&&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:c,strokeWidth:h,strokeLinecap:"round"}))}return f.createElement("g",{key:"ann-"+t},g)}},[B,z,h,_,s,c,$]),Y=e.useMemo(()=>e=>{const t=B.indexOf(e);return{fill:t>=0&&z.length>t?z[t]:"#6366f1",stroke:"white",strokeWidth:1,r:h,fillOpacity:1}},[B,z,h]),G=e.useMemo(()=>Ze(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(()=>ft([{label:j||dt(s),accessor:s,role:"x"},{label:P||dt(c),accessor:c,role:"y"},...u?[{label:X,accessor:u,role:"group"}]:[]]),[s,c,j,P,u,X]),U=jt({componentName:"ConnectedScatterplot",data:B,accessors:{xAccessor:s,yAccessor:c}});if(U)return f.createElement(pt,{componentName:"ConnectedScatterplot",message:U,width:E,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:B,xAccessor:s,yAccessor:c,pointStyle:G,size:[E,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:ut(g)||V}),(b||x)&&{customHoverBehavior:T}),y&&{pointIdAccessor:y}),{annotations:Z,svgAnnotationRules:F}),m);return f.createElement(xt,{componentName:"ConnectedScatterplot",width:E,height:L},f.createElement(ke,Object.assign({},Q)))}function $t(t){const n=it(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:S,linkedBrush:E,onObservation:L,chartId:O,loading:M,emptyContent:C,legendInteraction:j}=t,P=n.width,H=n.height,N=n.enableHover,D=n.showGrid,B=n.showLegend,W=n.title,T=n.xLabel,I=n.yLabel,R=St(M,P,H);if(R)return R;const $=At(o,P,H,C);if($)return $;const _=o||[],{activeSelectionHook:z,customHoverBehavior:F}=tt({selection:A,linkedHover:S,fallbackFields:h?["string"==typeof h?h:""]:[],onObservation:L,chartType:"BubbleChart",chartId:O}),Y=Ue(E);Fe({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=Je(_,h,g),q=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]),X=ot(j,h,q),V=e.useMemo(()=>X.legendSelectionHook?X.legendSelectionHook:z,[X.legendSelectionHook,z]),U=e.useMemo(()=>{const e=_.map(e=>"function"==typeof u?u(e):e[u]);return[Math.min(...e),Math.max(...e)]},[_,u]),Z=e.useMemo(()=>e=>{const t={fillOpacity:y,strokeWidth:p,stroke:m};return t.fill=h?Ee(e,h,G):Qe,t.r=Oe(e,u,d,U),t},[h,G,u,d,U,y,p,m]),Q=e.useMemo(()=>Ze(Z,V,A),[Z,V,A]),{legend:K,margin:J}=nt({data:_,colorBy:h,colorScale:G,showLegend:B,userMargin:r,defaults:n.marginDefaults}),ee=e.useMemo(()=>ft([{label:T||dt(l),accessor:l,role:"x"},{label:I||dt(c),accessor:c,role:"y"},{label:dt(u),accessor:u,role:"size"},...h?[{label:dt(h),accessor:h,role:"color"}]:[]]),[l,c,T,I,u,h]),te=jt({componentName:"BubbleChart",data:_,accessors:{xAccessor:l,yAccessor:c},requiredProps:{sizeBy:u}});if(te)return f.createElement(pt,{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:_,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:D},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:ut(v)||ee}),(S||L)&&{customHoverBehavior:F}),b&&{marginalGraphics:b}),x&&{pointIdAccessor:x}),k&&k.length>0&&{annotations:k}),w);return f.createElement(xt,{componentName:"BubbleChart",width:P,height:H},f.createElement(ke,Object.assign({},ne)))}function _t(t){const n=it(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:c="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:S,onObservation:E,chartId:L,loading:O,emptyContent:M,legendInteraction:C}=t,j=n.width,P=n.height,H=n.enableHover,N=n.title,D=n.xLabel,B=n.yLabel,W=St(O,j,P);if(W)return W;const T=At(r,j,P,M);if(T)return T;const I=r||[],{margin:R}=nt({data:I,colorBy:void 0,colorScale:void 0,showLegend:!1,userMargin:i,defaults:n.marginDefaults}),{activeSelectionHook:$,customHoverBehavior:_}=tt({selection:A,linkedHover:S,fallbackFields:[],onObservation:E,chartType:"Heatmap",chartId:L}),z=ot(C,void 0,[]),F=e.useMemo(()=>z.legendSelectionHook?z.legendSelectionHook:$,[z.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:l.interpolateBlues,reds:l.interpolateReds,greens:l.interpolateGreens,viridis:l.interpolateViridis}[g]||l.interpolateBlues).domain(G),[g,y,G]);e.useMemo(()=>{const e=Ke(s),t=Ke(c);return{xBinCount:new Set(I.map(e)).size,yBinCount:new Set(I.map(t)).size}},[I,s,c]),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(()=>Ze(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(()=>ft([{label:D||dt(s),accessor:s,role:"x"},{label:B||dt(c),accessor:c,role:"y"},{label:dt(u),accessor:u,role:"value"}]),[s,c,D,B,u]),U=jt({componentName:"Heatmap",data:I,accessors:{xAccessor:s,yAccessor:c,valueAccessor:u}});if(U)return f.createElement(pt,{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:c,valueAccessor:u,size:[j,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R,showAxes:n.showAxes,xLabel:D,yLabel:B,xFormat:d,yFormat:h,enableHover:H},N&&{title:N}),a&&{className:a}),{tooltipContent:ut(x)||V}),(S||E)&&{customHoverBehavior:_}),k&&k.length>0&&{annotations:k}),w);return f.createElement(xt,{componentName:"Heatmap",width:j,height:P},f.createElement(ke,Object.assign({},Z)))}Bt.displayName="LineChart",Wt.displayName="AreaChart",Tt.displayName="StackedAreaChart",It.displayName="Scatterplot",Rt.displayName="ConnectedScatterplot",$t.displayName="BubbleChart",_t.displayName="Heatmap";const zt="__splomIdx",Ft={top:4,bottom:4,left:4,right:4};function Yt({frameRef:o,cellSize:r,onBrush:i}){const a=e.useRef(null),s=r-Ft.left-Ft.right,l=r-Ft.top-Ft.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(${Ft.left},${Ft.top})`}))}function Gt({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=_e({name:c,clientId:`splom-${n}-${o}`}),m=Fe({name:c,xField:n,yField:o}),v=_e({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[zt];void 0!==n&&(b({[zt]:[n]}),null==g||g(t,e.x+Ft.left,e.y+Ft.top))},[b,g]),w=e.useCallback(e=>{const t={opacity:a,r:i};return t.fill=s?Ee(e,s,l):Qe,"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:Ft,showAxes:!1,enableHover:"hover"===h,customHoverBehavior:"hover"===h?k:void 0,tooltipContent:"hover"===h?()=>null:void 0}),"brush"===h&&f.createElement(Yt,{frameRef:y,cellSize:r,xField:n,yField:o,onBrush:x}))}function qt({data:t,field:n,label:o,cellSize:r,bins:i,brushSelectionName:a,hoverSelectionName:s,mode:l}){const c=_e({name:a,clientId:"splom-diag-"+n}),u=_e({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:Qe,opacity:.7})))}function Xt({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 Vt(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,S="splom",E="splom-hover",L=y?"hover":g?"brush":"hover",O=Ie(e=>e.clearSelection),[M,C]=e.useState(null),j=e.useCallback(()=>{O(E),C(null)},[O,E]),P=e.useMemo(()=>(n||[]).map((e,t)=>void 0!==e[zt]?e:Object.assign(Object.assign({},e),{[zt]:t})),[n]),H=Je(P,i,a),N=void 0!==b?b:!!i,D=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+""):Qe})):null},[N,i,P,H]),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 f.createElement("div",{className:k,style:{position:"relative"}},D&&f.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},D.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:B,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(Xt,{key:"diag-"+e,label:r[e]||e,cellSize:s}):f.createElement(qt,{key:"diag-"+e,data:P,field:e,label:r[e]||e,cellSize:s,bins:h,colorBy:i,colorScale:H,brushSelectionName:S,hoverSelectionName:E,unselectedOpacity:p,mode:L}):f.createElement(Gt,{key:`cell-${e}-${n}`,data:P,xField:n,yField:e,fieldLabels:r,cellSize:s,pointRadius:c,pointOpacity:u,colorBy:i,colorScale:H,brushSelectionName:S,hoverSelectionName:E,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[zt];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 Ut(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(Ve,{selections:o},f.createElement(Vt,Object.assign({},e)))}function Zt(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 Qt(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}}Ut.displayName="ScatterplotMatrix";const Kt={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(S(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(S(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(S(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(S(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:Zt,donut:Zt,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,S=h(e.pieceData[0],e.name),E=[];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;E.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:S,datum:e.pieceData,category:e.name,outliers:E}),m)for(const e of E)y.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:S.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:Qt(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(S(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:Qt(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(S(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(S(e.x,n,e.width,r-n,u,t,e.name))}}return l}};class Jt{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=Kt[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 en(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 tn(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 nn(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 on(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 rn(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 an(e){return Math.round(100*e)/100+""}function sn(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:S,xAccessor:E,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||an)(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:E,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,S,E,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 ln(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 cn=(e,t,n,o)=>{var r,i;const a=t.filter(e=>"wedge"===e.type);for(const t of a)ln(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&&(ln(e,t),e.globalAlpha=.35*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill()),e.globalAlpha=1},un=(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()}},dn=(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}},hn=e=>[dn,...e],gn={bar:hn([ge]),clusterbar:hn([ge]),point:hn([he]),swarm:hn([he]),pie:[cn],donut:[cn],boxplot:hn([(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:hn([un]),histogram:hn([ge]),ridgeline:hn([un]),timeline:hn([ge])},fn={top:50,right:40,bottom:60,left:70},yn={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 pn({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:yn},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:yn},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:yn},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:yn},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:yn},l&&f.createElement("div",{style:{fontWeight:"bold"}},l+""),""!==c&&f.createElement("div",null,"number"==typeof c?c.toLocaleString():c+""))}const mn=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:S,margin:E,barPadding:L,innerRadius:O,normalize:M,startAngle:C,dynamicColumnWidth:j,bins:P,showOutliers:H,showIQR:N,amplitude:D,connectorAccessor:B,connectorStyle:W,rExtent:T,oExtent:z,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:Se}=t,[Ee,Le]=$(w,A,S),Oe=e.useMemo(()=>Object.assign(Object.assign({},fn),E),[E]),Me=Le[0]-Oe.left-Oe.right,Ce=Le[1]-Oe.top-Oe.bottom,je=e.useRef(null),Pe=e.useRef(!0),He=e.useRef(0),Ne=e.useRef(null),De=e.useRef(()=>{}),[Be,We]=e.useState(null),[Te,Ie]=e.useState(null),[Re,$e]=e.useState(0),[_e,ze]=e.useState(!1),Fe=ne||oe,Ye="streaming"===l,Ge=e.useMemo(()=>({chartType:a,runtimeMode:Ye?"streaming":"bounded",windowSize:q,windowMode:G,extentPadding:F,projection:k,oAccessor:Ye?void 0:u,rAccessor:Ye?void 0:d,colorAccessor:h,stackBy:g,groupBy:y,multiAxis:p,timeAccessor:Ye?v:void 0,valueAccessor:Ye?b||("string"==typeof d||"function"==typeof d?d:void 0):void 0,categoryAccessor:Ye?x||u:void 0,rExtent:T,oExtent:z,barPadding:L,innerRadius:O,normalize:M,startAngle:C,dynamicColumnWidth:j,bins:P,showOutliers:H,showIQR:N,amplitude:D,connectorAccessor:B,connectorStyle:W,oSort:Y,pieceStyle:X,summaryStyle:V,colorScheme:U,barColors:Z,decay:ke,pulse:we,transition:Ae,staleness:Se}),[a,q,G,F,k,u,d,h,g,y,p,v,b,x,T,z,L,O,M,C,j,P,H,N,D,B,W,Y,X,V,U,Z,ke,we,Ae,Se,Ye]),qe=e.useRef(null);qe.current||(qe.current=new Jt(Ge));const Xe=e.useCallback(()=>{He.current||(He.current=requestAnimationFrame(()=>De.current()))},[]);e.useEffect(()=>{var e;null===(e=qe.current)||void 0===e||e.updateConfig(Ge),Pe.current=!0,Xe()},[Ge,Xe]);const Ve=e.useRef(null);Ve.current||(Ve.current=new m(e=>{const t=qe.current;t&&t.ingest(e)&&(Pe.current=!0,Xe())}));const Ue=e.useCallback(e=>{var t;null===(t=Ve.current)||void 0===t||t.push(e)},[]),Ze=e.useCallback(e=>{var t;null===(t=Ve.current)||void 0===t||t.pushMany(e)},[]),Qe=e.useCallback(()=>{var e,t;null===(e=Ve.current)||void 0===e||e.clear(),null===(t=qe.current)||void 0===t||t.clear(),Pe.current=!0,Xe()},[Xe]);e.useImperativeHandle(n,()=>({push:Ue,pushMany:Ze,clear:Qe,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}}),[Ue,Ze,Qe]),e.useEffect(()=>{var e;c&&(null===(e=Ve.current)||void 0===e||e.setBoundedData(c))},[c]);const Ke=e.useRef(()=>{}),Je=e.useRef(()=>{});Ke.current=e=>{if(!Fe)return;const t=je.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(Ne.current&&(Ne.current=null,We(null),ie&&ie(null),Xe()));const i=qe.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=en(i,t,n);break;case"point":e=tn(i,t,n);break;case"wedge":e=nn(i,t,n);break;case"boxplot":e=on(i,t,n);break;case"violin":e=rn(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-Ce/2:r);if(!s)return void(Ne.current&&(Ne.current=null,We(null),ie&&ie(null),Xe()));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});Ne.current=l,We(l),ie&&(ie(l),Pe.current=!0),Xe()},Je.current=()=>{Ne.current&&(Ne.current=null,We(null),ie&&(ie(null),Pe.current=!0),Xe())},e.useCallback(e=>Ke.current(e),[]);const et=e.useCallback(()=>Je.current(),[]),tt=e.useRef(-1),nt=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=tt.current,r=I(e.key,0>o?-1:o,n.length);if(null===r)return;if(e.preventDefault(),0>r)return tt.current=-1,Ne.current=null,We(null),ie&&ie(null),void Xe();const i=0>o?0:r;tt.current=i;const a=R(n[i]);Ne.current=a,We(a),ie&&ie(a),Xe()},[ie,Xe]),ot=e.useCallback(e=>{tt.current=-1,Ke.current(e)},[]);De.current=()=>{var e,t;He.current=0;const n=je.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const r=qe.current;if(!r)return;const i="undefined"!=typeof performance?performance.now():Date.now(),s=r.advanceTransition(i),l=Pe.current;l&&!s&&(r.computeScene({width:Me,height:Ce}),Pe.current=!1);const c="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=Le[0]*c,n.height=Le[1]*c,n.style.width=Le[0]+"px",n.style.height=Le[1]+"px",o.scale(c,c),o.clearRect(0,0,Le[0],Le[1]);const u=null!==(e=null==Se?void 0:Se.threshold)&&void 0!==e?e:5e3,d=Se&&r.lastIngestTime>0&&i-r.lastIngestTime>u;d&&(o.globalAlpha=null!==(t=null==Se?void 0:Se.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,Le[0],Le[1]));const f="radial"===k;f?(o.save(),o.translate(Oe.left+Me/2,Oe.top+Ce/2)):o.translate(Oe.left,Oe.top);const y=gn[a]||[],p={width:Me,height:Ce};for(const e of y)e(o,r.scene,r.scales,p);f&&o.restore(),d&&(o.globalAlpha=1),l&&r.scales&&(Ie(r.scales),$e(e=>e+1)),(null==Se?void 0:Se.showBadge)&&ze(!!d),(s||r.hasActivePulses)&&(He.current=requestAnimationFrame(()=>De.current()))},e.useEffect(()=>(Xe(),()=>{He.current&&(cancelAnimationFrame(He.current),He.current=0)}),[Xe]),e.useEffect(()=>{Pe.current=!0,Xe()},[a,Me,Ce,Q,be,Xe]),_(Se,qe,Pe,Xe,_e,ze);const rt=Fe&&Be?re?re(Be):f.createElement(pn,{hover:Be}):null,it="radial"===k,at=Be?it?Be.x+Me/2:Be.x:0,st=Be?it?Be.y+Ce/2:Be.y:0,lt=rt?f.createElement("div",{className:"stream-ordinal-tooltip",style:{position:"absolute",left:Oe.left+at,top:Oe.top+st,transform:`translate(${at>.7*Me?"calc(-100% - 12px)":"12px"}, ${.3*Ce>st?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},rt):null;if(se){const e=qe.current;e&&c&&(e.ingest({inserts:c,bounded:!0}),e.computeScene({width:Me,height:Ce}));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?Oe.left+Me/2:Oe.left,l=i?Oe.top+Ce/2:Oe.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: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}},ye&&f.createElement("g",{transform:`translate(${Oe.left},${Oe.top})`},ye),f.createElement("g",{transform:`translate(${a},${l})`},be&&f.createElement("rect",{x:0,y:0,width:Me,height:Ce,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(sn,{width:Me,height:Ce,totalWidth:Le[0],totalHeight:Le[1],margin:Oe,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:Oe.left+Me/2,top:Oe.top+Ce/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"}},xe))}return f.createElement("div",{ref:Ee,className:"stream-ordinal-frame"+(ve?" "+ve:""),role:"img","aria-label":"string"==typeof me?me:"Ordinal chart",tabIndex:0,style:{position:"relative",width:A?"100%":Le[0],height:S?"100%":Le[1]},onMouseMove:Fe?ot:void 0,onMouseLeave:Fe?et:void 0,onKeyDown:nt},ye&&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})`},ye)),f.createElement("canvas",{ref:je,style:{position:"absolute",top:0,left:0,width:Le[0],height:Le[1]}}),f.createElement(sn,{width:Me,height:Ce,totalWidth:Le[0],totalHeight:Le[1],margin:Oe,scales:Te,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:Re,xAccessor:"string"==typeof u?u:void 0,yAccessor:"string"==typeof d?d:void 0,annotationData:null===(i=qe.current)||void 0===i?void 0:i.getData()}),xe&&"radial"===k&&f.createElement("div",{style:{position:"absolute",left:Oe.left+Me/2,top:Oe.top+Ce/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"}},xe),(null==Se?void 0:Se.showBadge)&&f.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Se.badgePosition?{top:4,left:4}:"bottom-left"===Se.badgePosition?{bottom:4,left:4}:"bottom-right"===Se.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:_e?"#dc3545":"#28a745",color:"white"})},_e?"STALE":"LIVE"),lt)});function vn(t){const n=it(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:S}=t,E=n.width,L=n.height,O=n.enableHover,M=n.showGrid,C=n.showLegend,j=n.title,P=n.categoryLabel,H=n.valueLabel,N=St(w,E,L);if(N)return N;const D=At(o,E,L,A);if(D)return D;const B=o||[];Et("BarChart",B,"categoryAccessor",a),Et("BarChart",B,"valueAccessor",s);const{activeSelectionHook:W,customHoverBehavior:T}=tt({selection:v,linkedHover:b,fallbackFields:u?["string"==typeof u?u:""]:[],unwrapData:!0,onObservation:x,chartType:"BarChart",chartId:k}),I=et(B,h,s),R=Je(B,u,d),$=e.useMemo(()=>{if(!u)return[];const e=new Set;for(const t of B){const n="function"==typeof u?u(t):t[u];null!=n&&e.add(n+"")}return Array.from(e)},[B,u]),_=ot(S,u,$),z=e.useMemo(()=>_.legendSelectionHook?_.legendSelectionHook:W,[_.legendSelectionHook,W]),F=e.useMemo(()=>e=>{const t={};return t.fill=u?Ee(e,u,R):Qe,t},[u,R]),Y=e.useMemo(()=>Ze(F,z,v),[F,z,v]),{legend:G,margin:q}=nt({data:I,colorBy:u,colorScale:R,showLegend:C,userMargin:r,defaults:n.marginDefaults}),X=e.useMemo(()=>yt({categoryAccessor:a,valueAccessor:s,groupAccessor:u&&u!==a?u:void 0,groupLabel:"string"==typeof u?u:"group"}),[a,s,u]),V=jt({componentName:"BarChart",data:B,accessors:{categoryAccessor:a,valueAccessor:s}});if(V)return f.createElement(pt,{componentName:"BarChart",message:V,width:E,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:[E,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}),S&&"none"!==S&&{legendHoverBehavior:_.onLegendHover,legendClickBehavior:_.onLegendClick,legendHighlightedCategory:_.highlightedCategory,legendIsolatedCategories:_.isolatedCategories}),j&&{title:j}),i&&{className:i}),{tooltipContent:ut(y)||X}),(b||x)&&{customHoverBehavior:T}),p&&p.length>0&&{annotations:p}),m);return f.createElement(xt,{componentName:"BarChart",width:E,height:L},f.createElement(mn,Object.assign({},U)))}function bn(t){const n=it(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:S,legendInteraction:E}=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,D=St(A,L,O);if(D)return D;const B=At(o,L,O,S);if(B)return B;const W=o||[],T=d||s,{activeSelectionHook:I,customHoverBehavior:R}=tt({selection:b,linkedHover:x,fallbackFields:T?["string"==typeof T?T:""]:[],unwrapData:!0,onObservation:k,chartType:"StackedBarChart",chartId:w}),$=Je(W,T,h),_=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]),z=ot(E,T,_),F=e.useMemo(()=>z.legendSelectionHook?z.legendSelectionHook:I,[z.legendSelectionHook,I]),Y=e.useMemo(()=>e=>T?{fill:Ee(e,T,$)}:{fill:Qe},[T,$]),G=e.useMemo(()=>Ze(Y,F,b),[Y,F,b]),{legend:q,margin:X}=nt({data:W,colorBy:T,colorScale:$,showLegend:j,userMargin:r,defaults:n.marginDefaults}),V=e.useMemo(()=>yt({categoryAccessor:s,valueAccessor:l,groupAccessor:a}),[s,a,l]),U=jt({componentName:"StackedBarChart",data:W,accessors:{categoryAccessor:a,valueAccessor:l},requiredProps:{stackBy:s}});if(U)return f.createElement(pt,{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}),E&&"none"!==E&&{legendHoverBehavior:z.onLegendHover,legendClickBehavior:z.onLegendClick,legendHighlightedCategory:z.highlightedCategory,legendIsolatedCategories:z.isolatedCategories}),P&&{title:P}),i&&{className:i}),{tooltipContent:ut(p)||V}),(x||k)&&{customHoverBehavior:R}),m&&m.length>0&&{annotations:m}),v);return f.createElement(xt,{componentName:"StackedBarChart",width:L,height:O},f.createElement(mn,Object.assign({},Z)))}function xn(t){const n=it(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:S}=t,E=n.width,L=n.height,O=n.enableHover,M=n.showGrid,C=n.showLegend,j=n.title,P=n.categoryLabel,H=n.valueLabel,N=St(w,E,L);if(N)return N;const D=At(o,E,L,A);if(D)return D;const B=o||[],W=d||s,{activeSelectionHook:T,customHoverBehavior:I}=tt({selection:v,linkedHover:b,fallbackFields:W?["string"==typeof W?W:""]:[],unwrapData:!0,onObservation:x,chartType:"GroupedBarChart",chartId:k}),R=Je(B,W,h),$=e.useMemo(()=>{if(!W)return[];const e=new Set;for(const t of B){const n="function"==typeof W?W(t):t[W];null!=n&&e.add(n+"")}return Array.from(e)},[B,W]),_=ot(S,W,$),z=e.useMemo(()=>_.legendSelectionHook?_.legendSelectionHook:T,[_.legendSelectionHook,T]),F=e.useMemo(()=>e=>W?{fill:Ee(e,W,R)}:{fill:Qe},[W,R]),Y=e.useMemo(()=>Ze(F,z,v),[F,z,v]),{legend:G,margin:q}=nt({data:B,colorBy:W,colorScale:R,showLegend:C,userMargin:r,defaults:n.marginDefaults}),X=e.useMemo(()=>yt({categoryAccessor:s,valueAccessor:l,groupAccessor:a}),[s,a,l]),V=jt({componentName:"GroupedBarChart",data:B,accessors:{categoryAccessor:a,valueAccessor:l},requiredProps:{groupBy:s}});if(V)return f.createElement(pt,{componentName:"GroupedBarChart",message:V,width:E,height:L});const U=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"clusterbar",data:B,oAccessor:a,rAccessor:l,groupBy:s,projection:"horizontal"===c?"horizontal":"vertical",pieceStyle:Y,size:[E,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}),S&&"none"!==S&&{legendHoverBehavior:_.onLegendHover,legendClickBehavior:_.onLegendClick,legendHighlightedCategory:_.highlightedCategory,legendIsolatedCategories:_.isolatedCategories}),j&&{title:j}),i&&{className:i}),{tooltipContent:ut(y)||X}),(b||x)&&{customHoverBehavior:I}),p&&p.length>0&&{annotations:p}),m);return f.createElement(xt,{componentName:"GroupedBarChart",width:E,height:L},f.createElement(mn,Object.assign({},U)))}function kn(t){const n=it(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:S,loading:E,emptyContent:L,legendInteraction:O}=t,M=n.width,C=n.height,j=n.enableHover,P=n.showGrid,H=n.showLegend,N=n.title,D=n.categoryLabel,B=n.valueLabel,W=St(E,M,C);if(W)return W;const T=At(o,M,C,L);if(T)return T;const I=o||[],{activeSelectionHook:R,customHoverBehavior:$}=tt({selection:k,linkedHover:w,fallbackFields:u?["string"==typeof u?u:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:A,chartType:"SwarmPlot",chartId:S}),_=Je(I,u,d),z=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=ot(O,u,z),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?Ee(e,u,_):Qe,t.r=h?Oe(e,h,g,G):y,t},[u,_,h,g,G,y,p]),X=e.useMemo(()=>Ze(q,Y,k),[q,Y,k]),{legend:V,margin:U}=nt({data:I,colorBy:u,colorScale:_,showLegend:H,userMargin:r,defaults:n.marginDefaults}),Z=e.useMemo(()=>yt({categoryAccessor:a,valueAccessor:s,groupAccessor:u||void 0}),[a,s,u]),Q=jt({componentName:"SwarmPlot",data:I,accessors:{categoryAccessor:a,valueAccessor:s}});if(Q)return f.createElement(pt,{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:D,rLabel:B,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:ut(v)||Z}),(w||A)&&{customHoverBehavior:$}),b&&b.length>0&&{annotations:b}),x);return f.createElement(xt,{componentName:"SwarmPlot",width:M,height:C},f.createElement(mn,Object.assign({},K)))}function wn(t){const n=it(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:S}=t,E=n.width,L=n.height,O=n.enableHover,M=n.showGrid,C=n.showLegend,j=n.title,P=n.categoryLabel,H=n.valueLabel,N=St(w,E,L);if(N)return N;const D=At(o,E,L,A);if(D)return D;const B=o||[],{activeSelectionHook:W,customHoverBehavior:T}=tt({selection:v,linkedHover:b,fallbackFields:u?["string"==typeof u?u:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:x,chartType:"BoxPlot",chartId:k}),I=Je(B,u,d),R=e.useMemo(()=>{if(!u)return[];const e=new Set;for(const t of B){const n="function"==typeof u?u(t):t[u];null!=n&&e.add(n+"")}return Array.from(e)},[B,u]),$=ot(S,u,R),_=e.useMemo(()=>$.legendSelectionHook?$.legendSelectionHook:W,[$.legendSelectionHook,W]),z=e.useMemo(()=>e=>{const t=u?Ee(e,u,I):Qe;return{fill:t,stroke:t,fillOpacity:.8}},[u,I]),F=e.useMemo(()=>Ze(z,_,v),[z,_,v]),{legend:Y,margin:G}=nt({data:B,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:at},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=jt({componentName:"BoxPlot",data:B,accessors:{categoryAccessor:a,valueAccessor:s}});if(X)return f.createElement(pt,{componentName:"BoxPlot",message:X,width:E,height:L});const V=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"boxplot",data:B,oAccessor:a,rAccessor:s,projection:"horizontal"===l?"horizontal":"vertical",summaryStyle:F,showOutliers:h,size:[E,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}),S&&"none"!==S&&{legendHoverBehavior:$.onLegendHover,legendClickBehavior:$.onLegendClick,legendHighlightedCategory:$.highlightedCategory,legendIsolatedCategories:$.isolatedCategories}),j&&{title:j}),i&&{className:i}),{tooltipContent:ut(y)||q}),(b||x)&&{customHoverBehavior:T}),p&&p.length>0&&{annotations:p}),m);return f.createElement(xt,{componentName:"BoxPlot",width:E,height:L},f.createElement(mn,Object.assign({},V)))}function An(t){const n=it(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,S=n.width,E=n.height,L=n.enableHover,O=n.showGrid,M=n.showLegend,C=n.title,j=n.categoryLabel,P=n.valueLabel,H=St(w,S,E);if(H)return H;const N=At(o,S,E,A);if(N)return N;const D=o||[],{activeSelectionHook:B,customHoverBehavior:W}=tt({selection:v,linkedHover:b,fallbackFields:d?["string"==typeof d?d:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:x,chartType:"Histogram",chartId:k}),T=Je(D,d,h),I=e.useMemo(()=>e=>{const t=d?Ee(e,d,T):Qe;return{fill:t,stroke:t,fillOpacity:.8}},[d,T]),R=e.useMemo(()=>Ze(I,B,v),[I,B,v]),{legend:$,margin:_}=nt({data:D,colorBy:d,colorScale:T,showLegend:M,userMargin:r,defaults:n.marginDefaults}),z=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:at},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=jt({componentName:"Histogram",data:D,accessors:{categoryAccessor:a,valueAccessor:s}});if(F)return f.createElement(pt,{componentName:"Histogram",message:F,width:S,height:E});const Y=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"histogram",data:D,oAccessor:a,rAccessor:s,projection:"horizontal",summaryStyle:R,bins:l,normalize:c,size:[S,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:_,barPadding:g,enableHover:L,showAxes:n.showAxes,oLabel:j,rLabel:P,rFormat:u,showGrid:O},$&&{legend:$}),C&&{title:C}),i&&{className:i}),{tooltipContent:ut(y)||z}),(b||x)&&{customHoverBehavior:W}),p&&p.length>0&&{annotations:p}),m);return f.createElement(xt,{componentName:"Histogram",width:S,height:E},f.createElement(mn,Object.assign({},Y)))}function Sn(t){const n=it(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:S}=t,E=n.width,L=n.height,O=n.enableHover,M=n.showGrid,C=n.showLegend,j=n.title,P=n.categoryLabel,H=n.valueLabel,N=St(A,E,L);if(N)return N;const D=At(o,E,L,S);if(D)return D;const B=o||[],{activeSelectionHook:W,customHoverBehavior:T}=tt({selection:b,linkedHover:x,fallbackFields:h?["string"==typeof h?h:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:k,chartType:"ViolinPlot",chartId:w}),I=Je(B,h,g),R=e.useMemo(()=>e=>{const t=h?Ee(e,h,I):Qe;return{fill:t,stroke:t,fillOpacity:.6}},[h,I]),$=e.useMemo(()=>Ze(R,W,b),[R,W,b]),{legend:_,margin:z}=nt({data:B,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:at},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:at},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=jt({componentName:"ViolinPlot",data:B,accessors:{categoryAccessor:a,valueAccessor:s}});if(Y)return f.createElement(pt,{componentName:"ViolinPlot",message:Y,width:E,height:L});const G=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"violin",data:B,oAccessor:a,rAccessor:s,projection:"horizontal"===l?"horizontal":"vertical",summaryStyle:$,bins:c,showIQR:u,size:[E,L],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:z,barPadding:y,enableHover:O,showAxes:n.showAxes,oLabel:P,rLabel:H,rFormat:d,showGrid:M},_&&{legend:_}),j&&{title:j}),i&&{className:i}),{tooltipContent:ut(p)||F}),(x||k)&&{customHoverBehavior:T}),m&&m.length>0&&{annotations:m}),v);return f.createElement(xt,{componentName:"ViolinPlot",width:E,height:L},f.createElement(mn,Object.assign({},G)))}function En(t){var n;const o=it(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:S,emptyContent:E,legendInteraction:L}=t,O=o.width,M=o.height,C=o.enableHover,j=o.showGrid,P=o.showLegend,H=o.title,N=o.categoryLabel,D=o.valueLabel,B=St(S,O,M);if(B)return B;const W=At(r,O,M,E);if(W)return W;const T=r||[],{activeSelectionHook:I,customHoverBehavior:R}=tt({selection:x,linkedHover:k,fallbackFields:d?["string"==typeof d?d:""]:["string"==typeof s?s:""],unwrapData:!0,onObservation:w,chartType:"DotPlot",chartId:A}),$=et(T,g,l),_=Je(T,d,h),z=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=ot(L,d,z),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?Ee(e,d,_):Qe,t},[d,_,y]),q=e.useMemo(()=>Ze(G,Y,x),[G,Y,x]),{legend:X,margin:V}=nt({data:$,colorBy:d,colorScale:_,showLegend:P,userMargin:i,defaults:o.marginDefaults}),U=e.useMemo(()=>yt({categoryAccessor:s,valueAccessor:l}),[s,l]),Z=jt({componentName:"DotPlot",data:T,accessors:{categoryAccessor:s,valueAccessor:l}});if(Z)return f.createElement(pt,{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:D,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:ut(m)||U}),(k||w)&&{customHoverBehavior:R}),v&&v.length>0&&{annotations:v}),b);return f.createElement(xt,{componentName:"DotPlot",width:O,height:M},f.createElement(mn,Object.assign({},Q)))}function Ln(t){const n=it(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:S}=t,E=n.width,L=n.height,O=n.enableHover,M=n.showGrid,C=n.showLegend,j=n.title,P=n.categoryLabel,H=n.valueLabel,N=St(A,E,L);if(N)return N;const D=At(o,E,L,S);if(D)return D;const B=o||[],{activeSelectionHook:W,customHoverBehavior:T}=tt({selection:b,linkedHover:x,fallbackFields:h?["string"==typeof h?h:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:k,chartType:"RidgelinePlot",chartId:w}),I=Je(B,h,g),R=e.useMemo(()=>e=>{const t=h?Ee(e,h,I):Qe;return{fill:t,stroke:t,fillOpacity:.5}},[h,I]),$=e.useMemo(()=>Ze(R,W,b),[R,W,b]),{legend:_,margin:z}=nt({data:B,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:at},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:at},f.createElement("div",{style:{fontWeight:"bold"}},n+""))},[]),Y=jt({componentName:"RidgelinePlot",data:B,accessors:{categoryAccessor:a,valueAccessor:s}});if(Y)return f.createElement(pt,{componentName:"RidgelinePlot",message:Y,width:E,height:L});const G=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"ridgeline",data:B,oAccessor:a,rAccessor:s,projection:"horizontal"===l?"horizontal":"vertical",summaryStyle:$,bins:c,size:[E,L],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:z,barPadding:y,enableHover:O,showAxes:n.showAxes,oLabel:P,rLabel:H,rFormat:d,showGrid:M,oSort:!1,amplitude:u},_&&{legend:_}),j&&{title:j}),i&&{className:i}),{tooltipContent:ut(p)||F}),(x||k)&&{customHoverBehavior:T}),m&&m.length>0&&{annotations:m}),v);return f.createElement(xt,{componentName:"RidgelinePlot",width:E,height:L},f.createElement(mn,Object.assign({},G)))}function On(t){var n,o;const r=it(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,S=r.width,E=r.height,L=r.enableHover,O=r.showLegend,M=r.title,C=St(k,S,E);if(C)return C;const j=At(i,S,E,w);if(j)return j;const P=i||[],H=u||l,{activeSelectionHook:N,customHoverBehavior:D}=tt({selection:m,linkedHover:v,fallbackFields:H?["string"==typeof H?H:""]:[],unwrapData:!0,onObservation:b,chartType:"PieChart",chartId:x}),B=Je(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=ot(A,H,W),I=e.useMemo(()=>T.legendSelectionHook?T.legendSelectionHook:N,[T.legendSelectionHook,N]),R=e.useMemo(()=>e=>H?{fill:Ee(e,H,B)}:{fill:Qe},[H,B]),$=e.useMemo(()=>Ze(R,I,m),[R,I,m]),{legend:_,margin:z}=nt({data:P,colorBy:H,colorScale:B,showLegend:O,userMargin:a,defaults:r.marginDefaults}),F=e.useMemo(()=>yt({categoryAccessor:l,valueAccessor:c,groupAccessor:u&&u!==l?u:void 0,groupLabel:"string"==typeof u?u:"group",pieData:!0}),[l,c,u]),Y=jt({componentName:"PieChart",data:P,accessors:{categoryAccessor:l,valueAccessor:c}});if(Y)return f.createElement(pt,{componentName:"PieChart",message:Y,width:S,height:E});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:[S,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:z,enableHover:L,showAxes:!1},_&&{legend:_}),A&&"none"!==A&&{legendHoverBehavior:T.onLegendHover,legendClickBehavior:T.onLegendClick,legendHighlightedCategory:T.highlightedCategory,legendIsolatedCategories:T.isolatedCategories}),M&&{title:M}),s&&{className:s}),{tooltipContent:ut(g)||F}),(v||b)&&{customHoverBehavior:D}),y&&y.length>0&&{annotations:y}),p);return f.createElement(xt,{componentName:"PieChart",width:S,height:E},f.createElement(mn,Object.assign({},G)))}function Mn(t){var n,o;const r=it(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:S,legendInteraction:E}=t,L=r.width,O=r.height,M=r.enableHover,C=r.showLegend,j=r.title,P=St(A,L,O);if(P)return P;const H=At(i,L,O,S);if(H)return H;const N=i||[],D=h||l,{activeSelectionHook:B,customHoverBehavior:W}=tt({selection:b,linkedHover:x,fallbackFields:D?["string"==typeof D?D:""]:[],unwrapData:!0,onObservation:k,chartType:"DonutChart",chartId:w}),T=Je(N,D,g),I=e.useMemo(()=>{if(!D)return[];const e=new Set;for(const t of N){const n="function"==typeof D?D(t):t[D];null!=n&&e.add(n+"")}return Array.from(e)},[N,D]),R=ot(E,D,I),$=e.useMemo(()=>R.legendSelectionHook?R.legendSelectionHook:B,[R.legendSelectionHook,B]),_=e.useMemo(()=>e=>D?{fill:Ee(e,D,T)}:{fill:Qe},[D,T]),z=e.useMemo(()=>Ze(_,$,b),[_,$,b]),{legend:F,margin:Y}=nt({data:N,colorBy:D,colorScale:T,showLegend:C,userMargin:a,defaults:r.marginDefaults}),G=e.useMemo(()=>yt({categoryAccessor:l,valueAccessor:c,groupAccessor:h&&h!==l?h:void 0,groupLabel:"string"==typeof h?h:"group",pieData:!0}),[l,c,h]),q=jt({componentName:"DonutChart",data:N,accessors:{categoryAccessor:l,valueAccessor:c}});if(q)return f.createElement(pt,{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:z,innerRadius:u,startAngle:y,centerContent:d,size:[L,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Y,enableHover:M,showAxes:!1},F&&{legend:F}),E&&"none"!==E&&{legendHoverBehavior:R.onLegendHover,legendClickBehavior:R.onLegendClick,legendHighlightedCategory:R.highlightedCategory,legendIsolatedCategories:R.isolatedCategories}),j&&{title:j}),s&&{className:s}),{tooltipContent:ut(p)||G}),(x||k)&&{customHoverBehavior:W}),m&&m.length>0&&{annotations:m}),v);return f.createElement(xt,{componentName:"DonutChart",width:L,height:O},f.createElement(mn,Object.assign({},X)))}mn.displayName="StreamOrdinalFrame",vn.displayName="BarChart",bn.displayName="StackedBarChart",xn.displayName="GroupedBarChart",kn.displayName="SwarmPlot",wn.displayName="BoxPlot",An.displayName="Histogram",Sn.displayName="ViolinPlot",En.displayName="DotPlot",Ln.displayName="RidgelinePlot",On.displayName="PieChart",Mn.displayName="DonutChart";const Cn={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},jn={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class Pn{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=Hn(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 Hn(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=Nn(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=Nn(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 Nn(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 Dn(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function Bn(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 Wn(e){return e.y0-e.y1>0?"up":"down"}function Tn(e,t){return t(e.source)==t(e.target)}function In(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 Rn(e){return e.target.x0-e.source.x1}function $n(e,t){var n=zn(e),o=Rn(t)/Math.tan(n);return"up"==Wn(e)?e.y1-o:e.y1+o}function _n(e,t){var n=zn(e),o=Rn(t)/Math.tan(n);return"up"==Wn(e)?e.y1+o:e.y1-o}function zn(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function Fn(e,t){return t(e)}function Yn(e){return qn(e.source)}function Gn(e){return qn(e.target)}function qn(e){return(e.y0+e.y1)/2}function Xn(e){return e.virtual?0:e.value}function Vn(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!Tn(e,t)?n+1:n});var o=0;return e.targetLinks.forEach(function(e){o=e.circular&&!Tn(e,t)?o+1:o}),n+o}function Un(e){return e.target.depth}function Zn(e,t){return e.sourceLinks.length?e.depth:t-1}function Qn(e,t){return e.y0-t.y0}function Kn(e,t){return t.y0-e.y0}function Jn(e,t){return e.y1-t.y1}function eo(e,t){return t.y1-e.y1}function to(e,t){return oo(e.source,t.source)||e.index-t.index}function no(e,t){return oo(e.target,t.target)||e.index-t.index}function oo(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function ro(e,t){return io(e)==io(t)?"bottom"==e.circularLinkType?Kn(e,t):Qn(e,t):io(t)-io(e)}function io(e){return e.target.column-e.source.column}function ao(e,t){return so(e)==so(t)}function so(e){return e.y0-e.y1>0?"up":"down"}function lo(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}),co(a.links.filter(function(e){return"top"==e.circularLinkType}),t,n),co(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,Tn(e,t)&&In(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?Kn:Qn);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?eo:Jn),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 co(e,t,n){e.sort(ro);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(Tn(e,t)&&In(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&&uo(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 uo(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function ho(e){return function(){return e}}function go(e){return e.index}function fo(e){return e.nodes}function yo(e){return e.links}function po(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?Vn(t,n)-Vn(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==Vn(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 mo(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&&Vn(i,n)>0){var c=r.mean(i.sourceLinks,Gn),u=r.mean(i.targetLinks,Yn),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-qn(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,Gn),f=r.mean(i.targetLinks,Yn),y=((g&&f?(g+f)/2:g||f)-qn(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||oo),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 vo(e){e.nodes.forEach(function(e){e.sourceLinks.sort(no),e.targetLinks.sort(to)}),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 bo(){var e=0,t=0,n=1,o=1,i=24,a=8,s=null,l=go,c=Zn,u=void 0,d=32,h=2,g=fo,f=yo;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=Dn(n,o)),"object"!=typeof r&&(r=e.target=Dn(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=Bn(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){Fn(e,t)!=Fn(r.source,t)&&Fn(e,t)!=Fn(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),Tn(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,Xn),r.sum(e.targetLinks,Xn)),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),po(g,u,l),mo(g,u,l,f,f,d),vo(g),lo(g,l,h,10,8),po(g,u,l),mo(g,u,l,f,f,d),vo(g),lo(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 Fn(n.source,t)==Fn(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(!ao(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=$n(t,e);return e.y1-n}if(t.target.column>e.target.column)return $n(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 Fn(n.target,t)==Fn(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(!ao(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=_n(t,e);return e.y0-n}if(t.source.column>e.source.column)return _n(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),lo(g,l,h,10,8)}(y),y}return y.update=function(e){return vo(e),lo(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:ho(e),y):g},y.links=function(e){return arguments.length?(f="function"==typeof e?e:ho(e),y):f},y.nodeId=function(e){return arguments.length?(l="function"==typeof e?e:ho(e),y):l},y.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:ho(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 xo=e=>{let t,n,o,r,i,a,s,l,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=c.interpolateNumber(i,a),l=s(.5),u=s(.5),`M${t},${i}C${t},${l} ${n},${u} ${n},${a}L${o},${a}C${o},${u} ${r},${l} ${r},${i}Z`):(t=e.source.x1,n=e.target.x0,s=c.interpolateNumber(t,n),o=s(.5),r=s(.5),i=e.y0-e.sankeyWidth/2,a=e.y1-e.sankeyWidth/2,l=e.y1+e.sankeyWidth/2,u=e.y0+e.sankeyWidth/2,`M${t},${i}C${o},${i} ${r},${a} ${n},${a}L${n},${l}C${r},${l} ${o},${u} ${t},${u}Z`)};function ko(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 wo={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(Un))-1:0},justify:Zn},Ao={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=bo().extent(v).links(m).nodes(p).nodeAlign(wo[h]||Zn).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 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",f=Array.isArray(n.colorScheme)?n.colorScheme:l.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?ko(e):xo(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,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:p,sceneEdges:m,labels:v}}},So={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=Eo(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,c=n.edgeStyle,u=Eo(n.nodeSize,n.nodeSizeRange,e),d=Array.isArray(n.colorScheme)?n.colorScheme:l.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=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};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 Eo(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 Lo=l.schemeCategory10,Oo={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:Lo,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=Mo(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 Mo(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 Co={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:Do(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?jo(i,o,n):"treemap"===s||"partition"===s?Po(i,o):"circlepack"===s&&Ho(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=No(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=Bo(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=Bo(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=Bo(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 jo(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 Po(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 Ho(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 No(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 Do(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 Bo(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 Wo={sankey:Ao,force:So,chord:Oo,tree:Co,cluster:Co,treemap:Co,circlepack:Co,partition:Co};function To(e){return Wo[e]}class Io{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({},Cn),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new Pn(2e3))}updateConfig(e){this.config=e,this.tensionConfig=Object.assign(Object.assign({},Cn),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&!this.particlePool&&(this.particlePool=new Pn(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({},Ro(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({},Ro(t)),{data:e})),this.nodes.has(n)||this.nodes.set(n,Object.assign(Object.assign({},Ro(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,Ro(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,Ro(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=To(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=To(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=c.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=c.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 Ro(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 $o(e,t,n,o,r=30){let i=null,a=r,s=1/0;for(const t of e){const e=_o(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=Go(e,n,o);t&&a>t.distance&&(i=t,a=t.distance)}return i}function _o(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 zo=null,Fo=null;function Yo(){return Fo||(zo=document.createElement("canvas"),zo.width=1,zo.height=1,Fo=zo.getContext("2d")),Fo}function Go(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=Yo();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=Yo();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 qo(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 Xo(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 Vo(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 Uo(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 Zo(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()}qo.displayName="NetworkSVGOverlay";const Qo={top:20,right:80,bottom:20,left:80},Ko={top:40,right:40,bottom:40,left:40},Jo=new Set(["chord","force","circlepack"]),er=[800,600],tr={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 nr({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:tr},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:tr},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:tr},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 or=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:S=.1,padAngle:E=.01,groupWidth:L=20,sortGroups:O,edgeSort:M,treeOrientation:C="vertical",edgeType:j="curve",padding:P,paddingTop:H,tensionConfig:N,showParticles:D=!1,particleStyle:B,nodeStyle:W,edgeStyle:T,colorBy:R,colorScheme:z="category10",edgeColorBy:F="source",edgeOpacity:Y=.5,colorByDepth:G=!1,nodeSize:q=8,nodeSizeRange:X=[5,20],nodeLabel:V,showLabels:U=!0,size:Z=er,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:Se}=t,Ee=Jo.has(a)?Ko:Qo,[Le,Oe]=$(Z,Q,K),Me=Object.assign(Object.assign({},Ee),J),Ce=Oe[0]-Me.left-Me.right,je=Oe[1]-Me.top-Me.bottom,Pe=e.useMemo(()=>Object.assign(Object.assign({},Cn),N),[N]),He=e.useMemo(()=>Object.assign(Object.assign({},jn),B),[B]),Ne=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:S,padAngle:E,groupWidth:L,sortGroups:O,edgeSort:M,treeOrientation:C,edgeType:j,padding:P,paddingTop:H,tensionConfig:Pe,showParticles:D,particleStyle:He,nodeStyle:W,edgeStyle:T,nodeLabel:V,showLabels:U,colorBy:R,colorScheme:z,edgeColorBy:F,edgeOpacity:Y,colorByDepth:G,nodeSize:q,nodeSizeRange:X,decay:xe,pulse:ke,staleness:we,thresholds:Se}),[a,h,g,y,p,m,v,b,x,k,w,A,S,E,L,O,M,C,j,P,H,Pe,D,He,W,T,V,U,R,z,F,Y,G,q,X,xe,ke,we,Se]),De=e.useRef(null),Be=e.useRef(0),We=e.useRef(0),Te=e.useRef(!0),Ie=e.useRef(()=>{}),Re=e.useRef(null);Re.current||(Re.current=new Io(Ne));const[$e,_e]=e.useState(null),[ze,Fe]=e.useState(0),[Ye,Ge]=e.useState(0),[qe,Xe]=e.useState(!1),Ve=e.useRef(null),Ue=e.useRef(new Map),Ze=e.useRef(0),Qe=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(!Ue.current.has(t+"")){const e=Array.isArray(z)?z:Ae;Ue.current.set(t+"",e[Ze.current++%e.length])}return Ue.current.get(t+"")}}if(!Ue.current.has(e.id)){const t=Array.isArray(z)?z:Ae;Ue.current.set(e.id,t[Ze.current++%t.length])}return Ue.current.get(e.id)},[R,z]),Ke=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?Qe(n):t?Qe(t):"#999"},[F,Qe]),Je=e.useCallback(e=>{if(!(null==B?void 0:B.colorBy))return Ke(e);const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;return"target"===He.colorBy&&n?Qe(n):t?Qe(t):"#999"},[null==B?void 0:B.colorBy,He.colorBy,Qe,Ke]),et="sankey"===a&&D||!!ke,tt=e.useCallback(()=>{Be.current&&!et||Be.current||(Be.current=requestAnimationFrame(()=>Ie.current()))},[et]);e.useEffect(()=>{var e;null===(e=Re.current)||void 0===e||e.updateConfig(Ne),Te.current=!0,tt()},[Ne,tt]);const nt=e.useCallback(()=>{const e=Re.current;if(!e)return;e.runLayout([Ce,je]),e.buildScene([Ce,je]),Te.current=!0;const t=Array.isArray(z)?z:Ae,n=Array.from(e.nodes.values());for(let e=0;n.length>e;e++){const o=n[e];Ue.current.has(o.id)||Ue.current.set(o.id,t[e%t.length])}if(Ze.current=n.length,Fe(e.layoutVersion),ce){const{nodes:t,edges:n}=e.getLayoutData();ce(t,n)}},[Ce,je,ce,z]),ot=e.useCallback(e=>{const t=Re.current;t&&(t.ingestEdge(e)&&nt(),tt())},[nt,tt]),rt=e.useCallback(e=>{const t=Re.current;if(!t)return;let n=!1;for(const o of e)t.ingestEdge(o)&&(n=!0);n&&nt(),tt()},[nt,tt]),it=e.useCallback(()=>{var e;null===(e=Re.current)||void 0===e||e.clear(),Ue.current.clear(),Ze.current=0,Fe(0),_e(null),Ve.current=null,Te.current=!0,tt()},[tt]),at=e.useCallback(()=>{const e=Re.current;e&&(e.tension+=999,nt(),tt())},[nt,tt]);e.useImperativeHandle(n,()=>({push:ot,pushMany:rt,clear:it,getTopology:()=>{var e,t;return null!==(t=null===(e=Re.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=Re.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:at,getTension:()=>{var e,t;return null!==(t=null===(e=Re.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[ot,rt,it,at]);const st=["tree","cluster","treemap","circlepack","partition"].includes(a),lt=st?u||(Array.isArray(c)?void 0:c):void 0;e.useEffect(()=>{const e=Re.current;if(e)if(st&<)e.ingestHierarchy(lt,[Ce,je]),e.buildScene([Ce,je]),Te.current=!0,tt();else{const t=l||[],n=Array.isArray(c)?c:[];if(0===t.length&&0===n.length)return;e.ingestBounded(t,n,[Ce,je]),e.buildScene([Ce,je]);const o=Array.isArray(z)?z:Ae,r=Array.from(e.nodes.values());for(let e=0;r.length>e;e++){const t=r[e];Ue.current.has(t.id)||Ue.current.set(t.id,o[e%o.length])}Ze.current=r.length,Te.current=!0,tt()}},[l,c,u,lt,st,Ce,je,Ne,tt,z]),e.useEffect(()=>{d&&d.length>0&&rt(d)},[]);const ct=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]),ut=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]),dt=e.useRef(()=>{}),ht=e.useRef(()=>{});dt.current=e=>{if(!ne)return;const t=De.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>Ce||0>r||r>je)return void(Ve.current&&(Ve.current=null,_e(null),ct&&(ct(null),Te.current=!0),tt()));const i=Re.current;if(!i)return;const a=$o(i.sceneNodes,i.sceneEdges,o,r);if(!a)return void(Ve.current&&(Ve.current=null,_e(null),ct&&(ct(null),Te.current=!0),tt()));const s={type:a.type,data:a.datum,x:a.x,y:a.y};Ve.current=s,_e(s),ct&&(ct(s),Te.current=!0),tt()},ht.current=()=>{Ve.current&&(Ve.current=null,_e(null),ct&&(ct(null),Te.current=!0),tt())};const gt=e.useRef(()=>{});gt.current=e=>{if(!ie&&!ae)return;const t=De.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>Ce||0>r||r>je)return;const i=Re.current;if(!i)return;const a=$o(i.sceneNodes,i.sceneEdges,o,r);ut(a?{type:a.type,data:a.datum,x:a.x,y:a.y}:null)},e.useCallback(e=>dt.current(e),[]);const ft=e.useCallback(()=>ht.current(),[]),yt=e.useCallback(e=>gt.current(e),[]),pt=e.useRef(-1),mt=e.useCallback(e=>{const t=Re.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=pt.current,r=I(e.key,0>o?-1:o,n.length);if(null===r)return;if(e.preventDefault(),0>r)return pt.current=-1,Ve.current=null,_e(null),ct&&(ct(null),Te.current=!0),void tt();const i=0>o?0:r;pt.current=i;const a=n[i],s={type:"node",data:a.datum,x:a.x,y:a.y};Ve.current=s,_e(s),ct&&(ct(s),Te.current=!0),tt()},[ct,tt]),vt=e.useCallback(e=>{pt.current=-1,dt.current(e)},[]);Ie.current=()=>{var e,t,n;Be.current=0;const o=De.current;if(!o)return;const r=o.getContext("2d");if(!r)return;const i=Re.current;if(!i)return;const a=performance.now(),s=We.current?Math.min((a-We.current)/1e3,.1):.016;We.current=a;const l=i.advanceTransition(a);(l||Te.current)&&i.buildScene([Ce,je]);const c="undefined"!=typeof window&&window.devicePixelRatio||1;o.width=Oe[0]*c,o.height=Oe[1]*c,o.style.width=Oe[0]+"px",o.style.height=Oe[1]+"px",r.scale(c,c),r.translate(Me.left,Me.top),r.clearRect(-Me.left,-Me.top,Oe[0],Oe[1]),te&&(r.fillStyle=te,r.fillRect(0,0,Ce,je)),xe&&i.applyDecay(),ke&&i.applyPulse(a),Se&&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":Xo(e,n);break;case"line":Vo(e,n);break;case"ribbon":Uo(e,n);break;case"curved":Zo(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),D&&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:jn.spawnRate,s=null!==(i=o.maxPerEdge)&&void 0!==i?i:jn.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,He);const t=.5*(null!==(n=He.speedMultiplier)&&void 0!==n?n:1);let o;if(He.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:jn.radius,l=null!==(a=o.opacity)&&void 0!==a?a:jn.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,He,Je)}}d&&(r.globalAlpha=1);const h=Te.current;Te.current=!1,(h||l)&&Ge(e=>e+1),(et||l||i.hasActivePulses||i.hasActiveThresholds||i.hasActiveTopologyDiff)&&(Be.current=requestAnimationFrame(()=>Ie.current()))},e.useEffect(()=>(tt(),()=>{Be.current&&(cancelAnimationFrame(Be.current),Be.current=0)}),[tt]),e.useEffect(()=>{Te.current=!0,tt()},[a,Ce,je,te,tt]),_(we,Re,Te,tt,qe,Xe);const bt=ne&&$e?f.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:Me.left+$e.x,top:Me.top+$e.y,transform:`translate(${$e.x>.6*Ce?"calc(-100% - 12px)":"12px"}, ${.3*je>$e.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2}},oe?oe($e):f.createElement(nr,{data:$e})):null;if(se){const e=Re.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,[Ce,je]),e.buildScene([Ce,je]);else{const t=l||[],n=Array.isArray(c)?c:[];(t.length>0||n.length>0)&&(e.ingestBounded(t,n,[Ce,je]),e.buildScene([Ce,je]))}}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:Oe[0],height:Oe[1]}},f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Oe[0],height:Oe[1],style:{position:"absolute",left:0,top:0}},be&&f.createElement("g",{transform:`translate(${Me.left},${Me.top})`},be),f.createElement("g",{transform:`translate(${Me.left},${Me.top})`},te&&f.createElement("rect",{x:0,y:0,width:Ce,height:je,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(qo,{width:Ce,height:je,totalWidth:Oe[0],totalHeight:Oe[1],margin:Me,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 xt=Re.current;return f.createElement("div",{ref:Le,className:"stream-network-frame"+(ee?" "+ee:""),role:"img","aria-label":"string"==typeof me?me:"Network chart",tabIndex:0,style:{position:"relative",width:Q?"100%":Oe[0],height:K?"100%":Oe[1]},onMouseMove:ne?vt:void 0,onMouseLeave:ne?ft:void 0,onClick:ie||ae?yt:void 0,onKeyDown:mt},be&&f.createElement("svg",{style:{position:"absolute",top:0,left:0,width:Oe[0],height:Oe[1],pointerEvents:"none"}},f.createElement("g",{transform:`translate(${Me.left},${Me.top})`},be)),f.createElement("canvas",{ref:De,style:{position:"absolute",top:0,left:0}}),f.createElement(qo,{width:Ce,height:je,totalWidth:Oe[0],totalHeight:Oe[1],margin:Me,labels:(null==xt?void 0:xt.labels)||[],sceneNodes:null==xt?void 0:xt.sceneNodes,title:me,legend:he,legendHoverBehavior:ge,legendClickBehavior:fe,legendHighlightedCategory:ye,legendIsolatedCategories:pe,foregroundGraphics:ve,annotations:ue,svgAnnotationRules:de,annotationFrame:Ye}),bt,(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:qe?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},qe?"STALE":"LIVE"))});function rr(t){var n;const o=it(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:S,chartId:E,selection:L,linkedHover:O,loading:M,emptyContent:C,legendInteraction:j}=t,P=o.width,H=o.height,N=o.enableHover,D=o.showLegend,B=null!==(n=o.showLabels)&&void 0!==n&&n,W=o.title,T=St(M,P,H);if(T)return T;const I=At(i,P,H,C);if(I)return I;const R=r||[],$=i||[],_=Je(R,h,g),z=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=ot(j,h,z),Y=e.useMemo(()=>e=>{const t={};return t.fill=h?Ee(e.data||e,h,_):Qe,"number"==typeof y&&(t.r=y),t},[h,_,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(B&&d)return"function"==typeof d?d:e=>e[d]},[B,d]),{legend:X,margin:V}=nt({data:R,colorBy:h,colorScale:_,showLegend:D,userMargin:a,defaults:o.marginDefaults}),{customHoverBehavior:U}=tt({selection:L,linkedHover:O,fallbackFields:h?["string"==typeof h?h:""]:[],unwrapData:!0,onObservation:S,chartType:"ForceDirectedGraph",chartId:E}),Z=Ht({componentName:"ForceDirectedGraph",nodes:r,edges:i,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:l}});return Z?f.createElement(pt,{componentName:"ForceDirectedGraph",message:Z,width:P,height:H}):f.createElement(xt,{componentName:"ForceDirectedGraph",width:P,height:H},f.createElement(or,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:B,enableHover:N,tooltipContent:w?e=>ut(w)(e.data):void 0,customHoverBehavior:O||S?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 ir(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 ar(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 sr(e){return"function"==typeof e?e:t=>t[e]||1}function lr({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=Ee(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=Ee(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 cr(t){var n;const o=it(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:S,selection:E,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,D=o.title,B=St(O,j,P);if(B)return B;const W=At(i,j,P,M);if(W)return W;const T=i||[],I=e.useMemo(()=>ar(r,T,l,c),[r,T,l,c]),R=Je(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]),_=ot(C,h,$),z=e.useMemo(()=>(e,t)=>{var n,o;const r={stroke:"black",strokeWidth:1};if(h)r.fill=Ee(e.data||e,h,R);else{const i=Array.isArray(g)?g:we[g]||Ae,a=Array.isArray(i)?i:Ae,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(()=>lr({edgeColorBy:y,colorBy:h,colorScale:R,nodeStyleFn:z,edgeOpacity:x,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:x}}),[y,h,R,z,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}=tt({selection:E,linkedHover:L,fallbackFields:h?["string"==typeof h?h:""]:[],unwrapData:!0,onObservation:A,chartType:"ChordDiagram",chartId:S}),X=Ht({componentName:"ChordDiagram",edges:i,edgesRequired:!0});return X?f.createElement(pt,{componentName:"ChordDiagram",message:X,width:j,height:P}):f.createElement(xt,{componentName:"ChordDiagram",width:j,height:P},f.createElement(or,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:z,edgeStyle:F,colorBy:h,colorScheme:g,edgeColorBy:y,edgeOpacity:x,nodeLabel:Y,showLabels:N,enableHover:H,tooltipContent:k?e=>ut(k)(e.data):void 0,customHoverBehavior:L||A?q:void 0},C&&"none"!==C&&{legendHoverBehavior:_.onLegendHover,legendClickBehavior:_.onLegendClick,legendHighlightedCategory:_.highlightedCategory,legendIsolatedCategories:_.isolatedCategories},{className:s,title:D},w)))}function ur(t){var n;const o=it(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:S={},onObservation:E,chartId:L,selection:O,linkedHover:M,loading:C,emptyContent:j,legendInteraction:P}=t,H=o.width,N=o.height,D=o.enableHover,B=null===(n=o.showLabels)||void 0===n||n,W=o.title,T=St(C,H,N);if(T)return T;const I=At(i,H,N,j);if(I)return I;const R=i||[],$=e.useMemo(()=>ar(r,R,l,c),[r,R,l,c]),_=Je($,h,g),z=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=ot(P,h,z),Y=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=h?Ee(e.data||e,h,_):"#4d430c",t},[h,_]),G=e.useMemo(()=>lr({edgeColorBy:y,colorBy:h,colorScale:_,nodeStyleFn:Y,edgeOpacity:k,baseStyle:{stroke:"none",strokeWidth:0}}),[y,h,_,Y,k]),q=e.useMemo(()=>{if(!B)return;const e=x||d;return"function"==typeof e?e:t=>t[e]},[B,x,d]),X=Object.assign(Object.assign({},o.marginDefaults),a),{customHoverBehavior:V,customClickBehavior:U}=tt({selection:O,linkedHover:M,fallbackFields:h?["string"==typeof h?h:""]:[],unwrapData:!0,onObservation:E,chartType:"SankeyDiagram",chartId:L}),Z=Ht({componentName:"SankeyDiagram",edges:i,edgesRequired:!0});return Z?f.createElement(pt,{componentName:"SankeyDiagram",message:Z,width:H,height:N}):f.createElement(xt,{componentName:"SankeyDiagram",width:H,height:N},f.createElement(or,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:B,enableHover:D,tooltipContent:A?e=>ut(A)(e.data):void 0,customHoverBehavior:M||E?V:void 0,customClickBehavior:E?U:void 0},P&&"none"!==P&&{legendHoverBehavior:F.onLegendHover,legendClickBehavior:F.onLegendClick,legendHighlightedCategory:F.highlightedCategory,legendIsolatedCategories:F.isolatedCategories},{className:s,title:W},S)))}function dr(t){var n;const o=it(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:S,loading:E,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=St(E,O,M);if(H)return H;const N=e.useMemo(()=>ir(r,c),[r,c]),D=Je(N,y?void 0:h,g),B=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=ot(L,y?void 0:h,B),T=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=y?Se[(e.depth||0)%Se.length]:h?Ee(e.data||e,h,D):Qe,t},[h,y,D]),I=e.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),R=e.useMemo(()=>{if("treemap"===s||"circlepack"===s||"partition"===s)return sr(u)},[s,u]),$=Object.assign(Object.assign({},o.marginDefaults),i),{customHoverBehavior:_}=tt({selection:A,linkedHover:S,fallbackFields:h?["string"==typeof h?h:""]:[],unwrapData:!0,onObservation:k,chartType:"TreeDiagram",chartId:w}),z=Pt({componentName:"TreeDiagram",data:r});return z?f.createElement(pt,{componentName:"TreeDiagram",message:z,width:O,height:M}):f.createElement(xt,{componentName:"TreeDiagram",width:O,height:M},f.createElement(or,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=>ut(b)(e.data):void 0,customHoverBehavior:S||k?_:void 0},L&&"none"!==L&&{legendHoverBehavior:W.onLegendHover,legendClickBehavior:W.onLegendClick,legendHighlightedCategory:W.highlightedCategory,legendIsolatedCategories:W.isolatedCategories},{className:a,title:P},x)))}function hr(t){var n;const o=it(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:S,legendInteraction:E}=t,L=o.width,O=o.height,M=o.enableHover,C=null===(n=o.showLabels)||void 0===n||n,j=o.title,P=St(S,L,O);if(P)return P;const{activeSelectionHook:H,customHoverBehavior:N}=tt({selection:x,linkedHover:k,fallbackFields:u?["string"==typeof u?u:""]:[],onObservation:w,chartType:"Treemap",chartId:A}),D=e.useCallback(e=>{if(!e)return N(null);const t=e.data||e;N({data:(null==t?void 0:t.data)||t})},[N]),B=e.useMemo(()=>ir(r,s),[r,s]),W=Je(B,h?void 0:u,d),T=e.useMemo(()=>{if(!u||h)return[];const e=new Set;for(const t of B){const n="function"==typeof u?u(t):t[u];null!=n&&e.add(n+"")}return Array.from(e)},[B,u,h]),I=ot(E,h?void 0:u,T),R=e.useMemo(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=h?Se[(e.depth||0)%Se.length]:u?Ee(e.data||e,u,W):Qe,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]),_=e.useMemo(()=>sr(l),[l]),z=void 0!==m?m:C&&"parent"===g?18:void 0,F=Object.assign(Object.assign({},o.marginDefaults),i),Y=Pt({componentName:"Treemap",data:r});return Y?f.createElement(pt,{componentName:"Treemap",message:Y,width:L,height:O}):f.createElement(xt,{componentName:"Treemap",width:L,height:O},f.createElement(or,Object.assign({chartType:"treemap",data:r,size:[L,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:F,nodeIDAccessor:c,childrenAccessor:s,hierarchySum:_,padding:p,paddingTop:z,nodeStyle:$,colorBy:u,colorScheme:d,colorByDepth:h,nodeLabel:C?y||c:void 0,showLabels:C,enableHover:M,tooltipContent:v?e=>ut(v)(e.data):void 0},(k||w)&&{customHoverBehavior:D},E&&"none"!==E&&{legendHoverBehavior:I.onLegendHover,legendClickBehavior:I.onLegendClick,legendHighlightedCategory:I.highlightedCategory,legendIsolatedCategories:I.isolatedCategories},{className:a,title:j},b)))}function gr(t){var n;const o=it(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:S}=t,E=o.width,L=o.height,O=o.enableHover,M=null===(n=o.showLabels)||void 0===n||n,C=o.title,j=St(A,E,L);if(j)return j;const P=e.useMemo(()=>ir(r,s),[r,s]),H=Je(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]),D=ot(S,h?void 0:u,N),B=e.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:y};return t.fill=h?Se[(e.depth||0)%Se.length]:u?Ee(e.data||e,u,H):Qe,t},[u,h,H,y]),W=e.useMemo(()=>sr(l),[l]),T=Object.assign(Object.assign({},o.marginDefaults),i),{customHoverBehavior:I}=tt({selection:k,linkedHover:w,fallbackFields:u?["string"==typeof u?u:""]:[],unwrapData:!0,onObservation:b,chartType:"CirclePack",chartId:x}),R=Pt({componentName:"CirclePack",data:r});return R?f.createElement(pt,{componentName:"CirclePack",message:R,width:E,height:L}):f.createElement(xt,{componentName:"CirclePack",width:E,height:L},f.createElement(or,Object.assign({chartType:"circlepack",data:r,size:[E,L],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:T,nodeIDAccessor:c,childrenAccessor:s,hierarchySum:W,padding:p,nodeStyle:B,colorBy:u,colorScheme:d,colorByDepth:h,nodeLabel:M?g||c:void 0,showLabels:M,enableHover:O,tooltipContent:m?e=>ut(m)(e.data):void 0,customHoverBehavior:w||b?I:void 0},S&&"none"!==S&&{legendHoverBehavior:D.onLegendHover,legendClickBehavior:D.onLegendClick,legendHighlightedCategory:D.highlightedCategory,legendIsolatedCategories:D.isolatedCategories},{className:a,title:C},v)))}or.displayName="StreamNetworkFrame",rr.displayName="ForceDirectedGraph",cr.displayName="ChordDiagram",ur.displayName="SankeyDiagram",dr.displayName="TreeDiagram",hr.displayName="Treemap",gr.displayName="CirclePack";const fr=["#93c5fd","#fca5a5","#86efac","#fde68a","#c4b5fd","#f9a8d4","#a5f3fc"];function yr(t){const n=it(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:S,linkedHover:E,onObservation:L,chartId:O,loading:M}=t,C=n.width,j=n.height,P=n.title,H=St(M,C,j);if(H)return H;const N=e.useMemo(()=>"function"==typeof r?r:e=>e[r],[r]),D=e.useMemo(()=>"function"==typeof i?i:e=>{var t;return(null!==(t=e[i])&&void 0!==t?t:"")+""},[i]),B=e.useMemo(()=>"function"==typeof m?m:()=>m,[m]),{customHoverBehavior:W}=tt({selection:S,linkedHover:E,fallbackFields:a?["string"==typeof a?a:""]:[],onObservation:L,chartType:"OrbitDiagram",chartId:O}),T=Je(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,D,u,d,y),[o,C,j,N,D,u,d,y]),[,_]=e.useState(0),z=e.useRef(0),F=h*(Math.PI/360);e.useEffect(()=>{if(!b)return;let e;const t=()=>{z.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,z.current,F,g,$),_(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?fr[e.depth%fr.length]:a?Ee(e.datum,a,T):Qe,[a,c,T]),V=Pt({componentName:"OrbitDiagram",data:o});return V?f.createElement(pt,{componentName:"OrbitDiagram",message:V,width:C,height:j}):f.createElement(xt,{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=B(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},D(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,D(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)))}yr.displayName="OrbitDiagram";const pr=e.forwardRef(function(t,n){var o,r,i,a;const s=it(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:S,tooltipContent:E,tooltip:L,onHover:O,annotations:M,svgAnnotationRules:C,tickFormatTime:j,tickFormatValue:P,decay:H,pulse:N,staleness:D,transition:B,linkedHover:W,onObservation:T,chartId:I}=t,R=s.showAxes,$=s.enableHover,_=null!=c?c:s.marginDefaults,z=null!=l?l:[s.width,s.height],F=null!=E?E:L,Y=e.useRef(null),{customHoverBehavior:G}=tt({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:z,margin:_,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:S,hoverAnnotation:$,tooltipContent:F,customHoverBehavior:q,annotations:M,svgAnnotationRules:C,tickFormatTime:j,tickFormatValue:P,decay:H,pulse:N,staleness:D,transition:B})});pr.displayName="RealtimeLineChart";const mr=e.forwardRef(function(t,n){var o,r,i,a;const s=it(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:S,stroke:E,strokeWidth:L,gap:O,background:M,tooltipContent:C,tooltip:j,onHover:P,annotations:H,svgAnnotationRules:N,tickFormatTime:D,tickFormatValue:B,linkedHover:W,decay:T,pulse:I,staleness:R,transition:$,onObservation:_,chartId:z}=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}=tt({linkedHover:W,unwrapData:!0,onObservation:_,chartType:"RealtimeTemporalHistogram",chartId:z}),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!=S&&(Q.fill=S),null!=E&&(Q.stroke=E),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:D,tickFormatValue:B,decay:T,pulse:I,staleness:R,transition:$})});mr.displayName="RealtimeTemporalHistogram";const vr=mr,br=e.forwardRef(function(t,n){var o,r,i,a;const s=it(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:S,opacity:E,stroke:L,strokeWidth:O,background:M,tooltipContent:C,tooltip:j,onHover:P,annotations:H,svgAnnotationRules:N,tickFormatTime:D,tickFormatValue:B,linkedHover:W,onObservation:T,chartId:I}=t,R=s.showAxes,$=s.enableHover,_=null!=c?c:s.marginDefaults,z=null!=l?l:[s.width,s.height],F=null!=C?C:j,Y=e.useRef(null),{customHoverBehavior:G}=tt({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!=S&&(X.fill=S),null!=E&&(X.opacity=E),null!=L&&(X.stroke=L),null!=O&&(X.strokeWidth=O),f.createElement(ke,{ref:Y,chartType:"swarm",runtimeMode:"streaming",size:z,margin:_,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:D,tickFormatValue:B})});br.displayName="RealtimeSwarmChart";const xr=e.forwardRef(function(t,n){var o,r,i,a;const s=it(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:S,gap:E,stroke:L,strokeWidth:O,background:M,tooltipContent:C,tooltip:j,onHover:P,annotations:H,svgAnnotationRules:N,tickFormatTime:D,tickFormatValue:B,linkedHover:W,onObservation:T,chartId:I}=t,R=s.showAxes,$=s.enableHover,_=null!=c?c:s.marginDefaults,z=null!=l?l:[s.width,s.height],F=null!=C?C:j,Y=e.useRef(null),{customHoverBehavior:G}=tt({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!=S&&(X.connectorWidth=S),null!=E&&(X.gap=E),null!=L&&(X.stroke=L),null!=O&&(X.strokeWidth=O),f.createElement(ke,{ref:Y,chartType:"waterfall",runtimeMode:"streaming",size:z,margin:_,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:D,tickFormatValue:B})});xr.displayName="RealtimeWaterfallChart";const kr=e.forwardRef(function(t,n){var o,r,i,a;const s=it(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:S="count",background:E,tooltipContent:L,tooltip:O,onHover:M,annotations:C,svgAnnotationRules:j,tickFormatTime:P,tickFormatValue:H,decay:N,pulse:D,staleness:B,linkedHover:W,onObservation:T,chartId:I}=t,R=s.showAxes,$=s.enableHover,_=null!=c?c:s.marginDefaults,z=null!=l?l:[s.width,s.height],F=null!=L?L:O,Y=e.useRef(null),{customHoverBehavior:G}=tt({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:z,margin:_,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:S,showAxes:R,background:E,hoverAnnotation:$,tooltipContent:F,customHoverBehavior:q,annotations:C,svgAnnotationRules:j,tickFormatTime:P,tickFormatValue:H,decay:N,pulse:D,staleness:B})});kr.displayName="RealtimeHeatmap";let[wr]=He(e=>({tooltip:null,changeTooltip(t){e(()=>({tooltip:t}))}}));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}},Sr={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}},[Er,Lr]=He(e=>({theme:Ar,setTheme(t){e(e=>"light"===t?{theme:Ar}:"dark"===t?{theme:Sr}:{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"}},Dr={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},Br={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),Dr),{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),Dr),{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),Dr),{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),Dr),{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),Dr),{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),Dr),{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),Dr),{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),Br),{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),Br),{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),Br),{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),Br),{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),Br),{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),Br),{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),Br),{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),Br),{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"}}}};function Rr(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}function $r(e,t){const n=[],o=Ir[e];if(!o)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(Ir).join(", ")}`]};for(const r of o.required)null==t[r]&&n.push(`"${r}" is required for ${e}.`);for(const[e,r]of Object.entries(t)){if(null==r)continue;const t=o.props[e];if(t){if(!Rr(r,t.type)){const o=Array.isArray(t.type)?t.type.join(" | "):t.type;n.push(`"${e}" should be ${o}, got ${Array.isArray(r)?"array":typeof r}.`);continue}t.enum&&"string"==typeof r&&!t.enum.includes(r)&&n.push(`"${e}" value "${r}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const r=Object.keys(o.props),i=new Set(r);for(const o of Object.keys(t))if(void 0!==t[o]&&!i.has(o)){const t=Ot(o,r),i=t?`Unknown prop "${o}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${o}" for ${e}. Valid props: ${r.join(", ")}.`;n.push(i)}if("array"===o.dataShape){const r=t.data,i={};for(const e of o.dataAccessors){const n=t[e];"string"==typeof n&&(i[e]=n)}const a=jt({componentName:e,data:r,accessors:Object.keys(i).length>0?i:void 0});a&&n.push(a)}else if("object"===o.dataShape){const o=Pt({componentName:e,data:t.data});o&&n.push(o)}else if("network"===o.dataShape){const r=Ht({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:o.required.includes("nodes"),edgesRequired:o.required.includes("edges")});r&&n.push(r)}return{valid:0===n.length,errors:n}}const _r=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"]),zr=new Set(["data","nodes","edges"]),Fr="function"==typeof structuredClone?structuredClone:e=>JSON.parse(JSON.stringify(e));function Yr(e){return Cr(this,arguments,void 0,function*(e,t="json"){const n="jsx"===t?Gr(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 Gr(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")}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 Xr({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 Vr({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 Ur=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,S="object"==typeof(null==i?void 0:i.export)?i.export:{},E="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({},S),e)))}),[S]),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 Yr(a,e||E||"json"))}),[a,E]);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(Xr,{height:r}):c?f.createElement(Vr,{error:c}):u?f.createElement(mt,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:Zr},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:Zr},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:Zr},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)))}),Zr={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 Qr({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 Kr({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))}Qr.displayName="ChartGrid",Kr.displayName="ContextLayout";function Jr({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:S}=Ye({types:A,chartId:i,limit:1}),E=void 0!==a?a:S;e.useEffect(()=>{if(E)if("click"===E.type||"hover"===E.type){const e=E;g(e.datum),p(e),m||(v(!0),x(!0),clearTimeout(w.current),w.current=setTimeout(()=>x(!1),200))}else!s||"click-end"!==E.type&&"hover-end"!==E.type||L()},[E]),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:ei},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 ei={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};Jr.displayName="DetailsPanel";const ti=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),ni=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),oi=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),ri=new Set(["LineChart","AreaChart","StackedAreaChart"]);function ii(e){return"nominal"===e||"ordinal"===e}function ai(e){return"quantitative"===e||"temporal"===e}const si={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"},li={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"},ci={sum:"sum",mean:"mean",average:"mean",count:"count",min:"min",max:"max",median:"mean"};function ui(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 di(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}exports.AreaChart=Wt,exports.BarChart=vn,exports.BoxPlot=wn,exports.BubbleChart=$t,exports.CategoryColorProvider=Ce,exports.ChartContainer=Ur,exports.ChartGrid=Qr,exports.ChordDiagram=cr,exports.CirclePack=gr,exports.ConnectedScatterplot=Rt,exports.ContextLayout=Kr,exports.DetailsPanel=Jr,exports.DonutChart=Mn,exports.DotPlot=En,exports.ForceDirectedGraph=rr,exports.GroupedBarChart=xn,exports.Heatmap=_t,exports.Histogram=An,exports.LineChart=Bt,exports.LinkedCharts=Ve,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=st(e,n);l.push({value:lt(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=lt(st(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:lt(e[t],o)})});const c=Object.assign(Object.assign({},at),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=yr,exports.PieChart=On,exports.RealtimeHeatmap=kr,exports.RealtimeHistogram=vr,exports.RealtimeLineChart=pr,exports.RealtimeSwarmChart=br,exports.RealtimeWaterfallChart=xr,exports.RidgelinePlot=Ln,exports.SankeyDiagram=ur,exports.Scatterplot=It,exports.ScatterplotMatrix=Ut,exports.StackedAreaChart=Tt,exports.StackedBarChart=bn,exports.SwarmPlot=kn,exports.ThemeProvider=function({theme:e,children:t}){return f.createElement(Er,null,f.createElement(Or,{theme:e}),f.createElement(Mr,null,t))},exports.TooltipProvider=wr,exports.TreeDiagram=dr,exports.Treemap=hr,exports.ViolinPlot=Sn,exports.configToJSX=Gr,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.diagnoseConfig=function(e,t){const n=[],o=$r(e,t);for(const e of o.errors)n.push({severity:"error",code:"VALIDATION",message:e,fix:""});return Ir[e]?(function(e,t,n){const o=Ir[e];if(o){if("array"===o.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&n.push({severity:"error",code:"EMPTY_DATA",message:"data is an empty array — chart will render blank.",fix:"Provide at least one data point: data={[{ x: 1, y: 2 }]}."})}"network"===o.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&n.push({severity:"error",code:"EMPTY_EDGES",message:"edges is an empty array — network chart will render blank.",fix:'Provide at least one edge: edges={[{ source: "A", target: "B" }]}.'})}}(e,t,n),function(e,t,n){const o=t.width,r=t.height;if(void 0===o||"number"==typeof o&&o>0||n.push({severity:"error",code:"BAD_WIDTH",message:`width=${JSON.stringify(o)} — chart needs a positive number.`,fix:"Set width={600} or use responsiveWidth={true}."}),void 0===r||"number"==typeof r&&r>0||n.push({severity:"error",code:"BAD_HEIGHT",message:`height=${JSON.stringify(r)} — chart needs a positive number.`,fix:"Set height={400} or use responsiveHeight={true}."}),t.size&&Array.isArray(t.size)){const[e,o]=t.size;(null!=e&&0>=e||null!=o&&0>=o)&&n.push({severity:"error",code:"BAD_SIZE",message:`size=[${e}, ${o}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}(0,t,n),function(e,t,n){const o=Ir[e];if(!o||"array"!==o.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const i=r[0];if(!i||"object"!=typeof i)return;const a=Object.keys(i);for(const e of o.dataAccessors){const o=t[e];"string"==typeof o&&(o in i||n.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${o}" not found in data. Available fields: ${a.join(", ")}.`,fix:`Change ${e} to one of: ${a.map(e=>`"${e}"`).join(", ")}.`}))}}(e,t,n),function(e,t,n){ti.has(e)&&Array.isArray(t.data)&&n.push({severity:"error",code:"HIERARCHY_FLAT_ARRAY",message:e+" expects hierarchical data but received a flat array.",fix:'Pass a root object: data={{ name: "root", children: [...] }}. For flat data, use BarChart or LineChart.'})}(e,t,n),function(e,t,n){ni.has(e)&&(t.edges||t.data||n.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}(e,t,n),function(e,t,n){const o=Ir[e];if(!o||"array"!==o.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const i=r[0];if(!i||"object"!=typeof i)return;const a=t.xAccessor;"string"==typeof a&&i[a]instanceof Date&&!t.xFormat&&n.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${a}" contains Date objects but no xFormat is provided. Axis ticks may display "[object Object]".`,fix:"Add xFormat={d => d.toLocaleDateString()} or use timestamps (d.getTime()) instead of Date objects."})}(e,t,n),function(e,t,n){t.linkedHover&&!t.selection&&n.push({severity:"warning",code:"LINKED_HOVER_NO_SELECTION",message:"linkedHover is set but selection is not — this chart emits hover events but won't highlight from others.",fix:`Add selection={{ name: "${"object"==typeof t.linkedHover&&t.linkedHover.name||"hl"}" }} to receive cross-highlights.`})}(0,t,n),function(e,t,n){var o;if(!oi.has(e))return;const r=t.rExtent||t.yExtent;r&&Array.isArray(r)&&r.length>=1&&null!=r[0]&&0!==r[0]&&n.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${r[0]}). Bar and area charts should start at zero to avoid exaggerating differences.`,fix:`Remove the custom extent minimum or set it to 0: rExtent={[0, ${null!==(o=r[1])&&void 0!==o?o:"auto"}]}. For trend-focused charts, use LineChart instead.`})}(e,t,n),function(e,t,n){if(!ri.has(e))return;if(t.gapStrategy)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const r=t.yAccessor||"y";"string"==typeof r&&o.some(e=>{const t=e[r];return null==t||Number.isNaN(t)})&&n.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${r}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}(e,t,n),function(e,t,n){var o,r;const i=null!==(o=t.width)&&void 0!==o?o:600,a=null!==(r=t.height)&&void 0!==r?r:400,s=t.margin;if(!s||"object"!=typeof s)return;const l=(s.left||0)+(s.right||0),c=(s.top||0)+(s.bottom||0);i>l||n.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${l}px) >= width (${i}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),a>c||n.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${c}px) >= height (${a}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}(0,t,n),{ok:n.every(e=>"warning"===e.severity),diagnoses:n}):{ok:0===n.length,diagnoses:n}},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: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,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,S=v.opacity;let E;(null===(t=e.data)||void 0===t?void 0:t.values)?E=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=si[k.scale.scheme];e&&(L.colorScheme=e)}void 0!==(null==S?void 0:S.value)&&(L.pointOpacity=S.value);const M=null==b?void 0:b.aggregate,C=null==x?void 0:x.aggregate;if(E&&(M||C)){const e=C?x:b,t=C?b:x,n=ci[e.aggregate];if(n&&(null==t?void 0:t.field)&&e.field)E=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}(E,{groupBy:t.field,value:e.field,agg:n});else if(("count"===n||"count"===e.aggregate)&&(null==t?void 0:t.field)&&E){const e=new Map;for(const n of E){const o=n[t.field]+"";e.set(o,(e.get(o)||0)+1)}E=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";E&&(L.data=E),(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),di(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",ii(null==e?void 0:e.type)&&ai(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)):ai(null==e?void 0:e.type)&&ii(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,E,M,C);break;case"line":if(j="LineChart",ui(b,x,L,M,C),(null==k?void 0:k.field)&&(L.lineBy=k.field),m.interpolate){const e=li[m.interpolate];e&&(L.curve=e)}!0===m.point&&(L.showPoints=!0),E&&(L.data=E);break;case"area":if((null==k?void 0:k.field)?(j="StackedAreaChart",L.areaBy=k.field):j="AreaChart",ui(b,x,L,M,C),m.interpolate){const e=li[m.interpolate];e&&(L.curve=e)}void 0!==m.opacity&&(L.areaOpacity=m.opacity),E&&(L.data=E);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",ui(b,x,L,M,C),E&&(L.data=E);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),E&&(L.data=E);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),E&&(L.data=E);break;case"tick":j="DotPlot",ii(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)):ii(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)),E&&(L.data=E);break;default:y.push(`Unsupported mark type "${p}". Defaulting to Scatterplot.`),j="Scatterplot",ui(b,x,L,M,C),E&&(L.data=E)}return di(j,L,y)},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.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&&(_r.has(e)||!o&&zr.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=Fe,exports.useCategoryColors=je,exports.useChartObserver=Ye,exports.useFilteredData=function(t,n,o){const r=Ie(e=>e.selections.get(n));return e.useMemo(()=>{if(!r||0===r.clauses.size)return t;const e=Be(r,o);return t.filter(e)},[t,r,o])},exports.useLinkedHover=ze,exports.useSelection=_e,exports.useTheme=function(){return Lr(e=>e.theme)},exports.validateProps=$r;
|
|
1
|
+
"use strict";const e=require("react"),t=require("d3-brush"),n=require("d3-selection"),o=require("d3-scale"),r=require("d3-scale-chromatic"),i=require("d3-quadtree"),a=require("d3-array"),s=require("d3-hierarchy"),l=require("d3-shape"),c=require("regression"),u=require("d3-interpolate"),d=require("d3-force"),h=require("d3-chord");function g(e){return e&&e.__esModule?e:{default:e}}function f(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 p=f(e),y=g(c);class m{constructor(e,t){var n,o;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=null!==(n=null==t?void 0:t.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(o=null==t?void 0:t.chunkSize)&&void 0!==o?o:5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const o=Math.min(t+this.chunkSize,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)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){this.pushBuffer.push(e),this.scheduleFlush()}pushMany(e){if(0!==e.length){for(let t=0;e.length>t;t++)this.pushBuffer.push(e[t]);this.scheduleFlush()}}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}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}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];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 S(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 E(e,t,n,o,r,i,a){const s={type:"heatcell",x:e,y:t,w:n,h:o,fill:r,datum:i};return(null==a?void 0:a.showValues)&&(s.showValues=!0,s.value=a.value,a.valueFormat&&(s.valueFormat=a.valueFormat)),s}function O(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function M(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function P(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}const C={category10:r.schemeCategory10,tableau10:r.schemeTableau10,set3:r.schemeSet3,blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,oranges:r.interpolateOranges,purples:r.interpolatePurples,viridis:r.interpolateViridis,plasma:r.interpolatePlasma},L=r.schemeCategory10,j=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],N=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],D=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function _(e,t,n){if("function"==typeof t){const o=t(e);return n&&o&&"string"==typeof o&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||D.has(t)}(o)?n(o):o}const o=e[t];return n?n(o):L[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+""))%L.length]}function B(e,t,n="category10"){const r=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e))),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=C[n]||C.category10;if(i&&"function"==typeof a){let e=-1/0;for(const t of r){const n=Number(t);n>e&&(e=n)}return t=>a(Number(t)/e)}{const e=Array.isArray(a)?a:L;return o.scaleOrdinal().domain(r).range(e).unknown("#999")}}function H(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)}function R(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function T(e,t){return Math.min((e-t.startTime)/t.duration,1)}function W(e,t,n){return e+(t-e)*n}function I(){return"undefined"!=typeof performance?performance.now():Date.now()}class ${constructor(e){this.xExtent=new b,this.yExtent=new b,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this._quadtree=null,this.config=e,this.buffer=new v(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=O(e.timeAccessor||e.xAccessor,"time"),this.getY=O(e.valueAccessor||e.yAccessor,"value")):(this.getX=O(e.xAccessor,"x"),this.getY=O(e.yAccessor,"y")),this.getGroup=P(e.groupAccessor),this.getCategory=P(e.categoryAccessor),this.getSize=e.sizeAccessor?O(e.sizeAccessor,"size"):void 0,this.getColor=P(e.colorAccessor),this.getBounds=e.boundsAccessor?O(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?O(e.y0Accessor,"y0"):void 0,this.getPointId=P(e.pointIdAccessor),"candlestick"===e.chartType&&(this.getOpen=O(e.openAccessor,"open"),this.getHigh=O(e.highAccessor,"high"),this.getLow=O(e.lowAccessor,"low"),this.getClose=O(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,this._bufferDirty=!0,this._ingestVersion++,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){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity||1e6;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),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.getBufferArray(),d=this.xExtent.extent,h=this.yExtent.extent;let g=l.xExtent?[null!==(t=l.xExtent[0])&&void 0!==t?t:d[0],null!==(n=l.xExtent[1])&&void 0!==n?n:d[1]]:d,f=l.yExtent?[null!==(r=l.yExtent[0])&&void 0!==r?r:h[0],null!==(i=l.yExtent[1])&&void 0!==i?i:h[1]]:h;const p=l.yExtent&&null!=l.yExtent[0]&&null!=l.yExtent[1];if("stackedarea"===l.chartType&&!p&&c.size>0)if(l.normalize)f=[0,1+l.extentPadding];else{const e=`${c.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===e)f=this._stackExtentCache.yDomain;else{const t=this.groupData(u),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);f=[0,o+(o>0?o*l.extentPadding:1)],this._stackExtentCache={key:e,yDomain:f}}}else if("bar"===l.chartType&&l.binSize&&!p&&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);f=[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;f=[Math.min(0,e-Math.abs(o)),Math.max(0,t+Math.abs(o))]}else if(!p&&f[0]!==1/0){if(this.getBounds)for(const e of u){const t=this.getY(e),n=this.getBounds(e);null!=t&&!Number.isNaN(t)&&n&&(t+n>f[1]&&(f[1]=t+n),f[0]>t-n&&(f[0]=t-n))}const e=f[1]-f[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];f=[null!=n?f[0]:f[0]-t,null!=o?f[1]:f[1]+t],"log"===l.yScaleType&&0>=f[0]&&h[0]>0&&(f[0]=null!=n?f[0]:h[0]/(1+l.extentPadding))}if(g[0]!==1/0&&g[1]!==-1/0||(g=[0,1]),f[0]!==1/0&&f[1]!==-1/0||(f=[0,1]),"streaming"===l.runtimeMode)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(g).range(t),y:o.scaleLinear().domain(f).range([e.height,0])}}else{const t="down"===l.arrowOfTime?[0,e.height]:[e.height,0];this.scales={x:o.scaleLinear().domain(f).range([0,e.width]),y:o.scaleLinear().domain(g).range(t)}}else{const t=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return o.scaleLog().domain(e).range(n).clamp(!0)}return o.scaleLinear().domain(t).range(n)};this.scales={x:t(l.xScaleType,g,[0,e.width]),y:t(l.yScaleType,f,[e.height,0])}}var y;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(e,u),this.config.decay&&this.applyDecay(this.scene,u),this.config.pulse&&this.applyPulse(this.scene,u),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}rebuildQuadtree(){const e=this.config.chartType;if("scatter"!==e&&"bubble"!==e)return void(this._quadtree=null);const t=this.scene.filter(e=>"point"===e.type);this._quadtree=t.length>$.QUADTREE_THRESHOLD?i.quadtree().x(e=>e.x).y(e=>e.y).addAll(t):null}get quadtree(){return this._quadtree}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(),l=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return o.scaleLog().domain(e).range(n).clamp(!0)}return o.scaleLinear().domain(t).range(n)};this.scales={x:l(this.config.xScaleType,r,[a[0]*t,a[1]*t]),y:l(this.config.yScaleType,i,[s[0]*n,s[1]*n])},this.lastLayout={width:e.width,height:e.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(e,t){const{config:n,scales:o}=this;if(!o||0===t.length)return[];switch(n.chartType){case"line":return this.buildLineScene(t);case"area":return this.buildAreaScene(t);case"stackedarea":return this.buildStackedAreaScene(t);case"scatter":case"bubble":return this.buildPointScene(t);case"heatmap":return this.buildHeatmapScene(t,e);case"bar":return this.buildBarScene(t);case"swarm":return this.buildSwarmScene(t);case"waterfall":return this.buildWaterfallScene(t,e);case"candlestick":return this.buildCandlestickScene(t,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),this.config.curve&&"linear"!==this.config.curve&&(n.curve=this.config.curve),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),this.config.curve&&"linear"!==this.config.curve&&(r.curve=this.config.curve),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,a){var s;const l=new Set;for(const t of e)for(const e of t.data){const t=n(e);null==t||Number.isNaN(t)||l.add(t)}const c=Array.from(l).sort((e,t)=>e-t),u=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)}u.set(t.key,e)}let d;if(i){d=new Map;for(const t of c){let n=0;for(const o of e)n+=(null===(s=u.get(o.key))||void 0===s?void 0:s.get(t))||0;d.set(t,n||1)}}const h=[],g=new Map;for(const e of c)g.set(e,0);for(const n of e){const e=u.get(n.key),o=[],s=[];for(const n of c){let r=e.get(n)||0;const a=g.get(n);i&&(r/=d.get(n));const l=t.x(n);s.push([l,t.y(a)]),o.push([l,t.y(a+r)]),g.set(n,a+r)}const l={type:"area",topPath:o,bottomPath:s,style:r(n.key,n.data[0]),datum:n.data,group:n.key};a&&(l.curve=a),h.push(l)}return h}(t,this.scales,this.getX,this.getY,(e,t)=>this.resolveAreaStyle(e,t),this.config.normalize,this.config.curve&&"linear"!==this.config.curve?this.config.curve:void 0)}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){let e=1/0,n=-1/0;for(const o of t)e>o&&(e=o),o>n&&(n=o);r=t=>e===n?(o[0]+o[1])/2:o[0]+(t-e)/(n-e)*(o[1]-o[0])}}const i=this.getColor?this.resolveColorMap(e):null;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&&!e.fill){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 i=O(this.config.valueAccessor,"value"),a=M(this.config.xAccessor,"x"),s=M(this.config.yAccessor,"y"),l=new Set,c=new Set;for(const t of e)l.add(a(t)),c.add(s(t));const u=Array.from(l),d=Array.from(c),h=u.every(e=>"number"==typeof e&&!isNaN(e)),g=d.every(e=>"number"==typeof e&&!isNaN(e)),f=h?u.sort((e,t)=>e-t):u,p=g?d.sort((e,t)=>e-t):d;if(0===f.length||0===p.length)return n;const y=t.width/f.length,m=t.height/p.length,v=new Map;for(const t of e){const e=`${a(t)}\0${s(t)}`;v.set(e,{val:i(t),datum:t})}let b=1/0,x=-1/0;for(const{val:e}of v.values())b>e&&(b=e),e>x&&(x=e);const k=o.scaleSequential({blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,viridis:r.interpolateViridis}["string"==typeof this.config.colorScheme?this.config.colorScheme:"blues"]||r.interpolateBlues).domain([b,x]);for(let e=0;f.length>e;e++)for(let t=0;p.length>t;t++){const o=v.get(`${f[e]}\0${p[t]}`);if(!o)continue;const r=k(o.val);n.push(E(e*y,(p.length-1-t)*m,y,m,r,o.datum,this.config.showValues?{value:o.val,showValues:!0,valueFormat:this.config.heatmapValueFormat}:void 0))}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=O(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,p=(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)/f),a-1),r=Math.min(Math.floor((n-h)/p),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,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=y.get(e);i.push(E(r*k,(s-1-a)*w,k,w,c,{xi:r,yi:a,value:t,count:u.count,sum:u.sum,data:u.data},this.config.showValues?{value:t,showValues:!0,valueFormat:this.config.heatmapValueFormat}:void 0))}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(),a=t.filter(t=>e.has(t)),s=a.join("\0")+""+i.join("\0");this._barCategoryCache&&this._barCategoryCache.key===s?o=this._barCategoryCache.order:(o=[...a,...i],this._barCategoryCache={key:s,order:o})}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.abs(u-c),h=d>2?1:0,g=Math.min(c,u)+h/2,f=Math.max(d-h,1);if(f>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(S(g,Math.min(s,l),f,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(S(g,Math.min(t,n),f,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),p=f+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){f=p;continue}const k=a.y(f),w=a.y(p);i.push(S(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:p,delta:r,_connectorStroke:null==s?void 0:s.connectorStroke,_connectorWidth:null==s?void 0:s.connectorWidth}))),f=p}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){const e=Array.isArray(t.datum)?t.datum:[];if(2>e.length)continue;const n=Array(e.length);let o=!1;for(let t=0;e.length>t;t++){const a=i.get(e[t]);null!=a?(n[t]=this.computeDecayOpacity(a,r),1>n[t]&&(o=!0)):n[t]=1}o&&(t._decayOpacities=n);continue}if("area"===t.type){const e=Array.isArray(t.datum)?t.datum:[],n=t.topPath?t.topPath.length:e.length;if(2>n)continue;if(e.length===n){const o=Array(n);let a=!1;for(let t=0;e.length>t;t++){const n=i.get(e[t]);null!=n?(o[t]=this.computeDecayOpacity(n,r),1>o[t]&&(a=!0)):o[t]=1}a&&(t._decayOpacities=o)}else{let o=1;for(const t of e){const e=i.get(t);if(null!=e){const t=this.computeDecayOpacity(e,r);o>t&&(o=t)}}if(1>o){const e=Array(n);e.fill(o),t._decayOpacities=e}}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(){var e,t,n;this.prevPositionMap.clear(),this.prevPathMap.clear();for(let o=0;this.scene.length>o;o++){const r=this.scene[o],i=this.getNodeIdentity(r,o);i&&("point"===r.type?this.prevPositionMap.set(i,{x:r.x,y:r.y,r:r.r,opacity:r.style.opacity}):"rect"===r.type?this.prevPositionMap.set(i,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:r.style.opacity}):"heatcell"===r.type?this.prevPositionMap.set(i,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:null===(e=r.style)||void 0===e?void 0:e.opacity}):"candlestick"===r.type?this.prevPositionMap.set(i,{x:r.x,y:r.openY}):"line"===r.type?this.prevPathMap.set(i,{path:r.path.map(e=>[e[0],e[1]]),opacity:null===(t=r.style)||void 0===t?void 0:t.opacity}):"area"===r.type&&this.prevPathMap.set(i,{topPath:r.topPath.map(e=>[e[0],e[1]]),bottomPath:r.bottomPath.map(e=>[e[0],e[1]]),opacity:null===(n=r.style)||void 0===n?void 0:n.opacity}))}}getNodeIdentity(e,t){var n,o,r,i;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===this.config.runtimeMode&&e.datum){if(this.getCategory)return`p:${this.getCategory(e.datum)}:${this.getY(e.datum)}`;const t=this.getX(e.datum),n=this.getY(e.datum);if(null!=t&&null!=n)return`p:${t}:${n}`}return"p:"+t;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 null==e.datum?"c:"+t:"c:"+this.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}startTransition(){var e,t,n,o,r,i,a,s,l,c,u,d,h,g,f,p,y,m,v,b,x,k,w,A,S,E;if(!this.config.transition||0===this.prevPositionMap.size&&0===this.prevPathMap.size)return;const O=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let M=!1;const P=new Set,C=new Set;for(let e=0;this.scene.length>e;e++){const y=this.scene[e],m=this.getNodeIdentity(y,e);if(!m)continue;if(y._transitionKey=m,"line"===y.type||"area"===y.type){const e=this.prevPathMap.get(m);if(e){if(C.add(m),"line"===y.type&&e.path&&e.path.length===y.path.length){y._targetPath=y.path.map(e=>[e[0],e[1]]),y._prevPath=e.path;for(let t=0;y.path.length>t;t++)y.path[t]=[e.path[t][0],e.path[t][1]];M=!0}else if("area"===y.type&&e.topPath&&e.bottomPath&&e.topPath.length===y.topPath.length&&e.bottomPath.length===y.bottomPath.length){y._targetTopPath=y.topPath.map(e=>[e[0],e[1]]),y._targetBottomPath=y.bottomPath.map(e=>[e[0],e[1]]),y._prevTopPath=e.topPath,y._prevBottomPath=e.bottomPath;for(let t=0;y.topPath.length>t;t++)y.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;y.bottomPath.length>t;t++)y.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];M=!0}y._targetOpacity=null!==(t=y.style.opacity)&&void 0!==t?t:1}else y._targetOpacity=null!==(n=y.style.opacity)&&void 0!==n?n:1,y.style=Object.assign(Object.assign({},y.style),{opacity:0}),M=!0;continue}const v=this.prevPositionMap.get(m);if("point"===y.type)if(v){P.add(m);const e={x:y.x,y:y.y,r:y.r};y._targetOpacity=null!==(o=y.style.opacity)&&void 0!==o?o:1,v.x===e.x&&v.y===e.y||(y._targetX=e.x,y._targetY=e.y,y._targetR=e.r,y.x=v.x,y.y=v.y,y.r=null!==(r=v.r)&&void 0!==r?r:y.r,M=!0)}else y._targetOpacity=null!==(i=y.style.opacity)&&void 0!==i?i:1,y.style=Object.assign(Object.assign({},y.style),{opacity:0}),M=!0;else if("rect"===y.type)if(v){P.add(m);const e={x:y.x,y:y.y,w:y.w,h:y.h};y._targetOpacity=null!==(a=y.style.opacity)&&void 0!==a?a:1,v.x===e.x&&v.y===e.y&&v.w===e.w&&v.h===e.h||(y._targetX=e.x,y._targetY=e.y,y._targetW=e.w,y._targetH=e.h,y.x=v.x,y.y=v.y,y.w=null!==(s=v.w)&&void 0!==s?s:y.w,y.h=null!==(l=v.h)&&void 0!==l?l:y.h,M=!0)}else y._targetOpacity=null!==(c=y.style.opacity)&&void 0!==c?c:1,y.style=Object.assign(Object.assign({},y.style),{opacity:0}),M=!0;else if("heatcell"===y.type)if(v){P.add(m);const e={x:y.x,y:y.y,w:y.w,h:y.h};y._targetOpacity=null!==(d=null===(u=y.style)||void 0===u?void 0:u.opacity)&&void 0!==d?d:1,v.x===e.x&&v.y===e.y||(y._targetX=e.x,y._targetY=e.y,y._targetW=e.w,y._targetH=e.h,y.x=v.x,y.y=v.y,y.w=null!==(h=v.w)&&void 0!==h?h:y.w,y.h=null!==(g=v.h)&&void 0!==g?g:y.h,M=!0)}else y._targetOpacity=null!==(p=null===(f=y.style)||void 0===f?void 0:f.opacity)&&void 0!==p?p:1,y.style=Object.assign(Object.assign({},y.style||{}),{opacity:0}),M=!0}for(const[e,t]of this.prevPathMap)if(!C.has(e))if(e.startsWith("l:")&&t.path){const n={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(y=t.opacity)&&void 0!==y?y:1},_targetOpacity:0,_transitionKey:e,datum:null};this.exitNodes.push(n),M=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const n={type:"area",topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),group:e.slice(2),style:{fill:"#999",opacity:null!==(m=t.opacity)&&void 0!==m?m:1},_targetOpacity:0,_transitionKey:e,datum:null};this.exitNodes.push(n),M=!0}for(const[e,t]of this.prevPositionMap)if(!P.has(e)){if(e.startsWith("p:")){const n={type:"point",x:t.x,y:t.y,r:null!==(v=t.r)&&void 0!==v?v:3,style:{opacity:null!==(b=t.opacity)&&void 0!==b?b:1},datum:null,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}else if(e.startsWith("r:")){const n={type:"rect",x:t.x,y:t.y,w:null!==(x=t.w)&&void 0!==x?x:0,h:null!==(k=t.h)&&void 0!==k?k:0,style:{opacity:null!==(w=t.opacity)&&void 0!==w?w:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}else if(e.startsWith("h:")){const n={type:"heatcell",x:t.x,y:t.y,w:null!==(A=t.w)&&void 0!==A?A:0,h:null!==(S=t.h)&&void 0!==S?S:0,fill:"#999",datum:null,style:{opacity:null!==(E=t.opacity)&&void 0!==E?E:1},_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}M=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),M&&(this.activeTransition={startTime:I(),duration:O})}advanceTransition(e){var t,n,o,r,i,a;if(!this.activeTransition)return!1;const s=T(e,this.activeTransition),l=R(s,"linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?"linear":"ease-out-cubic");for(const e of this.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const o=t?this.prevPositionMap.get(t):void 0,r=o?null!==(n=o.opacity)&&void 0!==n?n:1:0;e.style.opacity=W(r,e._targetOpacity,l)}if(void 0===e._targetX)continue;if(!t)continue;const o=this.prevPositionMap.get(t);if(!o)continue;e.x=W(o.x,e._targetX,l),e.y=W(o.y,e._targetY,l),void 0!==e._targetR&&void 0!==o.r&&(e.r=W(o.r,e._targetR,l))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?this.prevPositionMap.get(t):void 0,r=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;e.style.opacity=W(r,e._targetOpacity,l)}if(void 0===e._targetX)continue;if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=W(n.x,e._targetX,l),e.y=W(n.y,e._targetY,l),void 0!==n.w&&(e.w=W(n.w,e._targetW,l)),void 0!==n.h&&(e.h=W(n.h,e._targetH,l))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?this.prevPositionMap.get(t):void 0,o=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:W(o,e._targetOpacity,l)})}if(void 0===e._targetX)continue;if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=W(n.x,e._targetX,l),e.y=W(n.y,e._targetY,l),void 0!==n.w&&(e.w=W(n.w,e._targetW,l)),void 0!==n.h&&(e.h=W(n.h,e._targetH,l))}else if("line"===e.type){if(void 0!==e._targetOpacity){const t=void 0===e._prevPath&&e._targetOpacity>0?0:null!==(i=e.style.opacity)&&void 0!==i?i:1;e.style=Object.assign(Object.assign({},e.style),{opacity:W(t,e._targetOpacity,l)})}const t=e._prevPath,n=e._targetPath;if(t&&n&&t.length===e.path.length)for(let o=0;e.path.length>o;o++)e.path[o][0]=W(t[o][0],n[o][0],l),e.path[o][1]=W(t[o][1],n[o][1],l)}else if("area"===e.type){if(void 0!==e._targetOpacity){const t=void 0===e._prevTopPath&&e._targetOpacity>0?0:null!==(a=e.style.opacity)&&void 0!==a?a:1;e.style=Object.assign(Object.assign({},e.style),{opacity:W(t,e._targetOpacity,l)})}const t=e._prevTopPath,n=e._prevBottomPath,o=e._targetTopPath,r=e._targetBottomPath;if(t&&o&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=W(t[n][0],o[n][0],l),e.topPath[n][1]=W(t[n][1],o[n][1],l);if(n&&r&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=W(n[t][0],r[t][0],l),e.bottomPath[t][1]=W(n[t][1],r[t][1],l)}}if(s>=1){for(const e of this.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style=Object.assign(Object.assign({},"line"===e.type||"area"===e.type?e.style:e.style||{}),{opacity:0===t?0:t}),e._targetOpacity=void 0}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}else if("line"===e.type){const t=e._targetPath;if(t)for(let n=0;e.path.length>n;n++)e.path[n]=t[n];e._prevPath=void 0,e._targetPath=void 0}else if("area"===e.type){const t=e._targetTopPath,n=e._targetBottomPath;if(t)for(let n=0;e.topPath.length>n;n++)e.topPath[n]=t[n];if(n)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=n[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0}}if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}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}))}resolveColorMap(e){const t=new Set;for(const n of e){const e=this.getColor(n);e&&t.add(e)}const n=Array.from(t).sort(),o=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===o)return this._colorMapCache.map;const r=Array.isArray(this.config.colorScheme)?this.config.colorScheme:j,i=new Map;for(let e=0;n.length>e;e++)i.set(n[e],r[e%r.length]);return this._colorMapCache={key:o,map:i},i}resolveLineStyle(e,t){const n=this.config.lineStyle;if("function"==typeof n){const o=n(t||{},e);if(o&&!o.stroke&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},o),{stroke:t})}return o}return 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){const n=this.config.areaStyle(t||{});if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}const o=this.config.lineStyle;if("function"==typeof o){const n=o(t||{},e);if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}return 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}}resolveGroupColor(e){if(this._colorMapCache){const t=this._colorMapCache.map.get(e);if(t)return t}const t=this._groupColorMap.get(e);if(t)return t;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:j,o=n[this._groupColorMap.size%n.length];return this._groupColorMap.set(e,o),o}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}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.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(e){void 0!==e.colorScheme&&(this._colorMapCache=null,this._groupColorMap=new Map),void 0===e.barColors&&void 0===e.colorScheme||(this._barCategoryCache=null),void 0===e.normalize&&void 0===e.extentPadding&&void 0===e.xAccessor&&void 0===e.yAccessor&&void 0===e.groupAccessor&&void 0===e.categoryAccessor&&void 0===e.chartType||(this._stackExtentCache=null),Object.assign(this.config,e),(void 0!==e.xAccessor||void 0!==e.yAccessor||void 0!==e.timeAccessor||void 0!==e.valueAccessor)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=O(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=O(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=O(this.config.xAccessor,"x"),this.getY=O(this.config.yAccessor,"y"))),void 0!==e.groupAccessor&&(this.getGroup=P(this.config.groupAccessor)),void 0!==e.categoryAccessor&&(this.getCategory=P(this.config.categoryAccessor)),void 0!==e.sizeAccessor&&(this.getSize=this.config.sizeAccessor?O(this.config.sizeAccessor,"size"):void 0),void 0!==e.colorAccessor&&(this.getColor=P(this.config.colorAccessor)),void 0!==e.y0Accessor&&(this.getY0=this.config.y0Accessor?O(this.config.y0Accessor,"y0"):void 0),void 0!==e.pointIdAccessor&&(this.getPointId=P(this.config.pointIdAccessor)),this.needsFullRebuild=!0}}function z(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 F(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function G(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 Y(e,t,n){var o,r,i,a;if(0===e.path.length)return null;const s=Q(e.path,t);if(0>s)return null;const[l,c]=e.path[s];let u;if(e.path.length>1){let o=1/0;const r=Math.max(0,s-1),i=Math.min(e.path.length-2,s);for(let a=r;i>=a;a++){const[r,i]=e.path[a],[s,l]=e.path[a+1],c=q(t,n,r,i,s,l);o>c&&(o=c)}u=o}else{const e=t-l,o=n-c;u=Math.sqrt(e*e+o*o)}const d=null!==(a=null!==(r=null===(o=e.style)||void 0===o?void 0:o.strokeWidth)&&void 0!==r?r:null===(i=e.style)||void 0===i?void 0:i.lineWidth)&&void 0!==a?a:1;return u>Math.max(5,d/2+2)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:l,y:c,distance:u}}function q(e,t,n,o,r,i){const a=r-n,s=i-o,l=a*a+s*s;if(0===l)return Math.sqrt(Math.pow(e-n,2)+Math.pow(t-o,2));let c=((e-n)*a+(t-o)*s)/l;c=Math.max(0,Math.min(1,c));const u=o+c*s;return Math.sqrt(Math.pow(e-(n+c*a),2)+Math.pow(t-u,2))}function X(e,t,n){const o=z(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function V(e,t,n){const o=z(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function U(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 K(e,t,n){if(0===e.topPath.length)return null;const o=Q(e.topPath,t);if(0>o)return null;const[r,i]=e.topPath[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 Q(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 Z(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 J(e){const t=e.datum||{};return Object.assign(Object.assign({},"object"!=typeof t||null===t||Array.isArray(t)?{}:t),{data:t,x:e.x,y:e.y,time:e.x,value:e.y})}function ee(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 te(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])}$.QUADTREE_THRESHOLD=500;const ne={fill:e=>p.createElement("rect",{style:e,width:16,height:16}),line:e=>p.createElement("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function oe(e,t,n,o){let r;return r="function"==typeof n?n(e):(0,ne[n])(o(e,t)),r}function re(){return p.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function ie(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function ae({config:e,orientation:t="vertical",width:n=100}){const{colorFn:o,domain:r,label:i,format:a}=e,s=a||(e=>Math.round(100*e)/100+""),l="grad-legend-"+p.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),a=Math.max(0,(n-t)/2),c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(p.createElement("stop",{key:e,offset:100*t+"%",stopColor:o(r[0]+t*(r[1]-r[0]))}))}return p.createElement("g",{"aria-label":i||"Gradient legend"},p.createElement("defs",null,p.createElement("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},c)),i&&p.createElement("text",{x:a+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),p.createElement("rect",{x:a,y:0,width:t,height:e,fill:`url(#${l})`,rx:2}),p.createElement("text",{x:a,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(r[0])),p.createElement("text",{x:a+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(r[1])))}const c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(p.createElement("stop",{key:e,offset:100*t+"%",stopColor:o(r[1]-t*(r[1]-r[0]))}))}return p.createElement("g",{"aria-label":i||"Gradient legend"},i&&p.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),p.createElement("defs",null,p.createElement("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},c)),p.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${l})`,rx:2}),p.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(r[1])),p.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(r[0])))}function se(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,legendInteraction:a,title:s="Legend",width:l=100,height:c=20,orientation:u="vertical"}=e,[d,h]=p.useState(0),[g,f]=p.useState(0),y=p.useCallback((e,t)=>{h(e),f(t)},[]),m="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:a,focusedItemIndex:s,onFocusedIndexChange:l,legendInteraction:c})=>{let u=24;const d=[];return e.forEach((e,h)=>{u+=5,d.push(p.createElement("line",{key:"legend-top-line legend-symbol-"+h,stroke:"gray",x1:0,y1:u,x2:t,y2:u})),u+=8,e.label&&(u+=16,d.push(p.createElement("text",{key:"legend-text-"+h,y:u,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label)),u+=8),d.push(p.createElement("g",{key:"legend-group-"+h,className:"legend-item",transform:`translate(0,${u})`},((e,t,n,o,r,i,a,s,l,c)=>{const{type:u="fill",styleFn:d,items:h}=e,g=[];let f=0;const y=!(!t&&!n),m="isolate"===c||void 0===c&&null!=r;return h.forEach((e,c)=>{const v=oe(e,c,u,d),b=ie(e,o,r),x=r&&r.size>0&&r.has(e.label);g.push(p.createElement("g",{key:"legend-item-"+c,transform:`translate(0,${f})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:y?s===i&&c===a?0:-1:void 0,role:y?"option":void 0,"aria-selected":y&&m?x||!1:void 0,"aria-current":y&&!m&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:y?n=>{var o;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(c+("ArrowDown"===n.key?1:-1)+h.length)%h.length;l(s,e);const t=null===(o=n.currentTarget.parentElement)||void 0===o?void 0:o.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:y?t=>{l(s,c),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:y?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:y?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},y&&p.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,x&&p.createElement(re,null),p.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),f+=22}),g})(e,n,o,r,i,a,s,h,l,c))),u+=22*e.items.length+8}),d})({legendGroups:t||[],width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:d,focusedItemIndex:g,onFocusedIndexChange:y,legendInteraction:a}):(({legendGroups:e,height:t,width:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:s,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u})=>{let d=0;const h=[];e.forEach((e,t)=>{let n=0;e.label&&(n+=16);const g=((e,t,n,o,r,i,a,s,l,c)=>{const{type:u="fill",styleFn:d,items:h}=e,g=[];let f=0;const y=!(!t&&!n),m="isolate"===c||void 0===c&&null!=r;return h.forEach((e,c)=>{const v=oe(e,c,u,d),b=ie(e,o,r),x=r&&r.size>0&&r.has(e.label);g.push(p.createElement("g",{key:"legend-item-"+c,transform:`translate(${f},0)`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:y?s===i&&c===a?0:-1:void 0,role:y?"option":void 0,"aria-selected":y&&m?x||!1:void 0,"aria-current":y&&!m&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:y?n=>{var o;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(c+("ArrowRight"===n.key?1:-1)+h.length)%h.length;l(s,e);const t=null===(o=n.currentTarget.parentElement)||void 0===o?void 0:o.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:y?t=>{l(s,c),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:y?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:y?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},y&&p.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,x&&p.createElement(re,null),p.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),f+=26+7*e.label.length}),{items:g,offset:f}})(e,o,r,i,a,s,l,t,c,u);n+=g.offset+5,h.push(Object.assign(Object.assign({label:e.label},g),{offset:n})),d+=n+12});let g=Math.max(0,(n-d)/2);const f=[];return h.forEach((n,o)=>{const r=e[o];r.label&&(f.push(p.createElement("text",{key:"legend-text-"+o,transform:`translate(${g},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},r.label)),g+=16),f.push(p.createElement("g",{key:"legend-group-"+o,className:"legend-item",transform:`translate(${g},0)`},n.items)),g+=n.offset+5,e[o+1]&&f.push(p.createElement("line",{key:"legend-top-line legend-symbol-"+o,stroke:"gray",x1:g,y1:-8,x2:g,y2:t+0+8})),g+=12}),p.createElement("g",null,f)})({legendGroups:t||[],title:s,height:c,width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:d,focusedItemIndex:g,onFocusedIndexChange:y,legendInteraction:a}),v=!(!n&&!o);return p.createElement("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==a&&(void 0!==a||null==i))||void 0,"aria-label":"Chart legend"},void 0!==s&&""!==s&&"vertical"===u&&p.createElement("text",{className:"legend-title",y:16,x:l/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},s),m)}function le(e){const{legend:t,totalWidth:n,totalHeight:o,margin:r,legendPosition:i="right",title:a,legendHoverBehavior:s,legendClickBehavior:l,legendHighlightedCategory:c,legendIsolatedCategories:u,legendInteraction:d}=e;if(!t)return null;const h="top"===i||"bottom"===i;let g,f;return"left"===i?(g=4,f=r.top):"top"===i?(g=0,f=a?32:8):"bottom"===i?(g=0,f=o-r.bottom+50):(g=n-r.right+10,f=r.top),p.createElement("g",{transform:`translate(${g}, ${f})`},function(e){return"object"==typeof e&&null!==e&&"gradient"in e}(t)?p.createElement(ae,{config:t.gradient,orientation:h?"horizontal":"vertical",width:h?n:100}):function(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}(t)?p.createElement(se,{legendGroups:t.legendGroups,title:"",width:h?n:100,orientation:h?"horizontal":"vertical",customHoverBehavior:s,customClickBehavior:l,highlightedCategory:c,isolatedCategories:u,legendInteraction:d}):t)}function ce(e){return"string"==typeof e?{type:e}:e}function ue({orient:t,config:n,values:o,scale:r,size:i,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=r.domain(),n=i-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:i,median:a,q3:s,whiskerLow:u,whiskerHigh:d}=e,h=Math.min(.5*n,20),g=(n-h)/2+4;if(c){const e=r(i),n=r(s),o=r(a),c=r(u),f=r(d),y="top"===t?-1:1,m=0;return p.createElement("g",{"data-testid":"marginal-boxplot-"+t},p.createElement("line",{x1:c,y1:m+y*(g+h/2),x2:f,y2:m+y*(g+h/2),stroke:l.fill,strokeWidth:l.strokeWidth}),p.createElement("line",{x1:c,y1:m+y*g,x2:c,y2:m+y*(g+h),stroke:l.fill,strokeWidth:l.strokeWidth}),p.createElement("line",{x1:f,y1:m+y*g,x2:f,y2:m+y*(g+h),stroke:l.fill,strokeWidth:l.strokeWidth}),p.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}),p.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=r(i),n=r(s),o=r(a),c=r(u),f=r(d),y="left"===t?-1:1,m=0;return p.createElement("g",{"data-testid":"marginal-boxplot-"+t},p.createElement("line",{x1:m+y*(g+h/2),y1:c,x2:m+y*(g+h/2),y2:f,stroke:l.fill,strokeWidth:l.strokeWidth}),p.createElement("line",{x1:m+y*g,y1:c,x2:m+y*(g+h),y2:c,stroke:l.fill,strokeWidth:l.strokeWidth}),p.createElement("line",{x1:m+y*g,y1:f,x2:m+y*(g+h),y2:f,stroke:l.fill,strokeWidth:l.strokeWidth}),p.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}),p.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=a.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 p.createElement("g",{"data-testid":"marginal-histogram-"+t},u.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const i=e.length/d*n;if(c){const n=r(e.x0),a=r(e.x1)-r(e.x0);return p.createElement("rect",{key:o,x:n,y:"top"===t?-4-i:4,width:Math.max(a,.5),height:i,fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}{const n=r(e.x0),a=r(e.x1)-r(e.x0);return p.createElement("rect",{key:o,x:"left"===t?-4-i:4,y:Math.min(n,n+a),width:i,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 i of u){if(null==i.x0||null==i.x1)continue;const a=i.length/d*(n/2),s=r((i.x0+i.x1)/2);o.push(c?`${s},${"top"===t?-(e-a):e-a}`:`${"left"===t?-(e-a):e-a},${s}`)}for(let i=u.length-1;i>=0;i--){const a=u[i];if(null==a.x0||null==a.x1)continue;const s=a.length/d*(n/2),l=r((a.x0+a.x1)/2);o.push(c?`${l},${"top"===t?-(e+s):e+s}`:`${"left"===t?-(e+s):e+s},${l}`)}return p.createElement("g",{"data-testid":"marginal-violin-"+t},p.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,i=null!=u[0].x0?r(u[0].x0):0;e.push(`M${i},${o}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const i=o.length/d*n,a=r((o.x0+o.x1)/2);e.push(`L${a},${"top"===t?-i-4:i+4}`)}const a=null!=u[u.length-1].x1?r(u[u.length-1].x1):s;e.push(`L${a},${o}`),e.push("Z")}else{const o=0,i=null!=u[0].x0?r(u[0].x0):0;e.push(`M${o},${i}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const i=o.length/d*n,a=r((o.x0+o.x1)/2);e.push(`L${"left"===t?-i-4:i+4},${a}`)}const a=null!=u[u.length-1].x1?r(u[u.length-1].x1):s;e.push(`L${o},${a}`),e.push("Z")}return p.createElement("g",{"data-testid":"marginal-ridgeline-"+t},p.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,r,l,i,s,t,c,4]);return u?p.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},u):null}function de(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 he(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 ge(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:f={},"data-testid":y}=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 p.createElement("g",Object.assign({className:("annotation "+(h||"")).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(p.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(p.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 p.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(p.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(p.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(p.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(p.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(p.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(p.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(p.createElement("path",{key:"bracket-path",d:he((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 p.createElement("g",{className:"annotation-subject"},a)}(x,c,d,t,n),!m.has("note")&&function(e,t,n,o){if(!e)return p.createElement("g",{className:"annotation-note"});const{label:r,title:i,orientation:a,align:s,wrap:l=120,noWrap:c}=e;if(!r&&!i)return p.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,f=i?c?[i]:de(i,l):[],y=r?c?[r]:de(r,l):[],m="leftRight"===u?"end"===h?-4:4:0;let v=0;const b=[];f.length>0&&(b.push(p.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:o||void 0,textAnchor:h,fontWeight:"bold"},f.map((e,t)=>p.createElement("tspan",{key:t,x:m,dy:0===t?0:g},e)))),v=f.length*g),y.length>0&&b.push(p.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:o||void 0,textAnchor:h,y:v},y.map((e,t)=>p.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=p.createElement("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"currentColor"})}else{const e=(f.length+y.length)*g+(y.length>0?g:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),x=p.createElement("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:o||"currentColor"})}const k=Math.max(0,f.length+y.length-1)*g;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===d?-(k+g+(y.length>0&&f.length>0?2:0))/2+8:"bottom"===d||0>n?-(k+2):18),p.createElement("g",{className:"annotation-note",transform:`translate(${t},${n})`},p.createElement("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0},b),x)}(s,v,b,d))}function fe(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 p.createElement(ge,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},r,{type:i}))});return p.createElement("g",null,s)}const s=o.note||{title:"none",label:o.label};return p.createElement(ge,Object.assign({"data-testid":"semiotic-annotation",key:`${s.label}-${s.title}-${o.i}`,events:a},o,{type:i}))}const pe={linear:l.curveLinear,monotoneX:l.curveMonotoneX,monotoneY:l.curveMonotoneY,step:l.curveStep,stepAfter:l.curveStepAfter,stepBefore:l.curveStepBefore,basis:l.curveBasis,cardinal:l.curveCardinal,catmullRom:l.curveCatmullRom};function ye(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 me(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 ve(e,t,n){var o,r,i,a;const s=e.anchor||"fixed";if("latest"===s){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const i=n.pointNodes[r];if(i.pointId===e.pointId){const e={x:i.x,y:i.y};return null===(o=n.stickyPositionCache)||void 0===o||o.set(t,e),e}}const i=function(e){var t,n,o,r,i,a;const s=e.data;if(!s||0===s.length)return null;const l=s[s.length-1],c=null!==(n=null===(t=e.scales)||void 0===t?void 0:t.x)&&void 0!==n?n:null===(o=e.scales)||void 0===o?void 0:o.time,u=null!==(i=null===(r=e.scales)||void 0===r?void 0:r.y)&&void 0!==i?i:null===(a=e.scales)||void 0===a?void 0:a.value;if(!c||!u)return null;const d=l[e.xAccessor||"x"],h=l[e.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return i&&(null===(r=n.stickyPositionCache)||void 0===r||r.set(t,i)),i}let l=null,c=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(l=t.x,c=t.y)}if(null!=l&&null!=c||(l=ye(e,n),c=me(e,n)),null!=l&&null!=c)return null===(i=n.stickyPositionCache)||void 0===i||i.set(t,{x:l,y:c}),{x:l,y:c};if("sticky"===s){const e=null===(a=n.stickyPositionCache)||void 0===a?void 0:a.get(t);if(e)return e}return null}function be(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function xe(e){return function(e,t,n){var o,r,i,a,c,u,d,h,g,f,m,v,b,x,k,w,A,S,E,O,M,P,C,L,j,N,D,_,B,H,R,T,W,I,$,z,F,G,Y,q,X,V,U,K;switch(e.type){case"label":{const o=ve(e,t,n);if(!o)return null;const{x:r,y:i}=o;return be(r,i,n)?p.createElement(fe,{key:"ann-"+t,noteData:{x:r,y:i,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":{const o=ve(e,t,n);if(!o)return null;const{x:r,y:i}=o;return be(r,i,n)?p.createElement(fe,{key:"ann-"+t,noteData:{x:r,y:i,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=ye(e,n);if(null==o)return null;const r=e.color||"#f97316";return p.createElement("g",{key:"ann-"+t},p.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&&p.createElement("text",{x:o+4,y:12,fill:r,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const o=me(e,n);if(null==o)return null;const r=e.color||"#f97316";return p.createElement("g",{key:"ann-"+t},p.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&&p.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:ye(Object.assign(Object.assign({},e),{type:"point"}),n),y:me(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=s.packEnclose(o),i=e.padding||10;return p.createElement("g",{key:"ann-"+t},p.createElement("circle",{cx:r.x,cy:r.y,r:r.r+i,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&p.createElement("text",{x:r.x,y:r.y-r.r-i-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"rect-enclose":{const o=(e.coordinates||[]).map(e=>({x:ye(Object.assign(Object.assign({},e),{type:"point"}),n),y:me(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 p.createElement("g",{key:"ann-"+t},p.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&&p.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 p.createElement("g",{key:"ann-"+t},r.map((t,o)=>{const r=ye(t,n),a=me(t,n);return null==r||null==a?null:p.createElement("circle",Object.assign({key:"hl-"+o,cx:r,cy:a,r:e.r||6},i))}))}case"bracket":{const o=ye(e,n),r=me(e,n);return p.createElement(fe,{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 s=n.data||[];if(2>s.length)return null;const l=n.xAccessor||"x",h=n.yAccessor||"y",g=s.map(e=>[e[l],e[h]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>g.length)return null;const f=null!==(r=null===(o=n.scales)||void 0===o?void 0:o.x)&&void 0!==r?r:null===(i=n.scales)||void 0===i?void 0:i.time,m=null!==(c=null===(a=n.scales)||void 0===a?void 0:a.y)&&void 0!==c?c:null===(u=n.scales)||void 0===u?void 0:u.value;if(!f||!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 p=u*g-d*d;if(1e-12>Math.abs(p))s.push([t,h/u]);else{const e=(u*f-d*h)/p;s.push([t,(h-e*d)/u+e*t])}}return s}(g,null!==(d=e.bandwidth)&&void 0!==d?d:.3):("polynomial"===v?y.default.polynomial(g,{order:e.order||2}):y.default.linear(g)).points;const x=b.map(([e,t])=>`${f(e)},${m(t)}`).join(" "),k=e.color||"#6366f1";return p.createElement("g",{key:"ann-"+t},p.createElement("polyline",{points:x,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&p.createElement("text",{x:f(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!==(g=null===(h=n.scales)||void 0===h?void 0:h.y)&&void 0!==g?g:null===(f=n.scales)||void 0===f?void 0:f.value,r=null!==(m=null==o?void 0:o(e.y0))&&void 0!==m?m:0,i=null!==(v=null==o?void 0:o(e.y1))&&void 0!==v?v:n.height||0;return p.createElement("g",{key:"ann-"+t},p.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&&p.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!==(x=null===(b=n.scales)||void 0===b?void 0:b.x)&&void 0!==x?x:null===(k=n.scales)||void 0===k?void 0:k.time,a=null!==(A=null===(w=n.scales)||void 0===w?void 0:w.y)&&void 0!==A?A:null===(S=n.scales)||void 0===S?void 0:S.value;if(!i||!a)return null;const s=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",u=e.filter,d=o.filter(e=>null!=e[s]&&null!=e[c]&&!(u&&!u(e))).sort((e,t)=>e[r]-t[r]);if(2>d.length)return null;const h=pe[n.curve||"linear"]||l.curveLinear,g=l.area().x(e=>i(e[r])).y0(e=>a(e[c])).y1(e=>a(e[s])).curve(h)(d);if(!g)return null;const f=e.fill||"#6366f1";return p.createElement("g",{key:"ann-"+t},p.createElement("path",{d:g,fill:f,fillOpacity:null!==(E=e.fillOpacity)&&void 0!==E?E:.15,stroke:"none"}),e.label&&d.length>0&&p.createElement("text",{x:i(d[d.length-1][r])+4,y:a(d[d.length-1][s])-4,fill:f,fontSize:11},e.label))}case"anomaly-band":{const o=n.data||[];if(2>o.length)return null;const r=n.yAccessor||"y",i=null!==(M=null===(O=n.scales)||void 0===O?void 0:O.x)&&void 0!==M?M:null===(P=n.scales)||void 0===P?void 0:P.time,a=null!==(L=null===(C=n.scales)||void 0===C?void 0:C.y)&&void 0!==L?L: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!==(N=e.threshold)&&void 0!==N?N:2,h=l-d*u,g=!1!==e.showBand,f=e.fill||"#6366f1",y=null!==(D=e.fillOpacity)&&void 0!==D?D:.1,m=e.anomalyColor||"#ef4444",v=null!==(_=e.anomalyRadius)&&void 0!==_?_: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 p.createElement("g",{key:"ann-"+t},g&&p.createElement("rect",{x:0,y:Math.min(b,x),width:n.width||0,height:Math.abs(x-b),fill:f,fillOpacity:y}),k.map((e,t)=>{const o=ye(e,n),r=me(e,n);return null==o||null==r?null:p.createElement("circle",{key:"anomaly-"+t,cx:o,cy:r,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5})}),e.label&&p.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!==(H=null===(B=n.scales)||void 0===B?void 0:B.x)&&void 0!==H?H:null===(R=n.scales)||void 0===R?void 0:R.time,s=null!==(W=null===(T=n.scales)||void 0===T?void 0:T.y)&&void 0!==W?W:null===(I=n.scales)||void 0===I?void 0:I.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,f=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+(f>0?Math.pow(e-g,2)/f:0))*v;A.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const S=`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`,E=A.map(e=>`${a(e.x)},${s(e.yCenter)}`).join(" "),O=`${a(x)},${s(c(x))}`,M=e.strokeColor||"#6366f1";return p.createElement("g",{key:"ann-"+t},p.createElement("path",{d:S,fill:e.fill||"#6366f1",fillOpacity:null!==(F=e.fillOpacity)&&void 0!==F?F:.15,stroke:"none"}),p.createElement("polyline",{points:`${O} ${E}`,fill:"none",stroke:M,strokeWidth:null!==(G=e.strokeWidth)&&void 0!==G?G:2,strokeDasharray:null!==(Y=e.strokeDasharray)&&void 0!==Y?Y:"6,3"}),e.label&&A.length>0&&p.createElement("text",{x:a(A[A.length-1].x)+4,y:s(A[A.length-1].yCenter)-4,fill:M,fontSize:11},e.label))}case"widget":{let o=null,r=null;if(null!=e.px&&null!=e.py)o=e.px,r=e.py;else{const i=ve(e,t,n);if(!i)return null;o=i.x,r=i.y}if(null==o||null==r)return null;if(!be(o,r,n))return null;const i=null!==(q=e.dx)&&void 0!==q?q:0,a=null!==(X=e.dy)&&void 0!==X?X:0,s=null!==(V=e.width)&&void 0!==V?V:32,l=null!==(U=e.height)&&void 0!==U?U:32,c=null!==(K=e.content)&&void 0!==K?K:p.createElement("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info"},"ℹ️");return p.createElement("foreignObject",{key:"ann-"+t,x:o+i-s/2,y:r+a-l/2,width:s,height:l,style:{overflow:"visible",pointerEvents:"auto"}},p.createElement("div",{style:{width:s,height:l,display:"flex",alignItems:"center",justifyContent:"center"}},c))}case"text":{const o=ve(e,t,n);if(!o)return null;const{x:r,y:i}=o;return p.createElement("text",{key:"ann-text-"+t,x:r+(e.dx||0),y:i+(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 ke(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 we(t){const{width:n,height:o,totalWidth:r,totalHeight:i,margin:a,scales:s,showAxes:l,axes:c,showGrid:u,xFormat:d,yFormat:h}=t,g=e.useMemo(()=>{var e;if(!s)return[];const t=null==c?void 0:c.find(e=>"bottom"===e.orient),o=(null==t?void 0:t.tickFormat)||d||Ae,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return s.x.ticks(Math.min(r,Math.max(2,Math.floor(n/70)))).map(e=>({value:e,pixel:s.x(e),label:o(e)}))},[s,c,d,n]),f=e.useMemo(()=>{var e;if(!s)return[];const t=null==c?void 0:c.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||h||Ae,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return s.y.ticks(Math.min(r,Math.max(2,Math.floor(o/30)))).map(e=>({value:e,pixel:s.y(e),label:n(e)}))},[s,c,h,o]),y=u&&s,m=l&&s;if(!y&&!m)return null;const v=null==c?void 0:c.find(e=>"bottom"===e.orient),b=null==c?void 0:c.find(e=>"left"===e.orient),x=m&&(!v||!1!==v.baseline),k=m&&(!b||!1!==b.baseline),w=(null==v?void 0:v.jaggedBase)||!1,A=(null==b?void 0:b.jaggedBase)||!1,S="var(--semiotic-border, #ccc)";return p.createElement("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},p.createElement("g",{transform:`translate(${a.left},${a.top})`},y&&p.createElement("g",{className:"stream-grid"},g.map((e,t)=>p.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),f.map((e,t)=>p.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:n,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),x&&!w&&p.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:S,strokeWidth:1}),w&&p.createElement("path",{d:ke("bottom",n,o),fill:"none",stroke:S,strokeWidth:1}),k&&!A&&p.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:S,strokeWidth:1}),A&&p.createElement("path",{d:ke("left",n,o),fill:"none",stroke:S,strokeWidth:1})))}function Ae(e){return Math.round(100*e)/100+""}function Se(e,t){return e instanceof Date&&(!(t&&t instanceof Date)||e.getFullYear()!==t.getFullYear()||e.getMonth()!==t.getMonth()||e.getDate()!==t.getDate())}function Ee(t){var n,o;const{width:r,height:i,totalWidth:a,totalHeight:s,margin:l,scales:c,showAxes:u,axes:d,xLabel:h,yLabel:g,xFormat:f,yFormat:y,showGrid:m,title:v,legend:b,legendHoverBehavior:x,legendClickBehavior:k,legendHighlightedCategory:w,legendIsolatedCategories:A,legendPosition:S="right",foregroundGraphics:E,marginalGraphics:O,xValues:M,yValues:P,annotations:C,svgAnnotationRules:L,xAccessor:j,yAccessor:N,annotationData:D,pointNodes:_,curve:B,underlayRendered:H,children:R}=t,T=e.useMemo(()=>{var e;if(!u||!c)return[];const t=null==d?void 0:d.find(e=>"bottom"===e.orient),n=(null==t?void 0:t.tickFormat)||f||Ae,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return c.x.ticks(Math.min(o,Math.max(2,Math.floor(r/70)))).map(e=>({value:e,pixel:c.x(e),label:n(e)}))},[u,c,d,f,r]),W=e.useMemo(()=>{var e;if(!u||!c)return[];const t=null==d?void 0:d.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||y||Ae,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return c.y.ticks(Math.min(o,Math.max(2,Math.floor(i/30)))).map(e=>({value:e,pixel:c.y(e),label:n(e)}))},[u,c,d,y,i]),I=e.useRef(new Map),$=e.useRef(null!==(n=null==C?void 0:C.length)&&void 0!==n?n:0),z=null!==(o=null==C?void 0:C.length)&&void 0!==o?o:0;$.current!==z&&($.current=z,I.current=new Map);const F=e.useMemo(()=>{if(!C||0===C.length)return null;const e=xe(),t={scales:c?{x:c.x,y:c.y,time:c.x,value:c.y}:null,timeAxis:"x",xAccessor:j,yAccessor:N,width:r,height:i,data:D,frameType:"xy",pointNodes:_,curve:B,stickyPositionCache:I.current};return C.map((n,o)=>{if(L){const r=L(n,o,t);return null!=r?r:e(n,o,t)}return e(n,o,t)}).filter(Boolean)},[C,L,r,i,j,N,D,c,_,B]);return u||v||b||E||O||F&&F.length>0||m||R?p.createElement("svg",{role:"img",width:a,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},p.createElement("title",null,"string"==typeof v?v:"XY Chart"),p.createElement("desc",null,"string"==typeof v?v+" — XY data visualization":"XY data visualization"),p.createElement("g",{transform:`translate(${l.left},${l.top})`},m&&c&&!H&&p.createElement("g",{className:"stream-grid"},T.map((e,t)=>p.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),W.map((e,t)=>p.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:r,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),u&&c&&(()=>{const e=null==d?void 0:d.find(e=>"left"===e.orient),t=null==d?void 0:d.find(e=>"bottom"===e.orient),n=!e||!1!==e.baseline,o=(null==e?void 0:e.jaggedBase)||!1,a=(null==t?void 0:t.jaggedBase)||!1,s=null==t?void 0:t.landmarkTicks,c=null==e?void 0:e.landmarkTicks,u="var(--semiotic-border, #ccc)",f="var(--semiotic-text-secondary, #666)",y="var(--semiotic-text, #333)";return p.createElement("g",{className:"stream-axes"},!H&&(!t||!1!==t.baseline)&&!a&&p.createElement("line",{x1:0,y1:i,x2:r,y2:i,stroke:u,strokeWidth:1}),!H&&a&&p.createElement("path",{d:ke("bottom",r,i),fill:"none",stroke:u,strokeWidth:1}),T.map((e,t)=>{const n=!!s&&("function"==typeof s?s(e.value,t):Se(e.value,t>0?T[t-1].value:void 0));return p.createElement("g",{key:"xtick-"+t,transform:`translate(${e.pixel},${i})`},p.createElement("line",{y2:5,stroke:u,strokeWidth:1}),p.createElement("text",{y:18,textAnchor:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:f,style:{userSelect:"none"}},e.label))}),h&&p.createElement("text",{x:r/2,y:i+40,textAnchor:"middle",fontSize:12,fill:y,style:{userSelect:"none"}},h),!H&&n&&!o&&p.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:u,strokeWidth:1}),!H&&o&&p.createElement("path",{d:ke("left",r,i),fill:"none",stroke:u,strokeWidth:1}),W.map((e,t)=>{const n=!!c&&("function"==typeof c?c(e.value,t):Se(e.value,t>0?W[t-1].value:void 0));return p.createElement("g",{key:"ytick-"+t,transform:`translate(0,${e.pixel})`},p.createElement("line",{x2:-5,stroke:u,strokeWidth:1}),p.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:f,style:{userSelect:"none"}},e.label))}),g&&p.createElement("text",{x:15-l.left,y:i/2,textAnchor:"middle",fontSize:12,fill:y,transform:`rotate(-90, ${15-l.left}, ${i/2})`,style:{userSelect:"none"}},g))})(),F,O&&c&&M&&P&&p.createElement(p.Fragment,null,O.top&&p.createElement("g",{transform:"translate(0, 0)"},p.createElement(ue,{orient:"top",config:ce(O.top),values:M,scale:c.x,size:l.top,length:r})),O.bottom&&p.createElement("g",{transform:`translate(0, ${i})`},p.createElement(ue,{orient:"bottom",config:ce(O.bottom),values:M,scale:c.x,size:l.bottom,length:r})),O.left&&p.createElement("g",{transform:"translate(0, 0)"},p.createElement(ue,{orient:"left",config:ce(O.left),values:P,scale:c.y,size:l.left,length:i})),O.right&&p.createElement("g",{transform:`translate(${r}, 0)`},p.createElement(ue,{orient:"right",config:ce(O.right),values:P,scale:c.y,size:l.right,length:i}))),E,R),v&&p.createElement("text",{x:a/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof v?v:null),le({legend:b,totalWidth:a,totalHeight:s,margin:l,legendPosition:S,title:v,legendHoverBehavior:x,legendClickBehavior:k,legendHighlightedCategory:w,legendIsolatedCategories:A})):null}const Oe="undefined"==typeof window||"undefined"==typeof document,Me={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Pe(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e)n[t.type]=(n[t.type]||0)+1;const o=[],r={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks"},i=["point","line","area","rect","heatcell","circle","candlestick"],a=Object.keys(n).sort((e,t)=>{const n=i.indexOf(e),o=i.indexOf(t);return(-1===n?999:n)-(-1===o?999:o)});for(const e of a)o.push(`${n[e]} ${r[e]||e}`);return`${t}, ${o.join(", ")}`}function Ce(e,t,n){const o=[];return e>0&&o.push(e+" nodes"),t>0&&o.push(t+" edges"),0===o.length?n+", empty":`${n}, ${o.join(", ")}`}function Le({scene:e,chartType:t}){var n,o,r,i;const a=[];for(const t of e){if(a.length>=50)break;"point"===t.type?a.push({label:"Point",values:{x:Math.round(100*t.x)/100+"",y:Math.round(100*t.y)/100+""}}):"rect"===t.type?a.push({label:"Bar",values:{category:(null===(n=t.datum)||void 0===n?void 0:n.category)||"",value:Math.round(100*(null!==(r=null===(o=t.datum)||void 0===o?void 0:o.value)&&void 0!==r?r:0))/100+""}}):"heatcell"===t.type&&a.push({label:"Cell",values:{x:Math.round(100*t.x)/100+"",y:Math.round(100*t.y)/100+"",value:Math.round(100*(null!==(i=t.value)&&void 0!==i?i:0))/100+""}})}if(0===a.length)return null;const s=new Set;for(const e of a)for(const t of Object.keys(e.values))s.add(t);const l=Array.from(s);return p.createElement("table",{style:Me,role:"table","aria-label":"Data table for "+t},p.createElement("thead",null,p.createElement("tr",null,l.map(e=>p.createElement("th",{key:e},e)))),p.createElement("tbody",null,a.map((e,t)=>p.createElement("tr",{key:t},l.map(t=>{var n;return p.createElement("td",{key:t},null!==(n=e.values[t])&&void 0!==n?n:"")}))),e.length>50&&p.createElement("tr",null,p.createElement("td",{colSpan:l.length},"...and ",e.length-50," more items"))))}function je({nodes:e,chartType:t}){var n,o,r,i,a;const s=[];for(const t of e){if(s.length>=50)break;s.push({values:{id:(null===(n=t.datum)||void 0===n?void 0:n.id)||t.id||"",x:Math.round(100*(null!==(r=null!==(o=t.cx)&&void 0!==o?o:t.x)&&void 0!==r?r:0))/100+"",y:Math.round(100*(null!==(a=null!==(i=t.cy)&&void 0!==i?i:t.y)&&void 0!==a?a:0))/100+""}})}if(0===s.length)return null;const l=new Set;for(const e of s)for(const t of Object.keys(e.values))l.add(t);const c=Array.from(l);return p.createElement("table",{style:Me,role:"table","aria-label":"Data table for "+t},p.createElement("thead",null,p.createElement("tr",null,c.map(e=>p.createElement("th",{key:e},e)))),p.createElement("tbody",null,s.map((e,t)=>p.createElement("tr",{key:t},c.map(t=>{var n;return p.createElement("td",{key:t},null!==(n=e.values[t])&&void 0!==n?n:"")}))),e.length>50&&p.createElement("tr",null,p.createElement("td",{colSpan:c.length},"...and ",e.length-50," more items"))))}function Ne({hoverPoint:e}){let t="";if(e){const n=e.data||e;t="object"==typeof n?"Focused on data point: "+Object.entries(n).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Focused on data point: "+n}return p.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:Me},t)}function De(t){const n=e.createContext(null),o=_e(t);return[function({children:o}){const r=e.useMemo(()=>_e(t),[]);return p.createElement(n.Provider,{value:r,children:o})},t=>{var r;const i=null!==(r=e.useContext(n))&&void 0!==r?r:o,a=e.useRef(t);a.current=t;const s=e.useCallback(()=>a.current(i.getState()),[i]),l=e.useCallback(()=>a.current(i.getState()),[i]);return e.useSyncExternalStore(i.subscribe,s,l)}]}function _e(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)}}}const Be={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}},He={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}},[Re,Te]=De(e=>({theme:Be,setTheme(t){e(e=>"light"===t?{theme:Be}:"dark"===t?{theme:He}:{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 We(e,t,n,o){const r=e.getContext("2d");if(!r)return null;const i=t[0]*o,a=t[1]*o,s=t[0]+"px",l=t[1]+"px";return e.style.width!==s&&(e.style.width=s),e.style.height!==l&&(e.style.height=l),e.width===i&&e.height===a||(e.width=i,e.height=a),r.setTransform(o,0,0,o,0,0),r.translate(n.left,n.top),r}function Ie(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function $e(e){switch(e){case"monotoneX":return l.curveMonotoneX;case"monotoneY":return l.curveMonotoneY;case"cardinal":return l.curveCardinal;case"catmullRom":return l.curveCatmullRom;case"step":return l.curveStep;case"stepBefore":return l.curveStepBefore;case"stepAfter":return l.curveStepAfter;case"basis":return l.curveBasis;case"natural":return l.curveNatural;default:return null}}function ze(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 Fe(e,t,n,o,r,i){if(2>t.length)return;const a=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],o=t[e][1]-t[e-1][1];a.push(a[e-1]+Math.sqrt(n*n+o*o))}const s=a[a.length-1];if(0===s)return;const l=Math.min(.2*s,40);e.strokeStyle=n,e.lineWidth=o,e.lineCap=i;for(let n=0;t.length-1>n;n++){const o=(a[n]+a[n+1])/2;let i=r;l>o&&(i*=o/l),l>s-o&&(i*=(s-o)/l),e.globalAlpha=Math.max(0,i),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}function Ge(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Ye(e,t,n=.3){Ge(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function qe(e,t,n=.6){var o,r,i,a,s;if(!Ge(t))return;const l=null!==(o=t._pulseGlowRadius)&&void 0!==o?o:4,c=t.r+l*t._pulseIntensity,u=null!==(i=null!==(r=t.cx)&&void 0!==r?r:t.x)&&void 0!==i?i:0,d=null!==(s=null!==(a=t.cy)&&void 0!==a?a:t.y)&&void 0!==s?s:0;e.beginPath(),e.arc(u,d,c,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function Xe(e,t,n,o=.35){Ge(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill())}function Ve(e){switch(e){case"monotoneX":return l.curveMonotoneX;case"monotoneY":return l.curveMonotoneY;case"cardinal":return l.curveCardinal;case"catmullRom":return l.curveCatmullRom;case"step":return l.curveStep;case"stepBefore":return l.curveStepBefore;case"stepAfter":return l.curveStepAfter;case"basis":return l.curveBasis;case"natural":return l.curveNatural;default:return null}}function Ue(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 Ke(e,t){const n=Ve(t.curve);if(!n||2>t.topPath.length||2>t.bottomPath.length){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()}else{const o=l.area().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),o(t.topPath)}}const Qe=(e,t,n,o)=>{var r,i,a;const s=t.filter(e=>"area"===e.type);for(const t of s){if(2>t.topPath.length)continue;const n=t.style.fill||"#4e79a7",o=t._decayOpacities;if(o&&o.length===t.topPath.length){const i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:.7;e.fillStyle=n;for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(o[n]+o[n+1])*i,e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.lineTo(t.bottomPath[n+1][0],t.bottomPath[n+1][1]),e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(o[n]+o[n+1]),e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.stroke()}e.globalAlpha=1;continue}const s=null!==(i=t.style.opacity)&&void 0!==i?i:1;if(Ke(e,t),t.fillGradient){let o=1/0;for(const e of t.topPath)o>e[1]&&(o=e[1]);let r=-1/0;for(const e of t.bottomPath)e[1]>r&&(r=e[1]);const i=Ue(n),a=t.fillGradient.topOpacity,l=t.fillGradient.bottomOpacity,c=e.createLinearGradient(0,o,0,r);c.addColorStop(0,`rgba(${i[0]},${i[1]},${i[2]},${a})`),c.addColorStop(1,`rgba(${i[0]},${i[1]},${i[2]},${l})`),e.fillStyle=c,e.globalAlpha=s}else{const o=null!==(a=t.style.fillOpacity)&&void 0!==a?a:.7;e.globalAlpha=o*s,e.fillStyle=n}if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(Ke(e,t),Xe(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=s,e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const n=Ve(t.curve);if(e.beginPath(),n)l.line().x(e=>e[0]).y(e=>e[1]).curve(n).context(e)(t.topPath);else{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}},Ze=(e,t,n,o)=>{var r;const i=t.filter(e=>"point"===e.type);e.save();try{for(const t of i){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;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()),qe(e,t),e.globalAlpha=1}}finally{e.restore()}},Je=(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?et(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))),Ye(e,t),e.globalAlpha=1};function et(e,t){const n=t.style.icon,o=t.style.iconPadding||2,r=Math.min(t.w,t.h)-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()}function tt(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>128?"#000":"#fff"}function nt(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}const ot={line:[Qe,(e,t,n,o)=>{var r,i;const a=t.filter(e=>"line"===e.type);for(const s of a){if(2>s.path.length)continue;const c=s.style.stroke||"#007bff",u=s.style.strokeWidth||2,d=s.colorThresholds,h=s.rawValues;if(e.setLineDash(s.style.strokeDasharray?s.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=s.style.opacity&&(e.globalAlpha=s.style.opacity),e.lineWidth=u,e.lineCap=s.style.strokeLinecap||"butt",s.style._edgeFade){const y=null!==(r=s.style.opacity)&&void 0!==r?r:1;Fe(e,s.path,c,u,y,s.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const g=$e(s.curve),f=d&&d.length>0&&h&&h.length===s.path.length,p=s._decayOpacities;if(p&&p.length===s.path.length&&!f){e.strokeStyle=c;const m=null!==(i=s.style.opacity)&&void 0!==i?i:1;for(let v=0;s.path.length-1>v;v++)e.globalAlpha=.5*(p[v]+p[v+1])*m,e.beginPath(),e.moveTo(s.path[v][0],s.path[v][1]),e.lineTo(s.path[v+1][0],s.path[v+1][1]),e.stroke()}else if(f){let b=null,x=null,k=null,w=null,A=!1;function S(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),A=!0}function E(){A&&(e.stroke(),A=!1)}for(let O=0;s.path.length>O;O++){const[M,P]=s.path[O],C=h[O],L=ze(C,d,c);if(null!==b&&null!==w&&null!==k){if(L===w)e.lineTo(M,P);else{const j=[];for(const N of d){const D=N.value;(k>D||D>C)&&(D>k||C>D)||k===D||C===D||j.push({t:(D-k)/(C-k)})}j.sort((e,t)=>e.t-t.t);for(const _ of j){const B=b+(M-b)*_.t,H=x+(P-x)*_.t,R=ze(k+(C-k)*Math.min(_.t+1e-4,1),d,c);e.lineTo(B,H),E(),S(R,B,H)}e.lineTo(M,P)}b=M,x=P,k=C,w=L}else S(L,M,P),b=M,x=P,k=C,w=L}E()}else{if(e.beginPath(),e.strokeStyle=c,g)l.line().x(e=>e[0]).y(e=>e[1]).curve(g).context(e)(s.path);else{const[T,W]=s.path[0];e.moveTo(T,W);for(let I=1;s.path.length>I;I++)e.lineTo(s.path[I][0],s.path[I][1])}e.stroke()}if(s.style.fill&&s.style.fillOpacity&&s.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=s.style.fillOpacity,e.fillStyle=s.style.fill,g&&!f)l.line().x(e=>e[0]).y(e=>e[1]).curve(g).context(e)(s.path);else{const[z,F]=s.path[0];e.moveTo(z,F);for(let G=1;s.path.length>G;G++)e.lineTo(s.path[G][0],s.path[G][1])}const $=s.path[0][0];e.lineTo(s.path[s.path.length-1][0],o.height),e.lineTo($,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}}],area:[Qe],stackedarea:[Qe],scatter:[Ze],bubble:[Ze],heatmap:[(e,t,n,o)=>{const r=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of r){const n=t.style;if(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),Ye(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const n=t.valueFormat?t.valueFormat(t.value):nt(t.value),o=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),r=t.x+t.w/2,i=t.y+t.h/2;e.fillStyle=tt(t.fill),e.font=o+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,r,i)}}}finally{e.restore()}}],bar:[Je],swarm:[Ze],waterfall:[(e,t,n,o)=>{var r,i,a;Je(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.save();const o=t._decayOpacity;null!=o&&1!==o&&(e.globalAlpha=o),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 r=Math.min(t.openY,t.closeY),i=Math.abs(t.openY-t.closeY),a=t.isUp?t.upColor:t.downColor;e.fillStyle=a,e.fillRect(t.x-t.bodyWidth/2,r,t.bodyWidth,Math.max(i,1)),e.strokeStyle=a,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,r,t.bodyWidth,Math.max(i,1)),e.restore()}}]},rt={top:20,right:20,bottom:30,left:40},it={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"},at={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 st({hover:e}){const t=e=>Number.isInteger(e)?e+"":e.toFixed(2);return p.createElement("div",{className:"semiotic-tooltip",style:at},p.createElement("div",{style:{fontWeight:600,marginBottom:2}},t(e.value)),p.createElement("div",{style:{opacity:.7,fontSize:11}},t(e.time)))}function lt({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 f=e.useRef(c);return f.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=f.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]),p.createElement("svg",{ref:d,width:i,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},p.createElement("g",{className:"brush-g",transform:`translate(${s.left},${s.top})`}))}const ct=e.forwardRef(function(t,n){var o,r,i,a,s,l,c,u,d;const{chartType:h,runtimeMode:g,data:f,chunkThreshold:y,chunkSize:v,xAccessor:b,yAccessor:x,colorAccessor:k,sizeAccessor:w,groupAccessor:A,lineDataAccessor:S,curve:E,normalize:O,binSize:M,valueAccessor:P,arrowOfTime:C="right",windowMode:L="sliding",windowSize:j=200,timeAccessor:N,xExtent:D,yExtent:_,extentPadding:B=.1,sizeRange:H,size:R=[500,300],responsiveWidth:T,responsiveHeight:W,margin:I,className:z,background:F,lineStyle:q,pointStyle:Q,areaStyle:ne,waterfallStyle:oe,swarmStyle:re,barColors:ie,colorScheme:ae,boundsAccessor:se,boundsStyle:le,y0Accessor:ce,gradientFill:ue,openAccessor:de,highAccessor:he,lowAccessor:ge,closeAccessor:fe,candlestickStyle:pe,showAxes:ye=!0,axes:me,xLabel:ve,yLabel:be,xFormat:xe,yFormat:ke,tickFormatTime:Ae,tickFormatValue:Se,hoverAnnotation:Me,tooltipContent:Ce,customHoverBehavior:je,enableHover:De,annotations:_e,svgAnnotationRules:Be,showGrid:He,legend:Re,legendHoverBehavior:$e,legendClickBehavior:ze,legendHighlightedCategory:Fe,legendIsolatedCategories:Ge,legendPosition:Ye,backgroundGraphics:qe,foregroundGraphics:Xe,canvasPreRenderers:Ve,title:Ue,categoryAccessor:Ke,brush:Qe,onBrush:Ze,decay:Je,pulse:et,transition:tt,staleness:nt,heatmapAggregation:at,heatmapXBins:ct,heatmapYBins:ut,showValues:dt,heatmapValueFormat:ht,marginalGraphics:gt,pointIdAccessor:ft,xScaleType:pt,yScaleType:yt,accessibleTable:mt}=t,[vt,bt]=ee(R,T,W),xt=Object.assign(Object.assign({},rt),I);if(gt){const e=60;gt.top&&e>xt.top&&(xt.top=e),gt.bottom&&e>xt.bottom&&(xt.bottom=e),gt.left&&e>xt.left&&(xt.left=e),gt.right&&e>xt.right&&(xt.right=e)}const kt=bt[0]-xt.left-xt.right,wt=bt[1]-xt.top-xt.bottom,At="function"==typeof Xe?Xe({size:bt,margin:xt}):Xe,St="function"==typeof qe?qe({size:bt,margin:xt}):qe,Et=null!=Me?Me:De,Ot=e.useRef(null),Mt=e.useRef(null),Pt=e.useRef(0),Ct=e.useRef(!1),Lt=Te(e=>e.theme),[jt,Nt]=e.useState(0),[Dt,_t]=e.useState(null),Bt=e.useRef(null),Ht=e.useRef(null),[Rt,Tt]=e.useState(null),[Wt,It]=e.useState(!1),[$t,zt]=e.useState([]),[Ft,Gt]=e.useState([]),Yt=e.useRef(()=>{}),qt="streaming"===g||["bar","swarm","waterfall"].includes(h),Xt=e.useMemo(()=>({chartType:h,runtimeMode:qt?"streaming":"bounded",windowSize:j,windowMode:L,arrowOfTime:qt?C:"right",extentPadding:B,xAccessor:qt?void 0:b,yAccessor:qt?void 0:x,timeAccessor:qt?N:void 0,valueAccessor:P,colorAccessor:k,sizeAccessor:w,groupAccessor:A,categoryAccessor:Ke,lineDataAccessor:S,xScaleType:pt,yScaleType:yt,xExtent:D,yExtent:_,sizeRange:H,binSize:M,normalize:O,boundsAccessor:se,boundsStyle:le,y0Accessor:ce,gradientFill:"boolean"==typeof ue?ue?{topOpacity:.8,bottomOpacity:.05}:void 0:ue,openAccessor:de,highAccessor:he,lowAccessor:ge,closeAccessor:fe,candlestickStyle:pe,lineStyle:q,pointStyle:Q,areaStyle:ne,swarmStyle:re,waterfallStyle:oe,colorScheme:ae,barColors:ie,annotations:_e,decay:Je,pulse:et,transition:tt,staleness:nt,heatmapAggregation:at,heatmapXBins:ct,heatmapYBins:ut,showValues:dt,heatmapValueFormat:ht,pointIdAccessor:ft,curve:E}),[h,j,L,C,B,b,x,N,P,pt,yt,k,w,A,Ke,S,D,_,H,M,O,se,le,ce,ue,de,he,ge,fe,pe,q,Q,ne,re,oe,ae,ie,_e,Je,et,tt,nt,at,ct,ut,dt,ht,qt,ft,E]),Vt=e.useRef(null);Vt.current||(Vt.current=new $(Xt));const Ut=e.useCallback(()=>{Pt.current||(Pt.current=requestAnimationFrame(()=>Yt.current()))},[]);e.useEffect(()=>{var e;null===(e=Vt.current)||void 0===e||e.updateConfig(Xt),Ct.current=!0,Ut()},[Xt,Ut]),e.useEffect(()=>{Ct.current=!0,Ut()},[Lt,Ut]);const Kt=e.useRef(null);Kt.current||(Kt.current=new m(e=>{const t=Vt.current;t&&t.ingest(e)&&(Ct.current=!0,Ut())},{chunkThreshold:y,chunkSize:v})),e.useEffect(()=>{var e;null===(e=Kt.current)||void 0===e||e.updateChunkOptions({chunkThreshold:y,chunkSize:v})},[y,v]);const Qt=e.useCallback(e=>{var t;null===(t=Kt.current)||void 0===t||t.push(e)},[]),Zt=e.useCallback(e=>{var t;null===(t=Kt.current)||void 0===t||t.pushMany(e)},[]),Jt=e.useCallback(()=>{var e,t;null===(e=Kt.current)||void 0===e||e.clear(),null===(t=Vt.current)||void 0===t||t.clear(),Ct.current=!0,Ut()},[Ut]);e.useImperativeHandle(n,()=>({push:Qt,pushMany:Zt,clear:Jt,getData:()=>{var e,t,n;return null===(e=Kt.current)||void 0===e||e.flush(),null!==(n=null===(t=Vt.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var e,t;return null!==(t=null===(e=Vt.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=Vt.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[Qt,Zt,Jt]),e.useEffect(()=>{var e;f&&(null===(e=Kt.current)||void 0===e||e.setBoundedData(f))},[f]);const en=e.useRef(()=>{}),tn=e.useRef(()=>{});en.current=e=>{if(!Et)return;const t=Ot.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-xt.left,r=e.clientY-n.top-xt.top;if(0>o||o>kt||0>r||r>wt)return void(Bt.current&&(Bt.current=null,Ht.current=null,Tt(null),je&&(je(null),Ct.current=!0),Ut()));const i=Vt.current;if(!i||0===i.scene.length)return;const a=function(e,t,n,o=30,r){let i=null,a=!1;if(r){const e=r.find(t,n,o);if(e){const r=G(e,t,n);r&&o>r.distance&&(i=r,a=!0)}}for(const s of e){let e=null;switch(s.type){case"point":if(r&&a)break;e=G(s,t,n);break;case"line":e=Y(s,t,n);break;case"rect":e=X(s,t,n);break;case"heatcell":e=V(s,t,n);break;case"area":if(!1===s.interactive)break;e=K(s,t,n);break;case"candlestick":e=U(s,t,n)}e&&o>e.distance&&(i&&e.distance>=i.distance||(i=e))}return i}(i.scene,o,r,30,i.quadtree);if(!a)return void(Bt.current&&(Bt.current=null,Ht.current=null,Tt(null),je&&je(null),Ut()));const s=a.datum||{},l=Object.assign(Object.assign({},"object"!=typeof s||null===s||Array.isArray(s)?{}:s),{data:s,time:a.x,value:a.y,x:a.x,y:a.y});Bt.current=l,Ht.current=a.node,Tt(l),je&&(je(l),Ct.current=!0),Ut()},tn.current=()=>{Bt.current&&(Bt.current=null,Ht.current=null,Tt(null),je&&(je(null),Ct.current=!0),Ut())},e.useCallback(e=>en.current(e),[]);const nn=e.useCallback(()=>tn.current(),[]),on=e.useRef(-1),rn=e.useCallback(e=>{const t=Vt.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>on.current?-1:on.current,r=Z(e.key,0>o?-1:o,n.length);if(null===r)return;if(e.preventDefault(),0>r)return on.current=-1,Bt.current=null,Ht.current=null,Tt(null),je&&je(null),void Ut();const i=0>o?0:r;on.current=i;const a=J(n[i]);Bt.current=a,Tt(a),je&&je(a),Ut()},[je,Ut]),an=e.useCallback(e=>{on.current=-1,en.current(e)},[]);Yt.current=()=>{var e,t;Pt.current=0;const n=Ot.current,o=Mt.current;if(!n||!o)return;const r=Vt.current;if(!r)return;const i="undefined"!=typeof performance?performance.now():Date.now(),a=r.advanceTransition(i),s=Ct.current||a;s&&!a&&r.computeScene({width:kt,height:wt});const l=Ie(),c=function(e){if(!e)return it;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||it.axisStroke,tickText:i||it.tickText,crosshair:i?i+"66":it.crosshair,hoverFill:l?l+"4D":it.hoverFill,hoverStroke:i?i+"99":it.hoverStroke,pointRing:l||it.pointRing}:it}(n),u=null!==(e=null==nt?void 0:nt.threshold)&&void 0!==e?e:5e3,d=nt&&r.lastIngestTime>0&&i-r.lastIngestTime>u;if(s){const e=We(n,bt,xt,l);if(e){e.clearRect(-xt.left,-xt.top,bt[0],bt[1]),d&&(e.globalAlpha=null!==(t=null==nt?void 0:nt.dimOpacity)&&void 0!==t?t:.5);const o=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=F||(o&&"transparent"!==o?o:null);if(i&&(e.fillStyle=i,e.fillRect(-xt.left,-xt.top,bt[0],bt[1])),e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,kt,wt),e.clip()),Ve&&r.scales)for(const t of Ve)e.save(),t(e,r.scene,r.scales,{width:kt,height:wt}),e.restore();const a=ot[h];if(a&&r.scales)for(const t of a)t(e,r.scene,r.scales,{width:kt,height:wt});e.restore(),d&&(e.globalAlpha=1)}}{const e=We(o,bt,xt,l);if(e&&(e.clearRect(-xt.left,-xt.top,bt[0],bt[1]),Et&&Bt.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,Bt.current,kt,wt,"object"==typeof Et?Et:{},0,c),Ht.current&&Array.isArray(Me))){const t=Me.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)}}s&&n&&n.setAttribute("aria-label",Pe(r.scene,h+" chart"));const g=Ct.current;if(Ct.current=!1,g&&r.scales&&((!Dt||Dt.x.domain()[0]!==r.scales.x.domain()[0]||Dt.x.domain()[1]!==r.scales.x.domain()[1]||Dt.y.domain()[0]!==r.scales.y.domain()[0]||Dt.y.domain()[1]!==r.scales.y.domain()[1]||Dt.x.range()[0]!==r.scales.x.range()[0]||Dt.x.range()[1]!==r.scales.x.range()[1]||Dt.y.range()[0]!==r.scales.y.range()[0]||Dt.y.range()[1]!==r.scales.y.range()[1])&&_t(r.scales),gt)){const e=r.getData(),t="function"==typeof b?b:e=>e[b||"x"],n="function"==typeof x?x:e=>e[x||"y"];zt(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),Gt(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}g&&_e&&_e.length>0&&Nt(e=>e+1),(null==nt?void 0:nt.showBadge)&&It(!!d),(a||r.hasActivePulses)&&(Pt.current=requestAnimationFrame(()=>Yt.current()))},e.useEffect(()=>(Ut(),()=>{Pt.current&&(cancelAnimationFrame(Pt.current),Pt.current=0)}),[Ut]),e.useEffect(()=>{Ct.current=!0,Ut()},[h,kt,wt,ye,F,q,Ve,Ut]),te(nt,Vt,Ct,Ut,Wt,It);const sn=Et&&Rt?Ce?Ce(Rt):p.createElement(st,{hover:Rt}):null,ln=sn?p.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:xt.left+Rt.x,top:xt.top+Rt.y,transform:`translate(${Rt.x>.7*kt?"calc(-100% - 12px)":"12px"}, ${.3*wt>Rt.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1,width:"max-content"}},sn):null,cn=on.current>=0&&Rt?p.createElement("svg",{style:{position:"absolute",left:0,top:0,width:bt[0],height:bt[1],pointerEvents:"none",zIndex:2}},p.createElement("circle",{cx:Rt.x+xt.left,cy:Rt.y+xt.top,r:8,fill:"none",stroke:"var(--accent, #6366f1)",strokeWidth:2,strokeDasharray:"4,2"})):null;if(Oe){const e=Vt.current;e&&f&&(e.ingest({inserts:f,bounded:!0}),e.computeScene({width:kt,height:wt}));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 p.createElement("div",{className:"stream-xy-frame"+(z?" "+z:""),role:"img","aria-label":"string"==typeof Ue?Ue:"XY chart",style:{position:"relative",width:bt[0],height:bt[1]}},p.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:bt[0],height:bt[1],style:{position:"absolute",left:0,top:0}},St,p.createElement("g",{transform:`translate(${xt.left},${xt.top})`},F&&p.createElement("rect",{x:0,y:0,width:kt,height:wt,fill:F}),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 p.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 p.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 p.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 p.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":{const n=e;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const e=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[o,r,i]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(n.fill),a=.299*o+.587*r+.114*i>128?"#000":"#fff",s=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return p.createElement("g",{key:"heatcell-"+t},p.createElement("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),p.createElement("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:s+"px"},e))}return p.createElement("rect",{key:"heatcell-"+t,x:n.x,y:n.y,width:n.w,height:n.h,fill:n.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 p.createElement("g",{key:"candle-"+t},p.createElement("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),p.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))),p.createElement(Ee,{width:kt,height:wt,totalWidth:bt[0],totalHeight:bt[1],margin:xt,scales:n,showAxes:ye,axes:me,xLabel:ve,yLabel:be,xFormat:xe||Ae,yFormat:ke||Se,showGrid:He,title:Ue,legend:Re,legendHoverBehavior:$e,legendClickBehavior:ze,legendHighlightedCategory:Fe,legendIsolatedCategories:Ge,legendPosition:Ye,foregroundGraphics:At,marginalGraphics:gt,xValues:[],yValues:[],annotations:_e,svgAnnotationRules:Be,annotationFrame:0,xAccessor:"string"==typeof b?b:"string"==typeof N?N:void 0,yAccessor:"string"==typeof x?x:"string"==typeof P?P:void 0,annotationData:null==e?void 0:e.getData(),pointNodes:null==e?void 0:e.scene.filter(e=>"point"===e.type),curve:"string"==typeof E?E:void 0}))}return p.createElement("div",{ref:vt,className:"stream-xy-frame"+(z?" "+z:""),role:"img","aria-label":"string"==typeof Ue?Ue:"XY chart",tabIndex:0,style:{position:"relative",width:T?"100%":bt[0],height:W?"100%":bt[1],overflow:"visible"},onMouseMove:Et?an:void 0,onMouseLeave:Et?nn:void 0,onKeyDown:rn},St&&p.createElement("svg",{style:{position:"absolute",left:0,top:0,width:bt[0],height:bt[1],pointerEvents:"none"}},St),p.createElement(we,{width:kt,height:wt,totalWidth:bt[0],totalHeight:bt[1],margin:xt,scales:Dt,showAxes:ye,axes:me,showGrid:He,xFormat:xe||Ae,yFormat:ke||Se}),p.createElement("canvas",{ref:Ot,"aria-label":Pe(null!==(a=null===(i=Vt.current)||void 0===i?void 0:i.scene)&&void 0!==a?a:[],h+" chart"),style:{position:"absolute",left:0,top:0}}),p.createElement("canvas",{ref:Mt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),p.createElement(Ne,{hoverPoint:Rt}),mt&&p.createElement(Le,{scene:null!==(l=null===(s=Vt.current)||void 0===s?void 0:s.scene)&&void 0!==l?l:[],chartType:h+" chart"}),p.createElement(Ee,{width:kt,height:wt,totalWidth:bt[0],totalHeight:bt[1],margin:xt,scales:Dt,showAxes:ye,axes:me,xLabel:ve,yLabel:be,xFormat:xe||Ae,yFormat:ke||Se,showGrid:He,title:Ue,legend:Re,legendHoverBehavior:$e,legendClickBehavior:ze,legendHighlightedCategory:Fe,legendIsolatedCategories:Ge,legendPosition:Ye,foregroundGraphics:At,marginalGraphics:gt,xValues:$t,yValues:Ft,annotations:_e,svgAnnotationRules:Be,annotationFrame:jt,xAccessor:"string"==typeof b?b:"string"==typeof N?N:void 0,yAccessor:"string"==typeof x?x:"string"==typeof P?P:void 0,annotationData:null===(c=Vt.current)||void 0===c?void 0:c.getData(),pointNodes:null===(u=Vt.current)||void 0===u?void 0:u.scene.filter(e=>"point"===e.type),curve:"string"==typeof E?E:void 0,underlayRendered:!0}),(Qe||Ze)&&p.createElement(lt,{width:kt,height:wt,totalWidth:bt[0],totalHeight:bt[1],margin:xt,dimension:null!==(d=null==Qe?void 0:Qe.dimension)&&void 0!==d?d:"xy",scales:Dt,onBrush:null!=Ze?Ze:()=>{}}),(null==nt?void 0:nt.showBadge)&&p.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===nt.badgePosition?{top:4,left:4}:"bottom-left"===nt.badgePosition?{bottom:4,left:4}:"bottom-right"===nt.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Wt?"#dc3545":"#28a745",color:"white"})},Wt?"STALE":"LIVE"),cn,ln)});ct.displayName="StreamXYFrame";const ut=e.createContext(null);function dt({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:C[o]||L,t={};for(let o=0;n.length>o;o++)t[n[o]]=e[o%e.length];return t}return{}},[t,n,o]);return p.createElement(ut.Provider,{value:i},r)}function ht(){return e.useContext(ut)}function gt(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 ft(e,t){const n=[];for(const[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(gt(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}function pt(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}dt.displayName="CategoryColorProvider";const[yt,mt]=De(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),r=pt(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=pt(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}})}})),[vt,bt]=De(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 xt(t){const n=e.useId(),o=t.clientId||n,{name:r}=t,i=mt(e=>e.selections.get(r)),a=mt(e=>e.setClause),s=mt(e=>e.clearClause),l=e.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:e.useMemo(()=>i&&0!==i.clauses.size?ft(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 kt(t){const n=t.name||"hover",{fields:o}=t,{predicate:r,isActive:i,selectPoints:a,clear:s}=xt({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 wt(t){const{name:n,xField:o,yField:r}=t,{predicate:i,isActive:a,selectInterval:s,clear:l}=xt({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 At(t={}){const{limit:n=50,types:o,chartId:r}=t,i=bt(e=>e.version),a=bt(e=>e.observations),s=bt(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 St=e.createContext(!1);function Et({selections:t}){const n=mt(e=>e.setResolution);return e.useEffect(()=>{for(const[e,o]of Object.entries(t))o.resolution&&n(e,o.resolution)},[t,n]),null}function Ot({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||"#333",stroke:e.color||"#333"}),type:"fill",items:i.map(([e,t])=>({label:e,color:t})),label:""}],l=kt({name:o,fields:[r]}),c=xt({name:o,clientId:"__linked-legend-isolate__"}),[u,d]=e.useState(new Set),[h,g]=e.useState(null),f=e.useRef(c.selectPoints);f.current=c.selectPoints;const y=e.useRef(c.clear);y.current=c.clear,e.useEffect(()=>{"isolate"===n&&(u.size>0?f.current({[r]:Array.from(u)}):y.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 p.createElement("svg",{width:"100%",height:30,style:{display:"block",overflow:"visible"}},p.createElement(se,{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 Mt({children:e,selections:t,showLegend:n,legendPosition:o="top",legendInteraction:r="none",legendSelectionName:i="legend",legendField:a="category"}){const s=ht(),l=void 0!==n?n:!(!s||0>=Object.keys(s).length);return p.createElement(yt,null,p.createElement(vt,null,t&&p.createElement(Et,{selections:t}),p.createElement(St.Provider,{value:l},l&&"top"===o&&s&&p.createElement(Ot,{categoryColors:s,interaction:r,selectionName:i,field:a}),e,l&&"bottom"===o&&s&&p.createElement(Ot,{categoryColors:s,interaction:r,selectionName:i,field:a}))))}function Pt({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=e.color||"#333",n={fill:t,stroke:t};return void 0!==r&&(n.stroke=r),void 0!==i&&(n.strokeWidth=i),n},type:"fill",items:a,label:""}]}}function Ct(e){return e?"string"==typeof e?{name:e}:e:null}function Lt(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 jt="#007bff";function Nt(e){return"function"==typeof e?e:t=>t[e]}function Dt(t,n,o="category10"){const r=ht();return e.useMemo(()=>{if(n){if(0===t.length)return r&&Object.keys(r).length>0?e=>r[e]||"#999":void 0;if("function"==typeof n){const e=Array.from(new Set(t.map(e=>n(e)+"")));return r&&Object.keys(r).length>0?e=>r[e]||"#999":B(e.map(e=>({_cat:e})),"_cat",o)}if(r&&Object.keys(r).length>0){const e=B(t,n,o);return t=>r[t]||e(t)}return B(t,n,o)}},[t,n,o,r])}function _t(t,n,o){return e.useMemo(()=>{if(!n)return t;const e=[...t];if("function"==typeof n)return e.sort(n);const r=Nt(o);return e.sort("asc"===n?(e,t)=>r(e)-r(t):(e,t)=>r(t)-r(e))},[t,n,o])}function Bt({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=xt({name:(null==t?void 0:t.name)||"__unused__"}),u=kt({name:(null==l?void 0:l.name)||"hover",fields:(null==l?void 0:l.fields)||o||[]}),d=bt(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 Ht({data:t,colorBy:n,colorScale:o,showLegend:r,legendPosition:i="right",userMargin:a,defaults:s={top:50,bottom:60,left:70,right:40}}){const l=e.useContext(St),c=void 0!==r?r:!l&&!!n,u=e.useMemo(()=>{if(c&&n)return Pt({data:t,colorBy:n,colorScale:o,getColor:_})},[c,n,t,o]),d=e.useMemo(()=>{const e=Object.assign(Object.assign({},s),a);return u&&("right"===i&&110>e.right?e.right=110:"left"===i&&110>e.left?e.left=110:"top"===i&&50>e.top?e.top=50:"bottom"===i&&80>e.bottom&&(e.bottom=80)),e},[s,a,u,i]);return{legend:u,margin:d,legendPosition:i}}function Rt(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 Tt={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 Wt(e,t,n){var o,r,i,a,s,l;const c=Tt[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}}const It={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 $t(e,t){return"function"==typeof t?t(e):e[t]}function zt(e,t){return t?t(e):null==e?"":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":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 Ft(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=$t(e,n);a=zt(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=$t(e,r);s.push({label:n,value:zt(a,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){a=zt(e[n],o);break}if(!a){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(a=zt(e[t[0]],o))}}const l=Object.assign(Object.assign({},It),r);return p.createElement("div",{className:("semiotic-tooltip "+i).trim(),style:l},a&&p.createElement("div",{style:{fontWeight:s.length>0?"bold":"normal"}},a),s.map((e,t)=>p.createElement("div",{key:t,style:{marginTop:0===t&&a?"4px":0}},e.label&&p.createElement("span",null,e.label,": "),e.value)))}}function Gt(e){if(!0===e)return Ft();if("function"==typeof e){const t=e;return e=>{const n=t(!e||"object"!=typeof e.data||null===e.data||"node"!==e.type&&"edge"!==e.type?e:e.data);return null==n?null:p.createElement("div",{className:"semiotic-tooltip",style:It},n)}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?Ft(e):Ft())}function Yt(e){return"string"==typeof e?e:"value"}function qt(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function Xt(e,t){return"function"==typeof t?t(e):e[t]}function Vt(e){const t=e.find(e=>"title"===e.role),n=e.filter(e=>"title"!==e.role);return e=>{const o=e.data;if(!o)return null;const r=t?qt(Xt(o,t.accessor)):null;return p.createElement("div",{className:"semiotic-tooltip",style:It},r&&p.createElement("div",{style:{fontWeight:"bold",marginBottom:n.length>0?4:0}},r),n.map((e,t)=>{const n=qt(Xt(o,e.accessor));return p.createElement("div",{key:t,style:t>0?{marginTop:2}:void 0},p.createElement("span",{style:{opacity:.7}},e.label,": "),p.createElement("span",null,n))}))}}function Ut({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=Xt(s,e),c=Xt(s,t),u=n?Xt(s,n):void 0;return p.createElement("div",{className:"semiotic-tooltip",style:It},p.createElement("div",{style:{fontWeight:"bold"}},qt(l)),p.createElement("div",{style:{marginTop:4}},qt(c)),null!=u&&p.createElement("div",{style:{marginTop:2,opacity:.8}},o||Yt(n),": ",qt(u)))}}function Kt({componentName:e,message:t,diagnosticHint:n,width:o,height:r}){return p.createElement("div",{role:"alert",style:{width:o,height:Math.max(r,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"}},p.createElement("div",{style:{textAlign:"center",maxWidth:400}},p.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),p.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t),n&&p.createElement("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6}},n)))}class Qt extends p.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:p.createElement(Kt,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function Zt(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 Jt(e,t,n=3){let o,r=n+1;for(const n of t){const t=Zt(e.toLowerCase(),n.toLowerCase());r>t&&(r=t,o=n)}return r>n?void 0:o}function en(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function tn(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=Jt(e,t,3))&&void 0!==n?n:null)}function nn({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(null==t)return null;if(!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=en(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=tn(i,t),o=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}function on({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 rn({componentName:e,nodes:t,edges:n,nodesRequired:o=!1,edgesRequired:r=!0,accessors:i}){if(null==t&&null==n)return null;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=en(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=tn(r,t),i=n?` Try ${o}="${n}".`:"";return`${e}: ${o} "${r}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}return null}const an={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:["boolean","function","object"]},frameProps:{type:"object"}},sn={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},ln={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"}},cn=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],un=["vertical","horizontal"],dn={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},an),sn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:cn},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({},an),sn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:cn},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},an),sn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:cn},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({},an),sn),{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({},an),sn),{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({},an),sn),{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"},showLegend:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},QuadrantChart:{required:["quadrants"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},an),sn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},quadrants:{type:"object"},xCenter:{type:"number"},yCenter:{type:"number"},centerlineStyle:{type:"object"},showQuadrantLabels:{type:"boolean"},quadrantLabelSize:{type:"number"},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},ConnectedScatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},an),sn),{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({},an),ln),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:un},sort:{type:["boolean","string","function"]},barPadding:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},an),ln),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:un},normalize:{type:"boolean"},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},an),ln),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:un},barPadding:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},an),ln),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:un},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({},an),ln),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:un},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},an),ln),{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({},an),ln),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:un},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({},an),ln),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:un},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},an),{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({},an),{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({},an),{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({},an),{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:un},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({},an),{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({},an),{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({},an),{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({},an),{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({},an),{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"}}}};function hn(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}function gn(e,t){const n=[],o=dn[e];if(!o)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(dn).join(", ")}`]};for(const r of o.required)null==t[r]&&n.push(`"${r}" is required for ${e}.`);for(const[e,r]of Object.entries(t)){if(null==r)continue;const t=o.props[e];if(t){if(!hn(r,t.type)){const o=Array.isArray(t.type)?t.type.join(" | "):t.type;n.push(`"${e}" should be ${o}, got ${Array.isArray(r)?"array":typeof r}.`);continue}t.enum&&"string"==typeof r&&!t.enum.includes(r)&&n.push(`"${e}" value "${r}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const r=Object.keys(o.props),i=new Set(r);for(const o of Object.keys(t))if(void 0!==t[o]&&!i.has(o)){const t=Jt(o,r),i=t?`Unknown prop "${o}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${o}" for ${e}. Valid props: ${r.join(", ")}.`;n.push(i)}if("array"===o.dataShape){const r=t.data,i={};for(const e of o.dataAccessors){const n=t[e];"string"==typeof n&&(i[e]=n)}const a=nn({componentName:e,data:r,accessors:Object.keys(i).length>0?i:void 0});a&&n.push(a)}else if("object"===o.dataShape){const o=on({componentName:e,data:t.data});o&&n.push(o)}else if("network"===o.dataShape){const r=rn({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:o.required.includes("nodes"),edgesRequired:o.required.includes("edges")});r&&n.push(r)}return{valid:0===n.length,errors:n}}const fn=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),pn=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),yn=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),mn=new Set(["LineChart","AreaChart","StackedAreaChart"]),vn=new Set(["BarChart","StackedBarChart","GroupedBarChart"]);function bn(e,t){const n=[],o=gn(e,t);for(const e of o.errors)n.push({severity:"error",code:"VALIDATION",message:e,fix:""});return dn[e]?(function(e,t,n){const o=dn[e];if(o){if("array"===o.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&n.push({severity:"error",code:"EMPTY_DATA",message:"data is an empty array — chart will render blank.",fix:"Provide at least one data point: data={[{ x: 1, y: 2 }]}."})}"network"===o.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&n.push({severity:"error",code:"EMPTY_EDGES",message:"edges is an empty array — network chart will render blank.",fix:'Provide at least one edge: edges={[{ source: "A", target: "B" }]}.'})}}(e,t,n),function(e,t,n){const o=t.width,r=t.height;if(void 0===o||"number"==typeof o&&o>0||n.push({severity:"error",code:"BAD_WIDTH",message:`width=${JSON.stringify(o)} — chart needs a positive number.`,fix:"Set width={600} or use responsiveWidth={true}."}),void 0===r||"number"==typeof r&&r>0||n.push({severity:"error",code:"BAD_HEIGHT",message:`height=${JSON.stringify(r)} — chart needs a positive number.`,fix:"Set height={400} or use responsiveHeight={true}."}),t.size&&Array.isArray(t.size)){const[e,o]=t.size;(null!=e&&0>=e||null!=o&&0>=o)&&n.push({severity:"error",code:"BAD_SIZE",message:`size=[${e}, ${o}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}(0,t,n),function(e,t,n){const o=dn[e];if(!o||"array"!==o.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const i=r[0];if(!i||"object"!=typeof i)return;const a=Object.keys(i);for(const e of o.dataAccessors){const o=t[e];"string"==typeof o&&(o in i||n.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${o}" not found in data. Available fields: ${a.join(", ")}.`,fix:`Change ${e} to one of: ${a.map(e=>`"${e}"`).join(", ")}.`}))}}(e,t,n),function(e,t,n){fn.has(e)&&Array.isArray(t.data)&&n.push({severity:"error",code:"HIERARCHY_FLAT_ARRAY",message:e+" expects hierarchical data but received a flat array.",fix:'Pass a root object: data={{ name: "root", children: [...] }}. For flat data, use BarChart or LineChart.'})}(e,t,n),function(e,t,n){pn.has(e)&&(t.edges||t.data||n.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}(e,t,n),function(e,t,n){const o=dn[e];if(!o||"array"!==o.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const i=r[0];if(!i||"object"!=typeof i)return;const a=t.xAccessor;"string"==typeof a&&i[a]instanceof Date&&!t.xFormat&&n.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${a}" contains Date objects but no xFormat is provided. Axis ticks may display "[object Object]".`,fix:"Add xFormat={d => d.toLocaleDateString()} or use timestamps (d.getTime()) instead of Date objects."})}(e,t,n),function(e,t,n){t.linkedHover&&!t.selection&&n.push({severity:"warning",code:"LINKED_HOVER_NO_SELECTION",message:"linkedHover is set but selection is not — this chart emits hover events but won't highlight from others.",fix:`Add selection={{ name: "${"object"==typeof t.linkedHover&&t.linkedHover.name||"hl"}" }} to receive cross-highlights.`})}(0,t,n),function(e,t,n){var o;if(!yn.has(e))return;const r=t.rExtent||t.yExtent;r&&Array.isArray(r)&&r.length>=1&&null!=r[0]&&0!==r[0]&&n.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${r[0]}). Bar and area charts should start at zero to avoid exaggerating differences.`,fix:`Remove the custom extent minimum or set it to 0: rExtent={[0, ${null!==(o=r[1])&&void 0!==o?o:"auto"}]}. For trend-focused charts, use LineChart instead.`})}(e,t,n),function(e,t,n){if(!mn.has(e))return;if(t.gapStrategy)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const r=t.yAccessor||"y";"string"==typeof r&&o.some(e=>{const t=e[r];return null==t||Number.isNaN(t)})&&n.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${r}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}(e,t,n),function(e,t,n){var o,r;const i=null!==(o=t.width)&&void 0!==o?o:600,a=null!==(r=t.height)&&void 0!==r?r:400,s=t.margin;if(!s||"object"!=typeof s)return;const l=(s.left||0)+(s.right||0),c=(s.top||0)+(s.bottom||0);i>l||n.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${l}px) >= width (${i}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),a>c||n.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${c}px) >= height (${a}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}(0,t,n),function(e,t,n){var o;const r=dn[e];if(!r||"array"!==r.dataShape)return;const i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;const a=[];t.xAccessor&&"string"==typeof t.xAccessor&&a.push({prop:"xAccessor",name:t.xAccessor}),t.yAccessor&&"string"==typeof t.yAccessor&&a.push({prop:"yAccessor",name:t.yAccessor}),t.valueAccessor&&"string"==typeof t.valueAccessor&&a.push({prop:"valueAccessor",name:t.valueAccessor});const s=Math.min(i.length,5);for(const e of a){let t=!0;for(let n=0;s>n;n++){const r=null===(o=i[n])||void 0===o?void 0:o[e.name];if("number"==typeof r&&Number.isFinite(r)){t=!1;break}}t&&n.push({severity:"error",code:"DEGENERATE_EXTENT",message:`${e.prop}="${e.name}" produces NaN or non-finite values for all sampled data points — chart extents will be invalid.`,fix:`Ensure data[].${e.name} contains finite numbers, or use a function accessor to transform values.`})}}(e,t,n),function(e,t,n){if(!vn.has(e))return;const o=t.barPadding;"number"==typeof o&&10>o&&n.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${o} is very small — bars may appear to have no spacing between them.`,fix:"Increase barPadding to at least 10 for visible gaps, e.g. barPadding={12}."})}(e,t,n),function(e,t,n){if("bottom"!==t.legendPosition)return;const o=t.margin;if(!o||"object"!=typeof o)return;const r=o.bottom;"number"==typeof r&&70>r&&n.push({severity:"warning",code:"BOTTOM_MARGIN_WITH_LEGEND",message:`legendPosition="bottom" with margin.bottom=${r}px — legend may overlap axis labels.`,fix:"Increase margin.bottom to at least 70, e.g. margin={{ ...margin, bottom: 80 }}."})}(0,t,n),function(e,t,n){var o;if(!t.showLegend)return;if("right"!==(null!==(o=t.legendPosition)&&void 0!==o?o:"right"))return;const r=t.margin;if(!r||"object"!=typeof r)return;const i=r.right;"number"==typeof i&&100>i&&n.push({severity:"warning",code:"LEGEND_MARGIN_TIGHT",message:`showLegend is true with legendPosition="right" but margin.right=${i}px — legend may be clipped or overlap the chart.`,fix:"Increase margin.right to at least 100, e.g. margin={{ ...margin, right: 120 }}."})}(0,t,n),function(e,t,n){if("Heatmap"!==e)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const r=o[0];if(r&&"object"==typeof r)for(const e of["xAccessor","yAccessor"]){const o=t[e];if("string"!=typeof o)continue;const i=r[o];"string"==typeof i&&n.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${o}" resolves to string values (e.g. "${i}"). Heatmap will use categorical axis handling which may produce unexpected cell layout.`,fix:"If you intend categorical axes this is fine. Otherwise, convert values to numbers before passing data."})}}(e,t,n),{ok:n.every(e=>"warning"===e.severity),diagnoses:n}):{ok:0===n.length,diagnoses:n}}var xn;const kn="undefined"!=typeof process&&"production"!==(null===(xn=process.env)||void 0===xn?void 0:xn.NODE_ENV);function wn({componentName:e,width:t,height:n,chartProps:o,children:r}){return p.createElement(Qt,{fallback:r=>{let i="";if(kn&&o)try{const t=bn(e,o);t.ok||(i=t.diagnoses.map(e=>`${"error"===e.severity?"✗":"⚠"} ${e.message}${e.fix?" — Fix: "+e.fix:""}`).join("\n"))}catch(e){}return p.createElement(Kt,{componentName:e,message:r.message,diagnosticHint:i,width:t,height:n})}},r)}const An={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"},Sn={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function En(e,t,n,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?p.createElement("div",{style:Object.assign(Object.assign({},An),{width:t,height:n})},o||"No data available"):null}function On(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 p.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)=>p.createElement("div",{key:n,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Sn),{position:"absolute",top:a+n*(r+i),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:r,opacity:.5+n%2*.2})})))}function Mn(e,t,n,o){if(!kn)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 Pn(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"==typeof SuppressedError&&SuppressedError;let Cn=null;function Ln(){return Pn(this,void 0,void 0,function*(){return Cn||(Cn=yield Promise.resolve().then(function(){return ta})),Cn})}const jn=e.forwardRef(function(t,n){var o,r;const i=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const a=Wt(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:s,margin:l,className:c,xFormat:u,yFormat:d,xAccessor:h="x",yAccessor:g="y",lineBy:f,lineDataAccessor:y="coordinates",colorBy:m,colorScheme:v="category10",curve:b="linear",showPoints:x=!1,pointRadius:k=3,fillArea:w=!1,areaOpacity:A=.3,lineWidth:S=2,tooltip:E,pointIdAccessor:O,annotations:M,directLabel:P,gapStrategy:C="break",anomaly:L,forecast:j,frameProps:N={},selection:D,linkedHover:B,onObservation:H,chartId:R,loading:T,emptyContent:W,legendInteraction:I,legendPosition:$,xScaleType:z,yScaleType:F}=t,G=a.width,Y=a.height,q=a.enableHover,X=a.showGrid,V=a.showLegend,U=a.title,K=a.xLabel,Q=a.yLabel,Z=On(T,G,Y);if(Z)return Z;const J=En(s,G,Y,W);if(J)return J;const ee=s||[];Mn("LineChart",ee,"xAccessor",h),Mn("LineChart",ee,"yAccessor",g);const te="string"==typeof h?h:"x",ne="string"==typeof g?g:"y",[oe,re]=e.useState(null),[ie,ae]=e.useState([]);e.useEffect(()=>{if(!j&&!L)return;let e=!1;return re(null),ae([]),j?function(...e){return Pn(this,void 0,void 0,function*(){return(yield Ln()).buildForecast(...e)})}(ee,te,ne,j,L).then(t=>{e||(re(t),ae(t.annotations))}).catch(()=>{e||(re(null),ae([]))}):L&&function(...e){return Pn(this,void 0,void 0,function*(){return(yield Ln()).buildAnomalyAnnotations(...e)})}(L).then(t=>{e||(re(null),ae(t))}).catch(()=>{e||ae([])}),()=>{e=!0}},[ee,j,L,te,ne]);const se=oe?oe.processedData:ee,le=j&&!f?"__forecastSegment":f,{activeSelectionHook:ce,customHoverBehavior:ue}=Bt({selection:D,linkedHover:B,fallbackFields:m?["string"==typeof m?m:""]:[],onObservation:H,chartType:"LineChart",chartId:R}),de=e.useCallback(e=>{const t="function"==typeof h?h(e):e[h],n="function"==typeof g?g(e):e[g];return null==t||null==n||Number.isNaN(t)||Number.isNaN(n)},[h,g]),he=void 0!==(null===(o=se[0])||void 0===o?void 0:o[y]),ge=e.useMemo(()=>{if(he)return se;if(le){const e=se.reduce((e,t)=>{const n="function"==typeof le?le(t):t[le];if(!e[n]){const t={[y]:[]};"string"==typeof le&&(t[le]=n),e[n]=t}return e[n][y].push(t),e},{});return Object.values(e)}return[{[y]:se}]},[se,le,y,he]),{gapProcessedLineData:fe,hasGaps:pe}=e.useMemo(()=>{if("interpolate"===C){let e=!1;const t=[];for(const n of ge){const o=(n[y]||[]).filter(t=>!de(t)||(e=!0,!1));o.length>0&&t.push(Object.assign(Object.assign({},n),{[y]:o}))}return{gapProcessedLineData:t,hasGaps:e}}if("break"===C){let e=!1;const t=[];for(const n of ge){const o=n[y]||[];let r=[],i=0;const a=le&&"string"==typeof le?n[le]:void 0;for(const s of o)if(de(s))e=!0,r.length>0&&(t.push(Object.assign(Object.assign({},n),{[y]: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),{[y]:r}))}return{gapProcessedLineData:t,hasGaps:e}}if("zero"===C){let e=!1;const t="string"==typeof g?g:"y",n=[];for(const o of ge){const r=o[y]||[],i=[];for(const n of r)de(n)?(e=!0,i.push(Object.assign(Object.assign({},n),{[t]:0}))):i.push(n);n.push(Object.assign(Object.assign({},o),{[y]:i}))}return{gapProcessedLineData:n,hasGaps:e}}return{gapProcessedLineData:ge,hasGaps:!1}},[ge,C,y,de,le,g]),ye=Dt(se,m,v),me=e.useMemo(()=>{if(!m)return[];const e=new Set;for(const t of se){const n="function"==typeof m?m(t):t[m];null!=n&&e.add(n+"")}return Array.from(e)},[se,m]),ve=Rt(I,m,me),be=e.useMemo(()=>ve.legendSelectionHook?ve.legendSelectionHook:ce,[ve.legendSelectionHook,ce]),xe=e.useMemo(()=>e=>{const t={strokeWidth:S};return m?ye&&(t.stroke=_(e,m,ye),w&&(t.fill=t.stroke,t.fillOpacity=A)):(t.stroke=jt,w&&(t.fill=jt,t.fillOpacity=A)),t},[m,ye,S,w,A]),[ke,we]=e.useState(null);e.useEffect(()=>{if(!j)return void we(null);let e=!1;return function(...e){return Pn(this,void 0,void 0,function*(){return(yield Ln()).createSegmentLineStyle(...e)})}(xe,j).then(t=>{e||we(()=>t)}).catch(()=>{e||we(null)}),()=>{e=!0}},[xe,j]);const Ae=ke||xe,Se=e.useMemo(()=>Lt(Ae,be,D),[Ae,be,D]),Ee=e.useMemo(()=>{if(x)return e=>{const t={r:k,fillOpacity:1};return m?ye&&(t.fill=_(e.parentLine||e,m,ye)):t.fill=jt,t}},[x,k,m,ye]),Oe=w?"area":"line",Me="object"==typeof P?P:{},Pe=Me.position||"end",Ce=Me.fontSize||11,Le=e.useMemo(()=>{var e,t;if(!P||!m)return[];const n="function"==typeof h?h:e=>e[h],o="function"==typeof g?g:e=>e[g],r="function"==typeof m?m:e=>e[m],i=new Map;for(const n of fe){const o=n[y]||[];if(0===o.length)continue;const a="end"===Pe?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 h?h:"x"]:n(t),["string"==typeof g?g:"y"]:o(t),dx:"end"===Pe?6:-6,dy:0,color:ye?ye(e):jt,fontSize:Ce}));a.sort((e,t)=>{const n="string"==typeof g?g:"y";return e[n]-t[n]});for(let e=1;a.length>e;e++){const t="string"==typeof g?g:"y",n=a[e-1],o=a[e];Ce+2>Math.abs(o[t]+o.dy-(n[t]+n.dy))&&(o.dy+=Ce+2)}return a},[P,m,ye,fe,y,h,g,Pe,Ce]),je=(!P||void 0!==V)&&V,Ne=e.useMemo(()=>{if(!P)return a.marginDefaults;const e=Le.reduce((e,t)=>{var n;const o=((null===(n=t.label)||void 0===n?void 0:n.length)||0)*(.6*Ce);return Math.max(e,o)},0),t=e+10,n="end"===Pe?"right":"left";return Object.assign(Object.assign({},a.marginDefaults),{[n]:Math.max(a.marginDefaults[n]||0,t)})},[P,Le,Ce,Pe,a.marginDefaults]),{legend:De,margin:_e,legendPosition:Be}=Ht({data:fe,colorBy:m,colorScale:ye,showLegend:je,legendPosition:$,userMargin:l,defaults:Ne}),He=f||m,Re=e.useMemo(()=>Vt([{label:K||Yt(h),accessor:h,role:"x"},{label:Q||Yt(g),accessor:g,role:"y"},...He?[{label:Yt(He),accessor:He,role:"group"}]:[]]),[h,g,K,Q,He]),Te=nn({componentName:"LineChart",data:he?(null===(r=se[0])||void 0===r?void 0:r[y])||[]:s,accessors:{xAccessor:h,yAccessor:g}});if(Te)return p.createElement(Kt,{componentName:"LineChart",message:Te,width:G,height:Y});const We=e.useMemo(()=>he||le||pe?fe.flatMap(e=>{const t=e[y]||[];return le&&"string"==typeof le?t.map(t=>Object.assign(Object.assign({},t),{[le]:e[le]})):t}):se,[fe,y,he,le,se,pe]),Ie=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:Oe},null!=s&&{data:We}),{xAccessor:h,yAccessor:g,xScaleType:z,yScaleType:F,groupAccessor:"break"===C&&pe?"_gapSegment":le||void 0,curve:b,lineStyle:Se}),x&&{pointStyle:Ee}),{size:[G,Y],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:_e,showAxes:a.showAxes,xLabel:K,yLabel:Q,xFormat:u,yFormat:d,enableHover:q,showGrid:X}),De&&{legend:De,legendPosition:Be}),I&&"none"!==I&&{legendHoverBehavior:ve.onLegendHover,legendClickBehavior:ve.onLegendClick,legendHighlightedCategory:ve.highlightedCategory,legendIsolatedCategories:ve.isolatedCategories}),U&&{title:U}),c&&{className:c}),{tooltipContent:!1===E?()=>null:Gt(E)||Re}),(B||H)&&{customHoverBehavior:ue}),O&&{pointIdAccessor:O}),((null==M?void 0:M.length)||ie.length||Le.length)&&{annotations:[...M||[],...ie,...Le]}),N);return p.createElement(wn,{componentName:"LineChart",width:G,height:Y},p.createElement(ct,Object.assign({ref:i},Ie)))});jn.displayName="LineChart";const Nn=e.forwardRef(function(t,n){var o;const r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const i=Wt(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:a,margin:s,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",areaBy:g,y0Accessor:f,gradientFill:y=!1,lineDataAccessor:m="coordinates",colorBy:v,colorScheme:b="category10",curve:x="monotoneX",areaOpacity:k=.7,showLine:w=!0,lineWidth:A=2,tooltip:S,annotations:E,frameProps:O={},selection:M,linkedHover:P,onObservation:C,chartId:L,loading:j,emptyContent:N,legendInteraction:D,legendPosition:B}=t,H=i.width,R=i.height,T=i.enableHover,W=i.showGrid,I=i.showLegend,$=i.title,z=i.xLabel,F=i.yLabel,G=On(j,H,R);if(G)return G;const Y=En(a,H,R,N);if(Y)return Y;const q=a||[];Mn("AreaChart",q,"xAccessor",d),Mn("AreaChart",q,"yAccessor",h);const{activeSelectionHook:X,customHoverBehavior:V}=Bt({selection:M,linkedHover:P,fallbackFields:v?["string"==typeof v?v:""]:[],onObservation:C,chartType:"AreaChart",chartId:L}),U=void 0!==(null===(o=q[0])||void 0===o?void 0:o[m]),K=e.useMemo(()=>{if(U)return q;if(g){const e=q.reduce((e,t)=>{const n="function"==typeof g?g(t):t[g];if(!e[n]){const t={[m]:[]};"string"==typeof g&&(t[g]=n),e[n]=t}return e[n][m].push(t),e},{});return Object.values(e)}return[{[m]:q}]},[q,g,m,U]),Q=Dt(q,v,b),Z=e.useMemo(()=>{if(!v)return[];const e=new Set;for(const t of q){const n="function"==typeof v?v(t):t[v];null!=n&&e.add(n+"")}return Array.from(e)},[q,v]),J=Rt(D,v,Z),ee=e.useMemo(()=>J.legendSelectionHook?J.legendSelectionHook:X,[J.legendSelectionHook,X]),te=e.useMemo(()=>e=>{const t={};if(v){if(Q){const n=_(e,v,Q);t.fill=n,w?(t.stroke=n,t.strokeWidth=A):t.stroke="none"}}else t.fill=jt,w?(t.stroke=jt,t.strokeWidth=A):t.stroke="none";return t.fillOpacity=k,t},[v,Q,k,w,A]),ne=e.useMemo(()=>Lt(te,ee,M),[te,ee,M]),{legend:oe,margin:re,legendPosition:ie}=Ht({data:K,colorBy:v,colorScale:Q,showLegend:I,legendPosition:B,userMargin:s,defaults:i.marginDefaults}),ae=g||v,se=e.useMemo(()=>Vt([{label:z||Yt(d),accessor:d,role:"x"},{label:F||Yt(h),accessor:h,role:"y"},...ae?[{label:Yt(ae),accessor:ae,role:"group"}]:[]]),[d,h,z,F,ae]),le=nn({componentName:"AreaChart",data:a,accessors:{xAccessor:d,yAccessor:h}});if(le)return p.createElement(Kt,{componentName:"AreaChart",message:le,width:H,height:R});const ce=e.useMemo(()=>U||g?K.flatMap(e=>{const t=e[m]||[];return g&&"string"==typeof g?t.map(t=>Object.assign(Object.assign({},t),{[g]:e[g]})):t}):q,[K,m,U,g,q]),ue=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area"},null!=a&&{data:ce}),{xAccessor:d,yAccessor:h,groupAccessor:g||void 0}),f&&{y0Accessor:f}),y&&{gradientFill:y}),{curve:x,lineStyle:ne,size:[H,R],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:re,showAxes:i.showAxes,xLabel:z,yLabel:F,xFormat:c,yFormat:u,enableHover:T,showGrid:W}),oe&&{legend:oe,legendPosition:ie}),D&&"none"!==D&&{legendHoverBehavior:J.onLegendHover,legendClickBehavior:J.onLegendClick,legendHighlightedCategory:J.highlightedCategory,legendIsolatedCategories:J.isolatedCategories}),$&&{title:$}),l&&{className:l}),{tooltipContent:!1===S?()=>null:Gt(S)||se}),(P||C)&&{customHoverBehavior:V}),E&&E.length>0&&{annotations:E}),O);return p.createElement(wn,{componentName:"AreaChart",width:H,height:R},p.createElement(ct,Object.assign({ref:r},ue)))});function Dn({isPushMode:t,colorBy:n,colorScheme:o,showLegend:r,legendPosition:i="right"}){const a=e.useRef(new Set),s=e.useRef([]),[l,c]=e.useState(0),u=e.useCallback(e=>{if(!n)return null;const t="function"==typeof n?n(e):e[n];return null!=t?t+"":null},[n]),d=e.useCallback(e=>{if(!t||!n)return;let o=!1;for(const t of e){if(!t||"object"!=typeof t)continue;const e=u(t);null==e||a.current.has(e)||(a.current.add(e),s.current.push(e),o=!0)}o&&c(e=>e+1)},[t,n,u]),h=e.useCallback(e=>t=>{d([t]),e(t)},[d]),g=e.useCallback(e=>t=>{d(t),e(t)},[d]),f=e.useCallback(()=>{a.current=new Set,s.current=[],c(e=>e+1)},[]),p=e.useMemo(()=>{if(!t||!n||!1===r)return;const e=s.current;if(0===e.length)return;const i=Array.isArray(o)?o:j,a=new Map;for(let t=0;e.length>t;t++)a.set(e[t],i[t%i.length]);const l="string"==typeof n?n:"__streamCat";return Pt({data:e.map(e=>({[l]:e})),colorBy:l,colorScale:e=>a.get(e)||"#999",getColor:_})},[t,n,r,o,l]),y=e.useMemo(()=>{if(p)return"right"===i?{right:110}:"left"===i?{left:110}:"top"===i?{top:50}:"bottom"===i?{bottom:80}:{right:110}},[p,i]);return{wrapPush:h,wrapPushMany:g,resetCategories:f,streamingLegend:p,streamingMarginAdjust:y}}Nn.displayName="AreaChart";const _n=e.forwardRef(function(t,n){var o;const r=e.useRef(null),i=Wt(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:a,margin:s,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",areaBy:g,lineDataAccessor:f="coordinates",colorBy:y,colorScheme:m="category10",curve:v="monotoneX",areaOpacity:b=.7,showLine:x=!0,lineWidth:k=2,normalize:w=!1,tooltip:A,annotations:S,frameProps:E={},selection:O,linkedHover:M,onObservation:P,chartId:C,loading:L,emptyContent:j,legendInteraction:N,legendPosition:D}=t,B=i.width,H=i.height,R=i.enableHover,T=i.showGrid,W=i.showLegend,I=i.title,$=i.xLabel,z=i.yLabel,F=On(L,B,H);if(F)return F;const G=En(a,B,H,j);if(G)return G;const Y=a||[],q=Dn({isPushMode:void 0===a,colorBy:y||g,colorScheme:m,showLegend:W,legendPosition:D}),X=e.useCallback(q.wrapPush(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)}),[q.wrapPush]),V=e.useCallback(q.wrapPushMany(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)}),[q.wrapPushMany]);e.useImperativeHandle(n,()=>({push:X,pushMany:V,clear:()=>{var e;q.resetCategories(),null===(e=r.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}),[X,V,q.resetCategories]);const{activeSelectionHook:U,customHoverBehavior:K}=Bt({selection:O,linkedHover:M,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:P,chartType:"StackedAreaChart",chartId:C}),Q=void 0!==(null===(o=Y[0])||void 0===o?void 0:o[f]),Z=e.useMemo(()=>{if(Q)return Y;if(g){const e=Y.reduce((e,t)=>{const n="function"==typeof g?g(t):t[g];if(!e[n]){const t={[f]:[]};"string"==typeof g&&(t[g]=n),e[n]=t}return e[n][f].push(t),e},{});return Object.values(e)}return[{[f]:Y}]},[Y,g,f,Q]),J=Dt(Y,y,m),ee=e.useMemo(()=>{if(!y)return[];const e=new Set;for(const t of Y){const n="function"==typeof y?y(t):t[y];null!=n&&e.add(n+"")}return Array.from(e)},[Y,y]),te=Rt(N,y,ee),ne=e.useMemo(()=>te.legendSelectionHook?te.legendSelectionHook:U,[te.legendSelectionHook,U]),oe=e.useMemo(()=>e=>{const t={};if(y&&J){const n=_(e,y,J);t.fill=n,x?(t.stroke=n,t.strokeWidth=k):t.stroke="none"}else y||(t.fill=jt,t.stroke=x?jt:"none",x&&(t.strokeWidth=k));return t.fillOpacity=b,t},[y,J,b,x,k]),re=e.useMemo(()=>Lt(oe,ne,O),[oe,ne,O]),{legend:ie,margin:ae,legendPosition:se}=Ht({data:Z,colorBy:y,colorScale:J,showLegend:W,legendPosition:D,userMargin:s,defaults:i.marginDefaults}),le=q.streamingLegend||ie,ce=D||se,ue=e.useMemo(()=>{if(q.streamingMarginAdjust){const e=Object.assign({},ae);for(const[t,n]of Object.entries(q.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return ae},[ae,q.streamingMarginAdjust]),de=g||y,he=e.useMemo(()=>Vt([{label:$||Yt(d),accessor:d,role:"x"},{label:z||Yt(h),accessor:h,role:"y"},...de?[{label:Yt(de),accessor:de,role:"group"}]:[]]),[d,h,$,z,de]),ge=nn({componentName:"StackedAreaChart",data:a,accessors:{xAccessor:d,yAccessor:h}});if(ge)return p.createElement(Kt,{componentName:"StackedAreaChart",message:ge,width:B,height:H});const fe=e.useMemo(()=>Q||g?Z.flatMap(e=>{const t=e[f]||[];return g&&"string"==typeof g?t.map(t=>Object.assign(Object.assign({},t),{[g]:e[g]})):t}):Y,[Z,f,Q,g,Y]),pe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea"},null!=a&&{data:fe}),{xAccessor:d,yAccessor:h,groupAccessor:g||void 0,curve:v,normalize:w,lineStyle:re,size:[B,H],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ue,showAxes:i.showAxes,xLabel:$,yLabel:z,xFormat:c,yFormat:u,enableHover:R,showGrid:T}),le&&{legend:le,legendPosition:ce}),N&&"none"!==N&&{legendHoverBehavior:te.onLegendHover,legendClickBehavior:te.onLegendClick,legendHighlightedCategory:te.highlightedCategory,legendIsolatedCategories:te.isolatedCategories}),I&&{title:I}),l&&{className:l}),{tooltipContent:!1===A?()=>null:Gt(A)||he}),(M||P)&&{customHoverBehavior:K}),S&&S.length>0&&{annotations:S}),E);return p.createElement(wn,{componentName:"StackedAreaChart",width:B,height:H},p.createElement(ct,Object.assign({ref:r},pe)))});function Bn(t){const{data:n,rawData:o,colorBy:r,colorScheme:i,legendInteraction:a,legendPosition:s,selection:l,linkedHover:c,fallbackFields:u,unwrapData:d=!1,onObservation:h,chartType:g,chartId:f,showLegend:p,userMargin:y,marginDefaults:m,loading:v,emptyContent:b,width:x,height:k}=t,{activeSelectionHook:w,customHoverBehavior:A,customClickBehavior:S}=Bt({selection:l,linkedHover:c,fallbackFields:u,unwrapData:d,onObservation:h,chartType:g,chartId:f}),E=Dt(n,r,i),O=e.useMemo(()=>{if(!r)return[];const e=new Set;for(const t of n){const n="function"==typeof r?r(t):t[r];null!=n&&e.add(n+"")}return Array.from(e)},[n,r]),M=Rt(a,r,O),P=e.useMemo(()=>M.legendSelectionHook?M.legendSelectionHook:w,[M.legendSelectionHook,w]),{legend:C,margin:L,legendPosition:j}=Ht({data:n,colorBy:r,colorScale:E,showLegend:p,legendPosition:s,userMargin:y,defaults:m}),N=e.useMemo(()=>{const e={};return C&&(e.legend=C,e.legendPosition=j),a&&"none"!==a&&(e.legendHoverBehavior=M.onLegendHover,e.legendClickBehavior=M.onLegendClick,e.legendHighlightedCategory=M.highlightedCategory,e.legendIsolatedCategories=M.isolatedCategories),e},[C,j,a,M.onLegendHover,M.onLegendClick,M.highlightedCategory,M.isolatedCategories]),D=On(v,x,k),_=D?null:En(o,x,k,b);return{colorScale:E,allCategories:O,legendState:M,effectiveSelectionHook:P,activeSelectionHook:w,customHoverBehavior:A,customClickBehavior:S,legend:C,margin:L,legendPosition:j,earlyReturn:D||_||null,legendBehaviorProps:N}}_n.displayName="StackedAreaChart";const Hn=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const r=Wt(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",colorBy:h,colorScheme:g="category10",sizeBy:f,sizeRange:y=[3,15],pointRadius:m=5,pointOpacity:v=.8,tooltip:b,marginalGraphics:x,pointIdAccessor:k,annotations:w,frameProps:A={},selection:S,linkedHover:E,linkedBrush:O,onObservation:M,chartId:P,loading:C,emptyContent:L,legendInteraction:j,legendPosition:N}=t,D=r.width,B=r.height,R=r.enableHover,T=r.showGrid,W=r.title,I=r.xLabel,$=r.yLabel,z=i||[],F=Bn({data:z,rawData:i,colorBy:h,colorScheme:g,legendInteraction:j,legendPosition:N,selection:S,linkedHover:E,fallbackFields:h?["string"==typeof h?h:""]:[],unwrapData:!1,onObservation:M,chartType:"Scatterplot",chartId:P,showLegend:r.showLegend,userMargin:a,marginDefaults:r.marginDefaults,loading:C,emptyContent:L,width:D,height:B}),G=Ct(O),Y=wt({name:(null==G?void 0:G.name)||"__unused_brush__",xField:(null==G?void 0:G.xField)||("string"==typeof u?u:void 0),yField:(null==G?void 0:G.yField)||("string"==typeof d?d:void 0)}),q=G?"xyBrush"===Y.brushInteraction.brush?"xy":"xBrush"===Y.brushInteraction.brush?"x":"y":void 0,X=p.useRef(Y.brushInteraction);X.current=Y.brushInteraction;const V=e.useCallback(e=>{const t=X.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)},[]);if(F.earlyReturn)return F.earlyReturn;Mn("Scatterplot",z,"xAccessor",u),Mn("Scatterplot",z,"yAccessor",d);const U=e.useMemo(()=>{if(!f||0===z.length)return;const e=z.map(e=>"function"==typeof f?f(e):e[f]);return[Math.min(...e),Math.max(...e)]},[z,f]),K=e.useMemo(()=>e=>{const t={fillOpacity:v};return h?F.colorScale&&(t.fill=_(e,h,F.colorScale)):t.fill=jt,t.r=f?H(e,f,y,U):m,t},[h,F.colorScale,f,y,U,m,v]),Q=e.useMemo(()=>Lt(K,F.effectiveSelectionHook,S),[K,F.effectiveSelectionHook,S]),Z=e.useMemo(()=>Vt([{label:I||Yt(u),accessor:u,role:"x"},{label:$||Yt(d),accessor:d,role:"y"},...h?[{label:Yt(h),accessor:h,role:"color"}]:[],...f?[{label:Yt(f),accessor:f,role:"size"}]:[]]),[u,d,I,$,h,f]),J=nn({componentName:"Scatterplot",data:i,accessors:{xAccessor:u,yAccessor:d}});if(J)return p.createElement(Kt,{componentName:"Scatterplot",message:J,width:D,height:B});const ee=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=i&&{data:z}),{xAccessor:u,yAccessor:d,colorAccessor:h||void 0,sizeAccessor:f||void 0,sizeRange:y,pointStyle:Q,colorScheme:g,size:[D,B],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:F.margin,showAxes:r.showAxes,xLabel:I,yLabel:$,xFormat:l,yFormat:c,enableHover:R,showGrid:T}),F.legendBehaviorProps),W&&{title:W}),s&&{className:s}),{tooltipContent:!1===b?()=>null:Gt(b)||Z}),(E||M)&&{customHoverBehavior:F.customHoverBehavior}),x&&{marginalGraphics:x}),k&&{pointIdAccessor:k}),w&&w.length>0&&{annotations:w}),G&&{brush:{dimension:q},onBrush:V}),A);return p.createElement(wn,{componentName:"Scatterplot",width:D,height:B},p.createElement(ct,Object.assign({ref:o},ee)))});function Rn(e,t){return r.interpolateViridis(1===t?.5:e/(t-1))}Hn.displayName="Scatterplot";const Tn=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const r=Wt(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,className:a,xFormat:s,yFormat:l,xAccessor:c="x",yAccessor:u="y",orderAccessor:d,orderLabel:h,pointRadius:g=4,tooltip:f,pointIdAccessor:y,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:k,chartId:w,loading:A,emptyContent:S,legendInteraction:E}=t,O=r.width,M=r.height,P=r.enableHover,C=r.showGrid,L=r.title,j=r.xLabel,N=r.yLabel,D=i||[],_=e.useMemo(()=>{if(!d||0===D.length)return D;const e="function"==typeof d?d:e=>e[d];return[...D].sort((t,n)=>{const o=e(t),r=e(n);return(o instanceof Date?o.getTime():+o)-(r instanceof Date?r.getTime():+r)})},[D,d]);Mn("ConnectedScatterplot",_,"xAccessor",c),Mn("ConnectedScatterplot",_,"yAccessor",u);const{activeSelectionHook:B,customHoverBehavior:H}=Bt({selection:b,linkedHover:x,fallbackFields:[],onObservation:k,chartType:"ConnectedScatterplot",chartId:w}),R=Rt(E,void 0,[]),T=e.useMemo(()=>R.legendSelectionHook?R.legendSelectionHook:B,[R.legendSelectionHook,B]),W=e.useMemo(()=>(e,t)=>{var n,o;const r=t.filter(e=>"point"===e.type);if(2>r.length)return;const i=null==T?void 0:T.isActive,a=null==T?void 0:T.predicate,s=100>r.length,l=r.length;e.lineCap="round";for(let t=0;l-1>t;t++){const c=r[t],u=r[t+1],d=Rn(t,l),h=!i||!a||a(null!==(n=c.datum)&&void 0!==n?n:c)||a(null!==(o=u.datum)&&void 0!==o?o:u),f=i?h?1:.2:1;s&&(e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle="white",e.lineWidth=g+2,e.globalAlpha=.5*f,e.stroke()),e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle=d,e.lineWidth=g,e.globalAlpha=f,e.stroke()}e.globalAlpha=1},[g,T]),I=e.useMemo(()=>[W],[W]),$=e.useRef({idx:0,total:0}),z=e.useMemo(()=>{const e="function"==typeof c?c:e=>e[c],t="function"==typeof u?u:e=>e[u];return n=>{var r,i;const a=$.current;if(0===a.idx){const n=null!==(i=null===(r=o.current)||void 0===r?void 0:r.getData())&&void 0!==i?i:_;a.total=n.filter(n=>{const o=e(n),r=t(n);return null!=o&&null!=r&&isFinite(o)&&isFinite(r)}).length}const s=a.total,l=a.idx;return a.idx++,s>a.idx||(a.idx=0),{fill:s>0?Rn(l,s):"#6366f1",stroke:"white",strokeWidth:1,r:g,fillOpacity:1}}},[g,_.length,c,u]),F=e.useMemo(()=>Lt(z,T,b),[z,T,b]),G=Object.assign({top:50,right:40,bottom:60,left:70},t.margin),Y=h||("string"==typeof d?d:"Order"),q=e.useMemo(()=>Vt([{label:j||Yt(c),accessor:c,role:"x"},{label:N||Yt(u),accessor:u,role:"y"},...d?[{label:Y,accessor:d,role:"group"}]:[]]),[c,u,j,N,d,Y]),X=nn({componentName:"ConnectedScatterplot",data:i,accessors:{xAccessor:c,yAccessor:u}}),V=On(A,O,M);if(V)return V;const U=En(i,O,M,S);if(U)return U;if(X)return p.createElement(Kt,{componentName:"ConnectedScatterplot",message:X,width:O,height:M});const K=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=i&&{data:_}),{xAccessor:c,yAccessor:u,pointStyle:F,size:[O,M],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:G,showAxes:r.showAxes,xLabel:j,yLabel:N,xFormat:s,yFormat:l,enableHover:P,showGrid:C}),L&&{title:L}),a&&{className:a}),{tooltipContent:!1===f?()=>null:Gt(f)||q}),(x||k)&&{customHoverBehavior:H}),y&&{pointIdAccessor:y}),{canvasPreRenderers:I}),m&&m.length>0&&{annotations:m}),v);return p.createElement(wn,{componentName:"ConnectedScatterplot",width:O,height:M},p.createElement(ct,Object.assign({ref:o},K)))});Tn.displayName="ConnectedScatterplot";const Wn=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const r=Wt(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",sizeBy:h,sizeRange:g=[5,40],colorBy:f,colorScheme:y="category10",bubbleOpacity:m=.6,bubbleStrokeWidth:v=1,bubbleStrokeColor:b="white",tooltip:x,marginalGraphics:k,pointIdAccessor:w,annotations:A,frameProps:S={},selection:E,linkedHover:O,linkedBrush:M,onObservation:P,chartId:C,loading:L,emptyContent:j,legendInteraction:N,legendPosition:D}=t,B=r.width,R=r.height,T=r.enableHover,W=r.showGrid,I=r.showLegend,$=r.title,z=r.xLabel,F=r.yLabel,G=On(L,B,R);if(G)return G;const Y=En(i,B,R,j);if(Y)return Y;const q=i||[],{activeSelectionHook:X,customHoverBehavior:V}=Bt({selection:E,linkedHover:O,fallbackFields:f?["string"==typeof f?f:""]:[],onObservation:P,chartType:"BubbleChart",chartId:C}),U=Ct(M);wt({name:(null==U?void 0:U.name)||"__unused_brush__",xField:(null==U?void 0:U.xField)||("string"==typeof u?u:void 0),yField:(null==U?void 0:U.yField)||("string"==typeof d?d:void 0)});const K=Dt(q,f,y),Q=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of q){const n="function"==typeof f?f(t):t[f];null!=n&&e.add(n+"")}return Array.from(e)},[q,f]),Z=Rt(N,f,Q),J=e.useMemo(()=>Z.legendSelectionHook?Z.legendSelectionHook:X,[Z.legendSelectionHook,X]),ee=e.useMemo(()=>{const e=q.map(e=>"function"==typeof h?h(e):e[h]);return[Math.min(...e),Math.max(...e)]},[q,h]),te=e.useMemo(()=>e=>{const t={fillOpacity:m,strokeWidth:v,stroke:b};return f?K&&(t.fill=_(e,f,K)):t.fill=jt,t.r=H(e,h,g,ee),t},[f,K,h,g,ee,m,v,b]),ne=e.useMemo(()=>Lt(te,J,E),[te,J,E]),{legend:oe,margin:re,legendPosition:ie}=Ht({data:q,colorBy:f,colorScale:K,showLegend:I,legendPosition:D,userMargin:a,defaults:r.marginDefaults}),ae=e.useMemo(()=>Vt([{label:z||Yt(u),accessor:u,role:"x"},{label:F||Yt(d),accessor:d,role:"y"},{label:Yt(h),accessor:h,role:"size"},...f?[{label:Yt(f),accessor:f,role:"color"}]:[]]),[u,d,z,F,h,f]),se=nn({componentName:"BubbleChart",data:i,accessors:{xAccessor:u,yAccessor:d},requiredProps:{sizeBy:h}});if(se)return p.createElement(Kt,{componentName:"BubbleChart",message:se,width:B,height:R});const le=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bubble"},null!=i&&{data:q}),{xAccessor:u,yAccessor:d,colorAccessor:f||void 0,sizeAccessor:h,sizeRange:g,pointStyle:ne,colorScheme:y,size:[B,R],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:re,showAxes:r.showAxes,xLabel:z,yLabel:F,xFormat:l,yFormat:c,enableHover:T,showGrid:W}),oe&&{legend:oe,legendPosition:ie}),N&&"none"!==N&&{legendHoverBehavior:Z.onLegendHover,legendClickBehavior:Z.onLegendClick,legendHighlightedCategory:Z.highlightedCategory,legendIsolatedCategories:Z.isolatedCategories}),$&&{title:$}),s&&{className:s}),{tooltipContent:!1===x?()=>null:Gt(x)||ae}),(O||P)&&{customHoverBehavior:V}),k&&{marginalGraphics:k}),w&&{pointIdAccessor:w}),A&&A.length>0&&{annotations:A}),S);return p.createElement(wn,{componentName:"BubbleChart",width:B,height:R},p.createElement(ct,Object.assign({ref:o},le)))});Wn.displayName="BubbleChart";const In=e.forwardRef(function(t,n){const i=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const a=Wt(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:s,margin:l,className:c,xAccessor:u="x",yAccessor:d="y",valueAccessor:h="value",xFormat:g,yFormat:f,colorScheme:y="blues",customColorScale:m,showValues:v=!1,valueFormat:b,cellBorderColor:x="#fff",cellBorderWidth:k=1,tooltip:w,annotations:A,frameProps:S={},selection:E,linkedHover:O,onObservation:M,chartId:P,loading:C,emptyContent:L,showLegend:j,legendPosition:N,legendInteraction:D}=t,_=a.width,B=a.height,H=a.enableHover,R=a.title,T=a.xLabel,W=a.yLabel,I=On(C,_,B);if(I)return I;const $=En(s,_,B,L);if($)return $;const z=s||[],F=null!=j&&j,G=null!=N?N:"right",{margin:Y}=Ht({data:z,colorBy:F?"value":void 0,colorScale:void 0,showLegend:F,legendPosition:G,userMargin:l,defaults:a.marginDefaults}),{activeSelectionHook:q,customHoverBehavior:X}=Bt({selection:E,linkedHover:O,fallbackFields:[],onObservation:M,chartType:"Heatmap",chartId:P}),V=Rt(D,void 0,[]),U=e.useMemo(()=>V.legendSelectionHook?V.legendSelectionHook:q,[V.legendSelectionHook,q]),K=e.useMemo(()=>"function"==typeof h?e=>h(e):e=>e[h],[h]),Q=e.useMemo(()=>{const e=z.map(K);return[Math.min(...e),Math.max(...e)]},[z,K]),Z=e.useMemo(()=>"custom"===y&&m?m:o.scaleSequential({blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,viridis:r.interpolateViridis}[y]||r.interpolateBlues).domain(Q),[y,m,Q]);e.useMemo(()=>{const e=Nt(u),t=Nt(d);return{xBinCount:new Set(z.map(e)).size,yBinCount:new Set(z.map(t)).size}},[z,u,d]),e.useMemo(()=>({coordinates:z}),[z]);const J=e.useMemo(()=>e=>{const t=K(e);return{fill:Z(t),stroke:x,strokeWidth:k}},[K,Z,x,k]);e.useMemo(()=>Lt(J,U,E),[J,U,E]);const ee=e.useMemo(()=>Vt([{label:T||Yt(u),accessor:u,role:"x"},{label:W||Yt(d),accessor:d,role:"y"},{label:Yt(h),accessor:h,role:"value"}]),[u,d,T,W,h]),te=nn({componentName:"Heatmap",data:s,accessors:{xAccessor:u,yAccessor:d,valueAccessor:h}});if(te)return p.createElement(Kt,{componentName:"Heatmap",message:te,width:_,height:B});const ne=e.useMemo(()=>{if(F)return{gradient:{colorFn:e=>Z(e),domain:Q,label:"string"==typeof h?h:"value",format:b}}},[F,Z,Q,h,b]),oe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap"},null!=s&&{data:z}),{xAccessor:u,yAccessor:d,valueAccessor:h,colorScheme:"custom"!==y?y:void 0,showValues:v,heatmapValueFormat:b,size:[_,B],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Y,showAxes:a.showAxes,xLabel:T,yLabel:W,xFormat:g,yFormat:f,enableHover:H}),ne&&{legend:ne,legendPosition:G}),R&&{title:R}),c&&{className:c}),{tooltipContent:!1===w?()=>null:Gt(w)||ee}),(O||M)&&{customHoverBehavior:X}),A&&A.length>0&&{annotations:A}),S);return p.createElement(wn,{componentName:"Heatmap",width:_,height:B},p.createElement(ct,Object.assign({ref:i},oe)))});In.displayName="Heatmap";const $n="__splomIdx",zn={top:4,bottom:4,left:4,right:4};function Fn({frameRef:o,cellSize:r,onBrush:i}){const a=e.useRef(null),s=r-zn.left-zn.right,l=r-zn.top-zn.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]),p.createElement("svg",{ref:a,width:r,height:r,style:{position:"absolute",top:0,left:0}},p.createElement("g",{className:"brush-g",transform:`translate(${zn.left},${zn.top})`}))}function Gn({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 f=e.useRef(null),y=xt({name:c,clientId:`splom-${n}-${o}`}),m=wt({name:c,xField:n,yField:o}),v=xt({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[$n];void 0!==n&&(b({[$n]:[n]}),null==g||g(t,e.x+zn.left,e.y+zn.top))},[b,g]),w=e.useCallback(e=>{const t={opacity:a,r:i};return t.fill=s?_(e,s,l):jt,"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):y.isActive&&!y.predicate(e)&&(t.opacity=d),t},[s,l,a,i,h,y.isActive,y.predicate,v.isActive,v.predicate,d]);return p.createElement("div",{style:{position:"relative",width:r,height:r}},p.createElement(ct,{ref:f,chartType:"scatter",data:t,size:[r,r],xAccessor:n,yAccessor:o,pointStyle:w,margin:zn,showAxes:!1,enableHover:"hover"===h,customHoverBehavior:"hover"===h?k:void 0,tooltipContent:"hover"===h?()=>null:void 0}),"brush"===h&&p.createElement(Fn,{frameRef:f,cellSize:r,xField:n,yField:o,onBrush:x}))}function Yn({data:t,field:n,label:o,cellSize:r,bins:i,colorBy:a,colorScale:s,brushSelectionName:l,hoverSelectionName:c,mode:u}){const d=xt({name:l,clientId:"splom-diag-"+n}),h=xt({name:c,clientId:`splom-diag-${n}-hover`}),g="hover"===u?h:d,f=g.isActive,y=g.predicate,m=e.useMemo(()=>{const e=t.map(e=>e[n]).filter(e=>null!=e&&!isNaN(e));if(0===e.length)return{bars:[],selectedBars:[],categoryBars:[],selectedCategoryBars:[],max:0,categories:[]};const o=Math.min(...e),s=(Math.max(...e)-o)/i||1,l="string"==typeof a?a:null,c=l?[...new Set(t.map(e=>e[l]).filter(e=>null!=e).map(String))]:[],u=new Map(c.map((e,t)=>[e,t])),d=Array(i).fill(0),h=Array(i).fill(0),g=Array.from({length:i},()=>Array(c.length).fill(0)),p=Array.from({length:i},()=>Array(c.length).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)/s),i-1);if(d[r]++,f&&!y(e)||h[r]++,l){const t=u.get(e[l]+"");void 0!==t&&(g[r][t]++,f&&!y(e)||p[r][t]++)}}const m=Math.max(...d,1),v=g.map((e,t)=>{let n=0;return e.map((e,o)=>{const a=e/m*(r-24),s={x:t/i*r,w:r/i-1,h:a,y0:n,category:c[o]};return n+=a,s})}),b=p.map((e,t)=>{let n=0;return e.map((e,o)=>{const a=e/m*(r-24),s={x:t/i*r,w:r/i-1,h:a,y0:n,category:c[o]};return n+=a,s})});return{bars:d.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/m*(r-24),count:e})),selectedBars:h.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/m*(r-24),count:e})),categoryBars:v,selectedCategoryBars:b,max:m,categories:c}},[t,n,i,r,f,y,a]);return p.createElement("svg",{width:r,height:r,style:{overflow:"hidden"}},p.createElement("text",{x:r/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333"},o),m.categories.length>0?m.categoryBars.map((e,t)=>e.map((e,n)=>p.createElement("rect",{key:`bg-${t}-${n}`,x:e.x,y:r-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:s?s(e.category):jt,opacity:f?.3:.6}))):m.bars.map((e,t)=>p.createElement("rect",{key:"bg-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:jt,opacity:f?.3:.6})),f&&(m.categories.length>0?m.selectedCategoryBars.map((e,t)=>e.map((e,n)=>p.createElement("rect",{key:`sel-${t}-${n}`,x:e.x,y:r-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:s?s(e.category):jt,opacity:.7}))):m.selectedBars.map((e,t)=>p.createElement("rect",{key:"sel-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:jt,opacity:.7}))))}function qn({label:e,cellSize:t}){return p.createElement("svg",{width:t,height:t},p.createElement("text",{x:t/2,y:t/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333"},e))}function Xn(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:f=!0,unselectedOpacity:y=.1,showGrid:m=!1,tooltip:v,showLegend:b,idAccessor:x,className:k,onObservation:w,chartId:A}=t,S="splom",E="splom-hover",O=f?"hover":g?"brush":"hover",M=mt(e=>e.clearSelection),[P,C]=e.useState(null),L=e.useCallback(()=>{M(E),C(null)},[M,E]),j=e.useMemo(()=>(n||[]).map((e,t)=>void 0!==e[$n]?e:Object.assign(Object.assign({},e),{[$n]:t})),[n]),N=Dt(j,i,a),D=void 0!==b?b:!!i,_=e.useMemo(()=>{if(!D||!i)return null;const e="string"==typeof i?i:null;return e?[...new Set(j.map(t=>t[e]))].map(e=>({label:e+"",color:N?N(e+""):jt})):null},[D,i,j,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 p.createElement("div",{className:k,style:{position:"relative"}},_&&p.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},_.map(e=>p.createElement("div",{key:e.label,style:{display:"flex",alignItems:"center",gap:4}},p.createElement("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:e.color}}),p.createElement("span",{style:{fontSize:11}},e.label)))),p.createElement("div",{style:B,onMouseLeave:"hover"===O?L:void 0},o.map((e,t)=>p.createElement(p.Fragment,{key:"row-"+e},p.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?p.createElement(qn,{key:"diag-"+e,label:r[e]||e,cellSize:s}):p.createElement(Yn,{key:"diag-"+e,data:j,field:e,label:r[e]||e,cellSize:s,bins:h,colorBy:i,colorScale:N,brushSelectionName:S,hoverSelectionName:E,unselectedOpacity:y,mode:O}):p.createElement(Gn,{key:`cell-${e}-${n}`,data:j,xField:n,yField:e,fieldLabels:r,cellSize:s,pointRadius:c,pointOpacity:u,colorBy:i,colorScale:N,brushSelectionName:S,hoverSelectionName:E,unselectedOpacity:y,showGrid:m,tooltip:v,mode:O,onPointHover:"hover"===O?(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})))),p.createElement("div",null)," ",o.map(e=>p.createElement("div",{key:"col-label-"+e,style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e))),P&&"hover"===O&&(()=>{const e=P.datum,t=r[P.xField]||P.xField,n=r[P.yField]||P.yField,o=i?"function"==typeof i?i(e):e[i]:null,a=x?"function"==typeof x?x(e):e[x]:"Row "+e[$n];return p.createElement("div",{style:{position:"absolute",left:40+P.colIndex*(s+l)+P.px,top:P.rowIndex*(s+l)+P.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}},p.createElement("div",{style:{fontWeight:"bold",marginBottom:2}},a+""),p.createElement("div",null,t,": ",null!=e[P.xField]?Number(e[P.xField]).toFixed(1):"–"),p.createElement("div",null,n,": ",null!=e[P.yField]?Number(e[P.yField]).toFixed(1):"–"),null!=o&&p.createElement("div",{style:{opacity:.8}},"string"==typeof i?i:"group",": ",o+""))})())}function Vn(e){const{brushMode:t="crossfilter",hoverMode:n=!0}=e,o={};return!n&&t&&(o.splom={resolution:t}),n&&(o["splom-hover"]={resolution:"union"}),p.createElement(Mt,{selections:o},p.createElement(Xn,Object.assign({},e)))}function Un(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 Kn(e){var t,n,o;const r=e.length,i=e[0],s=e[r-1];return{n:r,min:i,q1:null!==(t=a.quantile(e,.25))&&void 0!==t?t:i,median:null!==(n=a.quantile(e,.5))&&void 0!==n?n:(i+s)/2,q3:null!==(o=a.quantile(e,.75))&&void 0!==o?o:s,max:s,mean:e.reduce((e,t)=>e+t,0)/r}}Vn.displayName="ScatterplotMatrix";const Qn={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),p=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(S(e.x,n,e.width,Math.abs(a),f,p,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(S(n,e.x,Math.abs(a),e.width,f,p,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=.2*t,o=t-n,l=new Map;for(const t of e.pieceData){const e=i?i(t):"_default";l.has(e)||l.set(e,[]),l.get(e).push(t)}for(let i=0;d.length>i;i++){const h=l.get(d[i])||[];for(const l of h){const h=r(l),g=a(l,d[i]);if(u){const r=e.x+i*t+n/2,a=s(0),u=s(h);c.push(S(r,Math.min(a,u),o,Math.abs(a-u),g,l,d[i]))}else{const r=e.x+i*t+n/2,a=s(0),u=s(h);c.push(S(Math.min(a,u),r,Math.abs(u-a),o,g,l,d[i]))}}}}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,p=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=f&&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)*p,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:Un,donut:Un,boxplot:function(e,t){var n,o,r,i,s;const{scales:l,columns:c,config:u,getR:d,resolveSummaryStyle:h}=e,{r:g,projection:f}=l,p=[],y="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=a.quantile(t,.25))&&void 0!==n?n:l,f=null!==(o=a.quantile(t,.5))&&void 0!==o?o:(l+c)/2,v=null!==(r=a.quantile(t,.75))&&void 0!==r?r:c,b=v-u,x=u-1.5*b,k=v+1.5*b,w=null!==(i=t.find(e=>e>=x))&&void 0!==i?i:l,A=null!==(s=[...t].reverse().find(e=>k>=e))&&void 0!==s?s:c,S=h(e.pieceData[0],e.name),E=[];if(m)for(const t of e.pieceData){const n=d(t);if(x>n||n>k){const o=y?e.middle:g(n),r=y?g(n):e.middle;E.push({px:o,py:r,value:n,datum:t})}}if(p.push({type:"boxplot",x:y?e.middle:0,y:y?0:e.middle,projection:y?"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:S,datum:e.pieceData,category:e.name,outliers:E}),m)for(const e of E)p.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:S.fill||"#999",opacity:.6},datum:e.datum})}return p},violin:function(e,t){var n,o,r;const{scales:i,columns:s,config:l,getR:c,resolveSummaryStyle:u}=e,{r:d,projection:h}=i,g=[],f="vertical"===h,p=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 i=t[0],s=t[t.length-1],l=(s-i)/p||1,h=Array(p).fill(0);for(const e of t)h[Math.min(Math.floor((e-i)/l),p-1)]++;const m=Math.max(...h,1),v=e.width/2*.9;let b="";if(f){for(let t=0;p>t;t++){const n=d(i+(t+.5)*l),o=h[t]/m*v;b+=0===t?`M ${e.middle+o} ${n}`:` L ${e.middle+o} ${n}`}for(let t=p-1;t>=0;t--){const n=d(i+(t+.5)*l);b+=` L ${e.middle-h[t]/m*v} ${n}`}b+=" Z"}else{for(let t=0;p>t;t++){const n=d(i+(t+.5)*l),o=h[t]/m*v;b+=0===t?`M ${n} ${e.middle-o}`:` L ${n} ${e.middle-o}`}for(let t=p-1;t>=0;t--)b+=` L ${d(i+(t+.5)*l)} ${e.middle+h[t]/m*v}`;b+=" Z"}const x=u(e.pieceData[0],e.name);let k;if(y&&t.length>=4){const l=null!==(n=a.quantile(t,.25))&&void 0!==n?n:i,c=null!==(o=a.quantile(t,.5))&&void 0!==o?o:(i+s)/2,u=null!==(r=a.quantile(t,.75))&&void 0!==r?r: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(i)),width:e.width,height:Math.abs(d(s)-d(i))}:{x:Math.min(d(i),d(s)),y:e.x,width:Math.abs(d(s)-d(i)),height:e.width};g.push({type:"violin",pathString:b,translateX:0,translateY:0,bounds:w,iqrLine:k,stats:Kn(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(S(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),p=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]/f*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]/f*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:Kn(t),style:Object.assign(Object.assign({},p),{fillOpacity:null!==(n=p.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(S(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(S(e.x,n,e.width,r-n,u,t,e.name))}}return l}};class Zn{constructor(e){this.rExtent=new b,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.version=0,this.config=e,this.buffer=new v(e.windowSize),this.getO=P(e.oAccessor||e.categoryAccessor,"category");const t="streaming"===e.runtimeMode,n=e.rAccessor;Array.isArray(n)?(this.rAccessors=n.map(e=>O(e,"value")),this.getR=this.rAccessors[0],this.rExtents=n.map(()=>new b)):(this.getR=O(t&&(e.timeAccessor||e.valueAccessor)&&e.valueAccessor||n,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=P(e.stackBy),this.getGroup=P(e.groupBy),this.getColor=P(e.colorAccessor),this.getConnector=P(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{this._hasStreamingData=!0;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||this._hasStreamingData)&&void 0===n){const n=new Set;for(const t of e)n.add(this.getO(t));const o=[];for(const e of t)n.has(e)?o.push(e):this.categories.delete(e);return o}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&&this.config.normalize)a=0,s=1;else 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=Qn[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){if("function"==typeof this.config.pieceStyle){const n=this.config.pieceStyle(e,t);return n&&!n.fill&&t?Object.assign(Object.assign({},n),{fill:this.getColorFromScheme(t)}):n}return 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:j,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}getNodeKey(e,t){var n,o;if("point"===e.type){const n=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,o=t.get(n)||0;return t.set(n,o+1),`${n}:${o}`}return"rect"===e.type?`r:${e.group||""}:${null!==(o=null===(n=e.datum)||void 0===n?void 0:n.category)&&void 0!==o?o:""}`:null}snapshotPositions(){this.prevPositionMap.clear();const e=new Map;for(let t=0;this.scene.length>t;t++){const n=this.scene[t],o=this.getNodeKey(n,e);o&&("point"===n.type?this.prevPositionMap.set(o,{x:n.x,y:n.y,r:n.r,opacity:n.style.opacity}):"rect"===n.type&&this.prevPositionMap.set(o,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:n.style.opacity}))}}startTransition(){var e,t,n,o,r,i,a,s,l,c,u,d;if(!this.config.transition||0===this.prevPositionMap.size)return;const h=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let g=!1;const f=new Set,p=new Map;for(let e=0;this.scene.length>e;e++){const s=this.scene[e],l=this.getNodeKey(s,p);if(!l)continue;s._transitionKey=l;const c=this.prevPositionMap.get(l);"point"===s.type?c?(f.add(l),s._targetOpacity=null!==(t=s.style.opacity)&&void 0!==t?t:1,c.x===s.x&&c.y===s.y||(s._targetX=s.x,s._targetY=s.y,s.x=c.x,s.y=c.y,g=!0)):(s._targetOpacity=null!==(n=s.style.opacity)&&void 0!==n?n:1,s.style=Object.assign(Object.assign({},s.style),{opacity:0}),g=!0):"rect"===s.type&&(c?(f.add(l),s._targetOpacity=null!==(o=s.style.opacity)&&void 0!==o?o:1,c.x===s.x&&c.y===s.y&&c.w===s.w&&c.h===s.h||(s._targetX=s.x,s._targetY=s.y,s._targetW=s.w,s._targetH=s.h,s.x=c.x,s.y=c.y,s.w=null!==(r=c.w)&&void 0!==r?r:s.w,s.h=null!==(i=c.h)&&void 0!==i?i:s.h,g=!0)):(s._targetOpacity=null!==(a=s.style.opacity)&&void 0!==a?a:1,s.style=Object.assign(Object.assign({},s.style),{opacity:0}),g=!0))}this.exitNodes=[];for(const[e,t]of this.prevPositionMap)f.has(e)||(e.startsWith("p:")?this.exitNodes.push({type:"point",x:t.x,y:t.y,r:null!==(s=t.r)&&void 0!==s?s:3,style:{opacity:null!==(l=t.opacity)&&void 0!==l?l:1},datum:null,_targetOpacity:0,_transitionKey:e}):e.startsWith("r:")&&this.exitNodes.push({type:"rect",x:t.x,y:t.y,w:null!==(c=t.w)&&void 0!==c?c:0,h:null!==(u=t.h)&&void 0!==u?u:0,style:{opacity:null!==(d=t.opacity)&&void 0!==d?d:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e}),g=!0);this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),g&&(this.activeTransition={startTime:I(),duration:h})}advanceTransition(e){var t,n,o;if(!this.activeTransition)return!1;const r=T(e,this.activeTransition),i=R(r,"linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?"linear":"ease-out-cubic");for(const e of this.scene){const t=e._transitionKey;if(t)if("point"===e.type){if(void 0!==e._targetOpacity){const o=this.prevPositionMap.get(t),r=o?null!==(n=o.opacity)&&void 0!==n?n:1:0;e.style.opacity=W(r,e._targetOpacity,i)}if(void 0===e._targetX)continue;const o=this.prevPositionMap.get(t);if(!o)continue;e.x=W(o.x,e._targetX,i),e.y=W(o.y,e._targetY,i)}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=this.prevPositionMap.get(t),r=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;e.style.opacity=W(r,e._targetOpacity,i)}if(void 0===e._targetX)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=W(n.x,e._targetX,i),e.y=W(n.y,e._targetY,i),void 0!==n.w&&(e.w=W(n.w,e._targetW,i),e.h=W(n.h,e._targetH,i))}}if(r>=1){for(const e of this.scene)if(void 0!==e._targetOpacity&&(e.style=Object.assign(Object.assign({},e.style||{}),{opacity:0===e._targetOpacity?0:e._targetOpacity}),e._targetOpacity=void 0),"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}if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}getData(){return this.buffer.toArray()}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.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 Jn(e,t,n){const o=z(t,n,e);return o.hit?{datum:e.datum,x:o.cx,y:e.y,distance:0,category:e.group}:null}function eo(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 to(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=F(Math.atan2(r,o)),s=F(e.startAngle),l=F(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 no(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 oo(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 ro(t){const{width:n,height:o,totalWidth:r,totalHeight:i,margin:a,scales:s,showAxes:l,showGrid:c,rFormat:u}=t,d="radial"===(null==s?void 0:s.projection),h="horizontal"===(null==s?void 0:s.projection),g=e.useMemo(()=>!s||d?[]:s.r.ticks(5).map(e=>({value:e,pixel:s.r(e),label:(u||io)(e)})),[s,u,d]),f=c&&s&&!d,y=l&&s&&!d;return f||y?p.createElement("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},p.createElement("g",{transform:`translate(${a.left},${a.top})`},f&&p.createElement("g",{className:"ordinal-grid"},g.map((e,t)=>p.createElement("line",{key:"grid-"+t,x1:h?e.pixel:0,y1:h?0:e.pixel,x2:h?e.pixel:n,y2:h?o:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),y&&p.createElement(p.Fragment,null,h?p.createElement(p.Fragment,null,p.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),p.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})):p.createElement(p.Fragment,null,p.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),p.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}))))):null}function io(e){return Math.round(100*e)/100+""}function ao(t){var n,o;const{width:r,height:i,totalWidth:a,totalHeight:s,margin:l,scales:c,showAxes:u,oLabel:d,rLabel:h,oFormat:g,rFormat:f,showGrid:y,title:m,legend:v,legendHoverBehavior:b,legendClickBehavior:x,legendHighlightedCategory:k,legendIsolatedCategories:w,legendPosition:A="right",foregroundGraphics:S,annotations:E,svgAnnotationRules:O,xAccessor:M,yAccessor:P,annotationData:C,underlayRendered:L,children:j}=t,N="radial"===(null==c?void 0:c.projection),D="horizontal"===(null==c?void 0:c.projection),_=e.useMemo(()=>u&&c&&!N?c.o.domain().map(e=>{var t;return{value:e,pixel:(null!==(t=c.o(e))&&void 0!==t?t:0)+c.o.bandwidth()/2,label:g?g(e):e}}):[],[u,c,g,N]),B=e.useMemo(()=>u&&c&&!N?c.r.ticks(5).map(e=>({value:e,pixel:c.r(e),label:(f||io)(e)})):[],[u,c,f,N]),H=e.useRef(new Map),R=e.useRef(null!==(n=null==E?void 0:E.length)&&void 0!==n?n:0),T=null!==(o=null==E?void 0:E.length)&&void 0!==o?o:0;R.current!==T&&(R.current=T,H.current=new Map);const W=e.useMemo(()=>{if(!E||0===E.length)return null;const e=xe(),t="horizontal"===(null==c?void 0:c.projection),n=(null==c?void 0:c.o)?e=>{var t;return(null!==(t=c.o(e))&&void 0!==t?t:0)+c.o.bandwidth()/2}:null,o={scales:c?{x:t?c.r:n||c.r,y:t&&n||c.r,time:c.r,value:c.r}:null,timeAxis:"x",xAccessor:M,yAccessor:P,width:r,height:i,data:C,frameType:"ordinal",stickyPositionCache:H.current};return E.map((t,n)=>{if(O){const r=O(t,n,o);return null!=r?r:e(t,n,o)}return e(t,n,o)}).filter(Boolean)},[E,O,r,i,c,M,P,C]);return u||m||v||S||W&&W.length>0||y||j?p.createElement("svg",{role:"img",width:a,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},p.createElement("title",null,"string"==typeof m?m:"Ordinal Chart"),p.createElement("desc",null,"string"==typeof m?m+" — ordinal data visualization":"Ordinal data visualization"),p.createElement("g",{transform:`translate(${l.left},${l.top})`},y&&c&&!N&&!L&&p.createElement("g",{className:"ordinal-grid"},B.map((e,t)=>p.createElement("line",{key:"grid-"+t,x1:D?e.pixel:0,y1:D?0:e.pixel,x2:D?e.pixel:r,y2:D?i:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),u&&c&&!N&&p.createElement("g",{className:"ordinal-axes"},D?p.createElement(p.Fragment,null,!L&&p.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),_.map((e,t)=>p.createElement("g",{key:"cat-"+t,transform:`translate(0,${e.pixel})`},p.createElement("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),p.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),d&&p.createElement("text",{x:15-l.left,y:i/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-l.left}, ${i/2})`,style:{userSelect:"none"}},d),!L&&p.createElement("line",{x1:0,y1:i,x2:r,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),B.map((e,t)=>p.createElement("g",{key:"val-"+t,transform:`translate(${e.pixel},${i})`},p.createElement("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),p.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),h&&p.createElement("text",{x:r/2,y:i+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},h)):p.createElement(p.Fragment,null,!L&&p.createElement("line",{x1:0,y1:i,x2:r,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),_.map((e,t)=>p.createElement("g",{key:"cat-"+t,transform:`translate(${e.pixel},${i})`},p.createElement("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),p.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),d&&p.createElement("text",{x:r/2,y:i+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},d),!L&&p.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),B.map((e,t)=>p.createElement("g",{key:"val-"+t,transform:`translate(0,${e.pixel})`},p.createElement("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),p.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),h&&p.createElement("text",{x:15-l.left,y:i/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-l.left}, ${i/2})`,style:{userSelect:"none"}},h))),W,S,j),m&&p.createElement("text",{x:a/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof m?m:null),le({legend:v,totalWidth:a,totalHeight:s,margin:l,legendPosition:A,title:m,legendHoverBehavior:b,legendClickBehavior:x,legendHighlightedCategory:k,legendIsolatedCategories:w})):null}function so(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 lo=(e,t,n,o)=>{var r,i;const a=t.filter(e=>"wedge"===e.type);for(const t of a)so(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&&(so(e,t),Xe(e,t)),e.globalAlpha=1},co=(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()}},uo=(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}},ho=e=>[uo,...e],go={bar:ho([Je]),clusterbar:ho([Je]),point:ho([Ze]),swarm:ho([Ze]),pie:[lo],donut:[lo],boxplot:ho([(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()}},Ze]),violin:ho([co]),histogram:ho([Je]),ridgeline:ho([co]),timeline:ho([Je])},fo={top:50,right:40,bottom:60,left:70},po={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 yo({hover:e}){var t,n,o,r,i,a;const s=e.data||{},l=e.stats,c=e.category;if(Array.isArray(s)){const e=c||(null===(t=s[0])||void 0===t?void 0:t.category)||"";if(l)return p.createElement("div",{className:"semiotic-tooltip",style:po},e&&p.createElement("div",{style:{fontWeight:"bold"}},e+""),p.createElement("div",null,"n = ",l.n),p.createElement("div",null,"Min: ",l.min.toLocaleString()),p.createElement("div",null,"Q1: ",l.q1.toLocaleString()),p.createElement("div",null,"Median: ",l.median.toLocaleString()),p.createElement("div",null,"Q3: ",l.q3.toLocaleString()),p.createElement("div",null,"Max: ",l.max.toLocaleString()),p.createElement("div",{style:{opacity:.8}},"Mean: ",l.mean.toLocaleString(void 0,{maximumFractionDigits:2})));const n=s.length;return p.createElement("div",{className:"semiotic-tooltip",style:po},e&&p.createElement("div",{style:{fontWeight:"bold"}},e+""),p.createElement("div",null,n," items"))}if(null!=s.bin&&null!=s.count){const e=s.range||[];return p.createElement("div",{className:"semiotic-tooltip",style:po},s.category&&p.createElement("div",{style:{fontWeight:"bold"}},s.category+""),p.createElement("div",null,"Count: ",s.count),2===e.length&&p.createElement("div",{style:{opacity:.8}},Number(e[0]).toFixed(1)," – ",Number(e[1]).toFixed(1)))}const u=e.__oAccessor,d=e.__rAccessor,h=e.__chartType;if("swarm"===h||"point"===h){const e=Object.entries(s).filter(([e])=>!e.startsWith("_")&&"data"!==e);return p.createElement("div",{className:"semiotic-tooltip",style:po},e.map(([e,t])=>p.createElement("div",{key:e},p.createElement("span",{style:{opacity:.7}},e,":")," ","number"==typeof t?t.toLocaleString():t+"")))}const g=(u&&null!=s[u]?s[u]:null)||s.category||s.name||s.group||s.__rName||"",f=null!==(a=null!==(i=null!==(r=null!==(o=null!==(n=s.__aggregateValue)&&void 0!==n?n:d&&null!=s[d]?s[d]:null)&&void 0!==o?o:s.value)&&void 0!==r?r:s.__rValue)&&void 0!==i?i:s.pct)&&void 0!==a?a:"";if(!g&&""===f){const e=Object.entries(s).filter(([e])=>!e.startsWith("_")&&"data"!==e);return p.createElement("div",{className:"semiotic-tooltip",style:po},e.map(([e,t])=>p.createElement("div",{key:e},p.createElement("span",{style:{opacity:.7}},e,":")," ","number"==typeof t?t.toLocaleString():t+"")))}return p.createElement("div",{className:"semiotic-tooltip",style:po},g&&p.createElement("div",{style:{fontWeight:"bold"}},g+""),""!==f&&p.createElement("div",null,"number"==typeof f?f.toLocaleString():f+""))}const mo=e.forwardRef(function(t,n){var o,r,i,a,s,c,u;const{chartType:d,runtimeMode:h,data:g,oAccessor:f="category",rAccessor:y="value",colorAccessor:v,stackBy:b,groupBy:x,multiAxis:k,timeAccessor:w,valueAccessor:A,categoryAccessor:S,projection:E="vertical",size:O=[600,400],responsiveWidth:M,responsiveHeight:P,margin:C,barPadding:L,innerRadius:j,normalize:N,startAngle:D,dynamicColumnWidth:_,bins:B,showOutliers:H,showIQR:R,amplitude:T,connectorAccessor:W,connectorStyle:I,rExtent:$,oExtent:z,extentPadding:F=.05,oSort:G,windowMode:Y="sliding",windowSize:q=200,pieceStyle:X,summaryStyle:V,colorScheme:U,barColors:K,showAxes:Q=!0,oLabel:ne,rLabel:oe,oFormat:re,rFormat:ie,enableHover:ae=!0,hoverAnnotation:se,tooltipContent:le,customHoverBehavior:ce,annotations:ue,svgAnnotationRules:de,showGrid:he=!1,legend:ge,legendHoverBehavior:fe,legendClickBehavior:pe,legendHighlightedCategory:ye,legendIsolatedCategories:me,legendPosition:ve,backgroundGraphics:be,foregroundGraphics:xe,title:ke,className:we,background:Ae,centerContent:Se,decay:Ee,pulse:Me,transition:Ce,staleness:je,accessibleTable:De}=t,[_e,Be]=ee(O,M,P),He=e.useMemo(()=>Object.assign(Object.assign({},fo),C),[C]),Re=Be[0]-He.left-He.right,We=Be[1]-He.top-He.bottom,$e="function"==typeof xe?xe({size:Be,margin:He}):xe,ze=e.useRef(null),Fe=e.useRef(!0),Ge=Te(e=>e.theme),Ye=e.useRef(0),qe=e.useRef(null),Xe=e.useRef(()=>{}),[Ve,Ue]=e.useState(null),[Ke,Qe]=e.useState(null),[Ze,Je]=e.useState(0),[et,tt]=e.useState(!1),nt=ae||se,ot="streaming"===h,rt=e.useMemo(()=>({chartType:d,runtimeMode:ot?"streaming":"bounded",windowSize:q,windowMode:Y,extentPadding:F,projection:E,oAccessor:ot?void 0:f,rAccessor:ot?void 0:y,colorAccessor:v,stackBy:b,groupBy:x,multiAxis:k,timeAccessor:ot?w:void 0,valueAccessor:ot?A||("string"==typeof y||"function"==typeof y?y:void 0):void 0,categoryAccessor:ot?S||f:void 0,rExtent:$,oExtent:z,barPadding:L,innerRadius:j,normalize:N,startAngle:D,dynamicColumnWidth:_,bins:B,showOutliers:H,showIQR:R,amplitude:T,connectorAccessor:W,connectorStyle:I,oSort:G,pieceStyle:X,summaryStyle:V,colorScheme:U,barColors:K,decay:Ee,pulse:Me,transition:Ce,staleness:je}),[d,q,Y,F,E,f,y,v,b,x,k,w,A,S,$,z,L,j,N,D,_,B,H,R,T,W,I,G,X,V,U,K,Ee,Me,Ce,je,ot]),it=e.useRef(null);it.current||(it.current=new Zn(rt));const at=e.useCallback(()=>{Ye.current||(Ye.current=requestAnimationFrame(()=>Xe.current()))},[]);e.useEffect(()=>{var e;null===(e=it.current)||void 0===e||e.updateConfig(rt),Fe.current=!0,at()},[rt,at]),e.useEffect(()=>{Fe.current=!0,at()},[Ge,at]);const st=e.useRef(null);st.current||(st.current=new m(e=>{const t=it.current;t&&t.ingest(e)&&(Fe.current=!0,at())}));const lt=e.useCallback(e=>{var t;null===(t=st.current)||void 0===t||t.push(e)},[]),ct=e.useCallback(e=>{var t;null===(t=st.current)||void 0===t||t.pushMany(e)},[]),ut=e.useCallback(()=>{var e,t;null===(e=st.current)||void 0===e||e.clear(),null===(t=it.current)||void 0===t||t.clear(),Fe.current=!0,at()},[at]);e.useImperativeHandle(n,()=>({push:lt,pushMany:ct,clear:ut,getData:()=>{var e,t,n;return null===(e=st.current)||void 0===e||e.flush(),null!==(n=null===(t=it.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var e,t;return null!==(t=null===(e=it.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null}}),[lt,ct,ut]),e.useEffect(()=>{var e;g&&(null===(e=st.current)||void 0===e||e.setBoundedData(g))},[g]);const dt=e.useRef(()=>{}),ht=e.useRef(()=>{});dt.current=e=>{if(!nt)return;const t=ze.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-He.left,r=e.clientY-n.top-He.top;if(0>o||o>Re||0>r||r>We)return void(qe.current&&(qe.current=null,Ue(null),ce&&ce(null),at()));const i=it.current;if(!i||0===i.scene.length)return;const a="radial"===E,s=function(e,t,n,o=30){let r=null;for(const i of e){let e=null;switch(i.type){case"rect":e=Jn(i,t,n);break;case"point":e=eo(i,t,n);break;case"wedge":e=to(i,t,n);break;case"boxplot":e=no(i,t,n);break;case"violin":e=oo(i,t,n)}e&&o>e.distance&&(r&&e.distance>=r.distance||(r=e))}return r}(i.scene,a?o-Re/2:o,a?r-We/2:r);if(!s)return void(qe.current&&(qe.current=null,Ue(null),ce&&ce(null),at()));const l=s.datum||{},c=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"object"!=typeof l||null===l||Array.isArray(l)?{}:l),{data:l,time:s.x,value:s.y,x:s.x,y:s.y}),s.stats&&{stats:s.stats}),s.category&&{category:s.category}),{__oAccessor:"string"==typeof f?f:void 0,__rAccessor:"string"==typeof y?y:void 0,__chartType:d});qe.current=c,Ue(c),ce&&(ce(c),Fe.current=!0),at()},ht.current=()=>{qe.current&&(qe.current=null,Ue(null),ce&&(ce(null),Fe.current=!0),at())},e.useCallback(e=>dt.current(e),[]);const gt=e.useCallback(()=>ht.current(),[]),ft=e.useRef(-1),pt=e.useCallback(e=>{const t=it.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=ft.current,r=Z(e.key,0>o?-1:o,n.length);if(null===r)return;if(e.preventDefault(),0>r)return ft.current=-1,qe.current=null,Ue(null),ce&&ce(null),void at();const i=0>o?0:r;ft.current=i;const a=Object.assign(Object.assign({},J(n[i])),{__oAccessor:"string"==typeof f?f:void 0,__rAccessor:"string"==typeof y?y:void 0,__chartType:d});qe.current=a,Ue(a),ce&&ce(a),at()},[ce,at]),yt=e.useCallback(e=>{ft.current=-1,dt.current(e)},[]);Xe.current=()=>{var e,t;Ye.current=0;const n=ze.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const r=it.current;if(!r)return;const i="undefined"!=typeof performance?performance.now():Date.now(),a=r.advanceTransition(i),s=Fe.current;s&&!a&&(r.computeScene({width:Re,height:We}),Fe.current=!1),(s||a)&&n.setAttribute("aria-label",Pe(r.scene,d+" chart"));const l=Ie(),c=Be[0]*l,u=Be[1]*l;n.width===c&&n.height===u||(n.width=c,n.height=u,n.style.width=Be[0]+"px",n.style.height=Be[1]+"px"),o.setTransform(l,0,0,l,0,0),o.clearRect(0,0,Be[0],Be[1]);const h=null!==(e=null==je?void 0:je.threshold)&&void 0!==e?e:5e3,g=je&&r.lastIngestTime>0&&i-r.lastIngestTime>h;g&&(o.globalAlpha=null!==(t=null==je?void 0:je.dimOpacity)&&void 0!==t?t:.5);const f=n?getComputedStyle(n).getPropertyValue("--semiotic-bg").trim():"",p=Ae||(f&&"transparent"!==f?f:null);p&&(o.fillStyle=p,o.fillRect(0,0,Be[0],Be[1]));const y="radial"===E;y?(o.save(),o.translate(He.left+Re/2,He.top+We/2)):o.translate(He.left,He.top);const m=go[d]||[],v={width:Re,height:We};for(const e of m)e(o,r.scene,r.scales,v);y&&o.restore(),g&&(o.globalAlpha=1),s&&r.scales&&(Qe(r.scales),Je(e=>e+1)),(null==je?void 0:je.showBadge)&&tt(!!g),(a||r.hasActivePulses)&&(Ye.current=requestAnimationFrame(()=>Xe.current()))},e.useEffect(()=>(at(),()=>{Ye.current&&(cancelAnimationFrame(Ye.current),Ye.current=0)}),[at]),e.useEffect(()=>{Fe.current=!0,at()},[d,Re,We,Q,Ae,at]),te(je,it,Fe,at,et,tt);const mt=nt&&Ve?le?le(Ve):p.createElement(yo,{hover:Ve}):null,vt="radial"===E,bt=Ve?vt?Ve.x+Re/2:Ve.x:0,xt=Ve?vt?Ve.y+We/2:Ve.y:0,kt=mt?p.createElement("div",{className:"stream-ordinal-tooltip",style:{position:"absolute",left:He.left+bt,top:He.top+xt,transform:`translate(${bt>.7*Re?"calc(-100% - 12px)":"12px"}, ${.3*We>xt?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1,width:"max-content"}},mt):null;if(Oe){const e=it.current;e&&g&&(e.ingest({inserts:g,bounded:!0}),e.computeScene({width:Re,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"===E,a=i?He.left+Re/2:He.left,s=i?He.top+We/2:He.top;return p.createElement("div",{className:"stream-ordinal-frame"+(we?" "+we:""),role:"img","aria-label":"string"==typeof ke?ke:"Ordinal chart",style:{position:"relative",width:Be[0],height:Be[1]}},p.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Be[0],height:Be[1],style:{position:"absolute",left:0,top:0}},be&&p.createElement("g",{transform:`translate(${He.left},${He.top})`},be),p.createElement("g",{transform:`translate(${a},${s})`},Ae&&p.createElement("rect",{x:0,y:0,width:Re,height:We,fill:Ae}),t.map((e,t)=>function(e,t){var n,o,r,i,a;const s=e.category||e.group||"",c=n=>`ord-${e.type}-${s}-${t}-${n}`,u=`ord-${e.type}-${s}-${t}`;switch(e.type){case"rect":return p.createElement("rect",{key:u,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 p.createElement("circle",{key:u,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 t=e,n=l.arc().innerRadius(t.innerRadius).outerRadius(t.outerRadius).startAngle(t.startAngle).endAngle(t.endAngle)({})||"";return p.createElement("path",{key:u,d:n,transform:`translate(${t.cx},${t.cy})`,fill:t.style.fill||"#4e79a7",stroke:t.style.stroke,strokeWidth:t.style.strokeWidth,opacity:t.style.opacity})}case"boxplot":{const t=e,n=t.columnWidth/2;return"vertical"===t.projection?p.createElement("g",{key:u},p.createElement("line",{x1:t.x,y1:t.minPos,x2:t.x,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1}),p.createElement("rect",{x:t.x-n,y:Math.min(t.q1Pos,t.q3Pos),width:t.columnWidth,height:Math.abs(t.q3Pos-t.q1Pos),fill:t.style.fill||"#4e79a7",fillOpacity:null!==(o=t.style.fillOpacity)&&void 0!==o?o:.6,stroke:t.style.stroke||"#333",strokeWidth:1}),p.createElement("line",{x1:t.x-n,y1:t.medianPos,x2:t.x+n,y2:t.medianPos,stroke:t.style.stroke||"#333",strokeWidth:2}),p.createElement("line",{x1:t.x-.5*n,y1:t.minPos,x2:t.x+.5*n,y2:t.minPos,stroke:t.style.stroke||"#333",strokeWidth:1}),p.createElement("line",{x1:t.x-.5*n,y1:t.maxPos,x2:t.x+.5*n,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1})):p.createElement("g",{key:u},p.createElement("line",{x1:t.minPos,y1:t.y,x2:t.maxPos,y2:t.y,stroke:t.style.stroke||"#333",strokeWidth:1}),p.createElement("rect",{x:Math.min(t.q1Pos,t.q3Pos),y:t.y-n,width:Math.abs(t.q3Pos-t.q1Pos),height:t.columnWidth,fill:t.style.fill||"#4e79a7",fillOpacity:null!==(r=t.style.fillOpacity)&&void 0!==r?r:.6,stroke:t.style.stroke||"#333",strokeWidth:1}),p.createElement("line",{x1:t.medianPos,y1:t.y-n,x2:t.medianPos,y2:t.y+n,stroke:t.style.stroke||"#333",strokeWidth:2}),p.createElement("line",{x1:t.minPos,y1:t.y-.5*n,x2:t.minPos,y2:t.y+.5*n,stroke:t.style.stroke||"#333",strokeWidth:1}),p.createElement("line",{x1:t.maxPos,y1:t.y-.5*n,x2:t.maxPos,y2:t.y+.5*n,stroke:t.style.stroke||"#333",strokeWidth:1}))}case"violin":{const t=e,n=[p.createElement("path",{key:c("path"),d:t.pathString,transform:t.translateX||t.translateY?`translate(${t.translateX},${t.translateY})`:void 0,fill:t.style.fill||"#4e79a7",fillOpacity:null!==(i=t.style.fillOpacity)&&void 0!==i?i:.6,stroke:t.style.stroke||"#333",strokeWidth:t.style.strokeWidth||1})];if(t.iqrLine&&t.bounds){const e=t.bounds,o=e.x+e.width/2,r=e.y+e.height/2;e.height>e.width?n.push(p.createElement("line",{key:c("iqr"),x1:o,y1:t.iqrLine.q1Pos,x2:o,y2:t.iqrLine.q3Pos,stroke:t.style.stroke||"#333",strokeWidth:2}),p.createElement("circle",{key:c("med"),cx:o,cy:t.iqrLine.medianPos,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1})):n.push(p.createElement("line",{key:c("iqr"),x1:t.iqrLine.q1Pos,y1:r,x2:t.iqrLine.q3Pos,y2:r,stroke:t.style.stroke||"#333",strokeWidth:2}),p.createElement("circle",{key:c("med"),cx:t.iqrLine.medianPos,cy:r,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1}))}return p.createElement("g",{key:u},n)}case"connector":return p.createElement("line",{key:u,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))),p.createElement(ao,{width:Re,height:We,totalWidth:Be[0],totalHeight:Be[1],margin:He,scales:n,showAxes:Q,oLabel:ne,rLabel:oe,oFormat:re,rFormat:ie,showGrid:he,title:ke,legend:ge,legendHoverBehavior:fe,legendClickBehavior:pe,legendHighlightedCategory:ye,legendIsolatedCategories:me,legendPosition:ve,foregroundGraphics:$e,annotations:ue,svgAnnotationRules:de,annotationFrame:0,xAccessor:"string"==typeof f?f:void 0,yAccessor:"string"==typeof y?y:void 0,annotationData:null==e?void 0:e.getData()}),Se&&"radial"===E&&p.createElement("div",{style:{position:"absolute",left:He.left+Re/2,top:He.top+We/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"}},Se))}return p.createElement("div",{ref:_e,className:"stream-ordinal-frame"+(we?" "+we:""),role:"img","aria-label":"string"==typeof ke?ke:"Ordinal chart",tabIndex:0,style:{position:"relative",width:M?"100%":Be[0],height:P?"100%":Be[1],overflow:"visible"},onMouseMove:nt?yt:void 0,onMouseLeave:nt?gt:void 0,onKeyDown:pt},be&&p.createElement("svg",{style:{position:"absolute",top:0,left:0,width:Be[0],height:Be[1],pointerEvents:"none"}},p.createElement("g",{transform:`translate(${He.left},${He.top})`},be)),p.createElement(ro,{width:Re,height:We,totalWidth:Be[0],totalHeight:Be[1],margin:He,scales:Ke,showAxes:Q,showGrid:he,rFormat:ie}),p.createElement("canvas",{ref:ze,"aria-label":Pe(null!==(a=null===(i=it.current)||void 0===i?void 0:i.scene)&&void 0!==a?a:[],d+" chart"),style:{position:"absolute",top:0,left:0,width:Be[0],height:Be[1]}}),p.createElement(Ne,{hoverPoint:Ve}),De&&p.createElement(Le,{scene:null!==(c=null===(s=it.current)||void 0===s?void 0:s.scene)&&void 0!==c?c:[],chartType:d+" chart"}),p.createElement(ao,{width:Re,height:We,totalWidth:Be[0],totalHeight:Be[1],margin:He,scales:Ke,showAxes:Q,oLabel:ne,rLabel:oe,oFormat:re,rFormat:ie,showGrid:he,title:ke,legend:ge,legendHoverBehavior:fe,legendClickBehavior:pe,legendHighlightedCategory:ye,legendIsolatedCategories:me,legendPosition:ve,foregroundGraphics:$e,annotations:ue,svgAnnotationRules:de,annotationFrame:Ze,xAccessor:"string"==typeof f?f:void 0,yAccessor:"string"==typeof y?y:void 0,annotationData:null===(u=it.current)||void 0===u?void 0:u.getData(),underlayRendered:!0}),Se&&"radial"===E&&p.createElement("div",{style:{position:"absolute",left:He.left+Re/2,top:He.top+We/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"}},Se),(null==je?void 0:je.showBadge)&&p.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===je.badgePosition?{top:4,left:4}:"bottom-left"===je.badgePosition?{bottom:4,left:4}:"bottom-right"===je.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:et?"#dc3545":"#28a745",color:"white"})},et?"STALE":"LIVE"),kt)});mo.displayName="StreamOrdinalFrame";const vo=e.forwardRef(function(t,n){const o=Wt(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}),r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",orientation:u="vertical",valueFormat:d,colorBy:h,colorScheme:g="category10",sort:f=!1,barPadding:y=40,tooltip:m,annotations:v,frameProps:b={},selection:x,linkedHover:k,onObservation:w,chartId:A,loading:S,emptyContent:E,legendInteraction:O,legendPosition:M}=t,P=o.width,C=o.height,L=o.enableHover,j=o.showGrid,N=o.title,D=o.categoryLabel,B=o.valueLabel,H=i||[],R=Bn({data:H,rawData:i,colorBy:h,colorScheme:g,legendInteraction:O,legendPosition:M,selection:x,linkedHover:k,fallbackFields:h?["string"==typeof h?h:""]:[],unwrapData:!0,onObservation:w,chartType:"BarChart",chartId:A,showLegend:o.showLegend,userMargin:a,marginDefaults:o.marginDefaults,loading:S,emptyContent:E,width:P,height:C});if(R.earlyReturn)return R.earlyReturn;Mn("BarChart",H,"categoryAccessor",l),Mn("BarChart",H,"valueAccessor",c);const T=_t(H,f,c),W=e.useMemo(()=>e=>{const t={};return t.fill=h?_(e,h,R.colorScale):jt,t},[h,R.colorScale]),I=e.useMemo(()=>Lt(W,R.effectiveSelectionHook,x),[W,R.effectiveSelectionHook,x]),$=e.useMemo(()=>Ut({categoryAccessor:l,valueAccessor:c,groupAccessor:h&&h!==l?h:void 0,groupLabel:"string"==typeof h?h:"group"}),[l,c,h]),z=nn({componentName:"BarChart",data:i,accessors:{categoryAccessor:l,valueAccessor:c}});if(z)return p.createElement(Kt,{componentName:"BarChart",message:z,width:P,height:C});const F=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar"},null!=i&&{data:T}),{oAccessor:l,rAccessor:c,projection:"horizontal"===u?"horizontal":"vertical",pieceStyle:I,size:[P,C],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R.margin,barPadding:y,enableHover:L,showAxes:o.showAxes,oLabel:D,rLabel:B,rFormat:d,showGrid:j,oSort:f}),R.legendBehaviorProps),N&&{title:N}),s&&{className:s}),{tooltipContent:!1===m?()=>null:Gt(m)||$}),(k||w)&&{customHoverBehavior:R.customHoverBehavior}),v&&v.length>0&&{annotations:v}),b);return p.createElement(wn,{componentName:"BarChart",width:P,height:C},p.createElement(mo,Object.assign({ref:r},F)))});vo.displayName="BarChart";const bo=e.forwardRef(function(t,n){const o=Wt(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}),r=e.useRef(null),{data:i,margin:a,className:s,categoryAccessor:l="category",stackBy:c,valueAccessor:u="value",orientation:d="vertical",valueFormat:h,colorBy:g,colorScheme:f="category10",normalize:y=!1,barPadding:m=40,tooltip:v,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:A,chartId:S,loading:E,emptyContent:O,legendInteraction:M,legendPosition:P}=t,C=o.width,L=o.height,j=o.enableHover,N=o.showGrid,D=o.showLegend,B=o.title,H=o.categoryLabel,R=o.valueLabel,T=i||[],W=g||c,I=Dn({isPushMode:void 0===i,colorBy:W,colorScheme:f,showLegend:D,legendPosition:P}),$=e.useCallback(I.wrapPush(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)}),[I.wrapPush]),z=e.useCallback(I.wrapPushMany(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)}),[I.wrapPushMany]);e.useImperativeHandle(n,()=>({push:$,pushMany:z,clear:()=>{var e;I.resetCategories(),null===(e=r.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}),[$,z,I.resetCategories]);const F=Bn({data:T,rawData:i,colorBy:W,colorScheme:f,legendInteraction:M,legendPosition:P,selection:k,linkedHover:w,fallbackFields:W?["string"==typeof W?W:""]:[],unwrapData:!0,onObservation:A,chartType:"StackedBarChart",chartId:S,showLegend:D,userMargin:a,marginDefaults:o.marginDefaults,loading:E,emptyContent:O,width:C,height:L});if(F.earlyReturn)return F.earlyReturn;const G=e.useMemo(()=>e=>W?F.colorScale?{fill:_(e,W,F.colorScale)}:{}:{fill:jt},[W,F.colorScale]),Y=e.useMemo(()=>Lt(G,F.effectiveSelectionHook,k),[G,F.effectiveSelectionHook,k]),q=e.useMemo(()=>Ut({categoryAccessor:c,valueAccessor:u,groupAccessor:l}),[c,l,u]),X=nn({componentName:"StackedBarChart",data:i,accessors:{categoryAccessor:l,valueAccessor:u},requiredProps:{stackBy:c}});if(X)return p.createElement(Kt,{componentName:"StackedBarChart",message:X,width:C,height:L});const V=e.useMemo(()=>I.streamingLegend?Object.assign(Object.assign({},F.legendBehaviorProps),{legend:I.streamingLegend,legendPosition:P||F.legendPosition}):F.legendBehaviorProps,[F.legendBehaviorProps,F.legendPosition,I.streamingLegend,P]),U=e.useMemo(()=>{if(I.streamingMarginAdjust){const e=Object.assign({},F.margin);for(const[t,n]of Object.entries(I.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return F.margin},[F.margin,I.streamingMarginAdjust]),K=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar"},null!=i&&{data:T}),{oAccessor:l,rAccessor:u,stackBy:c,normalize:y,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:Y,size:[C,L],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:U,barPadding:m,enableHover:j,showAxes:o.showAxes,oLabel:H,rLabel:R,rFormat:h,showGrid:N}),V),B&&{title:B}),s&&{className:s}),{tooltipContent:!1===v?()=>null:Gt(v)||q}),(w||A)&&{customHoverBehavior:F.customHoverBehavior}),b&&b.length>0&&{annotations:b}),x);return p.createElement(wn,{componentName:"StackedBarChart",width:C,height:L},p.createElement(mo,Object.assign({ref:r},K)))});bo.displayName="StackedBarChart";const xo=e.forwardRef(function(t,n){const o=Wt(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}),r=e.useRef(null),{data:i,margin:a,className:s,categoryAccessor:l="category",groupBy:c,valueAccessor:u="value",orientation:d="vertical",valueFormat:h,colorBy:g,colorScheme:f="category10",barPadding:y=60,tooltip:m,annotations:v,frameProps:b={},selection:x,linkedHover:k,onObservation:w,chartId:A,loading:S,emptyContent:E,legendInteraction:O,legendPosition:M}=t,P=o.width,C=o.height,L=o.enableHover,j=o.showGrid,N=o.showLegend,D=o.title,B=o.categoryLabel,H=o.valueLabel,R=i||[],T=g||c,W=Dn({isPushMode:void 0===i,colorBy:T,colorScheme:f,showLegend:N,legendPosition:M}),I=e.useCallback(W.wrapPush(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)}),[W.wrapPush]),$=e.useCallback(W.wrapPushMany(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)}),[W.wrapPushMany]);e.useImperativeHandle(n,()=>({push:I,pushMany:$,clear:()=>{var e;W.resetCategories(),null===(e=r.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}),[I,$,W.resetCategories]);const z=Bn({data:R,rawData:i,colorBy:T,colorScheme:f,legendInteraction:O,legendPosition:M,selection:x,linkedHover:k,fallbackFields:T?["string"==typeof T?T:""]:[],unwrapData:!0,onObservation:w,chartType:"GroupedBarChart",chartId:A,showLegend:N,userMargin:a,marginDefaults:o.marginDefaults,loading:S,emptyContent:E,width:P,height:C});if(z.earlyReturn)return z.earlyReturn;const F=e.useMemo(()=>e=>T?z.colorScale?{fill:_(e,T,z.colorScale)}:{}:{fill:jt},[T,z.colorScale]),G=e.useMemo(()=>Lt(F,z.effectiveSelectionHook,x),[F,z.effectiveSelectionHook,x]),Y=e.useMemo(()=>Ut({categoryAccessor:c,valueAccessor:u,groupAccessor:l}),[c,l,u]),q=nn({componentName:"GroupedBarChart",data:i,accessors:{categoryAccessor:l,valueAccessor:u},requiredProps:{groupBy:c}});if(q)return p.createElement(Kt,{componentName:"GroupedBarChart",message:q,width:P,height:C});const X=e.useMemo(()=>W.streamingLegend?Object.assign(Object.assign({},z.legendBehaviorProps),{legend:W.streamingLegend,legendPosition:M||z.legendPosition}):z.legendBehaviorProps,[z.legendBehaviorProps,z.legendPosition,W.streamingLegend,M]),V=e.useMemo(()=>{if(W.streamingMarginAdjust){const e=Object.assign({},z.margin);for(const[t,n]of Object.entries(W.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return z.margin},[z.margin,W.streamingMarginAdjust]),U=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"clusterbar"},null!=i&&{data:R}),{oAccessor:l,rAccessor:u,groupBy:c,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:G,size:[P,C],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:V,barPadding:y,enableHover:L,showAxes:o.showAxes,oLabel:B,rLabel:H,rFormat:h,showGrid:j}),X),D&&{title:D}),s&&{className:s}),{tooltipContent:!1===m?()=>null:Gt(m)||Y}),(k||w)&&{customHoverBehavior:z.customHoverBehavior}),v&&v.length>0&&{annotations:v}),b);return p.createElement(wn,{componentName:"GroupedBarChart",width:P,height:C},p.createElement(mo,Object.assign({ref:r},U)))});xo.displayName="GroupedBarChart";const ko=e.forwardRef(function(t,n){const o=Wt(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}),r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",orientation:u="vertical",valueFormat:d,colorBy:h,colorScheme:g="category10",sizeBy:f,sizeRange:y=[3,8],pointRadius:m=4,pointOpacity:v=.7,categoryPadding:b=20,tooltip:x,annotations:k,frameProps:w={},selection:A,linkedHover:S,onObservation:E,chartId:O,loading:M,emptyContent:P,legendInteraction:C,legendPosition:L}=t,j=o.width,N=o.height,D=o.enableHover,B=o.showGrid,R=o.title,T=o.categoryLabel,W=o.valueLabel,I=i||[],$=Bn({data:I,rawData:i,colorBy:h,colorScheme:g,legendInteraction:C,legendPosition:L,selection:A,linkedHover:S,fallbackFields:h?["string"==typeof h?h:""]:["string"==typeof l?l:""],unwrapData:!0,onObservation:E,chartType:"SwarmPlot",chartId:O,showLegend:o.showLegend,userMargin:a,marginDefaults:o.marginDefaults,loading:M,emptyContent:P,width:j,height:N});if($.earlyReturn)return $.earlyReturn;const z=e.useMemo(()=>{if(!f)return;const e=I.map(e=>"function"==typeof f?f(e):e[f]);return[Math.min(...e),Math.max(...e)]},[I,f]),F=e.useMemo(()=>e=>{const t={fillOpacity:v};return t.fill=h?_(e,h,$.colorScale):jt,t.r=f?H(e,f,y,z):m,t},[h,$.colorScale,f,y,z,m,v]),G=e.useMemo(()=>Lt(F,$.effectiveSelectionHook,A),[F,$.effectiveSelectionHook,A]),Y=e.useMemo(()=>Ut({categoryAccessor:l,valueAccessor:c,groupAccessor:h||void 0}),[l,c,h]),q=nn({componentName:"SwarmPlot",data:i,accessors:{categoryAccessor:l,valueAccessor:c}});if(q)return p.createElement(Kt,{componentName:"SwarmPlot",message:q,width:j,height:N});const X=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"swarm"},null!=i&&{data:I}),{oAccessor:l,rAccessor:c,projection:"horizontal"===u?"horizontal":"vertical",pieceStyle:G,size:[j,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:$.margin,barPadding:b,enableHover:D,showAxes:o.showAxes,oLabel:T,rLabel:W,rFormat:d,showGrid:B}),$.legendBehaviorProps),R&&{title:R}),s&&{className:s}),{tooltipContent:!1===x?()=>null:Gt(x)||Y}),(S||E)&&{customHoverBehavior:$.customHoverBehavior}),k&&k.length>0&&{annotations:k}),w);return p.createElement(wn,{componentName:"SwarmPlot",width:j,height:N},p.createElement(mo,Object.assign({ref:r},X)))});ko.displayName="SwarmPlot";const wo=e.forwardRef(function(t,n){const o=Wt(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}),r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",orientation:u="vertical",valueFormat:d,colorBy:h,colorScheme:g="category10",showOutliers:f=!0,categoryPadding:y=20,tooltip:m,annotations:v,frameProps:b={},selection:x,linkedHover:k,onObservation:w,chartId:A,loading:S,emptyContent:E,legendInteraction:O,legendPosition:M}=t,P=o.width,C=o.height,L=o.enableHover,j=o.showGrid,N=o.title,D=o.categoryLabel,B=o.valueLabel,H=i||[],R=Bn({data:H,rawData:i,colorBy:h,colorScheme:g,legendInteraction:O,legendPosition:M,selection:x,linkedHover:k,fallbackFields:h?["string"==typeof h?h:""]:["string"==typeof l?l:""],unwrapData:!0,onObservation:w,chartType:"BoxPlot",chartId:A,showLegend:o.showLegend,userMargin:a,marginDefaults:o.marginDefaults,loading:S,emptyContent:E,width:P,height:C});if(R.earlyReturn)return R.earlyReturn;const T=e.useMemo(()=>e=>{const t=h?_(e,h,R.colorScale):jt;return{fill:t,stroke:t,fillOpacity:.8}},[h,R.colorScale]),W=e.useMemo(()=>Lt(T,R.effectiveSelectionHook,x),[T,R.effectiveSelectionHook,x]),I=e.useMemo(()=>e=>{const t=e.stats||(e.data||e).stats||{};return p.createElement("div",{className:"semiotic-tooltip",style:It},p.createElement("div",{style:{fontWeight:"bold",marginBottom:"4px"}},(e.category||(e.data||e).category||"")+""),null!=t.median&&p.createElement(p.Fragment,null,null!=t.n&&p.createElement("div",null,"n = ",t.n),p.createElement("div",null,"Median: ",t.median.toLocaleString()),p.createElement("div",null,"Q1: ",t.q1.toLocaleString()),p.createElement("div",null,"Q3: ",t.q3.toLocaleString()),p.createElement("div",null,"Min: ",t.min.toLocaleString()),p.createElement("div",null,"Max: ",t.max.toLocaleString())))},[]),$=nn({componentName:"BoxPlot",data:i,accessors:{categoryAccessor:l,valueAccessor:c}});if($)return p.createElement(Kt,{componentName:"BoxPlot",message:$,width:P,height:C});const z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"boxplot"},null!=i&&{data:H}),{oAccessor:l,rAccessor:c,projection:"horizontal"===u?"horizontal":"vertical",summaryStyle:W,showOutliers:f,size:[P,C],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R.margin,barPadding:y,enableHover:L,showAxes:o.showAxes,oLabel:D,rLabel:B,rFormat:d,showGrid:j}),R.legendBehaviorProps),N&&{title:N}),s&&{className:s}),{tooltipContent:!1===m?()=>null:Gt(m)||I}),(k||w)&&{customHoverBehavior:R.customHoverBehavior}),v&&v.length>0&&{annotations:v}),b);return p.createElement(wn,{componentName:"BoxPlot",width:P,height:C},p.createElement(mo,Object.assign({ref:r},z)))});wo.displayName="BoxPlot";const Ao=e.forwardRef(function(t,n){const o=Wt(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}),r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",bins:u=25,relative:d=!1,valueFormat:h,colorBy:g,colorScheme:f="category10",categoryPadding:y=20,tooltip:m,annotations:v,frameProps:b={},selection:x,linkedHover:k,onObservation:w,chartId:A,loading:S,emptyContent:E,legendPosition:O}=t,M=o.width,P=o.height,C=o.enableHover,L=o.showGrid,j=o.title,N=o.categoryLabel,D=o.valueLabel,B=i||[],H=Bn({data:B,rawData:i,colorBy:g,colorScheme:f,legendInteraction:void 0,legendPosition:O,selection:x,linkedHover:k,fallbackFields:g?["string"==typeof g?g:""]:["string"==typeof l?l:""],unwrapData:!0,onObservation:w,chartType:"Histogram",chartId:A,showLegend:o.showLegend,userMargin:a,marginDefaults:o.marginDefaults,loading:S,emptyContent:E,width:M,height:P});if(H.earlyReturn)return H.earlyReturn;const R=e.useMemo(()=>e=>{const t=g?_(e,g,H.colorScale):jt;return{fill:t,stroke:t,fillOpacity:.8}},[g,H.colorScale]),T=e.useMemo(()=>Lt(R,H.activeSelectionHook,x),[R,H.activeSelectionHook,x]),W=e.useMemo(()=>e=>{const t=e.data||e,n=t.category||e.category||"",o=t.count,r=t.range;return p.createElement("div",{className:"semiotic-tooltip",style:It},n&&p.createElement("div",{style:{fontWeight:"bold"}},n+""),null!=o&&p.createElement("div",null,"Count: ",o),r&&2===r.length&&p.createElement("div",{style:{opacity:.8}},Number(r[0]).toFixed(1)," – ",Number(r[1]).toFixed(1)))},[]),I=nn({componentName:"Histogram",data:i,accessors:{categoryAccessor:l,valueAccessor:c}});if(I)return p.createElement(Kt,{componentName:"Histogram",message:I,width:M,height:P});const $=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"histogram"},null!=i&&{data:B}),{oAccessor:l,rAccessor:c,projection:"horizontal",summaryStyle:T,bins:u,normalize:d,size:[M,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:H.margin,barPadding:y,enableHover:C,showAxes:o.showAxes,oLabel:N,rLabel:D,rFormat:h,showGrid:L}),H.legendBehaviorProps),j&&{title:j}),s&&{className:s}),{tooltipContent:!1===m?()=>null:Gt(m)||W}),(k||w)&&{customHoverBehavior:H.customHoverBehavior}),v&&v.length>0&&{annotations:v}),b);return p.createElement(wn,{componentName:"Histogram",width:M,height:P},p.createElement(mo,Object.assign({ref:r},$)))});Ao.displayName="Histogram";const So=e.forwardRef(function(t,n){const o=Wt(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}),r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",orientation:u="vertical",bins:d=25,showIQR:h=!0,valueFormat:g,colorBy:f,colorScheme:y="category10",categoryPadding:m=20,tooltip:v,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:A,chartId:S,loading:E,emptyContent:O,legendPosition:M}=t,P=o.width,C=o.height,L=o.enableHover,j=o.showGrid,N=o.title,D=o.categoryLabel,B=o.valueLabel,H=i||[],R=Bn({data:H,rawData:i,colorBy:f,colorScheme:y,legendInteraction:void 0,legendPosition:M,selection:k,linkedHover:w,fallbackFields:f?["string"==typeof f?f:""]:["string"==typeof l?l:""],unwrapData:!0,onObservation:A,chartType:"ViolinPlot",chartId:S,showLegend:o.showLegend,userMargin:a,marginDefaults:o.marginDefaults,loading:E,emptyContent:O,width:P,height:C});if(R.earlyReturn)return R.earlyReturn;const T=e.useMemo(()=>e=>{const t=f?_(e,f,R.colorScale):jt;return{fill:t,stroke:t,fillOpacity:.6}},[f,R.colorScale]),W=e.useMemo(()=>Lt(T,R.activeSelectionHook,k),[T,R.activeSelectionHook,k]),I=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 p.createElement("div",{className:"semiotic-tooltip",style:It},n&&p.createElement("div",{style:{fontWeight:"bold"}},n+""),p.createElement("div",null,"n = ",o.n),p.createElement("div",null,"Min: ",o.min.toLocaleString()),p.createElement("div",null,"Q1: ",o.q1.toLocaleString()),p.createElement("div",null,"Median: ",o.median.toLocaleString()),p.createElement("div",null,"Q3: ",o.q3.toLocaleString()),p.createElement("div",null,"Max: ",o.max.toLocaleString()),p.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 c?c(e):e[c];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 p.createElement("div",{className:"semiotic-tooltip",style:It},n&&p.createElement("div",{style:{fontWeight:"bold"}},n+""),i>0&&p.createElement("div",null,"n = ",i),null!=a&&p.createElement("div",null,"Median: ",a.toLocaleString()))},[c]),$=nn({componentName:"ViolinPlot",data:i,accessors:{categoryAccessor:l,valueAccessor:c}});if($)return p.createElement(Kt,{componentName:"ViolinPlot",message:$,width:P,height:C});const z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"violin"},null!=i&&{data:H}),{oAccessor:l,rAccessor:c,projection:"horizontal"===u?"horizontal":"vertical",summaryStyle:W,bins:d,showIQR:h,size:[P,C],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R.margin,barPadding:m,enableHover:L,showAxes:o.showAxes,oLabel:D,rLabel:B,rFormat:g,showGrid:j}),R.legendBehaviorProps),N&&{title:N}),s&&{className:s}),{tooltipContent:!1===v?()=>null:Gt(v)||I}),(w||A)&&{customHoverBehavior:R.customHoverBehavior}),b&&b.length>0&&{annotations:b}),x);return p.createElement(wn,{componentName:"ViolinPlot",width:P,height:C},p.createElement(mo,Object.assign({ref:r},z)))});So.displayName="ViolinPlot";const Eo=e.forwardRef(function(t,n){var o;const r=Wt(t.mode,{width:t.width,height:t.height,showGrid:null===(o=t.showGrid)||void 0===o||o,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),i=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const{data:a,margin:s,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="horizontal",valueFormat:h,colorBy:g,colorScheme:f="category10",sort:y=!0,dotRadius:m=5,categoryPadding:v=10,tooltip:b,annotations:x,frameProps:k={},selection:w,linkedHover:A,onObservation:S,chartId:E,loading:O,emptyContent:M,legendInteraction:P,legendPosition:C}=t,L=r.width,j=r.height,N=r.enableHover,D=r.showGrid,B=r.title,H=r.categoryLabel,R=r.valueLabel,T=a||[],W=Bn({data:T,rawData:a,colorBy:g,colorScheme:f,legendInteraction:P,legendPosition:C,selection:w,linkedHover:A,fallbackFields:g?["string"==typeof g?g:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:S,chartType:"DotPlot",chartId:E,showLegend:r.showLegend,userMargin:s,marginDefaults:r.marginDefaults,loading:O,emptyContent:M,width:L,height:j});if(W.earlyReturn)return W.earlyReturn;const I=_t(T,y,u),$=e.useMemo(()=>e=>{const t={r:m,fillOpacity:.8};return t.fill=g?_(e,g,W.colorScale):jt,t},[g,W.colorScale,m]),z=e.useMemo(()=>Lt($,W.effectiveSelectionHook,w),[$,W.effectiveSelectionHook,w]),F=e.useMemo(()=>Ut({categoryAccessor:c,valueAccessor:u}),[c,u]),G=nn({componentName:"DotPlot",data:a,accessors:{categoryAccessor:c,valueAccessor:u}});if(G)return p.createElement(Kt,{componentName:"DotPlot",message:G,width:L,height:j});const Y=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"point"},null!=a&&{data:I}),{oAccessor:c,rAccessor:u,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:z,size:[L,j],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:W.margin,barPadding:v,enableHover:N,showAxes:r.showAxes,oLabel:H,rLabel:R,rFormat:h,showGrid:D,oSort:y}),W.legendBehaviorProps),B&&{title:B}),l&&{className:l}),{tooltipContent:!1===b?()=>null:Gt(b)||F}),(A||S)&&{customHoverBehavior:W.customHoverBehavior}),x&&x.length>0&&{annotations:x}),k);return p.createElement(wn,{componentName:"DotPlot",width:L,height:j},p.createElement(mo,Object.assign({ref:i},Y)))});function Oo(t){const n=Wt(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:f=5,tooltip:y,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:k,chartId:w,loading:A,emptyContent:S,legendPosition:E}=t,O=n.width,M=n.height,P=n.enableHover,C=n.showGrid,L=n.title,j=n.categoryLabel,N=n.valueLabel,D=o||[],B=Bn({data:D,rawData:o,colorBy:h,colorScheme:g,legendInteraction:void 0,legendPosition:E,selection:b,linkedHover:x,fallbackFields:h?["string"==typeof h?h:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:k,chartType:"RidgelinePlot",chartId:w,showLegend:n.showLegend,userMargin:r,marginDefaults:n.marginDefaults,loading:A,emptyContent:S,width:O,height:M});if(B.earlyReturn)return B.earlyReturn;const H=e.useMemo(()=>e=>{const t=h?_(e,h,B.colorScale):jt;return{fill:t,stroke:t,fillOpacity:.5}},[h,B.colorScale]),R=e.useMemo(()=>Lt(H,B.activeSelectionHook,b),[H,B.activeSelectionHook,b]),T=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?p.createElement("div",{className:"semiotic-tooltip",style:It},n&&p.createElement("div",{style:{fontWeight:"bold"}},n+""),p.createElement("div",null,"n = ",o.n),p.createElement("div",null,"Min: ",o.min.toLocaleString()),p.createElement("div",null,"Q1: ",o.q1.toLocaleString()),p.createElement("div",null,"Median: ",o.median.toLocaleString()),p.createElement("div",null,"Q3: ",o.q3.toLocaleString()),p.createElement("div",null,"Max: ",o.max.toLocaleString()),p.createElement("div",{style:{opacity:.8}},"Mean: ",o.mean.toLocaleString(void 0,{maximumFractionDigits:2}))):p.createElement("div",{className:"semiotic-tooltip",style:It},p.createElement("div",{style:{fontWeight:"bold"}},n+""))},[]),W=nn({componentName:"RidgelinePlot",data:o,accessors:{categoryAccessor:a,valueAccessor:s}});if(W)return p.createElement(Kt,{componentName:"RidgelinePlot",message:W,width:O,height:M});const I=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"ridgeline"},null!=o&&{data:D}),{oAccessor:a,rAccessor:s,projection:"horizontal"===l?"horizontal":"vertical",summaryStyle:R,bins:c,size:[O,M],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:B.margin,barPadding:f,enableHover:P,showAxes:n.showAxes,oLabel:j,rLabel:N,rFormat:d,showGrid:C,oSort:!1,amplitude:u}),B.legendBehaviorProps),L&&{title:L}),i&&{className:i}),{tooltipContent:!1===y?()=>null:Gt(y)||T}),(x||k)&&{customHoverBehavior:B.customHoverBehavior}),m&&m.length>0&&{annotations:m}),v);return p.createElement(wn,{componentName:"RidgelinePlot",width:O,height:M},p.createElement(mo,Object.assign({},I)))}Eo.displayName="DotPlot",Oo.displayName="RidgelinePlot";const Mo=e.forwardRef(function(t,n){var o,r;const i=Wt(t.mode,{width:null!==(o=t.width)&&void 0!==o?o:400,height:null!==(r=t.height)&&void 0!==r?r:400,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title}),a=e.useRef(null),{data:s,margin:l,className:c,categoryAccessor:u="category",valueAccessor:d="value",colorBy:h,colorScheme:g="category10",startAngle:f=0,tooltip:y,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:k,chartId:w,loading:A,emptyContent:S,legendInteraction:E,legendPosition:O}=t,M=i.width,P=i.height,C=i.enableHover,L=i.showLegend,j=i.title,N=s||[],D=h||u,B=Dn({isPushMode:void 0===s,colorBy:D,colorScheme:g,showLegend:L,legendPosition:O}),H=e.useCallback(B.wrapPush(e=>{var t;return null===(t=a.current)||void 0===t?void 0:t.push(e)}),[B.wrapPush]),R=e.useCallback(B.wrapPushMany(e=>{var t;return null===(t=a.current)||void 0===t?void 0:t.pushMany(e)}),[B.wrapPushMany]);e.useImperativeHandle(n,()=>({push:H,pushMany:R,clear:()=>{var e;B.resetCategories(),null===(e=a.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=a.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}),[H,R,B.resetCategories]);const T=Bn({data:N,rawData:s,colorBy:D,colorScheme:g,legendInteraction:E,legendPosition:O,selection:b,linkedHover:x,fallbackFields:D?["string"==typeof D?D:""]:[],unwrapData:!0,onObservation:k,chartType:"PieChart",chartId:w,showLegend:L,userMargin:l,marginDefaults:i.marginDefaults,loading:A,emptyContent:S,width:M,height:P});if(T.earlyReturn)return T.earlyReturn;const W=e.useMemo(()=>e=>D?T.colorScale?{fill:_(e,D,T.colorScale)}:{}:{fill:jt},[D,T.colorScale]),I=e.useMemo(()=>Lt(W,T.effectiveSelectionHook,b),[W,T.effectiveSelectionHook,b]),$=e.useMemo(()=>Ut({categoryAccessor:u,valueAccessor:d,groupAccessor:h&&h!==u?h:void 0,groupLabel:"string"==typeof h?h:"group",pieData:!0}),[u,d,h]),z=nn({componentName:"PieChart",data:s,accessors:{categoryAccessor:u,valueAccessor:d}});if(z)return p.createElement(Kt,{componentName:"PieChart",message:z,width:M,height:P});const F=e.useMemo(()=>B.streamingLegend?Object.assign(Object.assign({},T.legendBehaviorProps),{legend:B.streamingLegend,legendPosition:O||T.legendPosition}):T.legendBehaviorProps,[T.legendBehaviorProps,T.legendPosition,B.streamingLegend,O]),G=e.useMemo(()=>{if(B.streamingMarginAdjust){const e=Object.assign({},T.margin);for(const[t,n]of Object.entries(B.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return T.margin},[T.margin,B.streamingMarginAdjust]),Y=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"pie"},null!=s&&{data:N}),{oAccessor:u,rAccessor:d,projection:"radial",pieceStyle:I,startAngle:f,size:[M,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:G,enableHover:C,showAxes:!1}),F),j&&{title:j}),c&&{className:c}),{tooltipContent:!1===y?()=>null:Gt(y)||$}),(x||k)&&{customHoverBehavior:T.customHoverBehavior}),m&&m.length>0&&{annotations:m}),v);return p.createElement(wn,{componentName:"PieChart",width:M,height:P},p.createElement(mo,Object.assign({ref:a},Y)))});Mo.displayName="PieChart";const Po=e.forwardRef(function(t,n){var o,r;const i=Wt(t.mode,{width:null!==(o=t.width)&&void 0!==o?o:400,height:null!==(r=t.height)&&void 0!==r?r:400,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,linkedHover:t.linkedHover}),a=e.useRef(null),{data:s,margin:l,className:c,categoryAccessor:u="category",valueAccessor:d="value",innerRadius:h=60,centerContent:g,colorBy:f,colorScheme:y="category10",startAngle:m=0,tooltip:v,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:A,chartId:S,loading:E,emptyContent:O,legendInteraction:M,legendPosition:P}=t,C=i.width,L=i.height,j=i.enableHover,N=i.showLegend,D=i.title,B=s||[],H=f||u,R=Dn({isPushMode:void 0===s,colorBy:H,colorScheme:y,showLegend:N,legendPosition:P}),T=e.useCallback(R.wrapPush(e=>{var t;return null===(t=a.current)||void 0===t?void 0:t.push(e)}),[R.wrapPush]),W=e.useCallback(R.wrapPushMany(e=>{var t;return null===(t=a.current)||void 0===t?void 0:t.pushMany(e)}),[R.wrapPushMany]);e.useImperativeHandle(n,()=>({push:T,pushMany:W,clear:()=>{var e;R.resetCategories(),null===(e=a.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=a.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}),[T,W,R.resetCategories]);const I=Bn({data:B,rawData:s,colorBy:H,colorScheme:y,legendInteraction:M,legendPosition:P,selection:k,linkedHover:w,fallbackFields:H?["string"==typeof H?H:""]:[],unwrapData:!0,onObservation:A,chartType:"DonutChart",chartId:S,showLegend:N,userMargin:l,marginDefaults:i.marginDefaults,loading:E,emptyContent:O,width:C,height:L});if(I.earlyReturn)return I.earlyReturn;const $=e.useMemo(()=>e=>H?I.colorScale?{fill:_(e,H,I.colorScale)}:{}:{fill:jt},[H,I.colorScale]),z=e.useMemo(()=>Lt($,I.effectiveSelectionHook,k),[$,I.effectiveSelectionHook,k]),F=e.useMemo(()=>Ut({categoryAccessor:u,valueAccessor:d,groupAccessor:f&&f!==u?f:void 0,groupLabel:"string"==typeof f?f:"group",pieData:!0}),[u,d,f]),G=nn({componentName:"DonutChart",data:s,accessors:{categoryAccessor:u,valueAccessor:d}});if(G)return p.createElement(Kt,{componentName:"DonutChart",message:G,width:C,height:L});const Y=e.useMemo(()=>R.streamingLegend?Object.assign(Object.assign({},I.legendBehaviorProps),{legend:R.streamingLegend,legendPosition:P||I.legendPosition}):I.legendBehaviorProps,[I.legendBehaviorProps,I.legendPosition,R.streamingLegend,P]),q=e.useMemo(()=>{if(R.streamingMarginAdjust){const e=Object.assign({},I.margin);for(const[t,n]of Object.entries(R.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return I.margin},[I.margin,R.streamingMarginAdjust]),X=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"donut"},null!=s&&{data:B}),{oAccessor:u,rAccessor:d,projection:"radial",pieceStyle:z,innerRadius:h,startAngle:m,centerContent:g,size:[C,L],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:q,enableHover:j,showAxes:!1}),Y),D&&{title:D}),c&&{className:c}),{tooltipContent:!1===v?()=>null:Gt(v)||F}),(w||A)&&{customHoverBehavior:I.customHoverBehavior}),b&&b.length>0&&{annotations:b}),x);return p.createElement(wn,{componentName:"DonutChart",width:C,height:L},p.createElement(mo,Object.assign({ref:a},X)))});Po.displayName="DonutChart";const Co={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Lo={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class jo{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=No(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 No(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=Do(l,c,u,d,s),g=d.x-l.x,f=d.y-l.y,p=Math.sqrt(g*g+f*f);if(p>.001){const e=g/p;h.x+=-f/p*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=Do(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 Do(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 _o(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function Bo(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 p=g[f];if(0>n[p]){n[p]=o[p]=u,r[p]=!0,u+=1,l.push(p),c.push(p);break}r[p]&&(o[t]=0|Math.min(o[t],o[p])),0>a[p]||s[t].push(a[p])}i[t]=f}else{if(o[t]===n[t]){var y=[],m=[],v=0;for(f=l.length-1;f>=0;--f){var b=l[f];if(r[b]=!1,y.push(b),m.push(s[b]),v+=s[b].length,a[b]=d.length,b===t){l.length=f;break}}d.push(y);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 p=1;f.length>p;p++)f[p]!==f[p-1]&&c.push(f[p]);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 p=0;s[f].length>p;p++){var y=s[f][p];i[+y]=!1,a[y]={}}c(n),n+=1}else n=h}return o}function Ho(e){return e.y0-e.y1>0?"up":"down"}function Ro(e,t){return t(e.source)==t(e.target)}function To(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 Wo(e){return e.target.x0-e.source.x1}function Io(e,t){var n=zo(e),o=Wo(t)/Math.tan(n);return"up"==Ho(e)?e.y1-o:e.y1+o}function $o(e,t){var n=zo(e),o=Wo(t)/Math.tan(n);return"up"==Ho(e)?e.y1+o:e.y1-o}function zo(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function Fo(e,t){return t(e)}function Go(e){return qo(e.source)}function Yo(e){return qo(e.target)}function qo(e){return(e.y0+e.y1)/2}function Xo(e){return e.virtual?0:e.value}function Vo(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!Ro(e,t)?n+1:n});var o=0;return e.targetLinks.forEach(function(e){o=e.circular&&!Ro(e,t)?o+1:o}),n+o}function Uo(e){return e.target.depth}function Ko(e,t){return e.sourceLinks.length?e.depth:t-1}function Qo(e,t){return e.y0-t.y0}function Zo(e,t){return t.y0-e.y0}function Jo(e,t){return e.y1-t.y1}function er(e,t){return t.y1-e.y1}function tr(e,t){return or(e.source,t.source)||e.index-t.index}function nr(e,t){return or(e.target,t.target)||e.index-t.index}function or(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function rr(e,t){return ir(e)==ir(t)?"bottom"==e.circularLinkType?Zo(e,t):Qo(e,t):ir(t)-ir(e)}function ir(e){return e.target.column-e.source.column}function ar(e,t){return sr(e)==sr(t)}function sr(e){return e.y0-e.y1>0?"up":"down"}function lr(e,t,n,o,r){let i=e;var s=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var l=a.min(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=i.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}),cr(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),cr(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),i.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,Ro(e,t)&&To(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+r+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-r-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var a=e.source.column,s=e.circularLinkType,c=i.links.filter(function(e){return e.source.column==a&&e.circularLinkType==s});c.sort("bottom"==e.circularLinkType?Zo:Qo);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}),a=e.target.column,(c=i.links.filter(function(e){return e.target.column==a&&e.circularLinkType==s})).sort("bottom"==e.circularLinkType?er:Jo),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(i.y1,e.source.y1,e.target.y1)+r+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-r-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)}),i}function cr(e,t,n){e.sort(rr);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(Ro(e,t)&&To(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&&ur(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 ur(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function dr(e){return function(){return e}}function hr(e){return e.index}function gr(e){return e.nodes}function fr(e){return e.links}function pr(e,t,n){var o=a.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,i){var a=r.length;if(t)r.sort(t);else if(i>0){var s=new Map;r.forEach(function(e,t){var n,o,r,i=(o=0,r=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=qo(e.source)*t,o+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=qo(e.target)*t,o+=t}}),o>0?r/o:NaN);s.set(e,{bc:i,idx:t})}),r.sort(function(e,t){var n=s.get(e),o=s.get(t),r=n.bc,i=o.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(r)||isNaN(i)?isNaN(r)?isNaN(i)?n.idx-o.idx:1:-1:r-i})}else r.sort(function(e,t){return e.circularLinkType==t.circularLinkType?Vo(t,n)-Vo(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==a||0==t.depth&&1==a?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==Vo(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)/a*r,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-a/2+r,t.y1=t.y0+t.value*e.ky)})})}function yr(e,t,n,o,r,i){var s=a.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=i;c>0;--c)u(l*=.99,n),d();function u(t,n){var o=s.length;s.forEach(function(r){var i=r.length,s=r[0].depth;r.forEach(function(r){var l;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&Vo(r,n)>0){var c=a.mean(r.sourceLinks,Yo),u=a.mean(r.targetLinks,Go),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-qo(r))*t*.3;r.y0+=h,r.y1+=h}}else if(0==s&&1==i)r.y0=e.y1/2-(l=r.y1-r.y0)/2,r.y1=e.y1/2+l/2;else if(s==o-1&&1==i)r.y0=e.y1/2-(l=r.y1-r.y0)/2,r.y1=e.y1/2+l/2;else if(1==r.targetLinks.length&&1==r.targetLinks[0].source.sourceLinks.length)l=r.y1-r.y0,r.y0=r.targetLinks[0].source.y0,r.y1=r.y0+l;else{var g=a.mean(r.sourceLinks,Yo),f=a.mean(r.targetLinks,Go),p=((g&&f?(g+f)/2:g||f)-qo(r))*t;r.y0+=p,r.y1+=p}})})}function d(){s.forEach(function(n){var i,a,s,l=e.y0,c=n.length;for(n.sort(t||or),s=0;c>s;++s)(a=l-(i=n[s]).y0)>0&&(i.y0+=a,i.y1+=a),l=i.y1+o;if((a=l-o-e.y1)>0)for(l=i.y0-=a,i.y1-=a,s=c-2;s>=0;--s)(a=(i=n[s]).y1+r-l)>0&&(i.y0-=a,i.y1-=a),l=i.y0})}}function mr(e){e.nodes.forEach(function(e){e.sourceLinks.sort(nr),e.targetLinks.sort(tr)}),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 vr(){var e=0,t=0,n=1,o=1,r=24,i=8,s=null,l=hr,c=Ko,u=void 0,d=32,h=2,g=gr,f=fr;function p(){var p={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 a.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=_o(n,o)),"object"!=typeof r&&(r=e.target=_o(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=Bo(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){Fo(e,t)!=Fo(r.source,t)&&Fo(e,t)!=Fo(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),Ro(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(g,l),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(a.sum(e.sourceLinks,Xo),a.sum(e.targetLinks,Xo)),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=i;if(null!==s){var p=a.groups(g.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),y=a.max(p,function(e){return e.length});y>1&&(f=Math.max(1,(o-t)*s/(y-1)))}(function(e,t,n){var o=a.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 r=a.min(o,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/a.sum(t,function(e){return e.value})});e.ky=r,e.links.forEach(function(t){t.width=t.value*e.ky});var i=a.max(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/i),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(g,f,r),pr(g,u,l),yr(g,u,l,f,f,d),mr(g),lr(g,l,h,10,8),pr(g,u,l),yr(g,u,l,f,f,d),mr(g),lr(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 Fo(n.source,t)==Fo(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(!ar(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=Io(t,e);return e.y1-n}if(t.target.column>e.target.column)return Io(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 Fo(n.target,t)==Fo(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(!ar(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=$o(t,e);return e.y0-n}if(t.source.column>e.source.column)return $o(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,r=!1;if(n.forEach(function(e){"top"==e.circularLinkType?o=!0:"bottom"==e.circularLinkType&&(r=!0)}),0==o||0==r){var i=a.min(t,function(e){return e.y0}),s=a.max(t,function(e){return e.y1}),l=(e.y1-e.y0)/(s-i);function c(t){return(t-i)/(s-i)*(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),lr(g,l,h,10,8)}(p),p}return p.update=function(e){return mr(e),lr(e,l,h,10,8),e},p.nodeWidth=function(e){return arguments.length?(r=+e,p):r},p.nodePadding=function(e){return arguments.length?(i=+e,p):i},p.nodePaddingRatio=function(e){return arguments.length?(s=+e,p):s},p.nodes=function(e){return arguments.length?(g="function"==typeof e?e:dr(e),p):g},p.links=function(e){return arguments.length?(f="function"==typeof e?e:dr(e),p):f},p.nodeId=function(e){return arguments.length?(l="function"==typeof e?e:dr(e),p):l},p.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:dr(e),p):c},p.nodeSort=function(e){return arguments.length?(u=e,p):u},p.iterations=function(e){return arguments.length?(d=+e,p):d},p.circularLinkGap=function(e){return arguments.length?(h=+e,p):h},p.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],p):[[e,t],[n,o]]},p.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],p):[n-e,o-t]},p}const br=e=>{let t,n,o,r,i,a,s,l,c;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=u.interpolateNumber(i,a),l=s(.5),c=s(.5),`M${t},${i}C${t},${l} ${n},${c} ${n},${a}L${o},${a}C${o},${c} ${r},${l} ${r},${i}Z`):(t=e.source.x1,n=e.target.x0,s=u.interpolateNumber(t,n),o=s(.5),r=s(.5),i=e.y0-e.sankeyWidth/2,a=e.y1-e.sankeyWidth/2,l=e.y1+e.sankeyWidth/2,c=e.y0+e.sankeyWidth/2,`M${t},${i}C${o},${i} ${r},${a} ${n},${a}L${n},${l}C${r},${l} ${o},${c} ${t},${c}Z`)};function xr(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 kr={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(Uo))-1:0},justify:Ko},wr={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,p=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=vr().extent(v).links(m).nodes(y).nodeAlign(kr[h]||Ko).nodeId(e=>e.id).nodeWidth(g).iterations(p);b.nodePaddingRatio&&b.nodePaddingRatio(f),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 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 i,a,s,l;const c="vertical"===n.orientation?"down":"right",u=n.nodeStyle,d=n.edgeStyle,h=null!==(i=n.edgeOpacity)&&void 0!==i?i:.5,g=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:r.schemeCategory10,p=new Map;e.forEach((e,t)=>{p.set(e.id,f[t%f.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||p.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=p.get(n.id)||o:t&&(o=p.get(t.id)||o);const r=d?d(e):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,i=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+i},${t.sourceY-n}L${t.sourceX+i},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:c,fillOpacity:null!==(a=r.fillOpacity)&&void 0!==a?a:h,stroke:"none",opacity:r.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+i}}),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!==(s=r.fillOpacity)&&void 0!==s?s:h,stroke:"none",opacity:r.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-l,x1:t.targetX}});continue}let i;if(i=e.circular&&e.circularPathData?xr(e):br(e),!i)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:i,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}}},Ar={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){var r,i;if(0===e.length)return;const a=null!==(r=n.forceStrength)&&void 0!==r?r:.1,s=o[0]/2,l=o[1]/2,c=n.__previousPositions;let u=0;const h=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=null==c?void 0:c.get(t.id);e?u++:n?(t.x=n.x,t.y=n.y,u++):h.push(t)}const g=u>0&&.3>=(e.length>0?h.length/e.length:1);if(g){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of h){const o=Sr(e.id,t,n);if(o.length>0){let t=0,n=0;for(const e of o)t+=e.x,n+=e.y;const r=Er(e.id),i=r%360*(Math.PI/180),a=10+r%20;e.x=t/o.length+a*Math.cos(i),e.y=n/o.length+a*Math.sin(i)}else{const t=Er(e.id),n=t%360*(Math.PI/180),o=15+t%30;e.x=s+o*Math.cos(n),e.y=l+o*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const o=e[n];if(null==o.x||null==o.y||0===o.x&&0===o.y){const e=10*Math.sqrt(n+.5),r=n*t;o.x=s+e*Math.cos(r),o.y=l+e*Math.sin(r)}}}const f=null!==(i=n.iterations)&&void 0!==i?i:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),p=g?40:f,y=Or(n.nodeSize,n.nodeSizeRange,e),m=e=>y(e),v=d.forceLink().strength(e=>Math.min(2.5,e.weight?e.weight*a:a)).id(e=>e.id),b=d.forceSimulation().force("charge",d.forceManyBody().strength(e=>-25*m(e))).force("center",d.forceCenter(s,l).strength(.8)).force("x",d.forceX(s).strength(.15)).force("y",d.forceY(l).strength(.15));if(b.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}));b.force("link",v),b.force("link").links(e)}g?b.alpha(.3):.1>b.alpha()&&b.alpha(1),b.stop();for(let e=0;p>e;++e)b.tick();for(const t of e){if(null==t.x||null==t.y)continue;const e=m(t);t.x=Math.max(e,Math.min(o[0]-e,t.x)),t.y=Math.max(e,Math.min(o[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=x.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=x.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,o){var i,a,s;const l=n.nodeStyle,c=n.edgeStyle,u=Or(n.nodeSize,n.nodeSizeRange,e),d=Array.isArray(n.colorScheme)?n.colorScheme:r.schemeCategory10,h=new Map;e.forEach((e,t)=>{h.set(e.id,d[t%d.length])});const g=[],f=[],p=[];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!==(i=n.strokeWidth)&&void 0!==i?i: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!==(a=o.strokeWidth)&&void 0!==a?a:1,opacity:null!==(s=o.opacity)&&void 0!==s?s:.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);p.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:p}}};function Sr(e,t,n){const o=[];for(const r of t){const t="string"==typeof r.source?r.source:r.source.id,i="string"==typeof r.target?r.target:r.target.id;let a=null;if(t===e?a=i:i===e&&(a=t),a){const e=n.get(a);!e||0===e.x&&0===e.y||o.push({x:e.x,y:e.y})}}return o}function Er(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function Or(e,t,n){var r,i;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!==(r=a.min(l))&&void 0!==r?r:0,u=null!==(i=a.max(l))&&void 0!==i?i: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 Mr=r.schemeCategory10,Pr={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,c=s-i,u=o[0]/2,d=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 p=new Map;for(let t=0;e.length>t;t++)p.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=p.get("string"==typeof e.source?e.source:e.source.id),o=p.get(t);if(void 0===n||void 0===o)continue;const r=g(e);m[n][o]=r}const v=h.chord().padAngle(r);a&&v.sortGroups(a);const b=v(m),x=b.groups,k=l.arc().innerRadius(c).outerRadius(s);for(const t of x){const n=e[t.index],o=k.centroid(t);n.x=o[0]+u,n.y=o[1]+d,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,d=o[1]/2,g=n.nodeStyle,f=n.edgeStyle,p=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:Mr,m=new Map;e.forEach((e,t)=>{m.set(e.id,y[t%y.length])});const v=h.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)||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:u,cy:d,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=Cr(n,u,d);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"===p&&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:d+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 Cr(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(" ")}function Lr(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>150?"#222":"#fff"}const jr={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,o){var r;const i=n.__hierarchyRoot;if(!i)return;const a=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=s.hierarchy(i,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(a){case"tree":!function(e,t,n,o){const r=t.treeOrientation||"vertical",i=s.tree();i.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),i(e)}(d,n,h,g);break;case"cluster":!function(e,t,n,o){const r=t.treeOrientation||"vertical",i=s.cluster();i.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),i(e)}(d,n,h,g);break;case"treemap":!function(e,t,n,o){var r,i;const a=null!==(r=t.padding)&&void 0!==r?r:4,l=null!==(i=t.paddingTop)&&void 0!==i?i:0,c=s.treemap().size([n,o]).tile(s.treemapBinary).padding(a);l>0&&c.paddingTop(l),c(e)}(d,n,h,g);break;case"circlepack":!function(e,t,n,o){var r;const i=null!==(r=t.padding)&&void 0!==r?r:4;s.pack().size([n,o]).padding(i)(e)}(d,n,h,g);break;case"partition":!function(e,t,n,o){var r;s.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 p=new Map;for(let t=0;f.length>t;t++){const o=f[t],i={id:Hr(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"===a||"cluster"===a?Nr(i,o,n):"treemap"===a||"partition"===a?Dr(i,o):"circlepack"===a&&_r(i,o),i.__hierarchyNode=o,e.push(i),p.set(o,i)}if("tree"===a||"cluster"===a)for(const e of f)if(e.parent){const n=p.get(e.parent),o=p.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",p="radial"===f,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;p&&(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 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;p&&(o+=y,r+=m,a+=y,s+=m);const u=Br(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=Rr(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(p&&(a+=y,s+=m),p){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"===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=Rr(t.nodeLabel),r=t.labelMode||"leaf",a="partition"===t.chartType;for(const c of e){const e=c.x1-c.x0,u=c.y1-c.y0;if(0>=e||0>=u)continue;const d=!((null===(i=c.data)||void 0===i?void 0:i.children)&&c.data.children.length>0);if(!a){if("leaf"===r&&!d)continue;if("parent"===r&&d)continue}const h=n?n(c):c.id;if(!h)continue;if((d?30:40)>e||(d?16:14)>u)continue;let g=o(c).fill||"#4d430c";t.colorByDepth&&void 0!==c.depth&&(g=l[c.depth%l.length]);const f=Lr(g);s.push(d?{x:c.x0+e/2,y:c.y0+u/2,text:h+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,u)/6)),fill:f}:{x:c.x0+4,y:c.y0+12,text:h+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:f})}}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=Rr(t.nodeLabel);for(const r of e){const e=null!==(s=r.__radius)&&void 0!==s?s:5,i=n?n(r):r.id;if(!i)continue;if(15>e)continue;const a=!((null===(l=r.data)||void 0===l?void 0:l.children)&&r.data.children.length>0);let c=o(r).fill||"#4d430c";if(t.colorByDepth&&void 0!==r.depth&&(c=d[r.depth%d.length]),a){const t=Lr(c);u.push({x:r.x,y:r.y,text:i+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:t})}else u.push({x:r.x,y:r.y-e+14,text:i+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:"#000",stroke:"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(e,n,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Nr(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 Dr(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 _r(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 Br(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 Hr(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 Rr(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}function Tr(e){const t=e;return t.__orbitState||(t.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),t.__orbitState}const Wr={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,o){const r=n.__hierarchyRoot;r&&function(e,t,n,o,r){var i,a;const s=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),c=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>{var n;return(null!==(n=e[t])&&void 0!==n?n:"")+""}}(n.nodeIDAccessor),u=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),d=null!==(i=n.orbitSize)&&void 0!==i?i:2.95,h=null!==(a=n.orbitEccentricity)&&void 0!==a?a:1,g="number"==typeof d?()=>d:d,f="number"==typeof h?()=>h:h,p=Tr(n);p.metaMap.clear(),o.length=0,r.length=0;const y=new Map;function m(e){var t;const n=null!==(t=y.get(e))&&void 0!==t?t:0;return y.set(e,n+1),0===n?e:`${e}__${n}`}const v=t[0]/2,b=t[1]/2,x=Math.min(t[0],t[1])/2*.85,k=m(c(e));o.push({id:k,x:v,y:b,x0:v,x1:v,y0:b,y1:b,width:0,height:0,value:0,depth:0,data:e}),p.metaMap.set(k,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,i,a,d,h,y){const v=s(t);if(!(null==v?void 0:v.length))return;const b=v.length;let x=0,k=0,w=0;for(;b>k;)k+=u[Math.min(w,u.length-1)],w++,x++;let A=0;for(let b=0;x>b;b++){const k=u[Math.min(b,u.length-1)],w=v.slice(A,A+k);if(!w.length)break;const S=(b+1)/x,E={id:n,depth:h,data:t,parentId:n},O=y?d/g(E)*S:d*S,M=l.pie().value(e=>{var t;return(null===(t=s(e))||void 0===t?void 0:t.length)?4:1}).sort(null),P=M(w),C=f(E);for(let t=0;w.length>t;t++){const s=(P[t].startAngle+P[t].endAngle)/2,l=w[t],u=m(c(l)),d=i+O*Math.sin(s),g=a+O*Math.cos(s)*C;o.push({id:u,x:d,y:g,x0:d,x1:d,y0:g,y1:g,width:0,height:0,value:0,depth:h,data:l}),p.metaMap.set(u,{ring:O,angle:s,depth:h,parentId:n,eccentricity:C}),r.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(l,u,d,g,O,h+1,!0)}A+=k}}(e,k,v,b,x,1,!1)}(r,o,n,e,t)},buildScene(e,t,n,o){var r,i,a,s,l;const c=n.nodeStyle,u=n.nodeSize,d="number"==typeof u?()=>u:"function"==typeof u?u:()=>6,h=[],g=[],f=[];if(!1!==n.orbitShowRings){const t=Tr(n),o=new Map;for(const t of e)o.set(t.id,t);const r=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=o.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;r.has(n)||r.set(n,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:n,ecc:o}]of r)for(let r=0;i>r;r++){const s=r/i*Math.PI*2,l=(r+1)/i*Math.PI*2;g.push({type:"line",x1:e+n*Math.sin(s),y1:t+n*Math.cos(s)*o,x2:e+n*Math.sin(l),y2:t+n*Math.cos(l)*o,style:a,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=d(t),n=c?c(t):{},o={fill:n.fill||"#6366f1",stroke:n.stroke||"#fff",strokeWidth:null!==(r=n.strokeWidth)&&void 0!==r?r:1,opacity:null!==(i=n.opacity)&&void 0!==i?i:0===(null!==(a=t.depth)&&void 0!==a?a:0)?1:.85};h.push({type:"circle",cx:t.x,cy:t.y,r:e,style:o,datum:t,id:t.id,label:t.id,depth:t.depth})}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);t&&n&&(null!=t.x&&null!=n.x&&g.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=d(n);if(4>=e)continue;const o="function"==typeof t?t(n):t&&null!==(l=null===(s=n.data)||void 0===s?void 0:s[t])&&void 0!==l?l:n.id;f.push({x:n.x,y:n.y+e+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:h,sceneEdges:g,labels:f}},tick:(e,t,n,o,r)=>!1!==n.orbitAnimated&&(function(e,t){var n,o;const r=Tr(t),i=null!==(n=t.orbitSpeed)&&void 0!==n?n:.25,a=null!==(o=t.orbitRevolution)&&void 0!==o?o:function(e){switch(e){case"decay":return e=>{var t;return Math.pow(.6,null!==(t=e.depth)&&void 0!==t?t:0)};case"alternate":return e=>{var t;const n=null!==(t=e.depth)&&void 0!==t?t:0;return(n%2==0?1:-1)/(n+1)};default:return e=>{var t;return 1/((null!==(t=e.depth)&&void 0!==t?t:0)+1)}}}(t.orbitRevolutionStyle),s=(("undefined"!=typeof performance?performance.now():Date.now())-r.startTime)/1e3,l=i*(Math.PI/6),c=new Map;for(const t of e)c.set(t.id,t);for(const t of e){const e=r.metaMap.get(t.id);if(!e||!e.parentId)continue;const n=c.get(e.parentId);if(!n)continue;const o=e.angle+s*l*a({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=n.x+e.ring*Math.sin(o),t.y=n.y+e.ring*Math.cos(o)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)},Ir={sankey:wr,force:Ar,chord:Pr,tree:jr,cluster:jr,treemap:jr,circlepack:jr,partition:jr,orbit:Wr};function $r(e){return Ir[e]}class zr{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._decaySortedNodes=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._lastPositionSnapshot=null,this.config=e,this.tensionConfig=Object.assign(Object.assign({},Co),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new jo(2e3))}updateConfig(e){const t=this.config,n=e;t.__orbitState&&(n.__orbitState=t.__orbitState),t.__hierarchyRoot&&(n.__hierarchyRoot=t.__hierarchyRoot),this.config=e,this.tensionConfig=Object.assign(Object.assign({},Co),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&!this.particlePool&&(this.particlePool=new jo(2e3))}ingestHierarchy(e,t){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,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(),this._decaySortedNodes=null;for(const t of e){const e=s(t)+"";this.nodes.set(e,Object.assign(Object.assign({},Fr(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({},Fr(t)),{data:e})),this.nodes.has(n)||this.nodes.set(n,Object.assign(Object.assign({},Fr(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._decaySortedNodes=null,this.nodes.has(t)||(this.nodes.set(t,Fr(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,Fr(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){var t,n,o,r,i,a;const s=$r(this.config.chartType);if(!s)return;let l=Array.from(this.nodes.values()),c=Array.from(this.edges.values());if(0===l.length&&!s.hierarchical)return;if(this.prepareForRelayout(),s.supportsStreaming&&!s.hierarchical){const e=new Map;for(const s of l)if(void 0!==s._prevX0){const l=(null!==(t=s._prevX1)&&void 0!==t?t:0)-(null!==(n=s._prevX0)&&void 0!==n?n:0),c=(null!==(o=s._prevY1)&&void 0!==o?o:0)-(null!==(r=s._prevY0)&&void 0!==r?r:0);e.set(s.id,{x:(null!==(i=s._prevX0)&&void 0!==i?i:0)+l/2,y:(null!==(a=s._prevY0)&&void 0!==a?a:0)+c/2})}else 0===s.x&&0===s.y||e.set(s.id,{x:s.x,y:s.y});if(this._lastPositionSnapshot)for(const[t,n]of this._lastPositionSnapshot)e.has(t)||e.set(t,n);this.config.__previousPositions=e.size>0?e:void 0}if(s.computeLayout(l,c,this.config,e),delete this.config.__previousPositions,s.hierarchical&&l.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of l)this.nodes.set(e.id,e);for(const e of c)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();const u=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||u.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=u,this.saveTargetPositions(),l.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 d=new Set(this.nodes.keys()),h=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 d)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)d.has(e)||this.removedNodes.add(e);for(const e of h)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)h.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=d,this.previousEdgeKeys=h,this.layoutVersion++}buildScene(e){const t=$r(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}get isAnimating(){const e=$r(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=$r(this.config.chartType);if(!(null==n?void 0:n.tick))return!1;const o=Array.from(this.nodes.values()),r=Array.from(this.edges.values());return n.tick(o,r,this.config,e,t)}advanceTransition(e){if(!this.transition)return!1;const t=T(e,this.transition),n=R(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=W(e._prevX0,e._targetX0,n),e.x1=W(e._prevX1,e._targetX1,n),e.y0=W(e._prevY0,e._targetY0,n),e.y1=W(e._prevY1,e._targetY1,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=W(e._prevY0,e._targetY0,n),e.y1=W(e._prevY1,e._targetY1,n),e.sankeyWidth=W(e._prevSankeyWidth,e._targetSankeyWidth,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=u.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=u.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;this._decaySortedNodes||(this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]));const l=this._decaySortedNodes,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._decaySortedNodes=null,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function Fr(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 Gr(e,t,n,o,r=30){let i=null,a=r,s=1/0;for(const t of e){const e=Yr(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=Ur(e,n,o);t&&a>t.distance&&(i=t,a=t.distance)}return i}function Yr(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=z(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=F(Math.atan2(r,o)),s=F(e.startAngle),l=F(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 qr=null,Xr=null;function Vr(){return Xr||(qr=document.createElement("canvas"),qr.width=1,qr.height=1,Xr=qr.getContext("2d")),Xr}function Ur(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=Vr();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}}const s=a.lineWidth;a.lineWidth=10;const l=a.isPointInStroke(i,t,n);if(a.lineWidth=s,l)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}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=Vr();if(!r)return null;if(r.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=r.lineWidth;r.lineWidth=10;const a=r.isPointInStroke(o,t,n);if(r.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch(e){}return null}(e,t,n);default:return null}}function Kr(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,legendPosition:g="right",foregroundGraphics:f,sceneNodes:y,annotations:m,svgAnnotationRules:v}=e;return p.createElement(p.Fragment,null,p.createElement("svg",{role:"img",width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},p.createElement("title",null,"string"==typeof s?s:"Network Chart"),p.createElement("desc",null,"string"==typeof s?s+" — network data visualization":"Network data visualization"),p.createElement("g",{transform:`translate(${i.left},${i.top})`},a.map((e,t)=>p.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)),m&&m.filter(e=>"widget"!==e.type).map((e,o)=>{if(v){const r=v(e,o,{width:t,height:n,sceneNodes:y});if(r)return p.createElement(p.Fragment,{key:"annotation-"+o},r)}return null}),f),s&&"string"==typeof s?p.createElement("text",{x:o/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},s):s?p.createElement("foreignObject",{x:0,y:0,width:o,height:i.top},s):null,le({legend:l,totalWidth:o,totalHeight:r,margin:i,legendPosition:g,title:s,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h})),null==m?void 0:m.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),f=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:p.createElement("span",{style:{fontSize:18,cursor:"default"}},"ℹ️");return p.createElement("div",{key:"widget-"+t,style:{position:"absolute",left:g+m-b/2,top:f+v-x/2,width:b,height:x,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5}},k)}))}function Qr(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 Zr(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 Jr(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 ei(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()}Kr.displayName="NetworkSVGOverlay";const ti={top:20,right:80,bottom:20,left:80},ni={top:40,right:40,bottom:40,left:40},oi=new Set(["chord","force","circlepack","orbit"]),ri=[800,600],ii={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function ai({data:e}){var t,n,o,r,i,a;if("edge"===e.type){const t=e.data;return p.createElement("div",{className:"semiotic-tooltip",style:ii},p.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&&p.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 p.createElement("div",{className:"semiotic-tooltip",style:ii},p.createElement("div",null,e.map((e,t)=>p.createElement("span",{key:t},t>0&&p.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),t===a?p.createElement("strong",null,e):p.createElement("span",{style:{opacity:.7}},e)))),null!=s.value&&s.value>0&&p.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 p.createElement("div",{className:"semiotic-tooltip",style:ii},p.createElement("div",{style:{fontWeight:600}},s.id),null!=s.value&&s.value>0&&p.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof s.value?s.value.toLocaleString():s.value+""),c>0&&p.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",c,u!==c&&` (weighted: ${u.toLocaleString()})`))}const si=e.forwardRef(function(t,n){var o,r,i,a,s,c,u,d,h,g,f;const{chartType:y,nodes:m,edges:v,data:b,initialEdges:x,nodeIDAccessor:k="id",sourceAccessor:w="source",targetAccessor:A="target",valueAccessor:S="value",childrenAccessor:E,hierarchySum:O,orientation:M="horizontal",nodeAlign:P="justify",nodePaddingRatio:C=.05,nodeWidth:j=15,iterations:N=300,forceStrength:D=.1,padAngle:_=.01,groupWidth:B=20,sortGroups:H,edgeSort:R,treeOrientation:T="vertical",edgeType:W="curve",padding:I,paddingTop:$,tensionConfig:z,showParticles:F=!1,particleStyle:G,nodeStyle:Y,edgeStyle:q,colorBy:X,colorScheme:V="category10",edgeColorBy:U="source",edgeOpacity:K=.5,colorByDepth:Q=!1,nodeSize:J=8,nodeSizeRange:ne=[5,20],nodeLabel:oe,showLabels:re=!0,labelMode:ie,size:ae=ri,responsiveWidth:se,responsiveHeight:le,margin:ce,className:ue,background:de,enableHover:he=!0,tooltipContent:ge,customHoverBehavior:fe,customClickBehavior:pe,onObservation:ye,chartId:me,onTopologyChange:ve,annotations:be,svgAnnotationRules:xe,legend:ke,legendPosition:we,legendHoverBehavior:Ae,legendClickBehavior:Se,legendHighlightedCategory:Ee,legendIsolatedCategories:Me,title:Pe,foregroundGraphics:Le,backgroundGraphics:De,decay:_e,pulse:Be,staleness:He,thresholds:Re,accessibleTable:$e,orbitMode:ze,orbitSize:Fe,orbitSpeed:Ge,orbitRevolution:Xe,orbitRevolutionStyle:Ve,orbitEccentricity:Ue,orbitShowRings:Ke,orbitAnimated:Qe}=t,Ze=oi.has(y)?ni:ti,[Je,et]=ee(ae,se,le),tt=Object.assign(Object.assign({},Ze),ce),nt=et[0]-tt.left-tt.right,ot=et[1]-tt.top-tt.bottom,rt="function"==typeof Le?Le({size:et,margin:tt}):Le,it=e.useMemo(()=>Object.assign(Object.assign({},Co),z),[z]),at=e.useMemo(()=>Object.assign(Object.assign({},Lo),G),[G]),st=e.useMemo(()=>({chartType:y,nodeIDAccessor:k,sourceAccessor:w,targetAccessor:A,valueAccessor:S,childrenAccessor:E,hierarchySum:O,orientation:M,nodeAlign:P,nodePaddingRatio:C,nodeWidth:j,iterations:N,forceStrength:D,padAngle:_,groupWidth:B,sortGroups:H,edgeSort:R,treeOrientation:T,edgeType:W,padding:I,paddingTop:$,tensionConfig:it,showParticles:F,particleStyle:at,nodeStyle:Y,edgeStyle:q,nodeLabel:oe,showLabels:re,labelMode:ie,colorBy:X,colorScheme:V,edgeColorBy:U,edgeOpacity:K,colorByDepth:Q,nodeSize:J,nodeSizeRange:ne,decay:_e,pulse:Be,staleness:He,thresholds:Re,orbitMode:ze,orbitSize:Fe,orbitSpeed:Ge,orbitRevolution:Xe,orbitRevolutionStyle:Ve,orbitEccentricity:Ue,orbitShowRings:Ke,orbitAnimated:Qe}),[y,k,w,A,S,E,O,M,P,C,j,N,D,_,B,H,R,T,W,I,$,it,F,at,Y,q,oe,re,ie,X,V,U,K,Q,J,ne,_e,Be,He,Re,ze,Fe,Ge,Xe,Ve,Ue,Ke,Qe]),lt=e.useRef(null),ct=e.useRef(0),ut=e.useRef(0),dt=e.useRef(!0),ht=Te(e=>e.theme),gt=e.useRef(()=>{}),ft=e.useRef(null);ft.current||(ft.current=new zr(st));const[pt,yt]=e.useState(null),[mt,vt]=e.useState(0),[bt,xt]=e.useState(0),[kt,wt]=e.useState(!1),At=e.useRef(null),St=e.useRef(new Map),Et=e.useRef(0),Ot=e.useCallback(e=>{if("function"==typeof X)return X(e)+"";if("string"==typeof X&&e.data){const t=e.data[X];if(void 0!==t){if(!St.current.has(t+"")){const e=Array.isArray(V)?V:L;St.current.set(t+"",e[Et.current++%e.length])}return St.current.get(t+"")}}if(!St.current.has(e.id)){const t=Array.isArray(V)?V:L;St.current.set(e.id,t[Et.current++%t.length])}return St.current.get(e.id)},[X,V]),Mt=e.useCallback(e=>{if("function"==typeof U)return U(e);const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;return"target"===U&&n?Ot(n):t?Ot(t):"#999"},[U,Ot]),Pt=e.useCallback(e=>{if(!(null==G?void 0:G.colorBy))return Mt(e);const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;return"target"===at.colorBy&&n?Ot(n):t?Ot(t):"#999"},[null==G?void 0:G.colorBy,at.colorBy,Ot,Mt]),Ct="sankey"===y&&F||!!Be||null!==(r=null===(o=ft.current)||void 0===o?void 0:o.isAnimating)&&void 0!==r&&r,Lt=e.useCallback(()=>{ct.current&&!Ct||ct.current||(ct.current=requestAnimationFrame(()=>gt.current()))},[Ct]);e.useEffect(()=>{var e;null===(e=ft.current)||void 0===e||e.updateConfig(st),dt.current=!0,Lt()},[st,Lt]),e.useEffect(()=>{dt.current=!0,Lt()},[ht,Lt]);const jt=e.useCallback(()=>{const e=ft.current;if(!e)return;e.runLayout([nt,ot]),e.buildScene([nt,ot]),dt.current=!0;const t=Array.isArray(V)?V:L,n=Array.from(e.nodes.values());for(let e=0;n.length>e;e++){const o=n[e];St.current.has(o.id)||St.current.set(o.id,t[e%t.length])}if(Et.current=n.length,vt(e.layoutVersion),ve){const{nodes:t,edges:n}=e.getLayoutData();ve(t,n)}},[nt,ot,ve,V]),Nt=e.useCallback(e=>{const t=ft.current;t&&(t.ingestEdge(e)&&jt(),Lt())},[jt,Lt]),Dt=e.useCallback(e=>{const t=ft.current;if(!t)return;let n=!1;for(const o of e)t.ingestEdge(o)&&(n=!0);n&&jt(),Lt()},[jt,Lt]),_t=e.useCallback(()=>{var e;null===(e=ft.current)||void 0===e||e.clear(),St.current.clear(),Et.current=0,vt(0),yt(null),At.current=null,dt.current=!0,Lt()},[Lt]),Bt=e.useCallback(()=>{const e=ft.current;e&&(e.tension+=999,jt(),Lt())},[jt,Lt]);e.useImperativeHandle(n,()=>({push:Nt,pushMany:Dt,clear:_t,getTopology:()=>{var e,t;return null!==(t=null===(e=ft.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=ft.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:Bt,getTension:()=>{var e,t;return null!==(t=null===(e=ft.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[Nt,Dt,_t,Bt]);const Ht=["tree","cluster","treemap","circlepack","partition","orbit"].includes(y),Rt=Ht?b||(Array.isArray(v)?void 0:v):void 0;e.useEffect(()=>{const e=ft.current;if(e)if(Ht&&Rt)e.ingestHierarchy(Rt,[nt,ot]),e.buildScene([nt,ot]),dt.current=!0,Lt();else{const t=m||[],n=Array.isArray(v)?v:[];if(0===t.length&&0===n.length)return;e.ingestBounded(t,n,[nt,ot]),e.buildScene([nt,ot]);const o=Array.isArray(V)?V:L,r=Array.from(e.nodes.values());for(let e=0;r.length>e;e++){const t=r[e];St.current.has(t.id)||St.current.set(t.id,o[e%o.length])}Et.current=r.length,dt.current=!0,Lt()}},[m,v,b,Rt,Ht,nt,ot,st,Lt,V]),e.useEffect(()=>{x&&x.length>0&&Dt(x)},[]);const Tt=e.useCallback(e=>{if(fe&&fe(e),ye){const t=Date.now();ye(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:me}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:me})}},[fe,ye,me]),Wt=e.useCallback(e=>{if(pe&&pe(e),ye){const t=Date.now();ye(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:me}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:me})}},[pe,ye,me]),It=e.useRef(()=>{}),$t=e.useRef(()=>{});It.current=e=>{if(!he)return;const t=lt.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-tt.left,r=e.clientY-n.top-tt.top;if(0>o||o>nt||0>r||r>ot)return void(At.current&&(At.current=null,yt(null),Tt&&(Tt(null),dt.current=!0),Lt()));const i=ft.current;if(!i)return;const a=Gr(i.sceneNodes,i.sceneEdges,o,r);if(!a)return void(At.current&&(At.current=null,yt(null),Tt&&(Tt(null),dt.current=!0),Lt()));const s=a.datum||{},l=Object.assign(Object.assign({},"object"!=typeof s||null===s||Array.isArray(s)?{}:s),{type:a.type,data:s,x:a.x,y:a.y});At.current=l,yt(l),Tt&&(Tt(l),dt.current=!0),Lt()},$t.current=()=>{At.current&&(At.current=null,yt(null),Tt&&(Tt(null),dt.current=!0),Lt())};const zt=e.useRef(()=>{});zt.current=e=>{if(!pe&&!ye)return;const t=lt.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-tt.left,r=e.clientY-n.top-tt.top;if(0>o||o>nt||0>r||r>ot)return;const i=ft.current;if(!i)return;const a=Gr(i.sceneNodes,i.sceneEdges,o,r);if(a){const e=a.datum||{};Wt(Object.assign(Object.assign({},"object"!=typeof e||null===e||Array.isArray(e)?{}:e),{type:a.type,data:e,x:a.x,y:a.y}))}else Wt(null)},e.useCallback(e=>It.current(e),[]);const Ft=e.useCallback(()=>$t.current(),[]),Gt=e.useCallback(e=>zt.current(e),[]),Yt=e.useRef(-1),qt=e.useCallback(e=>{const t=ft.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=Yt.current,r=Z(e.key,0>o?-1:o,n.length);if(null===r)return;if(e.preventDefault(),0>r)return Yt.current=-1,At.current=null,yt(null),Tt&&(Tt(null),dt.current=!0),void Lt();const i=0>o?0:r;Yt.current=i;const a=n[i],s=a.datum||{},l=Object.assign(Object.assign({},"object"!=typeof s||null===s||Array.isArray(s)?{}:s),{type:"node",data:s,x:a.x,y:a.y});At.current=l,yt(l),Tt&&(Tt(l),dt.current=!0),Lt()},[Tt,Lt]),Xt=e.useCallback(e=>{Yt.current=-1,It.current(e)},[]);gt.current=()=>{var e,t,n,o,r,i,a;ct.current=0;const s=lt.current;if(!s)return;const l=s.getContext("2d");if(!l)return;const c=ft.current;if(!c)return;const u=performance.now(),d=ut.current?Math.min((u-ut.current)/1e3,.1):.016;ut.current=u;const h=c.advanceTransition(u),g=c.tickAnimation([nt,ot],d);(h||dt.current||g)&&c.buildScene([nt,ot]);const f=Ie();if(!We(s,et,tt,f))return;l.clearRect(-tt.left,-tt.top,et[0],et[1]),de&&(l.fillStyle=de,l.fillRect(0,0,nt,ot)),_e&&c.applyDecay(),Be&&c.applyPulse(u),Re&&c.applyThresholds(u),c.applyTopologyDiff(u);const p=null!==(e=null==He?void 0:He.threshold)&&void 0!==e?e:5e3,y=He&&c.lastIngestTime>0&&u-c.lastIngestTime>p;if(y&&(l.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":Qr(e,n);break;case"line":Zr(e,n);break;case"ribbon":Jr(e,n);break;case"curved":ei(e,n)}}(l,c.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)),Ye(e,t),e.restore())}}(l,c.sceneNodes),function(e,t){var n,o,r;for(const i of t){if("circle"!==i.type)continue;const t=i;t.r>0&&(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()),qe(e,t),e.restore())}}(l,c.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()}}(l,c.sceneNodes),F&&c.particlePool&&!y){const e=Array.from(c.edges.values());if(e.length>0){!function(e,t,n,o){var r,i;const a=null!==(r=o.spawnRate)&&void 0!==r?r:Lo.spawnRate,s=null!==(i=o.maxPerEdge)&&void 0!==i?i:Lo.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)}}(c.particlePool,e,d,at);const t=.5*(null!==(n=at.speedMultiplier)&&void 0!==n?n:1);let o;if(at.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)}c.particlePool.step(d,t,e,o),function(e,t,n,o,r){var i,a;const s=null!==(i=o.radius)&&void 0!==i?i:Lo.radius,l=null!==(a=o.opacity)&&void 0!==a?a:Lo.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}(l,c.particlePool,e,at,Pt)}}y&&(l.globalAlpha=1);const m=dt.current;if(dt.current=!1,m||h||g){const e=lt.current;e&&e.setAttribute("aria-label",Ce(null!==(r=null===(o=c.sceneNodes)||void 0===o?void 0:o.length)&&void 0!==r?r:0,null!==(a=null===(i=c.sceneEdges)||void 0===i?void 0:i.length)&&void 0!==a?a:0,"Network chart"))}(m||h||g)&&xt(e=>e+1),(Ct||h||g||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff)&&(ct.current=requestAnimationFrame(()=>gt.current()))},e.useEffect(()=>(Lt(),()=>{ct.current&&(cancelAnimationFrame(ct.current),ct.current=0)}),[Lt]),e.useEffect(()=>{dt.current=!0,Lt()},[y,nt,ot,de,Lt]),te(He,ft,dt,Lt,kt,wt);const Vt=he&&pt?p.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:tt.left+pt.x,top:tt.top+pt.y,transform:`translate(${pt.x>.6*nt?"calc(-100% - 12px)":"12px"}, ${.3*ot>pt.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2,width:"max-content"}},ge?ge(pt):p.createElement(ai,{data:pt})):null;if(Oe){const e=ft.current;if(e){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(y),n=t?b||(Array.isArray(v)?void 0:v):void 0;if(t&&n)e.ingestHierarchy(n,[nt,ot]),e.buildScene([nt,ot]);else{const t=m||[],n=Array.isArray(v)?v:[];(t.length>0||n.length>0)&&(e.ingestBounded(t,n,[nt,ot]),e.buildScene([nt,ot]))}}const t=null!==(i=null==e?void 0:e.sceneNodes)&&void 0!==i?i:[],n=null!==(a=null==e?void 0:e.sceneEdges)&&void 0!==a?a:[],o=null!==(s=null==e?void 0:e.labels)&&void 0!==s?s:[];return p.createElement("div",{className:"stream-network-frame"+(ue?" "+ue:""),role:"img","aria-label":"string"==typeof Pe?Pe:"Network chart",style:{position:"relative",width:et[0],height:et[1]}},p.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:et[0],height:et[1],style:{position:"absolute",left:0,top:0}},De&&p.createElement("g",{transform:`translate(${tt.left},${tt.top})`},De),p.createElement("g",{transform:`translate(${tt.left},${tt.top})`},de&&p.createElement("rect",{x:0,y:0,width:nt,height:ot,fill:de}),n.map((e,t)=>function(e,t){switch(e.type){case"line":return p.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 p.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 p.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 p.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 p.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=l.arc().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle).endAngle(n.endAngle)({})||"";return p.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),o.map((e,t)=>function(e,t){return p.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))),p.createElement(Kr,{width:nt,height:ot,totalWidth:et[0],totalHeight:et[1],margin:tt,labels:o,sceneNodes:t,title:Pe,legend:ke,legendPosition:we,legendHoverBehavior:Ae,legendClickBehavior:Se,legendHighlightedCategory:Ee,legendIsolatedCategories:Me,foregroundGraphics:rt,annotations:be,svgAnnotationRules:xe,annotationFrame:0}))}const Ut=ft.current;return p.createElement("div",{ref:Je,className:"stream-network-frame"+(ue?" "+ue:""),role:"img","aria-label":"string"==typeof Pe?Pe:"Network chart",tabIndex:0,style:{position:"relative",width:se?"100%":et[0],height:le?"100%":et[1],overflow:"visible"},onMouseMove:he?Xt:void 0,onMouseLeave:he?Ft:void 0,onClick:pe||ye?Gt:void 0,onKeyDown:qt},De&&p.createElement("svg",{style:{position:"absolute",top:0,left:0,width:et[0],height:et[1],pointerEvents:"none"}},p.createElement("g",{transform:`translate(${tt.left},${tt.top})`},De)),p.createElement("canvas",{ref:lt,"aria-label":Ce(null!==(u=null===(c=null==Ut?void 0:Ut.sceneNodes)||void 0===c?void 0:c.length)&&void 0!==u?u:0,null!==(h=null===(d=null==Ut?void 0:Ut.sceneEdges)||void 0===d?void 0:d.length)&&void 0!==h?h:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),p.createElement(Ne,{hoverPoint:pt}),$e&&p.createElement(je,{nodes:null!==(g=null==Ut?void 0:Ut.sceneNodes)&&void 0!==g?g:[],edges:null!==(f=null==Ut?void 0:Ut.sceneEdges)&&void 0!==f?f:[],chartType:"Network chart"}),p.createElement(Kr,{width:nt,height:ot,totalWidth:et[0],totalHeight:et[1],margin:tt,labels:(null==Ut?void 0:Ut.labels)||[],sceneNodes:null==Ut?void 0:Ut.sceneNodes,title:Pe,legend:ke,legendPosition:we,legendHoverBehavior:Ae,legendClickBehavior:Se,legendHighlightedCategory:Ee,legendIsolatedCategories:Me,foregroundGraphics:rt,annotations:be,svgAnnotationRules:xe,annotationFrame:bt}),Vt,(null==He?void 0:He.showBadge)&&p.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:kt?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},kt?"STALE":"LIVE"))});si.displayName="StreamNetworkFrame";const li=e.forwardRef(function(t,n){var o;const r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,n,o;return null!==(o=null===(n=null===(t=null===(e=r.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.nodes)||void 0===n?void 0:n.map(e=>e.data))&&void 0!==o?o:[]}}));const i=Wt(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:a,edges:s,margin:l,className:c,nodeIDAccessor:u="id",sourceAccessor:d="source",targetAccessor:h="target",nodeLabel:g,colorBy:f,colorScheme:y="category10",nodeSize:m=8,nodeSizeRange:v=[5,20],edgeWidth:b=1,edgeColor:x="#999",edgeOpacity:k=.6,iterations:w=300,forceStrength:A=.1,tooltip:S,frameProps:E={},onObservation:O,chartId:M,selection:P,linkedHover:C,loading:L,emptyContent:j,legendInteraction:N,legendPosition:D}=t,B=i.width,H=i.height,R=i.enableHover,T=i.showLegend,W=null!==(o=i.showLabels)&&void 0!==o&&o,I=i.title,$=On(L,B,H);if($)return $;const z=En(a,B,H,j);if(z)return z;const F=a||[],G=s||[],Y=Dt(F,f,y),q=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of F){const n="function"==typeof f?f(t):t[f];null!=n&&e.add(n+"")}return Array.from(e)},[F,f]),X=Rt(N,f,q),V=e.useMemo(()=>e=>{const t={};return t.fill=f?_(e.data||e,f,Y):jt,"number"==typeof m&&(t.r=m),t},[f,Y,m]),U=e.useMemo(()=>e=>({stroke:x,strokeWidth:"number"==typeof b?b:"function"==typeof b?b(e):e[b]||1,opacity:k}),[b,x,k]),K=e.useMemo(()=>{if(W&&g)return"function"==typeof g?g:e=>{var t,n,o;return null!==(o=null!==(n=null===(t=e.data)||void 0===t?void 0:t[g])&&void 0!==n?n:e[g])&&void 0!==o?o:e.id}},[W,g]),{legend:Q,margin:Z,legendPosition:J}=Ht({data:F,colorBy:f,colorScale:Y,showLegend:T,legendPosition:D,userMargin:l,defaults:i.marginDefaults}),{customHoverBehavior:ee}=Bt({selection:P,linkedHover:C,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:O,chartType:"ForceDirectedGraph",chartId:M}),te=rn({componentName:"ForceDirectedGraph",nodes:a,edges:s,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:u}});return te?p.createElement(Kt,{componentName:"ForceDirectedGraph",message:te,width:B,height:H}):p.createElement(wn,{componentName:"ForceDirectedGraph",width:B,height:H},p.createElement(si,Object.assign({ref:r,chartType:"force"},null!=a&&{nodes:F},null!=s&&{edges:G},{size:[B,H],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Z,nodeIDAccessor:u,sourceAccessor:d,targetAccessor:h,iterations:w,forceStrength:A,nodeStyle:V,edgeStyle:U,colorBy:f,colorScheme:y,nodeSize:m,nodeSizeRange:v,nodeLabel:K,showLabels:W,enableHover:R,tooltipContent:!1===S?()=>null:Gt(S)||void 0,customHoverBehavior:C||O?ee:void 0,legend:Q,legendPosition:J},N&&"none"!==N&&{legendHoverBehavior:X.onLegendHover,legendClickBehavior:X.onLegendClick,legendHighlightedCategory:X.highlightedCategory,legendIsolatedCategories:X.isolatedCategories},{className:c,title:I},E)))});function ci(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 ui(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 di(e){return"function"==typeof e?e:t=>t[e]||1}function hi({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=_(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=_(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}}li.displayName="ForceDirectedGraph";const gi=e.forwardRef(function(t,n){var o;const r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,n,o;return null!==(o=null===(n=null===(t=null===(e=r.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===n?void 0:n.map(e=>e.data))&&void 0!==o?o:[]}}));const i=Wt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:a,edges:s,margin:l,className:c,sourceAccessor:u="source",targetAccessor:d="target",valueAccessor:h="value",nodeIdAccessor:g="id",colorBy:f,colorScheme:y="category10",edgeColorBy:m="source",padAngle:v=.01,groupWidth:b=20,sortGroups:x,nodeLabel:k,edgeOpacity:w=.5,tooltip:A,frameProps:S={},onObservation:E,chartId:O,selection:M,linkedHover:P,loading:j,emptyContent:N,legendInteraction:D}=t,B=i.width,H=i.height,R=i.enableHover,T=null===(o=i.showLabels)||void 0===o||o,W=i.title,I=On(j,B,H);if(I)return I;const $=En(s,B,H,N);if($)return $;const z=s||[],F=e.useMemo(()=>ui(a,z,u,d),[a,z,u,d]),G=Dt(F,f,y),Y=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of F){const n="function"==typeof f?f(t):t[f];null!=n&&e.add(n+"")}return Array.from(e)},[F,f]),q=Rt(D,f,Y),X=F.length>0,V=e.useMemo(()=>{if(X)return(e,t)=>{var n,o;const r={stroke:"black",strokeWidth:1};if(f)r.fill=_(e.data||e,f,G);else{const i=Array.isArray(y)?y:C[y]||L,a=Array.isArray(i)?i:L,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}},[X,f,G,y]),U=e.useMemo(()=>{if(X)return hi({edgeColorBy:m,colorBy:f,colorScale:G,nodeStyleFn:V||(e=>({fill:jt})),edgeOpacity:w,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:w}})},[X,m,f,G,V,w]),K=e.useMemo(()=>{if(!T)return;const e=k||g;return"function"==typeof e?e:t=>{var n,o,r;return null!==(r=null!==(o=null===(n=t.data)||void 0===n?void 0:n[e])&&void 0!==o?o:t[e])&&void 0!==r?r:t.id}},[T,k,g]),Q=Object.assign(Object.assign({},i.marginDefaults),l),{customHoverBehavior:Z}=Bt({selection:M,linkedHover:P,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:E,chartType:"ChordDiagram",chartId:O}),J=rn({componentName:"ChordDiagram",edges:s,edgesRequired:!0});return J?p.createElement(Kt,{componentName:"ChordDiagram",message:J,width:B,height:H}):p.createElement(wn,{componentName:"ChordDiagram",width:B,height:H},p.createElement(si,Object.assign({ref:r,chartType:"chord"},F.length>0&&{nodes:F},null!=s&&{edges:z},{size:[B,H],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Q,nodeIDAccessor:g,sourceAccessor:u,targetAccessor:d,valueAccessor:h,padAngle:v,groupWidth:b,sortGroups:x,nodeStyle:V,edgeStyle:U,colorBy:f,colorScheme:y,edgeColorBy:m,edgeOpacity:w,nodeLabel:K,showLabels:T,enableHover:R,tooltipContent:!1===A?()=>null:Gt(A)||void 0,customHoverBehavior:P||E?Z:void 0},D&&"none"!==D&&{legendHoverBehavior:q.onLegendHover,legendClickBehavior:q.onLegendClick,legendHighlightedCategory:q.highlightedCategory,legendIsolatedCategories:q.isolatedCategories},{className:c,title:W},S)))});gi.displayName="ChordDiagram";const fi=e.forwardRef(function(t,n){var o;const r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,n,o;return null!==(o=null===(n=null===(t=null===(e=r.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===n?void 0:n.map(e=>e.data))&&void 0!==o?o:[]}}));const i=Wt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:800,height:600}),{nodes:a,edges:s,margin:l,className:c,sourceAccessor:u="source",targetAccessor:d="target",valueAccessor:h="value",nodeIdAccessor:g="id",colorBy:f,colorScheme:y="category10",edgeColorBy:m="source",orientation:v="horizontal",nodeAlign:b="justify",nodePaddingRatio:x=.05,nodeWidth:k=15,nodeLabel:w,edgeOpacity:A=.5,edgeSort:S,tooltip:E,frameProps:O={},onObservation:M,chartId:P,selection:C,linkedHover:L,loading:j,emptyContent:N,legendInteraction:D}=t,B=i.width,H=i.height,R=i.enableHover,T=null===(o=i.showLabels)||void 0===o||o,W=i.title,I=On(j,B,H);if(I)return I;const $=En(s,B,H,N);if($)return $;const z=s||[],F=e.useMemo(()=>ui(a,z,u,d),[a,z,u,d]),G=Dt(F,f,y),Y=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of F){const n="function"==typeof f?f(t):t[f];null!=n&&e.add(n+"")}return Array.from(e)},[F,f]),q=Rt(D,f,Y),X=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?_(e.data||e,f,G):"#4d430c",t},[f,G]),V=e.useMemo(()=>hi({edgeColorBy:m,colorBy:f,colorScale:G,nodeStyleFn:X,edgeOpacity:A,baseStyle:{stroke:"none",strokeWidth:0}}),[m,f,G,X,A]),U=e.useMemo(()=>{if(!T)return;const e=w||g;return"function"==typeof e?e:t=>{var n,o,r;return null!==(r=null!==(o=null===(n=t.data)||void 0===n?void 0:n[e])&&void 0!==o?o:t[e])&&void 0!==r?r:t.id}},[T,w,g]),K=Object.assign(Object.assign({},i.marginDefaults),l),{customHoverBehavior:Q,customClickBehavior:Z}=Bt({selection:C,linkedHover:L,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:M,chartType:"SankeyDiagram",chartId:P}),J=rn({componentName:"SankeyDiagram",edges:s,edgesRequired:!0});return J?p.createElement(Kt,{componentName:"SankeyDiagram",message:J,width:B,height:H}):p.createElement(wn,{componentName:"SankeyDiagram",width:B,height:H},p.createElement(si,Object.assign({ref:r,chartType:"sankey"},F.length>0&&{nodes:F},null!=s&&{edges:z},{size:[B,H],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:K,nodeIDAccessor:g,sourceAccessor:u,targetAccessor:d,valueAccessor:h,orientation:v,nodeAlign:b,nodePaddingRatio:x,nodeWidth:k,nodeStyle:X,edgeStyle:V,colorBy:f,colorScheme:y,edgeColorBy:m,edgeOpacity:A,edgeSort:S,nodeLabel:U,showLabels:T,enableHover:R,tooltipContent:!1===E?()=>null:Gt(E)||void 0,customHoverBehavior:L||M?Q:void 0,customClickBehavior:M?Z:void 0},D&&"none"!==D&&{legendHoverBehavior:q.onLegendHover,legendClickBehavior:q.onLegendClick,legendHighlightedCategory:q.highlightedCategory,legendIsolatedCategories:q.isolatedCategories},{className:c,title:W},O)))});function pi(t){var n;const o=Wt(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:f=!1,edgeStyle:y="curve",nodeLabel:m,nodeSize:v=5,tooltip:b,frameProps:x={},onObservation:k,chartId:w,selection:A,linkedHover:S,loading:E,legendInteraction:O}=t,M=o.width,P=o.height,C=o.enableHover,L=null===(n=o.showLabels)||void 0===n||n,j=o.title,D=On(E,M,P);if(D)return D;const B=e.useMemo(()=>ci(null!=r?r:null,c),[r,c]),H=Dt(B,f?void 0:h,g),R=e.useMemo(()=>{if(!h||f)return[];const e=new Set;for(const t of B){const n="function"==typeof h?h(t):t[h];null!=n&&e.add(n+"")}return Array.from(e)},[B,h,f]),T=Rt(O,f?void 0:h,R),W=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?N[(e.depth||0)%N.length]:h?_(e.data||e,h,H):jt,t},[h,f,H]),I=e.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),$=e.useMemo(()=>{if("treemap"===s||"circlepack"===s||"partition"===s)return di(u)},[s,u]),z=Object.assign(Object.assign({},o.marginDefaults),i),{customHoverBehavior:F}=Bt({selection:A,linkedHover:S,fallbackFields:h?["string"==typeof h?h:""]:[],unwrapData:!0,onObservation:k,chartType:"TreeDiagram",chartId:w}),G=on({componentName:"TreeDiagram",data:r});return G?p.createElement(Kt,{componentName:"TreeDiagram",message:G,width:M,height:P}):p.createElement(wn,{componentName:"TreeDiagram",width:M,height:P},p.createElement(si,Object.assign({chartType:s},null!=r&&{data:r},{size:[M,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:z,nodeIDAccessor:d,childrenAccessor:c,hierarchySum:$,treeOrientation:l,edgeType:y,nodeStyle:W,edgeStyle:I,colorBy:h,colorScheme:g,colorByDepth:f,nodeSize:v,nodeLabel:L?m||d:void 0,showLabels:L,enableHover:C,tooltipContent:!1===b?()=>null:Gt(b)||void 0,customHoverBehavior:S||k?F:void 0},O&&"none"!==O&&{legendHoverBehavior:T.onLegendHover,legendClickBehavior:T.onLegendClick,legendHighlightedCategory:T.highlightedCategory,legendIsolatedCategories:T.isolatedCategories},{className:a,title:j},x)))}function yi(t){var n;const o=Wt(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:f,padding:y=4,paddingTop:m,tooltip:v,frameProps:b={},selection:x,linkedHover:k,onObservation:w,chartId:A,loading:S,legendInteraction:E}=t,O=o.width,M=o.height,P=o.enableHover,C=null===(n=o.showLabels)||void 0===n||n,L=o.title,j=On(S,O,M);if(j)return j;const{activeSelectionHook:D,customHoverBehavior:B}=Bt({selection:x,linkedHover:k,fallbackFields:u?["string"==typeof u?u:""]:[],onObservation:w,chartType:"Treemap",chartId:A}),H=e.useCallback(e=>{if(!e)return B(null);const t=e.data||e;B({data:(null==t?void 0:t.data)||t})},[B]),R=e.useMemo(()=>ci(null!=r?r:null,s),[r,s]),T=Dt(R,h?void 0:u,d),W=e.useMemo(()=>{if(!u||h)return[];const e=new Set;for(const t of R){const n="function"==typeof u?u(t):t[u];null!=n&&e.add(n+"")}return Array.from(e)},[R,u,h]),I=Rt(E,h?void 0:u,W),$=e.useMemo(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=h?N[(e.depth||0)%N.length]:u?_(e.data||e,u,T):jt,t},[u,h,T]),z=e.useMemo(()=>D?e=>{var t;const n=Object.assign({},$(e));if(D.isActive)if(D.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,x]),F=e.useMemo(()=>di(l),[l]),G=void 0!==m?m:C&&"parent"===g?18:void 0,Y=Object.assign(Object.assign({},o.marginDefaults),i),q=on({componentName:"Treemap",data:r});return q?p.createElement(Kt,{componentName:"Treemap",message:q,width:O,height:M}):p.createElement(wn,{componentName:"Treemap",width:O,height:M},p.createElement(si,Object.assign({chartType:"treemap"},null!=r&&{data:r},{size:[O,M],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Y,nodeIDAccessor:c,childrenAccessor:s,hierarchySum:F,padding:y,paddingTop:G,nodeStyle:z,colorBy:u,colorScheme:d,colorByDepth:h,nodeLabel:C?f||c:void 0,showLabels:C,labelMode:g,enableHover:P,tooltipContent:!1===v?()=>null:Gt(v)||void 0},(k||w)&&{customHoverBehavior:H},E&&"none"!==E&&{legendHoverBehavior:I.onLegendHover,legendClickBehavior:I.onLegendClick,legendHighlightedCategory:I.highlightedCategory,legendIsolatedCategories:I.isolatedCategories},{className:a,title:L},b)))}function mi(t){var n;const o=Wt(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:f=.7,padding:y=4,tooltip:m,frameProps:v={},onObservation:b,chartId:x,selection:k,linkedHover:w,loading:A,legendInteraction:S}=t,E=o.width,O=o.height,M=o.enableHover,P=null===(n=o.showLabels)||void 0===n||n,C=o.title,L=On(A,E,O);if(L)return L;const j=e.useMemo(()=>ci(null!=r?r:null,s),[r,s]),D=Dt(j,h?void 0:u,d),B=e.useMemo(()=>{if(!u||h)return[];const e=new Set;for(const t of j){const n="function"==typeof u?u(t):t[u];null!=n&&e.add(n+"")}return Array.from(e)},[j,u,h]),H=Rt(S,h?void 0:u,B),R=e.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:f};return t.fill=h?N[(e.depth||0)%N.length]:u?_(e.data||e,u,D):jt,t},[u,h,D,f]),T=e.useMemo(()=>di(l),[l]),W=Object.assign(Object.assign({},o.marginDefaults),i),{customHoverBehavior:I}=Bt({selection:k,linkedHover:w,fallbackFields:u?["string"==typeof u?u:""]:[],unwrapData:!0,onObservation:b,chartType:"CirclePack",chartId:x}),$=on({componentName:"CirclePack",data:r});return $?p.createElement(Kt,{componentName:"CirclePack",message:$,width:E,height:O}):p.createElement(wn,{componentName:"CirclePack",width:E,height:O},p.createElement(si,Object.assign({chartType:"circlepack"},null!=r&&{data:r},{size:[E,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:W,nodeIDAccessor:c,childrenAccessor:s,hierarchySum:T,padding:y,nodeStyle:R,colorBy:u,colorScheme:d,colorByDepth:h,nodeLabel:P?g||c:void 0,showLabels:P,enableHover:M,tooltipContent:!1===m?()=>null:Gt(m)||void 0,customHoverBehavior:w||b?I:void 0},S&&"none"!==S&&{legendHoverBehavior:H.onLegendHover,legendClickBehavior:H.onLegendClick,legendHighlightedCategory:H.highlightedCategory,legendIsolatedCategories:H.isolatedCategories},{className:a,title:C},v)))}fi.displayName="SankeyDiagram",pi.displayName="TreeDiagram",yi.displayName="Treemap",mi.displayName="CirclePack";const vi=N;function bi(t){const n=Wt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:o,margin:r,className:i,childrenAccessor:a="children",nodeIdAccessor:s="name",colorBy:l,colorScheme:c="category10",colorByDepth:u=!1,orbitMode:d="flat",orbitSize:h=2.95,speed:g=.25,revolution:f,revolutionStyle:y,eccentricity:m=1,showRings:v=!0,nodeRadius:b=6,showLabels:x=!1,animated:k=!0,tooltip:w,foregroundGraphics:A,annotations:S,frameProps:E={},onObservation:O,chartId:M,selection:P,linkedHover:j,loading:N}=t,D=n.width,B=n.height,H=n.enableHover,R=n.title,T=On(N,D,B);if(T)return T;const W=Dt(e.useMemo(()=>ci(o,a),[o,a]),u?void 0:l,c),I=e.useMemo(()=>{if(Array.isArray(c))return c;const e=C[c];return Array.isArray(e)?e:L},[c]),$=e.useMemo(()=>e=>{var t;const n={stroke:"#fff",strokeWidth:1},o=0===(null!==(t=e.depth)&&void 0!==t?t:0);return n.fill=u?o?I[0]:vi[(e.depth||0)%vi.length]:l?_(e.data||e,l,W):jt,n.opacity=o?1:.85,n},[l,u,W,I]),z=e.useMemo(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),F=Object.assign({top:10,right:10,bottom:10,left:10},r),{customHoverBehavior:G}=Bt({selection:P,linkedHover:j,fallbackFields:l?["string"==typeof l?l:""]:[],unwrapData:!0,onObservation:O,chartType:"OrbitDiagram",chartId:M}),Y=e.useMemo(()=>{if(G)return e=>{G(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[G]),q=on({componentName:"OrbitDiagram",data:o});return q?p.createElement(Kt,{componentName:"OrbitDiagram",message:q,width:D,height:B}):p.createElement(wn,{componentName:"OrbitDiagram",width:D,height:B},p.createElement(si,Object.assign({chartType:"orbit"},null!=o&&{data:o},{size:[D,B],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:F,nodeIDAccessor:s,childrenAccessor:a,nodeStyle:$,edgeStyle:z,colorBy:l,colorScheme:c,colorByDepth:u,nodeSize:b,nodeLabel:x?s:void 0,showLabels:x,enableHover:!k&&H,tooltipContent:k?void 0:!1===w?()=>null:Gt(w)||void 0,customHoverBehavior:j||O?Y:void 0,foregroundGraphics:A,annotations:S,className:i,title:R,orbitMode:d,orbitSize:h,orbitSpeed:g,orbitRevolution:f,orbitRevolutionStyle:y,orbitEccentricity:m,orbitShowRings:v,orbitAnimated:k},E)))}bi.displayName="OrbitDiagram";const xi=e.forwardRef(function(t,n){var o,r,i,a;const s=Wt(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:f,timeAccessor:y,valueAccessor:m,timeExtent:v,valueExtent:b,extentPadding:x,stroke:k="#007bff",strokeWidth:w=2,strokeDasharray:A,background:S,tooltipContent:E,tooltip:O,onHover:M,annotations:P,svgAnnotationRules:C,tickFormatTime:L,tickFormatValue:j,decay:N,pulse:D,staleness:_,transition:B,linkedHover:H,selection:R,onObservation:T,chartId:W,loading:I,emptyContent:$,emphasis:z,legendPosition:F}=t,G=s.showAxes,Y=s.enableHover,q=null!=c?c:s.marginDefaults,X=null!=l?l:[s.width,s.height],V=null!=E?E:O,U=e.useRef(null),{customHoverBehavior:K}=Bt({selection:R,linkedHover:H,unwrapData:!0,onObservation:T,chartType:"RealtimeLineChart",chartId:W}),Q=e.useCallback(e=>{M&&M(e),K(e)},[M,K]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const Z=On(I,X[0],X[1]);if(Z)return Z;const J=En(f,X[0],X[1],$);if(J)return J;const ee={stroke:k,strokeWidth:w,strokeDasharray:A};return p.createElement(ct,{ref:U,chartType:"line",runtimeMode:"streaming",size:X,margin:q,className:z?`${u||""} semiotic-emphasis-${z}`.trim():u,arrowOfTime:d,windowMode:h,windowSize:g,data:f,timeAccessor:y,valueAccessor:m,xExtent:v,yExtent:b,extentPadding:x,lineStyle:ee,showAxes:G,background:S,hoverAnnotation:Y,tooltipContent:V,customHoverBehavior:Q,annotations:P,svgAnnotationRules:C,tickFormatTime:L,tickFormatValue:j,decay:N,pulse:D,staleness:_,transition:B,legendPosition:F})});xi.displayName="RealtimeLineChart";const ki=e.forwardRef(function(t,n){var o,r,i,a;const s=Wt(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:f=200,data:y,timeAccessor:m,valueAccessor:v,timeExtent:b,valueExtent:x,extentPadding:k,categoryAccessor:w,colors:A,fill:S,stroke:E,strokeWidth:O,gap:M,background:P,tooltipContent:C,tooltip:L,onHover:j,annotations:N,svgAnnotationRules:D,tickFormatTime:_,tickFormatValue:B,linkedHover:H,selection:R,decay:T,pulse:W,staleness:I,transition:$,onObservation:z,chartId:F,loading:G,emptyContent:Y,emphasis:q,legendPosition:X}=t,V=s.showAxes,U=s.enableHover,K=null!=u?u:s.marginDefaults,Q=null!=c?c:[s.width,s.height],Z=null!=C?C:L,J=e.useRef(null),{customHoverBehavior:ee}=Bt({selection:R,linkedHover:H,unwrapData:!0,onObservation:z,chartType:"RealtimeTemporalHistogram",chartId:F}),te=e.useCallback(e=>{j&&j(e),ee(e)},[j,ee]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=J.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=J.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=J.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=J.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const ne=On(G,Q[0],Q[1]);if(ne)return ne;const oe=En(y,Q[0],Q[1],Y);if(oe)return oe;const re={};return null!=S&&(re.fill=S),null!=E&&(re.stroke=E),null!=O&&(re.strokeWidth=O),null!=M&&(re.gap=M),p.createElement(ct,{ref:J,chartType:"bar",runtimeMode:"streaming",size:Q,margin:K,className:q?`${d||""} semiotic-emphasis-${q}`.trim():d,arrowOfTime:h,windowMode:g,windowSize:f,data:y,timeAccessor:m,valueAccessor:v,xExtent:b,yExtent:x,extentPadding:k,binSize:l,categoryAccessor:w,barColors:A,barStyle:re,showAxes:V,background:P,hoverAnnotation:U,tooltipContent:Z,customHoverBehavior:te,annotations:N,svgAnnotationRules:D,tickFormatTime:_,tickFormatValue:B,decay:T,pulse:W,staleness:I,transition:$,legendPosition:X})});ki.displayName="RealtimeTemporalHistogram";const wi=ki,Ai=e.forwardRef(function(t,n){var o,r,i,a;const s=Wt(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:f,timeAccessor:y,valueAccessor:m,timeExtent:v,valueExtent:b,extentPadding:x,categoryAccessor:k,colors:w,radius:A,fill:S,opacity:E,stroke:O,strokeWidth:M,background:P,tooltipContent:C,tooltip:L,onHover:j,annotations:N,svgAnnotationRules:D,tickFormatTime:_,tickFormatValue:B,linkedHover:H,selection:R,onObservation:T,chartId:W,loading:I,emptyContent:$,emphasis:z,legendPosition:F}=t,G=s.showAxes,Y=s.enableHover,q=null!=c?c:s.marginDefaults,X=null!=l?l:[s.width,s.height],V=null!=C?C:L,U=e.useRef(null),{customHoverBehavior:K}=Bt({selection:R,linkedHover:H,unwrapData:!0,onObservation:T,chartType:"RealtimeSwarmChart",chartId:W}),Q=e.useCallback(e=>{j&&j(e),K(e)},[j,K]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const Z=On(I,X[0],X[1]);if(Z)return Z;const J=En(f,X[0],X[1],$);if(J)return J;const ee={};return null!=A&&(ee.radius=A),null!=S&&(ee.fill=S),null!=E&&(ee.opacity=E),null!=O&&(ee.stroke=O),null!=M&&(ee.strokeWidth=M),p.createElement(ct,{ref:U,chartType:"swarm",runtimeMode:"streaming",size:X,margin:q,className:z?`${u||""} semiotic-emphasis-${z}`.trim():u,arrowOfTime:d,windowMode:h,windowSize:g,data:f,timeAccessor:y,valueAccessor:m,xExtent:v,yExtent:b,extentPadding:x,categoryAccessor:k,barColors:w,swarmStyle:ee,showAxes:G,background:P,hoverAnnotation:Y,tooltipContent:V,customHoverBehavior:Q,annotations:N,svgAnnotationRules:D,tickFormatTime:_,tickFormatValue:B,legendPosition:F})});Ai.displayName="RealtimeSwarmChart";const Si=e.forwardRef(function(t,n){var o,r,i,a;const s=Wt(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:f,timeAccessor:y,valueAccessor:m,timeExtent:v,valueExtent:b,extentPadding:x,positiveColor:k,negativeColor:w,connectorStroke:A,connectorWidth:S,gap:E,stroke:O,strokeWidth:M,background:P,tooltipContent:C,tooltip:L,onHover:j,annotations:N,svgAnnotationRules:D,tickFormatTime:_,tickFormatValue:B,linkedHover:H,selection:R,onObservation:T,chartId:W,loading:I,emptyContent:$,emphasis:z,legendPosition:F}=t,G=s.showAxes,Y=s.enableHover,q=null!=c?c:s.marginDefaults,X=null!=l?l:[s.width,s.height],V=null!=C?C:L,U=e.useRef(null),{customHoverBehavior:K}=Bt({selection:R,linkedHover:H,unwrapData:!0,onObservation:T,chartType:"RealtimeWaterfallChart",chartId:W}),Q=e.useCallback(e=>{j&&j(e),K(e)},[j,K]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const Z=On(I,X[0],X[1]);if(Z)return Z;const J=En(f,X[0],X[1],$);if(J)return J;const ee={};return null!=k&&(ee.positiveColor=k),null!=w&&(ee.negativeColor=w),null!=A&&(ee.connectorStroke=A),null!=S&&(ee.connectorWidth=S),null!=E&&(ee.gap=E),null!=O&&(ee.stroke=O),null!=M&&(ee.strokeWidth=M),p.createElement(ct,{ref:U,chartType:"waterfall",runtimeMode:"streaming",size:X,margin:q,className:z?`${u||""} semiotic-emphasis-${z}`.trim():u,arrowOfTime:d,windowMode:h,windowSize:g,data:f,timeAccessor:y,valueAccessor:m,xExtent:v,yExtent:b,extentPadding:x,waterfallStyle:ee,showAxes:G,background:P,hoverAnnotation:Y,tooltipContent:V,customHoverBehavior:Q,annotations:N,svgAnnotationRules:D,tickFormatTime:_,tickFormatValue:B,legendPosition:F})});Si.displayName="RealtimeWaterfallChart";const Ei=e.forwardRef(function(t,n){var o,r,i,a;const s=Wt(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:f,timeAccessor:y,valueAccessor:m,categoryAccessor:v,timeExtent:b,valueExtent:x,extentPadding:k,heatmapXBins:w=20,heatmapYBins:A=20,aggregation:S="count",background:E,tooltipContent:O,tooltip:M,onHover:P,annotations:C,svgAnnotationRules:L,tickFormatTime:j,tickFormatValue:N,decay:D,pulse:_,staleness:B,linkedHover:H,selection:R,onObservation:T,chartId:W,loading:I,emptyContent:$,emphasis:z,legendPosition:F}=t,G=s.showAxes,Y=s.enableHover,q=null!=c?c:s.marginDefaults,X=null!=l?l:[s.width,s.height],V=null!=O?O:M,U=e.useRef(null),{customHoverBehavior:K}=Bt({selection:R,linkedHover:H,unwrapData:!0,onObservation:T,chartType:"RealtimeHeatmap",chartId:W}),Q=e.useCallback(e=>{P&&P(e),K(e)},[P,K]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const Z=On(I,X[0],X[1]);if(Z)return Z;const J=En(f,X[0],X[1],$);return J||p.createElement(ct,{ref:U,chartType:"heatmap",runtimeMode:"streaming",size:X,margin:q,className:z?`${u||""} semiotic-emphasis-${z}`.trim():u,arrowOfTime:d,windowMode:h,windowSize:g,data:f,timeAccessor:y,valueAccessor:m,categoryAccessor:v,xExtent:b,yExtent:x,extentPadding:k,heatmapXBins:w,heatmapYBins:A,heatmapAggregation:S,showAxes:G,background:E,hoverAnnotation:Y,tooltipContent:V,customHoverBehavior:Q,annotations:C,svgAnnotationRules:L,tickFormatTime:j,tickFormatValue:N,decay:D,pulse:_,staleness:B,legendPosition:F})});Ei.displayName="RealtimeHeatmap";let[Oi]=De(e=>({tooltip:null,changeTooltip(t){e(()=>({tooltip:t}))}}));function Mi({theme:e}){const t=Te(e=>e.setTheme);return p.useEffect(()=>{void 0!==e&&t(e)},[e,t]),null}function Pi({children:e}){const t=Te(e=>e.theme);return p.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 Ci(e,t){return Pn(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"),Li(a,s),"svg"===n){const e=(new XMLSerializer).serializeToString(s);ji(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?(ji(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 Li(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++)Li(o[e],r[e])}function ji(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)}const Ni=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"]),Di=new Set(["data","nodes","edges"]),_i="function"==typeof structuredClone?structuredClone:e=>JSON.parse(JSON.stringify(e));function Bi(e){return Pn(this,arguments,void 0,function*(e,t="json"){const n="jsx"===t?Hi(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 Hi(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")}const Ri={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 Ti({height:e}){return p.createElement("div",{role:"status","aria-busy":"true","aria-label":"Loading chart",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 Wi({error:e}){return p.createElement("div",{role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:120,padding:24,boxSizing:"border-box"}},p.createElement("div",{style:{textAlign:"center",maxWidth:400,fontSize:14,color:"var(--semiotic-text-secondary, #666)",lineHeight:1.5}},e))}const Ii=p.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:f},y){const m=p.useRef(null),v=p.useRef(null),[b,x]=p.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,S="object"==typeof(null==i?void 0:i.export)?i.export:{},E="object"==typeof(null==i?void 0:i.copyConfig)?i.copyConfig.format:"json",O=p.useCallback(e=>Pn(this,void 0,void 0,function*(){v.current&&(yield Ci(v.current,Object.assign(Object.assign({},S),e)))}),[S]),M=p.useCallback(()=>{m.current&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):m.current.requestFullscreen().catch(()=>{}))},[]),P=p.useCallback(e=>Pn(this,void 0,void 0,function*(){a&&(yield Bi(a,e||E||"json"))}),[a,E]);p.useEffect(()=>{const e=()=>{x(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]),p.useImperativeHandle(y,()=>({export:O,toggleFullscreen:M,copyConfig:P,element:m.current}),[O,M,P]);const C=e||t||s||k||w||A||d,L=l?p.createElement(Ti,{height:r}):c?p.createElement(Wi,{error:c}):u?p.createElement(Qt,null,n):n;return p.createElement(p.Fragment,null,p.createElement("style",{dangerouslySetInnerHTML:{__html:"@keyframes semiotic-skeleton-pulse {\n 0% { background-position: 200% 0; }\n 100% { background-position: -200% 0; }\n}"}}),p.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%"}:{}),f)},C&&p.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)"}},p.createElement("div",{className:"semiotic-chart-title-area"},e&&p.createElement("div",{className:"semiotic-chart-title",style:{fontSize:14,fontWeight:600,color:"var(--semiotic-text, #333)"}},e),t&&p.createElement("div",{className:"semiotic-chart-subtitle",style:{fontSize:12,color:"var(--semiotic-text-secondary, #666)",marginTop:e?2:0}},t)),p.createElement("div",{className:"semiotic-chart-toolbar",style:{display:"flex",alignItems:"center",gap:4}},s,k&&p.createElement("button",{className:"semiotic-chart-action",onClick:()=>O(),title:"Export chart","aria-label":"Export chart",style:$i},p.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},p.createElement("path",{d:"M7 2v8M3.5 7L7 10.5 10.5 7"}),p.createElement("path",{d:"M2 12h10"}))),w&&p.createElement("button",{className:"semiotic-chart-action",onClick:M,title:b?"Exit fullscreen":"Fullscreen","aria-label":b?"Exit fullscreen":"Enter fullscreen",style:$i},p.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},b?p.createElement(p.Fragment,null,p.createElement("path",{d:"M9 1v4h4"}),p.createElement("path",{d:"M5 13V9H1"}),p.createElement("path",{d:"M13 5H9V1"}),p.createElement("path",{d:"M1 9h4v4"})):p.createElement(p.Fragment,null,p.createElement("path",{d:"M1 5V1h4"}),p.createElement("path",{d:"M13 9v4H9"}),p.createElement("path",{d:"M9 1h4v4"}),p.createElement("path",{d:"M5 13H1V9"})))),A&&p.createElement("button",{className:"semiotic-chart-action",onClick:()=>P(),title:"Copy config","aria-label":"Copy chart configuration",style:$i},p.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},p.createElement("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1"}),p.createElement("path",{d:"M9 5V2a1 1 0 00-1-1H2a1 1 0 00-1 1v6a1 1 0 001 1h3"}))),d&&p.createElement("div",{className:"semiotic-chart-status","aria-live":"polite","aria-atomic":"true",style:{padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",background:Ri[d].bg,color:Ri[d].color,lineHeight:"18px"}},d))),p.createElement("div",{className:"semiotic-chart-body",ref:v,style:Object.assign({position:"relative",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center"},b?{flex:1}:{height:r})},L,h)))}),$i={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 zi({children:e,columns:t="auto",minCellWidth:n=300,gap:o=16,className:r,style:i}){const a="number"==typeof t?t:void 0;return p.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)},p.Children.map(e,e=>p.isValidElement(e)?"primary"!==e.props.emphasis||void 0!==a&&2>a?e:p.createElement("div",{style:{gridColumn:"span 2"}},e):e))}function Fi({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 p.createElement("div",{className:"semiotic-context-layout"+(i?" "+i:""),style:c},p.createElement("div",{style:{flex:"1 1 0%",minWidth:0,minHeight:0}},e),p.createElement("div",{style:u},t))}zi.displayName="ChartGrid",Fi.displayName="ContextLayout";function Gi({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),[f,y]=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:S}=At({types:A,chartId:i,limit:1}),E=void 0!==a?a:S;e.useEffect(()=>{if(E)if("click"===E.type||"hover"===E.type){const e=E;g(e.datum),y(e),m||(v(!0),x(!0),clearTimeout(w.current),w.current=setTimeout(()=>x(!1),200))}else!s||"click-end"!==E.type&&"hover-end"!==E.type||O()},[E]),e.useEffect(()=>{null==c||c(m)},[m,c]);const O=e.useCallback(()=>{x(!0),v(!1),clearTimeout(w.current),w.current=setTimeout(()=>{x(!1),g(null),y(null)},200)},[]);if(e.useEffect(()=>()=>clearTimeout(w.current),[]),!h&&!b)return null;const M=h&&f?t(h,f):null;if(null===M&&!b)return null;const P=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 p.createElement("div",{ref:k,className:`semiotic-details-panel semiotic-details-${n}${u?" "+u:""}`,style:Object.assign(Object.assign({},P),d)},l&&p.createElement("button",{className:"semiotic-details-close",onClick:O,"aria-label":"Close details",style:Yi},p.createElement("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"},p.createElement("path",{d:"M2 2l8 8M10 2l-8 8"}))),p.createElement("div",{className:"semiotic-details-content",style:{overflow:"auto",flex:1}},M))}const Yi={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};function qi(e){return"nominal"===e||"ordinal"===e}function Xi(e){return"quantitative"===e||"temporal"===e}Gi.displayName="DetailsPanel";const Vi={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"},Ui={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"},Ki={sum:"sum",mean:"mean",average:"mean",count:"count",min:"min",max:"max",median:"mean"};function Qi(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 Zi(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 Ji="__forecastSegment";function ea(e,t){return"function"==typeof t?t(e):!!e[t]}const ta=Object.freeze({__proto__:null,SEGMENT_FIELD:Ji,buildAnomalyAnnotations: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}]},buildForecast: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:p="#ef4444",anomalyRadius:y=6,label:m}=o,v=e.map(e=>{let t="observed";return c&&ea(e,c)?t="forecast":l&&ea(e,l)&&(t="training"),Object.assign(Object.assign({},e),{[Ji]:t})}),b=[];for(let e=0;v.length>e;e++)b.push(v[e]),v.length-1>e&&v[e][Ji]!==v[e+1][Ji]&&b.push(Object.assign(Object.assign({},v[e]),{[Ji]:v[e+1][Ji]}));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=>ea(e,u),color:p,r:y,style:{stroke:p,strokeWidth:1.5,fill:p,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=[],p=[];for(const n of e)n[t]>l?p.push(Object.assign(Object.assign({},n),{[Ji]:"observed"})):f.push(Object.assign(Object.assign({},n),{[Ji]:"training"}));const y=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(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,f=(i-a*r)/o,p=e=>f+a*e,b=y.map(([e,t])=>t-p(e)).reduce((e,t)=>e+t*t,0),x=Math.sqrt(b/Math.max(o-2,1)),k=y.reduce((e,t)=>e+t[0],0)/o,w=y.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,S=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),E=Math.max(...S),O=y.length>1?(y[o-1][0]-y[0][0])/(o-1):1;for(let e=1;c>=e;e++){const r=E+e*O,i=p(r),a=x*Math.sqrt(1+1/o+(w>0?Math.pow(r-k,2)/w:0))*A;v.push({[t]:r,[n]:i,[Ji]:"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&&p.length>0&&b.push(Object.assign(Object.assign({},f[f.length-1]),{[Ji]:"observed"})),b.push(...p),v.length>0){const e=p.length>0?p[p.length-1]:f[f.length-1];e&&b.push(Object.assign(Object.assign({},e),{[Ji]:"forecast"})),b.push(...v)}return{processedData:b,annotations:m}}(e,t,n,o,r);var i},createSegmentLineStyle: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[Ji];return"training"===o?Object.assign(Object.assign({},n),{strokeDasharray:r}):"forecast"===o?Object.assign(Object.assign({},n),{stroke:a,strokeDasharray:i}):n}}});exports.AreaChart=Nn,exports.BarChart=vo,exports.BoxPlot=wo,exports.BubbleChart=Wn,exports.CategoryColorProvider=dt,exports.ChartContainer=Ii,exports.ChartGrid=zi,exports.ChordDiagram=gi,exports.CirclePack=mi,exports.ConnectedScatterplot=Tn,exports.ContextLayout=Fi,exports.DetailsPanel=Gi,exports.DonutChart=Po,exports.DotPlot=Eo,exports.ForceDirectedGraph=li,exports.GroupedBarChart=xo,exports.Heatmap=In,exports.Histogram=Ao,exports.LineChart=jn,exports.LinkedCharts=Mt,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=$t(e,n);l.push({value:zt(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=zt($t(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:zt(e[t],o)})});const c=Object.assign(Object.assign({},It),r);return Array.isArray(l)&&0!==l.length?p.createElement("div",{className:("semiotic-tooltip semiotic-tooltip-multiline "+i).trim(),style:c},l.map((e,t)=>p.createElement("div",{key:t,style:{marginBottom:l.length-1>t?"4px":0}},e.label&&p.createElement("strong",null,e.label,s),e.value))):null}},exports.OrbitDiagram=bi,exports.PieChart=Mo,exports.RealtimeHeatmap=Ei,exports.RealtimeHistogram=wi,exports.RealtimeLineChart=xi,exports.RealtimeSwarmChart=Ai,exports.RealtimeWaterfallChart=Si,exports.RidgelinePlot=Oo,exports.SankeyDiagram=fi,exports.Scatterplot=Hn,exports.ScatterplotMatrix=Vn,exports.StackedAreaChart=_n,exports.StackedBarChart=bo,exports.SwarmPlot=ko,exports.ThemeProvider=function({theme:e,children:t}){return p.createElement(Re,null,p.createElement(Mi,{theme:e}),p.createElement(Pi,null,t))},exports.TooltipProvider=Oi,exports.TreeDiagram=pi,exports.Treemap=yi,exports.ViolinPlot=So,exports.configToJSX=Hi,exports.copyConfig=Bi,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.diagnoseConfig=bn,exports.exportChart=Ci,exports.fromConfig=function(e){if(!e.component||!e.props)throw Error("Invalid chart config: missing component or props");if(!dn[e.component])throw Error(`Unknown component "${e.component}". This config may require a newer version of semiotic.`);return{componentName:e.component,props:_i(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 p=[],{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,k=v.color,w=v.size,A=v.theta,S=v.opacity;let E;(null===(t=e.data)||void 0===t?void 0:t.values)?E=e.data.values:(null===(n=e.data)||void 0===n?void 0:n.url)&&p.push("data.url is not supported — only inline data.values can be translated. Provide data manually."),e.transform&&e.transform.length>0&&p.push("Vega-Lite transforms are not supported. Pre-transform your data before passing to fromVegaLite()."),e.layer&&p.push('Layered specs ("layer") are not supported. Only single-mark specs can be translated.'),(e.hconcat||e.vconcat||e.concat)&&p.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))&&p.push("Faceted views are not supported. Use Semiotic's LinkedCharts or render multiple charts manually."),e.repeat&&p.push('Repeated views ("repeat") are not supported. Translate each field combination individually.'),(e.params||e.selection)&&p.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 M=function(e){if(e)return"string"==typeof e?e:e.text}(e.title);if(M&&(O.title=M),(null==k?void 0:k.field)&&(O.colorBy=k.field,null===(o=k.scale)||void 0===o?void 0:o.scheme)){const e=Vi[k.scale.scheme];e&&(O.colorScheme=e)}void 0!==(null==S?void 0:S.value)&&(O.pointOpacity=S.value);const P=null==b?void 0:b.aggregate,C=null==x?void 0:x.aggregate;if(E&&(P||C)){const e=C?x:b,t=C?b:x,n=Ki[e.aggregate];if(n&&(null==t?void 0:t.field)&&e.field)E=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}(E,{groupBy:t.field,value:e.field,agg:n});else if(("count"===n||"count"===e.aggregate)&&(null==t?void 0:t.field)&&E){const e=new Map;for(const n of E){const o=n[t.field]+"";e.set(o,(e.get(o)||0)+1)}E=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";E&&(O.data=E),(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),Zi(e,O,p)}let L;switch(y){case"bar":L=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",qi(null==e?void 0:e.type)&&Xi(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)):Xi(null==e?void 0:e.type)&&qi(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,O,E,P,C);break;case"line":if(L="LineChart",Qi(b,x,O,P,C),(null==k?void 0:k.field)&&(O.lineBy=k.field),m.interpolate){const e=Ui[m.interpolate];e&&(O.curve=e)}!0===m.point&&(O.showPoints=!0),E&&(O.data=E);break;case"area":if((null==k?void 0:k.field)?(L="StackedAreaChart",O.areaBy=k.field):L="AreaChart",Qi(b,x,O,P,C),m.interpolate){const e=Ui[m.interpolate];e&&(O.curve=e)}void 0!==m.opacity&&(O.areaOpacity=m.opacity),E&&(O.data=E);break;case"point":case"circle":case"square":(null==w?void 0:w.field)?(L="BubbleChart",O.sizeBy=w.field,(null===(l=w.scale)||void 0===l?void 0:l.range)&&(O.sizeRange=w.scale.range)):L="Scatterplot",Qi(b,x,O,P,C),E&&(O.data=E);break;case"rect":L="Heatmap",(null==b?void 0:b.field)&&(O.xAccessor=b.field),(null==x?void 0:x.field)&&(O.yAccessor=x.field),(null==k?void 0:k.field)&&(O.valueAccessor=k.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),E&&(O.data=E);break;case"arc":m.innerRadius&&m.innerRadius>0?(L="DonutChart",O.innerRadius=m.innerRadius):L="PieChart",(null==A?void 0:A.field)?O.valueAccessor=A.field:(null==x?void 0:x.field)&&(O.valueAccessor=C?"value":x.field),(null==k?void 0:k.field)&&(O.categoryAccessor=k.field),(null==b?void 0:b.field)&&!(null==A?void 0:A.field)&&(O.categoryAccessor=b.field),E&&(O.data=E);break;case"tick":L="DotPlot",qi(null==b?void 0:b.type)?(O.categoryAccessor=b.field,(null==x?void 0:x.field)&&(O.valueAccessor=C?"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)):qi(null==x?void 0:x.type)?(O.categoryAccessor=x.field,(null==b?void 0:b.field)&&(O.valueAccessor=P?"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===(f=null==b?void 0:b.axis)||void 0===f?void 0:f.title)&&(O.valueLabel=b.axis.title)):((null==b?void 0:b.field)&&(O.categoryAccessor=b.field),(null==x?void 0:x.field)&&(O.valueAccessor=C?"value":x.field)),E&&(O.data=E);break;default:p.push(`Unsupported mark type "${y}". Defaulting to Scatterplot.`),L="Scatterplot",Qi(b,x,O,P,C),E&&(O.data=E)}return Zi(L,O,p)},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.toConfig=function(e,t,n){if(!dn[e])throw Error(`Unknown component "${e}". Known components: ${Object.keys(dn).join(", ")}`);const o=!1!==(null==n?void 0:n.includeData),r={};for(const[e,n]of Object.entries(t))null!=n&&(Ni.has(e)||!o&&Di.has(e)||"function"!=typeof n&&((null==n?void 0:n.$$typeof)||(r[e]=_i(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=wt,exports.useCategoryColors=ht,exports.useChartObserver=At,exports.useFilteredData=function(t,n,o){const r=mt(e=>e.selections.get(n));return e.useMemo(()=>{if(!r||0===r.clauses.size)return t;const e=ft(r,o);return t.filter(e)},[t,r,o])},exports.useLinkedHover=kt,exports.useSelection=xt,exports.useTheme=function(){return Te(e=>e.theme)},exports.validateProps=gn;
|