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/xy.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react"),t=require("d3-brush"),n=require("d3-selection"),o=require("d3-scale"),s=require("d3-array"),i=require("d3-hierarchy"),r=require("regression"),l=require("d3-scale-chromatic");function a(e){return e&&e.__esModule?e:{default:e}}function c(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 u=c(e),h=a(r),d=5e3;class f{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,d),bounded:!0,totalSize:e.length});let t=d;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const o=Math.min(t+d,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 g{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 p{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 y(e,t,n,o,s){const i=new Map;for(const r of e){const e=t(r),l=n(r);if(null==e||null==l||Number.isNaN(e)||Number.isNaN(l))continue;const a=Math.floor(e/o)*o;let c=i.get(a);if(c||(c={start:a,end:a+o,total:0,categories:new Map},i.set(a,c)),c.total+=l,s){const e=s(r);c.categories.set(e,(c.categories.get(e)||0)+l)}}return i}function m(e,t,n,o,s,i){const r=[];for(const s of e){const e=n(s),i=o(s);null==e||null==i||Number.isNaN(e)||Number.isNaN(i)||r.push({px:t.x(e),py:t.y(i),rawY:i,d:s})}r.sort((e,t)=>e.px-t.px);const l=Array(r.length),a=Array(r.length),c=Array(r.length);for(let e=0;r.length>e;e++){const t=r[e];l[e]=[t.px,t.py],a[e]=t.rawY,c[e]=t.d}return{type:"line",path:l,rawValues:a,style:s,datum:c,group:i}}function b(e,t,n,o,s,i,r,l){const a=[];for(const i of e){const e=n(i),r=o(i);if(null==e||null==r||Number.isNaN(e)||Number.isNaN(r))continue;const c=t.x(e),u=l?l(i):s;a.push({px:c,topY:t.y(r),botY:t.y(u)})}a.sort((e,t)=>e.px-t.px);const c=Array(a.length),u=Array(a.length);for(let e=0;a.length>e;e++){const t=a[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:r}}function v(e,t,n,o,s,i,r){const l=n(e),a=o(e);if(null==l||null==a||Number.isNaN(l)||Number.isNaN(a))return null;const c={type:"point",x:t.x(l),y:t.y(a),r:s,style:i,datum:e};return void 0!==r&&(c.pointId=r),c}function x(e,t,n,o,s,i,r){return{type:"rect",x:e,y:t,w:n,h:o,style:s,datum:i,group:r}}function k(e,t,n,o,s,i){return{type:"heatcell",x:e,y:t,w:n,h:o,fill:s,datum:i}}function w(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function A(e,t){return"function"==typeof e?e:e?t=>t[e]+"":void 0}class E{constructor(e){this.xExtent=new p,this.yExtent=new p,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 g(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=w(e.timeAccessor||e.xAccessor,"time"),this.getY=w(e.valueAccessor||e.yAccessor,"value")):(this.getX=w(e.xAccessor,"x"),this.getY=w(e.yAccessor,"y")),this.getGroup=A(e.groupAccessor),this.getCategory=A(e.categoryAccessor),this.getSize=e.sizeAccessor?w(e.sizeAccessor,"size"):void 0,this.getColor=A(e.colorAccessor),this.getBounds=e.boundsAccessor?w(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?w(e.y0Accessor,"y0"):void 0,this.getPointId=A(e.pointIdAccessor),"candlestick"===e.chartType&&(this.getOpen=w(e.openAccessor,"open"),this.getHigh=w(e.highAccessor,"high"),this.getLow=w(e.lowAccessor,"low"),this.getClose=w(e.closeAccessor,"close")),e.pulse&&(this.timestampBuffer=new g(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,s,i,r,l;const{config:a,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"===a.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,h=this.yExtent.extent;let d=a.xExtent?[null!==(t=a.xExtent[0])&&void 0!==t?t:u[0],null!==(n=a.xExtent[1])&&void 0!==n?n:u[1]]:u,f=a.yExtent?[null!==(s=a.yExtent[0])&&void 0!==s?s:h[0],null!==(i=a.yExtent[1])&&void 0!==i?i:h[1]]:h;const g=a.yExtent&&null!=a.yExtent[0]&&null!=a.yExtent[1];if("stackedarea"===a.chartType&&!g&&c.size>0)if(a.normalize)f=[0,1+a.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);f=[0,o+(o>0?o*a.extentPadding:1)]}else if("bar"===a.chartType&&a.binSize&&!g&&c.size>0){const[,e]=function(e,t,n,o,s){const i=y(e,t,n,o,s);if(0===i.size)return[0,0];let r=0;for(const e of i.values())e.total>r&&(r=e.total);return[0,r]}(c,this.getX,this.getY,a.binSize,this.getCategory);f=[0,e+e*a.extentPadding]}else if("waterfall"===a.chartType&&!g&&c.size>0){const[e,t]=function(e,t){let n=0,o=0,s=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(s+=e,n>s&&(n=s),s>o&&(o=s))}return[n,o]}(c,this.getY),n=t-e,o=n>0?n*a.extentPadding:1;f=[Math.min(0,e-Math.abs(o)),Math.max(0,t+Math.abs(o))]}else if(!g&&f[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>f[1]&&(f[1]=e+n),f[0]>e-n&&(f[0]=e-n))}}const e=f[1]-f[0],t=e>0?e*a.extentPadding:1,n=null===(r=a.yExtent)||void 0===r?void 0:r[0],o=null===(l=a.yExtent)||void 0===l?void 0:l[1];f=[null!=n?f[0]:f[0]-t,null!=o?f[1]:f[1]+t]}if(d[0]!==1/0&&d[1]!==-1/0||(d=[0,1]),f[0]!==1/0&&f[1]!==-1/0||(f=[0,1]),void 0!==a.arrowOfTime)if("x"==("up"===(p=a.arrowOfTime)||"down"===p?"y":"x")){const t="right"===a.arrowOfTime?[0,e.width]:[e.width,0];this.scales={x:o.scaleLinear().domain(d).range(t),y:o.scaleLinear().domain(f).range([e.height,0])}}else{const t="down"===a.arrowOfTime?[0,e.height]:[e.height,0];this.scales={x:o.scaleLinear().domain(f).range([0,e.width]),y:o.scaleLinear().domain(d).range(t)}}else this.scales={x:o.scaleLinear().domain(d).range([0,e.width]),y:o.scaleLinear().domain(f).range([e.height,0])};var p;this.config.transition&&this.scene.length>0&&this.snapshotPositions();const m=c.toArray();this.scene=this.buildSceneNodes(e),this.config.decay&&this.applyDecay(this.scene,m),this.config.pulse&&this.applyPulse(this.scene,m),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.needsFullRebuild=!1,this.lastLayout={width: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 s=this.scales.x.domain(),i=this.scales.y.domain(),r=this.scales.x.range(),l=this.scales.y.range();this.scales={x:o.scaleLinear().domain(s).range([r[0]*t,r[1]*t]),y:o.scaleLinear().domain(i).range([l[0]*n,l[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 s=n.toArray();switch(t.chartType){case"line":return this.buildLineScene(s);case"area":return this.buildAreaScene(s);case"stackedarea":return this.buildStackedAreaScene(s);case"scatter":case"bubble":return this.buildPointScene(s);case"heatmap":return this.buildHeatmapScene(s,e);case"bar":return this.buildBarScene(s);case"swarm":return this.buildSwarmScene(s);case"waterfall":return this.buildWaterfallScene(s,e);case"candlestick":return this.buildCandlestickScene(s,e);default:return[]}}buildLineScene(e){var t;const n=this.groupData(e),o=[],s=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=m(e.data,this.scales,this.getX,this.getY,t,e.key);s&&s.length>0&&(n.colorThresholds=s),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]),s=b(e.data,this.scales,this.getX,this.getY,o,t,e.key,this.getY0);this.config.gradientFill&&(s.fillGradient=this.config.gradientFill),n.push(s)}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,s,i){var r;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 a=Array.from(l).sort((e,t)=>e-t),c=new Map;for(const t of e){const e=new Map;for(const s of t.data){const t=n(s),i=o(s);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 a){let n=0;for(const o of e)n+=(null===(r=c.get(o.key))||void 0===r?void 0:r.get(t))||0;u.set(t,n||1)}}const h=[],d=new Map;for(const e of a)d.set(e,0);for(const n of e){const e=c.get(n.key),o=[],r=[];for(const n of a){let s=e.get(n)||0;const l=d.get(n);i&&(s/=u.get(n));const a=t.x(n);r.push([a,t.y(l)]),o.push([a,t.y(l+s)]),d.set(n,l+s)}h.push({type:"area",topPath:o,bottomPath:r,style:s(n.key,n.data[0]),datum:n.data,group:n.key})}return h}(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 s=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);s=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},r=e.r||n;if(s&&this.getSize){const e=this.getSize(o);null==e||Number.isNaN(e)||(r=s(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 l=this.getPointId?this.getPointId(o)+"":void 0,a=v(o,this.scales,this.getX,this.getY,r,e,l);a&&t.push(a)}return t}buildHeatmapScene(e,t){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(e,t);const o=w(this.config.valueAccessor,"value"),s=new Set,i=new Set;for(const t of e)s.add(this.getX(t)),i.add(this.getY(t));const r=Array.from(s).sort((e,t)=>e-t),l=Array.from(i).sort((e,t)=>e-t);if(0===r.length||0===l.length)return n;const a=t.width/r.length,c=t.height/l.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 h=1/0,d=-1/0;for(const{val:e}of u.values())h>e&&(h=e),e>d&&(d=e);const f=d-h||1;for(let e=0;r.length>e;e++)for(let t=0;l.length>t;t++){const o=u.get(`${r[e]}_${l[t]}`);if(!o)continue;const s=(o.val-h)/f;n.push(k(e*a,(l.length-1-t)*c,a,c,`rgb(${Math.round(220-180*s)},${Math.round(220-100*s)},${Math.round(255-50*s)})`,o.datum))}return n}buildStreamingHeatmapScene(e,t){var n,o,s;const i=[],r=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,l=null!==(o=this.config.heatmapYBins)&&void 0!==o?o:20,a=null!==(s=this.config.heatmapAggregation)&&void 0!==s?s:"count",c=w(this.config.valueAccessor,"value");if(!this.scales||0===e.length)return i;const[u,h]=this.scales.x.domain(),[d,f]=this.scales.y.domain(),g=(h-u||1)/r,p=(f-d||1)/l,y=new Map;for(const t of e){const e=this.getX(t),n=this.getY(t),o=Math.min(Math.floor((e-u)/g),r-1),s=Math.min(Math.floor((n-d)/p),l-1);if(0>o||0>s)continue;const i=`${o}_${s}`;let a=y.get(i);a||(a={sum:0,count:0,data:[]},y.set(i,a)),a.count++,a.sum+=c(t),a.data.push(t)}let m=1/0,b=-1/0;const v=new Map;for(const[e,t]of y){let n;switch(a){case"sum":n=t.sum;break;case"mean":n=t.count>0?t.sum/t.count:0;break;default:n=t.count}v.set(e,n),m>n&&(m=n),n>b&&(b=n)}const x=b-m||1,A=t.width/r,E=t.height/l;for(const[e,t]of v){const[n,o]=e.split("_"),s=+n,r=+o,a=(t-m)/x,c=`rgb(${Math.round(220-180*a)},${Math.round(220-100*a)},${Math.round(255-50*a)})`,u=y.get(e);i.push(k(s*A,(l-1-r)*E,A,E,c,{xi:s,yi:r,value:t,count:u.count,sum:u.sum,data:u.data}))}return i}buildBarScene(e){var t;if(!this.config.binSize)return[];const n=y(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):[],s=new Set(t),i=Array.from(e).filter(e=>!s.has(e)).sort();o=[...t.filter(t=>e.has(t)),...i]}const s=[],i=this.scales,[r,l]=i.x.domain();for(const e of n.values()){const n=Math.max(e.start,r),a=Math.min(e.end,l);if(n>=a)continue;const c=i.x(n),u=i.x(a),h=Math.min(c,u)+.5,d=Math.max(c,u)-.5-h;if(d>0)if(o&&e.categories.size>0){let n=0;for(const r of o){const o=e.categories.get(r)||0;if(0===o)continue;const l=i.y(n),a=i.y(n+o);s.push(x(h,Math.min(l,a),d,Math.abs(l-a),{fill:(null===(t=this.config.barColors)||void 0===t?void 0:t[r])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:r,categoryValue:o},r)),n+=o}}else{const t=i.y(0),n=i.y(e.total);s.push(x(h,Math.min(t,n),d,Math.abs(t-n),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}return s}buildSwarmScene(e){var t,n,o,s;const i=[],r=this.config.swarmStyle||{},l=null!==(t=r.radius)&&void 0!==t?t:3,a=null!==(n=r.fill)&&void 0!==n?n:"#007bff",c=null!==(o=r.opacity)&&void 0!==o?o:.7,u=r.stroke,h=r.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),r=this.scales.y(n);let d=a;if(this.getCategory){const e=this.getCategory(t);d=(null===(s=this.config.barColors)||void 0===s?void 0:s[e])||d}const f={type:"point",x:o,y:r,r:l,style:{fill:d,opacity:c,stroke:u,strokeWidth:h},datum:t};this.getPointId&&(f.pointId=this.getPointId(t)+""),i.push(f)}return i}buildWaterfallScene(e,t){var n,o,s;const i=[],r=this.scales,l=this.config.waterfallStyle,a=e.filter(e=>{const t=this.getY(e);return null!=t&&!Number.isNaN(t)});if(0===a.length)return i;const c=null!==(n=null==l?void 0:l.positiveColor)&&void 0!==n?n:"#28a745",u=null!==(o=null==l?void 0:l.negativeColor)&&void 0!==o?o:"#dc3545",h=null!==(s=null==l?void 0:l.gap)&&void 0!==s?s:1,d=null==l?void 0:l.stroke,f=null==l?void 0:l.strokeWidth;let g=0;for(let e=0;a.length>e;e++){const n=a[e],o=this.getX(n),s=this.getY(n),p=g+s;let y;y=a.length-1>e?this.getX(a[e+1])-o:e>0?o-this.getX(a[e-1]):0;const m=r.x(o),b=0!==y?r.x(o+y):m+t.width/10,v=Math.min(m,b)+h/2,k=Math.max(m,b)-h/2-v;if(0>=k){g=p;continue}const w=r.y(g),A=r.y(p);i.push(x(v,Math.min(w,A),k,Math.abs(w-A),{fill:0>s?u:c,stroke:d,strokeWidth:f},Object.assign(Object.assign({},n),{baseline:g,cumEnd:p,delta:s,_connectorStroke:null==l?void 0:l.connectorStroke,_connectorWidth:null==l?void 0:l.connectorWidth}))),g=p}return i}buildCandlestickScene(e,t){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],o=this.config.candlestickStyle||{},s=o.upColor||"#28a745",i=o.downColor||"#dc3545",r=o.wickColor||"#333",l=o.wickWidth||1,a=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&&a.length>1){let e=1/0;for(let t=1;a.length>t;t++){const n=Math.abs(this.scales.x(a[t])-this.scales.x(a[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),a=this.getHigh(t),u=this.getLow(t),h=this.getClose(t);if([o,a,u,h].some(e=>null==e||Number.isNaN(e)))continue;const d=h>=o;n.push({type:"candlestick",x:this.scales.x(e),openY:this.scales.y(o),closeY:this.scales.y(h),highY:this.scales.y(a),lowY:this.scales.y(u),bodyWidth:c,upColor:s,downColor:i,wickColor:r,wickWidth:l,isUp:d,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),s=this.getY(t);if(null==e||null==s||Number.isNaN(e)||Number.isNaN(s))continue;const i=this.getBounds(t),r=this.scales.x(e);if(i&&0!==i)n.push([r,this.scales.y(s+i)]),o.push([r,this.scales.y(s-i)]);else{const e=this.scales.y(s);n.push([r,e]),o.push([r,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,s;const i=this.config.decay;if(!i||1>=t)return 1;const r=null!==(n=i.minOpacity)&&void 0!==n?n:.1,l=t-1-e;switch(i.type){case"linear":return r+(1-l/(t-1))*(1-r);case"exponential":{const e=null!==(o=i.halfLife)&&void 0!==o?o:t/2;return r+Math.pow(.5,l/e)*(1-r)}case"step":return(null!==(s=i.stepThreshold)&&void 0!==s?s:.5*t)>l?1:r;default:return 1}}applyDecay(e,t){var n,o;if(!this.config.decay)return;const s=t.length;if(1>=s)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 r=this.computeDecayOpacity(e,s);if("heatcell"===t.type)t.style={opacity:r};else if("candlestick"===t.type)t._decayOpacity=r;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*r})}}}computePulseIntensity(e,t){var n;const o=this.config.pulse;if(!o)return 0;const s=null!==(n=o.duration)&&void 0!==n?n:500,i=t-e;return s>i?1-i/s:0}applyPulse(e,t){var n,o;if(!this.config.pulse||!this.timestampBuffer)return;const s="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",r=null!==(o=this.config.pulse.glowRadius)&&void 0!==o?o:4,l=new Map;for(let e=0;t.length>e;e++)l.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=l.get(t);if(null==e)continue;const o=this.timestampBuffer.get(e);if(null==o)continue;const i=this.computePulseIntensity(o,s);i>n&&(n=i)}n>0&&(t._pulseIntensity=n,t._pulseColor=i);continue}const e=l.get(t.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const o=this.computePulseIntensity(n,s);o>0&&(t._pulseIntensity=o,t._pulseColor=i,t._pulseGlowRadius=r)}}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,s,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===(s=e.datum)||void 0===s?void 0:s.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,s,i;if(!this.config.transition||0===this.prevPositionMap.size)return;const r=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;let l=!1;for(let e=0;this.scene.length>e;e++){const r=this.scene[e],a=this.getNodeIdentity(r,e);if(!a)continue;const c=this.prevPositionMap.get(a);if(c)if("point"===r.type){const e={x:r.x,y:r.y,r:r.r};c.x===e.x&&c.y===e.y||(r._targetX=e.x,r._targetY=e.y,r._targetR=e.r,r.x=c.x,r.y=c.y,r.r=null!==(t=c.r)&&void 0!==t?t:r.r,l=!0)}else if("rect"===r.type){const e={x:r.x,y:r.y,w:r.w,h:r.h};c.x===e.x&&c.y===e.y&&c.w===e.w&&c.h===e.h||(r._targetX=e.x,r._targetY=e.y,r._targetW=e.w,r._targetH=e.h,r.x=c.x,r.y=c.y,r.w=null!==(n=c.w)&&void 0!==n?n:r.w,r.h=null!==(o=c.h)&&void 0!==o?o:r.h,l=!0)}else if("heatcell"===r.type){const e={x:r.x,y:r.y,w:r.w,h:r.h};c.x===e.x&&c.y===e.y||(r._targetX=e.x,r._targetY=e.y,r._targetW=e.w,r._targetH=e.h,r.x=c.x,r.y=c.y,r.w=null!==(s=c.w)&&void 0!==s?s:r.w,r.h=null!==(i=c.h)&&void 0!==i?i:r.h,l=!0)}}l&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:r})}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 S(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 M(e,t,n){const o=t-e.x,s=n-e.y,i=Math.sqrt(o*o+s*s);return i>e.r+5?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:i}}function O(e,t,n){if(0===e.path.length)return null;const o=B(e.path,t);if(0>o)return null;const[s,i]=e.path[o],r=t-s,l=n-i,a=Math.sqrt(r*r+l*l);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:s,y:i,distance:a}}function C(e,t,n){const o=S(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function L(e,t,n){const o=S(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function j(e,t,n){const o=e.bodyWidth/2,s=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=s+Math.max(Math.max(e.openY,e.closeY)-s,1)/2,i=t-e.x,r=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(i*i+r*r)}}return null}function N(e,t,n){if(0===e.topPath.length)return null;const o=B(e.topPath,t);if(0>o)return null;const[s,i]=e.topPath[o],r=t-s,l=n-i;return{node:e,datum:e.datum,x:s,y:i,distance:Math.sqrt(r*r+l*l)}}function B(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const s=n+o>>1;t>e[s][0]?n=s+1:o=s}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}const H={fill:e=>u.createElement("rect",{style:e,width:20,height:20}),line:e=>u.createElement("line",{style:e,x1:0,y1:0,x2:20,y2:20})};function _(e,t,n,o){let s;return s="function"==typeof n?n(e):(0,H[n])(o(e,t)),s}function W(){return u.createElement("path",{d:"M2,6 L5,9 L10,3",fill:"none",stroke:"currentColor",strokeWidth:1.5,transform:"translate(-14, 5)"})}function $(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function z(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:s,isolatedCategories:i,title:r="Legend",width:l=100,height:a=20,orientation:c="vertical"}=e,h="vertical"===c?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:s,isolatedCategories:i})=>{let r=30;const l=[];return e.forEach((e,a)=>{r+=5,l.push(u.createElement("line",{key:"legend-top-line legend-symbol-"+a,stroke:"gray",x1:0,y1:r,x2:t,y2:r})),r+=10,e.label&&(r+=20,l.push(u.createElement("text",{key:"legend-text-"+a,y:r,className:"legend-group-label"},e.label)),r+=10),l.push(u.createElement("g",{key:"legend-group-"+a,className:"legend-item",transform:`translate(0,${r})`},((e,t,n,o,s)=>{const{type:i="fill",styleFn:r,items:l}=e,a=[];let c=0;const h=!(!t&&!n);return l.forEach((e,l)=>{const d=_(e,l,i,r),f=$(e,o,s),g=s&&s.size>0&&s.has(e.label);a.push(u.createElement("g",{key:"legend-item-"+l,transform:`translate(0,${c})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,style:{cursor:h?"pointer":"default",opacity:f,transition:"opacity 150ms ease",pointerEvents:"all"}},g&&u.createElement(W,null),d,u.createElement("text",{y:15,x:30},e.label))),c+=25}),a})(e,n,o,s,i))),r+=25*e.items.length+10}),l})({legendGroups:t,width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:s,isolatedCategories:i}):(({legendGroups:e,title:t,height:n,customClickBehavior:o,customHoverBehavior:s,highlightedCategory:i,isolatedCategories:r})=>{let l=0;const a=[],c=!1===t?10:40;return e.forEach((t,h)=>{t.label&&(a.push(u.createElement("text",{key:"legend-text-"+h,transform:`translate(${l},${c}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},t.label)),l+=20);const d=((e,t,n,o,s)=>{const{type:i="fill",styleFn:r,items:l}=e,a=[];let c=0;const h=!(!t&&!n);return l.forEach((e,l)=>{const d=_(e,l,i,r),f=$(e,o,s),g=s&&s.size>0&&s.has(e.label);a.push(u.createElement("g",{key:"legend-item-"+l,transform:`translate(${c},0)`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,style:{cursor:h?"pointer":"default",opacity:f,transition:"opacity 150ms ease",pointerEvents:"all"}},g&&u.createElement(W,null),d,u.createElement("text",{y:15,x:25},e.label))),c+=35,c+=8*e.label.length}),{items:a,offset:c}})(t,o,s,i,r);a.push(u.createElement("g",{key:"legend-group-"+h,className:"legend-item",transform:`translate(${l},${c})`},d.items)),l+=d.offset+5,e[h+1]&&a.push(u.createElement("line",{key:"legend-top-line legend-symbol-"+h,stroke:"gray",x1:l,y1:c-10,x2:l,y2:n+c+10})),l+=15}),u.createElement("g",null,!1!==t&&u.createElement("line",{x1:0,x2:l+10,y1:c-10,y2:c-10,stroke:"gray",className:"title-neatline"}),a)})({legendGroups:t,title:r,height:a,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:s,isolatedCategories:i});return u.createElement("g",null,void 0!==r&&u.createElement("text",{className:"legend-title",y:20,x:"horizontal"===c?0:l/2,textAnchor:"horizontal"===c?"start":"middle"},r),h)}function I(e){return"string"==typeof e?{type:e}:e}function F({orient:t,config:n,values:o,scale:i,size:r,length:l}){const a=function(e){var t,n,o,s,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!==(s=e.stroke)&&void 0!==s?s:"none",strokeWidth:null!==(i=e.strokeWidth)&&void 0!==i?i:1}}(n),c="top"===t||"bottom"===t,h=e.useMemo(()=>{if(0===o.length)return null;const e=i.domain(),n=r-8;if("boxplot"===a.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)],s=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],r=i-o;return{q1:o,median:s,q3:i,whiskerLow:Math.max(t[0],o-1.5*r),whiskerHigh:Math.min(t[n-1],i+1.5*r)}}(o);if(!e)return null;const{q1:s,median:r,q3:l,whiskerLow:h,whiskerHigh:d}=e,f=Math.min(.5*n,20),g=(n-f)/2+4;if(c){const e=i(s),n=i(l),o=i(r),c=i(h),p=i(d),y="top"===t?-1:1,m=0;return u.createElement("g",{"data-testid":"marginal-boxplot-"+t},u.createElement("line",{x1:c,y1:m+y*(g+f/2),x2:p,y2:m+y*(g+f/2),stroke:a.fill,strokeWidth:a.strokeWidth}),u.createElement("line",{x1:c,y1:m+y*g,x2:c,y2:m+y*(g+f),stroke:a.fill,strokeWidth:a.strokeWidth}),u.createElement("line",{x1:p,y1:m+y*g,x2:p,y2:m+y*(g+f),stroke:a.fill,strokeWidth:a.strokeWidth}),u.createElement("rect",{x:Math.min(e,n),y:"top"===t?m-g-f:m+g,width:Math.abs(n-e),height:f,fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}),u.createElement("line",{x1:o,y1:"top"===t?m-g-f:m+g,x2:o,y2:"top"===t?m-g:m+g+f,stroke:a.fill,strokeWidth:2}))}{const e=i(s),n=i(l),o=i(r),c=i(h),p=i(d),y="left"===t?-1:1,m=0;return u.createElement("g",{"data-testid":"marginal-boxplot-"+t},u.createElement("line",{x1:m+y*(g+f/2),y1:c,x2:m+y*(g+f/2),y2:p,stroke:a.fill,strokeWidth:a.strokeWidth}),u.createElement("line",{x1:m+y*g,y1:c,x2:m+y*(g+f),y2:c,stroke:a.fill,strokeWidth:a.strokeWidth}),u.createElement("line",{x1:m+y*g,y1:p,x2:m+y*(g+f),y2:p,stroke:a.fill,strokeWidth:a.strokeWidth}),u.createElement("rect",{x:"left"===t?m-g-f:m+g,y:Math.min(e,n),width:f,height:Math.abs(n-e),fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}),u.createElement("line",{x1:"left"===t?m-g-f:m+g,y1:o,x2:"left"===t?m-g:m+g+f,y2:o,stroke:a.fill,strokeWidth:2}))}}const h=s.bin().domain(e).thresholds(a.bins)(o);if(0===h.length)return null;const d=Math.max(...h.map(e=>e.length));if(0===d)return null;if("histogram"===a.type)return u.createElement("g",{"data-testid":"marginal-histogram-"+t},h.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const s=e.length/d*n;if(c){const n=i(e.x0),r=i(e.x1)-i(e.x0);return u.createElement("rect",{key:o,x:n,y:"top"===t?-4-s:4,width:Math.max(r,.5),height:s,fill:a.fill,fillOpacity:a.fillOpacity,stroke:a.stroke,strokeWidth:a.strokeWidth})}{const n=i(e.x0),r=i(e.x1)-i(e.x0);return u.createElement("rect",{key:o,x:"left"===t?-4-s:4,y:Math.min(n,n+r),width:s,height:Math.abs(r),fill:a.fill,fillOpacity:a.fillOpacity,stroke:a.stroke,strokeWidth:a.strokeWidth})}}));if("violin"===a.type){const e=n/2+4,o=[];for(const s of h){if(null==s.x0||null==s.x1)continue;const r=s.length/d*(n/2),l=i((s.x0+s.x1)/2);o.push(c?`${l},${"top"===t?-(e-r):e-r}`:`${"left"===t?-(e-r):e-r},${l}`)}for(let s=h.length-1;s>=0;s--){const r=h[s];if(null==r.x0||null==r.x1)continue;const l=r.length/d*(n/2),a=i((r.x0+r.x1)/2);o.push(c?`${a},${"top"===t?-(e+l):e+l}`:`${"left"===t?-(e+l):e+l},${a}`)}return u.createElement("g",{"data-testid":"marginal-violin-"+t},u.createElement("polygon",{points:o.join(" "),fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}))}if("ridgeline"===a.type){const e=[];if(c){const o=0,s=null!=h[0].x0?i(h[0].x0):0;e.push(`M${s},${o}`);for(const o of h){if(null==o.x0||null==o.x1)continue;const s=o.length/d*n,r=i((o.x0+o.x1)/2);e.push(`L${r},${"top"===t?-s-4:s+4}`)}const r=null!=h[h.length-1].x1?i(h[h.length-1].x1):l;e.push(`L${r},${o}`),e.push("Z")}else{const o=0,s=null!=h[0].x0?i(h[0].x0):0;e.push(`M${o},${s}`);for(const o of h){if(null==o.x0||null==o.x1)continue;const s=o.length/d*n,r=i((o.x0+o.x1)/2);e.push(`L${"left"===t?-s-4:s+4},${r}`)}const r=null!=h[h.length-1].x1?i(h[h.length-1].x1):l;e.push(`L${o},${r}`),e.push("Z")}return u.createElement("g",{"data-testid":"marginal-ridgeline-"+t},u.createElement("path",{d:e.join(" "),fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}))}return null},[o,i,a,r,l,t,c,4]);return h?u.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},h):null}function P(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),s=e.split(/\s+/),i=[];let r="";for(const e of s)r&&r.length+1+e.length>o?(i.push(r),r=e):r=r?`${r} ${e}`:e;return r&&i.push(r),i}function T(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 D(e){const{x:t=0,y:n=0,dx:o,dy:s,nx:i,ny:r,note:l,connector:a,subject:c,type:h,color:d,className:f,disable:g,events:p={},"data-testid":y}=e,m=new Set(Array.isArray(g)?g:[]);let b=o||0,v=s||0;null!=i&&(b=i-t),null!=r&&(v=r-n);const x="string"==typeof h?h:"label";if("bracket"===x&&c&&0===b&&0===v)if(void 0!==c.width){b=c.width/2;const e=c.depth||30;v=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;b=e+(0>e?-5:5),v=c.height/2}return u.createElement("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${t},${n})`,"data-testid":y},p),!m.has("connector")&&function(e,t,n,o,s,i){const r=[];let l=0,a=0;if("callout-circle"!==s&&"label"!==s||!(null==i?void 0:i.radius)){if("callout-rect"===s&&i){const n=i.width||0,o=i.height||0;if(n>0||o>0){const s=n/2,i=o/2,r=e-s,c=t-i;if(0!==r||0!==c){const e=Math.abs(r),t=Math.abs(c),u=n/2,h=o/2,d=e*h>t*u?u/e:h/t;l=s+r*d,a=i+c*d}}}else if("bracket"===s&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(l=e/2,a=n):void 0!==t&&(l=n,a=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const o=Math.atan2(t,e);l=Math.cos(o)*n,a=Math.sin(o)*n}}if(Math.sqrt(Math.pow(e-l,2)+Math.pow(t-a,2))>.5&&(r.push(u.createElement("line",{key:"connector-line",x1:l,y1:a,x2:e,y2:t,stroke:o||"currentColor"})),"arrow"===(null==n?void 0:n.end))){const n=10,s=16/180*Math.PI,i=Math.atan2(t-a,e-l);r.push(u.createElement("path",{key:"connector-arrow",d:`M${l},${a}L${l+n*Math.cos(i+s)},${a+n*Math.sin(i+s)}L${l+n*Math.cos(i-s)},${a+n*Math.sin(i-s)}Z`,fill:o||"currentColor",stroke:"none"}))}return u.createElement("g",{className:"annotation-connector"},r)}(b,v,a,d,x,c),!m.has("subject")&&function(e,t,n,o,s){var i;const r=[];switch(e){case"callout-circle":{const e=((null==t?void 0:t.radius)||0)+((null==t?void 0:t.radiusPadding)||0);e>0&&r.push(u.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)&&r.push(u.createElement("rect",{key:"subject-rect",width:e,height:o,fill:"none",stroke:n||"currentColor"}));break}case"callout-custom":(null==t?void 0:t.custom)&&r.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=o||0,i=s||0;if(void 0!==(null==t?void 0:t.x)){const o=(t.x||0)-e;r.push(u.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;r.push(u.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)?r.push(u.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)||r.push(u.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&&r.push(u.createElement("path",{key:"bracket-path",d:T((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 u.createElement("g",{className:"annotation-subject"},r)}(x,c,d,t,n),!m.has("note")&&function(e,t,n,o){if(!e)return u.createElement("g",{className:"annotation-note"});const{label:s,title:i,orientation:r,align:l,wrap:a=120,noWrap:c}=e;if(!s&&!i)return u.createElement("g",{className:"annotation-note"});let h=r;h||(h=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=l;d&&"dynamic"!==d||(d="topBottom"===h?0>t?"right":"left":0>n?"bottom":"top");let f="start";"topBottom"===h?"right"===d?f="end":"middle"===d&&(f="middle"):f=0>t?"end":"start";const g=16,p=i?c?[i]:P(i,a):[],y=s?c?[s]:P(s,a):[],m="leftRight"===h?"end"===f?-4:4:0;let b=0;const v=[];p.length>0&&(v.push(u.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:o||void 0,textAnchor:f,fontWeight:"bold"},p.map((e,t)=>u.createElement("tspan",{key:t,x:m,dy:0===t?0:g},e)))),b=p.length*g),y.length>0&&v.push(u.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:o||void 0,textAnchor:f,y:b},y.map((e,t)=>u.createElement("tspan",{key:t,x:m,dy:0===t?0:g},e))));let x=null;if((i||s)&&(0!==t||0!==n))if("topBottom"===h){const e=Math.min(a,120);let t=0,n=e;"end"===f?(t=-e,n=0):"middle"===f&&(t=-e/2,n=e/2),x=u.createElement("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"currentColor"})}else{const e=(p.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=u.createElement("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:o||"currentColor"})}const k=Math.max(0,p.length+y.length-1)*g;let w=0;return"topBottom"===h?w=0>n?-(k+2):18:"leftRight"===h&&(w="middle"===d?-(k+g+(y.length>0&&p.length>0?2:0))/2+8:"bottom"===d||0>n?-(k+2):18),u.createElement("g",{className:"annotation-note",transform:`translate(${t},${n})`},u.createElement("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0},v),x)}(l,b,v,d))}function R(e){var t,n;const{noteData:o}=e,{screenCoordinates:s}=o,i="string"==typeof o.type?o.type:"label",r=o.eventListeners||o.events||{};if(o.coordinates&&s){const e=o.nx||s[0][0]+(null!==(t=o.dx)&&void 0!==t?t:0),r=o.ny||s[0][1]+(null!==(n=o.dy)&&void 0!==n?n:0),l=s.map((t,n)=>{const s=Object.assign({},o,{note:0===n?o.note:{label:""},x:t[0],y:t[1],nx:e,ny:r});return u.createElement(D,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},s,{type:i}))});return u.createElement("g",null,l)}const l=o.note||{title:"none",label:o.label};return u.createElement(D,Object.assign({"data-testid":"semiotic-annotation",key:`${l.label}-${l.title}-${o.i}`,events:r},o,{type:i}))}function Y(e,t){var n,o,s;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(s=t.scales)||void 0===s?void 0:s.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function G(e,t){var n,o,s;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(s=t.scales)||void 0===s?void 0:s.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function X(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function q(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,s="left"===e?-1:1,i=Math.ceil(t/8);let r="M0,"+o;for(let e=0;i>e;e++){const n=8*(e+1);r+=`L${Math.min(8*e+4,t)},${o+4*s}`,r+=`L${Math.min(n,t)},${o}`}return r}{const o="bottom"===e?0:t,s="bottom"===e?1:-1,i=Math.ceil(n/8);let r=`M${o},0`;for(let e=0;i>e;e++){const t=8*(e+1);r+=`L${o+4*s},${Math.min(8*e+4,n)}`,r+=`L${o},${Math.min(t,n)}`}return r}}function V(e){return Math.round(100*e)/100+""}function U(e,t){return e instanceof Date&&(!(t&&t instanceof Date)||e.getFullYear()!==t.getFullYear()||e.getMonth()!==t.getMonth()||e.getDate()!==t.getDate())}function Z(t){const{width:n,height:o,totalWidth:s,totalHeight:r,margin:l,scales:a,showAxes:c,axes:d,xLabel:f,yLabel:g,xFormat:p,yFormat:y,showGrid:m,title:b,legend:v,legendHoverBehavior:x,legendClickBehavior:k,legendHighlightedCategory:w,legendIsolatedCategories:A,foregroundGraphics:E,marginalGraphics:S,xValues:M,yValues:O,annotations:C,svgAnnotationRules:L,annotationFrame:j,xAccessor:N,yAccessor:B,annotationData:H,pointNodes:_,children:W}=t,$=e.useMemo(()=>c&&a?a.x.ticks(5).map(e=>({value:e,pixel:a.x(e),label:(p||V)(e)})):[],[c,a,p]),P=e.useMemo(()=>c&&a?a.y.ticks(5).map(e=>({value:e,pixel:a.y(e),label:(y||V)(e)})):[],[c,a,y]),T=e.useMemo(()=>{if(!C||0===C.length)return null;const e=function(e,t,n){var o,s,r,l,a,c,d,f,g,p,y,m,b,v,x,k,w,A,E,S,M,O,C,L,j,N,B,H,_,W,$,z,I,F,P,T,D,q,V,U,Z,J,K,Q;switch(e.type){case"label":{let o=null,s=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);if(!t)return null;o=t.x,s=t.y}else o=Y(e,n),s=G(e,n);return null==o||null==s?null:X(o,s,n)?u.createElement(R,{key:"ann-"+t,noteData:{x:o,y:s,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"label",connector:e.connector||{end:"arrow"},color:e.color}}):null}case"callout":{let o=null,s=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);if(!t)return null;o=t.x,s=t.y}else o=Y(e,n),s=G(e,n);return null==o||null==s?null:X(o,s,n)?u.createElement(R,{key:"ann-"+t,noteData:{x:o,y:s,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"callout-circle",subject:{radius:e.radius||12},connector:e.connector||{end:"arrow"},color:e.color}}):null}case"x-threshold":{const o=Y(e,n);if(null==o)return null;const s=e.color||"#f97316";return u.createElement("g",{key:"ann-"+t},u.createElement("line",{x1:o,y1:0,x2:o,y2:n.height||0,stroke:s,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&u.createElement("text",{x:o+4,y:12,fill:s,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const o=G(e,n);if(null==o)return null;const s=e.color||"#f97316";return u.createElement("g",{key:"ann-"+t},u.createElement("line",{x1:0,y1:o,x2:n.width||0,y2:o,stroke:s,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&u.createElement("text",{x:(n.width||0)-4,y:o-4,textAnchor:"end",fill:s,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const o=(e.coordinates||[]).map(e=>({x:Y(Object.assign(Object.assign({},e),{type:"point"}),n),y:G(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 s=i.packEnclose(o),r=e.padding||10;return u.createElement("g",{key:"ann-"+t},u.createElement("circle",{cx:s.x,cy:s.y,r:s.r+r,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&u.createElement("text",{x:s.x,y:s.y-s.r-r-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"rect-enclose":{const o=(e.coordinates||[]).map(e=>({x:Y(Object.assign(Object.assign({},e),{type:"point"}),n),y:G(Object.assign(Object.assign({},e),{type:"point"}),n)})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const s=e.padding||10,i=o.map(e=>e.x),r=o.map(e=>e.y),l=Math.min(...i)-s,a=Math.max(...i)+s,c=Math.min(...r)-s,h=Math.max(...r)+s;return u.createElement("g",{key:"ann-"+t},u.createElement("rect",{x:l,y:c,width:a-l,height:h-c,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&u.createElement("text",{x:(l+a)/2,y:c-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"highlight":{const o=n.data||[],s="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 u.createElement("g",{key:"ann-"+t},s.map((t,o)=>{const s=Y(t,n),r=G(t,n);return null==s||null==r?null:u.createElement("circle",Object.assign({key:o,cx:s,cy:r,r:e.r||6},i))}))}case"bracket":{const o=Y(e,n),s=G(e,n);return u.createElement(R,{key:"ann-"+t,noteData:{x:null!=o?o:0,y:null!=s?s: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 f=n.xAccessor||"x",g=n.yAccessor||"y",p=i.map(e=>[e[f],e[g]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>p.length)return null;const y=null!==(s=null===(o=n.scales)||void 0===o?void 0:o.x)&&void 0!==s?s:null===(r=n.scales)||void 0===r?void 0:r.time,m=null!==(a=null===(l=n.scales)||void 0===l?void 0:l.y)&&void 0!==a?a:null===(c=n.scales)||void 0===c?void 0:c.value;if(!y||!m)return null;const b=e.method||"linear";let v;v="loess"===b?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]),s=o.map(e=>e[0]),i=o.map(e=>e[1]),r=Math.max(2,Math.ceil(t*n)),l=[];for(let e=0;n>e;e++){const t=s[e],o=s.map(e=>Math.abs(e-t)),a=o.slice().sort((e,t)=>e-t)[Math.min(r-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===a?0:o[e]/a;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,h=0,d=0,f=0,g=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,h+=t*s[e],d+=t*i[e],f+=t*s[e]*s[e],g+=t*s[e]*i[e])}if(0===u){l.push([t,i[e]]);continue}const p=u*f-h*h;if(1e-12>Math.abs(p))l.push([t,d/u]);else{const e=(u*g-h*d)/p;l.push([t,(d-e*h)/u+e*t])}}return l}(p,null!==(d=e.bandwidth)&&void 0!==d?d:.3):("polynomial"===b?h.default.polynomial(p,{order:e.order||2}):h.default.linear(p)).points;const x=v.map(([e,t])=>`${y(e)},${m(t)}`).join(" "),k=e.color||"#6366f1";return u.createElement("g",{key:"ann-"+t},u.createElement("polyline",{points:x,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&u.createElement("text",{x:y(v[v.length-1][0])+4,y:m(v[v.length-1][1])-4,fill:k,fontSize:11},e.label))}case"band":{const o=null!==(g=null===(f=n.scales)||void 0===f?void 0:f.y)&&void 0!==g?g:null===(p=n.scales)||void 0===p?void 0:p.value,s=null!==(y=null==o?void 0:o(e.y0))&&void 0!==y?y:0,i=null!==(m=null==o?void 0:o(e.y1))&&void 0!==m?m:n.height||0;return u.createElement("g",{key:"ann-"+t},u.createElement("rect",{x:0,y:Math.min(s,i),width:n.width||0,height:Math.abs(i-s),fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity||.1}),e.label&&u.createElement("text",{x:(n.width||0)-4,y:Math.min(s,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 s=n.xAccessor||"x",i=null!==(v=null===(b=n.scales)||void 0===b?void 0:b.x)&&void 0!==v?v:null===(x=n.scales)||void 0===x?void 0:x.time,r=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||!r)return null;const l=e.upperAccessor||"upperBounds",a=e.lowerAccessor||"lowerBounds",c=e.filter,h=o.filter(e=>null!=e[l]&&null!=e[a]&&!(c&&!c(e))).sort((e,t)=>e[s]-t[s]);if(2>h.length)return null;const d=h.map(e=>`${i(e[s])},${r(e[l])}`).join(" L"),f=h.slice().reverse().map(e=>`${i(e[s])},${r(e[a])}`).join(" L"),g=e.fill||"#6366f1";return u.createElement("g",{key:"ann-"+t},u.createElement("path",{d:`M${d} L${f} Z`,fill:g,fillOpacity:null!==(E=e.fillOpacity)&&void 0!==E?E:.15,stroke:"none"}),e.label&&h.length>0&&u.createElement("text",{x:i(h[h.length-1][s])+4,y:r(h[h.length-1][l])-4,fill:g,fontSize:11},e.label))}case"anomaly-band":{const o=n.data||[];if(2>o.length)return null;const s=n.yAccessor||"y",i=null!==(M=null===(S=n.scales)||void 0===S?void 0:S.x)&&void 0!==M?M:null===(O=n.scales)||void 0===O?void 0:O.time,r=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||!r)return null;const l=o.map(e=>e[s]).filter(e=>null!=e&&isFinite(e));if(2>l.length)return null;const a=l.reduce((e,t)=>e+t,0)/l.length,c=l.reduce((e,t)=>e+Math.pow(t-a,2),0)/l.length,h=Math.sqrt(c),d=null!==(N=e.threshold)&&void 0!==N?N:2,f=a-d*h,g=!1!==e.showBand,p=e.fill||"#6366f1",y=null!==(B=e.fillOpacity)&&void 0!==B?B:.1,m=e.anomalyColor||"#ef4444",b=null!==(H=e.anomalyRadius)&&void 0!==H?H:6,v=r(a+d*h),x=r(f),k=o.filter(e=>{const t=e[s];return null!=t&&Math.abs(t-a)>d*h});return u.createElement("g",{key:"ann-"+t},g&&u.createElement("rect",{x:0,y:Math.min(v,x),width:n.width||0,height:Math.abs(x-v),fill:p,fillOpacity:y}),k.map((e,t)=>{const o=Y(e,n),s=G(e,n);return null==o||null==s?null:u.createElement("circle",{key:t,cx:o,cy:s,r:b,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5})}),e.label&&u.createElement("text",{x:(n.width||0)-4,y:Math.min(v,x)-4,textAnchor:"end",fill:p,fontSize:11},e.label))}case"forecast":{const o=n.data||[];if(3>o.length)return null;const s=n.xAccessor||"x",i=n.yAccessor||"y",r=null!==(W=null===(_=n.scales)||void 0===_?void 0:_.x)&&void 0!==W?W:null===($=n.scales)||void 0===$?void 0:$.time,l=null!==(I=null===(z=n.scales)||void 0===z?void 0:z.y)&&void 0!==I?I:null===(F=n.scales)||void 0===F?void 0:F.value;if(!r||!l)return null;const a=o.map(e=>[e[s],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>a.length)return null;let c;if("polynomial"===(e.method||"linear")){const t=h.default.polynomial(a,{order:e.order||2}).equation;c=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}else{const e=a.length;let t=0,n=0,o=0,s=0;for(const[e,i]of a)t+=e,n+=i,o+=e*e,s+=e*i;const i=e*o-t*t;if(1e-12>Math.abs(i))return null;const r=(e*s-t*n)/i,l=(n-r*t)/e;c=e=>l+r*e}const d=a.length,f=a.map(([e,t])=>t-c(e)).reduce((e,t)=>e+t*t,0),g=Math.sqrt(f/Math.max(d-2,1)),p=a.reduce((e,t)=>e+t[0],0)/d,y=a.reduce((e,t)=>e+Math.pow(t[0]-p,2),0),m=null!==(P=e.confidence)&&void 0!==P?P:.95,b=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,v=null!==(T=e.steps)&&void 0!==T?T:5,x=a[d-1][0],k=(x-a[0][0])/Math.max(d-1,1),w=[];for(let e=1;v>=e;e++)w.push(x+e*k);const A=[];for(const e of w){const t=c(e),n=g*Math.sqrt(1+1/d+(y>0?Math.pow(e-p,2)/y:0))*b;A.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const E=`M${A.map(e=>`${r(e.x)},${l(e.yUpper)}`).join(" L")} L${A.slice().reverse().map(e=>`${r(e.x)},${l(e.yLower)}`).join(" L")} Z`,S=A.map(e=>`${r(e.x)},${l(e.yCenter)}`).join(" "),M=`${r(x)},${l(c(x))}`,O=e.strokeColor||"#6366f1";return u.createElement("g",{key:"ann-"+t},u.createElement("path",{d:E,fill:e.fill||"#6366f1",fillOpacity:null!==(D=e.fillOpacity)&&void 0!==D?D:.15,stroke:"none"}),u.createElement("polyline",{points:`${M} ${S}`,fill:"none",stroke:O,strokeWidth:null!==(q=e.strokeWidth)&&void 0!==q?q:2,strokeDasharray:null!==(V=e.strokeDasharray)&&void 0!==V?V:"6,3"}),e.label&&A.length>0&&u.createElement("text",{x:r(A[A.length-1].x)+4,y:l(A[A.length-1].yCenter)-4,fill:O,fontSize:11},e.label))}case"widget":{let o=null,s=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);if(!t)return null;o=t.x,s=t.y}else null!=e.px&&null!=e.py?(o=e.px,s=e.py):(o=Y(e,n),s=G(e,n));if(null==o||null==s)return null;if(!X(o,s,n))return null;const i=null!==(U=e.dx)&&void 0!==U?U:0,r=null!==(Z=e.dy)&&void 0!==Z?Z:0,l=null!==(J=e.width)&&void 0!==J?J:32,a=null!==(K=e.height)&&void 0!==K?K:32,c=null!==(Q=e.content)&&void 0!==Q?Q:u.createElement("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info"},"ℹ️");return u.createElement("foreignObject",{key:"ann-"+t,x:o+i-l/2,y:s+r-a/2,width:l,height:a,style:{overflow:"visible",pointerEvents:"auto"}},u.createElement("div",{style:{width:l,height:a,display:"flex",alignItems:"center",justifyContent:"center"}},c))}case"text":{const o=Y(e,n),s=G(e,n);return null==o||null==s?null:u.createElement("text",{key:"ann-text-"+t,x:o+(e.dx||0),y:s+(e.dy||0),fill:e.color||"var(--semiotic-text, #333)",fontSize:e.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},e.label)}default:return null}},t={scales:a?{x:a.x,y:a.y,time:a.x,value:a.y}:null,timeAxis:"x",xAccessor:N,yAccessor:B,width:n,height:o,data:H,frameType:"xy",pointNodes:_};return C.map((n,o)=>{if(L){const s=L(n,o,t);return null!=s?s:e(n,o,t)}return e(n,o,t)}).filter(Boolean)},[C,L,n,o,j,N,B,H]);return c||b||v||E||S||T&&T.length>0||m||W?u.createElement("svg",{width:s,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},u.createElement("g",{transform:`translate(${l.left},${l.top})`},m&&a&&u.createElement("g",{className:"stream-grid"},$.map((e,t)=>u.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),P.map((e,t)=>u.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:n,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),c&&a&&(()=>{const e=null==d?void 0:d.find(e=>"left"===e.orient),t=null==d?void 0:d.find(e=>"bottom"===e.orient),s=!e||!1!==e.baseline,i=(null==e?void 0:e.jaggedBase)||!1,r=(null==t?void 0:t.jaggedBase)||!1,a=null==t?void 0:t.landmarkTicks,c=null==e?void 0:e.landmarkTicks,h="var(--semiotic-border, #ccc)",p="var(--semiotic-text-secondary, #666)",y="var(--semiotic-text, #333)";return u.createElement("g",{className:"stream-axes"},(!t||!1!==t.baseline)&&!r&&u.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:h,strokeWidth:1}),r&&u.createElement("path",{d:q("bottom",n,o),fill:"none",stroke:h,strokeWidth:1}),$.map((e,t)=>{const n=!!a&&("function"==typeof a?a(e.value,t):U(e.value,t>0?$[t-1].value:void 0));return u.createElement("g",{key:"xtick-"+t,transform:`translate(${e.pixel},${o})`},u.createElement("line",{y2:5,stroke:h,strokeWidth:1}),u.createElement("text",{y:18,textAnchor:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:p,style:{userSelect:"none"}},e.label))}),f&&u.createElement("text",{x:n/2,y:o+40,textAnchor:"middle",fontSize:12,fill:y,style:{userSelect:"none"}},f),s&&!i&&u.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:h,strokeWidth:1}),i&&u.createElement("path",{d:q("left",n,o),fill:"none",stroke:h,strokeWidth:1}),P.map((e,t)=>{const n=!!c&&("function"==typeof c?c(e.value,t):U(e.value,t>0?P[t-1].value:void 0));return u.createElement("g",{key:"ytick-"+t,transform:`translate(0,${e.pixel})`},u.createElement("line",{x2:-5,stroke:h,strokeWidth:1}),u.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:p,style:{userSelect:"none"}},e.label))}),g&&u.createElement("text",{x:15-l.left,y:o/2,textAnchor:"middle",fontSize:12,fill:y,transform:`rotate(-90, ${15-l.left}, ${o/2})`,style:{userSelect:"none"}},g))})(),T,S&&a&&M&&O&&u.createElement(u.Fragment,null,S.top&&u.createElement("g",{transform:"translate(0, 0)"},u.createElement(F,{orient:"top",config:I(S.top),values:M,scale:a.x,size:l.top,length:n})),S.bottom&&u.createElement("g",{transform:`translate(0, ${o})`},u.createElement(F,{orient:"bottom",config:I(S.bottom),values:M,scale:a.x,size:l.bottom,length:n})),S.left&&u.createElement("g",{transform:"translate(0, 0)"},u.createElement(F,{orient:"left",config:I(S.left),values:O,scale:a.y,size:l.left,length:o})),S.right&&u.createElement("g",{transform:`translate(${n}, 0)`},u.createElement(F,{orient:"right",config:I(S.right),values:O,scale:a.y,size:l.right,length:o}))),E,W),b&&u.createElement("text",{x:s/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof b?b:null),v&&u.createElement("g",{transform:`translate(${s-l.right+10}, ${l.top})`},"object"==typeof(D=v)&&null!==D&&!u.isValidElement(D)&&"legendGroups"in D?u.createElement(z,{legendGroups:v.legendGroups,title:"",width:100,customHoverBehavior:x,customClickBehavior:k,highlightedCategory:w,isolatedCategories:A}):v)):null;var D}const J="undefined"==typeof window||"undefined"==typeof document;function K(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}function Q(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 ee(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 te=(e,t,n,o)=>{var s;const i=t.filter(e=>"area"===e.type);for(const t of i){if(2>t.topPath.length)continue;ee(e,t);const n=t.style.fill||"#4e79a7";if(t.fillGradient){const o=Math.min(...t.topPath.map(e=>e[1])),s=Math.max(...t.bottomPath.map(e=>e[1])),i=e.createLinearGradient(0,o,0,s);i.addColorStop(0,n),i.addColorStop(1,n),e.fillStyle=i;const r=Q(n),l=t.fillGradient.topOpacity,a=t.fillGradient.bottomOpacity,c=e.createLinearGradient(0,o,0,s);c.addColorStop(0,`rgba(${r[0]},${r[1]},${r[2]},${l})`),c.addColorStop(1,`rgba(${r[0]},${r[1]},${r[2]},${a})`),e.fillStyle=c,e.globalAlpha=1}else{const o=null!==(s=t.style.fillOpacity)&&void 0!==s?s:.7;e.globalAlpha=o,e.fillStyle=n}if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(ee(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}},ne=(e,t,n,o)=>{var s,i;const r=t.filter(e=>"point"===e.type);for(const t of r){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(s=t.style.opacity)&&void 0!==s?s: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}},oe=(e,t,n,o)=>{const s=t.filter(e=>"rect"===e.type);for(const t of s)null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon?se(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 se(e,t){const n=t.style.icon,o=t.style.iconPadding||2,s=Math.min(t.w,t.w)-o;if(0>=s)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=s+o,r=t.x+(t.w-s)/2;for(let o=t.y+t.h-s;o>=t.y-s;o-=i)e.drawImage(n,r,o,s,s)}else{const i=s+o,r=t.y+(t.h-s)/2;for(let o=t.x;t.x+t.w>o;o+=i)e.drawImage(n,o,r,s,s)}e.restore()}const ie={line:[te,(e,t,n,o)=>{const s=t.filter(e=>"line"===e.type);for(const i of s){if(2>i.path.length)continue;const r=i.style.stroke||"#007bff",l=i.style.strokeWidth||2,a=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=l,a&&0!==a.length&&c&&c.length===i.path.length){let u=null,h=null,d=null,f=null,g=!1;function p(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),g=!0}function y(){g&&(e.stroke(),g=!1)}for(let m=0;i.path.length>m;m++){const[b,v]=i.path[m],x=c[m],k=K(x,a,r);if(null!==u&&null!==f&&null!==d){if(k===f)e.lineTo(b,v);else{const w=[];for(const A of a){const E=A.value;(d>E||E>x)&&(E>d||x>E)||d===E||x===E||w.push({t:(E-d)/(x-d)})}w.sort((e,t)=>e.t-t.t);for(const S of w){const M=u+(b-u)*S.t,O=h+(v-h)*S.t,C=K(d+(x-d)*Math.min(S.t+1e-4,1),a,r);e.lineTo(M,O),y(),p(C,M,O)}e.lineTo(b,v)}u=b,h=v,d=x,f=k}else p(k,b,v),u=b,h=v,d=x,f=k}y()}else{e.beginPath(),e.strokeStyle=r;const[L,j]=i.path[0];e.moveTo(L,j);for(let N=1;i.path.length>N;N++)e.lineTo(i.path[N][0],i.path[N][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[B,H]=i.path[0];e.moveTo(B,H);for(let W=1;i.path.length>W;W++)e.lineTo(i.path[W][0],i.path[W][1]);const _=i.path[0][0];e.lineTo(i.path[i.path.length-1][0],o.height),e.lineTo(_,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([])}}],area:[te],stackedarea:[te],scatter:[ne],bubble:[ne],heatmap:[(e,t,n,o)=>{const s=t.filter(e=>"heatcell"===e.type);for(const t of s){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:[oe],swarm:[ne],waterfall:[(e,t,n,o)=>{var s,i,r;oe(e,t);const l=t.filter(e=>"rect"===e.type);if(2>l.length)return;const a=l[0].datum,c=null==a?void 0:a._connectorStroke;if(c){e.save(),e.strokeStyle=c,e.lineWidth=null!==(s=null==a?void 0:a._connectorWidth)&&void 0!==s?s:1,e.setLineDash([]);for(let t=0;l.length-1>t;t++){const o=l[t],s=l[t+1];if(!(null===(i=o.datum)||void 0===i?void 0:i.cumEnd)||!(null===(r=s.datum)||void 0===r?void 0:r.baseline))continue;const a=n.y(o.datum.cumEnd),c=o.x+o.w,u=s.x;e.beginPath(),e.moveTo(c,a),e.lineTo(u,a),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),s=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(s,1)),e.strokeStyle=i,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(s,1))}}]},re={top:20,right:20,bottom:30,left:40},le={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"},ae={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 ce({hover:e}){const t=e=>Number.isInteger(e)?e+"":e.toFixed(2);return u.createElement("div",{className:"semiotic-tooltip",style:ae},u.createElement("div",{style:{fontWeight:600,marginBottom:2}},t(e.value)),u.createElement("div",{style:{opacity:.7,fontSize:11}},t(e.time)))}function ue({width:o,height:s,totalWidth:i,totalHeight:r,margin:l,dimension:a,scales:c,onBrush:h}){const d=e.useRef(null),f=e.useRef(null),g=e.useRef(h);g.current=h;const p=e.useRef(c);return p.current=c,e.useEffect(()=>{if(!d.current)return;const e=n.select(d.current).select(".brush-g"),i="x"===a?t.brushX():"y"===a?t.brushY():t.brush();return i.extent([[0,0],[o,s]]),i.on("brush end",e=>{const t=p.current;if(!t)return;if(!e.selection)return void g.current(null);let n,i;if("x"===a){const[o,r]=e.selection;n=[t.x.invert(o),t.x.invert(r)],i=[t.y.invert(s),t.y.invert(0)]}else if("y"===a){const[s,r]=e.selection;n=[t.x.invert(0),t.x.invert(o)],i=[t.y.invert(r),t.y.invert(s)]}else{const[[o,s],[r,l]]=e.selection;n=[t.x.invert(o),t.x.invert(r)],i=[t.y.invert(l),t.y.invert(s)]}g.current({x:n,y:i})}),e.call(i),f.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),f.current=null}},[o,s,a]),u.createElement("svg",{ref:d,width:i,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},u.createElement("g",{className:"brush-g",transform:`translate(${l.left},${l.top})`}))}const he=e.forwardRef(function(t,n){var o,s,i,r,l;const{chartType:a,runtimeMode:c,data:h,xAccessor:d,yAccessor:g,colorAccessor:p,sizeAccessor:y,groupAccessor:m,lineDataAccessor:b,normalize:v,binSize:x,valueAccessor:k,arrowOfTime:w="right",windowMode:A="sliding",windowSize:S=200,timeAccessor:B,xExtent:H,yExtent:_,extentPadding:W=.1,sizeRange:$,size:z=[500,300],responsiveWidth:I,responsiveHeight:F,margin:P,className:T,background:D,lineStyle:R,pointStyle:Y,areaStyle:G,waterfallStyle:X,swarmStyle:q,barColors:V,colorScheme:U,boundsAccessor:K,boundsStyle:Q,y0Accessor:ee,gradientFill:te,openAccessor:ne,highAccessor:oe,lowAccessor:se,closeAccessor:ae,candlestickStyle:he,showAxes:de=!0,axes:fe,xLabel:ge,yLabel:pe,xFormat:ye,yFormat:me,tickFormatTime:be,tickFormatValue:ve,hoverAnnotation:xe,tooltipContent:ke,customHoverBehavior:we,enableHover:Ae,annotations:Ee,svgAnnotationRules:Se,showGrid:Me,legend:Oe,legendHoverBehavior:Ce,legendClickBehavior:Le,legendHighlightedCategory:je,legendIsolatedCategories:Ne,backgroundGraphics:Be,foregroundGraphics:He,title:_e,categoryAccessor:We,brush:$e,onBrush:ze,decay:Ie,pulse:Fe,transition:Pe,staleness:Te,heatmapAggregation:De,heatmapXBins:Re,heatmapYBins:Ye,marginalGraphics:Ge,pointIdAccessor:Xe}=t,[qe,Ve]=function(t,n,o){const s=e.useRef(null),[i,r]=e.useState(null);return e.useEffect(()=>{if(!n&&!o)return;const e=s.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;r(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[n,o]),[s,[n&&i?i.w:t[0],o&&i?i.h:t[1]]]}(z,I,F),Ue=Object.assign(Object.assign({},re),P);if(Ge){const e=60;Ge.top&&e>Ue.top&&(Ue.top=e),Ge.bottom&&e>Ue.bottom&&(Ue.bottom=e),Ge.left&&e>Ue.left&&(Ue.left=e),Ge.right&&e>Ue.right&&(Ue.right=e)}const Ze=Ve[0]-Ue.left-Ue.right,Je=Ve[1]-Ue.top-Ue.bottom,Ke=null!=xe?xe:Ae,Qe=e.useRef(null),et=e.useRef(null),tt=e.useRef(0),nt=e.useRef(!1),[ot,st]=e.useState(0),[it,rt]=e.useState(null),lt=e.useRef(null),at=e.useRef(null),[ct,ut]=e.useState(null),[ht,dt]=e.useState(!1),[ft,gt]=e.useState([]),[pt,yt]=e.useState([]),mt=e.useRef(()=>{}),bt="streaming"===c||["bar","swarm","waterfall"].includes(a),vt=e.useMemo(()=>({chartType:a,runtimeMode:bt?"streaming":"bounded",windowSize:S,windowMode:A,arrowOfTime:bt?w:"right",extentPadding:W,xAccessor:bt?void 0:d,yAccessor:bt?void 0:g,timeAccessor:bt?B:void 0,valueAccessor:k,colorAccessor:p,sizeAccessor:y,groupAccessor:m,categoryAccessor:We,lineDataAccessor:b,xExtent:H,yExtent:_,sizeRange:$,binSize:x,normalize:v,boundsAccessor:K,boundsStyle:Q,y0Accessor:ee,gradientFill:"boolean"==typeof te?te?{topOpacity:.8,bottomOpacity:.05}:void 0:te,openAccessor:ne,highAccessor:oe,lowAccessor:se,closeAccessor:ae,candlestickStyle:he,lineStyle:R,pointStyle:Y,areaStyle:G,swarmStyle:q,waterfallStyle:X,colorScheme:U,barColors:V,annotations:Ee,decay:Ie,pulse:Fe,transition:Pe,staleness:Te,heatmapAggregation:De,heatmapXBins:Re,heatmapYBins:Ye,pointIdAccessor:Xe}),[a,S,A,w,W,d,g,B,k,p,y,m,We,b,H,_,$,x,v,K,Q,ee,te,ne,oe,se,ae,he,R,Y,G,q,X,U,V,Ee,Ie,Fe,Pe,Te,De,Re,Ye,bt,Xe]),xt=e.useRef(null);xt.current||(xt.current=new E(vt));const kt=e.useCallback(()=>{tt.current||(tt.current=requestAnimationFrame(()=>mt.current()))},[]);e.useEffect(()=>{var e;null===(e=xt.current)||void 0===e||e.updateConfig(vt),nt.current=!0,kt()},[vt,kt]);const wt=e.useRef(null);wt.current||(wt.current=new f(e=>{const t=xt.current;t&&t.ingest(e)&&(nt.current=!0,kt())}));const At=e.useCallback(e=>{var t;null===(t=wt.current)||void 0===t||t.push(e)},[]),Et=e.useCallback(e=>{var t;null===(t=wt.current)||void 0===t||t.pushMany(e)},[]),St=e.useCallback(()=>{var e,t;null===(e=wt.current)||void 0===e||e.clear(),null===(t=xt.current)||void 0===t||t.clear(),nt.current=!0,kt()},[kt]);e.useImperativeHandle(n,()=>({push:At,pushMany:Et,clear:St,getData:()=>{var e,t;return null!==(t=null===(e=xt.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=xt.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=xt.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[At,Et,St]),e.useEffect(()=>{var e;h&&(null===(e=wt.current)||void 0===e||e.setBoundedData(h))},[h]);const Mt=e.useRef(()=>{}),Ot=e.useRef(()=>{});Mt.current=e=>{if(!Ke)return;const t=Qe.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Ue.left,s=e.clientY-n.top-Ue.top;if(0>o||o>Ze||0>s||s>Je)return void(lt.current&&(lt.current=null,at.current=null,ut(null),we&&(we(null),nt.current=!0),kt()));const i=xt.current;if(!i||0===i.scene.length)return;const r=function(e,t,n,o=30){let s=null;for(const i of e){let e=null;switch(i.type){case"point":e=M(i,t,n);break;case"line":e=O(i,t,n);break;case"rect":e=C(i,t,n);break;case"heatcell":e=L(i,t,n);break;case"area":if(!1===i.interactive)break;e=N(i,t,n);break;case"candlestick":e=j(i,t,n)}e&&o>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}(i.scene,o,s);if(!r)return void(lt.current&&(lt.current=null,at.current=null,ut(null),we&&we(null),kt()));const l={data:r.datum,time:r.x,value:r.y,x:r.x,y:r.y};lt.current=l,at.current=r.node,ut(l),we&&(we(l),nt.current=!0),kt()},Ot.current=()=>{lt.current&&(lt.current=null,at.current=null,ut(null),we&&(we(null),nt.current=!0),kt())},e.useCallback(e=>Mt.current(e),[]);const Ct=e.useCallback(()=>Ot.current(),[]),Lt=e.useRef(-1),jt=e.useCallback(e=>{const t=xt.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>Lt.current?-1:Lt.current,s=function(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}}(e.key,0>o?-1:o,n.length);if(null===s)return;if(e.preventDefault(),0>s)return Lt.current=-1,lt.current=null,at.current=null,ut(null),we&&we(null),void kt();const i=0>o?0:s;Lt.current=i;const r={data:(l=n[i]).datum,x:l.x,y:l.y,time:l.x,value:l.y};var l;lt.current=r,ut(r),we&&we(r),kt()},[we,kt]),Nt=e.useCallback(e=>{Lt.current=-1,Mt.current(e)},[]);mt.current=()=>{var e,t;tt.current=0;const n=Qe.current,o=et.current;if(!n||!o)return;const s=xt.current;if(!s)return;const i="undefined"!=typeof performance?performance.now():Date.now(),r=s.advanceTransition(i),l=nt.current||r;l&&!r&&s.computeScene({width:Ze,height:Je});const c="undefined"!=typeof window&&window.devicePixelRatio||1,u=function(e){if(!e)return le;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),s=t.getPropertyValue("--semiotic-bg").trim(),i=o||t.getPropertyValue("--text-secondary").trim(),r=t.getPropertyValue("--text-primary").trim(),l=n||t.getPropertyValue("--surface-3").trim(),a=s||t.getPropertyValue("--surface-0").trim();return i||r||n?{axisStroke:l||le.axisStroke,tickText:i||le.tickText,crosshair:i?i+"66":le.crosshair,hoverFill:a?a+"4D":le.hoverFill,hoverStroke:i?i+"99":le.hoverStroke,pointRing:a||le.pointRing}:le}(n),h=null!==(e=null==Te?void 0:Te.threshold)&&void 0!==e?e:5e3,f=Te&&s.lastIngestTime>0&&i-s.lastIngestTime>h;if(l){const e=n.getContext("2d");if(e){n.width=Ve[0]*c,n.height=Ve[1]*c,n.style.width=Ve[0]+"px",n.style.height=Ve[1]+"px",e.scale(c,c),e.translate(Ue.left,Ue.top),e.clearRect(-Ue.left,-Ue.top,Ve[0],Ve[1]),f&&(e.globalAlpha=null!==(t=null==Te?void 0:Te.dimOpacity)&&void 0!==t?t:.5);const o=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=D||(o&&"transparent"!==o?o:null);i&&(e.fillStyle=i,e.fillRect(-Ue.left,-Ue.top,Ve[0],Ve[1])),e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,Ze,Je),e.clip());const r=ie[a];if(r&&s.scales)for(const t of r)t(e,s.scene,s.scales,{width:Ze,height:Je});e.restore(),f&&(e.globalAlpha=1)}}{const e=o.getContext("2d");if(e&&(o.width=Ve[0]*c,o.height=Ve[1]*c,o.style.width=Ve[0]+"px",o.style.height=Ve[1]+"px",e.scale(c,c),e.translate(Ue.left,Ue.top),Ke&<.current&&s.scales&&function(e,t,n,o,s,i,r){if(!1===s.crosshair)return;e.save();const l="object"==typeof s.crosshair?s.crosshair:{};e.strokeStyle=l.stroke||r.crosshair,e.lineWidth=l.strokeWidth||1,e.setLineDash(l.strokeDasharray?l.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=r.pointRing,e.lineWidth=2,e.stroke()}(e,lt.current,Ze,Je,"object"==typeof Ke?Ke:{},0,u),at.current&&Array.isArray(xe))){const t=xe.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,o){var s;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!==(s=t.opacity)&&void 0!==s?s:1,e.stroke(),e.restore()}}(e,s.scene,at.current,t)}}const p=nt.current;if(nt.current=!1,p&&s.scales&&(rt(s.scales),Ge)){const e=s.getData(),t="function"==typeof d?d:e=>e[d||"x"],n="function"==typeof g?g:e=>e[g||"y"];gt(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),yt(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}p&&Ee&&Ee.length>0&&st(e=>e+1),(null==Te?void 0:Te.showBadge)&&dt(!!f),(r||s.hasActivePulses)&&(tt.current=requestAnimationFrame(()=>mt.current()))},e.useEffect(()=>(kt(),()=>{tt.current&&(cancelAnimationFrame(tt.current),tt.current=0)}),[kt]),e.useEffect(()=>{nt.current=!0,kt()},[a,Ze,Je,de,D,R,kt]),function(t,n,o,s,i,r){e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{var e;const l=n.current;if(!l||0===l.lastIngestTime)return;const a="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(e=t.threshold)&&void 0!==e?e:5e3,u=a-l.lastIngestTime>c;u!==i&&(r(u),o.current=!0,s())},1e3);return()=>clearInterval(e)},[t,i,s])}(Te,xt,nt,kt,ht,dt);const Bt=Ke&&ct?ke?ke(ct):u.createElement(ce,{hover:ct}):null,Ht=Bt?u.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:Ue.left+ct.x,top:Ue.top+ct.y,transform:`translate(${ct.x>.7*Ze?"calc(-100% - 12px)":"12px"}, ${.3*Je>ct.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},Bt):null,_t=Lt.current>=0&&ct?u.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Ve[0],height:Ve[1],pointerEvents:"none",zIndex:2}},u.createElement("circle",{cx:ct.x+Ue.left,cy:ct.y+Ue.top,r:8,fill:"none",stroke:"var(--accent, #6366f1)",strokeWidth:2,strokeDasharray:"4,2"})):null;if(J){const e=xt.current;e&&h&&(e.ingest({inserts:h,bounded:!0}),e.computeScene({width:Ze,height:Je}));const t=null!==(o=null==e?void 0:e.scene)&&void 0!==o?o:[],n=null!==(s=null==e?void 0:e.scales)&&void 0!==s?s:null;return u.createElement("div",{className:"stream-xy-frame"+(T?" "+T:""),role:"img","aria-label":"string"==typeof _e?_e:"XY chart",style:{position:"relative",width:Ve[0],height:Ve[1]}},u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ve[0],height:Ve[1],style:{position:"absolute",left:0,top:0}},Be,u.createElement("g",{transform:`translate(${Ue.left},${Ue.top})`},D&&u.createElement("rect",{x:0,y:0,width:Ze,height:Je,fill:D}),t.map((e,t)=>function(e,t){var n,o,s;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 u.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 s=e;if(0===s.topPath.length)return null;const i=s.topPath.map(([e,t])=>`${e},${t}`).join("L"),r=[...s.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L");return u.createElement("path",{key:"area-"+t,d:`M${i}L${r}Z`,fill:s.style.fill||"#4e79a7",fillOpacity:null!==(o=null!==(n=s.style.fillOpacity)&&void 0!==n?n:s.style.opacity)&&void 0!==o?o:.7,stroke:s.style.stroke,strokeWidth:s.style.strokeWidth})}case"point":return u.createElement("circle",{key:"point-"+t,cx:e.x,cy:e.y,r:e.r,fill:e.style.fill||"#4e79a7",opacity:null!==(s=e.style.opacity)&&void 0!==s?s:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth});case"rect":return u.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 u.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),s=Math.max(Math.abs(n.openY-n.closeY),1),i=n.isUp?n.upColor:n.downColor;return u.createElement("g",{key:"candle-"+t},u.createElement("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),u.createElement("rect",{x:n.x-n.bodyWidth/2,y:o,width:n.bodyWidth,height:s,fill:i,stroke:i,strokeWidth:1}))}default:return null}}(e,t)).filter(Boolean))),u.createElement(Z,{width:Ze,height:Je,totalWidth:Ve[0],totalHeight:Ve[1],margin:Ue,scales:n,showAxes:de,axes:fe,xLabel:ge,yLabel:pe,xFormat:ye||be,yFormat:me||ve,showGrid:Me,title:_e,legend:Oe,legendHoverBehavior:Ce,legendClickBehavior:Le,legendHighlightedCategory:je,legendIsolatedCategories:Ne,foregroundGraphics:He,marginalGraphics:Ge,xValues:[],yValues:[],annotations:Ee,svgAnnotationRules:Se,annotationFrame:0,xAccessor:"string"==typeof d?d:"string"==typeof B?B:void 0,yAccessor:"string"==typeof g?g:"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 u.createElement("div",{ref:qe,className:"stream-xy-frame"+(T?" "+T:""),role:"img","aria-label":"string"==typeof _e?_e:"XY chart",tabIndex:0,style:{position:"relative",width:I?"100%":Ve[0],height:F?"100%":Ve[1]},onMouseMove:Ke?Nt:void 0,onMouseLeave:Ke?Ct:void 0,onKeyDown:jt},Be&&u.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Ve[0],height:Ve[1],pointerEvents:"none"}},Be),u.createElement("canvas",{ref:Qe,style:{position:"absolute",left:0,top:0}}),u.createElement("canvas",{ref:et,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),u.createElement(Z,{width:Ze,height:Je,totalWidth:Ve[0],totalHeight:Ve[1],margin:Ue,scales:it,showAxes:de,axes:fe,xLabel:ge,yLabel:pe,xFormat:ye||be,yFormat:me||ve,showGrid:Me,title:_e,legend:Oe,legendHoverBehavior:Ce,legendClickBehavior:Le,legendHighlightedCategory:je,legendIsolatedCategories:Ne,foregroundGraphics:He,marginalGraphics:Ge,xValues:ft,yValues:pt,annotations:Ee,svgAnnotationRules:Se,annotationFrame:ot,xAccessor:"string"==typeof d?d:"string"==typeof B?B:void 0,yAccessor:"string"==typeof g?g:"string"==typeof k?k:void 0,annotationData:null===(i=xt.current)||void 0===i?void 0:i.getData(),pointNodes:null===(r=xt.current)||void 0===r?void 0:r.scene.filter(e=>"point"===e.type)}),($e||ze)&&u.createElement(ue,{width:Ze,height:Je,totalWidth:Ve[0],totalHeight:Ve[1],margin:Ue,dimension:null!==(l=null==$e?void 0:$e.dimension)&&void 0!==l?l:"xy",scales:it,onBrush:null!=ze?ze:()=>{}}),(null==Te?void 0:Te.showBadge)&&u.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Te.badgePosition?{top:4,left:4}:"bottom-left"===Te.badgePosition?{bottom:4,left:4}:"bottom-right"===Te.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:ht?"#dc3545":"#28a745",color:"white"})},ht?"STALE":"LIVE"),_t,Ht)});he.displayName="StreamXYFrame";const de={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},fe=l.schemeCategory10;function ge(e,t,n){if("function"==typeof t)return t(e);const o=e[t];return n?n(o):fe[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+""))%fe.length]}function pe(e,t,n="category10"){const s=Array.from(new Set(e.map(e=>e[t]))),i=s.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return o.scaleOrdinal().domain(s).range(n).unknown("#999");const r=de[n]||de.category10;if(i&&"function"==typeof r)return e=>r(Number(e)/Math.max(...s.map(Number)));{const e=Array.isArray(r)?r:fe;return o.scaleOrdinal().domain(s).range(e).unknown("#999")}}function ye(e,t,n=[3,20],o){let s;if(s="function"==typeof t?t(e):e[t],!o)return s;const[i,r]=o,[l,a]=n;return r===i?(l+a)/2:l+(s-i)/(r-i)*(a-l)}const me=e.createContext(null);function be(){return e.useContext(me)}const ve="undefined"!=typeof window?e.useLayoutEffect:e.useEffect;function xe(t){const n=e.createContext(null),o=ke(t);return[function({children:o}){const s=e.useMemo(()=>ke(t),[]);return u.createElement(n.Provider,{value:s,children:o})},t=>{var s;const i=null!==(s=e.useContext(n))&&void 0!==s?s:o;return function(t,n){const[o,s]=e.useState(n);return ve(()=>t(()=>s(n)),[t]),o}(i.subscribe,()=>t(i.getState()))}]}function ke(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 we(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,s]=o.range;t.push(t=>{const o=t[n];return o>=e&&s>=o})}return e=>t.every(t=>t(e))}function Ae(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[Ee,Se]=xe(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),s=Ae(o,t),i=new Map(s.clauses);return i.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},s),{clauses:i})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const s=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),s.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:s}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),s=Ae(o,t);return o.set(t,Object.assign(Object.assign({},s),{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}})}})),[Me,Oe]=xe(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 Ce(t){const n=e.useId(),o=t.clientId||n,{name:s}=t,i=Se(e=>e.selections.get(s)),r=Se(e=>e.setClause),l=Se(e=>e.clearClause),a=e.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:e.useMemo(()=>i&&0!==i.clauses.size?function(e,t){const n=[];for(const[o,s]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(we(s));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(i,o):()=>!0,[i,o]),isActive:a,selectPoints:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};r(s,{clientId:o,type:"point",fields:t})},[o,s,r]),selectInterval:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};r(s,{clientId:o,type:"interval",fields:t})},[o,s,r]),clear:e.useCallback(()=>{l(s,o)},[l,s,o]),clientId:o}}function Le(t){const n=t.name||"hover",{fields:o}=t,{predicate:s,isActive:i,selectPoints:r,clear:l}=Ce({name:n});return{onHover:e.useCallback(e=>{if(!e)return void l();const t={};for(const n of o){const o=e[n];void 0!==o&&(t[n]=[o])}Object.keys(t).length>0&&r(t)},[o,r,l,n]),predicate:s,isActive:i}}function je(t){const{name:n,xField:o,yField:s}=t,{predicate:i,isActive:r,selectInterval:l,clear:a}=Ce({name:n}),c=o&&s?"xyBrush":o?"xBrush":"yBrush",u=e.useCallback(e=>{if(!e)return void a();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])]),s&&(t[s]=[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)&&s&&(t[s]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&l(t)},[c,o,s,l,a]);return{brushInteraction:e.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:i,isActive:r,clear:a}}const Ne=e.createContext(!1);function Be({selections:t}){const n=Se(e=>e.setResolution);return e.useEffect(()=>{for(const[e,o]of Object.entries(t))o.resolution&&n(e,o.resolution)},[t,n]),null}function He({categoryColors:t,interaction:n,selectionName:o,field:s}){const i=Object.entries(t);if(0===i.length)return null;const r=i.map(([e])=>e),l=[{styleFn:e=>({fill:e.color,stroke:e.color}),type:"fill",items:i.map(([e,t])=>({label:e,color:t})),label:""}],a=Le({name:o,fields:[s]}),c=Ce({name:o,clientId:"__linked-legend-isolate__"}),[h,d]=e.useState(new Set),[f,g]=e.useState(null),p=e.useRef(c.selectPoints);p.current=c.selectPoints;const y=e.useRef(c.clear);y.current=c.clear,e.useEffect(()=>{"isolate"===n&&(h.size>0?p.current({[s]:Array.from(h)}):y.current())},[n,h,s]);const m=e.useCallback(e=>{"highlight"===n&&(e?(g(e.label),a.onHover({[s]:e.label})):(g(null),a.onHover(null)))},[n,s,a]),b=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===r.length?new Set:n})},[n,r.length]);return u.createElement("svg",{width:"100%",height:30,style:{display:"block",overflow:"visible"}},u.createElement(z,{legendGroups:l,title:!1,orientation:"horizontal",height:20,customHoverBehavior:"highlight"===n?m:void 0,customClickBehavior:"isolate"===n?b:void 0,highlightedCategory:f,isolatedCategories:h}))}function _e({children:e,selections:t,showLegend:n,legendPosition:o="top",legendInteraction:s="none",legendSelectionName:i="legend",legendField:r="category"}){const l=be(),a=void 0!==n?n:!(!l||0>=Object.keys(l).length);return u.createElement(Ee,null,u.createElement(Me,null,t&&u.createElement(Be,{selections:t}),u.createElement(Ne.Provider,{value:a},a&&"top"===o&&l&&u.createElement(He,{categoryColors:l,interaction:s,selectionName:i,field:r}),e,a&&"bottom"===o&&l&&u.createElement(He,{categoryColors:l,interaction:s,selectionName:i,field:r}))))}function We(e){return e?"string"==typeof e?{name:e}:e:null}function $e(e,t,n){return t?o=>{var s;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!==(s=null==n?void 0:n.unselectedOpacity)&&void 0!==s?s:.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 ze="#007bff";function Ie(e){return"function"==typeof e?e:t=>t[e]}function Fe(t,n,o="category10"){const s=be();return e.useMemo(()=>{if(n&&"function"!=typeof n)return s&&Object.keys(s).length>0?e=>s[e]||pe(t,n,o)(e):pe(t,n,o)},[t,n,o,s])}function Pe({selection:t,linkedHover:n,fallbackFields:o=[],unwrapData:s=!1,onObservation:i,chartType:r,chartId:l}){const a=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=Ce({name:(null==t?void 0:t.name)||"__unused__"}),u=Le({name:(null==a?void 0:a.name)||"hover",fields:(null==a?void 0:a.fields)||o||[]}),h=Oe(e=>e.pushObservation),d=t?{isActive:c.isActive,predicate:c.predicate}:null,f=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||h){const n={timestamp:Date.now(),chartType:r||"unknown",chartId:l};if(e){let s=e.data||e.datum||e;Array.isArray(s)&&(s=s[0]);const r=Object.assign(Object.assign({},n),{type:"hover",datum:s||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(r),h&&h(r)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(e),h&&h(e)}}},[n,u,i,r,l,h]),g=e.useCallback(e=>{var t,n;if(i||h){const o={timestamp:Date.now(),chartType:r||"unknown",chartId:l};if(e){let s=e.data||e.datum||e;Array.isArray(s)&&(s=s[0]);const r=Object.assign(Object.assign({},o),{type:"click",datum:s||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});i&&i(r),h&&h(r)}else{const e=Object.assign(Object.assign({},o),{type:"click-end"});i&&i(e),h&&h(e)}}},[i,h,r,l]);return{activeSelectionHook:d,customHoverBehavior:f,customClickBehavior:g}}function Te({data:t,colorBy:n,colorScale:o,showLegend:s,userMargin:i,defaults:r={top:50,bottom:60,left:70,right:40}}){const l=e.useContext(Ne),a=void 0!==s?s:!l&&!!n,c=e.useMemo(()=>{if(a&&n)return function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:s,strokeWidth:i}){return{legendGroups:[{styleFn:e=>{const t={fill:e.color,stroke:e.color};return void 0!==s&&(t.stroke=s),void 0!==i&&(t.strokeWidth=i),t},type:"fill",items:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(s=>{const i=e.find("function"==typeof t?e=>t(e)===s:e=>e[t]===s),r=i?o(i,t,n):n?n(s):"#000000";return{label:s+"",color:r}}),label:""}]}}({data:t,colorBy:n,colorScale:o,getColor:ge})},[a,n,t,o]),u=e.useMemo(()=>{const e=Object.assign(Object.assign({},r),i);return c&&120>e.right&&(e.right=120),e},[r,i,c]);return{legend:c,margin:u}}function De(t,n,o){const[s,i]=e.useState(null),[r,l]=e.useState(new Set),a=e.useCallback(e=>{"highlight"===t&&i(e?e.label:null)},[t]),c=e.useCallback(e=>{"isolate"===t&&l(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!=s?{isActive:!0,predicate:t=>(e?t[e]:"function"==typeof n?n(t):null)===s}:"isolate"===t&&r.size>0?{isActive:!0,predicate:t=>{const o=e?t[e]:"function"==typeof n?n(t):null;return r.has(o)}}:null},[t,n,s,r]);return{highlightedCategory:"highlight"===t?s:null,isolatedCategories:"isolate"===t?r:new Set,onLegendHover:a,onLegendClick:c,legendSelectionHook:u}}const Re={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 Ye(e,t,n){var o,s,i,r,l,a;const c=Re[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:c.width,height:null!==(s=t.height)&&void 0!==s?s:c.height,showAxes:c.showAxes,showGrid:null!==(i=t.showGrid)&&void 0!==i?i:c.showGrid,enableHover:null!==(r=t.enableHover)&&void 0!==r?r:!!t.linkedHover||c.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:c.showLegend,showLabels:null!==(a=t.showLabels)&&void 0!==a?a: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 Ge={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 Xe(e,t){return"function"==typeof t?t(e):e[t]}function qe(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 Ve(e={}){const{fields:t,title:n,format:o,style:s={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let r;const l=[];if(n){const t=Xe(e,n);r=qe(t,o)}if(t&&t.length>0)t.forEach(t=>{let n,s,i;"string"==typeof t?(n=t,s=t,i=o):(n=t.label,s=t.accessor||t.key||"",i=t.format||o);const r=Xe(e,s);l.push({label:n,value:qe(r,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){r=qe(e[n],o);break}if(!r){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(r=qe(e[t[0]],o))}}const a=Object.assign(Object.assign({},Ge),s);return u.createElement("div",{className:("semiotic-tooltip "+i).trim(),style:a},r&&u.createElement("div",{style:{fontWeight:l.length>0?"bold":"normal"}},r),l.map((e,t)=>u.createElement("div",{key:t,style:{marginTop:0===t&&r?"4px":0}},e.label&&u.createElement("span",null,e.label,": "),e.value)))}}function Ue(e){return!0===e?Ve():"function"==typeof e?e:!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?Ve(e):Ve())}function Ze(e){return"string"==typeof e?e:"value"}function Je(e){return t=>{const n=t.data;return n?u.createElement("div",{className:"semiotic-tooltip",style:Ge},e.map((e,t)=>{const o=function(e,t){return"function"==typeof t?t(e):e[t]}(n,e.accessor),s=null==(i=o)?"–":"number"==typeof i?Math.abs(i)>9999?i.toLocaleString():i+"":i instanceof Date?i.toLocaleDateString():i+"";var i;return u.createElement("div",{key:t,style:t>0?{marginTop:2}:void 0},u.createElement("span",{style:{opacity:.8}},e.label,": "),u.createElement("span",{style:{fontWeight:"color"===e.role||"group"===e.role?"bold":"normal"}},s))})):null}}function Ke({componentName:e,message:t,width:n,height:o}){return u.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"}},u.createElement("div",{style:{textAlign:"center",maxWidth:400}},u.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),u.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t)))}class Qe extends u.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:u.createElement(Ke,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}var et;const tt="undefined"!=typeof process&&"production"!==(null===(et=process.env)||void 0===et?void 0:et.NODE_ENV);function nt({componentName:e,width:t,height:n,children:o}){return u.createElement(Qe,{fallback:o=>u.createElement(Ke,{componentName:e,message:o.message,width:t,height:n})},o)}const ot={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"},st={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function it(e,t,n,o){return!1===o||e&&Array.isArray(e)&&e.length>0||e&&!Array.isArray(e)?null:u.createElement("div",{style:Object.assign(Object.assign({},ot),{width:t,height:n})},o||"No data available")}function rt(e,t,n){if(!e)return null;const o=Math.min(5,Math.floor(n/40)),s=Math.max(8,Math.floor(n/(3*o))),i=Math.max(6,Math.floor(n/(2.5*o))),r=Math.floor((n-(o*(s+i)-i))/2);return u.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)=>u.createElement("div",{key:n,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},st),{position:"absolute",top:r+n*(s+i),left:Math.floor(.1*t),width:30+Math.round(50*Math.random())+"%",height:s,opacity:.5+n%2*.2})})))}function lt(e,t,n,o){if(!tt)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const s=t[0];if(!s||"object"!=typeof s)return;if(o in s)return;const i=Object.keys(s).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${i}`)}function at(e,t){const n=e.length,o=t.length,s=Array(o+1);for(let e=0;o>=e;e++)s[e]=e;for(let i=1;n>=i;i++){let n=s[0];s[0]=i;for(let r=1;o>=r;r++){const o=s[r];s[r]=e[i-1]===t[r-1]?n:1+Math.min(n,s[r],s[r-1]),n=o}}return s[o]}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=function(e,t,n=3){let o,s=n+1;for(const n of t){const t=at(e.toLowerCase(),n.toLowerCase());s>t&&(s=t,o=n)}return s>n?void 0:o}(e,t,3))&&void 0!==n?n:null)}function ut({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=function(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[s,i]of Object.entries(n))if(i&&"string"==typeof i&&!(i in o)){const n=ct(i,t),o=n?` Try ${s}="${n}".`:"";return`${e}: ${s} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}const ht="__forecastSegment";function dt(e,t){return"function"==typeof t?t(e):!!e[t]}function ft(t){var n,o;const s=Ye(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:r,className:l,xFormat:a,yFormat:c,xAccessor:h="x",yAccessor:d="y",lineBy:f,lineDataAccessor:g="coordinates",colorBy:p,colorScheme:y="category10",curve:m="linear",showPoints:b=!1,pointRadius:v=3,fillArea:x=!1,areaOpacity:k=.3,lineWidth:w=2,tooltip:A,pointIdAccessor:E,annotations:S,directLabel:M,gapStrategy:O="break",anomaly:C,forecast:L,frameProps:j={},selection:N,linkedHover:B,onObservation:H,chartId:_,loading:W,emptyContent:$,legendInteraction:z}=t,I=s.width,F=s.height,P=s.enableHover,T=s.showGrid,D=s.showLegend,R=s.title,Y=s.xLabel,G=s.yLabel,X=rt(W,I,F);if(X)return X;const q=it(i,I,F,$);if(q)return q;const V=i||[];lt("LineChart",V,"xAccessor",h),lt("LineChart",V,"yAccessor",d);const U="string"==typeof h?h:"x",Z="string"==typeof d?d:"y",J=e.useMemo(()=>L?function(e,t,n,o,s){return(i=o).isTraining||i.isForecast||i.isAnomaly||i.upperBounds||i.lowerBounds?function(e,t,n,o,s){var i,r,l;const{isTraining:a,isForecast:c,isAnomaly:u,upperBounds:h,lowerBounds:d,color:f="#6366f1",bandOpacity:g=.15,anomalyColor:p="#ef4444",anomalyRadius:y=6,label:m}=o,b=e.map(e=>{let t="observed";return c&&dt(e,c)?t="forecast":a&&dt(e,a)&&(t="training"),Object.assign(Object.assign({},e),{[ht]:t})}),v=[];for(let e=0;b.length>e;e++)v.push(b[e]),b.length-1>e&&b[e][ht]!==b[e+1][ht]&&v.push(Object.assign(Object.assign({},b[e]),{[ht]:b[e+1][ht]}));const x=[];if(h&&d){const e="string"==typeof h?h:"__envUpper",t="string"==typeof d?d:"__envLower";if("function"==typeof h||"function"==typeof d)for(const n of v)"function"==typeof h&&(n[e]=h(n)),"function"==typeof d&&(n[t]=d(n));x.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:f,fillOpacity:g,label:m})}return u&&x.push({type:"highlight",filter:e=>dt(e,u),color:p,r:y,style:{stroke:p,strokeWidth:1.5,fill:p,fillOpacity:.7}}),s&&x.push({type:"anomaly-band",threshold:null!==(i=s.threshold)&&void 0!==i?i:2,showBand:!1!==s.showBand,fill:s.bandColor||"#6366f1",fillOpacity:null!==(r=s.bandOpacity)&&void 0!==r?r:.1,anomalyColor:s.anomalyColor||"#ef4444",anomalyRadius:null!==(l=s.anomalyRadius)&&void 0!==l?l:6,label:s.label}),{processedData:v,annotations:x}}(e,0,0,o,s):function(e,t,n,o,s){var i,r,l;const{trainEnd:a,steps:c=10,confidence:u=.95,color:h="#6366f1",bandOpacity:d=.15,label:f}=o;if(null==a)return{processedData:e,annotations:[]};const g=[],p=[];for(const n of e)n[t]>a?p.push(Object.assign(Object.assign({},n),{[ht]:"observed"})):g.push(Object.assign(Object.assign({},n),{[ht]:"training"}));const y=g.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=[],b=[];if(y.length>=3){const o=y.length;let s=0,i=0,r=0,l=0;for(const[e,t]of y)s+=e,i+=t,r+=e*e,l+=e*t;const a=o*r-s*s;if(Math.abs(a)>1e-12){const r=(o*l-s*i)/a,g=(i-r*s)/o,p=e=>g+r*e,v=y.map(([e,t])=>t-p(e)).reduce((e,t)=>e+t*t,0),x=Math.sqrt(v/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,E=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),S=Math.max(...E),M=y.length>1?(y[o-1][0]-y[0][0])/(o-1):1;for(let e=1;c>=e;e++){const s=S+e*M,i=p(s),r=x*Math.sqrt(1+1/o+(w>0?Math.pow(s-k,2)/w:0))*A;b.push({[t]:s,[n]:i,[ht]:"forecast",__forecastUpper:i+r,__forecastLower:i-r})}m.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:h,fillOpacity:d,label:f})}}m.push({type:"x-threshold",x:a,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),s&&m.push({type:"anomaly-band",threshold:null!==(i=s.threshold)&&void 0!==i?i:2,showBand:!1!==s.showBand,fill:s.bandColor||"#6366f1",fillOpacity:null!==(r=s.bandOpacity)&&void 0!==r?r:.1,anomalyColor:s.anomalyColor||"#ef4444",anomalyRadius:null!==(l=s.anomalyRadius)&&void 0!==l?l:6,label:s.label});const v=[];if(v.push(...g),g.length>0&&p.length>0&&v.push(Object.assign(Object.assign({},g[g.length-1]),{[ht]:"observed"})),v.push(...p),b.length>0){const e=p.length>0?p[p.length-1]:g[g.length-1];e&&v.push(Object.assign(Object.assign({},e),{[ht]:"forecast"})),v.push(...b)}return{processedData:v,annotations:m}}(e,t,n,o,s);var i}(V,U,Z,L,C):null,[V,L,C,U,Z]),K=e.useMemo(()=>J?J.annotations:C?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}]}(C):[],[J,C]),Q=J?J.processedData:V,ee=L&&!f?ht:f,{activeSelectionHook:te,customHoverBehavior:ne}=Pe({selection:N,linkedHover:B,fallbackFields:p?["string"==typeof p?p:""]:[],onObservation:H,chartType:"LineChart",chartId:_}),oe=e.useCallback(e=>{const t="function"==typeof h?h(e):e[h],n="function"==typeof d?d(e):e[d];return null==t||null==n||Number.isNaN(t)||Number.isNaN(n)},[h,d]),se=void 0!==(null===(n=Q[0])||void 0===n?void 0:n[g]),ie=e.useMemo(()=>{if(se)return Q;if(ee){const e=Q.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]:Q}]},[Q,ee,g,se]),{gapProcessedLineData:re,hasGaps:le}=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 s=[],i=0;const r=ee&&"string"==typeof ee?n[ee]:void 0;for(const l of o)if(oe(l))e=!0,s.length>0&&(t.push(Object.assign(Object.assign({},n),{[g]:s})),s=[],i++);else{const e=null!=r?`${r}__seg${i}`:"__seg"+i;s.push(Object.assign(Object.assign({},l),{_gapSegment:e}))}s.length>0&&t.push(Object.assign(Object.assign({},n),{[g]:s}))}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 s=o[g]||[],i=[];for(const n of s)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]),ae=Fe(Q,p,y),ce=e.useMemo(()=>{if(!p)return[];const e=new Set;for(const t of Q){const n="function"==typeof p?p(t):t[p];null!=n&&e.add(n+"")}return Array.from(e)},[Q,p]),ue=De(z,p,ce),de=e.useMemo(()=>ue.legendSelectionHook?ue.legendSelectionHook:te,[ue.legendSelectionHook,te]),fe=e.useMemo(()=>e=>{const t={strokeWidth:w};return t.stroke=p?ge(e,p,ae):ze,x&&(t.fill=t.stroke,t.fillOpacity=k),t},[p,ae,w,x,k]),pe=e.useMemo(()=>L?function(e,t){var n,o;const s=null!==(n=t.trainDasharray)&&void 0!==n?n:"8,4",i=null!==(o=t.forecastDasharray)&&void 0!==o?o:"4,4",r=t.color||"#6366f1";return t=>{const n=e(t),o=t[ht];return"training"===o?Object.assign(Object.assign({},n),{strokeDasharray:s}):"forecast"===o?Object.assign(Object.assign({},n),{stroke:r,strokeDasharray:i}):n}}(fe,L):fe,[fe,L]),ye=e.useMemo(()=>$e(pe,de,N),[pe,de,N]),me=e.useMemo(()=>{if(b)return e=>{const t={r:v,fillOpacity:1};return t.fill=p?ge(e.parentLine||e,p,ae):ze,t}},[b,v,p,ae]),be=x?"area":"line",ve="object"==typeof M?M:{},xe=ve.position||"end",ke=ve.fontSize||11,we=e.useMemo(()=>{var e,t;if(!M||!p)return[];const n="function"==typeof h?h:e=>e[h],o="function"==typeof d?d:e=>e[d],s="function"==typeof p?p:e=>e[p],i=new Map;for(const n of re){const o=n[g]||[];if(0===o.length)continue;const r="end"===xe?o[o.length-1]:o[0],l=null!==(t=null!==(e=s(r))&&void 0!==e?e:s(n))&&void 0!==t?t:"";l&&!i.has(l+"")&&i.set(l+"",r)}const r=Array.from(i.entries()).map(([e,t])=>({type:"text",label:e,["string"==typeof h?h:"x"]:n(t),["string"==typeof d?d:"y"]:o(t),dx:"end"===xe?6:-6,dy:0,color:ae?ae(e):ze,fontSize:ke}));r.sort((e,t)=>{const n="string"==typeof d?d:"y";return e[n]-t[n]});for(let e=1;r.length>e;e++){const t="string"==typeof d?d:"y",n=r[e-1],o=r[e];ke+2>Math.abs(o[t]+o.dy-(n[t]+n.dy))&&(o.dy+=ke+2)}return r},[M,p,ae,re,g,h,d,xe,ke]),Ae=(!M||void 0!==D)&&D,Ee=e.useMemo(()=>{if(!M)return s.marginDefaults;const e=we.reduce((e,t)=>{var n;const o=((null===(n=t.label)||void 0===n?void 0:n.length)||0)*(.6*ke);return Math.max(e,o)},0),t=e+10,n="end"===xe?"right":"left";return Object.assign(Object.assign({},s.marginDefaults),{[n]:Math.max(s.marginDefaults[n]||0,t)})},[M,we,ke,xe,s.marginDefaults]),{legend:Se,margin:Me}=Te({data:re,colorBy:p,colorScale:ae,showLegend:Ae,userMargin:r,defaults:Ee}),Oe=f||p,Ce=e.useMemo(()=>Je([{label:Y||Ze(h),accessor:h,role:"x"},{label:G||Ze(d),accessor:d,role:"y"},...Oe?[{label:Ze(Oe),accessor:Oe,role:"group"}]:[]]),[h,d,Y,G,Oe]),Le=ut({componentName:"LineChart",data:se?(null===(o=Q[0])||void 0===o?void 0:o[g])||[]:V,accessors:{xAccessor:h,yAccessor:d}});if(Le)return u.createElement(Ke,{componentName:"LineChart",message:Le,width:I,height:F});const je=e.useMemo(()=>se||ee||le?re.flatMap(e=>{const t=e[g]||[];return ee&&"string"==typeof ee?t.map(t=>Object.assign(Object.assign({},t),{[ee]:e[ee]})):t}):Q,[re,g,se,ee,Q,le]),Ne=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:be,data:je,xAccessor:h,yAccessor:d,groupAccessor:"break"===O&&le?"_gapSegment":ee||void 0,curve:m,lineStyle:ye},b&&{pointStyle:me}),{size:[I,F],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Me,showAxes:s.showAxes,xLabel:Y,yLabel:G,xFormat:a,yFormat:c,enableHover:P,showGrid:T}),Se&&{legend:Se}),z&&"none"!==z&&{legendHoverBehavior:ue.onLegendHover,legendClickBehavior:ue.onLegendClick,legendHighlightedCategory:ue.highlightedCategory,legendIsolatedCategories:ue.isolatedCategories}),R&&{title:R}),l&&{className:l}),{tooltipContent:Ue(A)||Ce}),(B||H)&&{customHoverBehavior:ne}),E&&{pointIdAccessor:E}),((null==S?void 0:S.length)||K.length||we.length)&&{annotations:[...S||[],...K,...we]}),j);return u.createElement(nt,{componentName:"LineChart",width:I,height:F},u.createElement(he,Object.assign({},Ne)))}function gt(t){var n;const o=Ye(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:i,className:r,xFormat:l,yFormat:a,xAccessor:c="x",yAccessor:h="y",areaBy:d,y0Accessor:f,gradientFill:g=!1,lineDataAccessor:p="coordinates",colorBy:y,colorScheme:m="category10",curve:b="monotoneX",areaOpacity:v=.7,showLine:x=!0,lineWidth:k=2,tooltip:w,annotations:A,frameProps:E={},selection:S,linkedHover:M,onObservation:O,chartId:C,loading:L,emptyContent:j,legendInteraction:N}=t,B=o.width,H=o.height,_=o.enableHover,W=o.showGrid,$=o.showLegend,z=o.title,I=o.xLabel,F=o.yLabel,P=rt(L,B,H);if(P)return P;const T=it(s,B,H,j);if(T)return T;const D=s||[];lt("AreaChart",D,"xAccessor",c),lt("AreaChart",D,"yAccessor",h);const{activeSelectionHook:R,customHoverBehavior:Y}=Pe({selection:S,linkedHover:M,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:O,chartType:"AreaChart",chartId:C}),G=void 0!==(null===(n=D[0])||void 0===n?void 0:n[p]),X=e.useMemo(()=>{if(G)return D;if(d){const e=D.reduce((e,t)=>{const n="function"==typeof d?d(t):t[d];if(!e[n]){const t={[p]:[]};"string"==typeof d&&(t[d]=n),e[n]=t}return e[n][p].push(t),e},{});return Object.values(e)}return[{[p]:D}]},[D,d,p,G]),q=Fe(D,y,m),V=e.useMemo(()=>{if(!y)return[];const e=new Set;for(const t of D){const n="function"==typeof y?y(t):t[y];null!=n&&e.add(n+"")}return Array.from(e)},[D,y]),U=De(N,y,V),Z=e.useMemo(()=>U.legendSelectionHook?U.legendSelectionHook:R,[U.legendSelectionHook,R]),J=e.useMemo(()=>e=>{const t={},n=y?ge(e,y,q):ze;return t.fill=n,t.fillOpacity=v,x?(t.stroke=n,t.strokeWidth=k):t.stroke="none",t},[y,q,v,x,k]),K=e.useMemo(()=>$e(J,Z,S),[J,Z,S]),{legend:Q,margin:ee}=Te({data:X,colorBy:y,colorScale:q,showLegend:$,userMargin:i,defaults:o.marginDefaults}),te=d||y,ne=e.useMemo(()=>Je([{label:I||Ze(c),accessor:c,role:"x"},{label:F||Ze(h),accessor:h,role:"y"},...te?[{label:Ze(te),accessor:te,role:"group"}]:[]]),[c,h,I,F,te]),oe=ut({componentName:"AreaChart",data:D,accessors:{xAccessor:c,yAccessor:h}});if(oe)return u.createElement(Ke,{componentName:"AreaChart",message:oe,width:B,height:H});const se=e.useMemo(()=>G||d?X.flatMap(e=>{const t=e[p]||[];return d&&"string"==typeof d?t.map(t=>Object.assign(Object.assign({},t),{[d]:e[d]})):t}):D,[X,p,G,d,D]),ie=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area",data:se,xAccessor:c,yAccessor:h,groupAccessor:d||void 0},f&&{y0Accessor:f}),g&&{gradientFill:g}),{curve:b,lineStyle:K,size:[B,H],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ee,showAxes:o.showAxes,xLabel:I,yLabel:F,xFormat:l,yFormat:a,enableHover:_,showGrid:W}),Q&&{legend:Q}),N&&"none"!==N&&{legendHoverBehavior:U.onLegendHover,legendClickBehavior:U.onLegendClick,legendHighlightedCategory:U.highlightedCategory,legendIsolatedCategories:U.isolatedCategories}),z&&{title:z}),r&&{className:r}),{tooltipContent:Ue(w)||ne}),(M||O)&&{customHoverBehavior:Y}),A&&A.length>0&&{annotations:A}),E);return u.createElement(nt,{componentName:"AreaChart",width:B,height:H},u.createElement(he,Object.assign({},ie)))}function pt(t){var n;const o=Ye(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:i,className:r,xFormat:l,yFormat:a,xAccessor:c="x",yAccessor:h="y",areaBy:d,lineDataAccessor:f="coordinates",colorBy:g,colorScheme:p="category10",curve:y="monotoneX",areaOpacity:m=.7,showLine:b=!0,lineWidth:v=2,normalize:x=!1,tooltip:k,annotations:w,frameProps:A={},selection:E,linkedHover:S,onObservation:M,chartId:O,loading:C,emptyContent:L,legendInteraction:j}=t,N=o.width,B=o.height,H=o.enableHover,_=o.showGrid,W=o.showLegend,$=o.title,z=o.xLabel,I=o.yLabel,F=rt(C,N,B);if(F)return F;const P=it(s,N,B,L);if(P)return P;const T=s||[],{activeSelectionHook:D,customHoverBehavior:R}=Pe({selection:E,linkedHover:S,fallbackFields:g?["string"==typeof g?g:""]:[],onObservation:M,chartType:"StackedAreaChart",chartId:O}),Y=void 0!==(null===(n=T[0])||void 0===n?void 0:n[f]),G=e.useMemo(()=>{if(Y)return T;if(d){const e=T.reduce((e,t)=>{const n="function"==typeof d?d(t):t[d];if(!e[n]){const t={[f]:[]};"string"==typeof d&&(t[d]=n),e[n]=t}return e[n][f].push(t),e},{});return Object.values(e)}return[{[f]:T}]},[T,d,f,Y]),X=Fe(T,g,p),q=e.useMemo(()=>{if(!g)return[];const e=new Set;for(const t of T){const n="function"==typeof g?g(t):t[g];null!=n&&e.add(n+"")}return Array.from(e)},[T,g]),V=De(j,g,q),U=e.useMemo(()=>V.legendSelectionHook?V.legendSelectionHook:D,[V.legendSelectionHook,D]),Z=e.useMemo(()=>e=>{const t={},n=g?ge(e,g,X):ze;return t.fill=n,t.fillOpacity=m,b?(t.stroke=n,t.strokeWidth=v):t.stroke="none",t},[g,X,m,b,v]),J=e.useMemo(()=>$e(Z,U,E),[Z,U,E]),{legend:K,margin:Q}=Te({data:G,colorBy:g,colorScale:X,showLegend:W,userMargin:i,defaults:o.marginDefaults}),ee=d||g,te=e.useMemo(()=>Je([{label:z||Ze(c),accessor:c,role:"x"},{label:I||Ze(h),accessor:h,role:"y"},...ee?[{label:Ze(ee),accessor:ee,role:"group"}]:[]]),[c,h,z,I,ee]),ne=ut({componentName:"StackedAreaChart",data:T,accessors:{xAccessor:c,yAccessor:h}});if(ne)return u.createElement(Ke,{componentName:"StackedAreaChart",message:ne,width:N,height:B});const oe=e.useMemo(()=>Y||d?G.flatMap(e=>{const t=e[f]||[];return d&&"string"==typeof d?t.map(t=>Object.assign(Object.assign({},t),{[d]:e[d]})):t}):T,[G,f,Y,d,T]),se=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea",data:oe,xAccessor:c,yAccessor:h,groupAccessor:d||void 0,curve:y,normalize:x,lineStyle:J,size:[N,B],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Q,showAxes:o.showAxes,xLabel:z,yLabel:I,xFormat:l,yFormat:a,enableHover:H,showGrid:_},K&&{legend:K}),j&&"none"!==j&&{legendHoverBehavior:V.onLegendHover,legendClickBehavior:V.onLegendClick,legendHighlightedCategory:V.highlightedCategory,legendIsolatedCategories:V.isolatedCategories}),$&&{title:$}),r&&{className:r}),{tooltipContent:Ue(k)||te}),(S||M)&&{customHoverBehavior:R}),w&&w.length>0&&{annotations:w}),A);return u.createElement(nt,{componentName:"StackedAreaChart",width:N,height:B},u.createElement(he,Object.assign({},se)))}function yt(t){const n=Ye(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:s,className:i,xFormat:r,yFormat:l,xAccessor:a="x",yAccessor:c="y",colorBy:h,colorScheme:d="category10",sizeBy:f,sizeRange:g=[3,15],pointRadius:p=5,pointOpacity:y=.8,tooltip:m,marginalGraphics:b,pointIdAccessor:v,annotations:x,frameProps:k={},selection:w,linkedHover:A,linkedBrush:E,onObservation:S,chartId:M,loading:O,emptyContent:C,legendInteraction:L}=t,j=n.width,N=n.height,B=n.enableHover,H=n.showGrid,_=n.showLegend,W=n.title,$=n.xLabel,z=n.yLabel,I=rt(O,j,N);if(I)return I;const F=it(o,j,N,C);if(F)return F;const P=o||[];lt("Scatterplot",P,"xAccessor",a),lt("Scatterplot",P,"yAccessor",c);const{activeSelectionHook:T,customHoverBehavior:D}=Pe({selection:w,linkedHover:A,fallbackFields:h?["string"==typeof h?h:""]:[],onObservation:S,chartType:"Scatterplot",chartId:M}),R=We(E),Y=je({name:(null==R?void 0:R.name)||"__unused_brush__",xField:(null==R?void 0:R.xField)||("string"==typeof a?a:void 0),yField:(null==R?void 0:R.yField)||("string"==typeof c?c:void 0)}),G=R?"xyBrush"===Y.brushInteraction.brush?"xy":"xBrush"===Y.brushInteraction.brush?"x":"y":void 0,X=u.useRef(Y.brushInteraction);X.current=Y.brushInteraction;const q=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)},[]),V=Fe(P,h,d),U=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]),Z=De(L,h,U),J=e.useMemo(()=>Z.legendSelectionHook?Z.legendSelectionHook:T,[Z.legendSelectionHook,T]),K=e.useMemo(()=>{if(!f||0===P.length)return;const e=P.map(e=>"function"==typeof f?f(e):e[f]);return[Math.min(...e),Math.max(...e)]},[P,f]),Q=e.useMemo(()=>e=>{const t={fillOpacity:y};return t.fill=h?ge(e,h,V):ze,t.r=f?ye(e,f,g,K):p,t},[h,V,f,g,K,p,y]),ee=e.useMemo(()=>$e(Q,J,w),[Q,J,w]),{legend:te,margin:ne}=Te({data:P,colorBy:h,colorScale:V,showLegend:_,userMargin:s,defaults:n.marginDefaults}),oe=e.useMemo(()=>Je([{label:$||Ze(a),accessor:a,role:"x"},{label:z||Ze(c),accessor:c,role:"y"},...h?[{label:Ze(h),accessor:h,role:"color"}]:[],...f?[{label:Ze(f),accessor:f,role:"size"}]:[]]),[a,c,$,z,h,f]),se=ut({componentName:"Scatterplot",data:P,accessors:{xAccessor:a,yAccessor:c}});if(se)return u.createElement(Ke,{componentName:"Scatterplot",message:se,width:j,height:N});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:P,xAccessor:a,yAccessor:c,colorAccessor:h||void 0,sizeAccessor:f||void 0,sizeRange:g,pointStyle:ee,colorScheme:d,size:[j,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ne,showAxes:n.showAxes,xLabel:$,yLabel:z,xFormat:r,yFormat:l,enableHover:B,showGrid:H},te&&{legend:te}),L&&"none"!==L&&{legendHoverBehavior:Z.onLegendHover,legendClickBehavior:Z.onLegendClick,legendHighlightedCategory:Z.highlightedCategory,legendIsolatedCategories:Z.isolatedCategories}),W&&{title:W}),i&&{className:i}),{tooltipContent:Ue(m)||oe}),(A||S)&&{customHoverBehavior:D}),b&&{marginalGraphics:b}),v&&{pointIdAccessor:v}),x&&x.length>0&&{annotations:x}),R&&{brush:{dimension:G},onBrush:q}),k);return u.createElement(nt,{componentName:"Scatterplot",width:j,height:N},u.createElement(he,Object.assign({},ie)))}function mt(t){const n=Ye(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:s,xFormat:i,yFormat:r,xAccessor:a="x",yAccessor:c="y",orderAccessor:h,orderLabel:d,pointRadius:f=4,tooltip:g,pointIdAccessor:p,annotations:y,frameProps:m={},selection:b,linkedHover:v,onObservation:x,chartId:k,loading:w,emptyContent:A,legendInteraction:E}=t,S=n.width,M=n.height,O=n.enableHover,C=n.showGrid,L=n.title,j=n.xLabel,N=n.yLabel,B=rt(w,S,M);if(B)return B;const H=it(o,S,M,A);if(H)return H;const _=o||[],W=e.useMemo(()=>{if(!h||0===_.length)return _;const e="function"==typeof h?h:e=>e[h];return[..._].sort((t,n)=>{const o=e(t),s=e(n);return(o instanceof Date?o.getTime():+o)-(s instanceof Date?s.getTime():+s)})},[_,h]);lt("ConnectedScatterplot",W,"xAccessor",a),lt("ConnectedScatterplot",W,"yAccessor",c);const{activeSelectionHook:$,customHoverBehavior:z}=Pe({selection:b,linkedHover:v,fallbackFields:[],onObservation:x,chartType:"ConnectedScatterplot",chartId:k}),I=De(E,void 0,[]),F=e.useMemo(()=>I.legendSelectionHook?I.legendSelectionHook:$,[I.legendSelectionHook,$]),P=W.length,T=P>0&&100>P,D=e.useMemo(()=>0===P?[]:W.map((e,t)=>l.interpolateViridis(1===P?.5:t/(P-1))),[W,P]);e.useMemo(()=>null,[P]);const R=e.useMemo(()=>{if(P>=2)return(e,t,n)=>{var o,s;if("connected-lines"!==e.type)return null;const i=n.scales;if(!i)return null;const r=null!==(o=i.x)&&void 0!==o?o:i.time,l=null!==(s=i.y)&&void 0!==s?s:i.value;if(!r||!l)return null;const h="string"==typeof a?e=>e[a]:a,d="string"==typeof c?e=>e[c]:c,g=[];for(let e=0;W.length-1>e;e++){const t=W[e],n=W[e+1],o=r(h(t)),s=l(d(t)),i=r(h(n)),a=l(d(n)),c=D[e];T&&g.push(u.createElement("line",{key:"halo-"+e,x1:o,y1:s,x2:i,y2:a,stroke:"white",strokeWidth:f+2,strokeOpacity:.5,strokeLinecap:"round"})),g.push(u.createElement("line",{key:"conn-"+e,x1:o,y1:s,x2:i,y2:a,stroke:c,strokeWidth:f,strokeLinecap:"round"}))}return u.createElement("g",{key:"ann-"+t},g)}},[W,D,f,T,a,c,P]),Y=e.useMemo(()=>e=>{const t=W.indexOf(e);return{fill:t>=0&&D.length>t?D[t]:"#6366f1",stroke:"white",strokeWidth:1,r:f,fillOpacity:1}},[W,D,f]),G=e.useMemo(()=>$e(Y,F,b),[Y,F,b]),X=Object.assign({top:50,right:40,bottom:60,left:70},t.margin),q=d||("string"==typeof h?h:"Order"),V=e.useMemo(()=>Je([{label:j||Ze(a),accessor:a,role:"x"},{label:N||Ze(c),accessor:c,role:"y"},...h?[{label:q,accessor:h,role:"group"}]:[]]),[a,c,j,N,h,q]),U=ut({componentName:"ConnectedScatterplot",data:W,accessors:{xAccessor:a,yAccessor:c}});if(U)return u.createElement(Ke,{componentName:"ConnectedScatterplot",message:U,width:S,height:M});const Z=e.useMemo(()=>[{type:"connected-lines"},...y||[]],[y]),J=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter",data:W,xAccessor:a,yAccessor:c,pointStyle:G,size:[S,M],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:X,showAxes:n.showAxes,xLabel:j,yLabel:N,xFormat:i,yFormat:r,enableHover:O,showGrid:C},L&&{title:L}),s&&{className:s}),{tooltipContent:Ue(g)||V}),(v||x)&&{customHoverBehavior:z}),p&&{pointIdAccessor:p}),{annotations:Z,svgAnnotationRules:R}),m);return u.createElement(nt,{componentName:"ConnectedScatterplot",width:S,height:M},u.createElement(he,Object.assign({},J)))}function bt(t){const n=Ye(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:s,className:i,xFormat:r,yFormat:l,xAccessor:a="x",yAccessor:c="y",sizeBy:h,sizeRange:d=[5,40],colorBy:f,colorScheme:g="category10",bubbleOpacity:p=.6,bubbleStrokeWidth:y=1,bubbleStrokeColor:m="white",tooltip:b,marginalGraphics:v,pointIdAccessor:x,annotations:k,frameProps:w={},selection:A,linkedHover:E,linkedBrush:S,onObservation:M,chartId:O,loading:C,emptyContent:L,legendInteraction:j}=t,N=n.width,B=n.height,H=n.enableHover,_=n.showGrid,W=n.showLegend,$=n.title,z=n.xLabel,I=n.yLabel,F=rt(C,N,B);if(F)return F;const P=it(o,N,B,L);if(P)return P;const T=o||[],{activeSelectionHook:D,customHoverBehavior:R}=Pe({selection:A,linkedHover:E,fallbackFields:f?["string"==typeof f?f:""]:[],onObservation:M,chartType:"BubbleChart",chartId:O}),Y=We(S);je({name:(null==Y?void 0:Y.name)||"__unused_brush__",xField:(null==Y?void 0:Y.xField)||("string"==typeof a?a:void 0),yField:(null==Y?void 0:Y.yField)||("string"==typeof c?c:void 0)});const G=Fe(T,f,g),X=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of T){const n="function"==typeof f?f(t):t[f];null!=n&&e.add(n+"")}return Array.from(e)},[T,f]),q=De(j,f,X),V=e.useMemo(()=>q.legendSelectionHook?q.legendSelectionHook:D,[q.legendSelectionHook,D]),U=e.useMemo(()=>{const e=T.map(e=>"function"==typeof h?h(e):e[h]);return[Math.min(...e),Math.max(...e)]},[T,h]),Z=e.useMemo(()=>e=>{const t={fillOpacity:p,strokeWidth:y,stroke:m};return t.fill=f?ge(e,f,G):ze,t.r=ye(e,h,d,U),t},[f,G,h,d,U,p,y,m]),J=e.useMemo(()=>$e(Z,V,A),[Z,V,A]),{legend:K,margin:Q}=Te({data:T,colorBy:f,colorScale:G,showLegend:W,userMargin:s,defaults:n.marginDefaults}),ee=e.useMemo(()=>Je([{label:z||Ze(a),accessor:a,role:"x"},{label:I||Ze(c),accessor:c,role:"y"},{label:Ze(h),accessor:h,role:"size"},...f?[{label:Ze(f),accessor:f,role:"color"}]:[]]),[a,c,z,I,h,f]),te=ut({componentName:"BubbleChart",data:T,accessors:{xAccessor:a,yAccessor:c},requiredProps:{sizeBy:h}});if(te)return u.createElement(Ke,{componentName:"BubbleChart",message:te,width:N,height:B});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:T,xAccessor:a,yAccessor:c,colorAccessor:f||void 0,sizeAccessor:h,sizeRange:d,pointStyle:J,colorScheme:g,size:[N,B],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Q,showAxes:n.showAxes,xLabel:z,yLabel:I,xFormat:r,yFormat:l,enableHover:H,showGrid:_},K&&{legend:K}),j&&"none"!==j&&{legendHoverBehavior:q.onLegendHover,legendClickBehavior:q.onLegendClick,legendHighlightedCategory:q.highlightedCategory,legendIsolatedCategories:q.isolatedCategories}),$&&{title:$}),i&&{className:i}),{tooltipContent:Ue(b)||ee}),(E||M)&&{customHoverBehavior:R}),v&&{marginalGraphics:v}),x&&{pointIdAccessor:x}),k&&k.length>0&&{annotations:k}),w);return u.createElement(nt,{componentName:"BubbleChart",width:N,height:B},u.createElement(he,Object.assign({},ne)))}function vt(t){const n=Ye(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:i,className:r,xAccessor:a="x",yAccessor:c="y",valueAccessor:h="value",xFormat:d,yFormat:f,colorScheme:g="blues",customColorScale:p,showValues:y=!1,valueFormat:m,cellBorderColor:b="#fff",cellBorderWidth:v=1,tooltip:x,annotations:k,frameProps:w={},selection:A,linkedHover:E,onObservation:S,chartId:M,loading:O,emptyContent:C,legendInteraction:L}=t,j=n.width,N=n.height,B=n.enableHover,H=n.title,_=n.xLabel,W=n.yLabel,$=rt(O,j,N);if($)return $;const z=it(s,j,N,C);if(z)return z;const I=s||[],{margin:F}=Te({data:I,colorBy:void 0,colorScale:void 0,showLegend:!1,userMargin:i,defaults:n.marginDefaults}),{activeSelectionHook:P,customHoverBehavior:T}=Pe({selection:A,linkedHover:E,fallbackFields:[],onObservation:S,chartType:"Heatmap",chartId:M}),D=De(L,void 0,[]),R=e.useMemo(()=>D.legendSelectionHook?D.legendSelectionHook:P,[D.legendSelectionHook,P]),Y=e.useMemo(()=>"function"==typeof h?e=>h(e):e=>e[h],[h]),G=e.useMemo(()=>{const e=I.map(Y);return[Math.min(...e),Math.max(...e)]},[I,Y]),X=e.useMemo(()=>"custom"===g&&p?p:o.scaleSequential({blues:l.interpolateBlues,reds:l.interpolateReds,greens:l.interpolateGreens,viridis:l.interpolateViridis}[g]||l.interpolateBlues).domain(G),[g,p,G]);e.useMemo(()=>{const e=Ie(a),t=Ie(c);return{xBinCount:new Set(I.map(e)).size,yBinCount:new Set(I.map(t)).size}},[I,a,c]),e.useMemo(()=>({coordinates:I}),[I]);const q=e.useMemo(()=>e=>{const t=Y(e);return{fill:X(t),stroke:b,strokeWidth:v}},[Y,X,b,v]);e.useMemo(()=>$e(q,R,A),[q,R,A]),e.useMemo(()=>{if(!y)return;const e=(G[0]+G[1])/2;return(t,n)=>{const o=Y(t),s=m?m(o):o+"";return u.createElement("text",{textAnchor:"middle",dominantBaseline:"middle",fill:Y(t)>e?"#fff":"#000",fontSize:"12px"},s)}},[y,Y,m,G]);const V=e.useMemo(()=>Je([{label:_||Ze(a),accessor:a,role:"x"},{label:W||Ze(c),accessor:c,role:"y"},{label:Ze(h),accessor:h,role:"value"}]),[a,c,_,W,h]),U=ut({componentName:"Heatmap",data:I,accessors:{xAccessor:a,yAccessor:c,valueAccessor:h}});if(U)return u.createElement(Ke,{componentName:"Heatmap",message:U,width:j,height:N});const Z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap",data:I,xAccessor:a,yAccessor:c,valueAccessor:h,size:[j,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:F,showAxes:n.showAxes,xLabel:_,yLabel:W,xFormat:d,yFormat:f,enableHover:B},H&&{title:H}),r&&{className:r}),{tooltipContent:Ue(x)||V}),(E||S)&&{customHoverBehavior:T}),k&&k.length>0&&{annotations:k}),w);return u.createElement(nt,{componentName:"Heatmap",width:j,height:N},u.createElement(he,Object.assign({},Z)))}ft.displayName="LineChart",gt.displayName="AreaChart",pt.displayName="StackedAreaChart",yt.displayName="Scatterplot",mt.displayName="ConnectedScatterplot",bt.displayName="BubbleChart",vt.displayName="Heatmap";const xt="__splomIdx",kt={top:4,bottom:4,left:4,right:4};function wt({frameRef:o,cellSize:s,onBrush:i}){const r=e.useRef(null),l=s-kt.left-kt.right,a=s-kt.top-kt.bottom;return e.useEffect(()=>{if(!r.current)return;const e=n.select(r.current).select(".brush-g"),s=t.brush().extent([[0,0],[l,a]]).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[[s,r],[l,a]]=e.selection,c=[[n.x.invert(s),n.y.invert(r)],[n.x.invert(l),n.y.invert(a)]];i(c)});return e.call(s),e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{s.on("brush end",null)}},[l,a,o,i]),u.createElement("svg",{ref:r,width:s,height:s,style:{position:"absolute",top:0,left:0}},u.createElement("g",{className:"brush-g",transform:`translate(${kt.left},${kt.top})`}))}function At({data:t,xField:n,yField:o,cellSize:s,pointRadius:i,pointOpacity:r,colorBy:l,colorScale:a,brushSelectionName:c,hoverSelectionName:h,unselectedOpacity:d,mode:f,onPointHover:g}){const p=e.useRef(null),y=Ce({name:c,clientId:`splom-${n}-${o}`}),m=je({name:c,xField:n,yField:o}),b=Ce({name:h,clientId:"splom-hover-source"}),v=b.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[xt];void 0!==n&&(v({[xt]:[n]}),null==g||g(t,e.x+kt.left,e.y+kt.top))},[v,g]),w=e.useCallback(e=>{const t={opacity:r,r:i};return t.fill=l?ge(e,l,a):ze,"hover"===f?b.isActive&&b.predicate(e)?(t.opacity=1,t.r=2.5*i,t.stroke="#333",t.strokeWidth=1.5):b.isActive&&(t.opacity=.6*r):y.isActive&&!y.predicate(e)&&(t.opacity=d),t},[l,a,r,i,f,y.isActive,y.predicate,b.isActive,b.predicate,d]);return u.createElement("div",{style:{position:"relative",width:s,height:s}},u.createElement(he,{ref:p,chartType:"scatter",data:t,size:[s,s],xAccessor:n,yAccessor:o,pointStyle:w,margin:kt,showAxes:!1,enableHover:"hover"===f,customHoverBehavior:"hover"===f?k:void 0,tooltipContent:"hover"===f?()=>null:void 0}),"brush"===f&&u.createElement(wt,{frameRef:p,cellSize:s,xField:n,yField:o,onBrush:x}))}function Et({data:t,field:n,label:o,cellSize:s,bins:i,brushSelectionName:r,hoverSelectionName:l,mode:a}){const c=Ce({name:r,clientId:"splom-diag-"+n}),h=Ce({name:l,clientId:`splom-diag-${n}-hover`}),d="hover"===a?h:c,f=d.isActive,g=d.predicate,p=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),r=(Math.max(...e)-o)/i||1,l=Array(i).fill(0),a=Array(i).fill(0);for(const e of t){const t=e[n];if(null==t||isNaN(t))continue;const s=Math.min(Math.floor((t-o)/r),i-1);l[s]++,f&&!g(e)||a[s]++}const c=Math.max(...l,1);return{bars:l.map((e,t)=>({x:t/i*s,w:s/i-1,h:e/c*(s-24),count:e})),selectedBars:a.map((e,t)=>({x:t/i*s,w:s/i-1,h:e/c*(s-24),count:e})),max:c}},[t,n,i,s,f,g]);return u.createElement("svg",{width:s,height:s,style:{overflow:"hidden"}},u.createElement("text",{x:s/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333"},o),p.bars.map((e,t)=>u.createElement("rect",{key:"bg-"+t,x:e.x,y:s-e.h,width:Math.max(e.w,1),height:e.h,fill:"#ccc",opacity:f?.3:.6})),f&&p.selectedBars.map((e,t)=>u.createElement("rect",{key:"sel-"+t,x:e.x,y:s-e.h,width:Math.max(e.w,1),height:e.h,fill:ze,opacity:.7})))}function St({label:e,cellSize:t}){return u.createElement("svg",{width:t,height:t},u.createElement("text",{x:t/2,y:t/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333"},e))}function Mt(t){const{data:n,fields:o,fieldLabels:s={},colorBy:i,colorScheme:r="category10",cellSize:l=150,cellGap:a=4,pointRadius:c=2,pointOpacity:h=.5,diagonal:d="histogram",histogramBins:f=20,brushMode:g="crossfilter",hoverMode:p=!0,unselectedOpacity:y=.1,showGrid:m=!1,tooltip:b,showLegend:v,idAccessor:x,className:k,onObservation:w,chartId:A}=t,E="splom",S="splom-hover",M=p?"hover":g?"brush":"hover",O=Se(e=>e.clearSelection),[C,L]=e.useState(null),j=e.useCallback(()=>{O(S),L(null)},[O,S]),N=e.useMemo(()=>(n||[]).map((e,t)=>void 0!==e[xt]?e:Object.assign(Object.assign({},e),{[xt]:t})),[n]),B=Fe(N,i,r),H=void 0!==v?v:!!i,_=e.useMemo(()=>{if(!H||!i)return null;const e="string"==typeof i?i:null;return e?[...new Set(N.map(t=>t[e]))].map(e=>({label:e+"",color:B?B(e+""):ze})):null},[H,i,N,B]),W=e.useMemo(()=>({display:"grid",gridTemplateColumns:"40px "+o.map(()=>l+"px").join(" "),gridTemplateRows:o.map(()=>l+"px").join(" ")+" 40px",gap:a+"px",width:"fit-content"}),[o,l,a,40]);return u.createElement("div",{className:k,style:{position:"relative"}},_&&u.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},_.map(e=>u.createElement("div",{key:e.label,style:{display:"flex",alignItems:"center",gap:4}},u.createElement("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:e.color}}),u.createElement("span",{style:{fontSize:11}},e.label)))),u.createElement("div",{style:W,onMouseLeave:"hover"===M?j:void 0},o.map((e,t)=>u.createElement(u.Fragment,{key:"row-"+e},u.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"}},s[e]||e),o.map((n,o)=>t===o?"label"===d?u.createElement(St,{key:"diag-"+e,label:s[e]||e,cellSize:l}):u.createElement(Et,{key:"diag-"+e,data:N,field:e,label:s[e]||e,cellSize:l,bins:f,colorBy:i,colorScale:B,brushSelectionName:E,hoverSelectionName:S,unselectedOpacity:y,mode:M}):u.createElement(At,{key:`cell-${e}-${n}`,data:N,xField:n,yField:e,fieldLabels:s,cellSize:l,pointRadius:c,pointOpacity:h,colorBy:i,colorScale:B,brushSelectionName:E,hoverSelectionName:S,unselectedOpacity:y,showGrid:m,tooltip:b,mode:M,onPointHover:"hover"===M?(s,i,r)=>{s?(L({datum:s,xField:n,yField:e,colIndex:o,rowIndex:t,px:null!=i?i:0,py:null!=r?r:0}),w&&w({type:"hover",datum:s,x:null!=i?i:0,y:null!=r?r:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A})):(L(null),w&&w({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A}))}:void 0})))),u.createElement("div",null)," ",o.map(e=>u.createElement("div",{key:"col-label-"+e,style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"}},s[e]||e))),C&&"hover"===M&&(()=>{const e=C.datum,t=s[C.xField]||C.xField,n=s[C.yField]||C.yField,o=i?"function"==typeof i?i(e):e[i]:null,r=x?"function"==typeof x?x(e):e[x]:"Row "+e[xt];return u.createElement("div",{style:{position:"absolute",left:40+C.colIndex*(l+a)+C.px,top:C.rowIndex*(l+a)+C.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}},u.createElement("div",{style:{fontWeight:"bold",marginBottom:2}},r+""),u.createElement("div",null,t,": ",null!=e[C.xField]?Number(e[C.xField]).toFixed(1):"–"),u.createElement("div",null,n,": ",null!=e[C.yField]?Number(e[C.yField]).toFixed(1):"–"),null!=o&&u.createElement("div",{style:{opacity:.8}},"string"==typeof i?i:"group",": ",o+""))})())}function Ot(e){const{brushMode:t="crossfilter",hoverMode:n=!0}=e,o={};return!n&&t&&(o.splom={resolution:t}),n&&(o["splom-hover"]={resolution:"union"}),u.createElement(_e,{selections:o},u.createElement(Mt,Object.assign({},e)))}function Ct({width:o,height:s,margin:i,scales:r,brushDirection:l,extent:a,onBrush:c}){const h=e.useRef(null),d=e.useRef(null),f=e.useRef(!1),g=o+i.left+i.right,p=s+i.top+i.bottom;return e.useEffect(()=>{if(!h.current||!r)return;const e=n.select(h.current).select(".brush-group"),i="x"===l?t.brushX().extent([[0,0],[o,s]]):t.brushY().extent([[0,0],[o,s]]);return i.on("brush end",e=>{if(f.current)return;if(!e.sourceEvent)return;const t=e.selection;if(!t)return void c(null);const n=("x"===l?r.x:r.y).invert;if(!n)return;const o=[n(t[0]),n(t[1])];c(o)}),e.call(i),d.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null)}},[r,o,s,l,c]),e.useEffect(()=>{if(!d.current||!r||!h.current)return;const e=n.select(h.current).select(".brush-group"),t="x"===l?r.x:r.y;if(f.current=!0,a){const n=[t(a[0]),t(a[1])];e.call(d.current.move,n)}else e.call(d.current.move,null);f.current=!1},[a,r,l]),u.createElement("svg",{ref:h,width:g,height:p,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},u.createElement("g",{className:"brush-group",transform:`translate(${i.left},${i.top})`}))}function Lt(t){var n,o;const{data:s,width:i=600,height:r=400,margin:l,className:a,title:c,xLabel:h,yLabel:d,xFormat:f,yFormat:g,xAccessor:p="x",yAccessor:y="y",lineBy:m,lineDataAccessor:b="coordinates",colorBy:v,colorScheme:x="category10",curve:k="linear",lineWidth:w=2,fillArea:A=!1,areaOpacity:E=.3,showPoints:S=!1,pointRadius:M=3,enableHover:O=!0,showGrid:C=!1,showLegend:L,tooltip:j,minimap:N={},renderBefore:B=!1,onBrush:H,brushExtent:_,frameProps:W={},loading:$,emptyContent:z}=t,I=rt($,i,r);if(I)return I;const F=it(s,i,r,z);if(F)return F;const P=s||[],[T,D]=e.useState(null),R=null!=_?_:T,Y=e.useCallback(e=>{_||D(e),null==H||H(e)},[_,H]),G=e.useRef(null),[X,q]=e.useState(null);e.useEffect(()=>{const e=()=>{var t,n;const o=null===(n=null===(t=G.current)||void 0===t?void 0:t.getScales)||void 0===n?void 0:n.call(t);o?q(o):requestAnimationFrame(e)};requestAnimationFrame(e)},[s]);const V=void 0!==(null===(n=P[0])||void 0===n?void 0:n[b]),U=e.useMemo(()=>{if(V)return P;if(m){const e=P.reduce((e,t)=>{const n="function"==typeof m?m(t):t[m];if(!e[n]){const t={[b]:[]};"string"==typeof m&&(t[m]=n),e[n]=t}return e[n][b].push(t),e},{});return Object.values(e)}return[{[b]:P}]},[P,m,b,V]),Z=e.useMemo(()=>V||m?U.flatMap(e=>{const t=e[b]||[];return m&&"string"==typeof m?t.map(t=>Object.assign(Object.assign({},t),{[m]:e[m]})):t}):P,[U,b,V,m,P]),J=Fe(P,v,x),K=e.useMemo(()=>e=>{const t={strokeWidth:w};return t.stroke=v?ge(e,v,J):ze,A&&(t.fill=t.stroke,t.fillOpacity=E),t},[v,J,w,A,E]),Q=e.useMemo(()=>N.lineStyle?N.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=v?ge(e,v,J):ze,t},[v,J,N.lineStyle]),ee=e.useMemo(()=>{if(S)return e=>{const t={r:M,fillOpacity:1};return t.fill=v?ge(e.parentLine||e,v,J):ze,t}},[S,M,v,J]),{legend:te,margin:ne}=Te({data:U,colorBy:v,colorScale:J,showLegend:L,userMargin:l}),oe=N.height||60,se=e.useMemo(()=>{var e,t,n,o,s,i,r,l;return{top:null!==(t=null===(e=N.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(o=null===(n=N.margin)||void 0===n?void 0:n.bottom)&&void 0!==o?o:20,left:null!==(i=null===(s=N.margin)||void 0===s?void 0:s.left)&&void 0!==i?i:ne.left,right:null!==(l=null===(r=N.margin)||void 0===r?void 0:r.right)&&void 0!==l?l:ne.right}},[N.margin,ne]),ie=N.brushDirection||"x",re=ut({componentName:"MinimapChart",data:P,accessors:{xAccessor:p,yAccessor:y}});if(re)return u.createElement(Ke,{componentName:"MinimapChart",message:re,width:i,height:r});const le=A?"area":"line",ae=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:le,data:Z,xAccessor:p,yAccessor:y,groupAccessor:m||void 0,curve:k,lineStyle:K},S&&{pointStyle:ee}),{size:[i,r],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ne,showAxes:!0,xLabel:h,yLabel:d,xFormat:f,yFormat:g,enableHover:O,showGrid:C}),te&&{legend:te}),c&&{title:c}),j&&{tooltipContent:Ue(j)||void 0}),R&&{xExtent:R}),W),ce={chartType:le,data:Z,xAccessor:p,yAccessor:y,groupAccessor:m||void 0,curve:k,lineStyle:Q,size:[i,oe+se.top+se.bottom],margin:se,showAxes:null!==(o=N.showAxes)&&void 0!==o&&o,background:N.background,enableHover:!1},ue=u.createElement("div",{key:"minimap",style:{position:"relative",width:i,overflow:"hidden"}},u.createElement(he,Object.assign({ref:G},ce)),u.createElement(Ct,{width:i-se.left-se.right,height:oe,margin:se,scales:X,brushDirection:ie,extent:R,onBrush:Y})),de=u.createElement("div",{key:"main",style:{overflow:"hidden"}},u.createElement(he,Object.assign({},ae)));return u.createElement("div",{className:"minimap-chart"+(a?" "+a:"")},B?ue:de,B?de:ue)}Ot.displayName="ScatterplotMatrix",Lt.displayName="MinimapChart",exports.AreaChart=gt,exports.BubbleChart=bt,exports.ConnectedScatterplot=mt,exports.Heatmap=vt,exports.LineChart=ft,exports.MinimapChart=Lt,exports.Scatterplot=yt,exports.ScatterplotMatrix=Ot,exports.StackedAreaChart=pt,exports.StreamXYFrame=he;
|
|
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"),s=require("d3-array"),a=require("d3-hierarchy"),l=require("d3-shape"),c=require("regression");function u(e){return e&&e.__esModule?e:{default:e}}function h(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 d=h(e),g=u(c);class p{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 y{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 f{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function m(e,t,n,o,r){const i=new Map;for(const s of e){const e=t(s),a=n(s);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))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+=a,r){const e=r(s);c.categories.set(e,(c.categories.get(e)||0)+a)}}return i}function v(e,t,n,o,r,i){const s=[];for(const r of e){const e=n(r),i=o(r);null==e||null==i||Number.isNaN(e)||Number.isNaN(i)||s.push({px:t.x(e),py:t.y(i),rawY:i,d:r})}s.sort((e,t)=>e.px-t.px);const a=Array(s.length),l=Array(s.length),c=Array(s.length);for(let e=0;s.length>e;e++){const t=s[e];a[e]=[t.px,t.py],l[e]=t.rawY,c[e]=t.d}return{type:"line",path:a,rawValues:l,style:r,datum:c,group:i}}function b(e,t,n,o,r,i,s,a){const l=[];for(const i of e){const e=n(i),s=o(i);if(null==e||null==s||Number.isNaN(e)||Number.isNaN(s))continue;const c=t.x(e),u=a?a(i):r;l.push({px:c,topY:t.y(s),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:s}}function x(e,t,n,o,r,i,s){const a=n(e),l=o(e);if(null==a||null==l||Number.isNaN(a)||Number.isNaN(l))return null;const c={type:"point",x:t.x(a),y:t.y(l),r:r,style:i,datum:e};return void 0!==s&&(c.pointId=s),c}function k(e,t,n,o,r,i,s){return{type:"rect",x:e,y:t,w:n,h:o,style:r,datum:i,group:s}}function w(e,t,n,o,r,i,s){const a={type:"heatcell",x:e,y:t,w:n,h:o,fill:r,datum:i};return(null==s?void 0:s.showValues)&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function A(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function S(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function O(e,t){return"function"==typeof e?e:e?t=>t[e]+"":void 0}const M={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},E=r.schemeCategory10,j=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],C=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 P(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")||C.has(t)}(o)?n(o):o}const o=e[t];return n?n(o):E[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+""))%E.length]}function _(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 s=M[n]||M.category10;if(i&&"function"==typeof s){let e=-1/0;for(const t of r){const n=Number(t);n>e&&(e=n)}return t=>s(Number(t)/e)}{const e=Array.isArray(s)?s:E;return o.scaleOrdinal().domain(r).range(e).unknown("#999")}}function L(e,t,n=[3,20],o){let r;if(r="function"==typeof t?t(e):e[t],!o)return r;const[i,s]=o,[a,l]=n;return s===i?(a+l)/2:a+(r-i)/(s-i)*(l-a)}function B(e,t,n){return e+(t-e)*n}class N{constructor(e){this.xExtent=new f,this.yExtent=new f,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 y(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=A(e.timeAccessor||e.xAccessor,"time"),this.getY=A(e.valueAccessor||e.yAccessor,"value")):(this.getX=A(e.xAccessor,"x"),this.getY=A(e.yAccessor,"y")),this.getGroup=O(e.groupAccessor),this.getCategory=O(e.categoryAccessor),this.getSize=e.sizeAccessor?A(e.sizeAccessor,"size"):void 0,this.getColor=O(e.colorAccessor),this.getBounds=e.boundsAccessor?A(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?A(e.y0Accessor,"y0"):void 0,this.getPointId=O(e.pointIdAccessor),"candlestick"===e.chartType&&(this.getOpen=A(e.openAccessor,"open"),this.getHigh=A(e.highAccessor,"high"),this.getLow=A(e.lowAccessor,"low"),this.getClose=A(e.closeAccessor,"close")),e.pulse&&(this.timestampBuffer=new y(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,s,a;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(),h=this.xExtent.extent,d=this.yExtent.extent;let g=l.xExtent?[null!==(t=l.xExtent[0])&&void 0!==t?t:h[0],null!==(n=l.xExtent[1])&&void 0!==n?n:h[1]]:h,p=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 y=l.yExtent&&null!=l.yExtent[0]&&null!=l.yExtent[1];if("stackedarea"===l.chartType&&!y&&c.size>0)if(l.normalize)p=[0,1+l.extentPadding];else{const e=`${c.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===e)p=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);p=[0,o+(o>0?o*l.extentPadding:1)],this._stackExtentCache={key:e,yDomain:p}}}else if("bar"===l.chartType&&l.binSize&&!y&&c.size>0){const[,e]=function(e,t,n,o,r){const i=m(e,t,n,o,r);if(0===i.size)return[0,0];let s=0;for(const e of i.values())e.total>s&&(s=e.total);return[0,s]}(c,this.getX,this.getY,l.binSize,this.getCategory);p=[0,e+e*l.extentPadding]}else if("waterfall"===l.chartType&&!y&&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;p=[Math.min(0,e-Math.abs(o)),Math.max(0,t+Math.abs(o))]}else if(!y&&p[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>p[1]&&(p[1]=t+n),p[0]>t-n&&(p[0]=t-n))}const e=p[1]-p[0],t=e>0?e*l.extentPadding:1,n=null===(s=l.yExtent)||void 0===s?void 0:s[0],o=null===(a=l.yExtent)||void 0===a?void 0:a[1];p=[null!=n?p[0]:p[0]-t,null!=o?p[1]:p[1]+t],"log"===l.yScaleType&&0>=p[0]&&d[0]>0&&(p[0]=null!=n?p[0]:d[0]/(1+l.extentPadding))}if(g[0]!==1/0&&g[1]!==-1/0||(g=[0,1]),p[0]!==1/0&&p[1]!==-1/0||(p=[0,1]),"streaming"===l.runtimeMode)if("x"==("up"===(f=l.arrowOfTime)||"down"===f?"y":"x")){const t="right"===l.arrowOfTime?[0,e.width]:[e.width,0];this.scales={x:o.scaleLinear().domain(g).range(t),y:o.scaleLinear().domain(p).range([e.height,0])}}else{const t="down"===l.arrowOfTime?[0,e.height]:[e.height,0];this.scales={x:o.scaleLinear().domain(p).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,p,[e.height,0])}}var f;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>N.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(),s=this.scales.x.range(),a=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,[s[0]*t,s[1]*t]),y:l(this.config.yScaleType,i,[a[0]*n,a[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=v(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=b(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,s){var a;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 h;if(i){h=new Map;for(const t of c){let n=0;for(const o of e)n+=(null===(a=u.get(o.key))||void 0===a?void 0:a.get(t))||0;h.set(t,n||1)}}const d=[],g=new Map;for(const e of c)g.set(e,0);for(const n of e){const e=u.get(n.key),o=[],a=[];for(const n of c){let r=e.get(n)||0;const s=g.get(n);i&&(r/=h.get(n));const l=t.x(n);a.push([l,t.y(s)]),o.push([l,t.y(s+r)]),g.set(n,s+r)}const l={type:"area",topPath:o,bottomPath:a,style:r(n.key,n.data[0]),datum:n.data,group:n.key};s&&(l.curve=s),d.push(l)}return d}(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},s=e.r||n;if(r&&this.getSize){const e=this.getSize(o);null==e||Number.isNaN(e)||(s=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 a=this.getPointId?this.getPointId(o)+"":void 0,l=x(o,this.scales,this.getX,this.getY,s,e,a);l&&t.push(l)}return t}buildHeatmapScene(e,t){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(e,t);const i=A(this.config.valueAccessor,"value"),s=S(this.config.xAccessor,"x"),a=S(this.config.yAccessor,"y"),l=new Set,c=new Set;for(const t of e)l.add(s(t)),c.add(a(t));const u=Array.from(l),h=Array.from(c),d=u.every(e=>"number"==typeof e&&!isNaN(e)),g=h.every(e=>"number"==typeof e&&!isNaN(e)),p=d?u.sort((e,t)=>e-t):u,y=g?h.sort((e,t)=>e-t):h;if(0===p.length||0===y.length)return n;const f=t.width/p.length,m=t.height/y.length,v=new Map;for(const t of e){const e=`${s(t)}\0${a(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;p.length>e;e++)for(let t=0;y.length>t;t++){const o=v.get(`${p[e]}\0${y[t]}`);if(!o)continue;const r=k(o.val);n.push(w(e*f,(y.length-1-t)*m,f,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=[],s=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,a=null!==(o=this.config.heatmapYBins)&&void 0!==o?o:20,l=null!==(r=this.config.heatmapAggregation)&&void 0!==r?r:"count",c=A(this.config.valueAccessor,"value");if(!this.scales||0===e.length)return i;const[u,h]=this.scales.x.domain(),[d,g]=this.scales.y.domain(),p=(h-u||1)/s,y=(g-d||1)/a,f=new Map;for(const t of e){const e=this.getX(t),n=this.getY(t),o=Math.min(Math.floor((e-u)/p),s-1),r=Math.min(Math.floor((n-d)/y),a-1);if(0>o||0>r)continue;const i=`${o}_${r}`;let l=f.get(i);l||(l={sum:0,count:0,data:[]},f.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 f){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/s,S=t.height/a;for(const[e,t]of b){const[n,o]=e.split("_"),r=+n,s=+o,l=(t-m)/x,c=`rgb(${Math.round(220-180*l)},${Math.round(220-100*l)},${Math.round(255-50*l)})`,u=f.get(e);i.push(w(r*k,(a-1-s)*S,k,S,c,{xi:r,yi:s,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=m(e,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===n.size)return[];let o=null;if(this.getCategory){const e=new Set;for(const t of n.values())for(const n of t.categories.keys())e.add(n);const t=this.config.barColors?Object.keys(this.config.barColors):[],r=new Set(t),i=Array.from(e).filter(e=>!r.has(e)).sort(),s=t.filter(t=>e.has(t)),a=s.join("\0")+""+i.join("\0");this._barCategoryCache&&this._barCategoryCache.key===a?o=this._barCategoryCache.order:(o=[...s,...i],this._barCategoryCache={key:a,order:o})}const r=[],i=this.scales,[s,a]=i.x.domain();for(const e of n.values()){const n=Math.max(e.start,s),l=Math.min(e.end,a);if(n>=l)continue;const c=i.x(n),u=i.x(l),h=Math.abs(u-c),d=h>2?1:0,g=Math.min(c,u)+d/2,p=Math.max(h-d,1);if(p>0)if(o&&e.categories.size>0){let n=0;for(const s of o){const o=e.categories.get(s)||0;if(0===o)continue;const a=i.y(n),l=i.y(n+o);r.push(k(g,Math.min(a,l),p,Math.abs(a-l),{fill:(null===(t=this.config.barColors)||void 0===t?void 0:t[s])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:s,categoryValue:o},s)),n+=o}}else{const t=i.y(0),n=i.y(e.total);r.push(k(g,Math.min(t,n),p,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=[],s=this.config.swarmStyle||{},a=null!==(t=s.radius)&&void 0!==t?t:3,l=null!==(n=s.fill)&&void 0!==n?n:"#007bff",c=null!==(o=s.opacity)&&void 0!==o?o:.7,u=s.stroke,h=s.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),s=this.scales.y(n);let d=l;if(this.getCategory){const e=this.getCategory(t);d=(null===(r=this.config.barColors)||void 0===r?void 0:r[e])||d}const g={type:"point",x:o,y:s,r:a,style:{fill:d,opacity:c,stroke:u,strokeWidth:h},datum:t};this.getPointId&&(g.pointId=this.getPointId(t)+""),i.push(g)}return i}buildWaterfallScene(e,t){var n,o,r;const i=[],s=this.scales,a=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==a?void 0:a.positiveColor)&&void 0!==n?n:"#28a745",u=null!==(o=null==a?void 0:a.negativeColor)&&void 0!==o?o:"#dc3545",h=null!==(r=null==a?void 0:a.gap)&&void 0!==r?r:1,d=null==a?void 0:a.stroke,g=null==a?void 0:a.strokeWidth;let p=0;for(let e=0;l.length>e;e++){const n=l[e],o=this.getX(n),r=this.getY(n),y=p+r;let f;f=l.length-1>e?this.getX(l[e+1])-o:e>0?o-this.getX(l[e-1]):0;const m=s.x(o),v=0!==f?s.x(o+f):m+t.width/10,b=Math.min(m,v)+h/2,x=Math.max(m,v)-h/2-b;if(0>=x){p=y;continue}const w=s.y(p),A=s.y(y);i.push(k(b,Math.min(w,A),x,Math.abs(w-A),{fill:0>r?u:c,stroke:d,strokeWidth:g},Object.assign(Object.assign({},n),{baseline:p,cumEnd:y,delta:r,_connectorStroke:null==a?void 0:a.connectorStroke,_connectorWidth:null==a?void 0:a.connectorWidth}))),p=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",s=o.wickColor||"#333",a=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),h=this.getClose(t);if([o,l,u,h].some(e=>null==e||Number.isNaN(e)))continue;const d=h>=o;n.push({type:"candlestick",x:this.scales.x(e),openY:this.scales.y(o),closeY:this.scales.y(h),highY:this.scales.y(l),lowY:this.scales.y(u),bodyWidth:c,upColor:r,downColor:i,wickColor:s,wickWidth:a,isUp:d,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),s=this.scales.x(e);if(i&&0!==i)n.push([s,this.scales.y(r+i)]),o.push([s,this.scales.y(r-i)]);else{const e=this.scales.y(r);n.push([s,e]),o.push([s,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 s=null!==(n=i.minOpacity)&&void 0!==n?n:.1,a=t-1-e;switch(i.type){case"linear":return s+(1-a/(t-1))*(1-s);case"exponential":{const e=null!==(o=i.halfLife)&&void 0!==o?o:t/2;return s+Math.pow(.5,a/e)*(1-s)}case"step":return(null!==(r=i.stepThreshold)&&void 0!==r?r:.5*t)>a?1:s;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 s=i.get(e[t]);null!=s?(n[t]=this.computeDecayOpacity(s,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 s=!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]&&(s=!0)):o[t]=1}s&&(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 s=this.computeDecayOpacity(e,r);if("heatcell"===t.type)t.style={opacity:s};else if("candlestick"===t.type)t._decayOpacity=s;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*s})}}}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)",s=null!==(o=this.config.pulse.glowRadius)&&void 0!==o?o:4,a=new Map;for(let e=0;t.length>e;e++)a.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=a.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=a.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=s)}}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,s,a,l,c,u,h,d,g,p,y,f,m,v,b,x,k,w,A,S,O;if(!this.config.transition||0===this.prevPositionMap.size&&0===this.prevPathMap.size)return;const M=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 E=!1;const j=new Set,C=new Set;for(let e=0;this.scene.length>e;e++){const f=this.scene[e],m=this.getNodeIdentity(f,e);if(!m)continue;if(f._transitionKey=m,"line"===f.type||"area"===f.type){const e=this.prevPathMap.get(m);if(e){if(C.add(m),"line"===f.type&&e.path&&e.path.length===f.path.length){f._targetPath=f.path.map(e=>[e[0],e[1]]),f._prevPath=e.path;for(let t=0;f.path.length>t;t++)f.path[t]=[e.path[t][0],e.path[t][1]];E=!0}else if("area"===f.type&&e.topPath&&e.bottomPath&&e.topPath.length===f.topPath.length&&e.bottomPath.length===f.bottomPath.length){f._targetTopPath=f.topPath.map(e=>[e[0],e[1]]),f._targetBottomPath=f.bottomPath.map(e=>[e[0],e[1]]),f._prevTopPath=e.topPath,f._prevBottomPath=e.bottomPath;for(let t=0;f.topPath.length>t;t++)f.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;f.bottomPath.length>t;t++)f.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];E=!0}f._targetOpacity=null!==(t=f.style.opacity)&&void 0!==t?t:1}else f._targetOpacity=null!==(n=f.style.opacity)&&void 0!==n?n:1,f.style=Object.assign(Object.assign({},f.style),{opacity:0}),E=!0;continue}const v=this.prevPositionMap.get(m);if("point"===f.type)if(v){j.add(m);const e={x:f.x,y:f.y,r:f.r};f._targetOpacity=null!==(o=f.style.opacity)&&void 0!==o?o:1,v.x===e.x&&v.y===e.y||(f._targetX=e.x,f._targetY=e.y,f._targetR=e.r,f.x=v.x,f.y=v.y,f.r=null!==(r=v.r)&&void 0!==r?r:f.r,E=!0)}else f._targetOpacity=null!==(i=f.style.opacity)&&void 0!==i?i:1,f.style=Object.assign(Object.assign({},f.style),{opacity:0}),E=!0;else if("rect"===f.type)if(v){j.add(m);const e={x:f.x,y:f.y,w:f.w,h:f.h};f._targetOpacity=null!==(s=f.style.opacity)&&void 0!==s?s:1,v.x===e.x&&v.y===e.y&&v.w===e.w&&v.h===e.h||(f._targetX=e.x,f._targetY=e.y,f._targetW=e.w,f._targetH=e.h,f.x=v.x,f.y=v.y,f.w=null!==(a=v.w)&&void 0!==a?a:f.w,f.h=null!==(l=v.h)&&void 0!==l?l:f.h,E=!0)}else f._targetOpacity=null!==(c=f.style.opacity)&&void 0!==c?c:1,f.style=Object.assign(Object.assign({},f.style),{opacity:0}),E=!0;else if("heatcell"===f.type)if(v){j.add(m);const e={x:f.x,y:f.y,w:f.w,h:f.h};f._targetOpacity=null!==(h=null===(u=f.style)||void 0===u?void 0:u.opacity)&&void 0!==h?h:1,v.x===e.x&&v.y===e.y||(f._targetX=e.x,f._targetY=e.y,f._targetW=e.w,f._targetH=e.h,f.x=v.x,f.y=v.y,f.w=null!==(d=v.w)&&void 0!==d?d:f.w,f.h=null!==(g=v.h)&&void 0!==g?g:f.h,E=!0)}else f._targetOpacity=null!==(y=null===(p=f.style)||void 0===p?void 0:p.opacity)&&void 0!==y?y:1,f.style=Object.assign(Object.assign({},f.style||{}),{opacity:0}),E=!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!==(f=t.opacity)&&void 0!==f?f:1},_targetOpacity:0,_transitionKey:e,datum:null};this.exitNodes.push(n),E=!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),E=!0}for(const[e,t]of this.prevPositionMap)if(!j.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!==(O=t.opacity)&&void 0!==O?O:1},_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}E=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),E&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:M})}advanceTransition(e){var t,n,o,r,i,s;if(!this.activeTransition)return!1;const a=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,this.activeTransition),l=function(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}(a,"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=B(r,e._targetOpacity,l)}if(void 0===e._targetX)continue;if(!t)continue;const o=this.prevPositionMap.get(t);if(!o)continue;e.x=B(o.x,e._targetX,l),e.y=B(o.y,e._targetY,l),void 0!==e._targetR&&void 0!==o.r&&(e.r=B(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=B(r,e._targetOpacity,l)}if(void 0===e._targetX)continue;if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=B(n.x,e._targetX,l),e.y=B(n.y,e._targetY,l),void 0!==n.w&&(e.w=B(n.w,e._targetW,l)),void 0!==n.h&&(e.h=B(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:B(o,e._targetOpacity,l)})}if(void 0===e._targetX)continue;if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=B(n.x,e._targetX,l),e.y=B(n.y,e._targetY,l),void 0!==n.w&&(e.w=B(n.w,e._targetW,l)),void 0!==n.h&&(e.h=B(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:B(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]=B(t[o][0],n[o][0],l),e.path[o][1]=B(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!==(s=e.style.opacity)&&void 0!==s?s:1;e.style=Object.assign(Object.assign({},e.style),{opacity:B(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]=B(t[n][0],o[n][0],l),e.topPath[n][1]=B(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]=B(n[t][0],r[t][0],l),e.bottomPath[t][1]=B(n[t][1],r[t][1],l)}}if(a>=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=A(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=A(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=A(this.config.xAccessor,"x"),this.getY=A(this.config.yAccessor,"y"))),void 0!==e.groupAccessor&&(this.getGroup=O(this.config.groupAccessor)),void 0!==e.categoryAccessor&&(this.getCategory=O(this.config.categoryAccessor)),void 0!==e.sizeAccessor&&(this.getSize=this.config.sizeAccessor?A(this.config.sizeAccessor,"size"):void 0),void 0!==e.colorAccessor&&(this.getColor=O(this.config.colorAccessor)),void 0!==e.y0Accessor&&(this.getY0=this.config.y0Accessor?A(this.config.y0Accessor,"y0"):void 0),void 0!==e.pointIdAccessor&&(this.getPointId=O(this.config.pointIdAccessor)),this.needsFullRebuild=!0}}function H(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 z(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 $(e,t,n){var o,r,i,s;if(0===e.path.length)return null;const a=R(e.path,t);if(0>a)return null;const[l,c]=e.path[a];let u;if(e.path.length>1){let o=1/0;const r=Math.max(0,a-1),i=Math.min(e.path.length-2,a);for(let s=r;i>=s;s++){const[r,i]=e.path[s],[a,l]=e.path[s+1],c=T(t,n,r,i,a,l);o>c&&(o=c)}u=o}else{const e=t-l,o=n-c;u=Math.sqrt(e*e+o*o)}const h=null!==(s=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!==s?s:1;return u>Math.max(5,h/2+2)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[a]?e.datum[a]:e.datum,x:l,y:c,distance:u}}function T(e,t,n,o,r,i){const s=r-n,a=i-o,l=s*s+a*a;if(0===l)return Math.sqrt(Math.pow(e-n,2)+Math.pow(t-o,2));let c=((e-n)*s+(t-o)*a)/l;c=Math.max(0,Math.min(1,c));const u=o+c*a;return Math.sqrt(Math.pow(e-(n+c*s),2)+Math.pow(t-u,2))}function W(e,t,n){const o=H(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function I(e,t,n){const o=H(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function F(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,s=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(i*i+s*s)}}return null}function D(e,t,n){if(0===e.topPath.length)return null;const o=R(e.topPath,t);if(0>o)return null;const[r,i]=e.topPath[o],s=t-r,a=n-i,l=Math.sqrt(s*s+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:r,y:i,distance:l}}function R(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}N.QUADTREE_THRESHOLD=500;const G={fill:e=>d.createElement("rect",{style:e,width:16,height:16}),line:e=>d.createElement("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function q(e,t,n,o){let r;return r="function"==typeof n?n(e):(0,G[n])(o(e,t)),r}function Y(){return d.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function X(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function V({config:e,orientation:t="vertical",width:n=100}){const{colorFn:o,domain:r,label:i,format:s}=e,a=s||(e=>Math.round(100*e)/100+""),l="grad-legend-"+d.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),s=Math.max(0,(n-t)/2),c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(d.createElement("stop",{key:e,offset:100*t+"%",stopColor:o(r[0]+t*(r[1]-r[0]))}))}return d.createElement("g",{"aria-label":i||"Gradient legend"},d.createElement("defs",null,d.createElement("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},c)),i&&d.createElement("text",{x:s+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),d.createElement("rect",{x:s,y:0,width:t,height:e,fill:`url(#${l})`,rx:2}),d.createElement("text",{x:s,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[0])),d.createElement("text",{x:s+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[1])))}const c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(d.createElement("stop",{key:e,offset:100*t+"%",stopColor:o(r[1]-t*(r[1]-r[0]))}))}return d.createElement("g",{"aria-label":i||"Gradient legend"},i&&d.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),d.createElement("defs",null,d.createElement("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},c)),d.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${l})`,rx:2}),d.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[1])),d.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[0])))}function Q(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,legendInteraction:s,title:a="Legend",width:l=100,height:c=20,orientation:u="vertical"}=e,[h,g]=d.useState(0),[p,y]=d.useState(0),f=d.useCallback((e,t)=>{g(e),y(t)},[]),m="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:l,legendInteraction:c})=>{let u=24;const h=[];return e.forEach((e,g)=>{u+=5,h.push(d.createElement("line",{key:"legend-top-line legend-symbol-"+g,stroke:"gray",x1:0,y1:u,x2:t,y2:u})),u+=8,e.label&&(u+=16,h.push(d.createElement("text",{key:"legend-text-"+g,y:u,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label)),u+=8),h.push(d.createElement("g",{key:"legend-group-"+g,className:"legend-item",transform:`translate(0,${u})`},((e,t,n,o,r,i,s,a,l,c)=>{const{type:u="fill",styleFn:h,items:g}=e,p=[];let y=0;const f=!(!t&&!n),m="isolate"===c||void 0===c&&null!=r;return g.forEach((e,c)=>{const v=q(e,c,u,h),b=X(e,o,r),x=r&&r.size>0&&r.has(e.label);p.push(d.createElement("g",{key:"legend-item-"+c,transform:`translate(0,${y})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:f?a===i&&c===s?0:-1:void 0,role:f?"option":void 0,"aria-selected":f&&m?x||!1:void 0,"aria-current":f&&!m&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:f?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)+g.length)%g.length;l(a,e);const t=null===(o=n.currentTarget.parentElement)||void 0===o?void 0:o.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:f?t=>{l(a,c),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:f?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:f?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},f&&d.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&&d.createElement(Y,null),d.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),y+=22}),p})(e,n,o,r,i,s,a,g,l,c))),u+=22*e.items.length+8}),h})({legendGroups:t||[],width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:h,focusedItemIndex:p,onFocusedIndexChange:f,legendInteraction:s}):(({legendGroups:e,height:t,width:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u})=>{let h=0;const g=[];e.forEach((e,t)=>{let n=0;e.label&&(n+=16);const p=((e,t,n,o,r,i,s,a,l,c)=>{const{type:u="fill",styleFn:h,items:g}=e,p=[];let y=0;const f=!(!t&&!n),m="isolate"===c||void 0===c&&null!=r;return g.forEach((e,c)=>{const v=q(e,c,u,h),b=X(e,o,r),x=r&&r.size>0&&r.has(e.label);p.push(d.createElement("g",{key:"legend-item-"+c,transform:`translate(${y},0)`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:f?a===i&&c===s?0:-1:void 0,role:f?"option":void 0,"aria-selected":f&&m?x||!1:void 0,"aria-current":f&&!m&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:f?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)+g.length)%g.length;l(a,e);const t=null===(o=n.currentTarget.parentElement)||void 0===o?void 0:o.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:f?t=>{l(a,c),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:f?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:f?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},f&&d.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&&d.createElement(Y,null),d.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),y+=26+7*e.label.length}),{items:p,offset:y}})(e,o,r,i,s,a,l,t,c,u);n+=p.offset+5,g.push(Object.assign(Object.assign({label:e.label},p),{offset:n})),h+=n+12});let p=Math.max(0,(n-h)/2);const y=[];return g.forEach((n,o)=>{const r=e[o];r.label&&(y.push(d.createElement("text",{key:"legend-text-"+o,transform:`translate(${p},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},r.label)),p+=16),y.push(d.createElement("g",{key:"legend-group-"+o,className:"legend-item",transform:`translate(${p},0)`},n.items)),p+=n.offset+5,e[o+1]&&y.push(d.createElement("line",{key:"legend-top-line legend-symbol-"+o,stroke:"gray",x1:p,y1:-8,x2:p,y2:t+0+8})),p+=12}),d.createElement("g",null,y)})({legendGroups:t||[],title:a,height:c,width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:h,focusedItemIndex:p,onFocusedIndexChange:f,legendInteraction:s}),v=!(!n&&!o);return d.createElement("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==s&&(void 0!==s||null==i))||void 0,"aria-label":"Chart legend"},void 0!==a&&""!==a&&"vertical"===u&&d.createElement("text",{className:"legend-title",y:16,x:l/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},a),m)}function U(e){return"string"==typeof e?{type:e}:e}function K({orient:t,config:n,values:o,scale:r,size:i,length:a}){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)],s=i-o;return{q1:o,median:r,q3:i,whiskerLow:Math.max(t[0],o-1.5*s),whiskerHigh:Math.min(t[n-1],i+1.5*s)}}(o);if(!e)return null;const{q1:i,median:s,q3:a,whiskerLow:u,whiskerHigh:h}=e,g=Math.min(.5*n,20),p=(n-g)/2+4;if(c){const e=r(i),n=r(a),o=r(s),c=r(u),y=r(h),f="top"===t?-1:1,m=0;return d.createElement("g",{"data-testid":"marginal-boxplot-"+t},d.createElement("line",{x1:c,y1:m+f*(p+g/2),x2:y,y2:m+f*(p+g/2),stroke:l.fill,strokeWidth:l.strokeWidth}),d.createElement("line",{x1:c,y1:m+f*p,x2:c,y2:m+f*(p+g),stroke:l.fill,strokeWidth:l.strokeWidth}),d.createElement("line",{x1:y,y1:m+f*p,x2:y,y2:m+f*(p+g),stroke:l.fill,strokeWidth:l.strokeWidth}),d.createElement("rect",{x:Math.min(e,n),y:"top"===t?m-p-g:m+p,width:Math.abs(n-e),height:g,fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),d.createElement("line",{x1:o,y1:"top"===t?m-p-g:m+p,x2:o,y2:"top"===t?m-p:m+p+g,stroke:l.fill,strokeWidth:2}))}{const e=r(i),n=r(a),o=r(s),c=r(u),y=r(h),f="left"===t?-1:1,m=0;return d.createElement("g",{"data-testid":"marginal-boxplot-"+t},d.createElement("line",{x1:m+f*(p+g/2),y1:c,x2:m+f*(p+g/2),y2:y,stroke:l.fill,strokeWidth:l.strokeWidth}),d.createElement("line",{x1:m+f*p,y1:c,x2:m+f*(p+g),y2:c,stroke:l.fill,strokeWidth:l.strokeWidth}),d.createElement("line",{x1:m+f*p,y1:y,x2:m+f*(p+g),y2:y,stroke:l.fill,strokeWidth:l.strokeWidth}),d.createElement("rect",{x:"left"===t?m-p-g:m+p,y:Math.min(e,n),width:g,height:Math.abs(n-e),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),d.createElement("line",{x1:"left"===t?m-p-g:m+p,y1:o,x2:"left"===t?m-p:m+p+g,y2:o,stroke:l.fill,strokeWidth:2}))}}const u=s.bin().domain(e).thresholds(l.bins)(o);if(0===u.length)return null;const h=Math.max(...u.map(e=>e.length));if(0===h)return null;if("histogram"===l.type)return d.createElement("g",{"data-testid":"marginal-histogram-"+t},u.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const i=e.length/h*n;if(c){const n=r(e.x0),s=r(e.x1)-r(e.x0);return d.createElement("rect",{key:o,x:n,y:"top"===t?-4-i:4,width:Math.max(s,.5),height:i,fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}{const n=r(e.x0),s=r(e.x1)-r(e.x0);return d.createElement("rect",{key:o,x:"left"===t?-4-i:4,y:Math.min(n,n+s),width:i,height:Math.abs(s),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 s=i.length/h*(n/2),a=r((i.x0+i.x1)/2);o.push(c?`${a},${"top"===t?-(e-s):e-s}`:`${"left"===t?-(e-s):e-s},${a}`)}for(let i=u.length-1;i>=0;i--){const s=u[i];if(null==s.x0||null==s.x1)continue;const a=s.length/h*(n/2),l=r((s.x0+s.x1)/2);o.push(c?`${l},${"top"===t?-(e+a):e+a}`:`${"left"===t?-(e+a):e+a},${l}`)}return d.createElement("g",{"data-testid":"marginal-violin-"+t},d.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/h*n,s=r((o.x0+o.x1)/2);e.push(`L${s},${"top"===t?-i-4:i+4}`)}const s=null!=u[u.length-1].x1?r(u[u.length-1].x1):a;e.push(`L${s},${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/h*n,s=r((o.x0+o.x1)/2);e.push(`L${"left"===t?-i-4:i+4},${s}`)}const s=null!=u[u.length-1].x1?r(u[u.length-1].x1):a;e.push(`L${o},${s}`),e.push("Z")}return d.createElement("g",{"data-testid":"marginal-ridgeline-"+t},d.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,a,t,c,4]);return u?d.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},u):null}function Z(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=e.split(/\s+/),i=[];let s="";for(const e of r)s&&s.length+1+e.length>o?(i.push(s),s=e):s=s?`${s} ${e}`:e;return s&&i.push(s),i}function J(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 ee(e){const{x:t=0,y:n=0,dx:o,dy:r,nx:i,ny:s,note:a,connector:l,subject:c,type:u,color:h,className:g,disable:p,events:y={},"data-testid":f}=e,m=new Set(Array.isArray(p)?p:[]);let v=o||0,b=r||0;null!=i&&(v=i-t),null!=s&&(b=s-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 d.createElement("g",Object.assign({className:("annotation "+(g||"")).trim(),transform:`translate(${t},${n})`,"data-testid":f},y),!m.has("connector")&&function(e,t,n,o,r,i){const s=[];let a=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,s=e-r,c=t-i;if(0!==s||0!==c){const e=Math.abs(s),t=Math.abs(c),u=n/2,h=o/2,d=e*h>t*u?u/e:h/t;a=r+s*d,l=i+c*d}}}else if("bracket"===r&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(a=e/2,l=n):void 0!==t&&(a=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);a=Math.cos(o)*n,l=Math.sin(o)*n}}if(Math.sqrt(Math.pow(e-a,2)+Math.pow(t-l,2))>.5&&(s.push(d.createElement("line",{key:"connector-line",x1:a,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-a);s.push(d.createElement("path",{key:"connector-arrow",d:`M${a},${l}L${a+n*Math.cos(i+r)},${l+n*Math.sin(i+r)}L${a+n*Math.cos(i-r)},${l+n*Math.sin(i-r)}Z`,fill:o||"currentColor",stroke:"none"}))}return d.createElement("g",{className:"annotation-connector"},s)}(v,b,l,h,x,c),!m.has("subject")&&function(e,t,n,o,r){var i;const s=[];switch(e){case"callout-circle":{const e=((null==t?void 0:t.radius)||0)+((null==t?void 0:t.radiusPadding)||0);e>0&&s.push(d.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)&&s.push(d.createElement("rect",{key:"subject-rect",width:e,height:o,fill:"none",stroke:n||"currentColor"}));break}case"callout-custom":(null==t?void 0:t.custom)&&s.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;s.push(d.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;s.push(d.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)?s.push(d.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)||s.push(d.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&&s.push(d.createElement("path",{key:"bracket-path",d:J((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 d.createElement("g",{className:"annotation-subject"},s)}(x,c,h,t,n),!m.has("note")&&function(e,t,n,o){if(!e)return d.createElement("g",{className:"annotation-note"});const{label:r,title:i,orientation:s,align:a,wrap:l=120,noWrap:c}=e;if(!r&&!i)return d.createElement("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let h=a;h&&"dynamic"!==h||(h="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let g="start";"topBottom"===u?"right"===h?g="end":"middle"===h&&(g="middle"):g=0>t?"end":"start";const p=16,y=i?c?[i]:Z(i,l):[],f=r?c?[r]:Z(r,l):[],m="leftRight"===u?"end"===g?-4:4:0;let v=0;const b=[];y.length>0&&(b.push(d.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:o||void 0,textAnchor:g,fontWeight:"bold"},y.map((e,t)=>d.createElement("tspan",{key:t,x:m,dy:0===t?0:p},e)))),v=y.length*p),f.length>0&&b.push(d.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:o||void 0,textAnchor:g,y:v},f.map((e,t)=>d.createElement("tspan",{key:t,x:m,dy:0===t?0:p},e))));let x=null;if((i||r)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(l,120);let t=0,n=e;"end"===g?(t=-e,n=0):"middle"===g&&(t=-e/2,n=e/2),x=d.createElement("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"currentColor"})}else{const e=(y.length+f.length)*p+(f.length>0?p:0);let t=0,n=e;"bottom"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),x=d.createElement("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:o||"currentColor"})}const k=Math.max(0,y.length+f.length-1)*p;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===h?-(k+p+(f.length>0&&y.length>0?2:0))/2+8:"bottom"===h||0>n?-(k+2):18),d.createElement("g",{className:"annotation-note",transform:`translate(${t},${n})`},d.createElement("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0},b),x)}(a,v,b,h))}function te(e){var t,n;const{noteData:o}=e,{screenCoordinates:r}=o,i="string"==typeof o.type?o.type:"label",s=o.eventListeners||o.events||{};if(o.coordinates&&r){const e=o.nx||r[0][0]+(null!==(t=o.dx)&&void 0!==t?t:0),s=o.ny||r[0][1]+(null!==(n=o.dy)&&void 0!==n?n:0),a=r.map((t,n)=>{const r=Object.assign({},o,{note:0===n?o.note:{label:""},x:t[0],y:t[1],nx:e,ny:s});return d.createElement(ee,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},r,{type:i}))});return d.createElement("g",null,a)}const a=o.note||{title:"none",label:o.label};return d.createElement(ee,Object.assign({"data-testid":"semiotic-annotation",key:`${a.label}-${a.title}-${o.i}`,events:s},o,{type:i}))}const ne={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 oe(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 re(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 ie(e,t,n){var o,r,i,s;const a=e.anchor||"fixed";if("latest"===a){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,s;const a=e.data;if(!a||0===a.length)return null;const l=a[a.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===(s=e.scales)||void 0===s?void 0:s.value;if(!c||!u)return null;const h=l[e.xAccessor||"x"],d=l[e.yAccessor||"y"];return null==h||null==d?null:{x:c(h),y:u(d)}}(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=oe(e,n),c=re(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"===a){const e=null===(s=n.stickyPositionCache)||void 0===s?void 0:s.get(t);if(e)return e}return null}function se(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function ae(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 s="M0,"+o;for(let e=0;i>e;e++){const n=8*(e+1);s+=`L${Math.min(8*e+4,t)},${o+4*r}`,s+=`L${Math.min(n,t)},${o}`}return s}{const o="bottom"===e?0:t,r="bottom"===e?1:-1,i=Math.ceil(n/8);let s=`M${o},0`;for(let e=0;i>e;e++){const t=8*(e+1);s+=`L${o+4*r},${Math.min(8*e+4,n)}`,s+=`L${o},${Math.min(t,n)}`}return s}}function le(t){const{width:n,height:o,totalWidth:r,totalHeight:i,margin:s,scales:a,showAxes:l,axes:c,showGrid:u,xFormat:h,yFormat:g}=t,p=e.useMemo(()=>{var e;if(!a)return[];const t=null==c?void 0:c.find(e=>"bottom"===e.orient),o=(null==t?void 0:t.tickFormat)||h||ce,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return a.x.ticks(Math.min(r,Math.max(2,Math.floor(n/70)))).map(e=>({value:e,pixel:a.x(e),label:o(e)}))},[a,c,h,n]),y=e.useMemo(()=>{var e;if(!a)return[];const t=null==c?void 0:c.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||g||ce,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return a.y.ticks(Math.min(r,Math.max(2,Math.floor(o/30)))).map(e=>({value:e,pixel:a.y(e),label:n(e)}))},[a,c,g,o]),f=u&&a,m=l&&a;if(!f&&!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 d.createElement("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},d.createElement("g",{transform:`translate(${s.left},${s.top})`},f&&d.createElement("g",{className:"stream-grid"},p.map((e,t)=>d.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),y.map((e,t)=>d.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:n,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),x&&!w&&d.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:S,strokeWidth:1}),w&&d.createElement("path",{d:ae("bottom",n,o),fill:"none",stroke:S,strokeWidth:1}),k&&!A&&d.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:S,strokeWidth:1}),A&&d.createElement("path",{d:ae("left",n,o),fill:"none",stroke:S,strokeWidth:1})))}function ce(e){return Math.round(100*e)/100+""}function ue(e,t){return e instanceof Date&&(!(t&&t instanceof Date)||e.getFullYear()!==t.getFullYear()||e.getMonth()!==t.getMonth()||e.getDate()!==t.getDate())}function he(t){var n,o;const{width:r,height:i,totalWidth:s,totalHeight:c,margin:u,scales:h,showAxes:p,axes:y,xLabel:f,yLabel:m,xFormat:v,yFormat:b,showGrid:x,title:k,legend:w,legendHoverBehavior:A,legendClickBehavior:S,legendHighlightedCategory:O,legendIsolatedCategories:M,legendPosition:E="right",foregroundGraphics:j,marginalGraphics:C,xValues:P,yValues:_,annotations:L,svgAnnotationRules:B,xAccessor:N,yAccessor:H,annotationData:z,pointNodes:$,curve:T,underlayRendered:W,children:I}=t,F=e.useMemo(()=>{var e;if(!p||!h)return[];const t=null==y?void 0:y.find(e=>"bottom"===e.orient),n=(null==t?void 0:t.tickFormat)||v||ce,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return h.x.ticks(Math.min(o,Math.max(2,Math.floor(r/70)))).map(e=>({value:e,pixel:h.x(e),label:n(e)}))},[p,h,y,v,r]),D=e.useMemo(()=>{var e;if(!p||!h)return[];const t=null==y?void 0:y.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||b||ce,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return h.y.ticks(Math.min(o,Math.max(2,Math.floor(i/30)))).map(e=>({value:e,pixel:h.y(e),label:n(e)}))},[p,h,y,b,i]),R=e.useRef(new Map),G=e.useRef(null!==(n=null==L?void 0:L.length)&&void 0!==n?n:0),q=null!==(o=null==L?void 0:L.length)&&void 0!==o?o:0;G.current!==q&&(G.current=q,R.current=new Map);const Y=e.useMemo(()=>{if(!L||0===L.length)return null;const e=function(e,t,n){var o,r,i,s,c,u,h,p,y,f,m,v,b,x,k,w,A,S,O,M,E,j,C,P,_,L,B,N,H,z,$,T,W,I,F,D,R,G,q,Y,X,V,Q,U;switch(e.type){case"label":{const o=ie(e,t,n);if(!o)return null;const{x:r,y:i}=o;return se(r,i,n)?d.createElement(te,{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=ie(e,t,n);if(!o)return null;const{x:r,y:i}=o;return se(r,i,n)?d.createElement(te,{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=oe(e,n);if(null==o)return null;const r=e.color||"#f97316";return d.createElement("g",{key:"ann-"+t},d.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&&d.createElement("text",{x:o+4,y:12,fill:r,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const o=re(e,n);if(null==o)return null;const r=e.color||"#f97316";return d.createElement("g",{key:"ann-"+t},d.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&&d.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:oe(Object.assign(Object.assign({},e),{type:"point"}),n),y:re(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=a.packEnclose(o),i=e.padding||10;return d.createElement("g",{key:"ann-"+t},d.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&&d.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:oe(Object.assign(Object.assign({},e),{type:"point"}),n),y:re(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),s=o.map(e=>e.y),a=Math.min(...i)-r,l=Math.max(...i)+r,c=Math.min(...s)-r,u=Math.max(...s)+r;return d.createElement("g",{key:"ann-"+t},d.createElement("rect",{x:a,y:c,width:l-a,height:u-c,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&d.createElement("text",{x:(a+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 d.createElement("g",{key:"ann-"+t},r.map((t,o)=>{const r=oe(t,n),s=re(t,n);return null==r||null==s?null:d.createElement("circle",Object.assign({key:"hl-"+o,cx:r,cy:s,r:e.r||6},i))}))}case"bracket":{const o=oe(e,n),r=re(e,n);return d.createElement(te,{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 a=n.data||[];if(2>a.length)return null;const l=n.xAccessor||"x",p=n.yAccessor||"y",y=a.map(e=>[e[l],e[p]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>y.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===(s=n.scales)||void 0===s?void 0:s.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]),s=Math.max(2,Math.ceil(t*n)),a=[];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(s-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,h=0,d=0,g=0,p=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,h+=t*r[e],d+=t*i[e],g+=t*r[e]*r[e],p+=t*r[e]*i[e])}if(0===u){a.push([t,i[e]]);continue}const y=u*g-h*h;if(1e-12>Math.abs(y))a.push([t,d/u]);else{const e=(u*p-h*d)/y;a.push([t,(d-e*h)/u+e*t])}}return a}(y,null!==(h=e.bandwidth)&&void 0!==h?h:.3):("polynomial"===v?g.default.polynomial(y,{order:e.order||2}):g.default.linear(y)).points;const x=b.map(([e,t])=>`${f(e)},${m(t)}`).join(" "),k=e.color||"#6366f1";return d.createElement("g",{key:"ann-"+t},d.createElement("polyline",{points:x,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&d.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!==(y=null===(p=n.scales)||void 0===p?void 0:p.y)&&void 0!==y?y: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 d.createElement("g",{key:"ann-"+t},d.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&&d.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,s=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||!s)return null;const a=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",u=e.filter,h=o.filter(e=>null!=e[a]&&null!=e[c]&&!(u&&!u(e))).sort((e,t)=>e[r]-t[r]);if(2>h.length)return null;const g=ne[n.curve||"linear"]||l.curveLinear,p=l.area().x(e=>i(e[r])).y0(e=>s(e[c])).y1(e=>s(e[a])).curve(g)(h);if(!p)return null;const y=e.fill||"#6366f1";return d.createElement("g",{key:"ann-"+t},d.createElement("path",{d:p,fill:y,fillOpacity:null!==(O=e.fillOpacity)&&void 0!==O?O:.15,stroke:"none"}),e.label&&h.length>0&&d.createElement("text",{x:i(h[h.length-1][r])+4,y:s(h[h.length-1][a])-4,fill:y,fontSize:11},e.label))}case"anomaly-band":{const o=n.data||[];if(2>o.length)return null;const r=n.yAccessor||"y",i=null!==(E=null===(M=n.scales)||void 0===M?void 0:M.x)&&void 0!==E?E:null===(j=n.scales)||void 0===j?void 0:j.time,s=null!==(P=null===(C=n.scales)||void 0===C?void 0:C.y)&&void 0!==P?P:null===(_=n.scales)||void 0===_?void 0:_.value;if(!i||!s)return null;const a=o.map(e=>e[r]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const l=a.reduce((e,t)=>e+t,0)/a.length,c=a.reduce((e,t)=>e+Math.pow(t-l,2),0)/a.length,u=Math.sqrt(c),h=null!==(L=e.threshold)&&void 0!==L?L:2,g=l-h*u,p=!1!==e.showBand,y=e.fill||"#6366f1",f=null!==(B=e.fillOpacity)&&void 0!==B?B:.1,m=e.anomalyColor||"#ef4444",v=null!==(N=e.anomalyRadius)&&void 0!==N?N:6,b=s(l+h*u),x=s(g),k=o.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-l)>h*u});return d.createElement("g",{key:"ann-"+t},p&&d.createElement("rect",{x:0,y:Math.min(b,x),width:n.width||0,height:Math.abs(x-b),fill:y,fillOpacity:f}),k.map((e,t)=>{const o=oe(e,n),r=re(e,n);return null==o||null==r?null:d.createElement("circle",{key:"anomaly-"+t,cx:o,cy:r,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5})}),e.label&&d.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",s=null!==(z=null===(H=n.scales)||void 0===H?void 0:H.x)&&void 0!==z?z:null===($=n.scales)||void 0===$?void 0:$.time,a=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(!s||!a)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=g.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 s=(e*r-t*n)/i,a=(n-s*t)/e;c=e=>a+s*e}const u=l.length,h=l.map(([e,t])=>t-c(e)).reduce((e,t)=>e+t*t,0),p=Math.sqrt(h/Math.max(u-2,1)),y=l.reduce((e,t)=>e+t[0],0)/u,f=l.reduce((e,t)=>e+Math.pow(t[0]-y,2),0),m=null!==(F=e.confidence)&&void 0!==F?F:.95,v=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,b=null!==(D=e.steps)&&void 0!==D?D: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=p*Math.sqrt(1+1/u+(f>0?Math.pow(e-y,2)/f:0))*v;A.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const S=`M${A.map(e=>`${s(e.x)},${a(e.yUpper)}`).join(" L")} L${A.slice().reverse().map(e=>`${s(e.x)},${a(e.yLower)}`).join(" L")} Z`,O=A.map(e=>`${s(e.x)},${a(e.yCenter)}`).join(" "),M=`${s(x)},${a(c(x))}`,E=e.strokeColor||"#6366f1";return d.createElement("g",{key:"ann-"+t},d.createElement("path",{d:S,fill:e.fill||"#6366f1",fillOpacity:null!==(R=e.fillOpacity)&&void 0!==R?R:.15,stroke:"none"}),d.createElement("polyline",{points:`${M} ${O}`,fill:"none",stroke:E,strokeWidth:null!==(G=e.strokeWidth)&&void 0!==G?G:2,strokeDasharray:null!==(q=e.strokeDasharray)&&void 0!==q?q:"6,3"}),e.label&&A.length>0&&d.createElement("text",{x:s(A[A.length-1].x)+4,y:a(A[A.length-1].yCenter)-4,fill:E,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=ie(e,t,n);if(!i)return null;o=i.x,r=i.y}if(null==o||null==r)return null;if(!se(o,r,n))return null;const i=null!==(Y=e.dx)&&void 0!==Y?Y:0,s=null!==(X=e.dy)&&void 0!==X?X:0,a=null!==(V=e.width)&&void 0!==V?V:32,l=null!==(Q=e.height)&&void 0!==Q?Q:32,c=null!==(U=e.content)&&void 0!==U?U:d.createElement("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info"},"ℹ️");return d.createElement("foreignObject",{key:"ann-"+t,x:o+i-a/2,y:r+s-l/2,width:a,height:l,style:{overflow:"visible",pointerEvents:"auto"}},d.createElement("div",{style:{width:a,height:l,display:"flex",alignItems:"center",justifyContent:"center"}},c))}case"text":{const o=ie(e,t,n);if(!o)return null;const{x:r,y:i}=o;return d.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}},t={scales:h?{x:h.x,y:h.y,time:h.x,value:h.y}:null,timeAxis:"x",xAccessor:N,yAccessor:H,width:r,height:i,data:z,frameType:"xy",pointNodes:$,curve:T,stickyPositionCache:R.current};return L.map((n,o)=>{if(B){const r=B(n,o,t);return null!=r?r:e(n,o,t)}return e(n,o,t)}).filter(Boolean)},[L,B,r,i,N,H,z,h,$,T]);return p||k||w||j||C||Y&&Y.length>0||x||I?d.createElement("svg",{role:"img",width:s,height:c,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},d.createElement("title",null,"string"==typeof k?k:"XY Chart"),d.createElement("desc",null,"string"==typeof k?k+" — XY data visualization":"XY data visualization"),d.createElement("g",{transform:`translate(${u.left},${u.top})`},x&&h&&!W&&d.createElement("g",{className:"stream-grid"},F.map((e,t)=>d.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),D.map((e,t)=>d.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:r,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),p&&h&&(()=>{const e=null==y?void 0:y.find(e=>"left"===e.orient),t=null==y?void 0:y.find(e=>"bottom"===e.orient),n=!e||!1!==e.baseline,o=(null==e?void 0:e.jaggedBase)||!1,s=(null==t?void 0:t.jaggedBase)||!1,a=null==t?void 0:t.landmarkTicks,l=null==e?void 0:e.landmarkTicks,c="var(--semiotic-border, #ccc)",h="var(--semiotic-text-secondary, #666)",g="var(--semiotic-text, #333)";return d.createElement("g",{className:"stream-axes"},!W&&(!t||!1!==t.baseline)&&!s&&d.createElement("line",{x1:0,y1:i,x2:r,y2:i,stroke:c,strokeWidth:1}),!W&&s&&d.createElement("path",{d:ae("bottom",r,i),fill:"none",stroke:c,strokeWidth:1}),F.map((e,t)=>{const n=!!a&&("function"==typeof a?a(e.value,t):ue(e.value,t>0?F[t-1].value:void 0));return d.createElement("g",{key:"xtick-"+t,transform:`translate(${e.pixel},${i})`},d.createElement("line",{y2:5,stroke:c,strokeWidth:1}),d.createElement("text",{y:18,textAnchor:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:h,style:{userSelect:"none"}},e.label))}),f&&d.createElement("text",{x:r/2,y:i+40,textAnchor:"middle",fontSize:12,fill:g,style:{userSelect:"none"}},f),!W&&n&&!o&&d.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:c,strokeWidth:1}),!W&&o&&d.createElement("path",{d:ae("left",r,i),fill:"none",stroke:c,strokeWidth:1}),D.map((e,t)=>{const n=!!l&&("function"==typeof l?l(e.value,t):ue(e.value,t>0?D[t-1].value:void 0));return d.createElement("g",{key:"ytick-"+t,transform:`translate(0,${e.pixel})`},d.createElement("line",{x2:-5,stroke:c,strokeWidth:1}),d.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:h,style:{userSelect:"none"}},e.label))}),m&&d.createElement("text",{x:15-u.left,y:i/2,textAnchor:"middle",fontSize:12,fill:g,transform:`rotate(-90, ${15-u.left}, ${i/2})`,style:{userSelect:"none"}},m))})(),Y,C&&h&&P&&_&&d.createElement(d.Fragment,null,C.top&&d.createElement("g",{transform:"translate(0, 0)"},d.createElement(K,{orient:"top",config:U(C.top),values:P,scale:h.x,size:u.top,length:r})),C.bottom&&d.createElement("g",{transform:`translate(0, ${i})`},d.createElement(K,{orient:"bottom",config:U(C.bottom),values:P,scale:h.x,size:u.bottom,length:r})),C.left&&d.createElement("g",{transform:"translate(0, 0)"},d.createElement(K,{orient:"left",config:U(C.left),values:_,scale:h.y,size:u.left,length:i})),C.right&&d.createElement("g",{transform:`translate(${r}, 0)`},d.createElement(K,{orient:"right",config:U(C.right),values:_,scale:h.y,size:u.right,length:i}))),j,I),k&&d.createElement("text",{x:s/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof k?k:null),function(e){const{legend:t,totalWidth:n,totalHeight:o,margin:r,legendPosition:i="right",title:s,legendHoverBehavior:a,legendClickBehavior:l,legendHighlightedCategory:c,legendIsolatedCategories:u,legendInteraction:h}=e;if(!t)return null;const g="top"===i||"bottom"===i;let p,y;return"left"===i?(p=4,y=r.top):"top"===i?(p=0,y=s?32:8):"bottom"===i?(p=0,y=o-r.bottom+50):(p=n-r.right+10,y=r.top),d.createElement("g",{transform:`translate(${p}, ${y})`},"object"==typeof(f=t)&&null!==f&&"gradient"in f?d.createElement(V,{config:t.gradient,orientation:g?"horizontal":"vertical",width:g?n:100}):function(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}(t)?d.createElement(Q,{legendGroups:t.legendGroups,title:"",width:g?n:100,orientation:g?"horizontal":"vertical",customHoverBehavior:a,customClickBehavior:l,highlightedCategory:c,isolatedCategories:u,legendInteraction:h}):t);var f}({legend:w,totalWidth:s,totalHeight:c,margin:u,legendPosition:E,title:k,legendHoverBehavior:A,legendClickBehavior:S,legendHighlightedCategory:O,legendIsolatedCategories:M})):null}const de="undefined"==typeof window||"undefined"==typeof document,ge={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"],s=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 s)o.push(`${n[e]} ${r[e]||e}`);return`${t}, ${o.join(", ")}`}function ye({scene:e,chartType:t}){var n,o,r,i;const s=[];for(const t of e){if(s.length>=50)break;"point"===t.type?s.push({label:"Point",values:{x:Math.round(100*t.x)/100+"",y:Math.round(100*t.y)/100+""}}):"rect"===t.type?s.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&&s.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===s.length)return null;const a=new Set;for(const e of s)for(const t of Object.keys(e.values))a.add(t);const l=Array.from(a);return d.createElement("table",{style:ge,role:"table","aria-label":"Data table for "+t},d.createElement("thead",null,d.createElement("tr",null,l.map(e=>d.createElement("th",{key:e},e)))),d.createElement("tbody",null,s.map((e,t)=>d.createElement("tr",{key:t},l.map(t=>{var n;return d.createElement("td",{key:t},null!==(n=e.values[t])&&void 0!==n?n:"")}))),e.length>50&&d.createElement("tr",null,d.createElement("td",{colSpan:l.length},"...and ",e.length-50," more items"))))}function fe({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 d.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:ge},t)}function me(t){const n=e.createContext(null),o=ve(t);return[function({children:o}){const r=e.useMemo(()=>ve(t),[]);return d.createElement(n.Provider,{value:r,children:o})},t=>{var r;const i=null!==(r=e.useContext(n))&&void 0!==r?r:o,s=e.useRef(t);s.current=t;const a=e.useCallback(()=>s.current(i.getState()),[i]),l=e.useCallback(()=>s.current(i.getState()),[i]);return e.useSyncExternalStore(i.subscribe,a,l)}]}function ve(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}},xe={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}},[ke,we]=me(e=>({theme:be,setTheme(t){e(e=>"light"===t?{theme:be}:"dark"===t?{theme:xe}:{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 Ae(e,t,n,o){const r=e.getContext("2d");if(!r)return null;const i=t[0]*o,s=t[1]*o,a=t[0]+"px",l=t[1]+"px";return e.style.width!==a&&(e.style.width=a),e.style.height!==l&&(e.style.height=l),e.width===i&&e.height===s||(e.width=i,e.height=s),r.setTransform(o,0,0,o,0,0),r.translate(n.left,n.top),r}function Se(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 Oe(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 Me(e,t,n,o,r,i){if(2>t.length)return;const s=[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];s.push(s[e-1]+Math.sqrt(n*n+o*o))}const a=s[s.length-1];if(0===a)return;const l=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=o,e.lineCap=i;for(let n=0;t.length-1>n;n++){const o=(s[n]+s[n+1])/2;let i=r;l>o&&(i*=o/l),l>a-o&&(i*=(a-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 Ee(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function je(e,t,n=.3){Ee(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 Ce(e,t,n=.6){var o,r,i,s,a;if(!Ee(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,h=null!==(a=null!==(s=t.cy)&&void 0!==s?s:t.y)&&void 0!==a?a:0;e.beginPath(),e.arc(u,h,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 Pe(e,t,n,o=.35){Ee(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill())}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 Le(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 Be(e,t){const n=_e(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 Ne=(e,t,n,o)=>{var r,i,s;const a=t.filter(e=>"area"===e.type);for(const t of a){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 a=null!==(i=t.style.opacity)&&void 0!==i?i:1;if(Be(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=Le(n),s=t.fillGradient.topOpacity,l=t.fillGradient.bottomOpacity,c=e.createLinearGradient(0,o,0,r);c.addColorStop(0,`rgba(${i[0]},${i[1]},${i[2]},${s})`),c.addColorStop(1,`rgba(${i[0]},${i[1]},${i[2]},${l})`),e.fillStyle=c,e.globalAlpha=a}else{const o=null!==(s=t.style.fillOpacity)&&void 0!==s?s:.7;e.globalAlpha=o*a,e.fillStyle=n}if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(Be(e,t),Pe(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=a,e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const n=_e(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}},He=(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()),Ce(e,t),e.globalAlpha=1}}finally{e.restore()}},ze=(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?$e(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))),je(e,t),e.globalAlpha=1};function $e(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,s=t.x+(t.w-r)/2;for(let o=t.y+t.h-r;o>=t.y-r;o-=i)e.drawImage(n,s,o,r,r)}else{const i=r+o,s=t.y+(t.h-r)/2;for(let o=t.x;t.x+t.w>o;o+=i)e.drawImage(n,o,s,r,r)}e.restore()}function Te(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 We(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}const Ie={line:[Ne,(e,t,n,o)=>{var r,i;const s=t.filter(e=>"line"===e.type);for(const a of s){if(2>a.path.length)continue;const c=a.style.stroke||"#007bff",u=a.style.strokeWidth||2,h=a.colorThresholds,d=a.rawValues;if(e.setLineDash(a.style.strokeDasharray?a.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=a.style.opacity&&(e.globalAlpha=a.style.opacity),e.lineWidth=u,e.lineCap=a.style.strokeLinecap||"butt",a.style._edgeFade){const f=null!==(r=a.style.opacity)&&void 0!==r?r:1;Me(e,a.path,c,u,f,a.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const g=Se(a.curve),p=h&&h.length>0&&d&&d.length===a.path.length,y=a._decayOpacities;if(y&&y.length===a.path.length&&!p){e.strokeStyle=c;const m=null!==(i=a.style.opacity)&&void 0!==i?i:1;for(let v=0;a.path.length-1>v;v++)e.globalAlpha=.5*(y[v]+y[v+1])*m,e.beginPath(),e.moveTo(a.path[v][0],a.path[v][1]),e.lineTo(a.path[v+1][0],a.path[v+1][1]),e.stroke()}else if(p){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 O(){A&&(e.stroke(),A=!1)}for(let M=0;a.path.length>M;M++){const[E,j]=a.path[M],C=d[M],P=Oe(C,h,c);if(null!==b&&null!==w&&null!==k){if(P===w)e.lineTo(E,j);else{const _=[];for(const L of h){const B=L.value;(k>B||B>C)&&(B>k||C>B)||k===B||C===B||_.push({t:(B-k)/(C-k)})}_.sort((e,t)=>e.t-t.t);for(const N of _){const H=b+(E-b)*N.t,z=x+(j-x)*N.t,$=Oe(k+(C-k)*Math.min(N.t+1e-4,1),h,c);e.lineTo(H,z),O(),S($,H,z)}e.lineTo(E,j)}b=E,x=j,k=C,w=P}else S(P,E,j),b=E,x=j,k=C,w=P}O()}else{if(e.beginPath(),e.strokeStyle=c,g)l.line().x(e=>e[0]).y(e=>e[1]).curve(g).context(e)(a.path);else{const[T,W]=a.path[0];e.moveTo(T,W);for(let I=1;a.path.length>I;I++)e.lineTo(a.path[I][0],a.path[I][1])}e.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=a.style.fillOpacity,e.fillStyle=a.style.fill,g&&!p)l.line().x(e=>e[0]).y(e=>e[1]).curve(g).context(e)(a.path);else{const[D,R]=a.path[0];e.moveTo(D,R);for(let G=1;a.path.length>G;G++)e.lineTo(a.path[G][0],a.path[G][1])}const F=a.path[0][0];e.lineTo(a.path[a.path.length-1][0],o.height),e.lineTo(F,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}}],area:[Ne],stackedarea:[Ne],scatter:[He],bubble:[He],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),je(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):We(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=Te(t.fill),e.font=o+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,r,i)}}}finally{e.restore()}}],bar:[ze],swarm:[He],waterfall:[(e,t,n,o)=>{var r,i,s;ze(e,t);const a=t.filter(e=>"rect"===e.type);if(2>a.length)return;const l=a[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;a.length-1>t;t++){const o=a[t],r=a[t+1];if(!(null===(i=o.datum)||void 0===i?void 0:i.cumEnd)||!(null===(s=r.datum)||void 0===s?void 0:s.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),s=t.isUp?t.upColor:t.downColor;e.fillStyle=s,e.fillRect(t.x-t.bodyWidth/2,r,t.bodyWidth,Math.max(i,1)),e.strokeStyle=s,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,r,t.bodyWidth,Math.max(i,1)),e.restore()}}]},Fe={top:20,right:20,bottom:30,left:40},De={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"},Re={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 Ge({hover:e}){const t=e=>Number.isInteger(e)?e+"":e.toFixed(2);return d.createElement("div",{className:"semiotic-tooltip",style:Re},d.createElement("div",{style:{fontWeight:600,marginBottom:2}},t(e.value)),d.createElement("div",{style:{opacity:.7,fontSize:11}},t(e.time)))}function qe({width:o,height:r,totalWidth:i,totalHeight:s,margin:a,dimension:l,scales:c,onBrush:u}){const h=e.useRef(null),g=e.useRef(null),p=e.useRef(u);p.current=u;const y=e.useRef(c);return y.current=c,e.useEffect(()=>{if(!h.current)return;const e=n.select(h.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 p.current(null);let n,i;if("x"===l){const[o,s]=e.selection;n=[t.x.invert(o),t.x.invert(s)],i=[t.y.invert(r),t.y.invert(0)]}else if("y"===l){const[r,s]=e.selection;n=[t.x.invert(0),t.x.invert(o)],i=[t.y.invert(s),t.y.invert(r)]}else{const[[o,r],[s,a]]=e.selection;n=[t.x.invert(o),t.x.invert(s)],i=[t.y.invert(a),t.y.invert(r)]}p.current({x:n,y:i})}),e.call(i),g.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),g.current=null}},[o,r,l]),d.createElement("svg",{ref:h,width:i,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},d.createElement("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`}))}const Ye=e.forwardRef(function(t,n){var o,r,i,s,a,l,c,u,h;const{chartType:g,runtimeMode:y,data:f,chunkThreshold:m,chunkSize:v,xAccessor:b,yAccessor:x,colorAccessor:k,sizeAccessor:w,groupAccessor:A,lineDataAccessor:S,curve:O,normalize:M,binSize:E,valueAccessor:j,arrowOfTime:C="right",windowMode:P="sliding",windowSize:_=200,timeAccessor:L,xExtent:B,yExtent:H,extentPadding:T=.1,sizeRange:R,size:G=[500,300],responsiveWidth:q,responsiveHeight:Y,margin:X,className:V,background:Q,lineStyle:U,pointStyle:K,areaStyle:Z,waterfallStyle:J,swarmStyle:ee,barColors:te,colorScheme:ne,boundsAccessor:oe,boundsStyle:re,y0Accessor:ie,gradientFill:se,openAccessor:ae,highAccessor:ce,lowAccessor:ue,closeAccessor:ge,candlestickStyle:me,showAxes:ve=!0,axes:be,xLabel:xe,yLabel:ke,xFormat:Se,yFormat:Oe,tickFormatTime:Me,tickFormatValue:Ee,hoverAnnotation:je,tooltipContent:Ce,customHoverBehavior:Pe,enableHover:_e,annotations:Le,svgAnnotationRules:Be,showGrid:Ne,legend:He,legendHoverBehavior:ze,legendClickBehavior:$e,legendHighlightedCategory:Te,legendIsolatedCategories:We,legendPosition:Re,backgroundGraphics:Ye,foregroundGraphics:Xe,canvasPreRenderers:Ve,title:Qe,categoryAccessor:Ue,brush:Ke,onBrush:Ze,decay:Je,pulse:et,transition:tt,staleness:nt,heatmapAggregation:ot,heatmapXBins:rt,heatmapYBins:it,showValues:st,heatmapValueFormat:at,marginalGraphics:lt,pointIdAccessor:ct,xScaleType:ut,yScaleType:ht,accessibleTable:dt}=t,[gt,pt]=function(t,n,o){const r=e.useRef(null),[i,s]=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;s(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]]]}(G,q,Y),yt=Object.assign(Object.assign({},Fe),X);if(lt){const e=60;lt.top&&e>yt.top&&(yt.top=e),lt.bottom&&e>yt.bottom&&(yt.bottom=e),lt.left&&e>yt.left&&(yt.left=e),lt.right&&e>yt.right&&(yt.right=e)}const ft=pt[0]-yt.left-yt.right,mt=pt[1]-yt.top-yt.bottom,vt="function"==typeof Xe?Xe({size:pt,margin:yt}):Xe,bt="function"==typeof Ye?Ye({size:pt,margin:yt}):Ye,xt=null!=je?je:_e,kt=e.useRef(null),wt=e.useRef(null),At=e.useRef(0),St=e.useRef(!1),Ot=we(e=>e.theme),[Mt,Et]=e.useState(0),[jt,Ct]=e.useState(null),Pt=e.useRef(null),_t=e.useRef(null),[Lt,Bt]=e.useState(null),[Nt,Ht]=e.useState(!1),[zt,$t]=e.useState([]),[Tt,Wt]=e.useState([]),It=e.useRef(()=>{}),Ft="streaming"===y||["bar","swarm","waterfall"].includes(g),Dt=e.useMemo(()=>({chartType:g,runtimeMode:Ft?"streaming":"bounded",windowSize:_,windowMode:P,arrowOfTime:Ft?C:"right",extentPadding:T,xAccessor:Ft?void 0:b,yAccessor:Ft?void 0:x,timeAccessor:Ft?L:void 0,valueAccessor:j,colorAccessor:k,sizeAccessor:w,groupAccessor:A,categoryAccessor:Ue,lineDataAccessor:S,xScaleType:ut,yScaleType:ht,xExtent:B,yExtent:H,sizeRange:R,binSize:E,normalize:M,boundsAccessor:oe,boundsStyle:re,y0Accessor:ie,gradientFill:"boolean"==typeof se?se?{topOpacity:.8,bottomOpacity:.05}:void 0:se,openAccessor:ae,highAccessor:ce,lowAccessor:ue,closeAccessor:ge,candlestickStyle:me,lineStyle:U,pointStyle:K,areaStyle:Z,swarmStyle:ee,waterfallStyle:J,colorScheme:ne,barColors:te,annotations:Le,decay:Je,pulse:et,transition:tt,staleness:nt,heatmapAggregation:ot,heatmapXBins:rt,heatmapYBins:it,showValues:st,heatmapValueFormat:at,pointIdAccessor:ct,curve:O}),[g,_,P,C,T,b,x,L,j,ut,ht,k,w,A,Ue,S,B,H,R,E,M,oe,re,ie,se,ae,ce,ue,ge,me,U,K,Z,ee,J,ne,te,Le,Je,et,tt,nt,ot,rt,it,st,at,Ft,ct,O]),Rt=e.useRef(null);Rt.current||(Rt.current=new N(Dt));const Gt=e.useCallback(()=>{At.current||(At.current=requestAnimationFrame(()=>It.current()))},[]);e.useEffect(()=>{var e;null===(e=Rt.current)||void 0===e||e.updateConfig(Dt),St.current=!0,Gt()},[Dt,Gt]),e.useEffect(()=>{St.current=!0,Gt()},[Ot,Gt]);const qt=e.useRef(null);qt.current||(qt.current=new p(e=>{const t=Rt.current;t&&t.ingest(e)&&(St.current=!0,Gt())},{chunkThreshold:m,chunkSize:v})),e.useEffect(()=>{var e;null===(e=qt.current)||void 0===e||e.updateChunkOptions({chunkThreshold:m,chunkSize:v})},[m,v]);const Yt=e.useCallback(e=>{var t;null===(t=qt.current)||void 0===t||t.push(e)},[]),Xt=e.useCallback(e=>{var t;null===(t=qt.current)||void 0===t||t.pushMany(e)},[]),Vt=e.useCallback(()=>{var e,t;null===(e=qt.current)||void 0===e||e.clear(),null===(t=Rt.current)||void 0===t||t.clear(),St.current=!0,Gt()},[Gt]);e.useImperativeHandle(n,()=>({push:Yt,pushMany:Xt,clear:Vt,getData:()=>{var e,t,n;return null===(e=qt.current)||void 0===e||e.flush(),null!==(n=null===(t=Rt.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var e,t;return null!==(t=null===(e=Rt.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=Rt.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[Yt,Xt,Vt]),e.useEffect(()=>{var e;f&&(null===(e=qt.current)||void 0===e||e.setBoundedData(f))},[f]);const Qt=e.useRef(()=>{}),Ut=e.useRef(()=>{});Qt.current=e=>{if(!xt)return;const t=kt.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-yt.left,r=e.clientY-n.top-yt.top;if(0>o||o>ft||0>r||r>mt)return void(Pt.current&&(Pt.current=null,_t.current=null,Bt(null),Pe&&(Pe(null),St.current=!0),Gt()));const i=Rt.current;if(!i||0===i.scene.length)return;const s=function(e,t,n,o=30,r){let i=null,s=!1;if(r){const e=r.find(t,n,o);if(e){const r=z(e,t,n);r&&o>r.distance&&(i=r,s=!0)}}for(const a of e){let e=null;switch(a.type){case"point":if(r&&s)break;e=z(a,t,n);break;case"line":e=$(a,t,n);break;case"rect":e=W(a,t,n);break;case"heatcell":e=I(a,t,n);break;case"area":if(!1===a.interactive)break;e=D(a,t,n);break;case"candlestick":e=F(a,t,n)}e&&o>e.distance&&(i&&e.distance>=i.distance||(i=e))}return i}(i.scene,o,r,30,i.quadtree);if(!s)return void(Pt.current&&(Pt.current=null,_t.current=null,Bt(null),Pe&&Pe(null),Gt()));const a=s.datum||{},l=Object.assign(Object.assign({},"object"!=typeof a||null===a||Array.isArray(a)?{}:a),{data:a,time:s.x,value:s.y,x:s.x,y:s.y});Pt.current=l,_t.current=s.node,Bt(l),Pe&&(Pe(l),St.current=!0),Gt()},Ut.current=()=>{Pt.current&&(Pt.current=null,_t.current=null,Bt(null),Pe&&(Pe(null),St.current=!0),Gt())},e.useCallback(e=>Qt.current(e),[]);const Kt=e.useCallback(()=>Ut.current(),[]),Zt=e.useRef(-1),Jt=e.useCallback(e=>{const t=Rt.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>Zt.current?-1:Zt.current,r=function(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}}(e.key,0>o?-1:o,n.length);if(null===r)return;if(e.preventDefault(),0>r)return Zt.current=-1,Pt.current=null,_t.current=null,Bt(null),Pe&&Pe(null),void Gt();const i=0>o?0:r;Zt.current=i;const s=function(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})}(n[i]);Pt.current=s,Bt(s),Pe&&Pe(s),Gt()},[Pe,Gt]),en=e.useCallback(e=>{Zt.current=-1,Qt.current(e)},[]);It.current=()=>{var e,t;At.current=0;const n=kt.current,o=wt.current;if(!n||!o)return;const r=Rt.current;if(!r)return;const i="undefined"!=typeof performance?performance.now():Date.now(),s=r.advanceTransition(i),a=St.current||s;a&&!s&&r.computeScene({width:ft,height:mt});const l="undefined"!=typeof window&&window.devicePixelRatio||1,c=function(e){if(!e)return De;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(),s=t.getPropertyValue("--text-primary").trim(),a=n||t.getPropertyValue("--surface-3").trim(),l=r||t.getPropertyValue("--surface-0").trim();return i||s||n?{axisStroke:a||De.axisStroke,tickText:i||De.tickText,crosshair:i?i+"66":De.crosshair,hoverFill:l?l+"4D":De.hoverFill,hoverStroke:i?i+"99":De.hoverStroke,pointRing:l||De.pointRing}:De}(n),u=null!==(e=null==nt?void 0:nt.threshold)&&void 0!==e?e:5e3,h=nt&&r.lastIngestTime>0&&i-r.lastIngestTime>u;if(a){const e=Ae(n,pt,yt,l);if(e){e.clearRect(-yt.left,-yt.top,pt[0],pt[1]),h&&(e.globalAlpha=null!==(t=null==nt?void 0:nt.dimOpacity)&&void 0!==t?t:.5);const o=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=Q||(o&&"transparent"!==o?o:null);if(i&&(e.fillStyle=i,e.fillRect(-yt.left,-yt.top,pt[0],pt[1])),e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,ft,mt),e.clip()),Ve&&r.scales)for(const t of Ve)e.save(),t(e,r.scene,r.scales,{width:ft,height:mt}),e.restore();const s=Ie[g];if(s&&r.scales)for(const t of s)t(e,r.scene,r.scales,{width:ft,height:mt});e.restore(),h&&(e.globalAlpha=1)}}{const e=Ae(o,pt,yt,l);if(e&&(e.clearRect(-yt.left,-yt.top,pt[0],pt[1]),xt&&Pt.current&&r.scales&&function(e,t,n,o,r,i,s){if(!1===r.crosshair)return;e.save();const a="object"==typeof r.crosshair?r.crosshair:{};e.strokeStyle=a.stroke||s.crosshair,e.lineWidth=a.strokeWidth||1,e.setLineDash(a.strokeDasharray?a.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=s.pointRing,e.lineWidth=2,e.stroke()}(e,Pt.current,ft,mt,"object"==typeof xt?xt:{},0,c),_t.current&&Array.isArray(je))){const t=je.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,_t.current,t)}}a&&n&&n.setAttribute("aria-label",pe(r.scene,g+" chart"));const d=St.current;if(St.current=!1,d&&r.scales&&((!jt||jt.x.domain()[0]!==r.scales.x.domain()[0]||jt.x.domain()[1]!==r.scales.x.domain()[1]||jt.y.domain()[0]!==r.scales.y.domain()[0]||jt.y.domain()[1]!==r.scales.y.domain()[1]||jt.x.range()[0]!==r.scales.x.range()[0]||jt.x.range()[1]!==r.scales.x.range()[1]||jt.y.range()[0]!==r.scales.y.range()[0]||jt.y.range()[1]!==r.scales.y.range()[1])&&Ct(r.scales),lt)){const e=r.getData(),t="function"==typeof b?b:e=>e[b||"x"],n="function"==typeof x?x:e=>e[x||"y"];$t(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),Wt(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}d&&Le&&Le.length>0&&Et(e=>e+1),(null==nt?void 0:nt.showBadge)&&Ht(!!h),(s||r.hasActivePulses)&&(At.current=requestAnimationFrame(()=>It.current()))},e.useEffect(()=>(Gt(),()=>{At.current&&(cancelAnimationFrame(At.current),At.current=0)}),[Gt]),e.useEffect(()=>{St.current=!0,Gt()},[g,ft,mt,ve,Q,U,Ve,Gt]),function(t,n,o,r,i,s){e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{var e;const a=n.current;if(!a||0===a.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(e=t.threshold)&&void 0!==e?e:5e3,u=l-a.lastIngestTime>c;u!==i&&(s(u),o.current=!0,r())},1e3);return()=>clearInterval(e)},[t,i,r])}(nt,Rt,St,Gt,Nt,Ht);const tn=xt&&Lt?Ce?Ce(Lt):d.createElement(Ge,{hover:Lt}):null,nn=tn?d.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:yt.left+Lt.x,top:yt.top+Lt.y,transform:`translate(${Lt.x>.7*ft?"calc(-100% - 12px)":"12px"}, ${.3*mt>Lt.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1,width:"max-content"}},tn):null,on=Zt.current>=0&&Lt?d.createElement("svg",{style:{position:"absolute",left:0,top:0,width:pt[0],height:pt[1],pointerEvents:"none",zIndex:2}},d.createElement("circle",{cx:Lt.x+yt.left,cy:Lt.y+yt.top,r:8,fill:"none",stroke:"var(--accent, #6366f1)",strokeWidth:2,strokeDasharray:"4,2"})):null;if(de){const e=Rt.current;e&&f&&(e.ingest({inserts:f,bounded:!0}),e.computeScene({width:ft,height:mt}));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 d.createElement("div",{className:"stream-xy-frame"+(V?" "+V:""),role:"img","aria-label":"string"==typeof Qe?Qe:"XY chart",style:{position:"relative",width:pt[0],height:pt[1]}},d.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:pt[0],height:pt[1],style:{position:"absolute",left:0,top:0}},bt,d.createElement("g",{transform:`translate(${yt.left},${yt.top})`},Q&&d.createElement("rect",{x:0,y:0,width:ft,height:mt,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 d.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"),s=[...r.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L");return d.createElement("path",{key:"area-"+t,d:`M${i}L${s}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 d.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 d.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),s=.299*o+.587*r+.114*i>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return d.createElement("g",{key:"heatcell-"+t},d.createElement("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),d.createElement("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px"},e))}return d.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 d.createElement("g",{key:"candle-"+t},d.createElement("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),d.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))),d.createElement(he,{width:ft,height:mt,totalWidth:pt[0],totalHeight:pt[1],margin:yt,scales:n,showAxes:ve,axes:be,xLabel:xe,yLabel:ke,xFormat:Se||Me,yFormat:Oe||Ee,showGrid:Ne,title:Qe,legend:He,legendHoverBehavior:ze,legendClickBehavior:$e,legendHighlightedCategory:Te,legendIsolatedCategories:We,legendPosition:Re,foregroundGraphics:vt,marginalGraphics:lt,xValues:[],yValues:[],annotations:Le,svgAnnotationRules:Be,annotationFrame:0,xAccessor:"string"==typeof b?b:"string"==typeof L?L:void 0,yAccessor:"string"==typeof x?x:"string"==typeof j?j:void 0,annotationData:null==e?void 0:e.getData(),pointNodes:null==e?void 0:e.scene.filter(e=>"point"===e.type),curve:"string"==typeof O?O:void 0}))}return d.createElement("div",{ref:gt,className:"stream-xy-frame"+(V?" "+V:""),role:"img","aria-label":"string"==typeof Qe?Qe:"XY chart",tabIndex:0,style:{position:"relative",width:q?"100%":pt[0],height:Y?"100%":pt[1],overflow:"visible"},onMouseMove:xt?en:void 0,onMouseLeave:xt?Kt:void 0,onKeyDown:Jt},bt&&d.createElement("svg",{style:{position:"absolute",left:0,top:0,width:pt[0],height:pt[1],pointerEvents:"none"}},bt),d.createElement(le,{width:ft,height:mt,totalWidth:pt[0],totalHeight:pt[1],margin:yt,scales:jt,showAxes:ve,axes:be,showGrid:Ne,xFormat:Se||Me,yFormat:Oe||Ee}),d.createElement("canvas",{ref:kt,"aria-label":pe(null!==(s=null===(i=Rt.current)||void 0===i?void 0:i.scene)&&void 0!==s?s:[],g+" chart"),style:{position:"absolute",left:0,top:0}}),d.createElement("canvas",{ref:wt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),d.createElement(fe,{hoverPoint:Lt}),dt&&d.createElement(ye,{scene:null!==(l=null===(a=Rt.current)||void 0===a?void 0:a.scene)&&void 0!==l?l:[],chartType:g+" chart"}),d.createElement(he,{width:ft,height:mt,totalWidth:pt[0],totalHeight:pt[1],margin:yt,scales:jt,showAxes:ve,axes:be,xLabel:xe,yLabel:ke,xFormat:Se||Me,yFormat:Oe||Ee,showGrid:Ne,title:Qe,legend:He,legendHoverBehavior:ze,legendClickBehavior:$e,legendHighlightedCategory:Te,legendIsolatedCategories:We,legendPosition:Re,foregroundGraphics:vt,marginalGraphics:lt,xValues:zt,yValues:Tt,annotations:Le,svgAnnotationRules:Be,annotationFrame:Mt,xAccessor:"string"==typeof b?b:"string"==typeof L?L:void 0,yAccessor:"string"==typeof x?x:"string"==typeof j?j:void 0,annotationData:null===(c=Rt.current)||void 0===c?void 0:c.getData(),pointNodes:null===(u=Rt.current)||void 0===u?void 0:u.scene.filter(e=>"point"===e.type),curve:"string"==typeof O?O:void 0,underlayRendered:!0}),(Ke||Ze)&&d.createElement(qe,{width:ft,height:mt,totalWidth:pt[0],totalHeight:pt[1],margin:yt,dimension:null!==(h=null==Ke?void 0:Ke.dimension)&&void 0!==h?h:"xy",scales:jt,onBrush:null!=Ze?Ze:()=>{}}),(null==nt?void 0:nt.showBadge)&&d.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:Nt?"#dc3545":"#28a745",color:"white"})},Nt?"STALE":"LIVE"),on,nn)});Ye.displayName="StreamXYFrame";const Xe=e.createContext(null);function Ve(){return e.useContext(Xe)}function Qe(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 Ue(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[Ke,Ze]=me(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),r=Ue(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=Ue(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}})}})),[Je,et]=me(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 tt(t){const n=e.useId(),o=t.clientId||n,{name:r}=t,i=Ze(e=>e.selections.get(r)),s=Ze(e=>e.setClause),a=Ze(e=>e.clearClause),l=e.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:e.useMemo(()=>i&&0!==i.clauses.size?function(e,t){const n=[];for(const[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(Qe(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(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)};s(r,{clientId:o,type:"point",fields:t})},[o,r,s]),selectInterval:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};s(r,{clientId:o,type:"interval",fields:t})},[o,r,s]),clear:e.useCallback(()=>{a(r,o)},[a,r,o]),clientId:o}}function nt(t){const n=t.name||"hover",{fields:o}=t,{predicate:r,isActive:i,selectPoints:s,clear:a}=tt({name:n});return{onHover:e.useCallback(e=>{if(!e)return void a();const t={};for(const n of o){const o=e[n];void 0!==o&&(t[n]=[o])}Object.keys(t).length>0&&s(t)},[o,s,a,n]),predicate:r,isActive:i}}function ot(t){const{name:n,xField:o,yField:r}=t,{predicate:i,isActive:s,selectInterval:a,clear:l}=tt({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&&a(t)},[c,o,r,a,l]);return{brushInteraction:e.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:i,isActive:s,clear:l}}const rt=e.createContext(!1);function it({selections:t}){const n=Ze(e=>e.setResolution);return e.useEffect(()=>{for(const[e,o]of Object.entries(t))o.resolution&&n(e,o.resolution)},[t,n]),null}function st({categoryColors:t,interaction:n,selectionName:o,field:r}){const i=Object.entries(t);if(0===i.length)return null;const s=i.map(([e])=>e),a=[{styleFn:e=>({fill:e.color||"#333",stroke:e.color||"#333"}),type:"fill",items:i.map(([e,t])=>({label:e,color:t})),label:""}],l=nt({name:o,fields:[r]}),c=tt({name:o,clientId:"__linked-legend-isolate__"}),[u,h]=e.useState(new Set),[g,p]=e.useState(null),y=e.useRef(c.selectPoints);y.current=c.selectPoints;const f=e.useRef(c.clear);f.current=c.clear,e.useEffect(()=>{"isolate"===n&&(u.size>0?y.current({[r]:Array.from(u)}):f.current())},[n,u,r]);const m=e.useCallback(e=>{"highlight"===n&&(e?(p(e.label),l.onHover({[r]:e.label})):(p(null),l.onHover(null)))},[n,r,l]),v=e.useCallback(e=>{"isolate"===n&&h(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===s.length?new Set:n})},[n,s.length]);return d.createElement("svg",{width:"100%",height:30,style:{display:"block",overflow:"visible"}},d.createElement(Q,{legendGroups:a,title:!1,orientation:"horizontal",height:20,customHoverBehavior:"highlight"===n?m:void 0,customClickBehavior:"isolate"===n?v:void 0,highlightedCategory:g,isolatedCategories:u}))}function at({children:e,selections:t,showLegend:n,legendPosition:o="top",legendInteraction:r="none",legendSelectionName:i="legend",legendField:s="category"}){const a=Ve(),l=void 0!==n?n:!(!a||0>=Object.keys(a).length);return d.createElement(Ke,null,d.createElement(Je,null,t&&d.createElement(it,{selections:t}),d.createElement(rt.Provider,{value:l},l&&"top"===o&&a&&d.createElement(st,{categoryColors:a,interaction:r,selectionName:i,field:s}),e,l&&"bottom"===o&&a&&d.createElement(st,{categoryColors:a,interaction:r,selectionName:i,field:s}))))}function lt({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:r,strokeWidth:i}){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: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),s=i?o(i,t,n):n?n(r):"#000000";return{label:r+"",color:s}}),label:""}]}}function ct(e){return e?"string"==typeof e?{name:e}:e:null}function ut(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 ht="#007bff";function dt(e){return"function"==typeof e?e:t=>t[e]}function gt(t,n,o="category10"){const r=Ve();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":_(e.map(e=>({_cat:e})),"_cat",o)}if(r&&Object.keys(r).length>0){const e=_(t,n,o);return t=>r[t]||e(t)}return _(t,n,o)}},[t,n,o,r])}function pt({selection:t,linkedHover:n,fallbackFields:o=[],unwrapData:r=!1,onObservation:i,chartType:s,chartId:a}){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=tt({name:(null==t?void 0:t.name)||"__unused__"}),u=nt({name:(null==l?void 0:l.name)||"hover",fields:(null==l?void 0:l.fields)||o||[]}),h=et(e=>e.pushObservation),d=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||h){const n={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const s=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(s),h&&h(s)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(e),h&&h(e)}}},[n,u,i,s,a,h]),p=e.useCallback(e=>{var t,n;if(i||h){const o={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const s=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(s),h&&h(s)}else{const e=Object.assign(Object.assign({},o),{type:"click-end"});i&&i(e),h&&h(e)}}},[i,h,s,a]);return{activeSelectionHook:d,customHoverBehavior:g,customClickBehavior:p}}function yt({data:t,colorBy:n,colorScale:o,showLegend:r,legendPosition:i="right",userMargin:s,defaults:a={top:50,bottom:60,left:70,right:40}}){const l=e.useContext(rt),c=void 0!==r?r:!l&&!!n,u=e.useMemo(()=>{if(c&&n)return lt({data:t,colorBy:n,colorScale:o,getColor:P})},[c,n,t,o]),h=e.useMemo(()=>{const e=Object.assign(Object.assign({},a),s);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},[a,s,u,i]);return{legend:u,margin:h,legendPosition:i}}function ft(t,n,o){const[r,i]=e.useState(null),[s,a]=e.useState(new Set),l=e.useCallback(e=>{"highlight"===t&&i(e?e.label:null)},[t]),c=e.useCallback(e=>{"isolate"===t&&a(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&&s.size>0?{isActive:!0,predicate:t=>{const o=e?t[e]:"function"==typeof n?n(t):null;return s.has(o)}}:null},[t,n,r,s]);return{highlightedCategory:"highlight"===t?r:null,isolatedCategories:"isolate"===t?s:new Set,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}const mt={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 vt(e,t,n){var o,r,i,s,a,l;const c=mt[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:c.width,height:null!==(r=t.height)&&void 0!==r?r:c.height,showAxes:c.showAxes,showGrid:null!==(i=t.showGrid)&&void 0!==i?i:c.showGrid,enableHover:null!==(s=t.enableHover)&&void 0!==s?s:!!t.linkedHover||c.enableHover,showLegend:null!==(a=t.showLegend)&&void 0!==a?a: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 bt={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 xt(e,t){return"function"==typeof t?t(e):e[t]}function kt(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 wt(e={}){const{fields:t,title:n,format:o,style:r={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let s;const a=[];if(n){const t=xt(e,n);s=kt(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 s=xt(e,r);a.push({label:n,value:kt(s,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){s=kt(e[n],o);break}if(!s){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(s=kt(e[t[0]],o))}}const l=Object.assign(Object.assign({},bt),r);return d.createElement("div",{className:("semiotic-tooltip "+i).trim(),style:l},s&&d.createElement("div",{style:{fontWeight:a.length>0?"bold":"normal"}},s),a.map((e,t)=>d.createElement("div",{key:t,style:{marginTop:0===t&&s?"4px":0}},e.label&&d.createElement("span",null,e.label,": "),e.value)))}}function At(e){if(!0===e)return wt();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:d.createElement("div",{className:"semiotic-tooltip",style:bt},n)}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?wt(e):wt())}function St(e){return"string"==typeof e?e:"value"}function Ot(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function Mt(e,t){return"function"==typeof t?t(e):e[t]}function Et(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?Ot(Mt(o,t.accessor)):null;return d.createElement("div",{className:"semiotic-tooltip",style:bt},r&&d.createElement("div",{style:{fontWeight:"bold",marginBottom:n.length>0?4:0}},r),n.map((e,t)=>{const n=Ot(Mt(o,e.accessor));return d.createElement("div",{key:t,style:t>0?{marginTop:2}:void 0},d.createElement("span",{style:{opacity:.7}},e.label,": "),d.createElement("span",null,n))}))}}function jt({componentName:e,message:t,diagnosticHint:n,width:o,height:r}){return d.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"}},d.createElement("div",{style:{textAlign:"center",maxWidth:400}},d.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),d.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t),n&&d.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 Ct extends d.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:d.createElement(jt,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function Pt(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 s=1;o>=s;s++){const o=r[s];r[s]=e[i-1]===t[s-1]?n:1+Math.min(n,r[s],r[s-1]),n=o}}return r[o]}function _t(e,t,n=3){let o,r=n+1;for(const n of t){const t=Pt(e.toLowerCase(),n.toLowerCase());r>t&&(r=t,o=n)}return r>n?void 0:o}function Lt(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function Bt(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=_t(e,t,3))&&void 0!==n?n:null)}function Nt({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=Lt(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=Bt(i,t),o=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}const Ht={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"}},zt={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},$t={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"}},Tt=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],Wt=["vertical","horizontal"],It={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),zt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Tt},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({},Ht),zt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Tt},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),zt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Tt},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({},Ht),zt),{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({},Ht),zt),{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({},Ht),zt),{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({},Ht),zt),{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({},Ht),zt),{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({},Ht),$t),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Wt},sort:{type:["boolean","string","function"]},barPadding:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),$t),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Wt},normalize:{type:"boolean"},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),$t),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Wt},barPadding:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),$t),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Wt},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({},Ht),$t),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Wt},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),$t),{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({},Ht),$t),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Wt},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({},Ht),$t),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Wt},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},Ht),{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({},Ht),{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({},Ht),{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({},Ht),{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:Wt},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({},Ht),{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({},Ht),{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({},Ht),{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({},Ht),{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({},Ht),{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 Ft(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}const Dt=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),Rt=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),Gt=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),qt=new Set(["LineChart","AreaChart","StackedAreaChart"]),Yt=new Set(["BarChart","StackedBarChart","GroupedBarChart"]);function Xt(e,t){const n=[],o=function(e,t){const n=[],o=It[e];if(!o)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(It).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(!Ft(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=_t(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 s=Nt({componentName:e,data:r,accessors:Object.keys(i).length>0?i:void 0});s&&n.push(s)}else if("object"===o.dataShape){const o=function({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}({componentName:e,data:t.data});o&&n.push(o)}else if("network"===o.dataShape){const r=function({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=Lt(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=Bt(r,t),i=n?` Try ${o}="${n}".`:"";return`${e}: ${o} "${r}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}return null}({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}}(e,t);for(const e of o.errors)n.push({severity:"error",code:"VALIDATION",message:e,fix:""});return It[e]?(function(e,t,n){const o=It[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=It[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 s=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: ${s.join(", ")}.`,fix:`Change ${e} to one of: ${s.map(e=>`"${e}"`).join(", ")}.`}))}}(e,t,n),function(e,t,n){Dt.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){Rt.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=It[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 s=t.xAccessor;"string"==typeof s&&i[s]instanceof Date&&!t.xFormat&&n.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${s}" 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(!Gt.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(!qt.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,s=null!==(r=t.height)&&void 0!==r?r:400,a=t.margin;if(!a||"object"!=typeof a)return;const l=(a.left||0)+(a.right||0),c=(a.top||0)+(a.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."}),s>c||n.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${c}px) >= height (${s}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}(0,t,n),function(e,t,n){var o;const r=It[e];if(!r||"array"!==r.dataShape)return;const i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;const s=[];t.xAccessor&&"string"==typeof t.xAccessor&&s.push({prop:"xAccessor",name:t.xAccessor}),t.yAccessor&&"string"==typeof t.yAccessor&&s.push({prop:"yAccessor",name:t.yAccessor}),t.valueAccessor&&"string"==typeof t.valueAccessor&&s.push({prop:"valueAccessor",name:t.valueAccessor});const a=Math.min(i.length,5);for(const e of s){let t=!0;for(let n=0;a>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(!Yt.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 Vt;const Qt="undefined"!=typeof process&&"production"!==(null===(Vt=process.env)||void 0===Vt?void 0:Vt.NODE_ENV);function Ut({componentName:e,width:t,height:n,chartProps:o,children:r}){return d.createElement(Ct,{fallback:r=>{let i="";if(Qt&&o)try{const t=Xt(e,o);t.ok||(i=t.diagnoses.map(e=>`${"error"===e.severity?"✗":"⚠"} ${e.message}${e.fix?" — Fix: "+e.fix:""}`).join("\n"))}catch(e){}return d.createElement(jt,{componentName:e,message:r.message,diagnosticHint:i,width:t,height:n})}},r)}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"},Zt={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Jt(e,t,n,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?d.createElement("div",{style:Object.assign(Object.assign({},Kt),{width:t,height:n})},o||"No data available"):null}function en(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))),s=Math.floor((n-(o*(r+i)-i))/2);return d.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)=>d.createElement("div",{key:n,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Zt),{position:"absolute",top:s+n*(r+i),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:r,opacity:.5+n%2*.2})})))}function tn(e,t,n,o){if(!Qt)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 nn(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;let on=null;function rn(){return nn(this,void 0,void 0,function*(){return on||(on=yield Promise.resolve().then(function(){return En})),on})}const sn=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 s=vt(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:l,className:c,xFormat:u,yFormat:h,xAccessor:g="x",yAccessor:p="y",lineBy:y,lineDataAccessor:f="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:O,pointIdAccessor:M,annotations:E,directLabel:j,gapStrategy:C="break",anomaly:_,forecast:L,frameProps:B={},selection:N,linkedHover:H,onObservation:z,chartId:$,loading:T,emptyContent:W,legendInteraction:I,legendPosition:F,xScaleType:D,yScaleType:R}=t,G=s.width,q=s.height,Y=s.enableHover,X=s.showGrid,V=s.showLegend,Q=s.title,U=s.xLabel,K=s.yLabel,Z=en(T,G,q);if(Z)return Z;const J=Jt(a,G,q,W);if(J)return J;const ee=a||[];tn("LineChart",ee,"xAccessor",g),tn("LineChart",ee,"yAccessor",p);const te="string"==typeof g?g:"x",ne="string"==typeof p?p:"y",[oe,re]=e.useState(null),[ie,se]=e.useState([]);e.useEffect(()=>{if(!L&&!_)return;let e=!1;return re(null),se([]),L?function(...e){return nn(this,void 0,void 0,function*(){return(yield rn()).buildForecast(...e)})}(ee,te,ne,L,_).then(t=>{e||(re(t),se(t.annotations))}).catch(()=>{e||(re(null),se([]))}):_&&function(...e){return nn(this,void 0,void 0,function*(){return(yield rn()).buildAnomalyAnnotations(...e)})}(_).then(t=>{e||(re(null),se(t))}).catch(()=>{e||se([])}),()=>{e=!0}},[ee,L,_,te,ne]);const ae=oe?oe.processedData:ee,le=L&&!y?"__forecastSegment":y,{activeSelectionHook:ce,customHoverBehavior:ue}=pt({selection:N,linkedHover:H,fallbackFields:m?["string"==typeof m?m:""]:[],onObservation:z,chartType:"LineChart",chartId:$}),he=e.useCallback(e=>{const t="function"==typeof g?g(e):e[g],n="function"==typeof p?p(e):e[p];return null==t||null==n||Number.isNaN(t)||Number.isNaN(n)},[g,p]),de=void 0!==(null===(o=ae[0])||void 0===o?void 0:o[f]),ge=e.useMemo(()=>{if(de)return ae;if(le){const e=ae.reduce((e,t)=>{const n="function"==typeof le?le(t):t[le];if(!e[n]){const t={[f]:[]};"string"==typeof le&&(t[le]=n),e[n]=t}return e[n][f].push(t),e},{});return Object.values(e)}return[{[f]:ae}]},[ae,le,f,de]),{gapProcessedLineData:pe,hasGaps:ye}=e.useMemo(()=>{if("interpolate"===C){let e=!1;const t=[];for(const n of ge){const o=(n[f]||[]).filter(t=>!he(t)||(e=!0,!1));o.length>0&&t.push(Object.assign(Object.assign({},n),{[f]:o}))}return{gapProcessedLineData:t,hasGaps:e}}if("break"===C){let e=!1;const t=[];for(const n of ge){const o=n[f]||[];let r=[],i=0;const s=le&&"string"==typeof le?n[le]:void 0;for(const a of o)if(he(a))e=!0,r.length>0&&(t.push(Object.assign(Object.assign({},n),{[f]:r})),r=[],i++);else{const e=null!=s?`${s}__seg${i}`:"__seg"+i;r.push(Object.assign(Object.assign({},a),{_gapSegment:e}))}r.length>0&&t.push(Object.assign(Object.assign({},n),{[f]:r}))}return{gapProcessedLineData:t,hasGaps:e}}if("zero"===C){let e=!1;const t="string"==typeof p?p:"y",n=[];for(const o of ge){const r=o[f]||[],i=[];for(const n of r)he(n)?(e=!0,i.push(Object.assign(Object.assign({},n),{[t]:0}))):i.push(n);n.push(Object.assign(Object.assign({},o),{[f]:i}))}return{gapProcessedLineData:n,hasGaps:e}}return{gapProcessedLineData:ge,hasGaps:!1}},[ge,C,f,he,le,p]),fe=gt(ae,m,v),me=e.useMemo(()=>{if(!m)return[];const e=new Set;for(const t of ae){const n="function"==typeof m?m(t):t[m];null!=n&&e.add(n+"")}return Array.from(e)},[ae,m]),ve=ft(I,m,me),be=e.useMemo(()=>ve.legendSelectionHook?ve.legendSelectionHook:ce,[ve.legendSelectionHook,ce]),xe=e.useMemo(()=>e=>{const t={strokeWidth:S};return m?fe&&(t.stroke=P(e,m,fe),w&&(t.fill=t.stroke,t.fillOpacity=A)):(t.stroke=ht,w&&(t.fill=ht,t.fillOpacity=A)),t},[m,fe,S,w,A]),[ke,we]=e.useState(null);e.useEffect(()=>{if(!L)return void we(null);let e=!1;return function(...e){return nn(this,void 0,void 0,function*(){return(yield rn()).createSegmentLineStyle(...e)})}(xe,L).then(t=>{e||we(()=>t)}).catch(()=>{e||we(null)}),()=>{e=!0}},[xe,L]);const Ae=ke||xe,Se=e.useMemo(()=>ut(Ae,be,N),[Ae,be,N]),Oe=e.useMemo(()=>{if(x)return e=>{const t={r:k,fillOpacity:1};return m?fe&&(t.fill=P(e.parentLine||e,m,fe)):t.fill=ht,t}},[x,k,m,fe]),Me=w?"area":"line",Ee="object"==typeof j?j:{},je=Ee.position||"end",Ce=Ee.fontSize||11,Pe=e.useMemo(()=>{var e,t;if(!j||!m)return[];const n="function"==typeof g?g:e=>e[g],o="function"==typeof p?p:e=>e[p],r="function"==typeof m?m:e=>e[m],i=new Map;for(const n of pe){const o=n[f]||[];if(0===o.length)continue;const s="end"===je?o[o.length-1]:o[0],a=null!==(t=null!==(e=r(s))&&void 0!==e?e:r(n))&&void 0!==t?t:"";a&&!i.has(a+"")&&i.set(a+"",s)}const s=Array.from(i.entries()).map(([e,t])=>({type:"text",label:e,["string"==typeof g?g:"x"]:n(t),["string"==typeof p?p:"y"]:o(t),dx:"end"===je?6:-6,dy:0,color:fe?fe(e):ht,fontSize:Ce}));s.sort((e,t)=>{const n="string"==typeof p?p:"y";return e[n]-t[n]});for(let e=1;s.length>e;e++){const t="string"==typeof p?p:"y",n=s[e-1],o=s[e];Ce+2>Math.abs(o[t]+o.dy-(n[t]+n.dy))&&(o.dy+=Ce+2)}return s},[j,m,fe,pe,f,g,p,je,Ce]),_e=(!j||void 0!==V)&&V,Le=e.useMemo(()=>{if(!j)return s.marginDefaults;const e=Pe.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"===je?"right":"left";return Object.assign(Object.assign({},s.marginDefaults),{[n]:Math.max(s.marginDefaults[n]||0,t)})},[j,Pe,Ce,je,s.marginDefaults]),{legend:Be,margin:Ne,legendPosition:He}=yt({data:pe,colorBy:m,colorScale:fe,showLegend:_e,legendPosition:F,userMargin:l,defaults:Le}),ze=y||m,$e=e.useMemo(()=>Et([{label:U||St(g),accessor:g,role:"x"},{label:K||St(p),accessor:p,role:"y"},...ze?[{label:St(ze),accessor:ze,role:"group"}]:[]]),[g,p,U,K,ze]),Te=Nt({componentName:"LineChart",data:de?(null===(r=ae[0])||void 0===r?void 0:r[f])||[]:a,accessors:{xAccessor:g,yAccessor:p}});if(Te)return d.createElement(jt,{componentName:"LineChart",message:Te,width:G,height:q});const We=e.useMemo(()=>de||le||ye?pe.flatMap(e=>{const t=e[f]||[];return le&&"string"==typeof le?t.map(t=>Object.assign(Object.assign({},t),{[le]:e[le]})):t}):ae,[pe,f,de,le,ae,ye]),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:Me},null!=a&&{data:We}),{xAccessor:g,yAccessor:p,xScaleType:D,yScaleType:R,groupAccessor:"break"===C&&ye?"_gapSegment":le||void 0,curve:b,lineStyle:Se}),x&&{pointStyle:Oe}),{size:[G,q],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Ne,showAxes:s.showAxes,xLabel:U,yLabel:K,xFormat:u,yFormat:h,enableHover:Y,showGrid:X}),Be&&{legend:Be,legendPosition:He}),I&&"none"!==I&&{legendHoverBehavior:ve.onLegendHover,legendClickBehavior:ve.onLegendClick,legendHighlightedCategory:ve.highlightedCategory,legendIsolatedCategories:ve.isolatedCategories}),Q&&{title:Q}),c&&{className:c}),{tooltipContent:!1===O?()=>null:At(O)||$e}),(H||z)&&{customHoverBehavior:ue}),M&&{pointIdAccessor:M}),((null==E?void 0:E.length)||ie.length||Pe.length)&&{annotations:[...E||[],...ie,...Pe]}),B);return d.createElement(Ut,{componentName:"LineChart",width:G,height:q},d.createElement(Ye,Object.assign({ref:i},Ie)))});sn.displayName="LineChart";const an=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=vt(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:a,className:l,xFormat:c,yFormat:u,xAccessor:h="x",yAccessor:g="y",areaBy:p,y0Accessor:y,gradientFill:f=!1,lineDataAccessor:m="coordinates",colorBy:v,colorScheme:b="category10",curve:x="monotoneX",areaOpacity:k=.7,showLine:w=!0,lineWidth:A=2,tooltip:S,annotations:O,frameProps:M={},selection:E,linkedHover:j,onObservation:C,chartId:_,loading:L,emptyContent:B,legendInteraction:N,legendPosition:H}=t,z=i.width,$=i.height,T=i.enableHover,W=i.showGrid,I=i.showLegend,F=i.title,D=i.xLabel,R=i.yLabel,G=en(L,z,$);if(G)return G;const q=Jt(s,z,$,B);if(q)return q;const Y=s||[];tn("AreaChart",Y,"xAccessor",h),tn("AreaChart",Y,"yAccessor",g);const{activeSelectionHook:X,customHoverBehavior:V}=pt({selection:E,linkedHover:j,fallbackFields:v?["string"==typeof v?v:""]:[],onObservation:C,chartType:"AreaChart",chartId:_}),Q=void 0!==(null===(o=Y[0])||void 0===o?void 0:o[m]),U=e.useMemo(()=>{if(Q)return Y;if(p){const e=Y.reduce((e,t)=>{const n="function"==typeof p?p(t):t[p];if(!e[n]){const t={[m]:[]};"string"==typeof p&&(t[p]=n),e[n]=t}return e[n][m].push(t),e},{});return Object.values(e)}return[{[m]:Y}]},[Y,p,m,Q]),K=gt(Y,v,b),Z=e.useMemo(()=>{if(!v)return[];const e=new Set;for(const t of Y){const n="function"==typeof v?v(t):t[v];null!=n&&e.add(n+"")}return Array.from(e)},[Y,v]),J=ft(N,v,Z),ee=e.useMemo(()=>J.legendSelectionHook?J.legendSelectionHook:X,[J.legendSelectionHook,X]),te=e.useMemo(()=>e=>{const t={};if(v){if(K){const n=P(e,v,K);t.fill=n,w?(t.stroke=n,t.strokeWidth=A):t.stroke="none"}}else t.fill=ht,w?(t.stroke=ht,t.strokeWidth=A):t.stroke="none";return t.fillOpacity=k,t},[v,K,k,w,A]),ne=e.useMemo(()=>ut(te,ee,E),[te,ee,E]),{legend:oe,margin:re,legendPosition:ie}=yt({data:U,colorBy:v,colorScale:K,showLegend:I,legendPosition:H,userMargin:a,defaults:i.marginDefaults}),se=p||v,ae=e.useMemo(()=>Et([{label:D||St(h),accessor:h,role:"x"},{label:R||St(g),accessor:g,role:"y"},...se?[{label:St(se),accessor:se,role:"group"}]:[]]),[h,g,D,R,se]),le=Nt({componentName:"AreaChart",data:s,accessors:{xAccessor:h,yAccessor:g}});if(le)return d.createElement(jt,{componentName:"AreaChart",message:le,width:z,height:$});const ce=e.useMemo(()=>Q||p?U.flatMap(e=>{const t=e[m]||[];return p&&"string"==typeof p?t.map(t=>Object.assign(Object.assign({},t),{[p]:e[p]})):t}):Y,[U,m,Q,p,Y]),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!=s&&{data:ce}),{xAccessor:h,yAccessor:g,groupAccessor:p||void 0}),y&&{y0Accessor:y}),f&&{gradientFill:f}),{curve:x,lineStyle:ne,size:[z,$],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:re,showAxes:i.showAxes,xLabel:D,yLabel:R,xFormat:c,yFormat:u,enableHover:T,showGrid:W}),oe&&{legend:oe,legendPosition:ie}),N&&"none"!==N&&{legendHoverBehavior:J.onLegendHover,legendClickBehavior:J.onLegendClick,legendHighlightedCategory:J.highlightedCategory,legendIsolatedCategories:J.isolatedCategories}),F&&{title:F}),l&&{className:l}),{tooltipContent:!1===S?()=>null:At(S)||ae}),(j||C)&&{customHoverBehavior:V}),O&&O.length>0&&{annotations:O}),M);return d.createElement(Ut,{componentName:"AreaChart",width:z,height:$},d.createElement(Ye,Object.assign({ref:r},ue)))});an.displayName="AreaChart";const ln=e.forwardRef(function(t,n){var o;const r=e.useRef(null),i=vt(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:a,className:l,xFormat:c,yFormat:u,xAccessor:h="x",yAccessor:g="y",areaBy:p,lineDataAccessor:y="coordinates",colorBy:f,colorScheme:m="category10",curve:v="monotoneX",areaOpacity:b=.7,showLine:x=!0,lineWidth:k=2,normalize:w=!1,tooltip:A,annotations:S,frameProps:O={},selection:M,linkedHover:E,onObservation:C,chartId:_,loading:L,emptyContent:B,legendInteraction:N,legendPosition:H}=t,z=i.width,$=i.height,T=i.enableHover,W=i.showGrid,I=i.showLegend,F=i.title,D=i.xLabel,R=i.yLabel,G=en(L,z,$);if(G)return G;const q=Jt(s,z,$,B);if(q)return q;const Y=s||[],X=function({isPushMode:t,colorBy:n,colorScheme:o,showLegend:r,legendPosition:i="right"}){const s=e.useRef(new Set),a=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]),h=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||s.current.has(e)||(s.current.add(e),a.current.push(e),o=!0)}o&&c(e=>e+1)},[t,n,u]),d=e.useCallback(e=>t=>{h([t]),e(t)},[h]),g=e.useCallback(e=>t=>{h(t),e(t)},[h]),p=e.useCallback(()=>{s.current=new Set,a.current=[],c(e=>e+1)},[]),y=e.useMemo(()=>{if(!t||!n||!1===r)return;const e=a.current;if(0===e.length)return;const i=Array.isArray(o)?o:j,s=new Map;for(let t=0;e.length>t;t++)s.set(e[t],i[t%i.length]);const l="string"==typeof n?n:"__streamCat";return lt({data:e.map(e=>({[l]:e})),colorBy:l,colorScale:e=>s.get(e)||"#999",getColor:P})},[t,n,r,o,l]),f=e.useMemo(()=>{if(y)return"right"===i?{right:110}:"left"===i?{left:110}:"top"===i?{top:50}:"bottom"===i?{bottom:80}:{right:110}},[y,i]);return{wrapPush:d,wrapPushMany:g,resetCategories:p,streamingLegend:y,streamingMarginAdjust:f}}({isPushMode:void 0===s,colorBy:f||p,colorScheme:m,showLegend:I,legendPosition:H}),V=e.useCallback(X.wrapPush(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)}),[X.wrapPush]),Q=e.useCallback(X.wrapPushMany(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)}),[X.wrapPushMany]);e.useImperativeHandle(n,()=>({push:V,pushMany:Q,clear:()=>{var e;X.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:[]}}),[V,Q,X.resetCategories]);const{activeSelectionHook:U,customHoverBehavior:K}=pt({selection:M,linkedHover:E,fallbackFields:f?["string"==typeof f?f:""]:[],onObservation:C,chartType:"StackedAreaChart",chartId:_}),Z=void 0!==(null===(o=Y[0])||void 0===o?void 0:o[y]),J=e.useMemo(()=>{if(Z)return Y;if(p){const e=Y.reduce((e,t)=>{const n="function"==typeof p?p(t):t[p];if(!e[n]){const t={[y]:[]};"string"==typeof p&&(t[p]=n),e[n]=t}return e[n][y].push(t),e},{});return Object.values(e)}return[{[y]:Y}]},[Y,p,y,Z]),ee=gt(Y,f,m),te=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of Y){const n="function"==typeof f?f(t):t[f];null!=n&&e.add(n+"")}return Array.from(e)},[Y,f]),ne=ft(N,f,te),oe=e.useMemo(()=>ne.legendSelectionHook?ne.legendSelectionHook:U,[ne.legendSelectionHook,U]),re=e.useMemo(()=>e=>{const t={};if(f&&ee){const n=P(e,f,ee);t.fill=n,x?(t.stroke=n,t.strokeWidth=k):t.stroke="none"}else f||(t.fill=ht,t.stroke=x?ht:"none",x&&(t.strokeWidth=k));return t.fillOpacity=b,t},[f,ee,b,x,k]),ie=e.useMemo(()=>ut(re,oe,M),[re,oe,M]),{legend:se,margin:ae,legendPosition:le}=yt({data:J,colorBy:f,colorScale:ee,showLegend:I,legendPosition:H,userMargin:a,defaults:i.marginDefaults}),ce=X.streamingLegend||se,ue=H||le,he=e.useMemo(()=>{if(X.streamingMarginAdjust){const e=Object.assign({},ae);for(const[t,n]of Object.entries(X.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return ae},[ae,X.streamingMarginAdjust]),de=p||f,ge=e.useMemo(()=>Et([{label:D||St(h),accessor:h,role:"x"},{label:R||St(g),accessor:g,role:"y"},...de?[{label:St(de),accessor:de,role:"group"}]:[]]),[h,g,D,R,de]),pe=Nt({componentName:"StackedAreaChart",data:s,accessors:{xAccessor:h,yAccessor:g}});if(pe)return d.createElement(jt,{componentName:"StackedAreaChart",message:pe,width:z,height:$});const ye=e.useMemo(()=>Z||p?J.flatMap(e=>{const t=e[y]||[];return p&&"string"==typeof p?t.map(t=>Object.assign(Object.assign({},t),{[p]:e[p]})):t}):Y,[J,y,Z,p,Y]),fe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea"},null!=s&&{data:ye}),{xAccessor:h,yAccessor:g,groupAccessor:p||void 0,curve:v,normalize:w,lineStyle:ie,size:[z,$],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:he,showAxes:i.showAxes,xLabel:D,yLabel:R,xFormat:c,yFormat:u,enableHover:T,showGrid:W}),ce&&{legend:ce,legendPosition:ue}),N&&"none"!==N&&{legendHoverBehavior:ne.onLegendHover,legendClickBehavior:ne.onLegendClick,legendHighlightedCategory:ne.highlightedCategory,legendIsolatedCategories:ne.isolatedCategories}),F&&{title:F}),l&&{className:l}),{tooltipContent:!1===A?()=>null:At(A)||ge}),(E||C)&&{customHoverBehavior:K}),S&&S.length>0&&{annotations:S}),O);return d.createElement(Ut,{componentName:"StackedAreaChart",width:z,height:$},d.createElement(Ye,Object.assign({ref:r},fe)))});ln.displayName="StackedAreaChart";const cn=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=vt(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:s,className:a,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:h="y",colorBy:g,colorScheme:p="category10",sizeBy:y,sizeRange:f=[3,15],pointRadius:m=5,pointOpacity:v=.8,tooltip:b,marginalGraphics:x,pointIdAccessor:k,annotations:w,frameProps:A={},selection:S,linkedHover:O,linkedBrush:M,onObservation:E,chartId:j,loading:C,emptyContent:_,legendInteraction:B,legendPosition:N}=t,H=r.width,z=r.height,$=r.enableHover,T=r.showGrid,W=r.title,I=r.xLabel,F=r.yLabel,D=i||[],R=function(t){const{data:n,rawData:o,colorBy:r,colorScheme:i,legendInteraction:s,legendPosition:a,selection:l,linkedHover:c,fallbackFields:u,unwrapData:h=!1,onObservation:d,chartType:g,chartId:p,showLegend:y,userMargin:f,marginDefaults:m,loading:v,emptyContent:b,width:x,height:k}=t,{activeSelectionHook:w,customHoverBehavior:A,customClickBehavior:S}=pt({selection:l,linkedHover:c,fallbackFields:u,unwrapData:h,onObservation:d,chartType:g,chartId:p}),O=gt(n,r,i),M=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]),E=ft(s,r,M),j=e.useMemo(()=>E.legendSelectionHook?E.legendSelectionHook:w,[E.legendSelectionHook,w]),{legend:C,margin:P,legendPosition:_}=yt({data:n,colorBy:r,colorScale:O,showLegend:y,legendPosition:a,userMargin:f,defaults:m}),L=e.useMemo(()=>{const e={};return C&&(e.legend=C,e.legendPosition=_),s&&"none"!==s&&(e.legendHoverBehavior=E.onLegendHover,e.legendClickBehavior=E.onLegendClick,e.legendHighlightedCategory=E.highlightedCategory,e.legendIsolatedCategories=E.isolatedCategories),e},[C,_,s,E.onLegendHover,E.onLegendClick,E.highlightedCategory,E.isolatedCategories]),B=en(v,x,k),N=B?null:Jt(o,x,k,b);return{colorScale:O,allCategories:M,legendState:E,effectiveSelectionHook:j,activeSelectionHook:w,customHoverBehavior:A,customClickBehavior:S,legend:C,margin:P,legendPosition:_,earlyReturn:B||N||null,legendBehaviorProps:L}}({data:D,rawData:i,colorBy:g,colorScheme:p,legendInteraction:B,legendPosition:N,selection:S,linkedHover:O,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!1,onObservation:E,chartType:"Scatterplot",chartId:j,showLegend:r.showLegend,userMargin:s,marginDefaults:r.marginDefaults,loading:C,emptyContent:_,width:H,height:z}),G=ct(M),q=ot({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 h?h:void 0)}),Y=G?"xyBrush"===q.brushInteraction.brush?"xy":"xBrush"===q.brushInteraction.brush?"x":"y":void 0,X=d.useRef(q.brushInteraction);X.current=q.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(R.earlyReturn)return R.earlyReturn;tn("Scatterplot",D,"xAccessor",u),tn("Scatterplot",D,"yAccessor",h);const Q=e.useMemo(()=>{if(!y||0===D.length)return;const e=D.map(e=>"function"==typeof y?y(e):e[y]);return[Math.min(...e),Math.max(...e)]},[D,y]),U=e.useMemo(()=>e=>{const t={fillOpacity:v};return g?R.colorScale&&(t.fill=P(e,g,R.colorScale)):t.fill=ht,t.r=y?L(e,y,f,Q):m,t},[g,R.colorScale,y,f,Q,m,v]),K=e.useMemo(()=>ut(U,R.effectiveSelectionHook,S),[U,R.effectiveSelectionHook,S]),Z=e.useMemo(()=>Et([{label:I||St(u),accessor:u,role:"x"},{label:F||St(h),accessor:h,role:"y"},...g?[{label:St(g),accessor:g,role:"color"}]:[],...y?[{label:St(y),accessor:y,role:"size"}]:[]]),[u,h,I,F,g,y]),J=Nt({componentName:"Scatterplot",data:i,accessors:{xAccessor:u,yAccessor:h}});if(J)return d.createElement(jt,{componentName:"Scatterplot",message:J,width:H,height:z});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:D}),{xAccessor:u,yAccessor:h,colorAccessor:g||void 0,sizeAccessor:y||void 0,sizeRange:f,pointStyle:K,colorScheme:p,size:[H,z],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R.margin,showAxes:r.showAxes,xLabel:I,yLabel:F,xFormat:l,yFormat:c,enableHover:$,showGrid:T}),R.legendBehaviorProps),W&&{title:W}),a&&{className:a}),{tooltipContent:!1===b?()=>null:At(b)||Z}),(O||E)&&{customHoverBehavior:R.customHoverBehavior}),x&&{marginalGraphics:x}),k&&{pointIdAccessor:k}),w&&w.length>0&&{annotations:w}),G&&{brush:{dimension:Y},onBrush:V}),A);return d.createElement(Ut,{componentName:"Scatterplot",width:H,height:z},d.createElement(Ye,Object.assign({ref:o},ee)))});function un(e,t){return r.interpolateViridis(1===t?.5:e/(t-1))}cn.displayName="Scatterplot";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=vt(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:s,xFormat:a,yFormat:l,xAccessor:c="x",yAccessor:u="y",orderAccessor:h,orderLabel:g,pointRadius:p=4,tooltip:y,pointIdAccessor:f,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:k,chartId:w,loading:A,emptyContent:S,legendInteraction:O}=t,M=r.width,E=r.height,j=r.enableHover,C=r.showGrid,P=r.title,_=r.xLabel,L=r.yLabel,B=i||[],N=e.useMemo(()=>{if(!h||0===B.length)return B;const e="function"==typeof h?h:e=>e[h];return[...B].sort((t,n)=>{const o=e(t),r=e(n);return(o instanceof Date?o.getTime():+o)-(r instanceof Date?r.getTime():+r)})},[B,h]);tn("ConnectedScatterplot",N,"xAccessor",c),tn("ConnectedScatterplot",N,"yAccessor",u);const{activeSelectionHook:H,customHoverBehavior:z}=pt({selection:b,linkedHover:x,fallbackFields:[],onObservation:k,chartType:"ConnectedScatterplot",chartId:w}),$=ft(O,void 0,[]),T=e.useMemo(()=>$.legendSelectionHook?$.legendSelectionHook:H,[$.legendSelectionHook,H]),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,s=null==T?void 0:T.predicate,a=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],h=un(t,l),d=!i||!s||s(null!==(n=c.datum)&&void 0!==n?n:c)||s(null!==(o=u.datum)&&void 0!==o?o:u),g=i?d?1:.2:1;a&&(e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle="white",e.lineWidth=p+2,e.globalAlpha=.5*g,e.stroke()),e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle=h,e.lineWidth=p,e.globalAlpha=g,e.stroke()}e.globalAlpha=1},[p,T]),I=e.useMemo(()=>[W],[W]),F=e.useRef({idx:0,total:0}),D=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 s=F.current;if(0===s.idx){const n=null!==(i=null===(r=o.current)||void 0===r?void 0:r.getData())&&void 0!==i?i:N;s.total=n.filter(n=>{const o=e(n),r=t(n);return null!=o&&null!=r&&isFinite(o)&&isFinite(r)}).length}const a=s.total,l=s.idx;return s.idx++,a>s.idx||(s.idx=0),{fill:a>0?un(l,a):"#6366f1",stroke:"white",strokeWidth:1,r:p,fillOpacity:1}}},[p,N.length,c,u]),R=e.useMemo(()=>ut(D,T,b),[D,T,b]),G=Object.assign({top:50,right:40,bottom:60,left:70},t.margin),q=g||("string"==typeof h?h:"Order"),Y=e.useMemo(()=>Et([{label:_||St(c),accessor:c,role:"x"},{label:L||St(u),accessor:u,role:"y"},...h?[{label:q,accessor:h,role:"group"}]:[]]),[c,u,_,L,h,q]),X=Nt({componentName:"ConnectedScatterplot",data:i,accessors:{xAccessor:c,yAccessor:u}}),V=en(A,M,E);if(V)return V;const Q=Jt(i,M,E,S);if(Q)return Q;if(X)return d.createElement(jt,{componentName:"ConnectedScatterplot",message:X,width:M,height:E});const U=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:N}),{xAccessor:c,yAccessor:u,pointStyle:R,size:[M,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:G,showAxes:r.showAxes,xLabel:_,yLabel:L,xFormat:a,yFormat:l,enableHover:j,showGrid:C}),P&&{title:P}),s&&{className:s}),{tooltipContent:!1===y?()=>null:At(y)||Y}),(x||k)&&{customHoverBehavior:z}),f&&{pointIdAccessor:f}),{canvasPreRenderers:I}),m&&m.length>0&&{annotations:m}),v);return d.createElement(Ut,{componentName:"ConnectedScatterplot",width:M,height:E},d.createElement(Ye,Object.assign({ref:o},U)))});hn.displayName="ConnectedScatterplot";const dn=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=vt(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:s,className:a,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:h="y",sizeBy:g,sizeRange:p=[5,40],colorBy:y,colorScheme:f="category10",bubbleOpacity:m=.6,bubbleStrokeWidth:v=1,bubbleStrokeColor:b="white",tooltip:x,marginalGraphics:k,pointIdAccessor:w,annotations:A,frameProps:S={},selection:O,linkedHover:M,linkedBrush:E,onObservation:j,chartId:C,loading:_,emptyContent:B,legendInteraction:N,legendPosition:H}=t,z=r.width,$=r.height,T=r.enableHover,W=r.showGrid,I=r.showLegend,F=r.title,D=r.xLabel,R=r.yLabel,G=en(_,z,$);if(G)return G;const q=Jt(i,z,$,B);if(q)return q;const Y=i||[],{activeSelectionHook:X,customHoverBehavior:V}=pt({selection:O,linkedHover:M,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:j,chartType:"BubbleChart",chartId:C}),Q=ct(E);ot({name:(null==Q?void 0:Q.name)||"__unused_brush__",xField:(null==Q?void 0:Q.xField)||("string"==typeof u?u:void 0),yField:(null==Q?void 0:Q.yField)||("string"==typeof h?h:void 0)});const U=gt(Y,y,f),K=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]),Z=ft(N,y,K),J=e.useMemo(()=>Z.legendSelectionHook?Z.legendSelectionHook:X,[Z.legendSelectionHook,X]),ee=e.useMemo(()=>{const e=Y.map(e=>"function"==typeof g?g(e):e[g]);return[Math.min(...e),Math.max(...e)]},[Y,g]),te=e.useMemo(()=>e=>{const t={fillOpacity:m,strokeWidth:v,stroke:b};return y?U&&(t.fill=P(e,y,U)):t.fill=ht,t.r=L(e,g,p,ee),t},[y,U,g,p,ee,m,v,b]),ne=e.useMemo(()=>ut(te,J,O),[te,J,O]),{legend:oe,margin:re,legendPosition:ie}=yt({data:Y,colorBy:y,colorScale:U,showLegend:I,legendPosition:H,userMargin:s,defaults:r.marginDefaults}),se=e.useMemo(()=>Et([{label:D||St(u),accessor:u,role:"x"},{label:R||St(h),accessor:h,role:"y"},{label:St(g),accessor:g,role:"size"},...y?[{label:St(y),accessor:y,role:"color"}]:[]]),[u,h,D,R,g,y]),ae=Nt({componentName:"BubbleChart",data:i,accessors:{xAccessor:u,yAccessor:h},requiredProps:{sizeBy:g}});if(ae)return d.createElement(jt,{componentName:"BubbleChart",message:ae,width:z,height:$});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:Y}),{xAccessor:u,yAccessor:h,colorAccessor:y||void 0,sizeAccessor:g,sizeRange:p,pointStyle:ne,colorScheme:f,size:[z,$],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:re,showAxes:r.showAxes,xLabel:D,yLabel:R,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}),F&&{title:F}),a&&{className:a}),{tooltipContent:!1===x?()=>null:At(x)||se}),(M||j)&&{customHoverBehavior:V}),k&&{marginalGraphics:k}),w&&{pointIdAccessor:w}),A&&A.length>0&&{annotations:A}),S);return d.createElement(Ut,{componentName:"BubbleChart",width:z,height:$},d.createElement(Ye,Object.assign({ref:o},le)))});dn.displayName="BubbleChart";const gn=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 s=vt(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:a,margin:l,className:c,xAccessor:u="x",yAccessor:h="y",valueAccessor:g="value",xFormat:p,yFormat:y,colorScheme:f="blues",customColorScale:m,showValues:v=!1,valueFormat:b,cellBorderColor:x="#fff",cellBorderWidth:k=1,tooltip:w,annotations:A,frameProps:S={},selection:O,linkedHover:M,onObservation:E,chartId:j,loading:C,emptyContent:P,showLegend:_,legendPosition:L,legendInteraction:B}=t,N=s.width,H=s.height,z=s.enableHover,$=s.title,T=s.xLabel,W=s.yLabel,I=en(C,N,H);if(I)return I;const F=Jt(a,N,H,P);if(F)return F;const D=a||[],R=null!=_&&_,G=null!=L?L:"right",{margin:q}=yt({data:D,colorBy:R?"value":void 0,colorScale:void 0,showLegend:R,legendPosition:G,userMargin:l,defaults:s.marginDefaults}),{activeSelectionHook:Y,customHoverBehavior:X}=pt({selection:O,linkedHover:M,fallbackFields:[],onObservation:E,chartType:"Heatmap",chartId:j}),V=ft(B,void 0,[]),Q=e.useMemo(()=>V.legendSelectionHook?V.legendSelectionHook:Y,[V.legendSelectionHook,Y]),U=e.useMemo(()=>"function"==typeof g?e=>g(e):e=>e[g],[g]),K=e.useMemo(()=>{const e=D.map(U);return[Math.min(...e),Math.max(...e)]},[D,U]),Z=e.useMemo(()=>"custom"===f&&m?m:o.scaleSequential({blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,viridis:r.interpolateViridis}[f]||r.interpolateBlues).domain(K),[f,m,K]);e.useMemo(()=>{const e=dt(u),t=dt(h);return{xBinCount:new Set(D.map(e)).size,yBinCount:new Set(D.map(t)).size}},[D,u,h]),e.useMemo(()=>({coordinates:D}),[D]);const J=e.useMemo(()=>e=>{const t=U(e);return{fill:Z(t),stroke:x,strokeWidth:k}},[U,Z,x,k]);e.useMemo(()=>ut(J,Q,O),[J,Q,O]);const ee=e.useMemo(()=>Et([{label:T||St(u),accessor:u,role:"x"},{label:W||St(h),accessor:h,role:"y"},{label:St(g),accessor:g,role:"value"}]),[u,h,T,W,g]),te=Nt({componentName:"Heatmap",data:a,accessors:{xAccessor:u,yAccessor:h,valueAccessor:g}});if(te)return d.createElement(jt,{componentName:"Heatmap",message:te,width:N,height:H});const ne=e.useMemo(()=>{if(R)return{gradient:{colorFn:e=>Z(e),domain:K,label:"string"==typeof g?g:"value",format:b}}},[R,Z,K,g,b]),oe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap"},null!=a&&{data:D}),{xAccessor:u,yAccessor:h,valueAccessor:g,colorScheme:"custom"!==f?f:void 0,showValues:v,heatmapValueFormat:b,size:[N,H],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:q,showAxes:s.showAxes,xLabel:T,yLabel:W,xFormat:p,yFormat:y,enableHover:z}),ne&&{legend:ne,legendPosition:G}),$&&{title:$}),c&&{className:c}),{tooltipContent:!1===w?()=>null:At(w)||ee}),(M||E)&&{customHoverBehavior:X}),A&&A.length>0&&{annotations:A}),S);return d.createElement(Ut,{componentName:"Heatmap",width:N,height:H},d.createElement(Ye,Object.assign({ref:i},oe)))});gn.displayName="Heatmap";const pn="__splomIdx",yn={top:4,bottom:4,left:4,right:4};function fn({frameRef:o,cellSize:r,onBrush:i}){const s=e.useRef(null),a=r-yn.left-yn.right,l=r-yn.top-yn.bottom;return e.useEffect(()=>{if(!s.current)return;const e=n.select(s.current).select(".brush-g"),r=t.brush().extent([[0,0],[a,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,s],[a,l]]=e.selection,c=[[n.x.invert(r),n.y.invert(s)],[n.x.invert(a),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)}},[a,l,o,i]),d.createElement("svg",{ref:s,width:r,height:r,style:{position:"absolute",top:0,left:0}},d.createElement("g",{className:"brush-g",transform:`translate(${yn.left},${yn.top})`}))}function mn({data:t,xField:n,yField:o,cellSize:r,pointRadius:i,pointOpacity:s,colorBy:a,colorScale:l,brushSelectionName:c,hoverSelectionName:u,unselectedOpacity:h,mode:g,onPointHover:p}){const y=e.useRef(null),f=tt({name:c,clientId:`splom-${n}-${o}`}),m=ot({name:c,xField:n,yField:o}),v=tt({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==p||p(null));const t=e.data,n=null==t?void 0:t[pn];void 0!==n&&(b({[pn]:[n]}),null==p||p(t,e.x+yn.left,e.y+yn.top))},[b,p]),w=e.useCallback(e=>{const t={opacity:s,r:i};return t.fill=a?P(e,a,l):ht,"hover"===g?v.isActive&&v.predicate(e)?(t.opacity=1,t.r=2.5*i,t.stroke="#333",t.strokeWidth=1.5):v.isActive&&(t.opacity=.6*s):f.isActive&&!f.predicate(e)&&(t.opacity=h),t},[a,l,s,i,g,f.isActive,f.predicate,v.isActive,v.predicate,h]);return d.createElement("div",{style:{position:"relative",width:r,height:r}},d.createElement(Ye,{ref:y,chartType:"scatter",data:t,size:[r,r],xAccessor:n,yAccessor:o,pointStyle:w,margin:yn,showAxes:!1,enableHover:"hover"===g,customHoverBehavior:"hover"===g?k:void 0,tooltipContent:"hover"===g?()=>null:void 0}),"brush"===g&&d.createElement(fn,{frameRef:y,cellSize:r,xField:n,yField:o,onBrush:x}))}function vn({data:t,field:n,label:o,cellSize:r,bins:i,colorBy:s,colorScale:a,brushSelectionName:l,hoverSelectionName:c,mode:u}){const h=tt({name:l,clientId:"splom-diag-"+n}),g=tt({name:c,clientId:`splom-diag-${n}-hover`}),p="hover"===u?g:h,y=p.isActive,f=p.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),a=(Math.max(...e)-o)/i||1,l="string"==typeof s?s: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])),h=Array(i).fill(0),d=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)/a),i-1);if(h[r]++,y&&!f(e)||d[r]++,l){const t=u.get(e[l]+"");void 0!==t&&(g[r][t]++,y&&!f(e)||p[r][t]++)}}const m=Math.max(...h,1),v=g.map((e,t)=>{let n=0;return e.map((e,o)=>{const s=e/m*(r-24),a={x:t/i*r,w:r/i-1,h:s,y0:n,category:c[o]};return n+=s,a})}),b=p.map((e,t)=>{let n=0;return e.map((e,o)=>{const s=e/m*(r-24),a={x:t/i*r,w:r/i-1,h:s,y0:n,category:c[o]};return n+=s,a})});return{bars:h.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/m*(r-24),count:e})),selectedBars:d.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,y,f,s]);return d.createElement("svg",{width:r,height:r,style:{overflow:"hidden"}},d.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)=>d.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:a?a(e.category):ht,opacity:y?.3:.6}))):m.bars.map((e,t)=>d.createElement("rect",{key:"bg-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:ht,opacity:y?.3:.6})),y&&(m.categories.length>0?m.selectedCategoryBars.map((e,t)=>e.map((e,n)=>d.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:a?a(e.category):ht,opacity:.7}))):m.selectedBars.map((e,t)=>d.createElement("rect",{key:"sel-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:ht,opacity:.7}))))}function bn({label:e,cellSize:t}){return d.createElement("svg",{width:t,height:t},d.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:s="category10",cellSize:a=150,cellGap:l=4,pointRadius:c=2,pointOpacity:u=.5,diagonal:h="histogram",histogramBins:g=20,brushMode:p="crossfilter",hoverMode:y=!0,unselectedOpacity:f=.1,showGrid:m=!1,tooltip:v,showLegend:b,idAccessor:x,className:k,onObservation:w,chartId:A}=t,S="splom",O="splom-hover",M=y?"hover":p?"brush":"hover",E=Ze(e=>e.clearSelection),[j,C]=e.useState(null),P=e.useCallback(()=>{E(O),C(null)},[E,O]),_=e.useMemo(()=>(n||[]).map((e,t)=>void 0!==e[pn]?e:Object.assign(Object.assign({},e),{[pn]:t})),[n]),L=gt(_,i,s),B=void 0!==b?b:!!i,N=e.useMemo(()=>{if(!B||!i)return null;const e="string"==typeof i?i:null;return e?[...new Set(_.map(t=>t[e]))].map(e=>({label:e+"",color:L?L(e+""):ht})):null},[B,i,_,L]),H=e.useMemo(()=>({display:"grid",gridTemplateColumns:"40px "+o.map(()=>a+"px").join(" "),gridTemplateRows:o.map(()=>a+"px").join(" ")+" 40px",gap:l+"px",width:"fit-content"}),[o,a,l,40]);return d.createElement("div",{className:k,style:{position:"relative"}},N&&d.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},N.map(e=>d.createElement("div",{key:e.label,style:{display:"flex",alignItems:"center",gap:4}},d.createElement("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:e.color}}),d.createElement("span",{style:{fontSize:11}},e.label)))),d.createElement("div",{style:H,onMouseLeave:"hover"===M?P:void 0},o.map((e,t)=>d.createElement(d.Fragment,{key:"row-"+e},d.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"===h?d.createElement(bn,{key:"diag-"+e,label:r[e]||e,cellSize:a}):d.createElement(vn,{key:"diag-"+e,data:_,field:e,label:r[e]||e,cellSize:a,bins:g,colorBy:i,colorScale:L,brushSelectionName:S,hoverSelectionName:O,unselectedOpacity:f,mode:M}):d.createElement(mn,{key:`cell-${e}-${n}`,data:_,xField:n,yField:e,fieldLabels:r,cellSize:a,pointRadius:c,pointOpacity:u,colorBy:i,colorScale:L,brushSelectionName:S,hoverSelectionName:O,unselectedOpacity:f,showGrid:m,tooltip:v,mode:M,onPointHover:"hover"===M?(r,i,s)=>{r?(C({datum:r,xField:n,yField:e,colIndex:o,rowIndex:t,px:null!=i?i:0,py:null!=s?s:0}),w&&w({type:"hover",datum:r,x:null!=i?i:0,y:null!=s?s:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A})):(C(null),w&&w({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A}))}:void 0})))),d.createElement("div",null)," ",o.map(e=>d.createElement("div",{key:"col-label-"+e,style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e))),j&&"hover"===M&&(()=>{const e=j.datum,t=r[j.xField]||j.xField,n=r[j.yField]||j.yField,o=i?"function"==typeof i?i(e):e[i]:null,s=x?"function"==typeof x?x(e):e[x]:"Row "+e[pn];return d.createElement("div",{style:{position:"absolute",left:40+j.colIndex*(a+l)+j.px,top:j.rowIndex*(a+l)+j.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}},d.createElement("div",{style:{fontWeight:"bold",marginBottom:2}},s+""),d.createElement("div",null,t,": ",null!=e[j.xField]?Number(e[j.xField]).toFixed(1):"–"),d.createElement("div",null,n,": ",null!=e[j.yField]?Number(e[j.yField]).toFixed(1):"–"),null!=o&&d.createElement("div",{style:{opacity:.8}},"string"==typeof i?i:"group",": ",o+""))})())}function kn(e){const{brushMode:t="crossfilter",hoverMode:n=!0}=e,o={};return!n&&t&&(o.splom={resolution:t}),n&&(o["splom-hover"]={resolution:"union"}),d.createElement(at,{selections:o},d.createElement(xn,Object.assign({},e)))}function wn({width:o,height:r,margin:i,scales:s,brushDirection:a,extent:l,onBrush:c}){const u=e.useRef(null),h=e.useRef(null),g=e.useRef(!1),p=o+i.left+i.right,y=r+i.top+i.bottom;return e.useEffect(()=>{if(!u.current||!s)return;const e=n.select(u.current).select(".brush-group"),i="x"===a?t.brushX().extent([[0,0],[o,r]]):t.brushY().extent([[0,0],[o,r]]);return i.on("brush end",e=>{if(g.current)return;if(!e.sourceEvent)return;const t=e.selection;if(!t)return void c(null);const n=("x"===a?s.x:s.y).invert;if(!n)return;const o=[n(t[0]),n(t[1])];c(o)}),e.call(i),h.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null)}},[s,o,r,a,c]),e.useEffect(()=>{if(!h.current||!s||!u.current)return;const e=n.select(u.current).select(".brush-group"),t="x"===a?s.x:s.y;if(g.current=!0,l){const n=[t(l[0]),t(l[1])];e.call(h.current.move,n)}else e.call(h.current.move,null);g.current=!1},[l,s,a]),d.createElement("svg",{ref:u,width:p,height:y,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},d.createElement("g",{className:"brush-group",transform:`translate(${i.left},${i.top})`}))}function An(t){var n,o;const{data:r,width:i=600,height:s=400,margin:a,className:l,title:c,xLabel:u,yLabel:h,xFormat:g,yFormat:p,xAccessor:y="x",yAccessor:f="y",lineBy:m,lineDataAccessor:v="coordinates",colorBy:b,colorScheme:x="category10",curve:k="linear",lineWidth:w=2,fillArea:A=!1,areaOpacity:S=.3,showPoints:O=!1,pointRadius:M=3,enableHover:E=!0,showGrid:j=!1,showLegend:C,legendPosition:_,tooltip:L,minimap:B={},renderBefore:N=!1,onBrush:H,brushExtent:z,frameProps:$={},loading:T,emptyContent:W}=t,I=en(T,i,s);if(I)return I;const F=Jt(r,i,s,W);if(F)return F;const D=r||[],[R,G]=e.useState(null),q=null!=z?z:R,Y=e.useCallback(e=>{z||G(e),null==H||H(e)},[z,H]),X=e.useRef(null),[V,Q]=e.useState(null);e.useEffect(()=>{const e=()=>{var t,n;const o=null===(n=null===(t=X.current)||void 0===t?void 0:t.getScales)||void 0===n?void 0:n.call(t);o?Q(o):requestAnimationFrame(e)};requestAnimationFrame(e)},[r]);const U=void 0!==(null===(n=D[0])||void 0===n?void 0:n[v]),K=e.useMemo(()=>{if(U)return D;if(m){const e=D.reduce((e,t)=>{const n="function"==typeof m?m(t):t[m];if(!e[n]){const t={[v]:[]};"string"==typeof m&&(t[m]=n),e[n]=t}return e[n][v].push(t),e},{});return Object.values(e)}return[{[v]:D}]},[D,m,v,U]),Z=e.useMemo(()=>U||m?K.flatMap(e=>{const t=e[v]||[];return m&&"string"==typeof m?t.map(t=>Object.assign(Object.assign({},t),{[m]:e[m]})):t}):D,[K,v,U,m,D]),J=gt(D,b,x),ee=e.useMemo(()=>e=>{const t={strokeWidth:w};return t.stroke=b?P(e,b,J):ht,A&&(t.fill=t.stroke,t.fillOpacity=S),t},[b,J,w,A,S]),te=e.useMemo(()=>B.lineStyle?B.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=b?P(e,b,J):ht,t},[b,J,B.lineStyle]),ne=e.useMemo(()=>{if(O)return e=>{const t={r:M,fillOpacity:1};return t.fill=b?P(e.parentLine||e,b,J):ht,t}},[O,M,b,J]),{legend:oe,margin:re,legendPosition:ie}=yt({data:K,colorBy:b,colorScale:J,showLegend:C,legendPosition:_,userMargin:a}),se=B.height||60,ae=e.useMemo(()=>{var e,t,n,o,r,i,s,a;return{top:null!==(t=null===(e=B.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(o=null===(n=B.margin)||void 0===n?void 0:n.bottom)&&void 0!==o?o:20,left:null!==(i=null===(r=B.margin)||void 0===r?void 0:r.left)&&void 0!==i?i:re.left,right:null!==(a=null===(s=B.margin)||void 0===s?void 0:s.right)&&void 0!==a?a:re.right}},[B.margin,re]),le=B.brushDirection||"x",ce=Nt({componentName:"MinimapChart",data:r,accessors:{xAccessor:y,yAccessor:f}});if(ce)return d.createElement(jt,{componentName:"MinimapChart",message:ce,width:i,height:s});const ue=A?"area":"line",he=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:ue,data:Z,xAccessor:y,yAccessor:f,groupAccessor:m||void 0,curve:k,lineStyle:ee},O&&{pointStyle:ne}),{size:[i,s],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:re,showAxes:!0,xLabel:u,yLabel:h,xFormat:g,yFormat:p,enableHover:E,showGrid:j}),oe&&{legend:oe,legendPosition:ie}),c&&{title:c}),L&&{tooltipContent:At(L)||void 0}),q&&{xExtent:q}),$),de={chartType:ue,data:Z,xAccessor:y,yAccessor:f,groupAccessor:m||void 0,curve:k,lineStyle:te,size:[i,se+ae.top+ae.bottom],margin:ae,showAxes:null!==(o=B.showAxes)&&void 0!==o&&o,background:B.background,enableHover:!1},ge=d.createElement("div",{key:"minimap",style:{position:"relative",width:i,overflow:"hidden"}},d.createElement(Ye,Object.assign({ref:X},de)),d.createElement(wn,{width:i-ae.left-ae.right,height:se,margin:ae,scales:V,brushDirection:le,extent:q,onBrush:Y})),pe=d.createElement("div",{key:"main",style:{overflow:"hidden"}},d.createElement(Ye,Object.assign({},he)));return d.createElement(Ut,{componentName:"MinimapChart",width:i,height:s},d.createElement("div",{className:"minimap-chart"+(l?" "+l:"")},N?ge:pe,N?pe:ge))}kn.displayName="ScatterplotMatrix",An.displayName="MinimapChart";const Sn=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=vt(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:s,className:a,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:h="y",xCenter:g,yCenter:p,quadrants:y,centerlineStyle:f={},showQuadrantLabels:m=!0,quadrantLabelSize:v=12,colorBy:b,colorScheme:x="category10",sizeBy:k,sizeRange:w=[3,15],pointRadius:A=5,pointOpacity:S=.8,tooltip:O,pointIdAccessor:M,annotations:E,frameProps:j={},selection:C,linkedHover:_,onObservation:B,chartId:N,loading:H,emptyContent:z,legendInteraction:$,legendPosition:T}=t,W=r.width,I=r.height,F=r.enableHover,D=r.showGrid,R=r.showLegend,G=r.title,q=r.xLabel,Y=r.yLabel,X=en(H,W,I);if(X)return X;const V=Jt(i,W,I,z);if(V)return V;const Q=i||[];tn("QuadrantChart",Q,"xAccessor",u),tn("QuadrantChart",Q,"yAccessor",h);const{activeSelectionHook:U,customHoverBehavior:K}=pt({selection:C,linkedHover:_,fallbackFields:"string"==typeof b?[b]:[],onObservation:B,chartType:"QuadrantChart",chartId:N}),Z=gt(Q,b,x),J=e.useMemo(()=>{if(!b)return[];const e=new Set;for(const t of Q){const n="function"==typeof b?b(t):t[b];null!=n&&e.add(n+"")}return Array.from(e)},[Q,b]),ee=ft($,b,J),te=e.useMemo(()=>ee.legendSelectionHook?ee.legendSelectionHook:U,[ee.legendSelectionHook,U]),ne=e.useMemo(()=>{if(!Q.length)return;const e="function"==typeof u?u:e=>+e[u],t="function"==typeof h?h:e=>+e[h];let n=1/0,o=-1/0,r=1/0,i=-1/0;for(const s of Q){const a=e(s),l=t(s);isFinite(a)&&(n>a&&(n=a),a>o&&(o=a)),isFinite(l)&&(r>l&&(r=l),l>i&&(i=l))}if(null!=g&&isFinite(g)&&(n>g&&(n=g),g>o&&(o=g)),null!=p&&isFinite(p)&&(r>p&&(r=p),p>i&&(i=p)),n===1/0)return;const s=.1*(o-n)||1,a=.1*(i-r)||1;return{xExtent:[n-s,o+s],yExtent:[r-a,i+a]}},[Q,u,h,g,p]),oe=e.useMemo(()=>{if(!k||0===Q.length)return;const e=Q.map(e=>"function"==typeof k?k(e):e[k]).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0!==e.length?[Math.min(...e),Math.max(...e)]:void 0},[Q,k]),re=e.useMemo(()=>"function"==typeof u?u:e=>+e[u],[u]),ie=e.useMemo(()=>"function"==typeof h?h:e=>+e[h],[h]),se=e.useMemo(()=>e=>{const t={fillOpacity:S};if(b)Z&&(t.fill=P(e,b,Z));else{const n=re(e),o=ie(e),r=null!=g?n>=g:void 0,i=null!=p?o>=p:void 0;t.fill=void 0===i||void 0===r?ht:i&&r?y.topRight.color:i&&!r?y.topLeft.color:!i&&r?y.bottomRight.color:y.bottomLeft.color}return t.r=k?L(e,k,w,oe):A,t},[b,Z,k,w,oe,A,S,re,ie,g,p,y]),ae=e.useMemo(()=>ut(se,te,C),[se,te,C]),{legend:le,margin:ce,legendPosition:ue}=yt({data:Q,colorBy:b,colorScale:Z,showLegend:R,legendPosition:T,userMargin:s,defaults:r.marginDefaults}),he=e.useMemo(()=>{if(!Q.length)return;const e=new Set;"string"==typeof u&&e.add(u),"string"==typeof h&&e.add(h),"string"==typeof b&&e.add(b),"string"==typeof k&&e.add(k);const t=Q[0];for(const n of Object.keys(t))if(!n.startsWith("_")&&!e.has(n)&&"string"==typeof t[n])return n},[Q,u,h,b,k]),de=e.useMemo(()=>Et([...he?[{label:he,accessor:he,role:"title"}]:[],{label:q||St(u),accessor:u,role:"x"},{label:Y||St(h),accessor:h,role:"y"},...b?[{label:St(b),accessor:b,role:"color"}]:[],...k?[{label:St(k),accessor:k,role:"size"}]:[]]),[he,u,h,q,Y,b,k]),ge=Nt({componentName:"QuadrantChart",data:i,accessors:{xAccessor:u,yAccessor:h}});if(ge)return d.createElement(jt,{componentName:"QuadrantChart",message:ge,width:W,height:I});const pe=e.useMemo(()=>{var e;const t={stroke:f.stroke||"#999",strokeWidth:null!==(e=f.strokeWidth)&&void 0!==e?e:1,dashArray:f.strokeDasharray||[]};return[(e,n,o,r)=>{var i;if(!(null==o?void 0:o.x)||!(null==o?void 0:o.y))return;const s=r.width,a=r.height,l=null!=g?o.x(g):s/2,c=null!=p?o.y(p):a/2;if(null!=g&&!isFinite(l))return;if(null!=p&&!isFinite(c))return;const u=Math.max(0,Math.min(s,l)),h=Math.max(0,Math.min(a,c)),d=[{config:y.topLeft,x:0,y:0,w:u,h:h},{config:y.topRight,x:u,y:0,w:s-u,h:h},{config:y.bottomLeft,x:0,y:h,w:u,h:a-h},{config:y.bottomRight,x:u,y:h,w:s-u,h:a-h}];for(const t of d)t.w>0&&t.h>0&&(e.fillStyle=t.config.color,e.globalAlpha=null!==(i=t.config.opacity)&&void 0!==i?i:.08,e.fillRect(t.x,t.y,t.w,t.h));e.globalAlpha=1,e.strokeStyle=t.stroke,e.lineWidth=t.strokeWidth,t.dashArray.length>0&&e.setLineDash(t.dashArray),e.beginPath(),e.moveTo(u,0),e.lineTo(u,a),e.stroke(),e.beginPath(),e.moveTo(0,h),e.lineTo(s,h),e.stroke(),e.setLineDash([])}]},[g,p,y,f]),ye=e.useMemo(()=>m?[...pe,(e,t,n,o)=>{if(!(null==n?void 0:n.x)||!(null==n?void 0:n.y))return;const r=o.width,i=o.height,s=null!=g?n.x(g):r/2,a=null!=p?n.y(p):i/2;(null==g||isFinite(s))&&(null==p||isFinite(a))&&(e.font=`600 ${v}px sans-serif`,e.globalAlpha=.5,e.fillStyle=y.topLeft.color,e.textAlign="left",e.textBaseline="top",e.fillText(y.topLeft.label,8,8),e.fillStyle=y.topRight.color,e.textAlign="right",e.textBaseline="top",e.fillText(y.topRight.label,r-8,8),e.fillStyle=y.bottomLeft.color,e.textAlign="left",e.textBaseline="bottom",e.fillText(y.bottomLeft.label,8,i-8),e.fillStyle=y.bottomRight.color,e.textAlign="right",e.textBaseline="bottom",e.fillText(y.bottomRight.label,r-8,i-8),e.globalAlpha=1)}]:pe,[pe,m,v,y,g,p]),fe=e.useMemo(()=>{const e=j.canvasPreRenderers||[];return[...ye,...e]},[ye,j.canvasPreRenderers]),me=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(Object.assign({chartType:"scatter"},null!=i&&{data:Q}),{xAccessor:u,yAccessor:h,colorAccessor:b||void 0,sizeAccessor:k||void 0,sizeRange:w,pointStyle:ae,colorScheme:x,size:[W,I],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ce,showAxes:r.showAxes,xLabel:q,yLabel:Y,xFormat:l,yFormat:c,enableHover:F,showGrid:D}),ne&&{xExtent:ne.xExtent,yExtent:ne.yExtent}),le&&{legend:le,legendPosition:ue}),$&&"none"!==$&&{legendHoverBehavior:ee.onLegendHover,legendClickBehavior:ee.onLegendClick,legendHighlightedCategory:ee.highlightedCategory,legendIsolatedCategories:ee.isolatedCategories}),G&&{title:G}),a&&{className:a}),{tooltipContent:!1===O?()=>null:!0===O||void 0===O?de:At(O)||de}),(_||B)&&{customHoverBehavior:K}),M&&{pointIdAccessor:M}),E&&E.length>0&&{annotations:E}),{canvasPreRenderers:fe}),j),fe.length>0&&{canvasPreRenderers:fe});return d.createElement(Ut,{componentName:"QuadrantChart",width:W,height:I},d.createElement(Ye,Object.assign({ref:o},me)))});Sn.displayName="QuadrantChart";const On="__forecastSegment";function Mn(e,t){return"function"==typeof t?t(e):!!e[t]}const En=Object.freeze({__proto__:null,SEGMENT_FIELD:On,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,s,a;const{isTraining:l,isForecast:c,isAnomaly:u,upperBounds:h,lowerBounds:d,color:g="#6366f1",bandOpacity:p=.15,anomalyColor:y="#ef4444",anomalyRadius:f=6,label:m}=o,v=e.map(e=>{let t="observed";return c&&Mn(e,c)?t="forecast":l&&Mn(e,l)&&(t="training"),Object.assign(Object.assign({},e),{[On]:t})}),b=[];for(let e=0;v.length>e;e++)b.push(v[e]),v.length-1>e&&v[e][On]!==v[e+1][On]&&b.push(Object.assign(Object.assign({},v[e]),{[On]:v[e+1][On]}));const x=[];if(h&&d){const e="string"==typeof h?h:"__envUpper",t="string"==typeof d?d:"__envLower";if("function"==typeof h||"function"==typeof d)for(const n of b)"function"==typeof h&&(n[e]=h(n)),"function"==typeof d&&(n[t]=d(n));x.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:g,fillOpacity:p,label:m})}return u&&x.push({type:"highlight",filter:e=>Mn(e,u),color:y,r:f,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!==(s=r.bandOpacity)&&void 0!==s?s:.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:null!==(a=r.anomalyRadius)&&void 0!==a?a:6,label:r.label}),{processedData:b,annotations:x}}(e,0,0,o,r):function(e,t,n,o,r){var i,s,a;const{trainEnd:l,steps:c=10,confidence:u=.95,color:h="#6366f1",bandOpacity:d=.15,label:g}=o;if(null==l)return{processedData:e,annotations:[]};const p=[],y=[];for(const n of e)n[t]>l?y.push(Object.assign(Object.assign({},n),{[On]:"observed"})):p.push(Object.assign(Object.assign({},n),{[On]:"training"}));const f=p.map(e=>[e[t],e[n]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),m=[],v=[];if(f.length>=3){const o=f.length;let r=0,i=0,s=0,a=0;for(const[e,t]of f)r+=e,i+=t,s+=e*e,a+=e*t;const l=o*s-r*r;if(Math.abs(l)>1e-12){const s=(o*a-r*i)/l,p=(i-s*r)/o,y=e=>p+s*e,b=f.map(([e,t])=>t-y(e)).reduce((e,t)=>e+t*t,0),x=Math.sqrt(b/Math.max(o-2,1)),k=f.reduce((e,t)=>e+t[0],0)/o,w=f.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)),O=Math.max(...S),M=f.length>1?(f[o-1][0]-f[0][0])/(o-1):1;for(let e=1;c>=e;e++){const r=O+e*M,i=y(r),s=x*Math.sqrt(1+1/o+(w>0?Math.pow(r-k,2)/w:0))*A;v.push({[t]:r,[n]:i,[On]:"forecast",__forecastUpper:i+s,__forecastLower:i-s})}m.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:h,fillOpacity:d,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!==(s=r.bandOpacity)&&void 0!==s?s:.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:null!==(a=r.anomalyRadius)&&void 0!==a?a:6,label:r.label});const b=[];if(b.push(...p),p.length>0&&y.length>0&&b.push(Object.assign(Object.assign({},p[p.length-1]),{[On]:"observed"})),b.push(...y),v.length>0){const e=y.length>0?y[y.length-1]:p[p.length-1];e&&b.push(Object.assign(Object.assign({},e),{[On]:"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",s=t.color||"#6366f1";return t=>{const n=e(t),o=t[On];return"training"===o?Object.assign(Object.assign({},n),{strokeDasharray:r}):"forecast"===o?Object.assign(Object.assign({},n),{stroke:s,strokeDasharray:i}):n}}});exports.AreaChart=an,exports.BubbleChart=dn,exports.ConnectedScatterplot=hn,exports.Heatmap=gn,exports.LineChart=sn,exports.MinimapChart=An,exports.QuadrantChart=Sn,exports.Scatterplot=cn,exports.ScatterplotMatrix=kn,exports.StackedAreaChart=ln,exports.StreamXYFrame=Ye;
|