semiotic 3.0.1 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +227 -27
- package/README.md +43 -11
- 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/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/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.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-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.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +29 -7
- 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"),i=require("d3-scale-chromatic"),r=require("d3-quadtree"),l=require("d3-array"),s=require("d3-hierarchy"),a=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),f=u(c);class g{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 p{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 y{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function m(e,t,n,o,i){const r=new Map;for(const l of e){const e=t(l),s=n(l);if(null==e||null==s||Number.isNaN(e)||Number.isNaN(s))continue;const a=Math.floor(e/o)*o;let c=r.get(a);if(c||(c={start:a,end:a+o,total:0,categories:new Map},r.set(a,c)),c.total+=s,i){const e=i(l);c.categories.set(e,(c.categories.get(e)||0)+s)}}return r}function v(e,t,n,o,i,r){const l=[];for(const i of e){const e=n(i),r=o(i);null==e||null==r||Number.isNaN(e)||Number.isNaN(r)||l.push({px:t.x(e),py:t.y(r),rawY:r,d:i})}l.sort((e,t)=>e.px-t.px);const s=Array(l.length),a=Array(l.length),c=Array(l.length);for(let e=0;l.length>e;e++){const t=l[e];s[e]=[t.px,t.py],a[e]=t.rawY,c[e]=t.d}return{type:"line",path:s,rawValues:a,style:i,datum:c,group:r}}function b(e,t,n,o,i,r,l,s){const a=[];for(const r of e){const e=n(r),l=o(r);if(null==e||null==l||Number.isNaN(e)||Number.isNaN(l))continue;const c=t.x(e),u=s?s(r):i;a.push({px:c,topY:t.y(l),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:r,datum:e,group:l}}function x(e,t,n,o,i,r,l){const s=n(e),a=o(e);if(null==s||null==a||Number.isNaN(s)||Number.isNaN(a))return null;const c={type:"point",x:t.x(s),y:t.y(a),r:i,style:r,datum:e};return void 0!==l&&(c.pointId=l),c}function k(e,t,n,o,i,r,l){return{type:"rect",x:e,y:t,w:n,h:o,style:i,datum:r,group:l}}function w(e,t,n,o,i,r,l){const s={type:"heatcell",x:e,y:t,w:n,h:o,fill:i,datum:r};return(null==l?void 0:l.showValues)&&(s.showValues=!0,s.value=l.value,l.valueFormat&&(s.valueFormat=l.valueFormat)),s}function A(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function M(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function S(e,t){return"function"==typeof e?e:e?t=>t[e]+"":void 0}const E={category10:i.schemeCategory10,tableau10:i.schemeTableau10,set3:i.schemeSet3,blues:i.interpolateBlues,reds:i.interpolateReds,greens:i.interpolateGreens,oranges:i.interpolateOranges,purples:i.interpolatePurples,viridis:i.interpolateViridis,plasma:i.interpolatePlasma},O=i.schemeCategory10,C=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],j=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")||j.has(t)}(o)?n(o):o}const o=e[t];return n?n(o):O[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+""))%O.length]}function _(e,t,n="category10"){const i=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e))),r=i.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return o.scaleOrdinal().domain(i).range(n).unknown("#999");const l=E[n]||E.category10;if(r&&"function"==typeof l){let e=-1/0;for(const t of i){const n=Number(t);n>e&&(e=n)}return t=>l(Number(t)/e)}{const e=Array.isArray(l)?l:O;return o.scaleOrdinal().domain(i).range(e).unknown("#999")}}function L(e,t,n=[3,20],o){let i;if(i="function"==typeof t?t(e):e[t],!o)return i;const[r,l]=o,[s,a]=n;return l===r?(s+a)/2:s+(i-r)/(l-r)*(a-s)}function B(e,t,n){return e+(t-e)*n}class N{constructor(e){this.xExtent=new y,this.yExtent=new y,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 p(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=S(e.groupAccessor),this.getCategory=S(e.categoryAccessor),this.getSize=e.sizeAccessor?A(e.sizeAccessor,"size"):void 0,this.getColor=S(e.colorAccessor),this.getBounds=e.boundsAccessor?A(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?A(e.y0Accessor,"y0"):void 0,this.getPointId=S(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 p(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,i,r,l,s;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.getBufferArray(),h=this.xExtent.extent,d=this.yExtent.extent;let f=a.xExtent?[null!==(t=a.xExtent[0])&&void 0!==t?t:h[0],null!==(n=a.xExtent[1])&&void 0!==n?n:h[1]]:h,g=a.yExtent?[null!==(i=a.yExtent[0])&&void 0!==i?i:d[0],null!==(r=a.yExtent[1])&&void 0!==r?r:d[1]]:d;const p=a.yExtent&&null!=a.yExtent[0]&&null!=a.yExtent[1];if("stackedarea"===a.chartType&&!p&&c.size>0)if(a.normalize)g=[0,1+a.extentPadding];else{const e=`${c.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===e)g=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);g=[0,o+(o>0?o*a.extentPadding:1)],this._stackExtentCache={key:e,yDomain:g}}}else if("bar"===a.chartType&&a.binSize&&!p&&c.size>0){const[,e]=function(e,t,n,o,i){const r=m(e,t,n,o,i);if(0===r.size)return[0,0];let l=0;for(const e of r.values())e.total>l&&(l=e.total);return[0,l]}(c,this.getX,this.getY,a.binSize,this.getCategory);g=[0,e+e*a.extentPadding]}else if("waterfall"===a.chartType&&!p&&c.size>0){const[e,t]=function(e,t){let n=0,o=0,i=0;for(const r of e){const e=t(r);null==e||Number.isNaN(e)||(i+=e,n>i&&(n=i),i>o&&(o=i))}return[n,o]}(c,this.getY),n=t-e,o=n>0?n*a.extentPadding:1;g=[Math.min(0,e-Math.abs(o)),Math.max(0,t+Math.abs(o))]}else if(!p&&g[0]!==1/0){if(this.getBounds)for(const e of u){const t=this.getY(e),n=this.getBounds(e);null!=t&&!Number.isNaN(t)&&n&&(t+n>g[1]&&(g[1]=t+n),g[0]>t-n&&(g[0]=t-n))}const e=g[1]-g[0],t=e>0?e*a.extentPadding:1,n=null===(l=a.yExtent)||void 0===l?void 0:l[0],o=null===(s=a.yExtent)||void 0===s?void 0:s[1];g=[null!=n?g[0]:g[0]-t,null!=o?g[1]:g[1]+t],"log"===a.yScaleType&&0>=g[0]&&d[0]>0&&(g[0]=null!=n?g[0]:d[0]/(1+a.extentPadding))}if(f[0]!==1/0&&f[1]!==-1/0||(f=[0,1]),g[0]!==1/0&&g[1]!==-1/0||(g=[0,1]),"streaming"===a.runtimeMode)if("x"==("up"===(y=a.arrowOfTime)||"down"===y?"y":"x")){const t="right"===a.arrowOfTime?[0,e.width]:[e.width,0];this.scales={x:o.scaleLinear().domain(f).range(t),y:o.scaleLinear().domain(g).range([e.height,0])}}else{const t="down"===a.arrowOfTime?[0,e.height]:[e.height,0];this.scales={x:o.scaleLinear().domain(g).range([0,e.width]),y:o.scaleLinear().domain(f).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(a.xScaleType,f,[0,e.width]),y:t(a.yScaleType,g,[e.height,0])}}var y;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(e,u),this.config.decay&&this.applyDecay(this.scene,u),this.config.pulse&&this.applyPulse(this.scene,u),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}rebuildQuadtree(){const e=this.config.chartType;if("scatter"!==e&&"bubble"!==e)return void(this._quadtree=null);const t=this.scene.filter(e=>"point"===e.type);this._quadtree=t.length>N.QUADTREE_THRESHOLD?r.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 i=this.scales.x.domain(),r=this.scales.y.domain(),l=this.scales.x.range(),s=this.scales.y.range(),a=(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:a(this.config.xScaleType,i,[l[0]*t,l[1]*t]),y:a(this.config.yScaleType,r,[s[0]*n,s[1]*n])},this.lastLayout={width:e.width,height:e.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(e,t){const{config:n,scales:o}=this;if(!o||0===t.length)return[];switch(n.chartType){case"line":return this.buildLineScene(t);case"area":return this.buildAreaScene(t);case"stackedarea":return this.buildStackedAreaScene(t);case"scatter":case"bubble":return this.buildPointScene(t);case"heatmap":return this.buildHeatmapScene(t,e);case"bar":return this.buildBarScene(t);case"swarm":return this.buildSwarmScene(t);case"waterfall":return this.buildWaterfallScene(t,e);case"candlestick":return this.buildCandlestickScene(t,e);default:return[]}}buildLineScene(e){var t;const n=this.groupData(e),o=[],i=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);i&&i.length>0&&(n.colorThresholds=i),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]),i=b(e.data,this.scales,this.getX,this.getY,o,t,e.key,this.getY0);this.config.gradientFill&&(i.fillGradient=this.config.gradientFill),this.config.curve&&"linear"!==this.config.curve&&(i.curve=this.config.curve),n.push(i)}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,i,r,l){var s;const a=new Set;for(const t of e)for(const e of t.data){const t=n(e);null==t||Number.isNaN(t)||a.add(t)}const c=Array.from(a).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const i of t.data){const t=n(i),r=o(i);null==t||null==r||Number.isNaN(t)||Number.isNaN(r)||e.set(t,(e.get(t)||0)+r)}u.set(t.key,e)}let h;if(r){h=new Map;for(const t of c){let n=0;for(const o of e)n+=(null===(s=u.get(o.key))||void 0===s?void 0:s.get(t))||0;h.set(t,n||1)}}const d=[],f=new Map;for(const e of c)f.set(e,0);for(const n of e){const e=u.get(n.key),o=[],s=[];for(const n of c){let i=e.get(n)||0;const l=f.get(n);r&&(i/=h.get(n));const a=t.x(n);s.push([a,t.y(l)]),o.push([a,t.y(l+i)]),f.set(n,l+i)}const a={type:"area",topPath:o,bottomPath:s,style:i(n.key,n.data[0]),datum:n.data,group:n.key};l&&(a.curve=l),d.push(a)}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 i=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);i=t=>e===n?(o[0]+o[1])/2:o[0]+(t-e)/(n-e)*(o[1]-o[0])}}const r=this.getColor?this.resolveColorMap(e):null;for(const o of e){let e=this.config.pointStyle?this.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},l=e.r||n;if(i&&this.getSize){const e=this.getSize(o);null==e||Number.isNaN(e)||(l=i(e))}if(r&&this.getColor&&!e.fill){const t=this.getColor(o);t&&r.has(t)&&(e=Object.assign(Object.assign({},e),{fill:r.get(t)}))}const s=this.getPointId?this.getPointId(o)+"":void 0,a=x(o,this.scales,this.getX,this.getY,l,e,s);a&&t.push(a)}return t}buildHeatmapScene(e,t){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(e,t);const r=A(this.config.valueAccessor,"value"),l=M(this.config.xAccessor,"x"),s=M(this.config.yAccessor,"y"),a=new Set,c=new Set;for(const t of e)a.add(l(t)),c.add(s(t));const u=Array.from(a),h=Array.from(c),d=u.every(e=>"number"==typeof e&&!isNaN(e)),f=h.every(e=>"number"==typeof e&&!isNaN(e)),g=d?u.sort((e,t)=>e-t):u,p=f?h.sort((e,t)=>e-t):h;if(0===g.length||0===p.length)return n;const y=t.width/g.length,m=t.height/p.length,v=new Map;for(const t of e){const e=`${l(t)}\0${s(t)}`;v.set(e,{val:r(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:i.interpolateBlues,reds:i.interpolateReds,greens:i.interpolateGreens,viridis:i.interpolateViridis}["string"==typeof this.config.colorScheme?this.config.colorScheme:"blues"]||i.interpolateBlues).domain([b,x]);for(let e=0;g.length>e;e++)for(let t=0;p.length>t;t++){const o=v.get(`${g[e]}\0${p[t]}`);if(!o)continue;const i=k(o.val);n.push(w(e*y,(p.length-1-t)*m,y,m,i,o.datum,this.config.showValues?{value:o.val,showValues:!0,valueFormat:this.config.heatmapValueFormat}:void 0))}return n}buildStreamingHeatmapScene(e,t){var n,o,i;const r=[],l=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,s=null!==(o=this.config.heatmapYBins)&&void 0!==o?o:20,a=null!==(i=this.config.heatmapAggregation)&&void 0!==i?i:"count",c=A(this.config.valueAccessor,"value");if(!this.scales||0===e.length)return r;const[u,h]=this.scales.x.domain(),[d,f]=this.scales.y.domain(),g=(h-u||1)/l,p=(f-d||1)/s,y=new Map;for(const t of e){const e=this.getX(t),n=this.getY(t),o=Math.min(Math.floor((e-u)/g),l-1),i=Math.min(Math.floor((n-d)/p),s-1);if(0>o||0>i)continue;const r=`${o}_${i}`;let a=y.get(r);a||(a={sum:0,count:0,data:[]},y.set(r,a)),a.count++,a.sum+=c(t),a.data.push(t)}let m=1/0,v=-1/0;const b=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}b.set(e,n),m>n&&(m=n),n>v&&(v=n)}const x=v-m||1,k=t.width/l,M=t.height/s;for(const[e,t]of b){const[n,o]=e.split("_"),i=+n,l=+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);r.push(w(i*k,(s-1-l)*M,k,M,c,{xi:i,yi:l,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 r}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):[],i=new Set(t),r=Array.from(e).filter(e=>!i.has(e)).sort(),l=t.filter(t=>e.has(t)),s=l.join("\0")+""+r.join("\0");this._barCategoryCache&&this._barCategoryCache.key===s?o=this._barCategoryCache.order:(o=[...l,...r],this._barCategoryCache={key:s,order:o})}const i=[],r=this.scales,[l,s]=r.x.domain();for(const e of n.values()){const n=Math.max(e.start,l),a=Math.min(e.end,s);if(n>=a)continue;const c=r.x(n),u=r.x(a),h=Math.abs(u-c),d=h>2?1:0,f=Math.min(c,u)+d/2,g=Math.max(h-d,1);if(g>0)if(o&&e.categories.size>0){let n=0;for(const l of o){const o=e.categories.get(l)||0;if(0===o)continue;const s=r.y(n),a=r.y(n+o);i.push(k(f,Math.min(s,a),g,Math.abs(s-a),{fill:(null===(t=this.config.barColors)||void 0===t?void 0:t[l])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:l,categoryValue:o},l)),n+=o}}else{const t=r.y(0),n=r.y(e.total);i.push(k(f,Math.min(t,n),g,Math.abs(t-n),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}return i}buildSwarmScene(e){var t,n,o,i;const r=[],l=this.config.swarmStyle||{},s=null!==(t=l.radius)&&void 0!==t?t:3,a=null!==(n=l.fill)&&void 0!==n?n:"#007bff",c=null!==(o=l.opacity)&&void 0!==o?o:.7,u=l.stroke,h=l.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),l=this.scales.y(n);let d=a;if(this.getCategory){const e=this.getCategory(t);d=(null===(i=this.config.barColors)||void 0===i?void 0:i[e])||d}const f={type:"point",x:o,y:l,r:s,style:{fill:d,opacity:c,stroke:u,strokeWidth:h},datum:t};this.getPointId&&(f.pointId=this.getPointId(t)+""),r.push(f)}return r}buildWaterfallScene(e,t){var n,o,i;const r=[],l=this.scales,s=this.config.waterfallStyle,a=e.filter(e=>{const t=this.getY(e);return null!=t&&!Number.isNaN(t)});if(0===a.length)return r;const c=null!==(n=null==s?void 0:s.positiveColor)&&void 0!==n?n:"#28a745",u=null!==(o=null==s?void 0:s.negativeColor)&&void 0!==o?o:"#dc3545",h=null!==(i=null==s?void 0:s.gap)&&void 0!==i?i:1,d=null==s?void 0:s.stroke,f=null==s?void 0:s.strokeWidth;let g=0;for(let e=0;a.length>e;e++){const n=a[e],o=this.getX(n),i=this.getY(n),p=g+i;let y;y=a.length-1>e?this.getX(a[e+1])-o:e>0?o-this.getX(a[e-1]):0;const m=l.x(o),v=0!==y?l.x(o+y):m+t.width/10,b=Math.min(m,v)+h/2,x=Math.max(m,v)-h/2-b;if(0>=x){g=p;continue}const w=l.y(g),A=l.y(p);r.push(k(b,Math.min(w,A),x,Math.abs(w-A),{fill:0>i?u:c,stroke:d,strokeWidth:f},Object.assign(Object.assign({},n),{baseline:g,cumEnd:p,delta:i,_connectorStroke:null==s?void 0:s.connectorStroke,_connectorWidth:null==s?void 0:s.connectorWidth}))),g=p}return r}buildCandlestickScene(e,t){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],o=this.config.candlestickStyle||{},i=o.upColor||"#28a745",r=o.downColor||"#dc3545",l=o.wickColor||"#333",s=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:i,downColor:r,wickColor:l,wickWidth:s,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),i=this.getY(t);if(null==e||null==i||Number.isNaN(e)||Number.isNaN(i))continue;const r=this.getBounds(t),l=this.scales.x(e);if(r&&0!==r)n.push([l,this.scales.y(i+r)]),o.push([l,this.scales.y(i-r)]);else{const e=this.scales.y(i);n.push([l,e]),o.push([l,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,i;const r=this.config.decay;if(!r||1>=t)return 1;const l=null!==(n=r.minOpacity)&&void 0!==n?n:.1,s=t-1-e;switch(r.type){case"linear":return l+(1-s/(t-1))*(1-l);case"exponential":{const e=null!==(o=r.halfLife)&&void 0!==o?o:t/2;return l+Math.pow(.5,s/e)*(1-l)}case"step":return(null!==(i=r.stepThreshold)&&void 0!==i?i:.5*t)>s?1:l;default:return 1}}applyDecay(e,t){var n,o;if(!this.config.decay)return;const i=t.length;if(1>=i)return;const r=new Map;for(let e=0;t.length>e;e++)r.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 l=r.get(e[t]);null!=l?(n[t]=this.computeDecayOpacity(l,i),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 l=!1;for(let t=0;e.length>t;t++){const n=r.get(e[t]);null!=n?(o[t]=this.computeDecayOpacity(n,i),1>o[t]&&(l=!0)):o[t]=1}l&&(t._decayOpacities=o)}else{let o=1;for(const t of e){const e=r.get(t);if(null!=e){const t=this.computeDecayOpacity(e,i);o>t&&(o=t)}}if(1>o){const e=Array(n);e.fill(o),t._decayOpacities=e}}continue}const e=r.get(t.datum);if(null==e)continue;const l=this.computeDecayOpacity(e,i);if("heatcell"===t.type)t.style={opacity:l};else if("candlestick"===t.type)t._decayOpacity=l;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*l})}}}computePulseIntensity(e,t){var n;const o=this.config.pulse;if(!o)return 0;const i=null!==(n=o.duration)&&void 0!==n?n:500,r=t-e;return i>r?1-r/i:0}applyPulse(e,t){var n,o;if(!this.config.pulse||!this.timestampBuffer)return;const i="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",l=null!==(o=this.config.pulse.glowRadius)&&void 0!==o?o:4,s=new Map;for(let e=0;t.length>e;e++)s.set(t[e],e);for(const t of e){if("line"===t.type)continue;if("area"===t.type){const e=Array.isArray(t.datum)?t.datum:[t.datum];let n=0;for(const t of e){const e=s.get(t);if(null==e)continue;const o=this.timestampBuffer.get(e);if(null==o)continue;const r=this.computePulseIntensity(o,i);r>n&&(n=r)}n>0&&(t._pulseIntensity=n,t._pulseColor=r);continue}const e=s.get(t.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const o=this.computePulseIntensity(n,i);o>0&&(t._pulseIntensity=o,t._pulseColor=r,t._pulseGlowRadius=l)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}snapshotPositions(){var e,t,n;this.prevPositionMap.clear(),this.prevPathMap.clear();for(let o=0;this.scene.length>o;o++){const i=this.scene[o],r=this.getNodeIdentity(i,o);r&&("point"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity}):"rect"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity}):"heatcell"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:null===(e=i.style)||void 0===e?void 0:e.opacity}):"candlestick"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.openY}):"line"===i.type?this.prevPathMap.set(r,{path:i.path.map(e=>[e[0],e[1]]),opacity:null===(t=i.style)||void 0===t?void 0:t.opacity}):"area"===i.type&&this.prevPathMap.set(r,{topPath:i.topPath.map(e=>[e[0],e[1]]),bottomPath:i.bottomPath.map(e=>[e[0],e[1]]),opacity:null===(n=i.style)||void 0===n?void 0:n.opacity}))}}getNodeIdentity(e,t){var n,o,i,r;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!==(r=null!==(o=null===(n=e.datum)||void 0===n?void 0:n.binStart)&&void 0!==o?o:null===(i=e.datum)||void 0===i?void 0:i.category)&&void 0!==r?r: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,i,r,l,s,a,c,u,h,d,f,g,p,y,m,v,b,x,k,w,A,M,S;if(!this.config.transition||0===this.prevPositionMap.size&&0===this.prevPathMap.size)return;const E=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 O=!1;const C=new Set,j=new Set;for(let e=0;this.scene.length>e;e++){const y=this.scene[e],m=this.getNodeIdentity(y,e);if(!m)continue;if(y._transitionKey=m,"line"===y.type||"area"===y.type){const e=this.prevPathMap.get(m);if(e){if(j.add(m),"line"===y.type&&e.path&&e.path.length===y.path.length){y._targetPath=y.path.map(e=>[e[0],e[1]]),y._prevPath=e.path;for(let t=0;y.path.length>t;t++)y.path[t]=[e.path[t][0],e.path[t][1]];O=!0}else if("area"===y.type&&e.topPath&&e.bottomPath&&e.topPath.length===y.topPath.length&&e.bottomPath.length===y.bottomPath.length){y._targetTopPath=y.topPath.map(e=>[e[0],e[1]]),y._targetBottomPath=y.bottomPath.map(e=>[e[0],e[1]]),y._prevTopPath=e.topPath,y._prevBottomPath=e.bottomPath;for(let t=0;y.topPath.length>t;t++)y.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;y.bottomPath.length>t;t++)y.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];O=!0}y._targetOpacity=null!==(t=y.style.opacity)&&void 0!==t?t:1}else y._targetOpacity=null!==(n=y.style.opacity)&&void 0!==n?n:1,y.style=Object.assign(Object.assign({},y.style),{opacity:0}),O=!0;continue}const v=this.prevPositionMap.get(m);if("point"===y.type)if(v){C.add(m);const e={x:y.x,y:y.y,r:y.r};y._targetOpacity=null!==(o=y.style.opacity)&&void 0!==o?o:1,v.x===e.x&&v.y===e.y||(y._targetX=e.x,y._targetY=e.y,y._targetR=e.r,y.x=v.x,y.y=v.y,y.r=null!==(i=v.r)&&void 0!==i?i:y.r,O=!0)}else y._targetOpacity=null!==(r=y.style.opacity)&&void 0!==r?r:1,y.style=Object.assign(Object.assign({},y.style),{opacity:0}),O=!0;else if("rect"===y.type)if(v){C.add(m);const e={x:y.x,y:y.y,w:y.w,h:y.h};y._targetOpacity=null!==(l=y.style.opacity)&&void 0!==l?l:1,v.x===e.x&&v.y===e.y&&v.w===e.w&&v.h===e.h||(y._targetX=e.x,y._targetY=e.y,y._targetW=e.w,y._targetH=e.h,y.x=v.x,y.y=v.y,y.w=null!==(s=v.w)&&void 0!==s?s:y.w,y.h=null!==(a=v.h)&&void 0!==a?a:y.h,O=!0)}else y._targetOpacity=null!==(c=y.style.opacity)&&void 0!==c?c:1,y.style=Object.assign(Object.assign({},y.style),{opacity:0}),O=!0;else if("heatcell"===y.type)if(v){C.add(m);const e={x:y.x,y:y.y,w:y.w,h:y.h};y._targetOpacity=null!==(h=null===(u=y.style)||void 0===u?void 0:u.opacity)&&void 0!==h?h:1,v.x===e.x&&v.y===e.y||(y._targetX=e.x,y._targetY=e.y,y._targetW=e.w,y._targetH=e.h,y.x=v.x,y.y=v.y,y.w=null!==(d=v.w)&&void 0!==d?d:y.w,y.h=null!==(f=v.h)&&void 0!==f?f:y.h,O=!0)}else y._targetOpacity=null!==(p=null===(g=y.style)||void 0===g?void 0:g.opacity)&&void 0!==p?p:1,y.style=Object.assign(Object.assign({},y.style||{}),{opacity:0}),O=!0}for(const[e,t]of this.prevPathMap)if(!j.has(e))if(e.startsWith("l:")&&t.path){const n={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(y=t.opacity)&&void 0!==y?y:1},_targetOpacity:0,_transitionKey:e,datum:null};this.exitNodes.push(n),O=!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),O=!0}for(const[e,t]of this.prevPositionMap)if(!C.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!==(M=t.h)&&void 0!==M?M:0,fill:"#999",datum:null,style:{opacity:null!==(S=t.opacity)&&void 0!==S?S:1},_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}O=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),O&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:E})}advanceTransition(e){var t,n,o,i,r,l;if(!this.activeTransition)return!1;const s=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,this.activeTransition),a=function(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}(s,"linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?"linear":"ease-out-cubic");for(const e of this.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const o=t?this.prevPositionMap.get(t):void 0,i=o?null!==(n=o.opacity)&&void 0!==n?n:1:0;e.style.opacity=B(i,e._targetOpacity,a)}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,a),e.y=B(o.y,e._targetY,a),void 0!==e._targetR&&void 0!==o.r&&(e.r=B(o.r,e._targetR,a))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?this.prevPositionMap.get(t):void 0,i=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;e.style.opacity=B(i,e._targetOpacity,a)}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,a),e.y=B(n.y,e._targetY,a),void 0!==n.w&&(e.w=B(n.w,e._targetW,a)),void 0!==n.h&&(e.h=B(n.h,e._targetH,a))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?this.prevPositionMap.get(t):void 0,o=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:B(o,e._targetOpacity,a)})}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,a),e.y=B(n.y,e._targetY,a),void 0!==n.w&&(e.w=B(n.w,e._targetW,a)),void 0!==n.h&&(e.h=B(n.h,e._targetH,a))}else if("line"===e.type){if(void 0!==e._targetOpacity){const t=void 0===e._prevPath&&e._targetOpacity>0?0:null!==(r=e.style.opacity)&&void 0!==r?r:1;e.style=Object.assign(Object.assign({},e.style),{opacity:B(t,e._targetOpacity,a)})}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],a),e.path[o][1]=B(t[o][1],n[o][1],a)}else if("area"===e.type){if(void 0!==e._targetOpacity){const t=void 0===e._prevTopPath&&e._targetOpacity>0?0:null!==(l=e.style.opacity)&&void 0!==l?l:1;e.style=Object.assign(Object.assign({},e.style),{opacity:B(t,e._targetOpacity,a)})}const t=e._prevTopPath,n=e._prevBottomPath,o=e._targetTopPath,i=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],a),e.topPath[n][1]=B(t[n][1],o[n][1],a);if(n&&i&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=B(n[t][0],i[t][0],a),e.bottomPath[t][1]=B(n[t][1],i[t][1],a)}}if(s>=1){for(const e of this.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style=Object.assign(Object.assign({},"line"===e.type||"area"===e.type?e.style:e.style||{}),{opacity:0===t?0:t}),e._targetOpacity=void 0}if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("line"===e.type){const t=e._targetPath;if(t)for(let n=0;e.path.length>n;n++)e.path[n]=t[n];e._prevPath=void 0,e._targetPath=void 0}else if("area"===e.type){const t=e._targetTopPath,n=e._targetBottomPath;if(t)for(let n=0;e.topPath.length>n;n++)e.topPath[n]=t[n];if(n)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=n[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0}}if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const n of e){const e=this.getGroup(n);t.has(e)||t.set(e,[]),t.get(e).push(n)}return Array.from(t.entries()).map(([e,t])=>({key:e,data:t}))}resolveColorMap(e){const t=new Set;for(const n of e){const e=this.getColor(n);e&&t.add(e)}const n=Array.from(t).sort(),o=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===o)return this._colorMapCache.map;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:C,r=new Map;for(let e=0;n.length>e;e++)r.set(n[e],i[e%i.length]);return this._colorMapCache={key:o,map:r},r}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:C,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=S(this.config.groupAccessor)),void 0!==e.categoryAccessor&&(this.getCategory=S(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=S(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=S(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 W(e,t,n){const o=t-e.x,i=n-e.y,r=Math.sqrt(o*o+i*i);return r>e.r+5?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:r}}function z(e,t,n){var o,i,r,l;if(0===e.path.length)return null;const s=R(e.path,t);if(0>s)return null;const[a,c]=e.path[s];let u;if(e.path.length>1){let o=1/0;const i=Math.max(0,s-1),r=Math.min(e.path.length-2,s);for(let l=i;r>=l;l++){const[i,r]=e.path[l],[s,a]=e.path[l+1],c=T(t,n,i,r,s,a);o>c&&(o=c)}u=o}else{const e=t-a,o=n-c;u=Math.sqrt(e*e+o*o)}const h=null!==(l=null!==(i=null===(o=e.style)||void 0===o?void 0:o.strokeWidth)&&void 0!==i?i:null===(r=e.style)||void 0===r?void 0:r.lineWidth)&&void 0!==l?l:1;return u>Math.max(5,h/2+2)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:a,y:c,distance:u}}function T(e,t,n,o,i,r){const l=i-n,s=r-o,a=l*l+s*s;if(0===a)return Math.sqrt(Math.pow(e-n,2)+Math.pow(t-o,2));let c=((e-n)*l+(t-o)*s)/a;c=Math.max(0,Math.min(1,c));const u=o+c*s;return Math.sqrt(Math.pow(e-(n+c*l),2)+Math.pow(t-u,2))}function F(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 $(e,t,n){const o=e.bodyWidth/2,i=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=i+Math.max(Math.max(e.openY,e.closeY)-i,1)/2,r=t-e.x,l=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(r*r+l*l)}}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[i,r]=e.topPath[o],l=t-i,s=n-r,a=Math.sqrt(l*l+s*s);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:i,y:r,distance:a}}function R(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const i=n+o>>1;t>e[i][0]?n=i+1:o=i}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 Y(e,t,n,o){let i;return i="function"==typeof n?n(e):(0,G[n])(o(e,t)),i}function q(){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:i,label:r,format:l}=e,s=l||(e=>Math.round(100*e)/100+""),a="grad-legend-"+d.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),l=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(i[0]+t*(i[1]-i[0]))}))}return d.createElement("g",{"aria-label":r||"Gradient legend"},d.createElement("defs",null,d.createElement("linearGradient",{id:a,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},c)),r&&d.createElement("text",{x:l+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},r),d.createElement("rect",{x:l,y:0,width:t,height:e,fill:`url(#${a})`,rx:2}),d.createElement("text",{x:l,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(i[0])),d.createElement("text",{x:l+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(i[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(i[1]-t*(i[1]-i[0]))}))}return d.createElement("g",{"aria-label":r||"Gradient legend"},r&&d.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},r),d.createElement("defs",null,d.createElement("linearGradient",{id:a,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},c)),d.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${a})`,rx:2}),d.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(i[1])),d.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(i[0])))}function Q(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:r,legendInteraction:l,title:s="Legend",width:a=100,height:c=20,orientation:u="vertical"}=e,[h,f]=d.useState(0),[g,p]=d.useState(0),y=d.useCallback((e,t)=>{f(e),p(t)},[]),m="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:r,focusedGroupIndex:l,focusedItemIndex:s,onFocusedIndexChange:a,legendInteraction:c})=>{let u=24;const h=[];return e.forEach((e,f)=>{u+=5,h.push(d.createElement("line",{key:"legend-top-line legend-symbol-"+f,stroke:"gray",x1:0,y1:u,x2:t,y2:u})),u+=8,e.label&&(u+=16,h.push(d.createElement("text",{key:"legend-text-"+f,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-"+f,className:"legend-item",transform:`translate(0,${u})`},((e,t,n,o,i,r,l,s,a,c)=>{const{type:u="fill",styleFn:h,items:f}=e,g=[];let p=0;const y=!(!t&&!n),m="isolate"===c||void 0===c&&null!=i;return f.forEach((e,c)=>{const v=Y(e,c,u,h),b=X(e,o,i),x=i&&i.size>0&&i.has(e.label);g.push(d.createElement("g",{key:"legend-item-"+c,transform:`translate(0,${p})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:y?s===r&&c===l?0:-1:void 0,role:y?"option":void 0,"aria-selected":y&&m?x||!1:void 0,"aria-current":y&&!m&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:y?n=>{var o;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(c+("ArrowDown"===n.key?1:-1)+f.length)%f.length;a(s,e);const t=null===(o=n.currentTarget.parentElement)||void 0===o?void 0:o.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:y?t=>{a(s,c),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:y?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:y?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},y&&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(q,null),d.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),p+=22}),g})(e,n,o,i,r,l,s,f,a,c))),u+=22*e.items.length+8}),h})({legendGroups:t||[],width:a,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:r,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:y,legendInteraction:l}):(({legendGroups:e,height:t,width:n,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:l,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:c,legendInteraction:u})=>{let h=0;const f=[];e.forEach((e,t)=>{let n=0;e.label&&(n+=16);const g=((e,t,n,o,i,r,l,s,a,c)=>{const{type:u="fill",styleFn:h,items:f}=e,g=[];let p=0;const y=!(!t&&!n),m="isolate"===c||void 0===c&&null!=i;return f.forEach((e,c)=>{const v=Y(e,c,u,h),b=X(e,o,i),x=i&&i.size>0&&i.has(e.label);g.push(d.createElement("g",{key:"legend-item-"+c,transform:`translate(${p},0)`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:y?s===r&&c===l?0:-1:void 0,role:y?"option":void 0,"aria-selected":y&&m?x||!1:void 0,"aria-current":y&&!m&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:y?n=>{var o;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(c+("ArrowRight"===n.key?1:-1)+f.length)%f.length;a(s,e);const t=null===(o=n.currentTarget.parentElement)||void 0===o?void 0:o.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:y?t=>{a(s,c),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:y?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:y?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},y&&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(q,null),d.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),p+=26+7*e.label.length}),{items:g,offset:p}})(e,o,i,r,l,s,a,t,c,u);n+=g.offset+5,f.push(Object.assign(Object.assign({label:e.label},g),{offset:n})),h+=n+12});let g=Math.max(0,(n-h)/2);const p=[];return f.forEach((n,o)=>{const i=e[o];i.label&&(p.push(d.createElement("text",{key:"legend-text-"+o,transform:`translate(${g},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},i.label)),g+=16),p.push(d.createElement("g",{key:"legend-group-"+o,className:"legend-item",transform:`translate(${g},0)`},n.items)),g+=n.offset+5,e[o+1]&&p.push(d.createElement("line",{key:"legend-top-line legend-symbol-"+o,stroke:"gray",x1:g,y1:-8,x2:g,y2:t+0+8})),g+=12}),d.createElement("g",null,p)})({legendGroups:t||[],title:s,height:c,width:a,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:r,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:y,legendInteraction:l}),v=!(!n&&!o);return d.createElement("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==l&&(void 0!==l||null==r))||void 0,"aria-label":"Chart legend"},void 0!==s&&""!==s&&"vertical"===u&&d.createElement("text",{className:"legend-title",y:16,x:a/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},s),m)}function U(e){return"string"==typeof e?{type:e}:e}function K({orient:t,config:n,values:o,scale:i,size:r,length:s}){const a=function(e){var t,n,o,i,r;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!==(i=e.stroke)&&void 0!==i?i:"none",strokeWidth:null!==(r=e.strokeWidth)&&void 0!==r?r:1}}(n),c="top"===t||"bottom"===t,u=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)],i=t[Math.floor(.5*n)],r=t[Math.floor(.75*n)],l=r-o;return{q1:o,median:i,q3:r,whiskerLow:Math.max(t[0],o-1.5*l),whiskerHigh:Math.min(t[n-1],r+1.5*l)}}(o);if(!e)return null;const{q1:r,median:l,q3:s,whiskerLow:u,whiskerHigh:h}=e,f=Math.min(.5*n,20),g=(n-f)/2+4;if(c){const e=i(r),n=i(s),o=i(l),c=i(u),p=i(h),y="top"===t?-1:1,m=0;return d.createElement("g",{"data-testid":"marginal-boxplot-"+t},d.createElement("line",{x1:c,y1:m+y*(g+f/2),x2:p,y2:m+y*(g+f/2),stroke:a.fill,strokeWidth:a.strokeWidth}),d.createElement("line",{x1:c,y1:m+y*g,x2:c,y2:m+y*(g+f),stroke:a.fill,strokeWidth:a.strokeWidth}),d.createElement("line",{x1:p,y1:m+y*g,x2:p,y2:m+y*(g+f),stroke:a.fill,strokeWidth:a.strokeWidth}),d.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}),d.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(r),n=i(s),o=i(l),c=i(u),p=i(h),y="left"===t?-1:1,m=0;return d.createElement("g",{"data-testid":"marginal-boxplot-"+t},d.createElement("line",{x1:m+y*(g+f/2),y1:c,x2:m+y*(g+f/2),y2:p,stroke:a.fill,strokeWidth:a.strokeWidth}),d.createElement("line",{x1:m+y*g,y1:c,x2:m+y*(g+f),y2:c,stroke:a.fill,strokeWidth:a.strokeWidth}),d.createElement("line",{x1:m+y*g,y1:p,x2:m+y*(g+f),y2:p,stroke:a.fill,strokeWidth:a.strokeWidth}),d.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}),d.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 u=l.bin().domain(e).thresholds(a.bins)(o);if(0===u.length)return null;const h=Math.max(...u.map(e=>e.length));if(0===h)return null;if("histogram"===a.type)return d.createElement("g",{"data-testid":"marginal-histogram-"+t},u.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const r=e.length/h*n;if(c){const n=i(e.x0),l=i(e.x1)-i(e.x0);return d.createElement("rect",{key:o,x:n,y:"top"===t?-4-r:4,width:Math.max(l,.5),height:r,fill:a.fill,fillOpacity:a.fillOpacity,stroke:a.stroke,strokeWidth:a.strokeWidth})}{const n=i(e.x0),l=i(e.x1)-i(e.x0);return d.createElement("rect",{key:o,x:"left"===t?-4-r:4,y:Math.min(n,n+l),width:r,height:Math.abs(l),fill:a.fill,fillOpacity:a.fillOpacity,stroke:a.stroke,strokeWidth:a.strokeWidth})}}));if("violin"===a.type){const e=n/2+4,o=[];for(const r of u){if(null==r.x0||null==r.x1)continue;const l=r.length/h*(n/2),s=i((r.x0+r.x1)/2);o.push(c?`${s},${"top"===t?-(e-l):e-l}`:`${"left"===t?-(e-l):e-l},${s}`)}for(let r=u.length-1;r>=0;r--){const l=u[r];if(null==l.x0||null==l.x1)continue;const s=l.length/h*(n/2),a=i((l.x0+l.x1)/2);o.push(c?`${a},${"top"===t?-(e+s):e+s}`:`${"left"===t?-(e+s):e+s},${a}`)}return d.createElement("g",{"data-testid":"marginal-violin-"+t},d.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,r=null!=u[0].x0?i(u[0].x0):0;e.push(`M${r},${o}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const r=o.length/h*n,l=i((o.x0+o.x1)/2);e.push(`L${l},${"top"===t?-r-4:r+4}`)}const l=null!=u[u.length-1].x1?i(u[u.length-1].x1):s;e.push(`L${l},${o}`),e.push("Z")}else{const o=0,r=null!=u[0].x0?i(u[0].x0):0;e.push(`M${o},${r}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const r=o.length/h*n,l=i((o.x0+o.x1)/2);e.push(`L${"left"===t?-r-4:r+4},${l}`)}const l=null!=u[u.length-1].x1?i(u[u.length-1].x1):s;e.push(`L${o},${l}`),e.push("Z")}return d.createElement("g",{"data-testid":"marginal-ridgeline-"+t},d.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,s,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)),i=e.split(/\s+/),r=[];let l="";for(const e of i)l&&l.length+1+e.length>o?(r.push(l),l=e):l=l?`${l} ${e}`:e;return l&&r.push(l),r}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:i,nx:r,ny:l,note:s,connector:a,subject:c,type:u,color:h,className:f,disable:g,events:p={},"data-testid":y}=e,m=new Set(Array.isArray(g)?g:[]);let v=o||0,b=i||0;null!=r&&(v=r-t),null!=l&&(b=l-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 "+(f||"")).trim(),transform:`translate(${t},${n})`,"data-testid":y},p),!m.has("connector")&&function(e,t,n,o,i,r){const l=[];let s=0,a=0;if("callout-circle"!==i&&"label"!==i||!(null==r?void 0:r.radius)){if("callout-rect"===i&&r){const n=r.width||0,o=r.height||0;if(n>0||o>0){const i=n/2,r=o/2,l=e-i,c=t-r;if(0!==l||0!==c){const e=Math.abs(l),t=Math.abs(c),u=n/2,h=o/2,d=e*h>t*u?u/e:h/t;s=i+l*d,a=r+c*d}}}else if("bracket"===i&&r){const e=r.width,t=r.height,n=r.depth||30;void 0!==e?(s=e/2,a=n):void 0!==t&&(s=n,a=t/2)}}else{const n=(r.radius||0)+(r.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const o=Math.atan2(t,e);s=Math.cos(o)*n,a=Math.sin(o)*n}}if(Math.sqrt(Math.pow(e-s,2)+Math.pow(t-a,2))>.5&&(l.push(d.createElement("line",{key:"connector-line",x1:s,y1:a,x2:e,y2:t,stroke:o||"currentColor"})),"arrow"===(null==n?void 0:n.end))){const n=10,i=16/180*Math.PI,r=Math.atan2(t-a,e-s);l.push(d.createElement("path",{key:"connector-arrow",d:`M${s},${a}L${s+n*Math.cos(r+i)},${a+n*Math.sin(r+i)}L${s+n*Math.cos(r-i)},${a+n*Math.sin(r-i)}Z`,fill:o||"currentColor",stroke:"none"}))}return d.createElement("g",{className:"annotation-connector"},l)}(v,b,a,h,x,c),!m.has("subject")&&function(e,t,n,o,i){var r;const l=[];switch(e){case"callout-circle":{const e=((null==t?void 0:t.radius)||0)+((null==t?void 0:t.radiusPadding)||0);e>0&&l.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)&&l.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)&&l.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=o||0,r=i||0;if(void 0!==(null==t?void 0:t.x)){const o=(t.x||0)-e;l.push(d.createElement("line",{key:"threshold-line",x1:o,y1:(t.y1||0)-r,x2:o,y2:(t.y2||0)-r,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==t?void 0:t.y)){const o=(t.y||0)-r;l.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)?l.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)||l.push(d.createElement("line",{key:"threshold-line",x1:0,y1:(t.y1||0)-r,x2:0,y2:(t.y2||0)-r,stroke:n||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(r=null==t?void 0:t.width)&&void 0!==r?r:null==t?void 0:t.height;void 0!==e&&l.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"},l)}(x,c,h,t,n),!m.has("note")&&function(e,t,n,o){if(!e)return d.createElement("g",{className:"annotation-note"});const{label:i,title:r,orientation:l,align:s,wrap:a=120,noWrap:c}=e;if(!i&&!r)return d.createElement("g",{className:"annotation-note"});let u=l;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let h=s;h&&"dynamic"!==h||(h="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let f="start";"topBottom"===u?"right"===h?f="end":"middle"===h&&(f="middle"):f=0>t?"end":"start";const g=16,p=r?c?[r]:Z(r,a):[],y=i?c?[i]:Z(i,a):[],m="leftRight"===u?"end"===f?-4:4:0;let v=0;const b=[];p.length>0&&(b.push(d.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:o||void 0,textAnchor:f,fontWeight:"bold"},p.map((e,t)=>d.createElement("tspan",{key:t,x:m,dy:0===t?0:g},e)))),v=p.length*g),y.length>0&&b.push(d.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:o||void 0,textAnchor:f,y:v},y.map((e,t)=>d.createElement("tspan",{key:t,x:m,dy:0===t?0:g},e))));let x=null;if((r||i)&&(0!==t||0!==n))if("topBottom"===u){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=d.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"===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,p.length+y.length-1)*g;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===h?-(k+g+(y.length>0&&p.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)}(s,v,b,h))}function te(e){var t,n;const{noteData:o}=e,{screenCoordinates:i}=o,r="string"==typeof o.type?o.type:"label",l=o.eventListeners||o.events||{};if(o.coordinates&&i){const e=o.nx||i[0][0]+(null!==(t=o.dx)&&void 0!==t?t:0),l=o.ny||i[0][1]+(null!==(n=o.dy)&&void 0!==n?n:0),s=i.map((t,n)=>{const i=Object.assign({},o,{note:0===n?o.note:{label:""},x:t[0],y:t[1],nx:e,ny:l});return d.createElement(ee,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},i,{type:r}))});return d.createElement("g",null,s)}const s=o.note||{title:"none",label:o.label};return d.createElement(ee,Object.assign({"data-testid":"semiotic-annotation",key:`${s.label}-${s.title}-${o.i}`,events:l},o,{type:r}))}const ne={linear:a.curveLinear,monotoneX:a.curveMonotoneX,monotoneY:a.curveMonotoneY,step:a.curveStep,stepAfter:a.curveStepAfter,stepBefore:a.curveStepBefore,basis:a.curveBasis,cardinal:a.curveCardinal,catmullRom:a.curveCatmullRom};function oe(e,t){var n,o,i;const r=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(i=t.scales)||void 0===i?void 0:i.time;return r?null!=e.x?r(e.x):t.xAccessor&&null!=e[t.xAccessor]?r(e[t.xAccessor]):null:null}function ie(e,t){var n,o,i;const r=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(i=t.scales)||void 0===i?void 0:i.value;return r?null!=e.y?r(e.y):t.yAccessor&&null!=e[t.yAccessor]?r(e[t.yAccessor]):null:null}function re(e,t,n){var o,i,r,l;const s=e.anchor||"fixed";if("latest"===s){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let i=n.pointNodes.length-1;i>=0;i--){const r=n.pointNodes[i];if(r.pointId===e.pointId){const e={x:r.x,y:r.y};return null===(o=n.stickyPositionCache)||void 0===o||o.set(t,e),e}}const r=function(e){var t,n,o,i,r,l;const s=e.data;if(!s||0===s.length)return null;const a=s[s.length-1],c=null!==(n=null===(t=e.scales)||void 0===t?void 0:t.x)&&void 0!==n?n:null===(o=e.scales)||void 0===o?void 0:o.time,u=null!==(r=null===(i=e.scales)||void 0===i?void 0:i.y)&&void 0!==r?r:null===(l=e.scales)||void 0===l?void 0:l.value;if(!c||!u)return null;const h=a[e.xAccessor||"x"],d=a[e.yAccessor||"y"];return null==h||null==d?null:{x:c(h),y:u(d)}}(n);return r&&(null===(i=n.stickyPositionCache)||void 0===i||i.set(t,r)),r}let a=null,c=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(a=t.x,c=t.y)}if(null!=a&&null!=c||(a=oe(e,n),c=ie(e,n)),null!=a&&null!=c)return null===(r=n.stickyPositionCache)||void 0===r||r.set(t,{x:a,y:c}),{x:a,y:c};if("sticky"===s){const e=null===(l=n.stickyPositionCache)||void 0===l?void 0:l.get(t);if(e)return e}return null}function le(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function se(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,i="left"===e?-1:1,r=Math.ceil(t/8);let l="M0,"+o;for(let e=0;r>e;e++){const n=8*(e+1);l+=`L${Math.min(8*e+4,t)},${o+4*i}`,l+=`L${Math.min(n,t)},${o}`}return l}{const o="bottom"===e?0:t,i="bottom"===e?1:-1,r=Math.ceil(n/8);let l=`M${o},0`;for(let e=0;r>e;e++){const t=8*(e+1);l+=`L${o+4*i},${Math.min(8*e+4,n)}`,l+=`L${o},${Math.min(t,n)}`}return l}}function ae(t){const{width:n,height:o,totalWidth:i,totalHeight:r,margin:l,scales:s,showAxes:a,axes:c,showGrid:u,xFormat:h,yFormat:f}=t,g=e.useMemo(()=>{var e;if(!s)return[];const t=null==c?void 0:c.find(e=>"bottom"===e.orient),o=(null==t?void 0:t.tickFormat)||h||ce,i=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return s.x.ticks(Math.min(i,Math.max(2,Math.floor(n/70)))).map(e=>({value:e,pixel:s.x(e),label:o(e)}))},[s,c,h,n]),p=e.useMemo(()=>{var e;if(!s)return[];const t=null==c?void 0:c.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||f||ce,i=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return s.y.ticks(Math.min(i,Math.max(2,Math.floor(o/30)))).map(e=>({value:e,pixel:s.y(e),label:n(e)}))},[s,c,f,o]),y=u&&s,m=a&&s;if(!y&&!m)return null;const v=null==c?void 0:c.find(e=>"bottom"===e.orient),b=null==c?void 0:c.find(e=>"left"===e.orient),x=m&&(!v||!1!==v.baseline),k=m&&(!b||!1!==b.baseline),w=(null==v?void 0:v.jaggedBase)||!1,A=(null==b?void 0:b.jaggedBase)||!1,M="var(--semiotic-border, #ccc)";return d.createElement("svg",{width:i,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},d.createElement("g",{transform:`translate(${l.left},${l.top})`},y&&d.createElement("g",{className:"stream-grid"},g.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})),p.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:M,strokeWidth:1}),w&&d.createElement("path",{d:se("bottom",n,o),fill:"none",stroke:M,strokeWidth:1}),k&&!A&&d.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:M,strokeWidth:1}),A&&d.createElement("path",{d:se("left",n,o),fill:"none",stroke:M,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:i,height:r,totalWidth:l,totalHeight:c,margin:u,scales:h,showAxes:g,axes:p,xLabel:y,yLabel:m,xFormat:v,yFormat:b,showGrid:x,title:k,legend:w,legendHoverBehavior:A,legendClickBehavior:M,legendHighlightedCategory:S,legendIsolatedCategories:E,legendPosition:O="right",foregroundGraphics:C,marginalGraphics:j,xValues:P,yValues:_,annotations:L,svgAnnotationRules:B,xAccessor:N,yAccessor:H,annotationData:W,pointNodes:z,curve:T,underlayRendered:F,children:I}=t,$=e.useMemo(()=>{var e;if(!g||!h)return[];const t=null==p?void 0:p.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(i/70)))).map(e=>({value:e,pixel:h.x(e),label:n(e)}))},[g,h,p,v,i]),D=e.useMemo(()=>{var e;if(!g||!h)return[];const t=null==p?void 0:p.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(r/30)))).map(e=>({value:e,pixel:h.y(e),label:n(e)}))},[g,h,p,b,r]),R=e.useRef(new Map),G=e.useRef(null!==(n=null==L?void 0:L.length)&&void 0!==n?n:0),Y=null!==(o=null==L?void 0:L.length)&&void 0!==o?o:0;G.current!==Y&&(G.current=Y,R.current=new Map);const q=e.useMemo(()=>{if(!L||0===L.length)return null;const e=function(e,t,n){var o,i,r,l,c,u,h,g,p,y,m,v,b,x,k,w,A,M,S,E,O,C,j,P,_,L,B,N,H,W,z,T,F,I,$,D,R,G,Y,q,X,V,Q,U;switch(e.type){case"label":{const o=re(e,t,n);if(!o)return null;const{x:i,y:r}=o;return le(i,r,n)?d.createElement(te,{key:"ann-"+t,noteData:{x:i,y:r,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"label",connector:e.connector||{end:"arrow"},color:e.color}}):null}case"callout":{const o=re(e,t,n);if(!o)return null;const{x:i,y:r}=o;return le(i,r,n)?d.createElement(te,{key:"ann-"+t,noteData:{x:i,y:r,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"callout-circle",subject:{radius:e.radius||12},connector:e.connector||{end:"arrow"},color:e.color}}):null}case"x-threshold":{const o=oe(e,n);if(null==o)return null;const i=e.color||"#f97316";return d.createElement("g",{key:"ann-"+t},d.createElement("line",{x1:o,y1:0,x2:o,y2:n.height||0,stroke:i,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&d.createElement("text",{x:o+4,y:12,fill:i,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const o=ie(e,n);if(null==o)return null;const i=e.color||"#f97316";return d.createElement("g",{key:"ann-"+t},d.createElement("line",{x1:0,y1:o,x2:n.width||0,y2:o,stroke:i,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:i,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:ie(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 i=s.packEnclose(o),r=e.padding||10;return d.createElement("g",{key:"ann-"+t},d.createElement("circle",{cx:i.x,cy:i.y,r:i.r+r,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&d.createElement("text",{x:i.x,y:i.y-i.r-r-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:ie(Object.assign(Object.assign({},e),{type:"point"}),n)})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const i=e.padding||10,r=o.map(e=>e.x),l=o.map(e=>e.y),s=Math.min(...r)-i,a=Math.max(...r)+i,c=Math.min(...l)-i,u=Math.max(...l)+i;return d.createElement("g",{key:"ann-"+t},d.createElement("rect",{x:s,y:c,width:a-s,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:(s+a)/2,y:c-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"highlight":{const o=n.data||[],i="function"==typeof e.filter?o.filter(e.filter):e.field&&null!=e.value?o.filter(t=>t[e.field]===e.value):[],r=e.style||{stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return d.createElement("g",{key:"ann-"+t},i.map((t,o)=>{const i=oe(t,n),l=ie(t,n);return null==i||null==l?null:d.createElement("circle",Object.assign({key:"hl-"+o,cx:i,cy:l,r:e.r||6},r))}))}case"bracket":{const o=oe(e,n),i=ie(e,n);return d.createElement(te,{key:"ann-"+t,noteData:{x:null!=o?o:0,y:null!=i?i:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}})}case"trend":{const s=n.data||[];if(2>s.length)return null;const a=n.xAccessor||"x",g=n.yAccessor||"y",p=s.map(e=>[e[a],e[g]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>p.length)return null;const y=null!==(i=null===(o=n.scales)||void 0===o?void 0:o.x)&&void 0!==i?i:null===(r=n.scales)||void 0===r?void 0:r.time,m=null!==(c=null===(l=n.scales)||void 0===l?void 0:l.y)&&void 0!==c?c:null===(u=n.scales)||void 0===u?void 0:u.value;if(!y||!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]),i=o.map(e=>e[0]),r=o.map(e=>e[1]),l=Math.max(2,Math.ceil(t*n)),s=[];for(let e=0;n>e;e++){const t=i[e],o=i.map(e=>Math.abs(e-t)),a=o.slice().sort((e,t)=>e-t)[Math.min(l-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*i[e],d+=t*r[e],f+=t*i[e]*i[e],g+=t*i[e]*r[e])}if(0===u){s.push([t,r[e]]);continue}const p=u*f-h*h;if(1e-12>Math.abs(p))s.push([t,d/u]);else{const e=(u*g-h*d)/p;s.push([t,(d-e*h)/u+e*t])}}return s}(p,null!==(h=e.bandwidth)&&void 0!==h?h:.3):("polynomial"===v?f.default.polynomial(p,{order:e.order||2}):f.default.linear(p)).points;const x=b.map(([e,t])=>`${y(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:y(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!==(p=null===(g=n.scales)||void 0===g?void 0:g.y)&&void 0!==p?p:null===(y=n.scales)||void 0===y?void 0:y.value,i=null!==(m=null==o?void 0:o(e.y0))&&void 0!==m?m:0,r=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(i,r),width:n.width||0,height:Math.abs(r-i),fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity||.1}),e.label&&d.createElement("text",{x:(n.width||0)-4,y:Math.min(i,r)-4,textAnchor:"end",fill:e.color||"#6366f1",fontSize:11},e.label))}case"envelope":{const o=n.data||[];if(2>o.length)return null;const i=n.xAccessor||"x",r=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,l=null!==(A=null===(w=n.scales)||void 0===w?void 0:w.y)&&void 0!==A?A:null===(M=n.scales)||void 0===M?void 0:M.value;if(!r||!l)return null;const s=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",u=e.filter,h=o.filter(e=>null!=e[s]&&null!=e[c]&&!(u&&!u(e))).sort((e,t)=>e[i]-t[i]);if(2>h.length)return null;const f=ne[n.curve||"linear"]||a.curveLinear,g=a.area().x(e=>r(e[i])).y0(e=>l(e[c])).y1(e=>l(e[s])).curve(f)(h);if(!g)return null;const p=e.fill||"#6366f1";return d.createElement("g",{key:"ann-"+t},d.createElement("path",{d:g,fill:p,fillOpacity:null!==(S=e.fillOpacity)&&void 0!==S?S:.15,stroke:"none"}),e.label&&h.length>0&&d.createElement("text",{x:r(h[h.length-1][i])+4,y:l(h[h.length-1][s])-4,fill:p,fontSize:11},e.label))}case"anomaly-band":{const o=n.data||[];if(2>o.length)return null;const i=n.yAccessor||"y",r=null!==(O=null===(E=n.scales)||void 0===E?void 0:E.x)&&void 0!==O?O:null===(C=n.scales)||void 0===C?void 0:C.time,l=null!==(P=null===(j=n.scales)||void 0===j?void 0:j.y)&&void 0!==P?P:null===(_=n.scales)||void 0===_?void 0:_.value;if(!r||!l)return null;const s=o.map(e=>e[i]).filter(e=>null!=e&&isFinite(e));if(2>s.length)return null;const a=s.reduce((e,t)=>e+t,0)/s.length,c=s.reduce((e,t)=>e+Math.pow(t-a,2),0)/s.length,u=Math.sqrt(c),h=null!==(L=e.threshold)&&void 0!==L?L:2,f=a-h*u,g=!1!==e.showBand,p=e.fill||"#6366f1",y=null!==(B=e.fillOpacity)&&void 0!==B?B:.1,m=e.anomalyColor||"#ef4444",v=null!==(N=e.anomalyRadius)&&void 0!==N?N:6,b=l(a+h*u),x=l(f),k=o.filter(e=>{const t=e[i];return null!=t&&Math.abs(t-a)>h*u});return d.createElement("g",{key:"ann-"+t},g&&d.createElement("rect",{x:0,y:Math.min(b,x),width:n.width||0,height:Math.abs(x-b),fill:p,fillOpacity:y}),k.map((e,t)=>{const o=oe(e,n),i=ie(e,n);return null==o||null==i?null:d.createElement("circle",{key:"anomaly-"+t,cx:o,cy:i,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:p,fontSize:11},e.label))}case"forecast":{const o=n.data||[];if(3>o.length)return null;const i=n.xAccessor||"x",r=n.yAccessor||"y",l=null!==(W=null===(H=n.scales)||void 0===H?void 0:H.x)&&void 0!==W?W:null===(z=n.scales)||void 0===z?void 0:z.time,s=null!==(F=null===(T=n.scales)||void 0===T?void 0:T.y)&&void 0!==F?F:null===(I=n.scales)||void 0===I?void 0:I.value;if(!l||!s)return null;const a=o.map(e=>[e[i],e[r]]).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=f.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,i=0;for(const[e,r]of a)t+=e,n+=r,o+=e*e,i+=e*r;const r=e*o-t*t;if(1e-12>Math.abs(r))return null;const l=(e*i-t*n)/r,s=(n-l*t)/e;c=e=>s+l*e}const u=a.length,h=a.map(([e,t])=>t-c(e)).reduce((e,t)=>e+t*t,0),g=Math.sqrt(h/Math.max(u-2,1)),p=a.reduce((e,t)=>e+t[0],0)/u,y=a.reduce((e,t)=>e+Math.pow(t[0]-p,2),0),m=null!==($=e.confidence)&&void 0!==$?$:.95,v=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,b=null!==(D=e.steps)&&void 0!==D?D:5,x=a[u-1][0],k=(x-a[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=g*Math.sqrt(1+1/u+(y>0?Math.pow(e-p,2)/y:0))*v;A.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const M=`M${A.map(e=>`${l(e.x)},${s(e.yUpper)}`).join(" L")} L${A.slice().reverse().map(e=>`${l(e.x)},${s(e.yLower)}`).join(" L")} Z`,S=A.map(e=>`${l(e.x)},${s(e.yCenter)}`).join(" "),E=`${l(x)},${s(c(x))}`,O=e.strokeColor||"#6366f1";return d.createElement("g",{key:"ann-"+t},d.createElement("path",{d:M,fill:e.fill||"#6366f1",fillOpacity:null!==(R=e.fillOpacity)&&void 0!==R?R:.15,stroke:"none"}),d.createElement("polyline",{points:`${E} ${S}`,fill:"none",stroke:O,strokeWidth:null!==(G=e.strokeWidth)&&void 0!==G?G:2,strokeDasharray:null!==(Y=e.strokeDasharray)&&void 0!==Y?Y:"6,3"}),e.label&&A.length>0&&d.createElement("text",{x:l(A[A.length-1].x)+4,y:s(A[A.length-1].yCenter)-4,fill:O,fontSize:11},e.label))}case"widget":{let o=null,i=null;if(null!=e.px&&null!=e.py)o=e.px,i=e.py;else{const r=re(e,t,n);if(!r)return null;o=r.x,i=r.y}if(null==o||null==i)return null;if(!le(o,i,n))return null;const r=null!==(q=e.dx)&&void 0!==q?q:0,l=null!==(X=e.dy)&&void 0!==X?X:0,s=null!==(V=e.width)&&void 0!==V?V:32,a=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+r-s/2,y:i+l-a/2,width:s,height:a,style:{overflow:"visible",pointerEvents:"auto"}},d.createElement("div",{style:{width:s,height:a,display:"flex",alignItems:"center",justifyContent:"center"}},c))}case"text":{const o=re(e,t,n);if(!o)return null;const{x:i,y:r}=o;return d.createElement("text",{key:"ann-text-"+t,x:i+(e.dx||0),y:r+(e.dy||0),fill:e.color||"var(--semiotic-text, #333)",fontSize:e.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},e.label)}default:return null}},t={scales:h?{x:h.x,y:h.y,time:h.x,value:h.y}:null,timeAxis:"x",xAccessor:N,yAccessor:H,width:i,height:r,data:W,frameType:"xy",pointNodes:z,curve:T,stickyPositionCache:R.current};return L.map((n,o)=>{if(B){const i=B(n,o,t);return null!=i?i:e(n,o,t)}return e(n,o,t)}).filter(Boolean)},[L,B,i,r,N,H,W,h,z,T]);return g||k||w||C||j||q&&q.length>0||x||I?d.createElement("svg",{role:"img",width:l,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&&!F&&d.createElement("g",{className:"stream-grid"},$.map((e,t)=>d.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:r,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),D.map((e,t)=>d.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:i,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),g&&h&&(()=>{const e=null==p?void 0:p.find(e=>"left"===e.orient),t=null==p?void 0:p.find(e=>"bottom"===e.orient),n=!e||!1!==e.baseline,o=(null==e?void 0:e.jaggedBase)||!1,l=(null==t?void 0:t.jaggedBase)||!1,s=null==t?void 0:t.landmarkTicks,a=null==e?void 0:e.landmarkTicks,c="var(--semiotic-border, #ccc)",h="var(--semiotic-text-secondary, #666)",f="var(--semiotic-text, #333)";return d.createElement("g",{className:"stream-axes"},!F&&(!t||!1!==t.baseline)&&!l&&d.createElement("line",{x1:0,y1:r,x2:i,y2:r,stroke:c,strokeWidth:1}),!F&&l&&d.createElement("path",{d:se("bottom",i,r),fill:"none",stroke:c,strokeWidth:1}),$.map((e,t)=>{const n=!!s&&("function"==typeof s?s(e.value,t):ue(e.value,t>0?$[t-1].value:void 0));return d.createElement("g",{key:"xtick-"+t,transform:`translate(${e.pixel},${r})`},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))}),y&&d.createElement("text",{x:i/2,y:r+40,textAnchor:"middle",fontSize:12,fill:f,style:{userSelect:"none"}},y),!F&&n&&!o&&d.createElement("line",{x1:0,y1:0,x2:0,y2:r,stroke:c,strokeWidth:1}),!F&&o&&d.createElement("path",{d:se("left",i,r),fill:"none",stroke:c,strokeWidth:1}),D.map((e,t)=>{const n=!!a&&("function"==typeof a?a(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:r/2,textAnchor:"middle",fontSize:12,fill:f,transform:`rotate(-90, ${15-u.left}, ${r/2})`,style:{userSelect:"none"}},m))})(),q,j&&h&&P&&_&&d.createElement(d.Fragment,null,j.top&&d.createElement("g",{transform:"translate(0, 0)"},d.createElement(K,{orient:"top",config:U(j.top),values:P,scale:h.x,size:u.top,length:i})),j.bottom&&d.createElement("g",{transform:`translate(0, ${r})`},d.createElement(K,{orient:"bottom",config:U(j.bottom),values:P,scale:h.x,size:u.bottom,length:i})),j.left&&d.createElement("g",{transform:"translate(0, 0)"},d.createElement(K,{orient:"left",config:U(j.left),values:_,scale:h.y,size:u.left,length:r})),j.right&&d.createElement("g",{transform:`translate(${i}, 0)`},d.createElement(K,{orient:"right",config:U(j.right),values:_,scale:h.y,size:u.right,length:r}))),C,I),k&&d.createElement("text",{x:l/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:i,legendPosition:r="right",title:l,legendHoverBehavior:s,legendClickBehavior:a,legendHighlightedCategory:c,legendIsolatedCategories:u,legendInteraction:h}=e;if(!t)return null;const f="top"===r||"bottom"===r;let g,p;return"left"===r?(g=4,p=i.top):"top"===r?(g=0,p=l?32:8):"bottom"===r?(g=0,p=o-i.bottom+50):(g=n-i.right+10,p=i.top),d.createElement("g",{transform:`translate(${g}, ${p})`},"object"==typeof(y=t)&&null!==y&&"gradient"in y?d.createElement(V,{config:t.gradient,orientation:f?"horizontal":"vertical",width:f?n:100}):function(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}(t)?d.createElement(Q,{legendGroups:t.legendGroups,title:"",width:f?n:100,orientation:f?"horizontal":"vertical",customHoverBehavior:s,customClickBehavior:a,highlightedCategory:c,isolatedCategories:u,legendInteraction:h}):t);var y}({legend:w,totalWidth:l,totalHeight:c,margin:u,legendPosition:O,title:k,legendHoverBehavior:A,legendClickBehavior:M,legendHighlightedCategory:S,legendIsolatedCategories:E})):null}const de="undefined"==typeof window||"undefined"==typeof document,fe={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function ge(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=[],i={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks"},r=["point","line","area","rect","heatcell","circle","candlestick"],l=Object.keys(n).sort((e,t)=>{const n=r.indexOf(e),o=r.indexOf(t);return(-1===n?999:n)-(-1===o?999:o)});for(const e of l)o.push(`${n[e]} ${i[e]||e}`);return`${t}, ${o.join(", ")}`}function pe({scene:e,chartType:t}){var n,o,i,r;const l=[];for(const t of e){if(l.length>=50)break;"point"===t.type?l.push({label:"Point",values:{x:Math.round(100*t.x)/100+"",y:Math.round(100*t.y)/100+""}}):"rect"===t.type?l.push({label:"Bar",values:{category:(null===(n=t.datum)||void 0===n?void 0:n.category)||"",value:Math.round(100*(null!==(i=null===(o=t.datum)||void 0===o?void 0:o.value)&&void 0!==i?i:0))/100+""}}):"heatcell"===t.type&&l.push({label:"Cell",values:{x:Math.round(100*t.x)/100+"",y:Math.round(100*t.y)/100+"",value:Math.round(100*(null!==(r=t.value)&&void 0!==r?r:0))/100+""}})}if(0===l.length)return null;const s=new Set;for(const e of l)for(const t of Object.keys(e.values))s.add(t);const a=Array.from(s);return d.createElement("table",{style:fe,role:"table","aria-label":"Data table for "+t},d.createElement("thead",null,d.createElement("tr",null,a.map(e=>d.createElement("th",{key:e},e)))),d.createElement("tbody",null,l.map((e,t)=>d.createElement("tr",{key:t},a.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:a.length},"...and ",e.length-50," more items"))))}function ye({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:fe},t)}function me(t){const n=e.createContext(null),o=ve(t);return[function({children:o}){const i=e.useMemo(()=>ve(t),[]);return d.createElement(n.Provider,{value:i,children:o})},t=>{var i;const r=null!==(i=e.useContext(n))&&void 0!==i?i:o,l=e.useRef(t);l.current=t;const s=e.useCallback(()=>l.current(r.getState()),[r]),a=e.useCallback(()=>l.current(r.getState()),[r]);return e.useSyncExternalStore(r.subscribe,s,a)}]}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 i=e.getContext("2d");if(!i)return null;const r=t[0]*o,l=t[1]*o,s=t[0]+"px",a=t[1]+"px";return e.style.width!==s&&(e.style.width=s),e.style.height!==a&&(e.style.height=a),e.width===r&&e.height===l||(e.width=r,e.height=l),i.setTransform(o,0,0,o,0,0),i.translate(n.left,n.top),i}function Me(e){switch(e){case"monotoneX":return a.curveMonotoneX;case"monotoneY":return a.curveMonotoneY;case"cardinal":return a.curveCardinal;case"catmullRom":return a.curveCatmullRom;case"step":return a.curveStep;case"stepBefore":return a.curveStepBefore;case"stepAfter":return a.curveStepAfter;case"basis":return a.curveBasis;case"natural":return a.curveNatural;default:return null}}function Se(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 Ee(e,t,n,o,i,r){if(2>t.length)return;const l=[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];l.push(l[e-1]+Math.sqrt(n*n+o*o))}const s=l[l.length-1];if(0===s)return;const a=Math.min(.2*s,40);e.strokeStyle=n,e.lineWidth=o,e.lineCap=r;for(let n=0;t.length-1>n;n++){const o=(l[n]+l[n+1])/2;let r=i;a>o&&(r*=o/a),a>s-o&&(r*=(s-o)/a),e.globalAlpha=Math.max(0,r),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}function Oe(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Ce(e,t,n=.3){Oe(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 je(e,t,n=.6){var o,i,r,l,s;if(!Oe(t))return;const a=null!==(o=t._pulseGlowRadius)&&void 0!==o?o:4,c=t.r+a*t._pulseIntensity,u=null!==(r=null!==(i=t.cx)&&void 0!==i?i:t.x)&&void 0!==r?r:0,h=null!==(s=null!==(l=t.cy)&&void 0!==l?l:t.y)&&void 0!==s?s: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){Oe(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 a.curveMonotoneX;case"monotoneY":return a.curveMonotoneY;case"cardinal":return a.curveCardinal;case"catmullRom":return a.curveCatmullRom;case"step":return a.curveStep;case"stepBefore":return a.curveStepBefore;case"stepAfter":return a.curveStepAfter;case"basis":return a.curveBasis;case"natural":return a.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=a.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 i,r,l;const s=t.filter(e=>"area"===e.type);for(const t of s){if(2>t.topPath.length)continue;const n=t.style.fill||"#4e79a7",o=t._decayOpacities;if(o&&o.length===t.topPath.length){const r=null!==(i=t.style.fillOpacity)&&void 0!==i?i:.7;e.fillStyle=n;for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(o[n]+o[n+1])*r,e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.lineTo(t.bottomPath[n+1][0],t.bottomPath[n+1][1]),e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(o[n]+o[n+1]),e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.stroke()}e.globalAlpha=1;continue}const s=null!==(r=t.style.opacity)&&void 0!==r?r:1;if(Be(e,t),t.fillGradient){let o=1/0;for(const e of t.topPath)o>e[1]&&(o=e[1]);let i=-1/0;for(const e of t.bottomPath)e[1]>i&&(i=e[1]);const r=Le(n),l=t.fillGradient.topOpacity,a=t.fillGradient.bottomOpacity,c=e.createLinearGradient(0,o,0,i);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=s}else{const o=null!==(l=t.style.fillOpacity)&&void 0!==l?l:.7;e.globalAlpha=o*s,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=s,e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const n=_e(t.curve);if(e.beginPath(),n)a.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 i;const r=t.filter(e=>"point"===e.type);e.save();try{for(const t of r){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(i=t.style.opacity)&&void 0!==i?i: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()),je(e,t),e.globalAlpha=1}}finally{e.restore()}},We=(e,t,n,o)=>{const i=t.filter(e=>"rect"===e.type);for(const t of i)null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon?ze(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))),Ce(e,t),e.globalAlpha=1};function ze(e,t){const n=t.style.icon,o=t.style.iconPadding||2,i=Math.min(t.w,t.h)-o;if(0>=i)return;const r=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),r){const r=i+o,l=t.x+(t.w-i)/2;for(let o=t.y+t.h-i;o>=t.y-i;o-=r)e.drawImage(n,l,o,i,i)}else{const r=i+o,l=t.y+(t.h-i)/2;for(let o=t.x;t.x+t.w>o;o+=r)e.drawImage(n,o,l,i,i)}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 Fe(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 i,r;const l=t.filter(e=>"line"===e.type);for(const s of l){if(2>s.path.length)continue;const c=s.style.stroke||"#007bff",u=s.style.strokeWidth||2,h=s.colorThresholds,d=s.rawValues;if(e.setLineDash(s.style.strokeDasharray?s.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=s.style.opacity&&(e.globalAlpha=s.style.opacity),e.lineWidth=u,e.lineCap=s.style.strokeLinecap||"butt",s.style._edgeFade){const y=null!==(i=s.style.opacity)&&void 0!==i?i:1;Ee(e,s.path,c,u,y,s.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const f=Me(s.curve),g=h&&h.length>0&&d&&d.length===s.path.length,p=s._decayOpacities;if(p&&p.length===s.path.length&&!g){e.strokeStyle=c;const m=null!==(r=s.style.opacity)&&void 0!==r?r:1;for(let v=0;s.path.length-1>v;v++)e.globalAlpha=.5*(p[v]+p[v+1])*m,e.beginPath(),e.moveTo(s.path[v][0],s.path[v][1]),e.lineTo(s.path[v+1][0],s.path[v+1][1]),e.stroke()}else if(g){let b=null,x=null,k=null,w=null,A=!1;function M(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),A=!0}function S(){A&&(e.stroke(),A=!1)}for(let E=0;s.path.length>E;E++){const[O,C]=s.path[E],j=d[E],P=Se(j,h,c);if(null!==b&&null!==w&&null!==k){if(P===w)e.lineTo(O,C);else{const _=[];for(const L of h){const B=L.value;(k>B||B>j)&&(B>k||j>B)||k===B||j===B||_.push({t:(B-k)/(j-k)})}_.sort((e,t)=>e.t-t.t);for(const N of _){const H=b+(O-b)*N.t,W=x+(C-x)*N.t,z=Se(k+(j-k)*Math.min(N.t+1e-4,1),h,c);e.lineTo(H,W),S(),M(z,H,W)}e.lineTo(O,C)}b=O,x=C,k=j,w=P}else M(P,O,C),b=O,x=C,k=j,w=P}S()}else{if(e.beginPath(),e.strokeStyle=c,f)a.line().x(e=>e[0]).y(e=>e[1]).curve(f).context(e)(s.path);else{const[T,F]=s.path[0];e.moveTo(T,F);for(let I=1;s.path.length>I;I++)e.lineTo(s.path[I][0],s.path[I][1])}e.stroke()}if(s.style.fill&&s.style.fillOpacity&&s.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=s.style.fillOpacity,e.fillStyle=s.style.fill,f&&!g)a.line().x(e=>e[0]).y(e=>e[1]).curve(f).context(e)(s.path);else{const[D,R]=s.path[0];e.moveTo(D,R);for(let G=1;s.path.length>G;G++)e.lineTo(s.path[G][0],s.path[G][1])}const $=s.path[0][0];e.lineTo(s.path[s.path.length-1][0],o.height),e.lineTo($,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}}],area:[Ne],stackedarea:[Ne],scatter:[He],bubble:[He],heatmap:[(e,t,n,o)=>{const i=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of i){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),Ce(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):Fe(t.value),o=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),i=t.x+t.w/2,r=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,i,r)}}}finally{e.restore()}}],bar:[We],swarm:[He],waterfall:[(e,t,n,o)=>{var i,r,l;We(e,t);const s=t.filter(e=>"rect"===e.type);if(2>s.length)return;const a=s[0].datum,c=null==a?void 0:a._connectorStroke;if(c){e.save(),e.strokeStyle=c,e.lineWidth=null!==(i=null==a?void 0:a._connectorWidth)&&void 0!==i?i:1,e.setLineDash([]);for(let t=0;s.length-1>t;t++){const o=s[t],i=s[t+1];if(!(null===(r=o.datum)||void 0===r?void 0:r.cumEnd)||!(null===(l=i.datum)||void 0===l?void 0:l.baseline))continue;const a=n.y(o.datum.cumEnd),c=o.x+o.w,u=i.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.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 i=Math.min(t.openY,t.closeY),r=Math.abs(t.openY-t.closeY),l=t.isUp?t.upColor:t.downColor;e.fillStyle=l,e.fillRect(t.x-t.bodyWidth/2,i,t.bodyWidth,Math.max(r,1)),e.strokeStyle=l,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,i,t.bodyWidth,Math.max(r,1)),e.restore()}}]},$e={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 Ye({width:o,height:i,totalWidth:r,totalHeight:l,margin:s,dimension:a,scales:c,onBrush:u}){const h=e.useRef(null),f=e.useRef(null),g=e.useRef(u);g.current=u;const p=e.useRef(c);return p.current=c,e.useEffect(()=>{if(!h.current)return;const e=n.select(h.current).select(".brush-g"),r="x"===a?t.brushX():"y"===a?t.brushY():t.brush();return r.extent([[0,0],[o,i]]),r.on("brush end",e=>{const t=p.current;if(!t)return;if(!e.selection)return void g.current(null);let n,r;if("x"===a){const[o,l]=e.selection;n=[t.x.invert(o),t.x.invert(l)],r=[t.y.invert(i),t.y.invert(0)]}else if("y"===a){const[i,l]=e.selection;n=[t.x.invert(0),t.x.invert(o)],r=[t.y.invert(l),t.y.invert(i)]}else{const[[o,i],[l,s]]=e.selection;n=[t.x.invert(o),t.x.invert(l)],r=[t.y.invert(s),t.y.invert(i)]}g.current({x:n,y:r})}),e.call(r),f.current=r,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null),f.current=null}},[o,i,a]),d.createElement("svg",{ref:h,width:r,height:l,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},d.createElement("g",{className:"brush-g",transform:`translate(${s.left},${s.top})`}))}const qe=e.forwardRef(function(t,n){var o,i,r,l,s,a,c,u,h;const{chartType:f,runtimeMode:p,data:y,chunkThreshold:m,chunkSize:v,xAccessor:b,yAccessor:x,colorAccessor:k,sizeAccessor:w,groupAccessor:A,lineDataAccessor:M,curve:S,normalize:E,binSize:O,valueAccessor:C,arrowOfTime:j="right",windowMode:P="sliding",windowSize:_=200,timeAccessor:L,xExtent:B,yExtent:H,extentPadding:T=.1,sizeRange:R,size:G=[500,300],responsiveWidth:Y,responsiveHeight:q,margin:X,className:V,background:Q,lineStyle:U,pointStyle:K,areaStyle:Z,waterfallStyle:J,swarmStyle:ee,barColors:te,colorScheme:ne,boundsAccessor:oe,boundsStyle:ie,y0Accessor:re,gradientFill:le,openAccessor:se,highAccessor:ce,lowAccessor:ue,closeAccessor:fe,candlestickStyle:me,showAxes:ve=!0,axes:be,xLabel:xe,yLabel:ke,xFormat:Me,yFormat:Se,tickFormatTime:Ee,tickFormatValue:Oe,hoverAnnotation:Ce,tooltipContent:je,customHoverBehavior:Pe,enableHover:_e,annotations:Le,svgAnnotationRules:Be,showGrid:Ne,legend:He,legendHoverBehavior:We,legendClickBehavior:ze,legendHighlightedCategory:Te,legendIsolatedCategories:Fe,legendPosition:Re,backgroundGraphics:qe,foregroundGraphics:Xe,canvasPreRenderers:Ve,title:Qe,categoryAccessor:Ue,brush:Ke,onBrush:Ze,decay:Je,pulse:et,transition:tt,staleness:nt,heatmapAggregation:ot,heatmapXBins:it,heatmapYBins:rt,showValues:lt,heatmapValueFormat:st,marginalGraphics:at,pointIdAccessor:ct,xScaleType:ut,yScaleType:ht,accessibleTable:dt}=t,[ft,gt]=function(t,n,o){const i=e.useRef(null),[r,l]=e.useState(null);return e.useEffect(()=>{if(!n&&!o)return;const e=i.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;l(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[n,o]),[i,[n&&r?r.w:t[0],o&&r?r.h:t[1]]]}(G,Y,q),pt=Object.assign(Object.assign({},$e),X);if(at){const e=60;at.top&&e>pt.top&&(pt.top=e),at.bottom&&e>pt.bottom&&(pt.bottom=e),at.left&&e>pt.left&&(pt.left=e),at.right&&e>pt.right&&(pt.right=e)}const yt=gt[0]-pt.left-pt.right,mt=gt[1]-pt.top-pt.bottom,vt="function"==typeof Xe?Xe({size:gt,margin:pt}):Xe,bt="function"==typeof qe?qe({size:gt,margin:pt}):qe,xt=null!=Ce?Ce:_e,kt=e.useRef(null),wt=e.useRef(null),At=e.useRef(0),Mt=e.useRef(!1),St=we(e=>e.theme),[Et,Ot]=e.useState(0),[Ct,jt]=e.useState(null),Pt=e.useRef(null),_t=e.useRef(null),[Lt,Bt]=e.useState(null),[Nt,Ht]=e.useState(!1),[Wt,zt]=e.useState([]),[Tt,Ft]=e.useState([]),It=e.useRef(()=>{}),$t="streaming"===p||["bar","swarm","waterfall"].includes(f),Dt=e.useMemo(()=>({chartType:f,runtimeMode:$t?"streaming":"bounded",windowSize:_,windowMode:P,arrowOfTime:$t?j:"right",extentPadding:T,xAccessor:$t?void 0:b,yAccessor:$t?void 0:x,timeAccessor:$t?L:void 0,valueAccessor:C,colorAccessor:k,sizeAccessor:w,groupAccessor:A,categoryAccessor:Ue,lineDataAccessor:M,xScaleType:ut,yScaleType:ht,xExtent:B,yExtent:H,sizeRange:R,binSize:O,normalize:E,boundsAccessor:oe,boundsStyle:ie,y0Accessor:re,gradientFill:"boolean"==typeof le?le?{topOpacity:.8,bottomOpacity:.05}:void 0:le,openAccessor:se,highAccessor:ce,lowAccessor:ue,closeAccessor:fe,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:it,heatmapYBins:rt,showValues:lt,heatmapValueFormat:st,pointIdAccessor:ct,curve:S}),[f,_,P,j,T,b,x,L,C,ut,ht,k,w,A,Ue,M,B,H,R,O,E,oe,ie,re,le,se,ce,ue,fe,me,U,K,Z,ee,J,ne,te,Le,Je,et,tt,nt,ot,it,rt,lt,st,$t,ct,S]),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),Mt.current=!0,Gt()},[Dt,Gt]),e.useEffect(()=>{Mt.current=!0,Gt()},[St,Gt]);const Yt=e.useRef(null);Yt.current||(Yt.current=new g(e=>{const t=Rt.current;t&&t.ingest(e)&&(Mt.current=!0,Gt())},{chunkThreshold:m,chunkSize:v})),e.useEffect(()=>{var e;null===(e=Yt.current)||void 0===e||e.updateChunkOptions({chunkThreshold:m,chunkSize:v})},[m,v]);const qt=e.useCallback(e=>{var t;null===(t=Yt.current)||void 0===t||t.push(e)},[]),Xt=e.useCallback(e=>{var t;null===(t=Yt.current)||void 0===t||t.pushMany(e)},[]),Vt=e.useCallback(()=>{var e,t;null===(e=Yt.current)||void 0===e||e.clear(),null===(t=Rt.current)||void 0===t||t.clear(),Mt.current=!0,Gt()},[Gt]);e.useImperativeHandle(n,()=>({push:qt,pushMany:Xt,clear:Vt,getData:()=>{var e,t,n;return null===(e=Yt.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}}),[qt,Xt,Vt]),e.useEffect(()=>{var e;y&&(null===(e=Yt.current)||void 0===e||e.setBoundedData(y))},[y]);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-pt.left,i=e.clientY-n.top-pt.top;if(0>o||o>yt||0>i||i>mt)return void(Pt.current&&(Pt.current=null,_t.current=null,Bt(null),Pe&&(Pe(null),Mt.current=!0),Gt()));const r=Rt.current;if(!r||0===r.scene.length)return;const l=function(e,t,n,o=30,i){let r=null,l=!1;if(i){const e=i.find(t,n,o);if(e){const i=W(e,t,n);i&&o>i.distance&&(r=i,l=!0)}}for(const s of e){let e=null;switch(s.type){case"point":if(i&&l)break;e=W(s,t,n);break;case"line":e=z(s,t,n);break;case"rect":e=F(s,t,n);break;case"heatcell":e=I(s,t,n);break;case"area":if(!1===s.interactive)break;e=D(s,t,n);break;case"candlestick":e=$(s,t,n)}e&&o>e.distance&&(r&&e.distance>=r.distance||(r=e))}return r}(r.scene,o,i,30,r.quadtree);if(!l)return void(Pt.current&&(Pt.current=null,_t.current=null,Bt(null),Pe&&Pe(null),Gt()));const s=l.datum||{},a=Object.assign(Object.assign({},"object"!=typeof s||null===s||Array.isArray(s)?{}:s),{data:s,time:l.x,value:l.y,x:l.x,y:l.y});Pt.current=a,_t.current=l.node,Bt(a),Pe&&(Pe(a),Mt.current=!0),Gt()},Ut.current=()=>{Pt.current&&(Pt.current=null,_t.current=null,Bt(null),Pe&&(Pe(null),Mt.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,i=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===i)return;if(e.preventDefault(),0>i)return Zt.current=-1,Pt.current=null,_t.current=null,Bt(null),Pe&&Pe(null),void Gt();const r=0>o?0:i;Zt.current=r;const l=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[r]);Pt.current=l,Bt(l),Pe&&Pe(l),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 i=Rt.current;if(!i)return;const r="undefined"!=typeof performance?performance.now():Date.now(),l=i.advanceTransition(r),s=Mt.current||l;s&&!l&&i.computeScene({width:yt,height:mt});const a="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(),i=t.getPropertyValue("--semiotic-bg").trim(),r=o||t.getPropertyValue("--text-secondary").trim(),l=t.getPropertyValue("--text-primary").trim(),s=n||t.getPropertyValue("--surface-3").trim(),a=i||t.getPropertyValue("--surface-0").trim();return r||l||n?{axisStroke:s||De.axisStroke,tickText:r||De.tickText,crosshair:r?r+"66":De.crosshair,hoverFill:a?a+"4D":De.hoverFill,hoverStroke:r?r+"99":De.hoverStroke,pointRing:a||De.pointRing}:De}(n),u=null!==(e=null==nt?void 0:nt.threshold)&&void 0!==e?e:5e3,h=nt&&i.lastIngestTime>0&&r-i.lastIngestTime>u;if(s){const e=Ae(n,gt,pt,a);if(e){e.clearRect(-pt.left,-pt.top,gt[0],gt[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(),r=Q||(o&&"transparent"!==o?o:null);if(r&&(e.fillStyle=r,e.fillRect(-pt.left,-pt.top,gt[0],gt[1])),e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,yt,mt),e.clip()),Ve&&i.scales)for(const t of Ve)e.save(),t(e,i.scene,i.scales,{width:yt,height:mt}),e.restore();const l=Ie[f];if(l&&i.scales)for(const t of l)t(e,i.scene,i.scales,{width:yt,height:mt});e.restore(),h&&(e.globalAlpha=1)}}{const e=Ae(o,gt,pt,a);if(e&&(xt&&Pt.current&&i.scales&&function(e,t,n,o,i,r,l){if(!1===i.crosshair)return;e.save();const s="object"==typeof i.crosshair?i.crosshair:{};e.strokeStyle=s.stroke||l.crosshair,e.lineWidth=s.strokeWidth||1,e.setLineDash(s.strokeDasharray?s.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(t.x,0),e.lineTo(t.x,o),e.stroke(),e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke(),e.restore(),e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle="#007bff",e.fill(),e.strokeStyle=l.pointRing,e.lineWidth=2,e.stroke()}(e,Pt.current,yt,mt,"object"==typeof xt?xt:{},0,c),_t.current&&Array.isArray(Ce))){const t=Ce.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,o){var i;if(!n)return;const r=n.group;if(void 0!==r)for(const n of t){if("line"!==n.type)continue;if(n.group!==r)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!==(i=t.opacity)&&void 0!==i?i:1,e.stroke(),e.restore()}}(e,i.scene,_t.current,t)}}s&&n&&n.setAttribute("aria-label",ge(i.scene,f+" chart"));const d=Mt.current;if(Mt.current=!1,d&&i.scales&&((!Ct||Ct.x.domain()[0]!==i.scales.x.domain()[0]||Ct.x.domain()[1]!==i.scales.x.domain()[1]||Ct.y.domain()[0]!==i.scales.y.domain()[0]||Ct.y.domain()[1]!==i.scales.y.domain()[1]||Ct.x.range()[0]!==i.scales.x.range()[0]||Ct.x.range()[1]!==i.scales.x.range()[1]||Ct.y.range()[0]!==i.scales.y.range()[0]||Ct.y.range()[1]!==i.scales.y.range()[1])&&jt(i.scales),at)){const e=i.getData(),t="function"==typeof b?b:e=>e[b||"x"],n="function"==typeof x?x:e=>e[x||"y"];zt(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),Ft(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}d&&Le&&Le.length>0&&Ot(e=>e+1),(null==nt?void 0:nt.showBadge)&&Ht(!!h),(l||i.hasActivePulses)&&(At.current=requestAnimationFrame(()=>It.current()))},e.useEffect(()=>(Gt(),()=>{At.current&&(cancelAnimationFrame(At.current),At.current=0)}),[Gt]),e.useEffect(()=>{Mt.current=!0,Gt()},[f,yt,mt,ve,Q,U,Ve,Gt]),function(t,n,o,i,r,l){e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{var e;const s=n.current;if(!s||0===s.lastIngestTime)return;const a="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(e=t.threshold)&&void 0!==e?e:5e3,u=a-s.lastIngestTime>c;u!==r&&(l(u),o.current=!0,i())},1e3);return()=>clearInterval(e)},[t,r,i])}(nt,Rt,Mt,Gt,Nt,Ht);const tn=xt&&Lt?je?je(Lt):d.createElement(Ge,{hover:Lt}):null,nn=tn?d.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:pt.left+Lt.x,top:pt.top+Lt.y,transform:`translate(${Lt.x>.7*yt?"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:gt[0],height:gt[1],pointerEvents:"none",zIndex:2}},d.createElement("circle",{cx:Lt.x+pt.left,cy:Lt.y+pt.top,r:8,fill:"none",stroke:"var(--accent, #6366f1)",strokeWidth:2,strokeDasharray:"4,2"})):null;if(de){const e=Rt.current;e&&y&&(e.ingest({inserts:y,bounded:!0}),e.computeScene({width:yt,height:mt}));const t=null!==(o=null==e?void 0:e.scene)&&void 0!==o?o:[],n=null!==(i=null==e?void 0:e.scales)&&void 0!==i?i: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:gt[0],height:gt[1]}},d.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:gt[0],height:gt[1],style:{position:"absolute",left:0,top:0}},bt,d.createElement("g",{transform:`translate(${pt.left},${pt.top})`},Q&&d.createElement("rect",{x:0,y:0,width:yt,height:mt,fill:Q}),t.map((e,t)=>function(e,t){var n,o,i;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 i=e;if(0===i.topPath.length)return null;const r=i.topPath.map(([e,t])=>`${e},${t}`).join("L"),l=[...i.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L");return d.createElement("path",{key:"area-"+t,d:`M${r}L${l}Z`,fill:i.style.fill||"#4e79a7",fillOpacity:null!==(o=null!==(n=i.style.fillOpacity)&&void 0!==n?n:i.style.opacity)&&void 0!==o?o:.7,stroke:i.style.stroke,strokeWidth:i.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!==(i=e.style.opacity)&&void 0!==i?i:.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,i,r]=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),l=.299*o+.587*i+.114*r>128?"#000":"#fff",s=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:l,fontSize:s+"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),i=Math.max(Math.abs(n.openY-n.closeY),1),r=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:i,fill:r,stroke:r,strokeWidth:1}))}default:return null}}(e,t)).filter(Boolean))),d.createElement(he,{width:yt,height:mt,totalWidth:gt[0],totalHeight:gt[1],margin:pt,scales:n,showAxes:ve,axes:be,xLabel:xe,yLabel:ke,xFormat:Me||Ee,yFormat:Se||Oe,showGrid:Ne,title:Qe,legend:He,legendHoverBehavior:We,legendClickBehavior:ze,legendHighlightedCategory:Te,legendIsolatedCategories:Fe,legendPosition:Re,foregroundGraphics:vt,marginalGraphics:at,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 C?C:void 0,annotationData:null==e?void 0:e.getData(),pointNodes:null==e?void 0:e.scene.filter(e=>"point"===e.type),curve:"string"==typeof S?S:void 0}))}return d.createElement("div",{ref:ft,className:"stream-xy-frame"+(V?" "+V:""),role:"img","aria-label":"string"==typeof Qe?Qe:"XY chart",tabIndex:0,style:{position:"relative",width:Y?"100%":gt[0],height:q?"100%":gt[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:gt[0],height:gt[1],pointerEvents:"none"}},bt),d.createElement(ae,{width:yt,height:mt,totalWidth:gt[0],totalHeight:gt[1],margin:pt,scales:Ct,showAxes:ve,axes:be,showGrid:Ne,xFormat:Me||Ee,yFormat:Se||Oe}),d.createElement("canvas",{ref:kt,"aria-label":ge(null!==(l=null===(r=Rt.current)||void 0===r?void 0:r.scene)&&void 0!==l?l:[],f+" chart"),style:{position:"absolute",left:0,top:0}}),d.createElement("canvas",{ref:wt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),d.createElement(ye,{hoverPoint:Lt}),dt&&d.createElement(pe,{scene:null!==(a=null===(s=Rt.current)||void 0===s?void 0:s.scene)&&void 0!==a?a:[],chartType:f+" chart"}),d.createElement(he,{width:yt,height:mt,totalWidth:gt[0],totalHeight:gt[1],margin:pt,scales:Ct,showAxes:ve,axes:be,xLabel:xe,yLabel:ke,xFormat:Me||Ee,yFormat:Se||Oe,showGrid:Ne,title:Qe,legend:He,legendHoverBehavior:We,legendClickBehavior:ze,legendHighlightedCategory:Te,legendIsolatedCategories:Fe,legendPosition:Re,foregroundGraphics:vt,marginalGraphics:at,xValues:Wt,yValues:Tt,annotations:Le,svgAnnotationRules:Be,annotationFrame:Et,xAccessor:"string"==typeof b?b:"string"==typeof L?L:void 0,yAccessor:"string"==typeof x?x:"string"==typeof C?C: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 S?S:void 0,underlayRendered:!0}),(Ke||Ze)&&d.createElement(Ye,{width:yt,height:mt,totalWidth:gt[0],totalHeight:gt[1],margin:pt,dimension:null!==(h=null==Ke?void 0:Ke.dimension)&&void 0!==h?h:"xy",scales:Ct,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)});qe.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,i]=o.range;t.push(t=>{const o=t[n];return o>=e&&i>=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),i=Ue(o,t),r=new Map(i.clauses);return r.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},i),{clauses:r})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const i=new Map(e.selections),r=new Map(o.clauses);return r.delete(n),i.set(t,Object.assign(Object.assign({},o),{clauses:r})),{selections:i}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),i=Ue(o,t);return o.set(t,Object.assign(Object.assign({},i),{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:i}=t,r=Ze(e=>e.selections.get(i)),l=Ze(e=>e.setClause),s=Ze(e=>e.clearClause),a=e.useMemo(()=>!!r&&r.clauses.size>0,[r]);return{predicate:e.useMemo(()=>r&&0!==r.clauses.size?function(e,t){const n=[];for(const[o,i]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(Qe(i));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(r,o):()=>!0,[r,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)};l(i,{clientId:o,type:"point",fields:t})},[o,i,l]),selectInterval:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};l(i,{clientId:o,type:"interval",fields:t})},[o,i,l]),clear:e.useCallback(()=>{s(i,o)},[s,i,o]),clientId:o}}function nt(t){const n=t.name||"hover",{fields:o}=t,{predicate:i,isActive:r,selectPoints:l,clear:s}=tt({name:n});return{onHover:e.useCallback(e=>{if(!e)return void s();const t={};for(const n of o){const o=e[n];void 0!==o&&(t[n]=[o])}Object.keys(t).length>0&&l(t)},[o,l,s,n]),predicate:i,isActive:r}}function ot(t){const{name:n,xField:o,yField:i}=t,{predicate:r,isActive:l,selectInterval:s,clear:a}=tt({name:n}),c=o&&i?"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])]),i&&(t[i]=[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)&&i&&(t[i]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&s(t)},[c,o,i,s,a]);return{brushInteraction:e.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:r,isActive:l,clear:a}}const it=e.createContext(!1);function rt({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 lt({categoryColors:t,interaction:n,selectionName:o,field:i}){const r=Object.entries(t);if(0===r.length)return null;const l=r.map(([e])=>e),s=[{styleFn:e=>({fill:e.color||"#333",stroke:e.color||"#333"}),type:"fill",items:r.map(([e,t])=>({label:e,color:t})),label:""}],a=nt({name:o,fields:[i]}),c=tt({name:o,clientId:"__linked-legend-isolate__"}),[u,h]=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&&(u.size>0?p.current({[i]:Array.from(u)}):y.current())},[n,u,i]);const m=e.useCallback(e=>{"highlight"===n&&(e?(g(e.label),a.onHover({[i]:e.label})):(g(null),a.onHover(null)))},[n,i,a]),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===l.length?new Set:n})},[n,l.length]);return d.createElement("svg",{width:"100%",height:30,style:{display:"block",overflow:"visible"}},d.createElement(Q,{legendGroups:s,title:!1,orientation:"horizontal",height:20,customHoverBehavior:"highlight"===n?m:void 0,customClickBehavior:"isolate"===n?v:void 0,highlightedCategory:f,isolatedCategories:u}))}function st({children:e,selections:t,showLegend:n,legendPosition:o="top",legendInteraction:i="none",legendSelectionName:r="legend",legendField:l="category"}){const s=Ve(),a=void 0!==n?n:!(!s||0>=Object.keys(s).length);return d.createElement(Ke,null,d.createElement(Je,null,t&&d.createElement(rt,{selections:t}),d.createElement(it.Provider,{value:a},a&&"top"===o&&s&&d.createElement(lt,{categoryColors:s,interaction:i,selectionName:r,field:l}),e,a&&"bottom"===o&&s&&d.createElement(lt,{categoryColors:s,interaction:i,selectionName:r,field:l}))))}function at({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:i,strokeWidth:r}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==i&&(n.stroke=i),void 0!==r&&(n.strokeWidth=r),n},type:"fill",items:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(i=>{const r=e.find("function"==typeof t?e=>t(e)===i:e=>e[t]===i),l=r?o(r,t,n):n?n(i):"#000000";return{label:i+"",color:l}}),label:""}]}}function ct(e){return e?"string"==typeof e?{name:e}:e:null}function ut(e,t,n){return t?o=>{var i;const r=Object.assign({},e(o));if(t.isActive)if(t.predicate(o))(null==n?void 0:n.selectedStyle)&&Object.assign(r,n.selectedStyle);else{const e=null!==(i=null==n?void 0:n.unselectedOpacity)&&void 0!==i?i:.2;r.opacity=e,r.fillOpacity=e,r.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(r,n.unselectedStyle)}return r}:e}const ht="#007bff";function dt(e){return"function"==typeof e?e:t=>t[e]}function ft(t,n,o="category10"){const i=Ve();return e.useMemo(()=>{if(n){if(0===t.length)return i&&Object.keys(i).length>0?e=>i[e]||"#999":void 0;if("function"==typeof n){const e=Array.from(new Set(t.map(e=>n(e)+"")));return i&&Object.keys(i).length>0?e=>i[e]||"#999":_(e.map(e=>({_cat:e})),"_cat",o)}if(i&&Object.keys(i).length>0){const e=_(t,n,o);return t=>i[t]||e(t)}return _(t,n,o)}},[t,n,o,i])}function gt({selection:t,linkedHover:n,fallbackFields:o=[],unwrapData:i=!1,onObservation:r,chartType:l,chartId:s}){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=tt({name:(null==t?void 0:t.name)||"__unused__"}),u=nt({name:(null==a?void 0:a.name)||"hover",fields:(null==a?void 0:a.fields)||o||[]}),h=et(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(r||h){const n={timestamp:Date.now(),chartType:l||"unknown",chartId:s};if(e){let i=e.data||e.datum||e;Array.isArray(i)&&(i=i[0]);const l=Object.assign(Object.assign({},n),{type:"hover",datum:i||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0});r&&r(l),h&&h(l)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});r&&r(e),h&&h(e)}}},[n,u,r,l,s,h]),g=e.useCallback(e=>{var t,n;if(r||h){const o={timestamp:Date.now(),chartType:l||"unknown",chartId:s};if(e){let i=e.data||e.datum||e;Array.isArray(i)&&(i=i[0]);const l=Object.assign(Object.assign({},o),{type:"click",datum:i||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});r&&r(l),h&&h(l)}else{const e=Object.assign(Object.assign({},o),{type:"click-end"});r&&r(e),h&&h(e)}}},[r,h,l,s]);return{activeSelectionHook:d,customHoverBehavior:f,customClickBehavior:g}}function pt({data:t,colorBy:n,colorScale:o,showLegend:i,legendPosition:r="right",userMargin:l,defaults:s={top:50,bottom:60,left:70,right:40}}){const a=e.useContext(it),c=void 0!==i?i:!a&&!!n,u=e.useMemo(()=>{if(c&&n)return at({data:t,colorBy:n,colorScale:o,getColor:P})},[c,n,t,o]),h=e.useMemo(()=>{const e=Object.assign(Object.assign({},s),l);return u&&("right"===r&&110>e.right?e.right=110:"left"===r&&110>e.left?e.left=110:"top"===r&&50>e.top?e.top=50:"bottom"===r&&80>e.bottom&&(e.bottom=80)),e},[s,l,u,r]);return{legend:u,margin:h,legendPosition:r}}function yt(t,n,o){const[i,r]=e.useState(null),[l,s]=e.useState(new Set),a=e.useCallback(e=>{"highlight"===t&&r(e?e.label:null)},[t]),c=e.useCallback(e=>{"isolate"===t&&s(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===o.length?new Set:n})},[t,o.length]),u=e.useMemo(()=>{if(!t||"none"===t||!n)return null;const e="string"==typeof n?n:null;return"highlight"===t&&null!=i?{isActive:!0,predicate:t=>(e?t[e]:"function"==typeof n?n(t):null)===i}:"isolate"===t&&l.size>0?{isActive:!0,predicate:t=>{const o=e?t[e]:"function"==typeof n?n(t):null;return l.has(o)}}:null},[t,n,i,l]);return{highlightedCategory:"highlight"===t?i:null,isolatedCategories:"isolate"===t?l:new Set,onLegendHover:a,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,i,r,l,s,a;const c=mt[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:c.width,height:null!==(i=t.height)&&void 0!==i?i:c.height,showAxes:c.showAxes,showGrid:null!==(r=t.showGrid)&&void 0!==r?r:c.showGrid,enableHover:null!==(l=t.enableHover)&&void 0!==l?l:!!t.linkedHover||c.enableHover,showLegend:null!==(s=t.showLegend)&&void 0!==s?s: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 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:i={},className:r=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let l;const s=[];if(n){const t=xt(e,n);l=kt(t,o)}if(t&&t.length>0)t.forEach(t=>{let n,i,r;"string"==typeof t?(n=t,i=t,r=o):(n=t.label,i=t.accessor||t.key||"",r=t.format||o);const l=xt(e,i);s.push({label:n,value:kt(l,r)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){l=kt(e[n],o);break}if(!l){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(l=kt(e[t[0]],o))}}const a=Object.assign(Object.assign({},bt),i);return d.createElement("div",{className:("semiotic-tooltip "+r).trim(),style:a},l&&d.createElement("div",{style:{fontWeight:s.length>0?"bold":"normal"}},l),s.map((e,t)=>d.createElement("div",{key:t,style:{marginTop:0===t&&l?"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 Mt(e){return"string"==typeof e?e:"value"}function St(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function Et(e,t){return"function"==typeof t?t(e):e[t]}function Ot(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 i=t?St(Et(o,t.accessor)):null;return d.createElement("div",{className:"semiotic-tooltip",style:bt},i&&d.createElement("div",{style:{fontWeight:"bold",marginBottom:n.length>0?4:0}},i),n.map((e,t)=>{const n=St(Et(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 Ct({componentName:e,message:t,width:n,height:o}){return d.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"}},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)))}class jt 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(Ct,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}var Pt;const _t="undefined"!=typeof process&&"production"!==(null===(Pt=process.env)||void 0===Pt?void 0:Pt.NODE_ENV);function Lt({componentName:e,width:t,height:n,children:o}){return d.createElement(jt,{fallback:o=>d.createElement(Ct,{componentName:e,message:o.message,width:t,height:n})},o)}const Bt={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"},Nt={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Ht(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({},Bt),{width:t,height:n})},o||"No data available"):null}function Wt(e,t,n){if(!e)return null;const o=Math.min(5,Math.floor(n/40)),i=Math.max(8,Math.floor(n/(3*o))),r=Math.max(6,Math.floor(n/(2.5*o))),l=Math.floor((n-(o*(i+r)-r))/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({},Nt),{position:"absolute",top:l+n*(i+r),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:i,opacity:.5+n%2*.2})})))}function zt(e,t,n,o){if(!_t)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const i=t[0];if(!i||"object"!=typeof i)return;if(o in i)return;const r=Object.keys(i).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${r}`)}function Tt(e,t){const n=e.length,o=t.length,i=Array(o+1);for(let e=0;o>=e;e++)i[e]=e;for(let r=1;n>=r;r++){let n=i[0];i[0]=r;for(let l=1;o>=l;l++){const o=i[l];i[l]=e[r-1]===t[l-1]?n:1+Math.min(n,i[l],i[l-1]),n=o}}return i[o]}function Ft(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,i=n+1;for(const n of t){const t=Tt(e.toLowerCase(),n.toLowerCase());i>t&&(i=t,o=n)}return i>n?void 0:o}(e,t,3))&&void 0!==n?n:null)}function It({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=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[i,r]of Object.entries(n))if(r&&"string"==typeof r&&!(r in o)){const n=Ft(r,t),o=n?` Try ${i}="${n}".`:"";return`${e}: ${i} "${r}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}function $t(e,t,n,o){return new(n||(n=Promise))(function(i,r){function l(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(l,s)}a((o=o.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;let Dt=null;function Rt(){return $t(this,void 0,void 0,function*(){return Dt||(Dt=yield Promise.resolve().then(function(){return dn})),Dt})}const Gt=e.forwardRef(function(t,n){var o,i;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 l=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:c,xFormat:u,yFormat:h,xAccessor:f="x",yAccessor:g="y",lineBy:p,lineDataAccessor:y="coordinates",colorBy:m,colorScheme:v="category10",curve:b="linear",showPoints:x=!1,pointRadius:k=3,fillArea:w=!1,areaOpacity:A=.3,lineWidth:M=2,tooltip:S,pointIdAccessor:E,annotations:O,directLabel:C,gapStrategy:j="break",anomaly:_,forecast:L,frameProps:B={},selection:N,linkedHover:H,onObservation:W,chartId:z,loading:T,emptyContent:F,legendInteraction:I,legendPosition:$,xScaleType:D,yScaleType:R}=t,G=l.width,Y=l.height,q=l.enableHover,X=l.showGrid,V=l.showLegend,Q=l.title,U=l.xLabel,K=l.yLabel,Z=Wt(T,G,Y);if(Z)return Z;const J=Ht(s,G,Y,F);if(J)return J;const ee=s||[];zt("LineChart",ee,"xAccessor",f),zt("LineChart",ee,"yAccessor",g);const te="string"==typeof f?f:"x",ne="string"==typeof g?g:"y",[oe,ie]=e.useState(null),[re,le]=e.useState([]);e.useEffect(()=>{if(!L&&!_)return;let e=!1;return ie(null),le([]),L?function(...e){return $t(this,void 0,void 0,function*(){return(yield Rt()).buildForecast(...e)})}(ee,te,ne,L,_).then(t=>{e||(ie(t),le(t.annotations))}).catch(()=>{e||(ie(null),le([]))}):_&&function(...e){return $t(this,void 0,void 0,function*(){return(yield Rt()).buildAnomalyAnnotations(...e)})}(_).then(t=>{e||(ie(null),le(t))}).catch(()=>{e||le([])}),()=>{e=!0}},[ee,L,_,te,ne]);const se=oe?oe.processedData:ee,ae=L&&!p?"__forecastSegment":p,{activeSelectionHook:ce,customHoverBehavior:ue}=gt({selection:N,linkedHover:H,fallbackFields:m?["string"==typeof m?m:""]:[],onObservation:W,chartType:"LineChart",chartId:z}),he=e.useCallback(e=>{const t="function"==typeof f?f(e):e[f],n="function"==typeof g?g(e):e[g];return null==t||null==n||Number.isNaN(t)||Number.isNaN(n)},[f,g]),de=void 0!==(null===(o=se[0])||void 0===o?void 0:o[y]),fe=e.useMemo(()=>{if(de)return se;if(ae){const e=se.reduce((e,t)=>{const n="function"==typeof ae?ae(t):t[ae];if(!e[n]){const t={[y]:[]};"string"==typeof ae&&(t[ae]=n),e[n]=t}return e[n][y].push(t),e},{});return Object.values(e)}return[{[y]:se}]},[se,ae,y,de]),{gapProcessedLineData:ge,hasGaps:pe}=e.useMemo(()=>{if("interpolate"===j){let e=!1;const t=[];for(const n of fe){const o=(n[y]||[]).filter(t=>!he(t)||(e=!0,!1));o.length>0&&t.push(Object.assign(Object.assign({},n),{[y]:o}))}return{gapProcessedLineData:t,hasGaps:e}}if("break"===j){let e=!1;const t=[];for(const n of fe){const o=n[y]||[];let i=[],r=0;const l=ae&&"string"==typeof ae?n[ae]:void 0;for(const s of o)if(he(s))e=!0,i.length>0&&(t.push(Object.assign(Object.assign({},n),{[y]:i})),i=[],r++);else{const e=null!=l?`${l}__seg${r}`:"__seg"+r;i.push(Object.assign(Object.assign({},s),{_gapSegment:e}))}i.length>0&&t.push(Object.assign(Object.assign({},n),{[y]:i}))}return{gapProcessedLineData:t,hasGaps:e}}if("zero"===j){let e=!1;const t="string"==typeof g?g:"y",n=[];for(const o of fe){const i=o[y]||[],r=[];for(const n of i)he(n)?(e=!0,r.push(Object.assign(Object.assign({},n),{[t]:0}))):r.push(n);n.push(Object.assign(Object.assign({},o),{[y]:r}))}return{gapProcessedLineData:n,hasGaps:e}}return{gapProcessedLineData:fe,hasGaps:!1}},[fe,j,y,he,ae,g]),ye=ft(se,m,v),me=e.useMemo(()=>{if(!m)return[];const e=new Set;for(const t of se){const n="function"==typeof m?m(t):t[m];null!=n&&e.add(n+"")}return Array.from(e)},[se,m]),ve=yt(I,m,me),be=e.useMemo(()=>ve.legendSelectionHook?ve.legendSelectionHook:ce,[ve.legendSelectionHook,ce]),xe=e.useMemo(()=>e=>{const t={strokeWidth:M};return m?ye&&(t.stroke=P(e,m,ye),w&&(t.fill=t.stroke,t.fillOpacity=A)):(t.stroke=ht,w&&(t.fill=ht,t.fillOpacity=A)),t},[m,ye,M,w,A]),[ke,we]=e.useState(null);e.useEffect(()=>{if(!L)return void we(null);let e=!1;return function(...e){return $t(this,void 0,void 0,function*(){return(yield Rt()).createSegmentLineStyle(...e)})}(xe,L).then(t=>{e||we(()=>t)}).catch(()=>{e||we(null)}),()=>{e=!0}},[xe,L]);const Ae=ke||xe,Me=e.useMemo(()=>ut(Ae,be,N),[Ae,be,N]),Se=e.useMemo(()=>{if(x)return e=>{const t={r:k,fillOpacity:1};return m?ye&&(t.fill=P(e.parentLine||e,m,ye)):t.fill=ht,t}},[x,k,m,ye]),Ee=w?"area":"line",Oe="object"==typeof C?C:{},Ce=Oe.position||"end",je=Oe.fontSize||11,Pe=e.useMemo(()=>{var e,t;if(!C||!m)return[];const n="function"==typeof f?f:e=>e[f],o="function"==typeof g?g:e=>e[g],i="function"==typeof m?m:e=>e[m],r=new Map;for(const n of ge){const o=n[y]||[];if(0===o.length)continue;const l="end"===Ce?o[o.length-1]:o[0],s=null!==(t=null!==(e=i(l))&&void 0!==e?e:i(n))&&void 0!==t?t:"";s&&!r.has(s+"")&&r.set(s+"",l)}const l=Array.from(r.entries()).map(([e,t])=>({type:"text",label:e,["string"==typeof f?f:"x"]:n(t),["string"==typeof g?g:"y"]:o(t),dx:"end"===Ce?6:-6,dy:0,color:ye?ye(e):ht,fontSize:je}));l.sort((e,t)=>{const n="string"==typeof g?g:"y";return e[n]-t[n]});for(let e=1;l.length>e;e++){const t="string"==typeof g?g:"y",n=l[e-1],o=l[e];je+2>Math.abs(o[t]+o.dy-(n[t]+n.dy))&&(o.dy+=je+2)}return l},[C,m,ye,ge,y,f,g,Ce,je]),_e=(!C||void 0!==V)&&V,Le=e.useMemo(()=>{if(!C)return l.marginDefaults;const e=Pe.reduce((e,t)=>{var n;const o=((null===(n=t.label)||void 0===n?void 0:n.length)||0)*(.6*je);return Math.max(e,o)},0),t=e+10,n="end"===Ce?"right":"left";return Object.assign(Object.assign({},l.marginDefaults),{[n]:Math.max(l.marginDefaults[n]||0,t)})},[C,Pe,je,Ce,l.marginDefaults]),{legend:Be,margin:Ne,legendPosition:He}=pt({data:ge,colorBy:m,colorScale:ye,showLegend:_e,legendPosition:$,userMargin:a,defaults:Le}),We=p||m,ze=e.useMemo(()=>Ot([{label:U||Mt(f),accessor:f,role:"x"},{label:K||Mt(g),accessor:g,role:"y"},...We?[{label:Mt(We),accessor:We,role:"group"}]:[]]),[f,g,U,K,We]),Te=It({componentName:"LineChart",data:de?(null===(i=se[0])||void 0===i?void 0:i[y])||[]:s,accessors:{xAccessor:f,yAccessor:g}});if(Te)return d.createElement(Ct,{componentName:"LineChart",message:Te,width:G,height:Y});const Fe=e.useMemo(()=>de||ae||pe?ge.flatMap(e=>{const t=e[y]||[];return ae&&"string"==typeof ae?t.map(t=>Object.assign(Object.assign({},t),{[ae]:e[ae]})):t}):se,[ge,y,de,ae,se,pe]),Ie=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:Ee},null!=s&&{data:Fe}),{xAccessor:f,yAccessor:g,xScaleType:D,yScaleType:R,groupAccessor:"break"===j&&pe?"_gapSegment":ae||void 0,curve:b,lineStyle:Me}),x&&{pointStyle:Se}),{size:[G,Y],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Ne,showAxes:l.showAxes,xLabel:U,yLabel:K,xFormat:u,yFormat:h,enableHover:q,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===S?()=>null:At(S)||ze}),(H||W)&&{customHoverBehavior:ue}),E&&{pointIdAccessor:E}),((null==O?void 0:O.length)||re.length||Pe.length)&&{annotations:[...O||[],...re,...Pe]}),B);return d.createElement(Lt,{componentName:"LineChart",width:G,height:Y},d.createElement(qe,Object.assign({ref:r},Ie)))});Gt.displayName="LineChart";const Yt=e.forwardRef(function(t,n){var o;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 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:l,margin:s,className:a,xFormat:c,yFormat:u,xAccessor:h="x",yAccessor:f="y",areaBy:g,y0Accessor:p,gradientFill:y=!1,lineDataAccessor:m="coordinates",colorBy:v,colorScheme:b="category10",curve:x="monotoneX",areaOpacity:k=.7,showLine:w=!0,lineWidth:A=2,tooltip:M,annotations:S,frameProps:E={},selection:O,linkedHover:C,onObservation:j,chartId:_,loading:L,emptyContent:B,legendInteraction:N,legendPosition:H}=t,W=r.width,z=r.height,T=r.enableHover,F=r.showGrid,I=r.showLegend,$=r.title,D=r.xLabel,R=r.yLabel,G=Wt(L,W,z);if(G)return G;const Y=Ht(l,W,z,B);if(Y)return Y;const q=l||[];zt("AreaChart",q,"xAccessor",h),zt("AreaChart",q,"yAccessor",f);const{activeSelectionHook:X,customHoverBehavior:V}=gt({selection:O,linkedHover:C,fallbackFields:v?["string"==typeof v?v:""]:[],onObservation:j,chartType:"AreaChart",chartId:_}),Q=void 0!==(null===(o=q[0])||void 0===o?void 0:o[m]),U=e.useMemo(()=>{if(Q)return q;if(g){const e=q.reduce((e,t)=>{const n="function"==typeof g?g(t):t[g];if(!e[n]){const t={[m]:[]};"string"==typeof g&&(t[g]=n),e[n]=t}return e[n][m].push(t),e},{});return Object.values(e)}return[{[m]:q}]},[q,g,m,Q]),K=ft(q,v,b),Z=e.useMemo(()=>{if(!v)return[];const e=new Set;for(const t of q){const n="function"==typeof v?v(t):t[v];null!=n&&e.add(n+"")}return Array.from(e)},[q,v]),J=yt(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,O),[te,ee,O]),{legend:oe,margin:ie,legendPosition:re}=pt({data:U,colorBy:v,colorScale:K,showLegend:I,legendPosition:H,userMargin:s,defaults:r.marginDefaults}),le=g||v,se=e.useMemo(()=>Ot([{label:D||Mt(h),accessor:h,role:"x"},{label:R||Mt(f),accessor:f,role:"y"},...le?[{label:Mt(le),accessor:le,role:"group"}]:[]]),[h,f,D,R,le]),ae=It({componentName:"AreaChart",data:l,accessors:{xAccessor:h,yAccessor:f}});if(ae)return d.createElement(Ct,{componentName:"AreaChart",message:ae,width:W,height:z});const ce=e.useMemo(()=>Q||g?U.flatMap(e=>{const t=e[m]||[];return g&&"string"==typeof g?t.map(t=>Object.assign(Object.assign({},t),{[g]:e[g]})):t}):q,[U,m,Q,g,q]),ue=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area"},null!=l&&{data:ce}),{xAccessor:h,yAccessor:f,groupAccessor:g||void 0}),p&&{y0Accessor:p}),y&&{gradientFill:y}),{curve:x,lineStyle:ne,size:[W,z],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ie,showAxes:r.showAxes,xLabel:D,yLabel:R,xFormat:c,yFormat:u,enableHover:T,showGrid:F}),oe&&{legend:oe,legendPosition:re}),N&&"none"!==N&&{legendHoverBehavior:J.onLegendHover,legendClickBehavior:J.onLegendClick,legendHighlightedCategory:J.highlightedCategory,legendIsolatedCategories:J.isolatedCategories}),$&&{title:$}),a&&{className:a}),{tooltipContent:!1===M?()=>null:At(M)||se}),(C||j)&&{customHoverBehavior:V}),S&&S.length>0&&{annotations:S}),E);return d.createElement(Lt,{componentName:"AreaChart",width:W,height:z},d.createElement(qe,Object.assign({ref:i},ue)))});Yt.displayName="AreaChart";const qt=e.forwardRef(function(t,n){var o;const i=e.useRef(null),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:l,margin:s,className:a,xFormat:c,yFormat:u,xAccessor:h="x",yAccessor:f="y",areaBy:g,lineDataAccessor:p="coordinates",colorBy:y,colorScheme:m="category10",curve:v="monotoneX",areaOpacity:b=.7,showLine:x=!0,lineWidth:k=2,normalize:w=!1,tooltip:A,annotations:M,frameProps:S={},selection:E,linkedHover:O,onObservation:j,chartId:_,loading:L,emptyContent:B,legendInteraction:N,legendPosition:H}=t,W=r.width,z=r.height,T=r.enableHover,F=r.showGrid,I=r.showLegend,$=r.title,D=r.xLabel,R=r.yLabel,G=Wt(L,W,z);if(G)return G;const Y=Ht(l,W,z,B);if(Y)return Y;const q=l||[],X=function({isPushMode:t,colorBy:n,colorScheme:o,showLegend:i,legendPosition:r="right"}){const l=e.useRef(new Set),s=e.useRef([]),[a,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||l.current.has(e)||(l.current.add(e),s.current.push(e),o=!0)}o&&c(e=>e+1)},[t,n,u]),d=e.useCallback(e=>t=>{h([t]),e(t)},[h]),f=e.useCallback(e=>t=>{h(t),e(t)},[h]),g=e.useCallback(()=>{l.current=new Set,s.current=[],c(e=>e+1)},[]),p=e.useMemo(()=>{if(!t||!n||!1===i)return;const e=s.current;if(0===e.length)return;const r=Array.isArray(o)?o:C,l=new Map;for(let t=0;e.length>t;t++)l.set(e[t],r[t%r.length]);const a="string"==typeof n?n:"__streamCat";return at({data:e.map(e=>({[a]:e})),colorBy:a,colorScale:e=>l.get(e)||"#999",getColor:P})},[t,n,i,o,a]),y=e.useMemo(()=>{if(p)return"right"===r?{right:110}:"left"===r?{left:110}:"top"===r?{top:50}:"bottom"===r?{bottom:80}:{right:110}},[p,r]);return{wrapPush:d,wrapPushMany:f,resetCategories:g,streamingLegend:p,streamingMarginAdjust:y}}({isPushMode:void 0===l,colorBy:y||g,colorScheme:m,showLegend:I,legendPosition:H}),V=e.useCallback(X.wrapPush(e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)}),[X.wrapPush]),Q=e.useCallback(X.wrapPushMany(e=>{var t;return null===(t=i.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=i.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}),[V,Q,X.resetCategories]);const{activeSelectionHook:U,customHoverBehavior:K}=gt({selection:E,linkedHover:O,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:j,chartType:"StackedAreaChart",chartId:_}),Z=void 0!==(null===(o=q[0])||void 0===o?void 0:o[p]),J=e.useMemo(()=>{if(Z)return q;if(g){const e=q.reduce((e,t)=>{const n="function"==typeof g?g(t):t[g];if(!e[n]){const t={[p]:[]};"string"==typeof g&&(t[g]=n),e[n]=t}return e[n][p].push(t),e},{});return Object.values(e)}return[{[p]:q}]},[q,g,p,Z]),ee=ft(q,y,m),te=e.useMemo(()=>{if(!y)return[];const e=new Set;for(const t of q){const n="function"==typeof y?y(t):t[y];null!=n&&e.add(n+"")}return Array.from(e)},[q,y]),ne=yt(N,y,te),oe=e.useMemo(()=>ne.legendSelectionHook?ne.legendSelectionHook:U,[ne.legendSelectionHook,U]),ie=e.useMemo(()=>e=>{const t={};if(y&&ee){const n=P(e,y,ee);t.fill=n,x?(t.stroke=n,t.strokeWidth=k):t.stroke="none"}else y||(t.fill=ht,t.stroke=x?ht:"none",x&&(t.strokeWidth=k));return t.fillOpacity=b,t},[y,ee,b,x,k]),re=e.useMemo(()=>ut(ie,oe,E),[ie,oe,E]),{legend:le,margin:se,legendPosition:ae}=pt({data:J,colorBy:y,colorScale:ee,showLegend:I,legendPosition:H,userMargin:s,defaults:r.marginDefaults}),ce=X.streamingLegend||le,ue=H||ae,he=e.useMemo(()=>{if(X.streamingMarginAdjust){const e=Object.assign({},se);for(const[t,n]of Object.entries(X.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return se},[se,X.streamingMarginAdjust]),de=g||y,fe=e.useMemo(()=>Ot([{label:D||Mt(h),accessor:h,role:"x"},{label:R||Mt(f),accessor:f,role:"y"},...de?[{label:Mt(de),accessor:de,role:"group"}]:[]]),[h,f,D,R,de]),ge=It({componentName:"StackedAreaChart",data:l,accessors:{xAccessor:h,yAccessor:f}});if(ge)return d.createElement(Ct,{componentName:"StackedAreaChart",message:ge,width:W,height:z});const pe=e.useMemo(()=>Z||g?J.flatMap(e=>{const t=e[p]||[];return g&&"string"==typeof g?t.map(t=>Object.assign(Object.assign({},t),{[g]:e[g]})):t}):q,[J,p,Z,g,q]),ye=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea"},null!=l&&{data:pe}),{xAccessor:h,yAccessor:f,groupAccessor:g||void 0,curve:v,normalize:w,lineStyle:re,size:[W,z],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:he,showAxes:r.showAxes,xLabel:D,yLabel:R,xFormat:c,yFormat:u,enableHover:T,showGrid:F}),ce&&{legend:ce,legendPosition:ue}),N&&"none"!==N&&{legendHoverBehavior:ne.onLegendHover,legendClickBehavior:ne.onLegendClick,legendHighlightedCategory:ne.highlightedCategory,legendIsolatedCategories:ne.isolatedCategories}),$&&{title:$}),a&&{className:a}),{tooltipContent:!1===A?()=>null:At(A)||fe}),(O||j)&&{customHoverBehavior:K}),M&&M.length>0&&{annotations:M}),S);return d.createElement(Lt,{componentName:"StackedAreaChart",width:W,height:z},d.createElement(qe,Object.assign({ref:i},ye)))});qt.displayName="StackedAreaChart";const Xt=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 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:r,margin:l,className:s,xFormat:a,yFormat:c,xAccessor:u="x",yAccessor:h="y",colorBy:f,colorScheme:g="category10",sizeBy:p,sizeRange:y=[3,15],pointRadius:m=5,pointOpacity:v=.8,tooltip:b,marginalGraphics:x,pointIdAccessor:k,annotations:w,frameProps:A={},selection:M,linkedHover:S,linkedBrush:E,onObservation:O,chartId:C,loading:j,emptyContent:_,legendInteraction:B,legendPosition:N}=t,H=i.width,W=i.height,z=i.enableHover,T=i.showGrid,F=i.title,I=i.xLabel,$=i.yLabel,D=r||[],R=function(t){const{data:n,rawData:o,colorBy:i,colorScheme:r,legendInteraction:l,legendPosition:s,selection:a,linkedHover:c,fallbackFields:u,unwrapData:h=!1,onObservation:d,chartType:f,chartId:g,showLegend:p,userMargin:y,marginDefaults:m,loading:v,emptyContent:b,width:x,height:k}=t,{activeSelectionHook:w,customHoverBehavior:A,customClickBehavior:M}=gt({selection:a,linkedHover:c,fallbackFields:u,unwrapData:h,onObservation:d,chartType:f,chartId:g}),S=ft(n,i,r),E=e.useMemo(()=>{if(!i)return[];const e=new Set;for(const t of n){const n="function"==typeof i?i(t):t[i];null!=n&&e.add(n+"")}return Array.from(e)},[n,i]),O=yt(l,i,E),C=e.useMemo(()=>O.legendSelectionHook?O.legendSelectionHook:w,[O.legendSelectionHook,w]),{legend:j,margin:P,legendPosition:_}=pt({data:n,colorBy:i,colorScale:S,showLegend:p,legendPosition:s,userMargin:y,defaults:m}),L=e.useMemo(()=>{const e={};return j&&(e.legend=j,e.legendPosition=_),l&&"none"!==l&&(e.legendHoverBehavior=O.onLegendHover,e.legendClickBehavior=O.onLegendClick,e.legendHighlightedCategory=O.highlightedCategory,e.legendIsolatedCategories=O.isolatedCategories),e},[j,_,l,O.onLegendHover,O.onLegendClick,O.highlightedCategory,O.isolatedCategories]),B=Wt(v,x,k),N=B?null:Ht(o,x,k,b);return{colorScale:S,allCategories:E,legendState:O,effectiveSelectionHook:C,activeSelectionHook:w,customHoverBehavior:A,customClickBehavior:M,legend:j,margin:P,legendPosition:_,earlyReturn:B||N||null,legendBehaviorProps:L}}({data:D,rawData:r,colorBy:f,colorScheme:g,legendInteraction:B,legendPosition:N,selection:M,linkedHover:S,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!1,onObservation:O,chartType:"Scatterplot",chartId:C,showLegend:i.showLegend,userMargin:l,marginDefaults:i.marginDefaults,loading:j,emptyContent:_,width:H,height:W}),G=ct(E),Y=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)}),q=G?"xyBrush"===Y.brushInteraction.brush?"xy":"xBrush"===Y.brushInteraction.brush?"x":"y":void 0,X=d.useRef(Y.brushInteraction);X.current=Y.brushInteraction;const V=e.useCallback(e=>{const t=X.current;t.end(e?"xyBrush"===t.brush?[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:"xBrush"===t.brush?e.x:e.y:null)},[]);if(R.earlyReturn)return R.earlyReturn;zt("Scatterplot",D,"xAccessor",u),zt("Scatterplot",D,"yAccessor",h);const Q=e.useMemo(()=>{if(!p||0===D.length)return;const e=D.map(e=>"function"==typeof p?p(e):e[p]);return[Math.min(...e),Math.max(...e)]},[D,p]),U=e.useMemo(()=>e=>{const t={fillOpacity:v};return f?R.colorScale&&(t.fill=P(e,f,R.colorScale)):t.fill=ht,t.r=p?L(e,p,y,Q):m,t},[f,R.colorScale,p,y,Q,m,v]),K=e.useMemo(()=>ut(U,R.effectiveSelectionHook,M),[U,R.effectiveSelectionHook,M]),Z=e.useMemo(()=>Ot([{label:I||Mt(u),accessor:u,role:"x"},{label:$||Mt(h),accessor:h,role:"y"},...f?[{label:Mt(f),accessor:f,role:"color"}]:[],...p?[{label:Mt(p),accessor:p,role:"size"}]:[]]),[u,h,I,$,f,p]),J=It({componentName:"Scatterplot",data:r,accessors:{xAccessor:u,yAccessor:h}});if(J)return d.createElement(Ct,{componentName:"Scatterplot",message:J,width:H,height:W});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!=r&&{data:D}),{xAccessor:u,yAccessor:h,colorAccessor:f||void 0,sizeAccessor:p||void 0,sizeRange:y,pointStyle:K,colorScheme:g,size:[H,W],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R.margin,showAxes:i.showAxes,xLabel:I,yLabel:$,xFormat:a,yFormat:c,enableHover:z,showGrid:T}),R.legendBehaviorProps),F&&{title:F}),s&&{className:s}),{tooltipContent:!1===b?()=>null:At(b)||Z}),(S||O)&&{customHoverBehavior:R.customHoverBehavior}),x&&{marginalGraphics:x}),k&&{pointIdAccessor:k}),w&&w.length>0&&{annotations:w}),G&&{brush:{dimension:q},onBrush:V}),A);return d.createElement(Lt,{componentName:"Scatterplot",width:H,height:W},d.createElement(qe,Object.assign({ref:o},ee)))});function Vt(e,t){return i.interpolateViridis(1===t?.5:e/(t-1))}Xt.displayName="Scatterplot";const Qt=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 i=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:r,className:l,xFormat:s,yFormat:a,xAccessor:c="x",yAccessor:u="y",orderAccessor:h,orderLabel:f,pointRadius:g=4,tooltip:p,pointIdAccessor:y,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:k,chartId:w,loading:A,emptyContent:M,legendInteraction:S}=t,E=i.width,O=i.height,C=i.enableHover,j=i.showGrid,P=i.title,_=i.xLabel,L=i.yLabel,B=r||[],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),i=e(n);return(o instanceof Date?o.getTime():+o)-(i instanceof Date?i.getTime():+i)})},[B,h]);zt("ConnectedScatterplot",N,"xAccessor",c),zt("ConnectedScatterplot",N,"yAccessor",u);const{activeSelectionHook:H,customHoverBehavior:W}=gt({selection:b,linkedHover:x,fallbackFields:[],onObservation:k,chartType:"ConnectedScatterplot",chartId:w}),z=yt(S,void 0,[]),T=e.useMemo(()=>z.legendSelectionHook?z.legendSelectionHook:H,[z.legendSelectionHook,H]),F=e.useMemo(()=>(e,t)=>{var n,o;const i=t.filter(e=>"point"===e.type);if(2>i.length)return;const r=null==T?void 0:T.isActive,l=null==T?void 0:T.predicate,s=100>i.length,a=i.length;e.lineCap="round";for(let t=0;a-1>t;t++){const c=i[t],u=i[t+1],h=Vt(t,a),d=!r||!l||l(null!==(n=c.datum)&&void 0!==n?n:c)||l(null!==(o=u.datum)&&void 0!==o?o:u),f=r?d?1:.2:1;s&&(e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle="white",e.lineWidth=g+2,e.globalAlpha=.5*f,e.stroke()),e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle=h,e.lineWidth=g,e.globalAlpha=f,e.stroke()}e.globalAlpha=1},[g,T]),I=e.useMemo(()=>[F],[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 i,r;const l=$.current;if(0===l.idx){const n=null!==(r=null===(i=o.current)||void 0===i?void 0:i.getData())&&void 0!==r?r:N;l.total=n.filter(n=>{const o=e(n),i=t(n);return null!=o&&null!=i&&isFinite(o)&&isFinite(i)}).length}const s=l.total,a=l.idx;return l.idx++,s>l.idx||(l.idx=0),{fill:s>0?Vt(a,s):"#6366f1",stroke:"white",strokeWidth:1,r:g,fillOpacity:1}}},[g,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),Y=f||("string"==typeof h?h:"Order"),q=e.useMemo(()=>Ot([{label:_||Mt(c),accessor:c,role:"x"},{label:L||Mt(u),accessor:u,role:"y"},...h?[{label:Y,accessor:h,role:"group"}]:[]]),[c,u,_,L,h,Y]),X=It({componentName:"ConnectedScatterplot",data:r,accessors:{xAccessor:c,yAccessor:u}}),V=Wt(A,E,O);if(V)return V;const Q=Ht(r,E,O,M);if(Q)return Q;if(X)return d.createElement(Ct,{componentName:"ConnectedScatterplot",message:X,width:E,height:O});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!=r&&{data:N}),{xAccessor:c,yAccessor:u,pointStyle:R,size:[E,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:G,showAxes:i.showAxes,xLabel:_,yLabel:L,xFormat:s,yFormat:a,enableHover:C,showGrid:j}),P&&{title:P}),l&&{className:l}),{tooltipContent:!1===p?()=>null:At(p)||q}),(x||k)&&{customHoverBehavior:W}),y&&{pointIdAccessor:y}),{canvasPreRenderers:I}),m&&m.length>0&&{annotations:m}),v);return d.createElement(Lt,{componentName:"ConnectedScatterplot",width:E,height:O},d.createElement(qe,Object.assign({ref:o},U)))});Qt.displayName="ConnectedScatterplot";const Ut=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 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:r,margin:l,className:s,xFormat:a,yFormat:c,xAccessor:u="x",yAccessor:h="y",sizeBy:f,sizeRange:g=[5,40],colorBy:p,colorScheme:y="category10",bubbleOpacity:m=.6,bubbleStrokeWidth:v=1,bubbleStrokeColor:b="white",tooltip:x,marginalGraphics:k,pointIdAccessor:w,annotations:A,frameProps:M={},selection:S,linkedHover:E,linkedBrush:O,onObservation:C,chartId:j,loading:_,emptyContent:B,legendInteraction:N,legendPosition:H}=t,W=i.width,z=i.height,T=i.enableHover,F=i.showGrid,I=i.showLegend,$=i.title,D=i.xLabel,R=i.yLabel,G=Wt(_,W,z);if(G)return G;const Y=Ht(r,W,z,B);if(Y)return Y;const q=r||[],{activeSelectionHook:X,customHoverBehavior:V}=gt({selection:S,linkedHover:E,fallbackFields:p?["string"==typeof p?p:""]:[],onObservation:C,chartType:"BubbleChart",chartId:j}),Q=ct(O);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=ft(q,p,y),K=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]),Z=yt(N,p,K),J=e.useMemo(()=>Z.legendSelectionHook?Z.legendSelectionHook:X,[Z.legendSelectionHook,X]),ee=e.useMemo(()=>{const e=q.map(e=>"function"==typeof f?f(e):e[f]);return[Math.min(...e),Math.max(...e)]},[q,f]),te=e.useMemo(()=>e=>{const t={fillOpacity:m,strokeWidth:v,stroke:b};return p?U&&(t.fill=P(e,p,U)):t.fill=ht,t.r=L(e,f,g,ee),t},[p,U,f,g,ee,m,v,b]),ne=e.useMemo(()=>ut(te,J,S),[te,J,S]),{legend:oe,margin:ie,legendPosition:re}=pt({data:q,colorBy:p,colorScale:U,showLegend:I,legendPosition:H,userMargin:l,defaults:i.marginDefaults}),le=e.useMemo(()=>Ot([{label:D||Mt(u),accessor:u,role:"x"},{label:R||Mt(h),accessor:h,role:"y"},{label:Mt(f),accessor:f,role:"size"},...p?[{label:Mt(p),accessor:p,role:"color"}]:[]]),[u,h,D,R,f,p]),se=It({componentName:"BubbleChart",data:r,accessors:{xAccessor:u,yAccessor:h},requiredProps:{sizeBy:f}});if(se)return d.createElement(Ct,{componentName:"BubbleChart",message:se,width:W,height:z});const ae=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!=r&&{data:q}),{xAccessor:u,yAccessor:h,colorAccessor:p||void 0,sizeAccessor:f,sizeRange:g,pointStyle:ne,colorScheme:y,size:[W,z],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ie,showAxes:i.showAxes,xLabel:D,yLabel:R,xFormat:a,yFormat:c,enableHover:T,showGrid:F}),oe&&{legend:oe,legendPosition:re}),N&&"none"!==N&&{legendHoverBehavior:Z.onLegendHover,legendClickBehavior:Z.onLegendClick,legendHighlightedCategory:Z.highlightedCategory,legendIsolatedCategories:Z.isolatedCategories}),$&&{title:$}),s&&{className:s}),{tooltipContent:!1===x?()=>null:At(x)||le}),(E||C)&&{customHoverBehavior:V}),k&&{marginalGraphics:k}),w&&{pointIdAccessor:w}),A&&A.length>0&&{annotations:A}),M);return d.createElement(Lt,{componentName:"BubbleChart",width:W,height:z},d.createElement(qe,Object.assign({ref:o},ae)))});Ut.displayName="BubbleChart";const Kt=e.forwardRef(function(t,n){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 l=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:s,margin:a,className:c,xAccessor:u="x",yAccessor:h="y",valueAccessor:f="value",xFormat:g,yFormat:p,colorScheme:y="blues",customColorScale:m,showValues:v=!1,valueFormat:b,cellBorderColor:x="#fff",cellBorderWidth:k=1,tooltip:w,annotations:A,frameProps:M={},selection:S,linkedHover:E,onObservation:O,chartId:C,loading:j,emptyContent:P,showLegend:_,legendPosition:L,legendInteraction:B}=t,N=l.width,H=l.height,W=l.enableHover,z=l.title,T=l.xLabel,F=l.yLabel,I=Wt(j,N,H);if(I)return I;const $=Ht(s,N,H,P);if($)return $;const D=s||[],R=null!=_&&_,G=null!=L?L:"right",{margin:Y}=pt({data:D,colorBy:R?"value":void 0,colorScale:void 0,showLegend:R,legendPosition:G,userMargin:a,defaults:l.marginDefaults}),{activeSelectionHook:q,customHoverBehavior:X}=gt({selection:S,linkedHover:E,fallbackFields:[],onObservation:O,chartType:"Heatmap",chartId:C}),V=yt(B,void 0,[]),Q=e.useMemo(()=>V.legendSelectionHook?V.legendSelectionHook:q,[V.legendSelectionHook,q]),U=e.useMemo(()=>"function"==typeof f?e=>f(e):e=>e[f],[f]),K=e.useMemo(()=>{const e=D.map(U);return[Math.min(...e),Math.max(...e)]},[D,U]),Z=e.useMemo(()=>"custom"===y&&m?m:o.scaleSequential({blues:i.interpolateBlues,reds:i.interpolateReds,greens:i.interpolateGreens,viridis:i.interpolateViridis}[y]||i.interpolateBlues).domain(K),[y,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,S),[J,Q,S]);const ee=e.useMemo(()=>Ot([{label:T||Mt(u),accessor:u,role:"x"},{label:F||Mt(h),accessor:h,role:"y"},{label:Mt(f),accessor:f,role:"value"}]),[u,h,T,F,f]),te=It({componentName:"Heatmap",data:s,accessors:{xAccessor:u,yAccessor:h,valueAccessor:f}});if(te)return d.createElement(Ct,{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 f?f:"value",format:b}}},[R,Z,K,f,b]),oe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap"},null!=s&&{data:D}),{xAccessor:u,yAccessor:h,valueAccessor:f,colorScheme:"custom"!==y?y:void 0,showValues:v,heatmapValueFormat:b,size:[N,H],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Y,showAxes:l.showAxes,xLabel:T,yLabel:F,xFormat:g,yFormat:p,enableHover:W}),ne&&{legend:ne,legendPosition:G}),z&&{title:z}),c&&{className:c}),{tooltipContent:!1===w?()=>null:At(w)||ee}),(E||O)&&{customHoverBehavior:X}),A&&A.length>0&&{annotations:A}),M);return d.createElement(Lt,{componentName:"Heatmap",width:N,height:H},d.createElement(qe,Object.assign({ref:r},oe)))});Kt.displayName="Heatmap";const Zt="__splomIdx",Jt={top:4,bottom:4,left:4,right:4};function en({frameRef:o,cellSize:i,onBrush:r}){const l=e.useRef(null),s=i-Jt.left-Jt.right,a=i-Jt.top-Jt.bottom;return e.useEffect(()=>{if(!l.current)return;const e=n.select(l.current).select(".brush-g"),i=t.brush().extent([[0,0],[s,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 r(null);const[[i,l],[s,a]]=e.selection,c=[[n.x.invert(i),n.y.invert(l)],[n.x.invert(s),n.y.invert(a)]];r(c)});return e.call(i),e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null)}},[s,a,o,r]),d.createElement("svg",{ref:l,width:i,height:i,style:{position:"absolute",top:0,left:0}},d.createElement("g",{className:"brush-g",transform:`translate(${Jt.left},${Jt.top})`}))}function tn({data:t,xField:n,yField:o,cellSize:i,pointRadius:r,pointOpacity:l,colorBy:s,colorScale:a,brushSelectionName:c,hoverSelectionName:u,unselectedOpacity:h,mode:f,onPointHover:g}){const p=e.useRef(null),y=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==g||g(null));const t=e.data,n=null==t?void 0:t[Zt];void 0!==n&&(b({[Zt]:[n]}),null==g||g(t,e.x+Jt.left,e.y+Jt.top))},[b,g]),w=e.useCallback(e=>{const t={opacity:l,r:r};return t.fill=s?P(e,s,a):ht,"hover"===f?v.isActive&&v.predicate(e)?(t.opacity=1,t.r=2.5*r,t.stroke="#333",t.strokeWidth=1.5):v.isActive&&(t.opacity=.6*l):y.isActive&&!y.predicate(e)&&(t.opacity=h),t},[s,a,l,r,f,y.isActive,y.predicate,v.isActive,v.predicate,h]);return d.createElement("div",{style:{position:"relative",width:i,height:i}},d.createElement(qe,{ref:p,chartType:"scatter",data:t,size:[i,i],xAccessor:n,yAccessor:o,pointStyle:w,margin:Jt,showAxes:!1,enableHover:"hover"===f,customHoverBehavior:"hover"===f?k:void 0,tooltipContent:"hover"===f?()=>null:void 0}),"brush"===f&&d.createElement(en,{frameRef:p,cellSize:i,xField:n,yField:o,onBrush:x}))}function nn({data:t,field:n,label:o,cellSize:i,bins:r,colorBy:l,colorScale:s,brushSelectionName:a,hoverSelectionName:c,mode:u}){const h=tt({name:a,clientId:"splom-diag-"+n}),f=tt({name:c,clientId:`splom-diag-${n}-hover`}),g="hover"===u?f:h,p=g.isActive,y=g.predicate,m=e.useMemo(()=>{const e=t.map(e=>e[n]).filter(e=>null!=e&&!isNaN(e));if(0===e.length)return{bars:[],selectedBars:[],categoryBars:[],selectedCategoryBars:[],max:0,categories:[]};const o=Math.min(...e),s=(Math.max(...e)-o)/r||1,a="string"==typeof l?l:null,c=a?[...new Set(t.map(e=>e[a]).filter(e=>null!=e).map(String))]:[],u=new Map(c.map((e,t)=>[e,t])),h=Array(r).fill(0),d=Array(r).fill(0),f=Array.from({length:r},()=>Array(c.length).fill(0)),g=Array.from({length:r},()=>Array(c.length).fill(0));for(const e of t){const t=e[n];if(null==t||isNaN(t))continue;const i=Math.min(Math.floor((t-o)/s),r-1);if(h[i]++,p&&!y(e)||d[i]++,a){const t=u.get(e[a]+"");void 0!==t&&(f[i][t]++,p&&!y(e)||g[i][t]++)}}const m=Math.max(...h,1),v=f.map((e,t)=>{let n=0;return e.map((e,o)=>{const l=e/m*(i-24),s={x:t/r*i,w:i/r-1,h:l,y0:n,category:c[o]};return n+=l,s})}),b=g.map((e,t)=>{let n=0;return e.map((e,o)=>{const l=e/m*(i-24),s={x:t/r*i,w:i/r-1,h:l,y0:n,category:c[o]};return n+=l,s})});return{bars:h.map((e,t)=>({x:t/r*i,w:i/r-1,h:e/m*(i-24),count:e})),selectedBars:d.map((e,t)=>({x:t/r*i,w:i/r-1,h:e/m*(i-24),count:e})),categoryBars:v,selectedCategoryBars:b,max:m,categories:c}},[t,n,r,i,p,y,l]);return d.createElement("svg",{width:i,height:i,style:{overflow:"hidden"}},d.createElement("text",{x:i/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:i-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:s?s(e.category):ht,opacity:p?.3:.6}))):m.bars.map((e,t)=>d.createElement("rect",{key:"bg-"+t,x:e.x,y:i-e.h,width:Math.max(e.w,1),height:e.h,fill:ht,opacity:p?.3:.6})),p&&(m.categories.length>0?m.selectedCategoryBars.map((e,t)=>e.map((e,n)=>d.createElement("rect",{key:`sel-${t}-${n}`,x:e.x,y:i-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:s?s(e.category):ht,opacity:.7}))):m.selectedBars.map((e,t)=>d.createElement("rect",{key:"sel-"+t,x:e.x,y:i-e.h,width:Math.max(e.w,1),height:e.h,fill:ht,opacity:.7}))))}function on({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 rn(t){const{data:n,fields:o,fieldLabels:i={},colorBy:r,colorScheme:l="category10",cellSize:s=150,cellGap:a=4,pointRadius:c=2,pointOpacity:u=.5,diagonal:h="histogram",histogramBins:f=20,brushMode:g="crossfilter",hoverMode:p=!0,unselectedOpacity:y=.1,showGrid:m=!1,tooltip:v,showLegend:b,idAccessor:x,className:k,onObservation:w,chartId:A}=t,M="splom",S="splom-hover",E=p?"hover":g?"brush":"hover",O=Ze(e=>e.clearSelection),[C,j]=e.useState(null),P=e.useCallback(()=>{O(S),j(null)},[O,S]),_=e.useMemo(()=>(n||[]).map((e,t)=>void 0!==e[Zt]?e:Object.assign(Object.assign({},e),{[Zt]:t})),[n]),L=ft(_,r,l),B=void 0!==b?b:!!r,N=e.useMemo(()=>{if(!B||!r)return null;const e="string"==typeof r?r:null;return e?[...new Set(_.map(t=>t[e]))].map(e=>({label:e+"",color:L?L(e+""):ht})):null},[B,r,_,L]),H=e.useMemo(()=>({display:"grid",gridTemplateColumns:"40px "+o.map(()=>s+"px").join(" "),gridTemplateRows:o.map(()=>s+"px").join(" ")+" 40px",gap:a+"px",width:"fit-content"}),[o,s,a,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"===E?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"}},i[e]||e),o.map((n,o)=>t===o?"label"===h?d.createElement(on,{key:"diag-"+e,label:i[e]||e,cellSize:s}):d.createElement(nn,{key:"diag-"+e,data:_,field:e,label:i[e]||e,cellSize:s,bins:f,colorBy:r,colorScale:L,brushSelectionName:M,hoverSelectionName:S,unselectedOpacity:y,mode:E}):d.createElement(tn,{key:`cell-${e}-${n}`,data:_,xField:n,yField:e,fieldLabels:i,cellSize:s,pointRadius:c,pointOpacity:u,colorBy:r,colorScale:L,brushSelectionName:M,hoverSelectionName:S,unselectedOpacity:y,showGrid:m,tooltip:v,mode:E,onPointHover:"hover"===E?(i,r,l)=>{i?(j({datum:i,xField:n,yField:e,colIndex:o,rowIndex:t,px:null!=r?r:0,py:null!=l?l:0}),w&&w({type:"hover",datum:i,x:null!=r?r:0,y:null!=l?l:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A})):(j(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"}},i[e]||e))),C&&"hover"===E&&(()=>{const e=C.datum,t=i[C.xField]||C.xField,n=i[C.yField]||C.yField,o=r?"function"==typeof r?r(e):e[r]:null,l=x?"function"==typeof x?x(e):e[x]:"Row "+e[Zt];return d.createElement("div",{style:{position:"absolute",left:40+C.colIndex*(s+a)+C.px,top:C.rowIndex*(s+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}},d.createElement("div",{style:{fontWeight:"bold",marginBottom:2}},l+""),d.createElement("div",null,t,": ",null!=e[C.xField]?Number(e[C.xField]).toFixed(1):"–"),d.createElement("div",null,n,": ",null!=e[C.yField]?Number(e[C.yField]).toFixed(1):"–"),null!=o&&d.createElement("div",{style:{opacity:.8}},"string"==typeof r?r:"group",": ",o+""))})())}function ln(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(st,{selections:o},d.createElement(rn,Object.assign({},e)))}function sn({width:o,height:i,margin:r,scales:l,brushDirection:s,extent:a,onBrush:c}){const u=e.useRef(null),h=e.useRef(null),f=e.useRef(!1),g=o+r.left+r.right,p=i+r.top+r.bottom;return e.useEffect(()=>{if(!u.current||!l)return;const e=n.select(u.current).select(".brush-group"),r="x"===s?t.brushX().extent([[0,0],[o,i]]):t.brushY().extent([[0,0],[o,i]]);return r.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"===s?l.x:l.y).invert;if(!n)return;const o=[n(t[0]),n(t[1])];c(o)}),e.call(r),h.current=r,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null)}},[l,o,i,s,c]),e.useEffect(()=>{if(!h.current||!l||!u.current)return;const e=n.select(u.current).select(".brush-group"),t="x"===s?l.x:l.y;if(f.current=!0,a){const n=[t(a[0]),t(a[1])];e.call(h.current.move,n)}else e.call(h.current.move,null);f.current=!1},[a,l,s]),d.createElement("svg",{ref:u,width:g,height:p,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},d.createElement("g",{className:"brush-group",transform:`translate(${r.left},${r.top})`}))}function an(t){var n,o;const{data:i,width:r=600,height:l=400,margin:s,className:a,title:c,xLabel:u,yLabel:h,xFormat:f,yFormat:g,xAccessor:p="x",yAccessor:y="y",lineBy:m,lineDataAccessor:v="coordinates",colorBy:b,colorScheme:x="category10",curve:k="linear",lineWidth:w=2,fillArea:A=!1,areaOpacity:M=.3,showPoints:S=!1,pointRadius:E=3,enableHover:O=!0,showGrid:C=!1,showLegend:j,legendPosition:_,tooltip:L,minimap:B={},renderBefore:N=!1,onBrush:H,brushExtent:W,frameProps:z={},loading:T,emptyContent:F}=t,I=Wt(T,r,l);if(I)return I;const $=Ht(i,r,l,F);if($)return $;const D=i||[],[R,G]=e.useState(null),Y=null!=W?W:R,q=e.useCallback(e=>{W||G(e),null==H||H(e)},[W,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)},[i]);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=ft(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=M),t},[b,J,w,A,M]),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(S)return e=>{const t={r:E,fillOpacity:1};return t.fill=b?P(e.parentLine||e,b,J):ht,t}},[S,E,b,J]),{legend:oe,margin:ie,legendPosition:re}=pt({data:K,colorBy:b,colorScale:J,showLegend:j,legendPosition:_,userMargin:s}),le=B.height||60,se=e.useMemo(()=>{var e,t,n,o,i,r,l,s;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!==(r=null===(i=B.margin)||void 0===i?void 0:i.left)&&void 0!==r?r:ie.left,right:null!==(s=null===(l=B.margin)||void 0===l?void 0:l.right)&&void 0!==s?s:ie.right}},[B.margin,ie]),ae=B.brushDirection||"x",ce=It({componentName:"MinimapChart",data:i,accessors:{xAccessor:p,yAccessor:y}});if(ce)return d.createElement(Ct,{componentName:"MinimapChart",message:ce,width:r,height:l});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:p,yAccessor:y,groupAccessor:m||void 0,curve:k,lineStyle:ee},S&&{pointStyle:ne}),{size:[r,l],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ie,showAxes:!0,xLabel:u,yLabel:h,xFormat:f,yFormat:g,enableHover:O,showGrid:C}),oe&&{legend:oe,legendPosition:re}),c&&{title:c}),L&&{tooltipContent:At(L)||void 0}),Y&&{xExtent:Y}),z),de={chartType:ue,data:Z,xAccessor:p,yAccessor:y,groupAccessor:m||void 0,curve:k,lineStyle:te,size:[r,le+se.top+se.bottom],margin:se,showAxes:null!==(o=B.showAxes)&&void 0!==o&&o,background:B.background,enableHover:!1},fe=d.createElement("div",{key:"minimap",style:{position:"relative",width:r,overflow:"hidden"}},d.createElement(qe,Object.assign({ref:X},de)),d.createElement(sn,{width:r-se.left-se.right,height:le,margin:se,scales:V,brushDirection:ae,extent:Y,onBrush:q})),ge=d.createElement("div",{key:"main",style:{overflow:"hidden"}},d.createElement(qe,Object.assign({},he)));return d.createElement(Lt,{componentName:"MinimapChart",width:r,height:l},d.createElement("div",{className:"minimap-chart"+(a?" "+a:"")},N?fe:ge,N?ge:fe))}ln.displayName="ScatterplotMatrix",an.displayName="MinimapChart";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 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:r,margin:l,className:s,xFormat:a,yFormat:c,xAccessor:u="x",yAccessor:h="y",xCenter:f,yCenter:g,quadrants:p,centerlineStyle:y={},showQuadrantLabels:m=!0,quadrantLabelSize:v=12,colorBy:b,colorScheme:x="category10",sizeBy:k,sizeRange:w=[3,15],pointRadius:A=5,pointOpacity:M=.8,tooltip:S,pointIdAccessor:E,annotations:O,frameProps:C={},selection:j,linkedHover:_,onObservation:B,chartId:N,loading:H,emptyContent:W,legendInteraction:z,legendPosition:T}=t,F=i.width,I=i.height,$=i.enableHover,D=i.showGrid,R=i.showLegend,G=i.title,Y=i.xLabel,q=i.yLabel,X=Wt(H,F,I);if(X)return X;const V=Ht(r,F,I,W);if(V)return V;const Q=r||[];zt("QuadrantChart",Q,"xAccessor",u),zt("QuadrantChart",Q,"yAccessor",h);const{activeSelectionHook:U,customHoverBehavior:K}=gt({selection:j,linkedHover:_,fallbackFields:"string"==typeof b?[b]:[],onObservation:B,chartType:"QuadrantChart",chartId:N}),Z=ft(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=yt(z,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,i=1/0,r=-1/0;for(const l of Q){const s=e(l),a=t(l);isFinite(s)&&(n>s&&(n=s),s>o&&(o=s)),isFinite(a)&&(i>a&&(i=a),a>r&&(r=a))}if(null!=f&&isFinite(f)&&(n>f&&(n=f),f>o&&(o=f)),null!=g&&isFinite(g)&&(i>g&&(i=g),g>r&&(r=g)),n===1/0)return;const l=.1*(o-n)||1,s=.1*(r-i)||1;return{xExtent:[n-l,o+l],yExtent:[i-s,r+s]}},[Q,u,h,f,g]),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]),ie=e.useMemo(()=>"function"==typeof u?u:e=>+e[u],[u]),re=e.useMemo(()=>"function"==typeof h?h:e=>+e[h],[h]),le=e.useMemo(()=>e=>{const t={fillOpacity:M};if(b)Z&&(t.fill=P(e,b,Z));else{const n=ie(e),o=re(e),i=null!=f?n>=f:void 0,r=null!=g?o>=g:void 0;t.fill=void 0===r||void 0===i?ht:r&&i?p.topRight.color:r&&!i?p.topLeft.color:!r&&i?p.bottomRight.color:p.bottomLeft.color}return t.r=k?L(e,k,w,oe):A,t},[b,Z,k,w,oe,A,M,ie,re,f,g,p]),se=e.useMemo(()=>ut(le,te,j),[le,te,j]),{legend:ae,margin:ce,legendPosition:ue}=pt({data:Q,colorBy:b,colorScale:Z,showLegend:R,legendPosition:T,userMargin:l,defaults:i.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(()=>Ot([...he?[{label:he,accessor:he,role:"title"}]:[],{label:Y||Mt(u),accessor:u,role:"x"},{label:q||Mt(h),accessor:h,role:"y"},...b?[{label:Mt(b),accessor:b,role:"color"}]:[],...k?[{label:Mt(k),accessor:k,role:"size"}]:[]]),[he,u,h,Y,q,b,k]),fe=It({componentName:"QuadrantChart",data:r,accessors:{xAccessor:u,yAccessor:h}});if(fe)return d.createElement(Ct,{componentName:"QuadrantChart",message:fe,width:F,height:I});const ge=e.useMemo(()=>{var e;const t={stroke:y.stroke||"#999",strokeWidth:null!==(e=y.strokeWidth)&&void 0!==e?e:1,dashArray:y.strokeDasharray||[]};return[(e,n,o,i)=>{var r;if(!(null==o?void 0:o.x)||!(null==o?void 0:o.y))return;const l=i.width,s=i.height,a=null!=f?o.x(f):l/2,c=null!=g?o.y(g):s/2;if(null!=f&&!isFinite(a))return;if(null!=g&&!isFinite(c))return;const u=Math.max(0,Math.min(l,a)),h=Math.max(0,Math.min(s,c)),d=[{config:p.topLeft,x:0,y:0,w:u,h:h},{config:p.topRight,x:u,y:0,w:l-u,h:h},{config:p.bottomLeft,x:0,y:h,w:u,h:s-h},{config:p.bottomRight,x:u,y:h,w:l-u,h:s-h}];for(const t of d)t.w>0&&t.h>0&&(e.fillStyle=t.config.color,e.globalAlpha=null!==(r=t.config.opacity)&&void 0!==r?r:.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,s),e.stroke(),e.beginPath(),e.moveTo(0,h),e.lineTo(l,h),e.stroke(),e.setLineDash([])}]},[f,g,p,y]),pe=e.useMemo(()=>m?[...ge,(e,t,n,o)=>{if(!(null==n?void 0:n.x)||!(null==n?void 0:n.y))return;const i=o.width,r=o.height,l=null!=f?n.x(f):i/2,s=null!=g?n.y(g):r/2;(null==f||isFinite(l))&&(null==g||isFinite(s))&&(e.font=`600 ${v}px sans-serif`,e.globalAlpha=.5,e.fillStyle=p.topLeft.color,e.textAlign="left",e.textBaseline="top",e.fillText(p.topLeft.label,8,8),e.fillStyle=p.topRight.color,e.textAlign="right",e.textBaseline="top",e.fillText(p.topRight.label,i-8,8),e.fillStyle=p.bottomLeft.color,e.textAlign="left",e.textBaseline="bottom",e.fillText(p.bottomLeft.label,8,r-8),e.fillStyle=p.bottomRight.color,e.textAlign="right",e.textBaseline="bottom",e.fillText(p.bottomRight.label,i-8,r-8),e.globalAlpha=1)}]:ge,[ge,m,v,p,f,g]),ye=e.useMemo(()=>{const e=C.canvasPreRenderers||[];return[...pe,...e]},[pe,C.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!=r&&{data:Q}),{xAccessor:u,yAccessor:h,colorAccessor:b||void 0,sizeAccessor:k||void 0,sizeRange:w,pointStyle:se,colorScheme:x,size:[F,I],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ce,showAxes:i.showAxes,xLabel:Y,yLabel:q,xFormat:a,yFormat:c,enableHover:$,showGrid:D}),ne&&{xExtent:ne.xExtent,yExtent:ne.yExtent}),ae&&{legend:ae,legendPosition:ue}),z&&"none"!==z&&{legendHoverBehavior:ee.onLegendHover,legendClickBehavior:ee.onLegendClick,legendHighlightedCategory:ee.highlightedCategory,legendIsolatedCategories:ee.isolatedCategories}),G&&{title:G}),s&&{className:s}),{tooltipContent:!1===S?()=>null:!0===S||void 0===S?de:At(S)||de}),(_||B)&&{customHoverBehavior:K}),E&&{pointIdAccessor:E}),O&&O.length>0&&{annotations:O}),{canvasPreRenderers:ye}),C),ye.length>0&&{canvasPreRenderers:ye});return d.createElement(Lt,{componentName:"QuadrantChart",width:F,height:I},d.createElement(qe,Object.assign({ref:o},me)))});cn.displayName="QuadrantChart";const un="__forecastSegment";function hn(e,t){return"function"==typeof t?t(e):!!e[t]}const dn=Object.freeze({__proto__:null,SEGMENT_FIELD:un,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,i){return(r=o).isTraining||r.isForecast||r.isAnomaly||r.upperBounds||r.lowerBounds?function(e,t,n,o,i){var r,l,s;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,v=e.map(e=>{let t="observed";return c&&hn(e,c)?t="forecast":a&&hn(e,a)&&(t="training"),Object.assign(Object.assign({},e),{[un]:t})}),b=[];for(let e=0;v.length>e;e++)b.push(v[e]),v.length-1>e&&v[e][un]!==v[e+1][un]&&b.push(Object.assign(Object.assign({},v[e]),{[un]:v[e+1][un]}));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:f,fillOpacity:g,label:m})}return u&&x.push({type:"highlight",filter:e=>hn(e,u),color:p,r:y,style:{stroke:p,strokeWidth:1.5,fill:p,fillOpacity:.7}}),i&&x.push({type:"anomaly-band",threshold:null!==(r=i.threshold)&&void 0!==r?r:2,showBand:!1!==i.showBand,fill:i.bandColor||"#6366f1",fillOpacity:null!==(l=i.bandOpacity)&&void 0!==l?l:.1,anomalyColor:i.anomalyColor||"#ef4444",anomalyRadius:null!==(s=i.anomalyRadius)&&void 0!==s?s:6,label:i.label}),{processedData:b,annotations:x}}(e,0,0,o,i):function(e,t,n,o,i){var r,l,s;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),{[un]:"observed"})):g.push(Object.assign(Object.assign({},n),{[un]:"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=[],v=[];if(y.length>=3){const o=y.length;let i=0,r=0,l=0,s=0;for(const[e,t]of y)i+=e,r+=t,l+=e*e,s+=e*t;const a=o*l-i*i;if(Math.abs(a)>1e-12){const l=(o*s-i*r)/a,g=(r-l*i)/o,p=e=>g+l*e,b=y.map(([e,t])=>t-p(e)).reduce((e,t)=>e+t*t,0),x=Math.sqrt(b/Math.max(o-2,1)),k=y.reduce((e,t)=>e+t[0],0)/o,w=y.reduce((e,t)=>e+Math.pow(t[0]-k,2),0),A=.99>u?.95>u?.9>u?1:1.645:1.96:2.576,M=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),S=Math.max(...M),E=y.length>1?(y[o-1][0]-y[0][0])/(o-1):1;for(let e=1;c>=e;e++){const i=S+e*E,r=p(i),l=x*Math.sqrt(1+1/o+(w>0?Math.pow(i-k,2)/w:0))*A;v.push({[t]:i,[n]:r,[un]:"forecast",__forecastUpper:r+l,__forecastLower:r-l})}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"}),i&&m.push({type:"anomaly-band",threshold:null!==(r=i.threshold)&&void 0!==r?r:2,showBand:!1!==i.showBand,fill:i.bandColor||"#6366f1",fillOpacity:null!==(l=i.bandOpacity)&&void 0!==l?l:.1,anomalyColor:i.anomalyColor||"#ef4444",anomalyRadius:null!==(s=i.anomalyRadius)&&void 0!==s?s:6,label:i.label});const b=[];if(b.push(...g),g.length>0&&p.length>0&&b.push(Object.assign(Object.assign({},g[g.length-1]),{[un]:"observed"})),b.push(...p),v.length>0){const e=p.length>0?p[p.length-1]:g[g.length-1];e&&b.push(Object.assign(Object.assign({},e),{[un]:"forecast"})),b.push(...v)}return{processedData:b,annotations:m}}(e,t,n,o,i);var r},createSegmentLineStyle:function(e,t){var n,o;const i=null!==(n=t.trainDasharray)&&void 0!==n?n:"8,4",r=null!==(o=t.forecastDasharray)&&void 0!==o?o:"4,4",l=t.color||"#6366f1";return t=>{const n=e(t),o=t[un];return"training"===o?Object.assign(Object.assign({},n),{strokeDasharray:i}):"forecast"===o?Object.assign(Object.assign({},n),{stroke:l,strokeDasharray:r}):n}}});exports.AreaChart=Yt,exports.BubbleChart=Ut,exports.ConnectedScatterplot=Qt,exports.Heatmap=Kt,exports.LineChart=Gt,exports.MinimapChart=an,exports.QuadrantChart=cn,exports.Scatterplot=Xt,exports.ScatterplotMatrix=ln,exports.StackedAreaChart=qt,exports.StreamXYFrame=qe;
|