semiotic 3.1.2 → 3.2.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.
Files changed (82) hide show
  1. package/CLAUDE.md +134 -216
  2. package/LICENSE +197 -10
  3. package/README.md +1 -0
  4. package/ai/dist/componentRegistry.js +6 -0
  5. package/ai/dist/mcp-server.js +115 -5
  6. package/ai/examples.md +93 -0
  7. package/ai/schema.json +3916 -878
  8. package/ai/system-prompt.md +27 -0
  9. package/dist/components/ThemeProvider.d.ts +5 -3
  10. package/dist/components/charts/geo/ChoroplethMap.d.ts +1 -1
  11. package/dist/components/charts/index.d.ts +8 -1
  12. package/dist/components/charts/ordinal/BarChart.d.ts +1 -0
  13. package/dist/components/charts/ordinal/BoxPlot.d.ts +1 -0
  14. package/dist/components/charts/ordinal/DonutChart.d.ts +1 -0
  15. package/dist/components/charts/ordinal/DotPlot.d.ts +1 -0
  16. package/dist/components/charts/ordinal/FunnelChart.d.ts +55 -0
  17. package/dist/components/charts/ordinal/GroupedBarChart.d.ts +1 -0
  18. package/dist/components/charts/ordinal/Histogram.d.ts +1 -0
  19. package/dist/components/charts/ordinal/PieChart.d.ts +1 -0
  20. package/dist/components/charts/ordinal/RidgelinePlot.d.ts +1 -0
  21. package/dist/components/charts/ordinal/StackedBarChart.d.ts +1 -0
  22. package/dist/components/charts/ordinal/SwarmPlot.d.ts +1 -0
  23. package/dist/components/charts/ordinal/ViolinPlot.d.ts +1 -0
  24. package/dist/components/charts/shared/colorManipulation.d.ts +15 -0
  25. package/dist/components/charts/shared/formatUtils.d.ts +28 -0
  26. package/dist/components/charts/shared/hatchPattern.d.ts +35 -0
  27. package/dist/components/charts/shared/hooks.d.ts +16 -1
  28. package/dist/components/charts/shared/legendUtils.d.ts +2 -1
  29. package/dist/components/charts/shared/selectionUtils.d.ts +11 -0
  30. package/dist/components/charts/shared/statisticalOverlays.d.ts +49 -5
  31. package/dist/components/charts/shared/types.d.ts +4 -1
  32. package/dist/components/charts/xy/Heatmap.d.ts +1 -1
  33. package/dist/components/charts/xy/MultiAxisLineChart.d.ts +71 -0
  34. package/dist/components/realtime/types.d.ts +2 -0
  35. package/dist/components/semiotic-ai.d.ts +3 -0
  36. package/dist/components/semiotic-ordinal.d.ts +3 -0
  37. package/dist/components/semiotic-themes.d.ts +64 -0
  38. package/dist/components/semiotic-xy.d.ts +1 -0
  39. package/dist/components/semiotic.d.ts +11 -5
  40. package/dist/components/store/ThemeStore.d.ts +22 -2
  41. package/dist/components/stream/OrdinalSVGOverlay.d.ts +1 -0
  42. package/dist/components/stream/PipelineStore.d.ts +2 -0
  43. package/dist/components/stream/SVGOverlay.d.ts +5 -3
  44. package/dist/components/stream/accessorUtils.d.ts +14 -0
  45. package/dist/components/stream/networkTypes.d.ts +2 -0
  46. package/dist/components/stream/ordinalSceneBuilders/barFunnelScene.d.ts +27 -0
  47. package/dist/components/stream/ordinalSceneBuilders/funnelScene.d.ts +26 -0
  48. package/dist/components/stream/ordinalTypes.d.ts +16 -2
  49. package/dist/components/stream/renderers/barFunnelCanvasRenderer.d.ts +12 -0
  50. package/dist/components/stream/renderers/trapezoidCanvasRenderer.d.ts +15 -0
  51. package/dist/components/stream/sceneUtils.d.ts +10 -0
  52. package/dist/components/stream/types.d.ts +10 -3
  53. package/dist/geo.min.js +1 -1
  54. package/dist/geo.module.min.js +1 -1
  55. package/dist/network.min.js +1 -1
  56. package/dist/network.module.min.js +1 -1
  57. package/dist/ordinal.min.js +1 -1
  58. package/dist/ordinal.module.min.js +1 -1
  59. package/dist/realtime.min.js +1 -1
  60. package/dist/realtime.module.min.js +1 -1
  61. package/dist/semiotic-ai-statisticalOverlays-C2PPlmXv.js +1 -0
  62. package/dist/semiotic-ai.d.ts +3 -0
  63. package/dist/semiotic-ai.min.js +1 -1
  64. package/dist/semiotic-ai.module.min.js +1 -1
  65. package/dist/semiotic-ordinal.d.ts +3 -0
  66. package/dist/semiotic-statisticalOverlays-D8LhSbQt.js +1 -0
  67. package/dist/semiotic-themes.d.ts +64 -0
  68. package/dist/semiotic-themes.min.js +1 -0
  69. package/dist/semiotic-themes.module.min.js +1 -0
  70. package/dist/semiotic-xy.d.ts +1 -0
  71. package/dist/semiotic.d.ts +11 -5
  72. package/dist/semiotic.min.js +1 -1
  73. package/dist/semiotic.module.min.js +1 -1
  74. package/dist/server.min.js +1 -1
  75. package/dist/server.module.min.js +1 -1
  76. package/dist/xy-statisticalOverlays-C2PPlmXv.js +1 -0
  77. package/dist/xy.min.js +1 -1
  78. package/dist/xy.module.min.js +1 -1
  79. package/package.json +24 -5
  80. package/dist/semiotic-ai-statisticalOverlays-C1f7TYyD.js +0 -1
  81. package/dist/semiotic-statisticalOverlays-C1f7TYyD.js +0 -1
  82. package/dist/xy-statisticalOverlays-C1f7TYyD.js +0 -1
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"),r=require("d3-scale-chromatic"),i=require("d3-quadtree"),s=require("d3-array"),a=require("d3-hierarchy"),l=require("d3-shape"),c=require("regression");function u(e){return e&&e.__esModule?e:{default:e}}function h(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}return t.default=e,Object.freeze(t)}const d=h(e),g=u(c);class p{constructor(e,t){var n,o;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=null!==(n=null==t?void 0:t.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(o=null==t?void 0:t.chunkSize)&&void 0!==o?o:5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const o=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){this.pushBuffer.push(e),this.scheduleFlush()}pushMany(e){if(0!==e.length){for(let t=0;e.length>t;t++)this.pushBuffer.push(e[t]);this.scheduleFlush()}}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}class y{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class f{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function m(e,t,n,o,r){const i=new Map;for(const s of e){const e=t(s),a=n(s);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const l=Math.floor(e/o)*o;let c=i.get(l);if(c||(c={start:l,end:l+o,total:0,categories:new Map},i.set(l,c)),c.total+=a,r){const e=r(s);c.categories.set(e,(c.categories.get(e)||0)+a)}}return i}function v(e,t,n,o,r,i){const s=[];for(const r of e){const e=n(r),i=o(r);null==e||null==i||Number.isNaN(e)||Number.isNaN(i)||s.push({px:t.x(e),py:t.y(i),rawY:i,d:r})}s.sort((e,t)=>e.px-t.px);const a=Array(s.length),l=Array(s.length),c=Array(s.length);for(let e=0;s.length>e;e++){const t=s[e];a[e]=[t.px,t.py],l[e]=t.rawY,c[e]=t.d}return{type:"line",path:a,rawValues:l,style:r,datum:c,group:i}}function b(e,t,n,o,r,i,s,a){const l=[];for(const i of e){const e=n(i),s=o(i);if(null==e||null==s||Number.isNaN(e)||Number.isNaN(s))continue;const c=t.x(e),u=a?a(i):r;l.push({px:c,topY:t.y(s),botY:t.y(u)})}l.sort((e,t)=>e.px-t.px);const c=Array(l.length),u=Array(l.length);for(let e=0;l.length>e;e++){const t=l[e];c[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:c,bottomPath:u,style:i,datum:e,group:s}}function x(e,t,n,o,r,i,s){const a=n(e),l=o(e);if(null==a||null==l||Number.isNaN(a)||Number.isNaN(l))return null;const c={type:"point",x:t.x(a),y:t.y(l),r:r,style:i,datum:e};return void 0!==s&&(c.pointId=s),c}function k(e,t,n,o,r,i,s){return{type:"rect",x:e,y:t,w:n,h:o,style:r,datum:i,group:s}}function w(e,t,n,o,r,i,s){const a={type:"heatcell",x:e,y:t,w:n,h:o,fill:r,datum:i};return(null==s?void 0:s.showValues)&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function A(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function S(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function O(e,t){return"function"==typeof e?e:e?t=>t[e]+"":void 0}const M={category10:r.schemeCategory10,tableau10:r.schemeTableau10,set3:r.schemeSet3,blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,oranges:r.interpolateOranges,purples:r.interpolatePurples,viridis:r.interpolateViridis,plasma:r.interpolatePlasma},E=r.schemeCategory10,j=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],C=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function P(e,t,n){if("function"==typeof t){const o=t(e);return n&&o&&"string"==typeof o&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||C.has(t)}(o)?n(o):o}const o=e[t];return n?n(o):E[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(o+""))%E.length]}function _(e,t,n="category10"){const r=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e))),i=r.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return o.scaleOrdinal().domain(r).range(n).unknown("#999");const s=M[n]||M.category10;if(i&&"function"==typeof s){let e=-1/0;for(const t of r){const n=Number(t);n>e&&(e=n)}return t=>s(Number(t)/e)}{const e=Array.isArray(s)?s:E;return o.scaleOrdinal().domain(r).range(e).unknown("#999")}}function L(e,t,n=[3,20],o){let r;if(r="function"==typeof t?t(e):e[t],!o)return r;const[i,s]=o,[a,l]=n;return s===i?(a+l)/2:a+(r-i)/(s-i)*(l-a)}function B(e,t,n){return e+(t-e)*n}class N{constructor(e){this.xExtent=new f,this.yExtent=new f,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this._quadtree=null,this.config=e,this.buffer=new y(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=A(e.timeAccessor||e.xAccessor,"time"),this.getY=A(e.valueAccessor||e.yAccessor,"value")):(this.getX=A(e.xAccessor,"x"),this.getY=A(e.yAccessor,"y")),this.getGroup=O(e.groupAccessor),this.getCategory=O(e.categoryAccessor),this.getSize=e.sizeAccessor?A(e.sizeAccessor,"size"):void 0,this.getColor=O(e.colorAccessor),this.getBounds=e.boundsAccessor?A(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?A(e.y0Accessor,"y0"):void 0,this.getPointId=O(e.pointIdAccessor),"candlestick"===e.chartType&&(this.getOpen=A(e.openAccessor,"open"),this.getHigh=A(e.highAccessor,"high"),this.getLow=A(e.lowAccessor,"low"),this.getClose=A(e.closeAccessor,"close")),e.pulse&&(this.timestampBuffer=new y(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n)))}else for(const n of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity||1e6;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n))),null!=e&&(this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):this.yExtent.evict(this.getY(e)))}return!0}computeScene(e){var t,n,r,i,s,a;const{config:l,buffer:c}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);if(this.xExtent.dirty&&this.xExtent.recalculate(c,this.getX),this.yExtent.dirty)if("candlestick"===l.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of c)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(c,this.getY);const u=this.getBufferArray(),h=this.xExtent.extent,d=this.yExtent.extent;let g=l.xExtent?[null!==(t=l.xExtent[0])&&void 0!==t?t:h[0],null!==(n=l.xExtent[1])&&void 0!==n?n:h[1]]:h,p=l.yExtent?[null!==(r=l.yExtent[0])&&void 0!==r?r:d[0],null!==(i=l.yExtent[1])&&void 0!==i?i:d[1]]:d;const y=l.yExtent&&null!=l.yExtent[0]&&null!=l.yExtent[1];if("stackedarea"===l.chartType&&!y&&c.size>0)if(l.normalize)p=[0,1+l.extentPadding];else{const e=`${c.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===e)p=this._stackExtentCache.yDomain;else{const t=this.groupData(u),n=new Map;for(const e of t)for(const t of e.data){const e=this.getX(t),o=this.getY(t);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||n.set(e,(n.get(e)||0)+o)}let o=0;for(const e of n.values())e>o&&(o=e);p=[0,o+(o>0?o*l.extentPadding:1)],this._stackExtentCache={key:e,yDomain:p}}}else if("bar"===l.chartType&&l.binSize&&!y&&c.size>0){const[,e]=function(e,t,n,o,r){const i=m(e,t,n,o,r);if(0===i.size)return[0,0];let s=0;for(const e of i.values())e.total>s&&(s=e.total);return[0,s]}(c,this.getX,this.getY,l.binSize,this.getCategory);p=[0,e+e*l.extentPadding]}else if("waterfall"===l.chartType&&!y&&c.size>0){const[e,t]=function(e,t){let n=0,o=0,r=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(r+=e,n>r&&(n=r),r>o&&(o=r))}return[n,o]}(c,this.getY),n=t-e,o=n>0?n*l.extentPadding:1;p=[Math.min(0,e-Math.abs(o)),Math.max(0,t+Math.abs(o))]}else if(!y&&p[0]!==1/0){if(this.getBounds)for(const e of u){const t=this.getY(e),n=this.getBounds(e);null!=t&&!Number.isNaN(t)&&n&&(t+n>p[1]&&(p[1]=t+n),p[0]>t-n&&(p[0]=t-n))}const e=p[1]-p[0],t=e>0?e*l.extentPadding:1,n=null===(s=l.yExtent)||void 0===s?void 0:s[0],o=null===(a=l.yExtent)||void 0===a?void 0:a[1];p=[null!=n?p[0]:p[0]-t,null!=o?p[1]:p[1]+t],"log"===l.yScaleType&&0>=p[0]&&d[0]>0&&(p[0]=null!=n?p[0]:d[0]/(1+l.extentPadding))}if(g[0]!==1/0&&g[1]!==-1/0||(g=[0,1]),p[0]!==1/0&&p[1]!==-1/0||(p=[0,1]),"streaming"===l.runtimeMode)if("x"==("up"===(f=l.arrowOfTime)||"down"===f?"y":"x")){const t="right"===l.arrowOfTime?[0,e.width]:[e.width,0];this.scales={x:o.scaleLinear().domain(g).range(t),y:o.scaleLinear().domain(p).range([e.height,0])}}else{const t="down"===l.arrowOfTime?[0,e.height]:[e.height,0];this.scales={x:o.scaleLinear().domain(p).range([0,e.width]),y:o.scaleLinear().domain(g).range(t)}}else{const t=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return o.scaleLog().domain(e).range(n).clamp(!0)}return o.scaleLinear().domain(t).range(n)};this.scales={x:t(l.xScaleType,g,[0,e.width]),y:t(l.yScaleType,p,[e.height,0])}}var f;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(e,u),this.config.decay&&this.applyDecay(this.scene,u),this.config.pulse&&this.applyPulse(this.scene,u),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}rebuildQuadtree(){const e=this.config.chartType;if("scatter"!==e&&"bubble"!==e)return void(this._quadtree=null);const t=this.scene.filter(e=>"point"===e.type);this._quadtree=t.length>N.QUADTREE_THRESHOLD?i.quadtree().x(e=>e.x).y(e=>e.y).addAll(t):null}get quadtree(){return this._quadtree}remapScene(e){const t=e.width/this.lastLayout.width,n=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const o of e.path)o[0]*=t,o[1]*=n;break;case"area":for(const o of e.topPath)o[0]*=t,o[1]*=n;for(const o of e.bottomPath)o[0]*=t,o[1]*=n;break;case"point":e.x*=t,e.y*=n;break;case"rect":case"heatcell":e.x*=t,e.y*=n,e.w*=t,e.h*=n;break;case"candlestick":e.x*=t,e.openY*=n,e.closeY*=n,e.highY*=n,e.lowY*=n}const r=this.scales.x.domain(),i=this.scales.y.domain(),s=this.scales.x.range(),a=this.scales.y.range(),l=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return o.scaleLog().domain(e).range(n).clamp(!0)}return o.scaleLinear().domain(t).range(n)};this.scales={x:l(this.config.xScaleType,r,[s[0]*t,s[1]*t]),y:l(this.config.yScaleType,i,[a[0]*n,a[1]*n])},this.lastLayout={width:e.width,height:e.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(e,t){const{config:n,scales:o}=this;if(!o||0===t.length)return[];switch(n.chartType){case"line":return this.buildLineScene(t);case"area":return this.buildAreaScene(t);case"stackedarea":return this.buildStackedAreaScene(t);case"scatter":case"bubble":return this.buildPointScene(t);case"heatmap":return this.buildHeatmapScene(t,e);case"bar":return this.buildBarScene(t);case"swarm":return this.buildSwarmScene(t);case"waterfall":return this.buildWaterfallScene(t,e);case"candlestick":return this.buildCandlestickScene(t,e);default:return[]}}buildLineScene(e){var t;const n=this.groupData(e),o=[],r=null===(t=this.config.annotations)||void 0===t?void 0:t.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(this.getBounds)for(const e of n){const t=this.buildBoundsForGroup(e.data,e.key);t&&o.push(t)}for(const e of n){const t=this.resolveLineStyle(e.key,e.data[0]),n=v(e.data,this.scales,this.getX,this.getY,t,e.key);r&&r.length>0&&(n.colorThresholds=r),this.config.curve&&"linear"!==this.config.curve&&(n.curve=this.config.curve),o.push(n)}return o}buildAreaScene(e){const t=this.groupData(e),n=[],o=this.scales.y.domain()[0];for(const e of t){const t=this.resolveAreaStyle(e.key,e.data[0]),r=b(e.data,this.scales,this.getX,this.getY,o,t,e.key,this.getY0);this.config.gradientFill&&(r.fillGradient=this.config.gradientFill),this.config.curve&&"linear"!==this.config.curve&&(r.curve=this.config.curve),n.push(r)}return n}buildStackedAreaScene(e){const t=this.groupData(e);return t.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0),function(e,t,n,o,r,i,s){var a;const l=new Set;for(const t of e)for(const e of t.data){const t=n(e);null==t||Number.isNaN(t)||l.add(t)}const c=Array.from(l).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const r of t.data){const t=n(r),i=o(r);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||e.set(t,(e.get(t)||0)+i)}u.set(t.key,e)}let h;if(i){h=new Map;for(const t of c){let n=0;for(const o of e)n+=(null===(a=u.get(o.key))||void 0===a?void 0:a.get(t))||0;h.set(t,n||1)}}const d=[],g=new Map;for(const e of c)g.set(e,0);for(const n of e){const e=u.get(n.key),o=[],a=[];for(const n of c){let r=e.get(n)||0;const s=g.get(n);i&&(r/=h.get(n));const l=t.x(n);a.push([l,t.y(s)]),o.push([l,t.y(s+r)]),g.set(n,s+r)}const l={type:"area",topPath:o,bottomPath:a,style:r(n.key,n.data[0]),datum:n.data,group:n.key};s&&(l.curve=s),d.push(l)}return d}(t,this.scales,this.getX,this.getY,(e,t)=>this.resolveAreaStyle(e,t),this.config.normalize,this.config.curve&&"linear"!==this.config.curve?this.config.curve:void 0)}buildPointScene(e){const t=[],n="bubble"===this.config.chartType?10:5,o=this.config.sizeRange||[3,15];let r=null;if(this.getSize&&!this.config.pointStyle){const t=e.map(e=>this.getSize(e)).filter(e=>null!=e&&!Number.isNaN(e));if(t.length>0){let e=1/0,n=-1/0;for(const o of t)e>o&&(e=o),o>n&&(n=o);r=t=>e===n?(o[0]+o[1])/2:o[0]+(t-e)/(n-e)*(o[1]-o[0])}}const i=this.getColor?this.resolveColorMap(e):null;for(const o of e){let e=this.config.pointStyle?this.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},s=e.r||n;if(r&&this.getSize){const e=this.getSize(o);null==e||Number.isNaN(e)||(s=r(e))}if(i&&this.getColor&&!e.fill){const t=this.getColor(o);t&&i.has(t)&&(e=Object.assign(Object.assign({},e),{fill:i.get(t)}))}const a=this.getPointId?this.getPointId(o)+"":void 0,l=x(o,this.scales,this.getX,this.getY,s,e,a);l&&t.push(l)}return t}buildHeatmapScene(e,t){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(e,t);const i=A(this.config.valueAccessor,"value"),s=S(this.config.xAccessor,"x"),a=S(this.config.yAccessor,"y"),l=new Set,c=new Set;for(const t of e)l.add(s(t)),c.add(a(t));const u=Array.from(l),h=Array.from(c),d=u.every(e=>"number"==typeof e&&!isNaN(e)),g=h.every(e=>"number"==typeof e&&!isNaN(e)),p=d?u.sort((e,t)=>e-t):u,y=g?h.sort((e,t)=>e-t):h;if(0===p.length||0===y.length)return n;const f=t.width/p.length,m=t.height/y.length,v=new Map;for(const t of e){const e=`${s(t)}\0${a(t)}`;v.set(e,{val:i(t),datum:t})}let b=1/0,x=-1/0;for(const{val:e}of v.values())b>e&&(b=e),e>x&&(x=e);const k=o.scaleSequential({blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,viridis:r.interpolateViridis}["string"==typeof this.config.colorScheme?this.config.colorScheme:"blues"]||r.interpolateBlues).domain([b,x]);for(let e=0;p.length>e;e++)for(let t=0;y.length>t;t++){const o=v.get(`${p[e]}\0${y[t]}`);if(!o)continue;const r=k(o.val);n.push(w(e*f,(y.length-1-t)*m,f,m,r,o.datum,this.config.showValues?{value:o.val,showValues:!0,valueFormat:this.config.heatmapValueFormat}:void 0))}return n}buildStreamingHeatmapScene(e,t){var n,o,r;const i=[],s=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,a=null!==(o=this.config.heatmapYBins)&&void 0!==o?o:20,l=null!==(r=this.config.heatmapAggregation)&&void 0!==r?r:"count",c=A(this.config.valueAccessor,"value");if(!this.scales||0===e.length)return i;const[u,h]=this.scales.x.domain(),[d,g]=this.scales.y.domain(),p=(h-u||1)/s,y=(g-d||1)/a,f=new Map;for(const t of e){const e=this.getX(t),n=this.getY(t),o=Math.min(Math.floor((e-u)/p),s-1),r=Math.min(Math.floor((n-d)/y),a-1);if(0>o||0>r)continue;const i=`${o}_${r}`;let l=f.get(i);l||(l={sum:0,count:0,data:[]},f.set(i,l)),l.count++,l.sum+=c(t),l.data.push(t)}let m=1/0,v=-1/0;const b=new Map;for(const[e,t]of f){let n;switch(l){case"sum":n=t.sum;break;case"mean":n=t.count>0?t.sum/t.count:0;break;default:n=t.count}b.set(e,n),m>n&&(m=n),n>v&&(v=n)}const x=v-m||1,k=t.width/s,S=t.height/a;for(const[e,t]of b){const[n,o]=e.split("_"),r=+n,s=+o,l=(t-m)/x,c=`rgb(${Math.round(220-180*l)},${Math.round(220-100*l)},${Math.round(255-50*l)})`,u=f.get(e);i.push(w(r*k,(a-1-s)*S,k,S,c,{xi:r,yi:s,value:t,count:u.count,sum:u.sum,data:u.data},this.config.showValues?{value:t,showValues:!0,valueFormat:this.config.heatmapValueFormat}:void 0))}return i}buildBarScene(e){var t;if(!this.config.binSize)return[];const n=m(e,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===n.size)return[];let o=null;if(this.getCategory){const e=new Set;for(const t of n.values())for(const n of t.categories.keys())e.add(n);const t=this.config.barColors?Object.keys(this.config.barColors):[],r=new Set(t),i=Array.from(e).filter(e=>!r.has(e)).sort(),s=t.filter(t=>e.has(t)),a=s.join("\0")+""+i.join("\0");this._barCategoryCache&&this._barCategoryCache.key===a?o=this._barCategoryCache.order:(o=[...s,...i],this._barCategoryCache={key:a,order:o})}const r=[],i=this.scales,[s,a]=i.x.domain();for(const e of n.values()){const n=Math.max(e.start,s),l=Math.min(e.end,a);if(n>=l)continue;const c=i.x(n),u=i.x(l),h=Math.abs(u-c),d=h>2?1:0,g=Math.min(c,u)+d/2,p=Math.max(h-d,1);if(p>0)if(o&&e.categories.size>0){let n=0;for(const s of o){const o=e.categories.get(s)||0;if(0===o)continue;const a=i.y(n),l=i.y(n+o);r.push(k(g,Math.min(a,l),p,Math.abs(a-l),{fill:(null===(t=this.config.barColors)||void 0===t?void 0:t[s])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:s,categoryValue:o},s)),n+=o}}else{const t=i.y(0),n=i.y(e.total);r.push(k(g,Math.min(t,n),p,Math.abs(t-n),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}return r}buildSwarmScene(e){var t,n,o,r;const i=[],s=this.config.swarmStyle||{},a=null!==(t=s.radius)&&void 0!==t?t:3,l=null!==(n=s.fill)&&void 0!==n?n:"#007bff",c=null!==(o=s.opacity)&&void 0!==o?o:.7,u=s.stroke,h=s.strokeWidth;for(const t of e){const e=this.getX(t),n=this.getY(t);if(null==n||Number.isNaN(n))continue;const o=this.scales.x(e),s=this.scales.y(n);let d=l;if(this.getCategory){const e=this.getCategory(t);d=(null===(r=this.config.barColors)||void 0===r?void 0:r[e])||d}const g={type:"point",x:o,y:s,r:a,style:{fill:d,opacity:c,stroke:u,strokeWidth:h},datum:t};this.getPointId&&(g.pointId=this.getPointId(t)+""),i.push(g)}return i}buildWaterfallScene(e,t){var n,o,r;const i=[],s=this.scales,a=this.config.waterfallStyle,l=e.filter(e=>{const t=this.getY(e);return null!=t&&!Number.isNaN(t)});if(0===l.length)return i;const c=null!==(n=null==a?void 0:a.positiveColor)&&void 0!==n?n:"#28a745",u=null!==(o=null==a?void 0:a.negativeColor)&&void 0!==o?o:"#dc3545",h=null!==(r=null==a?void 0:a.gap)&&void 0!==r?r:1,d=null==a?void 0:a.stroke,g=null==a?void 0:a.strokeWidth;let p=0;for(let e=0;l.length>e;e++){const n=l[e],o=this.getX(n),r=this.getY(n),y=p+r;let f;f=l.length-1>e?this.getX(l[e+1])-o:e>0?o-this.getX(l[e-1]):0;const m=s.x(o),v=0!==f?s.x(o+f):m+t.width/10,b=Math.min(m,v)+h/2,x=Math.max(m,v)-h/2-b;if(0>=x){p=y;continue}const w=s.y(p),A=s.y(y);i.push(k(b,Math.min(w,A),x,Math.abs(w-A),{fill:0>r?u:c,stroke:d,strokeWidth:g},Object.assign(Object.assign({},n),{baseline:p,cumEnd:y,delta:r,_connectorStroke:null==a?void 0:a.connectorStroke,_connectorWidth:null==a?void 0:a.connectorWidth}))),p=y}return i}buildCandlestickScene(e,t){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],o=this.config.candlestickStyle||{},r=o.upColor||"#28a745",i=o.downColor||"#dc3545",s=o.wickColor||"#333",a=o.wickWidth||1,l=e.map(e=>this.getX(e)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let c=o.bodyWidth||6;if(!o.bodyWidth&&l.length>1){let e=1/0;for(let t=1;l.length>t;t++){const n=Math.abs(this.scales.x(l[t])-this.scales.x(l[t-1]));n>0&&e>n&&(e=n)}e!==1/0&&(c=Math.max(2,Math.min(.6*e,20)))}for(const t of e){const e=this.getX(t);if(null==e||Number.isNaN(e))continue;const o=this.getOpen(t),l=this.getHigh(t),u=this.getLow(t),h=this.getClose(t);if([o,l,u,h].some(e=>null==e||Number.isNaN(e)))continue;const d=h>=o;n.push({type:"candlestick",x:this.scales.x(e),openY:this.scales.y(o),closeY:this.scales.y(h),highY:this.scales.y(l),lowY:this.scales.y(u),bodyWidth:c,upColor:r,downColor:i,wickColor:s,wickWidth:a,isUp:d,datum:t})}return n}buildBoundsForGroup(e,t){if(!this.getBounds||!this.scales)return null;const n=[],o=[];for(const t of e){const e=this.getX(t),r=this.getY(t);if(null==e||null==r||Number.isNaN(e)||Number.isNaN(r))continue;const i=this.getBounds(t),s=this.scales.x(e);if(i&&0!==i)n.push([s,this.scales.y(r+i)]),o.push([s,this.scales.y(r-i)]);else{const e=this.scales.y(r);n.push([s,e]),o.push([s,e])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:o,style:this.resolveBoundsStyle(t,e[0]),datum:e,group:t,interactive:!1}}resolveBoundsStyle(e,t){const n=this.config.boundsStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(e,t).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){var n,o,r;const i=this.config.decay;if(!i||1>=t)return 1;const s=null!==(n=i.minOpacity)&&void 0!==n?n:.1,a=t-1-e;switch(i.type){case"linear":return s+(1-a/(t-1))*(1-s);case"exponential":{const e=null!==(o=i.halfLife)&&void 0!==o?o:t/2;return s+Math.pow(.5,a/e)*(1-s)}case"step":return(null!==(r=i.stepThreshold)&&void 0!==r?r:.5*t)>a?1:s;default:return 1}}applyDecay(e,t){var n,o;if(!this.config.decay)return;const r=t.length;if(1>=r)return;const i=new Map;for(let e=0;t.length>e;e++)i.set(t[e],e);for(const t of e){if("line"===t.type){const e=Array.isArray(t.datum)?t.datum:[];if(2>e.length)continue;const n=Array(e.length);let o=!1;for(let t=0;e.length>t;t++){const s=i.get(e[t]);null!=s?(n[t]=this.computeDecayOpacity(s,r),1>n[t]&&(o=!0)):n[t]=1}o&&(t._decayOpacities=n);continue}if("area"===t.type){const e=Array.isArray(t.datum)?t.datum:[],n=t.topPath?t.topPath.length:e.length;if(2>n)continue;if(e.length===n){const o=Array(n);let s=!1;for(let t=0;e.length>t;t++){const n=i.get(e[t]);null!=n?(o[t]=this.computeDecayOpacity(n,r),1>o[t]&&(s=!0)):o[t]=1}s&&(t._decayOpacities=o)}else{let o=1;for(const t of e){const e=i.get(t);if(null!=e){const t=this.computeDecayOpacity(e,r);o>t&&(o=t)}}if(1>o){const e=Array(n);e.fill(o),t._decayOpacities=e}}continue}const e=i.get(t.datum);if(null==e)continue;const s=this.computeDecayOpacity(e,r);if("heatcell"===t.type)t.style={opacity:s};else if("candlestick"===t.type)t._decayOpacity=s;else{const e=null!==(o=null===(n=t.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:e*s})}}}computePulseIntensity(e,t){var n;const o=this.config.pulse;if(!o)return 0;const r=null!==(n=o.duration)&&void 0!==n?n:500,i=t-e;return r>i?1-i/r:0}applyPulse(e,t){var n,o;if(!this.config.pulse||!this.timestampBuffer)return;const r="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",s=null!==(o=this.config.pulse.glowRadius)&&void 0!==o?o:4,a=new Map;for(let e=0;t.length>e;e++)a.set(t[e],e);for(const t of e){if("line"===t.type)continue;if("area"===t.type){const e=Array.isArray(t.datum)?t.datum:[t.datum];let n=0;for(const t of e){const e=a.get(t);if(null==e)continue;const o=this.timestampBuffer.get(e);if(null==o)continue;const i=this.computePulseIntensity(o,r);i>n&&(n=i)}n>0&&(t._pulseIntensity=n,t._pulseColor=i);continue}const e=a.get(t.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const o=this.computePulseIntensity(n,r);o>0&&(t._pulseIntensity=o,t._pulseColor=i,t._pulseGlowRadius=s)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}snapshotPositions(){var e,t,n;this.prevPositionMap.clear(),this.prevPathMap.clear();for(let o=0;this.scene.length>o;o++){const r=this.scene[o],i=this.getNodeIdentity(r,o);i&&("point"===r.type?this.prevPositionMap.set(i,{x:r.x,y:r.y,r:r.r,opacity:r.style.opacity}):"rect"===r.type?this.prevPositionMap.set(i,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:r.style.opacity}):"heatcell"===r.type?this.prevPositionMap.set(i,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:null===(e=r.style)||void 0===e?void 0:e.opacity}):"candlestick"===r.type?this.prevPositionMap.set(i,{x:r.x,y:r.openY}):"line"===r.type?this.prevPathMap.set(i,{path:r.path.map(e=>[e[0],e[1]]),opacity:null===(t=r.style)||void 0===t?void 0:t.opacity}):"area"===r.type&&this.prevPathMap.set(i,{topPath:r.topPath.map(e=>[e[0],e[1]]),bottomPath:r.bottomPath.map(e=>[e[0],e[1]]),opacity:null===(n=r.style)||void 0===n?void 0:n.opacity}))}}getNodeIdentity(e,t){var n,o,r,i;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===this.config.runtimeMode&&e.datum){if(this.getCategory)return`p:${this.getCategory(e.datum)}:${this.getY(e.datum)}`;const t=this.getX(e.datum),n=this.getY(e.datum);if(null!=t&&null!=n)return`p:${t}:${n}`}return"p:"+t;case"rect":return`r:${e.group||""}:${null!==(i=null!==(o=null===(n=e.datum)||void 0===n?void 0:n.binStart)&&void 0!==o?o:null===(r=e.datum)||void 0===r?void 0:r.category)&&void 0!==i?i:t}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+t:"c:"+this.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}startTransition(){var e,t,n,o,r,i,s,a,l,c,u,h,d,g,p,y,f,m,v,b,x,k,w,A,S,O;if(!this.config.transition||0===this.prevPositionMap.size&&0===this.prevPathMap.size)return;const M=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let E=!1;const j=new Set,C=new Set;for(let e=0;this.scene.length>e;e++){const f=this.scene[e],m=this.getNodeIdentity(f,e);if(!m)continue;if(f._transitionKey=m,"line"===f.type||"area"===f.type){const e=this.prevPathMap.get(m);if(e){if(C.add(m),"line"===f.type&&e.path&&e.path.length===f.path.length){f._targetPath=f.path.map(e=>[e[0],e[1]]),f._prevPath=e.path;for(let t=0;f.path.length>t;t++)f.path[t]=[e.path[t][0],e.path[t][1]];E=!0}else if("area"===f.type&&e.topPath&&e.bottomPath&&e.topPath.length===f.topPath.length&&e.bottomPath.length===f.bottomPath.length){f._targetTopPath=f.topPath.map(e=>[e[0],e[1]]),f._targetBottomPath=f.bottomPath.map(e=>[e[0],e[1]]),f._prevTopPath=e.topPath,f._prevBottomPath=e.bottomPath;for(let t=0;f.topPath.length>t;t++)f.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;f.bottomPath.length>t;t++)f.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];E=!0}f._targetOpacity=null!==(t=f.style.opacity)&&void 0!==t?t:1}else f._targetOpacity=null!==(n=f.style.opacity)&&void 0!==n?n:1,f.style=Object.assign(Object.assign({},f.style),{opacity:0}),E=!0;continue}const v=this.prevPositionMap.get(m);if("point"===f.type)if(v){j.add(m);const e={x:f.x,y:f.y,r:f.r};f._targetOpacity=null!==(o=f.style.opacity)&&void 0!==o?o:1,v.x===e.x&&v.y===e.y||(f._targetX=e.x,f._targetY=e.y,f._targetR=e.r,f.x=v.x,f.y=v.y,f.r=null!==(r=v.r)&&void 0!==r?r:f.r,E=!0)}else f._targetOpacity=null!==(i=f.style.opacity)&&void 0!==i?i:1,f.style=Object.assign(Object.assign({},f.style),{opacity:0}),E=!0;else if("rect"===f.type)if(v){j.add(m);const e={x:f.x,y:f.y,w:f.w,h:f.h};f._targetOpacity=null!==(s=f.style.opacity)&&void 0!==s?s:1,v.x===e.x&&v.y===e.y&&v.w===e.w&&v.h===e.h||(f._targetX=e.x,f._targetY=e.y,f._targetW=e.w,f._targetH=e.h,f.x=v.x,f.y=v.y,f.w=null!==(a=v.w)&&void 0!==a?a:f.w,f.h=null!==(l=v.h)&&void 0!==l?l:f.h,E=!0)}else f._targetOpacity=null!==(c=f.style.opacity)&&void 0!==c?c:1,f.style=Object.assign(Object.assign({},f.style),{opacity:0}),E=!0;else if("heatcell"===f.type)if(v){j.add(m);const e={x:f.x,y:f.y,w:f.w,h:f.h};f._targetOpacity=null!==(h=null===(u=f.style)||void 0===u?void 0:u.opacity)&&void 0!==h?h:1,v.x===e.x&&v.y===e.y||(f._targetX=e.x,f._targetY=e.y,f._targetW=e.w,f._targetH=e.h,f.x=v.x,f.y=v.y,f.w=null!==(d=v.w)&&void 0!==d?d:f.w,f.h=null!==(g=v.h)&&void 0!==g?g:f.h,E=!0)}else f._targetOpacity=null!==(y=null===(p=f.style)||void 0===p?void 0:p.opacity)&&void 0!==y?y:1,f.style=Object.assign(Object.assign({},f.style||{}),{opacity:0}),E=!0}for(const[e,t]of this.prevPathMap)if(!C.has(e))if(e.startsWith("l:")&&t.path){const n={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(f=t.opacity)&&void 0!==f?f:1},_targetOpacity:0,_transitionKey:e,datum:null};this.exitNodes.push(n),E=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const n={type:"area",topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),group:e.slice(2),style:{fill:"#999",opacity:null!==(m=t.opacity)&&void 0!==m?m:1},_targetOpacity:0,_transitionKey:e,datum:null};this.exitNodes.push(n),E=!0}for(const[e,t]of this.prevPositionMap)if(!j.has(e)){if(e.startsWith("p:")){const n={type:"point",x:t.x,y:t.y,r:null!==(v=t.r)&&void 0!==v?v:3,style:{opacity:null!==(b=t.opacity)&&void 0!==b?b:1},datum:null,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}else if(e.startsWith("r:")){const n={type:"rect",x:t.x,y:t.y,w:null!==(x=t.w)&&void 0!==x?x:0,h:null!==(k=t.h)&&void 0!==k?k:0,style:{opacity:null!==(w=t.opacity)&&void 0!==w?w:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}else if(e.startsWith("h:")){const n={type:"heatcell",x:t.x,y:t.y,w:null!==(A=t.w)&&void 0!==A?A:0,h:null!==(S=t.h)&&void 0!==S?S:0,fill:"#999",datum:null,style:{opacity:null!==(O=t.opacity)&&void 0!==O?O:1},_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}E=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),E&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:M})}advanceTransition(e){var t,n,o,r,i,s;if(!this.activeTransition)return!1;const a=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,this.activeTransition),l=function(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}(a,"linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?"linear":"ease-out-cubic");for(const e of this.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const o=t?this.prevPositionMap.get(t):void 0,r=o?null!==(n=o.opacity)&&void 0!==n?n:1:0;e.style.opacity=B(r,e._targetOpacity,l)}if(void 0===e._targetX)continue;if(!t)continue;const o=this.prevPositionMap.get(t);if(!o)continue;e.x=B(o.x,e._targetX,l),e.y=B(o.y,e._targetY,l),void 0!==e._targetR&&void 0!==o.r&&(e.r=B(o.r,e._targetR,l))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?this.prevPositionMap.get(t):void 0,r=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;e.style.opacity=B(r,e._targetOpacity,l)}if(void 0===e._targetX)continue;if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=B(n.x,e._targetX,l),e.y=B(n.y,e._targetY,l),void 0!==n.w&&(e.w=B(n.w,e._targetW,l)),void 0!==n.h&&(e.h=B(n.h,e._targetH,l))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?this.prevPositionMap.get(t):void 0,o=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:B(o,e._targetOpacity,l)})}if(void 0===e._targetX)continue;if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=B(n.x,e._targetX,l),e.y=B(n.y,e._targetY,l),void 0!==n.w&&(e.w=B(n.w,e._targetW,l)),void 0!==n.h&&(e.h=B(n.h,e._targetH,l))}else if("line"===e.type){if(void 0!==e._targetOpacity){const t=void 0===e._prevPath&&e._targetOpacity>0?0:null!==(i=e.style.opacity)&&void 0!==i?i:1;e.style=Object.assign(Object.assign({},e.style),{opacity:B(t,e._targetOpacity,l)})}const t=e._prevPath,n=e._targetPath;if(t&&n&&t.length===e.path.length)for(let o=0;e.path.length>o;o++)e.path[o][0]=B(t[o][0],n[o][0],l),e.path[o][1]=B(t[o][1],n[o][1],l)}else if("area"===e.type){if(void 0!==e._targetOpacity){const t=void 0===e._prevTopPath&&e._targetOpacity>0?0:null!==(s=e.style.opacity)&&void 0!==s?s:1;e.style=Object.assign(Object.assign({},e.style),{opacity:B(t,e._targetOpacity,l)})}const t=e._prevTopPath,n=e._prevBottomPath,o=e._targetTopPath,r=e._targetBottomPath;if(t&&o&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=B(t[n][0],o[n][0],l),e.topPath[n][1]=B(t[n][1],o[n][1],l);if(n&&r&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=B(n[t][0],r[t][0],l),e.bottomPath[t][1]=B(n[t][1],r[t][1],l)}}if(a>=1){for(const e of this.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style=Object.assign(Object.assign({},"line"===e.type||"area"===e.type?e.style:e.style||{}),{opacity:0===t?0:t}),e._targetOpacity=void 0}if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("line"===e.type){const t=e._targetPath;if(t)for(let n=0;e.path.length>n;n++)e.path[n]=t[n];e._prevPath=void 0,e._targetPath=void 0}else if("area"===e.type){const t=e._targetTopPath,n=e._targetBottomPath;if(t)for(let n=0;e.topPath.length>n;n++)e.topPath[n]=t[n];if(n)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=n[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0}}if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const n of e){const e=this.getGroup(n);t.has(e)||t.set(e,[]),t.get(e).push(n)}return Array.from(t.entries()).map(([e,t])=>({key:e,data:t}))}resolveColorMap(e){const t=new Set;for(const n of e){const e=this.getColor(n);e&&t.add(e)}const n=Array.from(t).sort(),o=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===o)return this._colorMapCache.map;const r=Array.isArray(this.config.colorScheme)?this.config.colorScheme:j,i=new Map;for(let e=0;n.length>e;e++)i.set(n[e],r[e%r.length]);return this._colorMapCache={key:o,map:i},i}resolveLineStyle(e,t){const n=this.config.lineStyle;if("function"==typeof n){const o=n(t||{},e);if(o&&!o.stroke&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},o),{stroke:t})}return o}return n&&"object"==typeof n?{stroke:n.stroke||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var n;if(this.config.areaStyle){const n=this.config.areaStyle(t||{});if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}const o=this.config.lineStyle;if("function"==typeof o){const n=o(t||{},e);if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}return o&&"object"==typeof o?{fill:o.fill||o.stroke||"#4e79a7",fillOpacity:null!==(n=o.fillOpacity)&&void 0!==n?n:.7,stroke:o.stroke||"#4e79a7",strokeWidth:o.strokeWidth||2}:{fill:"#4e79a7",fillOpacity:.7,stroke:"#4e79a7",strokeWidth:2}}resolveGroupColor(e){if(this._colorMapCache){const t=this._colorMapCache.map.get(e);if(t)return t}const t=this._groupColorMap.get(e);if(t)return t;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:j,o=n[this._groupColorMap.size%n.length];return this._groupColorMap.set(e,o),o}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(e){void 0!==e.colorScheme&&(this._colorMapCache=null,this._groupColorMap=new Map),void 0===e.barColors&&void 0===e.colorScheme||(this._barCategoryCache=null),void 0===e.normalize&&void 0===e.extentPadding&&void 0===e.xAccessor&&void 0===e.yAccessor&&void 0===e.groupAccessor&&void 0===e.categoryAccessor&&void 0===e.chartType||(this._stackExtentCache=null),Object.assign(this.config,e),(void 0!==e.xAccessor||void 0!==e.yAccessor||void 0!==e.timeAccessor||void 0!==e.valueAccessor)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=A(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=A(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=A(this.config.xAccessor,"x"),this.getY=A(this.config.yAccessor,"y"))),void 0!==e.groupAccessor&&(this.getGroup=O(this.config.groupAccessor)),void 0!==e.categoryAccessor&&(this.getCategory=O(this.config.categoryAccessor)),void 0!==e.sizeAccessor&&(this.getSize=this.config.sizeAccessor?A(this.config.sizeAccessor,"size"):void 0),void 0!==e.colorAccessor&&(this.getColor=O(this.config.colorAccessor)),void 0!==e.y0Accessor&&(this.getY0=this.config.y0Accessor?A(this.config.y0Accessor,"y0"):void 0),void 0!==e.pointIdAccessor&&(this.getPointId=O(this.config.pointIdAccessor)),this.needsFullRebuild=!0}}function H(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function z(e,t,n){const o=t-e.x,r=n-e.y,i=Math.sqrt(o*o+r*r);return i>e.r+5?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:i}}function $(e,t,n){var o,r,i,s;if(0===e.path.length)return null;const a=R(e.path,t);if(0>a)return null;const[l,c]=e.path[a];let u;if(e.path.length>1){let o=1/0;const r=Math.max(0,a-1),i=Math.min(e.path.length-2,a);for(let s=r;i>=s;s++){const[r,i]=e.path[s],[a,l]=e.path[s+1],c=T(t,n,r,i,a,l);o>c&&(o=c)}u=o}else{const e=t-l,o=n-c;u=Math.sqrt(e*e+o*o)}const h=null!==(s=null!==(r=null===(o=e.style)||void 0===o?void 0:o.strokeWidth)&&void 0!==r?r:null===(i=e.style)||void 0===i?void 0:i.lineWidth)&&void 0!==s?s:1;return u>Math.max(5,h/2+2)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[a]?e.datum[a]:e.datum,x:l,y:c,distance:u}}function T(e,t,n,o,r,i){const s=r-n,a=i-o,l=s*s+a*a;if(0===l)return Math.sqrt(Math.pow(e-n,2)+Math.pow(t-o,2));let c=((e-n)*s+(t-o)*a)/l;c=Math.max(0,Math.min(1,c));const u=o+c*a;return Math.sqrt(Math.pow(e-(n+c*s),2)+Math.pow(t-u,2))}function W(e,t,n){const o=H(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function I(e,t,n){const o=H(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function F(e,t,n){const o=e.bodyWidth/2,r=Math.min(e.openY,e.closeY);if(!(e.x-o-3>t||t>e.x+o+3||e.highY-3>n||n>e.lowY+3)){const o=r+Math.max(Math.max(e.openY,e.closeY)-r,1)/2,i=t-e.x,s=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(i*i+s*s)}}return null}function D(e,t,n){if(0===e.topPath.length)return null;const o=R(e.topPath,t);if(0>o)return null;const[r,i]=e.topPath[o],s=t-r,a=n-i,l=Math.sqrt(s*s+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:r,y:i,distance:l}}function R(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const r=n+o>>1;t>e[r][0]?n=r+1:o=r}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}N.QUADTREE_THRESHOLD=500;const G={fill:e=>d.createElement("rect",{style:e,width:16,height:16}),line:e=>d.createElement("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function q(e,t,n,o){let r;return r="function"==typeof n?n(e):(0,G[n])(o(e,t)),r}function Y(){return d.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function X(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function V({config:e,orientation:t="vertical",width:n=100}){const{colorFn:o,domain:r,label:i,format:s}=e,a=s||(e=>Math.round(100*e)/100+""),l="grad-legend-"+d.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),s=Math.max(0,(n-t)/2),c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(d.createElement("stop",{key:e,offset:100*t+"%",stopColor:o(r[0]+t*(r[1]-r[0]))}))}return d.createElement("g",{"aria-label":i||"Gradient legend"},d.createElement("defs",null,d.createElement("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},c)),i&&d.createElement("text",{x:s+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),d.createElement("rect",{x:s,y:0,width:t,height:e,fill:`url(#${l})`,rx:2}),d.createElement("text",{x:s,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[0])),d.createElement("text",{x:s+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[1])))}const c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(d.createElement("stop",{key:e,offset:100*t+"%",stopColor:o(r[1]-t*(r[1]-r[0]))}))}return d.createElement("g",{"aria-label":i||"Gradient legend"},i&&d.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),d.createElement("defs",null,d.createElement("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},c)),d.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${l})`,rx:2}),d.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[1])),d.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[0])))}function Q(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,legendInteraction:s,title:a="Legend",width:l=100,height:c=20,orientation:u="vertical"}=e,[h,g]=d.useState(0),[p,y]=d.useState(0),f=d.useCallback((e,t)=>{g(e),y(t)},[]),m="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:l,legendInteraction:c})=>{let u=24;const h=[];return e.forEach((e,g)=>{u+=5,h.push(d.createElement("line",{key:"legend-top-line legend-symbol-"+g,stroke:"gray",x1:0,y1:u,x2:t,y2:u})),u+=8,e.label&&(u+=16,h.push(d.createElement("text",{key:"legend-text-"+g,y:u,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label)),u+=8),h.push(d.createElement("g",{key:"legend-group-"+g,className:"legend-item",transform:`translate(0,${u})`},((e,t,n,o,r,i,s,a,l,c)=>{const{type:u="fill",styleFn:h,items:g}=e,p=[];let y=0;const f=!(!t&&!n),m="isolate"===c||void 0===c&&null!=r;return g.forEach((e,c)=>{const v=q(e,c,u,h),b=X(e,o,r),x=r&&r.size>0&&r.has(e.label);p.push(d.createElement("g",{key:"legend-item-"+c,transform:`translate(0,${y})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:f?a===i&&c===s?0:-1:void 0,role:f?"option":void 0,"aria-selected":f&&m?x||!1:void 0,"aria-current":f&&!m&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:f?n=>{var o;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(c+("ArrowDown"===n.key?1:-1)+g.length)%g.length;l(a,e);const t=null===(o=n.currentTarget.parentElement)||void 0===o?void 0:o.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:f?t=>{l(a,c),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:f?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:f?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},f&&d.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,x&&d.createElement(Y,null),d.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),y+=22}),p})(e,n,o,r,i,s,a,g,l,c))),u+=22*e.items.length+8}),h})({legendGroups:t||[],width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:h,focusedItemIndex:p,onFocusedIndexChange:f,legendInteraction:s}):(({legendGroups:e,height:t,width:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u})=>{let h=0;const g=[];e.forEach((e,t)=>{let n=0;e.label&&(n+=16);const p=((e,t,n,o,r,i,s,a,l,c)=>{const{type:u="fill",styleFn:h,items:g}=e,p=[];let y=0;const f=!(!t&&!n),m="isolate"===c||void 0===c&&null!=r;return g.forEach((e,c)=>{const v=q(e,c,u,h),b=X(e,o,r),x=r&&r.size>0&&r.has(e.label);p.push(d.createElement("g",{key:"legend-item-"+c,transform:`translate(${y},0)`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:f?a===i&&c===s?0:-1:void 0,role:f?"option":void 0,"aria-selected":f&&m?x||!1:void 0,"aria-current":f&&!m&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:f?n=>{var o;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(c+("ArrowRight"===n.key?1:-1)+g.length)%g.length;l(a,e);const t=null===(o=n.currentTarget.parentElement)||void 0===o?void 0:o.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:f?t=>{l(a,c),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:f?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:f?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},f&&d.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,x&&d.createElement(Y,null),d.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),y+=26+7*e.label.length}),{items:p,offset:y}})(e,o,r,i,s,a,l,t,c,u);n+=p.offset+5,g.push(Object.assign(Object.assign({label:e.label},p),{offset:n})),h+=n+12});let p=Math.max(0,(n-h)/2);const y=[];return g.forEach((n,o)=>{const r=e[o];r.label&&(y.push(d.createElement("text",{key:"legend-text-"+o,transform:`translate(${p},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},r.label)),p+=16),y.push(d.createElement("g",{key:"legend-group-"+o,className:"legend-item",transform:`translate(${p},0)`},n.items)),p+=n.offset+5,e[o+1]&&y.push(d.createElement("line",{key:"legend-top-line legend-symbol-"+o,stroke:"gray",x1:p,y1:-8,x2:p,y2:t+0+8})),p+=12}),d.createElement("g",null,y)})({legendGroups:t||[],title:a,height:c,width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:h,focusedItemIndex:p,onFocusedIndexChange:f,legendInteraction:s}),v=!(!n&&!o);return d.createElement("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==s&&(void 0!==s||null==i))||void 0,"aria-label":"Chart legend"},void 0!==a&&""!==a&&"vertical"===u&&d.createElement("text",{className:"legend-title",y:16,x:l/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},a),m)}function U(e){return"string"==typeof e?{type:e}:e}function K({orient:t,config:n,values:o,scale:r,size:i,length:a}){const l=function(e){var t,n,o,r,i;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(n=e.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(o=e.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(r=e.stroke)&&void 0!==r?r:"none",strokeWidth:null!==(i=e.strokeWidth)&&void 0!==i?i:1}}(n),c="top"===t||"bottom"===t,u=e.useMemo(()=>{if(0===o.length)return null;const e=r.domain(),n=i-8;if("boxplot"===l.type){const e=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],r=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],s=i-o;return{q1:o,median:r,q3:i,whiskerLow:Math.max(t[0],o-1.5*s),whiskerHigh:Math.min(t[n-1],i+1.5*s)}}(o);if(!e)return null;const{q1:i,median:s,q3:a,whiskerLow:u,whiskerHigh:h}=e,g=Math.min(.5*n,20),p=(n-g)/2+4;if(c){const e=r(i),n=r(a),o=r(s),c=r(u),y=r(h),f="top"===t?-1:1,m=0;return d.createElement("g",{"data-testid":"marginal-boxplot-"+t},d.createElement("line",{x1:c,y1:m+f*(p+g/2),x2:y,y2:m+f*(p+g/2),stroke:l.fill,strokeWidth:l.strokeWidth}),d.createElement("line",{x1:c,y1:m+f*p,x2:c,y2:m+f*(p+g),stroke:l.fill,strokeWidth:l.strokeWidth}),d.createElement("line",{x1:y,y1:m+f*p,x2:y,y2:m+f*(p+g),stroke:l.fill,strokeWidth:l.strokeWidth}),d.createElement("rect",{x:Math.min(e,n),y:"top"===t?m-p-g:m+p,width:Math.abs(n-e),height:g,fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),d.createElement("line",{x1:o,y1:"top"===t?m-p-g:m+p,x2:o,y2:"top"===t?m-p:m+p+g,stroke:l.fill,strokeWidth:2}))}{const e=r(i),n=r(a),o=r(s),c=r(u),y=r(h),f="left"===t?-1:1,m=0;return d.createElement("g",{"data-testid":"marginal-boxplot-"+t},d.createElement("line",{x1:m+f*(p+g/2),y1:c,x2:m+f*(p+g/2),y2:y,stroke:l.fill,strokeWidth:l.strokeWidth}),d.createElement("line",{x1:m+f*p,y1:c,x2:m+f*(p+g),y2:c,stroke:l.fill,strokeWidth:l.strokeWidth}),d.createElement("line",{x1:m+f*p,y1:y,x2:m+f*(p+g),y2:y,stroke:l.fill,strokeWidth:l.strokeWidth}),d.createElement("rect",{x:"left"===t?m-p-g:m+p,y:Math.min(e,n),width:g,height:Math.abs(n-e),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),d.createElement("line",{x1:"left"===t?m-p-g:m+p,y1:o,x2:"left"===t?m-p:m+p+g,y2:o,stroke:l.fill,strokeWidth:2}))}}const u=s.bin().domain(e).thresholds(l.bins)(o);if(0===u.length)return null;const h=Math.max(...u.map(e=>e.length));if(0===h)return null;if("histogram"===l.type)return d.createElement("g",{"data-testid":"marginal-histogram-"+t},u.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const i=e.length/h*n;if(c){const n=r(e.x0),s=r(e.x1)-r(e.x0);return d.createElement("rect",{key:o,x:n,y:"top"===t?-4-i:4,width:Math.max(s,.5),height:i,fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}{const n=r(e.x0),s=r(e.x1)-r(e.x0);return d.createElement("rect",{key:o,x:"left"===t?-4-i:4,y:Math.min(n,n+s),width:i,height:Math.abs(s),fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}}));if("violin"===l.type){const e=n/2+4,o=[];for(const i of u){if(null==i.x0||null==i.x1)continue;const s=i.length/h*(n/2),a=r((i.x0+i.x1)/2);o.push(c?`${a},${"top"===t?-(e-s):e-s}`:`${"left"===t?-(e-s):e-s},${a}`)}for(let i=u.length-1;i>=0;i--){const s=u[i];if(null==s.x0||null==s.x1)continue;const a=s.length/h*(n/2),l=r((s.x0+s.x1)/2);o.push(c?`${l},${"top"===t?-(e+a):e+a}`:`${"left"===t?-(e+a):e+a},${l}`)}return d.createElement("g",{"data-testid":"marginal-violin-"+t},d.createElement("polygon",{points:o.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}if("ridgeline"===l.type){const e=[];if(c){const o=0,i=null!=u[0].x0?r(u[0].x0):0;e.push(`M${i},${o}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const i=o.length/h*n,s=r((o.x0+o.x1)/2);e.push(`L${s},${"top"===t?-i-4:i+4}`)}const s=null!=u[u.length-1].x1?r(u[u.length-1].x1):a;e.push(`L${s},${o}`),e.push("Z")}else{const o=0,i=null!=u[0].x0?r(u[0].x0):0;e.push(`M${o},${i}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const i=o.length/h*n,s=r((o.x0+o.x1)/2);e.push(`L${"left"===t?-i-4:i+4},${s}`)}const s=null!=u[u.length-1].x1?r(u[u.length-1].x1):a;e.push(`L${o},${s}`),e.push("Z")}return d.createElement("g",{"data-testid":"marginal-ridgeline-"+t},d.createElement("path",{d:e.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}return null},[o,r,l,i,a,t,c,4]);return u?d.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},u):null}function Z(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=e.split(/\s+/),i=[];let s="";for(const e of r)s&&s.length+1+e.length>o?(i.push(s),s=e):s=s?`${s} ${e}`:e;return s&&i.push(s),i}function J(e,t,n,o){return"curly"===e?o?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:o?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function ee(e){const{x:t=0,y:n=0,dx:o,dy:r,nx:i,ny:s,note:a,connector:l,subject:c,type:u,color:h,className:g,disable:p,events:y={},"data-testid":f}=e,m=new Set(Array.isArray(p)?p:[]);let v=o||0,b=r||0;null!=i&&(v=i-t),null!=s&&(b=s-n);const x="string"==typeof u?u:"label";if("bracket"===x&&c&&0===v&&0===b)if(void 0!==c.width){v=c.width/2;const e=c.depth||30;b=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;v=e+(0>e?-5:5),b=c.height/2}return d.createElement("g",Object.assign({className:("annotation "+(g||"")).trim(),transform:`translate(${t},${n})`,"data-testid":f},y),!m.has("connector")&&function(e,t,n,o,r,i){const s=[];let a=0,l=0;if("callout-circle"!==r&&"label"!==r||!(null==i?void 0:i.radius)){if("callout-rect"===r&&i){const n=i.width||0,o=i.height||0;if(n>0||o>0){const r=n/2,i=o/2,s=e-r,c=t-i;if(0!==s||0!==c){const e=Math.abs(s),t=Math.abs(c),u=n/2,h=o/2,d=e*h>t*u?u/e:h/t;a=r+s*d,l=i+c*d}}}else if("bracket"===r&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(a=e/2,l=n):void 0!==t&&(a=n,l=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const o=Math.atan2(t,e);a=Math.cos(o)*n,l=Math.sin(o)*n}}if(Math.sqrt(Math.pow(e-a,2)+Math.pow(t-l,2))>.5&&(s.push(d.createElement("line",{key:"connector-line",x1:a,y1:l,x2:e,y2:t,stroke:o||"currentColor"})),"arrow"===(null==n?void 0:n.end))){const n=10,r=16/180*Math.PI,i=Math.atan2(t-l,e-a);s.push(d.createElement("path",{key:"connector-arrow",d:`M${a},${l}L${a+n*Math.cos(i+r)},${l+n*Math.sin(i+r)}L${a+n*Math.cos(i-r)},${l+n*Math.sin(i-r)}Z`,fill:o||"currentColor",stroke:"none"}))}return d.createElement("g",{className:"annotation-connector"},s)}(v,b,l,h,x,c),!m.has("subject")&&function(e,t,n,o,r){var i;const s=[];switch(e){case"callout-circle":{const e=((null==t?void 0:t.radius)||0)+((null==t?void 0:t.radiusPadding)||0);e>0&&s.push(d.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:n||"currentColor"}));break}case"callout-rect":{const e=(null==t?void 0:t.width)||0,o=(null==t?void 0:t.height)||0;(e>0||o>0)&&s.push(d.createElement("rect",{key:"subject-rect",width:e,height:o,fill:"none",stroke:n||"currentColor"}));break}case"callout-custom":(null==t?void 0:t.custom)&&s.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=o||0,i=r||0;if(void 0!==(null==t?void 0:t.x)){const o=(t.x||0)-e;s.push(d.createElement("line",{key:"threshold-line",x1:o,y1:(t.y1||0)-i,x2:o,y2:(t.y2||0)-i,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==t?void 0:t.y)){const o=(t.y||0)-i;s.push(d.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:o,x2:(t.x2||0)-e,y2:o,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==t?void 0:t.x1)||void 0!==(null==t?void 0:t.x2)?s.push(d.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"currentColor",strokeDasharray:"5,5"})):void 0===(null==t?void 0:t.y1)&&void 0===(null==t?void 0:t.y2)||s.push(d.createElement("line",{key:"threshold-line",x1:0,y1:(t.y1||0)-i,x2:0,y2:(t.y2||0)-i,stroke:n||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(i=null==t?void 0:t.width)&&void 0!==i?i:null==t?void 0:t.height;void 0!==e&&s.push(d.createElement("path",{key:"bracket-path",d:J((null==t?void 0:t.type)||"curly",e,(null==t?void 0:t.depth)||30,void 0===(null==t?void 0:t.width)),fill:"none",stroke:n||"currentColor"}));break}}return d.createElement("g",{className:"annotation-subject"},s)}(x,c,h,t,n),!m.has("note")&&function(e,t,n,o){if(!e)return d.createElement("g",{className:"annotation-note"});const{label:r,title:i,orientation:s,align:a,wrap:l=120,noWrap:c}=e;if(!r&&!i)return d.createElement("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let h=a;h&&"dynamic"!==h||(h="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let g="start";"topBottom"===u?"right"===h?g="end":"middle"===h&&(g="middle"):g=0>t?"end":"start";const p=16,y=i?c?[i]:Z(i,l):[],f=r?c?[r]:Z(r,l):[],m="leftRight"===u?"end"===g?-4:4:0;let v=0;const b=[];y.length>0&&(b.push(d.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:o||void 0,textAnchor:g,fontWeight:"bold"},y.map((e,t)=>d.createElement("tspan",{key:t,x:m,dy:0===t?0:p},e)))),v=y.length*p),f.length>0&&b.push(d.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:o||void 0,textAnchor:g,y:v},f.map((e,t)=>d.createElement("tspan",{key:t,x:m,dy:0===t?0:p},e))));let x=null;if((i||r)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(l,120);let t=0,n=e;"end"===g?(t=-e,n=0):"middle"===g&&(t=-e/2,n=e/2),x=d.createElement("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"currentColor"})}else{const e=(y.length+f.length)*p+(f.length>0?p:0);let t=0,n=e;"bottom"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),x=d.createElement("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:o||"currentColor"})}const k=Math.max(0,y.length+f.length-1)*p;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===h?-(k+p+(f.length>0&&y.length>0?2:0))/2+8:"bottom"===h||0>n?-(k+2):18),d.createElement("g",{className:"annotation-note",transform:`translate(${t},${n})`},d.createElement("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0},b),x)}(a,v,b,h))}function te(e){var t,n;const{noteData:o}=e,{screenCoordinates:r}=o,i="string"==typeof o.type?o.type:"label",s=o.eventListeners||o.events||{};if(o.coordinates&&r){const e=o.nx||r[0][0]+(null!==(t=o.dx)&&void 0!==t?t:0),s=o.ny||r[0][1]+(null!==(n=o.dy)&&void 0!==n?n:0),a=r.map((t,n)=>{const r=Object.assign({},o,{note:0===n?o.note:{label:""},x:t[0],y:t[1],nx:e,ny:s});return d.createElement(ee,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},r,{type:i}))});return d.createElement("g",null,a)}const a=o.note||{title:"none",label:o.label};return d.createElement(ee,Object.assign({"data-testid":"semiotic-annotation",key:`${a.label}-${a.title}-${o.i}`,events:s},o,{type:i}))}const ne={linear:l.curveLinear,monotoneX:l.curveMonotoneX,monotoneY:l.curveMonotoneY,step:l.curveStep,stepAfter:l.curveStepAfter,stepBefore:l.curveStepBefore,basis:l.curveBasis,cardinal:l.curveCardinal,catmullRom:l.curveCatmullRom};function oe(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function re(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function ie(e,t,n){var o,r,i,s;const a=e.anchor||"fixed";if("latest"===a){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const i=n.pointNodes[r];if(i.pointId===e.pointId){const e={x:i.x,y:i.y};return null===(o=n.stickyPositionCache)||void 0===o||o.set(t,e),e}}const i=function(e){var t,n,o,r,i,s;const a=e.data;if(!a||0===a.length)return null;const l=a[a.length-1],c=null!==(n=null===(t=e.scales)||void 0===t?void 0:t.x)&&void 0!==n?n:null===(o=e.scales)||void 0===o?void 0:o.time,u=null!==(i=null===(r=e.scales)||void 0===r?void 0:r.y)&&void 0!==i?i:null===(s=e.scales)||void 0===s?void 0:s.value;if(!c||!u)return null;const h=l[e.xAccessor||"x"],d=l[e.yAccessor||"y"];return null==h||null==d?null:{x:c(h),y:u(d)}}(n);return i&&(null===(r=n.stickyPositionCache)||void 0===r||r.set(t,i)),i}let l=null,c=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(l=t.x,c=t.y)}if(null!=l&&null!=c||(l=oe(e,n),c=re(e,n)),null!=l&&null!=c)return null===(i=n.stickyPositionCache)||void 0===i||i.set(t,{x:l,y:c}),{x:l,y:c};if("sticky"===a){const e=null===(s=n.stickyPositionCache)||void 0===s?void 0:s.get(t);if(e)return e}return null}function se(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function ae(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,r="left"===e?-1:1,i=Math.ceil(t/8);let s="M0,"+o;for(let e=0;i>e;e++){const n=8*(e+1);s+=`L${Math.min(8*e+4,t)},${o+4*r}`,s+=`L${Math.min(n,t)},${o}`}return s}{const o="bottom"===e?0:t,r="bottom"===e?1:-1,i=Math.ceil(n/8);let s=`M${o},0`;for(let e=0;i>e;e++){const t=8*(e+1);s+=`L${o+4*r},${Math.min(8*e+4,n)}`,s+=`L${o},${Math.min(t,n)}`}return s}}function le(t){const{width:n,height:o,totalWidth:r,totalHeight:i,margin:s,scales:a,showAxes:l,axes:c,showGrid:u,xFormat:h,yFormat:g}=t,p=e.useMemo(()=>{var e;if(!a)return[];const t=null==c?void 0:c.find(e=>"bottom"===e.orient),o=(null==t?void 0:t.tickFormat)||h||ce,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return a.x.ticks(Math.min(r,Math.max(2,Math.floor(n/70)))).map(e=>({value:e,pixel:a.x(e),label:o(e)}))},[a,c,h,n]),y=e.useMemo(()=>{var e;if(!a)return[];const t=null==c?void 0:c.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||g||ce,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return a.y.ticks(Math.min(r,Math.max(2,Math.floor(o/30)))).map(e=>({value:e,pixel:a.y(e),label:n(e)}))},[a,c,g,o]),f=u&&a,m=l&&a;if(!f&&!m)return null;const v=null==c?void 0:c.find(e=>"bottom"===e.orient),b=null==c?void 0:c.find(e=>"left"===e.orient),x=m&&(!v||!1!==v.baseline),k=m&&(!b||!1!==b.baseline),w=(null==v?void 0:v.jaggedBase)||!1,A=(null==b?void 0:b.jaggedBase)||!1,S="var(--semiotic-border, #ccc)";return d.createElement("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},d.createElement("g",{transform:`translate(${s.left},${s.top})`},f&&d.createElement("g",{className:"stream-grid"},p.map((e,t)=>d.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),y.map((e,t)=>d.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:n,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),x&&!w&&d.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:S,strokeWidth:1}),w&&d.createElement("path",{d:ae("bottom",n,o),fill:"none",stroke:S,strokeWidth:1}),k&&!A&&d.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:S,strokeWidth:1}),A&&d.createElement("path",{d:ae("left",n,o),fill:"none",stroke:S,strokeWidth:1})))}function ce(e){return Math.round(100*e)/100+""}function ue(e,t){return e instanceof Date&&(!(t&&t instanceof Date)||e.getFullYear()!==t.getFullYear()||e.getMonth()!==t.getMonth()||e.getDate()!==t.getDate())}function he(t){var n,o;const{width:r,height:i,totalWidth:s,totalHeight:c,margin:u,scales:h,showAxes:p,axes:y,xLabel:f,yLabel:m,xFormat:v,yFormat:b,showGrid:x,title:k,legend:w,legendHoverBehavior:A,legendClickBehavior:S,legendHighlightedCategory:O,legendIsolatedCategories:M,legendPosition:E="right",foregroundGraphics:j,marginalGraphics:C,xValues:P,yValues:_,annotations:L,svgAnnotationRules:B,xAccessor:N,yAccessor:H,annotationData:z,pointNodes:$,curve:T,underlayRendered:W,children:I}=t,F=e.useMemo(()=>{var e;if(!p||!h)return[];const t=null==y?void 0:y.find(e=>"bottom"===e.orient),n=(null==t?void 0:t.tickFormat)||v||ce,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return h.x.ticks(Math.min(o,Math.max(2,Math.floor(r/70)))).map(e=>({value:e,pixel:h.x(e),label:n(e)}))},[p,h,y,v,r]),D=e.useMemo(()=>{var e;if(!p||!h)return[];const t=null==y?void 0:y.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||b||ce,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return h.y.ticks(Math.min(o,Math.max(2,Math.floor(i/30)))).map(e=>({value:e,pixel:h.y(e),label:n(e)}))},[p,h,y,b,i]),R=e.useRef(new Map),G=e.useRef(null!==(n=null==L?void 0:L.length)&&void 0!==n?n:0),q=null!==(o=null==L?void 0:L.length)&&void 0!==o?o:0;G.current!==q&&(G.current=q,R.current=new Map);const Y=e.useMemo(()=>{if(!L||0===L.length)return null;const e=function(e,t,n){var o,r,i,s,c,u,h,p,y,f,m,v,b,x,k,w,A,S,O,M,E,j,C,P,_,L,B,N,H,z,$,T,W,I,F,D,R,G,q,Y,X,V,Q,U;switch(e.type){case"label":{const o=ie(e,t,n);if(!o)return null;const{x:r,y:i}=o;return se(r,i,n)?d.createElement(te,{key:"ann-"+t,noteData:{x:r,y:i,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"label",connector:e.connector||{end:"arrow"},color:e.color}}):null}case"callout":{const o=ie(e,t,n);if(!o)return null;const{x:r,y:i}=o;return se(r,i,n)?d.createElement(te,{key:"ann-"+t,noteData:{x:r,y:i,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"callout-circle",subject:{radius:e.radius||12},connector:e.connector||{end:"arrow"},color:e.color}}):null}case"x-threshold":{const o=oe(e,n);if(null==o)return null;const r=e.color||"#f97316";return d.createElement("g",{key:"ann-"+t},d.createElement("line",{x1:o,y1:0,x2:o,y2:n.height||0,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&d.createElement("text",{x:o+4,y:12,fill:r,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const o=re(e,n);if(null==o)return null;const r=e.color||"#f97316";return d.createElement("g",{key:"ann-"+t},d.createElement("line",{x1:0,y1:o,x2:n.width||0,y2:o,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&d.createElement("text",{x:(n.width||0)-4,y:o-4,textAnchor:"end",fill:r,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const o=(e.coordinates||[]).map(e=>({x:oe(Object.assign(Object.assign({},e),{type:"point"}),n),y:re(Object.assign(Object.assign({},e),{type:"point"}),n),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const r=a.packEnclose(o),i=e.padding||10;return d.createElement("g",{key:"ann-"+t},d.createElement("circle",{cx:r.x,cy:r.y,r:r.r+i,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&d.createElement("text",{x:r.x,y:r.y-r.r-i-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"rect-enclose":{const o=(e.coordinates||[]).map(e=>({x:oe(Object.assign(Object.assign({},e),{type:"point"}),n),y:re(Object.assign(Object.assign({},e),{type:"point"}),n)})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const r=e.padding||10,i=o.map(e=>e.x),s=o.map(e=>e.y),a=Math.min(...i)-r,l=Math.max(...i)+r,c=Math.min(...s)-r,u=Math.max(...s)+r;return d.createElement("g",{key:"ann-"+t},d.createElement("rect",{x:a,y:c,width:l-a,height:u-c,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&d.createElement("text",{x:(a+l)/2,y:c-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"highlight":{const o=n.data||[],r="function"==typeof e.filter?o.filter(e.filter):e.field&&null!=e.value?o.filter(t=>t[e.field]===e.value):[],i=e.style||{stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return d.createElement("g",{key:"ann-"+t},r.map((t,o)=>{const r=oe(t,n),s=re(t,n);return null==r||null==s?null:d.createElement("circle",Object.assign({key:"hl-"+o,cx:r,cy:s,r:e.r||6},i))}))}case"bracket":{const o=oe(e,n),r=re(e,n);return d.createElement(te,{key:"ann-"+t,noteData:{x:null!=o?o:0,y:null!=r?r:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}})}case"trend":{const a=n.data||[];if(2>a.length)return null;const l=n.xAccessor||"x",p=n.yAccessor||"y",y=a.map(e=>[e[l],e[p]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>y.length)return null;const f=null!==(r=null===(o=n.scales)||void 0===o?void 0:o.x)&&void 0!==r?r:null===(i=n.scales)||void 0===i?void 0:i.time,m=null!==(c=null===(s=n.scales)||void 0===s?void 0:s.y)&&void 0!==c?c:null===(u=n.scales)||void 0===u?void 0:u.value;if(!f||!m)return null;const v=e.method||"linear";let b;b="loess"===v?function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),r=o.map(e=>e[0]),i=o.map(e=>e[1]),s=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=r[e],o=r.map(e=>Math.abs(e-t)),l=o.slice().sort((e,t)=>e-t)[Math.min(s-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:o[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,h=0,d=0,g=0,p=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,h+=t*r[e],d+=t*i[e],g+=t*r[e]*r[e],p+=t*r[e]*i[e])}if(0===u){a.push([t,i[e]]);continue}const y=u*g-h*h;if(1e-12>Math.abs(y))a.push([t,d/u]);else{const e=(u*p-h*d)/y;a.push([t,(d-e*h)/u+e*t])}}return a}(y,null!==(h=e.bandwidth)&&void 0!==h?h:.3):("polynomial"===v?g.default.polynomial(y,{order:e.order||2}):g.default.linear(y)).points;const x=b.map(([e,t])=>`${f(e)},${m(t)}`).join(" "),k=e.color||"#6366f1";return d.createElement("g",{key:"ann-"+t},d.createElement("polyline",{points:x,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&d.createElement("text",{x:f(b[b.length-1][0])+4,y:m(b[b.length-1][1])-4,fill:k,fontSize:11},e.label))}case"band":{const o=null!==(y=null===(p=n.scales)||void 0===p?void 0:p.y)&&void 0!==y?y:null===(f=n.scales)||void 0===f?void 0:f.value,r=null!==(m=null==o?void 0:o(e.y0))&&void 0!==m?m:0,i=null!==(v=null==o?void 0:o(e.y1))&&void 0!==v?v:n.height||0;return d.createElement("g",{key:"ann-"+t},d.createElement("rect",{x:0,y:Math.min(r,i),width:n.width||0,height:Math.abs(i-r),fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity||.1}),e.label&&d.createElement("text",{x:(n.width||0)-4,y:Math.min(r,i)-4,textAnchor:"end",fill:e.color||"#6366f1",fontSize:11},e.label))}case"envelope":{const o=n.data||[];if(2>o.length)return null;const r=n.xAccessor||"x",i=null!==(x=null===(b=n.scales)||void 0===b?void 0:b.x)&&void 0!==x?x:null===(k=n.scales)||void 0===k?void 0:k.time,s=null!==(A=null===(w=n.scales)||void 0===w?void 0:w.y)&&void 0!==A?A:null===(S=n.scales)||void 0===S?void 0:S.value;if(!i||!s)return null;const a=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",u=e.filter,h=o.filter(e=>null!=e[a]&&null!=e[c]&&!(u&&!u(e))).sort((e,t)=>e[r]-t[r]);if(2>h.length)return null;const g=ne[n.curve||"linear"]||l.curveLinear,p=l.area().x(e=>i(e[r])).y0(e=>s(e[c])).y1(e=>s(e[a])).curve(g)(h);if(!p)return null;const y=e.fill||"#6366f1";return d.createElement("g",{key:"ann-"+t},d.createElement("path",{d:p,fill:y,fillOpacity:null!==(O=e.fillOpacity)&&void 0!==O?O:.15,stroke:"none"}),e.label&&h.length>0&&d.createElement("text",{x:i(h[h.length-1][r])+4,y:s(h[h.length-1][a])-4,fill:y,fontSize:11},e.label))}case"anomaly-band":{const o=n.data||[];if(2>o.length)return null;const r=n.yAccessor||"y",i=null!==(E=null===(M=n.scales)||void 0===M?void 0:M.x)&&void 0!==E?E:null===(j=n.scales)||void 0===j?void 0:j.time,s=null!==(P=null===(C=n.scales)||void 0===C?void 0:C.y)&&void 0!==P?P:null===(_=n.scales)||void 0===_?void 0:_.value;if(!i||!s)return null;const a=o.map(e=>e[r]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const l=a.reduce((e,t)=>e+t,0)/a.length,c=a.reduce((e,t)=>e+Math.pow(t-l,2),0)/a.length,u=Math.sqrt(c),h=null!==(L=e.threshold)&&void 0!==L?L:2,g=l-h*u,p=!1!==e.showBand,y=e.fill||"#6366f1",f=null!==(B=e.fillOpacity)&&void 0!==B?B:.1,m=e.anomalyColor||"#ef4444",v=null!==(N=e.anomalyRadius)&&void 0!==N?N:6,b=s(l+h*u),x=s(g),k=o.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-l)>h*u});return d.createElement("g",{key:"ann-"+t},p&&d.createElement("rect",{x:0,y:Math.min(b,x),width:n.width||0,height:Math.abs(x-b),fill:y,fillOpacity:f}),k.map((e,t)=>{const o=oe(e,n),r=re(e,n);return null==o||null==r?null:d.createElement("circle",{key:"anomaly-"+t,cx:o,cy:r,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5})}),e.label&&d.createElement("text",{x:(n.width||0)-4,y:Math.min(b,x)-4,textAnchor:"end",fill:y,fontSize:11},e.label))}case"forecast":{const o=n.data||[];if(3>o.length)return null;const r=n.xAccessor||"x",i=n.yAccessor||"y",s=null!==(z=null===(H=n.scales)||void 0===H?void 0:H.x)&&void 0!==z?z:null===($=n.scales)||void 0===$?void 0:$.time,a=null!==(W=null===(T=n.scales)||void 0===T?void 0:T.y)&&void 0!==W?W:null===(I=n.scales)||void 0===I?void 0:I.value;if(!s||!a)return null;const l=o.map(e=>[e[r],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>l.length)return null;let c;if("polynomial"===(e.method||"linear")){const t=g.default.polynomial(l,{order:e.order||2}).equation;c=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}else{const e=l.length;let t=0,n=0,o=0,r=0;for(const[e,i]of l)t+=e,n+=i,o+=e*e,r+=e*i;const i=e*o-t*t;if(1e-12>Math.abs(i))return null;const s=(e*r-t*n)/i,a=(n-s*t)/e;c=e=>a+s*e}const u=l.length,h=l.map(([e,t])=>t-c(e)).reduce((e,t)=>e+t*t,0),p=Math.sqrt(h/Math.max(u-2,1)),y=l.reduce((e,t)=>e+t[0],0)/u,f=l.reduce((e,t)=>e+Math.pow(t[0]-y,2),0),m=null!==(F=e.confidence)&&void 0!==F?F:.95,v=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,b=null!==(D=e.steps)&&void 0!==D?D:5,x=l[u-1][0],k=(x-l[0][0])/Math.max(u-1,1),w=[];for(let e=1;b>=e;e++)w.push(x+e*k);const A=[];for(const e of w){const t=c(e),n=p*Math.sqrt(1+1/u+(f>0?Math.pow(e-y,2)/f:0))*v;A.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const S=`M${A.map(e=>`${s(e.x)},${a(e.yUpper)}`).join(" L")} L${A.slice().reverse().map(e=>`${s(e.x)},${a(e.yLower)}`).join(" L")} Z`,O=A.map(e=>`${s(e.x)},${a(e.yCenter)}`).join(" "),M=`${s(x)},${a(c(x))}`,E=e.strokeColor||"#6366f1";return d.createElement("g",{key:"ann-"+t},d.createElement("path",{d:S,fill:e.fill||"#6366f1",fillOpacity:null!==(R=e.fillOpacity)&&void 0!==R?R:.15,stroke:"none"}),d.createElement("polyline",{points:`${M} ${O}`,fill:"none",stroke:E,strokeWidth:null!==(G=e.strokeWidth)&&void 0!==G?G:2,strokeDasharray:null!==(q=e.strokeDasharray)&&void 0!==q?q:"6,3"}),e.label&&A.length>0&&d.createElement("text",{x:s(A[A.length-1].x)+4,y:a(A[A.length-1].yCenter)-4,fill:E,fontSize:11},e.label))}case"widget":{let o=null,r=null;if(null!=e.px&&null!=e.py)o=e.px,r=e.py;else{const i=ie(e,t,n);if(!i)return null;o=i.x,r=i.y}if(null==o||null==r)return null;if(!se(o,r,n))return null;const i=null!==(Y=e.dx)&&void 0!==Y?Y:0,s=null!==(X=e.dy)&&void 0!==X?X:0,a=null!==(V=e.width)&&void 0!==V?V:32,l=null!==(Q=e.height)&&void 0!==Q?Q:32,c=null!==(U=e.content)&&void 0!==U?U:d.createElement("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info"},"ℹ️");return d.createElement("foreignObject",{key:"ann-"+t,x:o+i-a/2,y:r+s-l/2,width:a,height:l,style:{overflow:"visible",pointerEvents:"auto"}},d.createElement("div",{style:{width:a,height:l,display:"flex",alignItems:"center",justifyContent:"center"}},c))}case"text":{const o=ie(e,t,n);if(!o)return null;const{x:r,y:i}=o;return d.createElement("text",{key:"ann-text-"+t,x:r+(e.dx||0),y:i+(e.dy||0),fill:e.color||"var(--semiotic-text, #333)",fontSize:e.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},e.label)}default:return null}},t={scales:h?{x:h.x,y:h.y,time:h.x,value:h.y}:null,timeAxis:"x",xAccessor:N,yAccessor:H,width:r,height:i,data:z,frameType:"xy",pointNodes:$,curve:T,stickyPositionCache:R.current};return L.map((n,o)=>{if(B){const r=B(n,o,t);return null!=r?r:e(n,o,t)}return e(n,o,t)}).filter(Boolean)},[L,B,r,i,N,H,z,h,$,T]);return p||k||w||j||C||Y&&Y.length>0||x||I?d.createElement("svg",{role:"img",width:s,height:c,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},d.createElement("title",null,"string"==typeof k?k:"XY Chart"),d.createElement("desc",null,"string"==typeof k?k+" — XY data visualization":"XY data visualization"),d.createElement("g",{transform:`translate(${u.left},${u.top})`},x&&h&&!W&&d.createElement("g",{className:"stream-grid"},F.map((e,t)=>d.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),D.map((e,t)=>d.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:r,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),p&&h&&(()=>{const e=null==y?void 0:y.find(e=>"left"===e.orient),t=null==y?void 0:y.find(e=>"bottom"===e.orient),n=!e||!1!==e.baseline,o=(null==e?void 0:e.jaggedBase)||!1,s=(null==t?void 0:t.jaggedBase)||!1,a=null==t?void 0:t.landmarkTicks,l=null==e?void 0:e.landmarkTicks,c="var(--semiotic-border, #ccc)",h="var(--semiotic-text-secondary, #666)",g="var(--semiotic-text, #333)";return d.createElement("g",{className:"stream-axes"},!W&&(!t||!1!==t.baseline)&&!s&&d.createElement("line",{x1:0,y1:i,x2:r,y2:i,stroke:c,strokeWidth:1}),!W&&s&&d.createElement("path",{d:ae("bottom",r,i),fill:"none",stroke:c,strokeWidth:1}),F.map((e,t)=>{const n=!!a&&("function"==typeof a?a(e.value,t):ue(e.value,t>0?F[t-1].value:void 0));return d.createElement("g",{key:"xtick-"+t,transform:`translate(${e.pixel},${i})`},d.createElement("line",{y2:5,stroke:c,strokeWidth:1}),d.createElement("text",{y:18,textAnchor:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:h,style:{userSelect:"none"}},e.label))}),f&&d.createElement("text",{x:r/2,y:i+40,textAnchor:"middle",fontSize:12,fill:g,style:{userSelect:"none"}},f),!W&&n&&!o&&d.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:c,strokeWidth:1}),!W&&o&&d.createElement("path",{d:ae("left",r,i),fill:"none",stroke:c,strokeWidth:1}),D.map((e,t)=>{const n=!!l&&("function"==typeof l?l(e.value,t):ue(e.value,t>0?D[t-1].value:void 0));return d.createElement("g",{key:"ytick-"+t,transform:`translate(0,${e.pixel})`},d.createElement("line",{x2:-5,stroke:c,strokeWidth:1}),d.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:h,style:{userSelect:"none"}},e.label))}),m&&d.createElement("text",{x:15-u.left,y:i/2,textAnchor:"middle",fontSize:12,fill:g,transform:`rotate(-90, ${15-u.left}, ${i/2})`,style:{userSelect:"none"}},m))})(),Y,C&&h&&P&&_&&d.createElement(d.Fragment,null,C.top&&d.createElement("g",{transform:"translate(0, 0)"},d.createElement(K,{orient:"top",config:U(C.top),values:P,scale:h.x,size:u.top,length:r})),C.bottom&&d.createElement("g",{transform:`translate(0, ${i})`},d.createElement(K,{orient:"bottom",config:U(C.bottom),values:P,scale:h.x,size:u.bottom,length:r})),C.left&&d.createElement("g",{transform:"translate(0, 0)"},d.createElement(K,{orient:"left",config:U(C.left),values:_,scale:h.y,size:u.left,length:i})),C.right&&d.createElement("g",{transform:`translate(${r}, 0)`},d.createElement(K,{orient:"right",config:U(C.right),values:_,scale:h.y,size:u.right,length:i}))),j,I),k&&d.createElement("text",{x:s/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof k?k:null),function(e){const{legend:t,totalWidth:n,totalHeight:o,margin:r,legendPosition:i="right",title:s,legendHoverBehavior:a,legendClickBehavior:l,legendHighlightedCategory:c,legendIsolatedCategories:u,legendInteraction:h}=e;if(!t)return null;const g="top"===i||"bottom"===i;let p,y;return"left"===i?(p=4,y=r.top):"top"===i?(p=0,y=s?32:8):"bottom"===i?(p=0,y=o-r.bottom+50):(p=n-r.right+10,y=r.top),d.createElement("g",{transform:`translate(${p}, ${y})`},"object"==typeof(f=t)&&null!==f&&"gradient"in f?d.createElement(V,{config:t.gradient,orientation:g?"horizontal":"vertical",width:g?n:100}):function(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}(t)?d.createElement(Q,{legendGroups:t.legendGroups,title:"",width:g?n:100,orientation:g?"horizontal":"vertical",customHoverBehavior:a,customClickBehavior:l,highlightedCategory:c,isolatedCategories:u,legendInteraction:h}):t);var f}({legend:w,totalWidth:s,totalHeight:c,margin:u,legendPosition:E,title:k,legendHoverBehavior:A,legendClickBehavior:S,legendHighlightedCategory:O,legendIsolatedCategories:M})):null}const de="undefined"==typeof window||"undefined"==typeof document,ge={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function pe(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e)n[t.type]=(n[t.type]||0)+1;const o=[],r={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks"},i=["point","line","area","rect","heatcell","circle","candlestick"],s=Object.keys(n).sort((e,t)=>{const n=i.indexOf(e),o=i.indexOf(t);return(-1===n?999:n)-(-1===o?999:o)});for(const e of s)o.push(`${n[e]} ${r[e]||e}`);return`${t}, ${o.join(", ")}`}function ye({scene:e,chartType:t}){var n,o,r,i;const s=[];for(const t of e){if(s.length>=50)break;"point"===t.type?s.push({label:"Point",values:{x:Math.round(100*t.x)/100+"",y:Math.round(100*t.y)/100+""}}):"rect"===t.type?s.push({label:"Bar",values:{category:(null===(n=t.datum)||void 0===n?void 0:n.category)||"",value:Math.round(100*(null!==(r=null===(o=t.datum)||void 0===o?void 0:o.value)&&void 0!==r?r:0))/100+""}}):"heatcell"===t.type&&s.push({label:"Cell",values:{x:Math.round(100*t.x)/100+"",y:Math.round(100*t.y)/100+"",value:Math.round(100*(null!==(i=t.value)&&void 0!==i?i:0))/100+""}})}if(0===s.length)return null;const a=new Set;for(const e of s)for(const t of Object.keys(e.values))a.add(t);const l=Array.from(a);return d.createElement("table",{style:ge,role:"table","aria-label":"Data table for "+t},d.createElement("thead",null,d.createElement("tr",null,l.map(e=>d.createElement("th",{key:e},e)))),d.createElement("tbody",null,s.map((e,t)=>d.createElement("tr",{key:t},l.map(t=>{var n;return d.createElement("td",{key:t},null!==(n=e.values[t])&&void 0!==n?n:"")}))),e.length>50&&d.createElement("tr",null,d.createElement("td",{colSpan:l.length},"...and ",e.length-50," more items"))))}function fe({hoverPoint:e}){let t="";if(e){const n=e.data||e;t="object"==typeof n?"Focused on data point: "+Object.entries(n).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Focused on data point: "+n}return d.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:ge},t)}function me(t){const n=e.createContext(null),o=ve(t);return[function({children:o}){const r=e.useMemo(()=>ve(t),[]);return d.createElement(n.Provider,{value:r,children:o})},t=>{var r;const i=null!==(r=e.useContext(n))&&void 0!==r?r:o,s=e.useRef(t);s.current=t;const a=e.useCallback(()=>s.current(i.getState()),[i]),l=e.useCallback(()=>s.current(i.getState()),[i]);return e.useSyncExternalStore(i.subscribe,a,l)}]}function ve(e){const t=new EventTarget;let n=e(function(e){n=Object.assign(Object.assign({},n),e(n)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}const be={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},xe={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},[ke,we]=me(e=>({theme:be,setTheme(t){e(e=>"light"===t?{theme:be}:"dark"===t?{theme:xe}:{theme:Object.assign(Object.assign(Object.assign({},e.theme),t),{colors:Object.assign(Object.assign({},e.theme.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.theme.typography),t.typography||{})})})}}));function Ae(e,t,n,o){const r=e.getContext("2d");if(!r)return null;const i=t[0]*o,s=t[1]*o,a=t[0]+"px",l=t[1]+"px";return e.style.width!==a&&(e.style.width=a),e.style.height!==l&&(e.style.height=l),e.width===i&&e.height===s||(e.width=i,e.height=s),r.setTransform(o,0,0,o,0,0),r.translate(n.left,n.top),r}function Se(e){switch(e){case"monotoneX":return l.curveMonotoneX;case"monotoneY":return l.curveMonotoneY;case"cardinal":return l.curveCardinal;case"catmullRom":return l.curveCatmullRom;case"step":return l.curveStep;case"stepBefore":return l.curveStepBefore;case"stepAfter":return l.curveStepAfter;case"basis":return l.curveBasis;case"natural":return l.curveNatural;default:return null}}function Oe(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}function Me(e,t,n,o,r,i){if(2>t.length)return;const s=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],o=t[e][1]-t[e-1][1];s.push(s[e-1]+Math.sqrt(n*n+o*o))}const a=s[s.length-1];if(0===a)return;const l=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=o,e.lineCap=i;for(let n=0;t.length-1>n;n++){const o=(s[n]+s[n+1])/2;let i=r;l>o&&(i*=o/l),l>a-o&&(i*=(a-o)/l),e.globalAlpha=Math.max(0,i),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}function Ee(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function je(e,t,n=.3){Ee(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function Ce(e,t,n=.6){var o,r,i,s,a;if(!Ee(t))return;const l=null!==(o=t._pulseGlowRadius)&&void 0!==o?o:4,c=t.r+l*t._pulseIntensity,u=null!==(i=null!==(r=t.cx)&&void 0!==r?r:t.x)&&void 0!==i?i:0,h=null!==(a=null!==(s=t.cy)&&void 0!==s?s:t.y)&&void 0!==a?a:0;e.beginPath(),e.arc(u,h,c,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function Pe(e,t,n,o=.35){Ee(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill())}function _e(e){switch(e){case"monotoneX":return l.curveMonotoneX;case"monotoneY":return l.curveMonotoneY;case"cardinal":return l.curveCardinal;case"catmullRom":return l.curveCatmullRom;case"step":return l.curveStep;case"stepBefore":return l.curveStepBefore;case"stepAfter":return l.curveStepAfter;case"basis":return l.curveBasis;case"natural":return l.curveNatural;default:return null}}function Le(e){if(e.startsWith("#")){const t=4===e.length?e[1]+e[1]+e[2]+e[2]+e[3]+e[3]:e.slice(1,7);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[78,121,167]}function Be(e,t){const n=_e(t.curve);if(!n||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath()}else{const o=l.area().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),o(t.topPath)}}const Ne=(e,t,n,o)=>{var r,i,s;const a=t.filter(e=>"area"===e.type);for(const t of a){if(2>t.topPath.length)continue;const n=t.style.fill||"#4e79a7",o=t._decayOpacities;if(o&&o.length===t.topPath.length){const i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:.7;e.fillStyle=n;for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(o[n]+o[n+1])*i,e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.lineTo(t.bottomPath[n+1][0],t.bottomPath[n+1][1]),e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(o[n]+o[n+1]),e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.stroke()}e.globalAlpha=1;continue}const a=null!==(i=t.style.opacity)&&void 0!==i?i:1;if(Be(e,t),t.fillGradient){let o=1/0;for(const e of t.topPath)o>e[1]&&(o=e[1]);let r=-1/0;for(const e of t.bottomPath)e[1]>r&&(r=e[1]);const i=Le(n),s=t.fillGradient.topOpacity,l=t.fillGradient.bottomOpacity,c=e.createLinearGradient(0,o,0,r);c.addColorStop(0,`rgba(${i[0]},${i[1]},${i[2]},${s})`),c.addColorStop(1,`rgba(${i[0]},${i[1]},${i[2]},${l})`),e.fillStyle=c,e.globalAlpha=a}else{const o=null!==(s=t.style.fillOpacity)&&void 0!==s?s:.7;e.globalAlpha=o*a,e.fillStyle=n}if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(Be(e,t),Pe(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=a,e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const n=_e(t.curve);if(e.beginPath(),n)l.line().x(e=>e[0]).y(e=>e[1]).curve(n).context(e)(t.topPath);else{e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1])}e.stroke()}e.globalAlpha=1}},He=(e,t,n,o)=>{var r;const i=t.filter(e=>"point"===e.type);e.save();try{for(const t of i){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(r=t.style.opacity)&&void 0!==r?r:t.style.fillOpacity;null!=n&&(e.globalAlpha=n),e.fillStyle=t.style.fill||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),Ce(e,t),e.globalAlpha=1}}finally{e.restore()}},ze=(e,t,n,o)=>{const r=t.filter(e=>"rect"===e.type);for(const t of r)null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon?$e(e,t):(e.fillStyle=t.style.fill||"#007bff",e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))),je(e,t),e.globalAlpha=1};function $e(e,t){const n=t.style.icon,o=t.style.iconPadding||2,r=Math.min(t.w,t.h)-o;if(0>=r)return;const i=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),i){const i=r+o,s=t.x+(t.w-r)/2;for(let o=t.y+t.h-r;o>=t.y-r;o-=i)e.drawImage(n,s,o,r,r)}else{const i=r+o,s=t.y+(t.h-r)/2;for(let o=t.x;t.x+t.w>o;o+=i)e.drawImage(n,o,s,r,r)}e.restore()}function Te(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>128?"#000":"#fff"}function We(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}const Ie={line:[Ne,(e,t,n,o)=>{var r,i;const s=t.filter(e=>"line"===e.type);for(const a of s){if(2>a.path.length)continue;const c=a.style.stroke||"#007bff",u=a.style.strokeWidth||2,h=a.colorThresholds,d=a.rawValues;if(e.setLineDash(a.style.strokeDasharray?a.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=a.style.opacity&&(e.globalAlpha=a.style.opacity),e.lineWidth=u,e.lineCap=a.style.strokeLinecap||"butt",a.style._edgeFade){const f=null!==(r=a.style.opacity)&&void 0!==r?r:1;Me(e,a.path,c,u,f,a.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const g=Se(a.curve),p=h&&h.length>0&&d&&d.length===a.path.length,y=a._decayOpacities;if(y&&y.length===a.path.length&&!p){e.strokeStyle=c;const m=null!==(i=a.style.opacity)&&void 0!==i?i:1;for(let v=0;a.path.length-1>v;v++)e.globalAlpha=.5*(y[v]+y[v+1])*m,e.beginPath(),e.moveTo(a.path[v][0],a.path[v][1]),e.lineTo(a.path[v+1][0],a.path[v+1][1]),e.stroke()}else if(p){let b=null,x=null,k=null,w=null,A=!1;function S(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),A=!0}function O(){A&&(e.stroke(),A=!1)}for(let M=0;a.path.length>M;M++){const[E,j]=a.path[M],C=d[M],P=Oe(C,h,c);if(null!==b&&null!==w&&null!==k){if(P===w)e.lineTo(E,j);else{const _=[];for(const L of h){const B=L.value;(k>B||B>C)&&(B>k||C>B)||k===B||C===B||_.push({t:(B-k)/(C-k)})}_.sort((e,t)=>e.t-t.t);for(const N of _){const H=b+(E-b)*N.t,z=x+(j-x)*N.t,$=Oe(k+(C-k)*Math.min(N.t+1e-4,1),h,c);e.lineTo(H,z),O(),S($,H,z)}e.lineTo(E,j)}b=E,x=j,k=C,w=P}else S(P,E,j),b=E,x=j,k=C,w=P}O()}else{if(e.beginPath(),e.strokeStyle=c,g)l.line().x(e=>e[0]).y(e=>e[1]).curve(g).context(e)(a.path);else{const[T,W]=a.path[0];e.moveTo(T,W);for(let I=1;a.path.length>I;I++)e.lineTo(a.path[I][0],a.path[I][1])}e.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=a.style.fillOpacity,e.fillStyle=a.style.fill,g&&!p)l.line().x(e=>e[0]).y(e=>e[1]).curve(g).context(e)(a.path);else{const[D,R]=a.path[0];e.moveTo(D,R);for(let G=1;a.path.length>G;G++)e.lineTo(a.path[G][0],a.path[G][1])}const F=a.path[0][0];e.lineTo(a.path[a.path.length-1][0],o.height),e.lineTo(F,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}}],area:[Ne],stackedarea:[Ne],scatter:[He],bubble:[He],heatmap:[(e,t,n,o)=>{const r=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of r){const n=t.style;if(null!=(null==n?void 0:n.opacity)&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle="#fff",e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),je(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const n=t.valueFormat?t.valueFormat(t.value):We(t.value),o=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),r=t.x+t.w/2,i=t.y+t.h/2;e.fillStyle=Te(t.fill),e.font=o+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,r,i)}}}finally{e.restore()}}],bar:[ze],swarm:[He],waterfall:[(e,t,n,o)=>{var r,i,s;ze(e,t);const a=t.filter(e=>"rect"===e.type);if(2>a.length)return;const l=a[0].datum,c=null==l?void 0:l._connectorStroke;if(c){e.save(),e.strokeStyle=c,e.lineWidth=null!==(r=null==l?void 0:l._connectorWidth)&&void 0!==r?r:1,e.setLineDash([]);for(let t=0;a.length-1>t;t++){const o=a[t],r=a[t+1];if(!(null===(i=o.datum)||void 0===i?void 0:i.cumEnd)||!(null===(s=r.datum)||void 0===s?void 0:s.baseline))continue;const l=n.y(o.datum.cumEnd),c=o.x+o.w,u=r.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[(e,t,n,o)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const o=t._decayOpacity;null!=o&&1!==o&&(e.globalAlpha=o),e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=t.wickColor,e.lineWidth=t.wickWidth,e.stroke();const r=Math.min(t.openY,t.closeY),i=Math.abs(t.openY-t.closeY),s=t.isUp?t.upColor:t.downColor;e.fillStyle=s,e.fillRect(t.x-t.bodyWidth/2,r,t.bodyWidth,Math.max(i,1)),e.strokeStyle=s,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,r,t.bodyWidth,Math.max(i,1)),e.restore()}}]},Fe={top:20,right:20,bottom:30,left:40},De={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white"},Re={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Ge({hover:e}){const t=e=>Number.isInteger(e)?e+"":e.toFixed(2);return d.createElement("div",{className:"semiotic-tooltip",style:Re},d.createElement("div",{style:{fontWeight:600,marginBottom:2}},t(e.value)),d.createElement("div",{style:{opacity:.7,fontSize:11}},t(e.time)))}function qe({width:o,height:r,totalWidth:i,totalHeight:s,margin:a,dimension:l,scales:c,onBrush:u}){const h=e.useRef(null),g=e.useRef(null),p=e.useRef(u);p.current=u;const y=e.useRef(c);return y.current=c,e.useEffect(()=>{if(!h.current)return;const e=n.select(h.current).select(".brush-g"),i="x"===l?t.brushX():"y"===l?t.brushY():t.brush();return i.extent([[0,0],[o,r]]),i.on("brush end",e=>{const t=y.current;if(!t)return;if(!e.selection)return void p.current(null);let n,i;if("x"===l){const[o,s]=e.selection;n=[t.x.invert(o),t.x.invert(s)],i=[t.y.invert(r),t.y.invert(0)]}else if("y"===l){const[r,s]=e.selection;n=[t.x.invert(0),t.x.invert(o)],i=[t.y.invert(s),t.y.invert(r)]}else{const[[o,r],[s,a]]=e.selection;n=[t.x.invert(o),t.x.invert(s)],i=[t.y.invert(a),t.y.invert(r)]}p.current({x:n,y:i})}),e.call(i),g.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),g.current=null}},[o,r,l]),d.createElement("svg",{ref:h,width:i,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},d.createElement("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`}))}const Ye=e.forwardRef(function(t,n){var o,r,i,s,a,l,c,u,h;const{chartType:g,runtimeMode:y,data:f,chunkThreshold:m,chunkSize:v,xAccessor:b,yAccessor:x,colorAccessor:k,sizeAccessor:w,groupAccessor:A,lineDataAccessor:S,curve:O,normalize:M,binSize:E,valueAccessor:j,arrowOfTime:C="right",windowMode:P="sliding",windowSize:_=200,timeAccessor:L,xExtent:B,yExtent:H,extentPadding:T=.1,sizeRange:R,size:G=[500,300],responsiveWidth:q,responsiveHeight:Y,margin:X,className:V,background:Q,lineStyle:U,pointStyle:K,areaStyle:Z,waterfallStyle:J,swarmStyle:ee,barColors:te,colorScheme:ne,boundsAccessor:oe,boundsStyle:re,y0Accessor:ie,gradientFill:se,openAccessor:ae,highAccessor:ce,lowAccessor:ue,closeAccessor:ge,candlestickStyle:me,showAxes:ve=!0,axes:be,xLabel:xe,yLabel:ke,xFormat:Se,yFormat:Oe,tickFormatTime:Me,tickFormatValue:Ee,hoverAnnotation:je,tooltipContent:Ce,customHoverBehavior:Pe,enableHover:_e,annotations:Le,svgAnnotationRules:Be,showGrid:Ne,legend:He,legendHoverBehavior:ze,legendClickBehavior:$e,legendHighlightedCategory:Te,legendIsolatedCategories:We,legendPosition:Re,backgroundGraphics:Ye,foregroundGraphics:Xe,canvasPreRenderers:Ve,title:Qe,categoryAccessor:Ue,brush:Ke,onBrush:Ze,decay:Je,pulse:et,transition:tt,staleness:nt,heatmapAggregation:ot,heatmapXBins:rt,heatmapYBins:it,showValues:st,heatmapValueFormat:at,marginalGraphics:lt,pointIdAccessor:ct,xScaleType:ut,yScaleType:ht,accessibleTable:dt}=t,[gt,pt]=function(t,n,o){const r=e.useRef(null),[i,s]=e.useState(null);return e.useEffect(()=>{if(!n&&!o)return;const e=r.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;s(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[n,o]),[r,[n&&i?i.w:t[0],o&&i?i.h:t[1]]]}(G,q,Y),yt=Object.assign(Object.assign({},Fe),X);if(lt){const e=60;lt.top&&e>yt.top&&(yt.top=e),lt.bottom&&e>yt.bottom&&(yt.bottom=e),lt.left&&e>yt.left&&(yt.left=e),lt.right&&e>yt.right&&(yt.right=e)}const ft=pt[0]-yt.left-yt.right,mt=pt[1]-yt.top-yt.bottom,vt="function"==typeof Xe?Xe({size:pt,margin:yt}):Xe,bt="function"==typeof Ye?Ye({size:pt,margin:yt}):Ye,xt=null!=je?je:_e,kt=e.useRef(null),wt=e.useRef(null),At=e.useRef(0),St=e.useRef(!1),Ot=we(e=>e.theme),[Mt,Et]=e.useState(0),[jt,Ct]=e.useState(null),Pt=e.useRef(null),_t=e.useRef(null),[Lt,Bt]=e.useState(null),[Nt,Ht]=e.useState(!1),[zt,$t]=e.useState([]),[Tt,Wt]=e.useState([]),It=e.useRef(()=>{}),Ft="streaming"===y||["bar","swarm","waterfall"].includes(g),Dt=e.useMemo(()=>({chartType:g,runtimeMode:Ft?"streaming":"bounded",windowSize:_,windowMode:P,arrowOfTime:Ft?C:"right",extentPadding:T,xAccessor:Ft?void 0:b,yAccessor:Ft?void 0:x,timeAccessor:Ft?L:void 0,valueAccessor:j,colorAccessor:k,sizeAccessor:w,groupAccessor:A,categoryAccessor:Ue,lineDataAccessor:S,xScaleType:ut,yScaleType:ht,xExtent:B,yExtent:H,sizeRange:R,binSize:E,normalize:M,boundsAccessor:oe,boundsStyle:re,y0Accessor:ie,gradientFill:"boolean"==typeof se?se?{topOpacity:.8,bottomOpacity:.05}:void 0:se,openAccessor:ae,highAccessor:ce,lowAccessor:ue,closeAccessor:ge,candlestickStyle:me,lineStyle:U,pointStyle:K,areaStyle:Z,swarmStyle:ee,waterfallStyle:J,colorScheme:ne,barColors:te,annotations:Le,decay:Je,pulse:et,transition:tt,staleness:nt,heatmapAggregation:ot,heatmapXBins:rt,heatmapYBins:it,showValues:st,heatmapValueFormat:at,pointIdAccessor:ct,curve:O}),[g,_,P,C,T,b,x,L,j,ut,ht,k,w,A,Ue,S,B,H,R,E,M,oe,re,ie,se,ae,ce,ue,ge,me,U,K,Z,ee,J,ne,te,Le,Je,et,tt,nt,ot,rt,it,st,at,Ft,ct,O]),Rt=e.useRef(null);Rt.current||(Rt.current=new N(Dt));const Gt=e.useCallback(()=>{At.current||(At.current=requestAnimationFrame(()=>It.current()))},[]);e.useEffect(()=>{var e;null===(e=Rt.current)||void 0===e||e.updateConfig(Dt),St.current=!0,Gt()},[Dt,Gt]),e.useEffect(()=>{St.current=!0,Gt()},[Ot,Gt]);const qt=e.useRef(null);qt.current||(qt.current=new p(e=>{const t=Rt.current;t&&t.ingest(e)&&(St.current=!0,Gt())},{chunkThreshold:m,chunkSize:v})),e.useEffect(()=>{var e;null===(e=qt.current)||void 0===e||e.updateChunkOptions({chunkThreshold:m,chunkSize:v})},[m,v]);const Yt=e.useCallback(e=>{var t;null===(t=qt.current)||void 0===t||t.push(e)},[]),Xt=e.useCallback(e=>{var t;null===(t=qt.current)||void 0===t||t.pushMany(e)},[]),Vt=e.useCallback(()=>{var e,t;null===(e=qt.current)||void 0===e||e.clear(),null===(t=Rt.current)||void 0===t||t.clear(),St.current=!0,Gt()},[Gt]);e.useImperativeHandle(n,()=>({push:Yt,pushMany:Xt,clear:Vt,getData:()=>{var e,t,n;return null===(e=qt.current)||void 0===e||e.flush(),null!==(n=null===(t=Rt.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var e,t;return null!==(t=null===(e=Rt.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=Rt.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[Yt,Xt,Vt]),e.useEffect(()=>{var e;f&&(null===(e=qt.current)||void 0===e||e.setBoundedData(f))},[f]);const Qt=e.useRef(()=>{}),Ut=e.useRef(()=>{});Qt.current=e=>{if(!xt)return;const t=kt.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-yt.left,r=e.clientY-n.top-yt.top;if(0>o||o>ft||0>r||r>mt)return void(Pt.current&&(Pt.current=null,_t.current=null,Bt(null),Pe&&(Pe(null),St.current=!0),Gt()));const i=Rt.current;if(!i||0===i.scene.length)return;const s=function(e,t,n,o=30,r){let i=null,s=!1;if(r){const e=r.find(t,n,o);if(e){const r=z(e,t,n);r&&o>r.distance&&(i=r,s=!0)}}for(const a of e){let e=null;switch(a.type){case"point":if(r&&s)break;e=z(a,t,n);break;case"line":e=$(a,t,n);break;case"rect":e=W(a,t,n);break;case"heatcell":e=I(a,t,n);break;case"area":if(!1===a.interactive)break;e=D(a,t,n);break;case"candlestick":e=F(a,t,n)}e&&o>e.distance&&(i&&e.distance>=i.distance||(i=e))}return i}(i.scene,o,r,30,i.quadtree);if(!s)return void(Pt.current&&(Pt.current=null,_t.current=null,Bt(null),Pe&&Pe(null),Gt()));const a=s.datum||{},l=Object.assign(Object.assign({},"object"!=typeof a||null===a||Array.isArray(a)?{}:a),{data:a,time:s.x,value:s.y,x:s.x,y:s.y});Pt.current=l,_t.current=s.node,Bt(l),Pe&&(Pe(l),St.current=!0),Gt()},Ut.current=()=>{Pt.current&&(Pt.current=null,_t.current=null,Bt(null),Pe&&(Pe(null),St.current=!0),Gt())},e.useCallback(e=>Qt.current(e),[]);const Kt=e.useCallback(()=>Ut.current(),[]),Zt=e.useRef(-1),Jt=e.useCallback(e=>{const t=Rt.current;if(!t||0===t.scene.length)return;const n=function(e){const t=[];for(const n of e)switch(n.type){case"point":t.push({x:n.x,y:n.y,datum:n.datum});break;case"line":{const e=n,o=Array.isArray(e.datum)?e.datum:[];for(let n=0;e.path.length>n&&o.length>n;n++)t.push({x:e.path[n][0],y:e.path[n][1],datum:o[n]});break}case"area":{const e=n,o=Array.isArray(e.datum)?e.datum:[];for(let n=0;e.topPath.length>n&&o.length>n;n++)t.push({x:e.topPath[n][0],y:e.topPath[n][1],datum:o[n]});break}case"rect":case"heatcell":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.scene);if(0===n.length)return;const o=0>Zt.current?-1:Zt.current,r=function(e,t,n){switch(e){case"ArrowRight":case"ArrowDown":return n-1>t?t+1:t;case"ArrowLeft":case"ArrowUp":return t>0?t-1:t;case"Home":return 0;case"End":return n-1;case"Escape":return-1;default:return null}}(e.key,0>o?-1:o,n.length);if(null===r)return;if(e.preventDefault(),0>r)return Zt.current=-1,Pt.current=null,_t.current=null,Bt(null),Pe&&Pe(null),void Gt();const i=0>o?0:r;Zt.current=i;const s=function(e){const t=e.datum||{};return Object.assign(Object.assign({},"object"!=typeof t||null===t||Array.isArray(t)?{}:t),{data:t,x:e.x,y:e.y,time:e.x,value:e.y})}(n[i]);Pt.current=s,Bt(s),Pe&&Pe(s),Gt()},[Pe,Gt]),en=e.useCallback(e=>{Zt.current=-1,Qt.current(e)},[]);It.current=()=>{var e,t;At.current=0;const n=kt.current,o=wt.current;if(!n||!o)return;const r=Rt.current;if(!r)return;const i="undefined"!=typeof performance?performance.now():Date.now(),s=r.advanceTransition(i),a=St.current||s;a&&!s&&r.computeScene({width:ft,height:mt});const l="undefined"!=typeof window&&window.devicePixelRatio||1,c=function(e){if(!e)return De;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),r=t.getPropertyValue("--semiotic-bg").trim(),i=o||t.getPropertyValue("--text-secondary").trim(),s=t.getPropertyValue("--text-primary").trim(),a=n||t.getPropertyValue("--surface-3").trim(),l=r||t.getPropertyValue("--surface-0").trim();return i||s||n?{axisStroke:a||De.axisStroke,tickText:i||De.tickText,crosshair:i?i+"66":De.crosshair,hoverFill:l?l+"4D":De.hoverFill,hoverStroke:i?i+"99":De.hoverStroke,pointRing:l||De.pointRing}:De}(n),u=null!==(e=null==nt?void 0:nt.threshold)&&void 0!==e?e:5e3,h=nt&&r.lastIngestTime>0&&i-r.lastIngestTime>u;if(a){const e=Ae(n,pt,yt,l);if(e){e.clearRect(-yt.left,-yt.top,pt[0],pt[1]),h&&(e.globalAlpha=null!==(t=null==nt?void 0:nt.dimOpacity)&&void 0!==t?t:.5);const o=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=Q||(o&&"transparent"!==o?o:null);if(i&&(e.fillStyle=i,e.fillRect(-yt.left,-yt.top,pt[0],pt[1])),e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,ft,mt),e.clip()),Ve&&r.scales)for(const t of Ve)e.save(),t(e,r.scene,r.scales,{width:ft,height:mt}),e.restore();const s=Ie[g];if(s&&r.scales)for(const t of s)t(e,r.scene,r.scales,{width:ft,height:mt});e.restore(),h&&(e.globalAlpha=1)}}{const e=Ae(o,pt,yt,l);if(e&&(e.clearRect(-yt.left,-yt.top,pt[0],pt[1]),xt&&Pt.current&&r.scales&&function(e,t,n,o,r,i,s){if(!1===r.crosshair)return;e.save();const a="object"==typeof r.crosshair?r.crosshair:{};e.strokeStyle=a.stroke||s.crosshair,e.lineWidth=a.strokeWidth||1,e.setLineDash(a.strokeDasharray?a.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(t.x,0),e.lineTo(t.x,o),e.stroke(),e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke(),e.restore(),e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle="#007bff",e.fill(),e.strokeStyle=s.pointRing,e.lineWidth=2,e.stroke()}(e,Pt.current,ft,mt,"object"==typeof xt?xt:{},0,c),_t.current&&Array.isArray(je))){const t=je.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,o){var r;if(!n)return;const i=n.group;if(void 0!==i)for(const n of t){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const t="function"==typeof o.style?o.style(n.datum):o.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||"#007bff",e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=null!==(r=t.opacity)&&void 0!==r?r:1,e.stroke(),e.restore()}}(e,r.scene,_t.current,t)}}a&&n&&n.setAttribute("aria-label",pe(r.scene,g+" chart"));const d=St.current;if(St.current=!1,d&&r.scales&&((!jt||jt.x.domain()[0]!==r.scales.x.domain()[0]||jt.x.domain()[1]!==r.scales.x.domain()[1]||jt.y.domain()[0]!==r.scales.y.domain()[0]||jt.y.domain()[1]!==r.scales.y.domain()[1]||jt.x.range()[0]!==r.scales.x.range()[0]||jt.x.range()[1]!==r.scales.x.range()[1]||jt.y.range()[0]!==r.scales.y.range()[0]||jt.y.range()[1]!==r.scales.y.range()[1])&&Ct(r.scales),lt)){const e=r.getData(),t="function"==typeof b?b:e=>e[b||"x"],n="function"==typeof x?x:e=>e[x||"y"];$t(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),Wt(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}d&&Le&&Le.length>0&&Et(e=>e+1),(null==nt?void 0:nt.showBadge)&&Ht(!!h),(s||r.hasActivePulses)&&(At.current=requestAnimationFrame(()=>It.current()))},e.useEffect(()=>(Gt(),()=>{At.current&&(cancelAnimationFrame(At.current),At.current=0)}),[Gt]),e.useEffect(()=>{St.current=!0,Gt()},[g,ft,mt,ve,Q,U,Ve,Gt]),function(t,n,o,r,i,s){e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{var e;const a=n.current;if(!a||0===a.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(e=t.threshold)&&void 0!==e?e:5e3,u=l-a.lastIngestTime>c;u!==i&&(s(u),o.current=!0,r())},1e3);return()=>clearInterval(e)},[t,i,r])}(nt,Rt,St,Gt,Nt,Ht);const tn=xt&&Lt?Ce?Ce(Lt):d.createElement(Ge,{hover:Lt}):null,nn=tn?d.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:yt.left+Lt.x,top:yt.top+Lt.y,transform:`translate(${Lt.x>.7*ft?"calc(-100% - 12px)":"12px"}, ${.3*mt>Lt.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1,width:"max-content"}},tn):null,on=Zt.current>=0&&Lt?d.createElement("svg",{style:{position:"absolute",left:0,top:0,width:pt[0],height:pt[1],pointerEvents:"none",zIndex:2}},d.createElement("circle",{cx:Lt.x+yt.left,cy:Lt.y+yt.top,r:8,fill:"none",stroke:"var(--accent, #6366f1)",strokeWidth:2,strokeDasharray:"4,2"})):null;if(de){const e=Rt.current;e&&f&&(e.ingest({inserts:f,bounded:!0}),e.computeScene({width:ft,height:mt}));const t=null!==(o=null==e?void 0:e.scene)&&void 0!==o?o:[],n=null!==(r=null==e?void 0:e.scales)&&void 0!==r?r:null;return d.createElement("div",{className:"stream-xy-frame"+(V?" "+V:""),role:"img","aria-label":"string"==typeof Qe?Qe:"XY chart",style:{position:"relative",width:pt[0],height:pt[1]}},d.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:pt[0],height:pt[1],style:{position:"absolute",left:0,top:0}},bt,d.createElement("g",{transform:`translate(${yt.left},${yt.top})`},Q&&d.createElement("rect",{x:0,y:0,width:ft,height:mt,fill:Q}),t.map((e,t)=>function(e,t){var n,o,r;switch(e.type){case"line":{const n=e;if(0===n.path.length)return null;const o="M"+n.path.map(([e,t])=>`${e},${t}`).join("L");return d.createElement("path",{key:"line-"+t,d:o,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity})}case"area":{const r=e;if(0===r.topPath.length)return null;const i=r.topPath.map(([e,t])=>`${e},${t}`).join("L"),s=[...r.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L");return d.createElement("path",{key:"area-"+t,d:`M${i}L${s}Z`,fill:r.style.fill||"#4e79a7",fillOpacity:null!==(o=null!==(n=r.style.fillOpacity)&&void 0!==n?n:r.style.opacity)&&void 0!==o?o:.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})}case"point":return d.createElement("circle",{key:"point-"+t,cx:e.x,cy:e.y,r:e.r,fill:e.style.fill||"#4e79a7",opacity:null!==(r=e.style.opacity)&&void 0!==r?r:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth});case"rect":return d.createElement("rect",{key:"rect-"+t,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.style.fill||"#4e79a7",opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth});case"heatcell":{const n=e;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const e=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[o,r,i]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(n.fill),s=.299*o+.587*r+.114*i>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return d.createElement("g",{key:"heatcell-"+t},d.createElement("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),d.createElement("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px"},e))}return d.createElement("rect",{key:"heatcell-"+t,x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill})}case"candlestick":{const n=e,o=Math.min(n.openY,n.closeY),r=Math.max(Math.abs(n.openY-n.closeY),1),i=n.isUp?n.upColor:n.downColor;return d.createElement("g",{key:"candle-"+t},d.createElement("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),d.createElement("rect",{x:n.x-n.bodyWidth/2,y:o,width:n.bodyWidth,height:r,fill:i,stroke:i,strokeWidth:1}))}default:return null}}(e,t)).filter(Boolean))),d.createElement(he,{width:ft,height:mt,totalWidth:pt[0],totalHeight:pt[1],margin:yt,scales:n,showAxes:ve,axes:be,xLabel:xe,yLabel:ke,xFormat:Se||Me,yFormat:Oe||Ee,showGrid:Ne,title:Qe,legend:He,legendHoverBehavior:ze,legendClickBehavior:$e,legendHighlightedCategory:Te,legendIsolatedCategories:We,legendPosition:Re,foregroundGraphics:vt,marginalGraphics:lt,xValues:[],yValues:[],annotations:Le,svgAnnotationRules:Be,annotationFrame:0,xAccessor:"string"==typeof b?b:"string"==typeof L?L:void 0,yAccessor:"string"==typeof x?x:"string"==typeof j?j:void 0,annotationData:null==e?void 0:e.getData(),pointNodes:null==e?void 0:e.scene.filter(e=>"point"===e.type),curve:"string"==typeof O?O:void 0}))}return d.createElement("div",{ref:gt,className:"stream-xy-frame"+(V?" "+V:""),role:"img","aria-label":"string"==typeof Qe?Qe:"XY chart",tabIndex:0,style:{position:"relative",width:q?"100%":pt[0],height:Y?"100%":pt[1],overflow:"visible"},onMouseMove:xt?en:void 0,onMouseLeave:xt?Kt:void 0,onKeyDown:Jt},bt&&d.createElement("svg",{style:{position:"absolute",left:0,top:0,width:pt[0],height:pt[1],pointerEvents:"none"}},bt),d.createElement(le,{width:ft,height:mt,totalWidth:pt[0],totalHeight:pt[1],margin:yt,scales:jt,showAxes:ve,axes:be,showGrid:Ne,xFormat:Se||Me,yFormat:Oe||Ee}),d.createElement("canvas",{ref:kt,"aria-label":pe(null!==(s=null===(i=Rt.current)||void 0===i?void 0:i.scene)&&void 0!==s?s:[],g+" chart"),style:{position:"absolute",left:0,top:0}}),d.createElement("canvas",{ref:wt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),d.createElement(fe,{hoverPoint:Lt}),dt&&d.createElement(ye,{scene:null!==(l=null===(a=Rt.current)||void 0===a?void 0:a.scene)&&void 0!==l?l:[],chartType:g+" chart"}),d.createElement(he,{width:ft,height:mt,totalWidth:pt[0],totalHeight:pt[1],margin:yt,scales:jt,showAxes:ve,axes:be,xLabel:xe,yLabel:ke,xFormat:Se||Me,yFormat:Oe||Ee,showGrid:Ne,title:Qe,legend:He,legendHoverBehavior:ze,legendClickBehavior:$e,legendHighlightedCategory:Te,legendIsolatedCategories:We,legendPosition:Re,foregroundGraphics:vt,marginalGraphics:lt,xValues:zt,yValues:Tt,annotations:Le,svgAnnotationRules:Be,annotationFrame:Mt,xAccessor:"string"==typeof b?b:"string"==typeof L?L:void 0,yAccessor:"string"==typeof x?x:"string"==typeof j?j:void 0,annotationData:null===(c=Rt.current)||void 0===c?void 0:c.getData(),pointNodes:null===(u=Rt.current)||void 0===u?void 0:u.scene.filter(e=>"point"===e.type),curve:"string"==typeof O?O:void 0,underlayRendered:!0}),(Ke||Ze)&&d.createElement(qe,{width:ft,height:mt,totalWidth:pt[0],totalHeight:pt[1],margin:yt,dimension:null!==(h=null==Ke?void 0:Ke.dimension)&&void 0!==h?h:"xy",scales:jt,onBrush:null!=Ze?Ze:()=>{}}),(null==nt?void 0:nt.showBadge)&&d.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===nt.badgePosition?{top:4,left:4}:"bottom-left"===nt.badgePosition?{bottom:4,left:4}:"bottom-right"===nt.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Nt?"#dc3545":"#28a745",color:"white"})},Nt?"STALE":"LIVE"),on,nn)});Ye.displayName="StreamXYFrame";const Xe=e.createContext(null);function Ve(){return e.useContext(Xe)}function Qe(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,r]=o.range;t.push(t=>{const o=t[n];return o>=e&&r>=o})}return e=>t.every(t=>t(e))}function Ue(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[Ke,Ze]=me(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),r=Ue(o,t),i=new Map(r.clauses);return i.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},r),{clauses:i})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const r=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),r.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:r}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),r=Ue(o,t);return o.set(t,Object.assign(Object.assign({},r),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}})),[Je,et]=me(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function tt(t){const n=e.useId(),o=t.clientId||n,{name:r}=t,i=Ze(e=>e.selections.get(r)),s=Ze(e=>e.setClause),a=Ze(e=>e.clearClause),l=e.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:e.useMemo(()=>i&&0!==i.clauses.size?function(e,t){const n=[];for(const[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(Qe(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(i,o):()=>!0,[i,o]),isActive:l,selectPoints:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};s(r,{clientId:o,type:"point",fields:t})},[o,r,s]),selectInterval:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};s(r,{clientId:o,type:"interval",fields:t})},[o,r,s]),clear:e.useCallback(()=>{a(r,o)},[a,r,o]),clientId:o}}function nt(t){const n=t.name||"hover",{fields:o}=t,{predicate:r,isActive:i,selectPoints:s,clear:a}=tt({name:n});return{onHover:e.useCallback(e=>{if(!e)return void a();const t={};for(const n of o){const o=e[n];void 0!==o&&(t[n]=[o])}Object.keys(t).length>0&&s(t)},[o,s,a,n]),predicate:r,isActive:i}}function ot(t){const{name:n,xField:o,yField:r}=t,{predicate:i,isActive:s,selectInterval:a,clear:l}=tt({name:n}),c=o&&r?"xyBrush":o?"xBrush":"yBrush",u=e.useCallback(e=>{if(!e)return void l();const t={};"xyBrush"===c&&Array.isArray(e)&&2===e.length?(o&&(t[o]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),r&&(t[r]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&Array.isArray(e)?o&&(t[o]=[Math.min(...e),Math.max(...e)]):"yBrush"===c&&Array.isArray(e)&&r&&(t[r]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&a(t)},[c,o,r,a,l]);return{brushInteraction:e.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:i,isActive:s,clear:l}}const rt=e.createContext(!1);function it({selections:t}){const n=Ze(e=>e.setResolution);return e.useEffect(()=>{for(const[e,o]of Object.entries(t))o.resolution&&n(e,o.resolution)},[t,n]),null}function st({categoryColors:t,interaction:n,selectionName:o,field:r}){const i=Object.entries(t);if(0===i.length)return null;const s=i.map(([e])=>e),a=[{styleFn:e=>({fill:e.color||"#333",stroke:e.color||"#333"}),type:"fill",items:i.map(([e,t])=>({label:e,color:t})),label:""}],l=nt({name:o,fields:[r]}),c=tt({name:o,clientId:"__linked-legend-isolate__"}),[u,h]=e.useState(new Set),[g,p]=e.useState(null),y=e.useRef(c.selectPoints);y.current=c.selectPoints;const f=e.useRef(c.clear);f.current=c.clear,e.useEffect(()=>{"isolate"===n&&(u.size>0?y.current({[r]:Array.from(u)}):f.current())},[n,u,r]);const m=e.useCallback(e=>{"highlight"===n&&(e?(p(e.label),l.onHover({[r]:e.label})):(p(null),l.onHover(null)))},[n,r,l]),v=e.useCallback(e=>{"isolate"===n&&h(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===s.length?new Set:n})},[n,s.length]);return d.createElement("svg",{width:"100%",height:30,style:{display:"block",overflow:"visible"}},d.createElement(Q,{legendGroups:a,title:!1,orientation:"horizontal",height:20,customHoverBehavior:"highlight"===n?m:void 0,customClickBehavior:"isolate"===n?v:void 0,highlightedCategory:g,isolatedCategories:u}))}function at({children:e,selections:t,showLegend:n,legendPosition:o="top",legendInteraction:r="none",legendSelectionName:i="legend",legendField:s="category"}){const a=Ve(),l=void 0!==n?n:!(!a||0>=Object.keys(a).length);return d.createElement(Ke,null,d.createElement(Je,null,t&&d.createElement(it,{selections:t}),d.createElement(rt.Provider,{value:l},l&&"top"===o&&a&&d.createElement(st,{categoryColors:a,interaction:r,selectionName:i,field:s}),e,l&&"bottom"===o&&a&&d.createElement(st,{categoryColors:a,interaction:r,selectionName:i,field:s}))))}function lt({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:r,strokeWidth:i}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==r&&(n.stroke=r),void 0!==i&&(n.strokeWidth=i),n},type:"fill",items:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(r=>{const i=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),s=i?o(i,t,n):n?n(r):"#000000";return{label:r+"",color:s}}),label:""}]}}function ct(e){return e?"string"==typeof e?{name:e}:e:null}function ut(e,t,n){return t?o=>{var r;const i=Object.assign({},e(o));if(t.isActive)if(t.predicate(o))(null==n?void 0:n.selectedStyle)&&Object.assign(i,n.selectedStyle);else{const e=null!==(r=null==n?void 0:n.unselectedOpacity)&&void 0!==r?r:.2;i.opacity=e,i.fillOpacity=e,i.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(i,n.unselectedStyle)}return i}:e}const ht="#007bff";function dt(e){return"function"==typeof e?e:t=>t[e]}function gt(t,n,o="category10"){const r=Ve();return e.useMemo(()=>{if(n){if(0===t.length)return r&&Object.keys(r).length>0?e=>r[e]||"#999":void 0;if("function"==typeof n){const e=Array.from(new Set(t.map(e=>n(e)+"")));return r&&Object.keys(r).length>0?e=>r[e]||"#999":_(e.map(e=>({_cat:e})),"_cat",o)}if(r&&Object.keys(r).length>0){const e=_(t,n,o);return t=>r[t]||e(t)}return _(t,n,o)}},[t,n,o,r])}function pt({selection:t,linkedHover:n,fallbackFields:o=[],unwrapData:r=!1,onObservation:i,chartType:s,chartId:a}){const l=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields}:null}(n,o),c=tt({name:(null==t?void 0:t.name)||"__unused__"}),u=nt({name:(null==l?void 0:l.name)||"hover",fields:(null==l?void 0:l.fields)||o||[]}),h=et(e=>e.pushObservation),d=t?{isActive:c.isActive,predicate:c.predicate}:null,g=e.useCallback(e=>{var t,o;if(n)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]),u.onHover(t)}else u.onHover(null);if(i||h){const n={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const s=Object.assign(Object.assign({},n),{type:"hover",datum:r||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(s),h&&h(s)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(e),h&&h(e)}}},[n,u,i,s,a,h]),p=e.useCallback(e=>{var t,n;if(i||h){const o={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const s=Object.assign(Object.assign({},o),{type:"click",datum:r||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});i&&i(s),h&&h(s)}else{const e=Object.assign(Object.assign({},o),{type:"click-end"});i&&i(e),h&&h(e)}}},[i,h,s,a]);return{activeSelectionHook:d,customHoverBehavior:g,customClickBehavior:p}}function yt({data:t,colorBy:n,colorScale:o,showLegend:r,legendPosition:i="right",userMargin:s,defaults:a={top:50,bottom:60,left:70,right:40}}){const l=e.useContext(rt),c=void 0!==r?r:!l&&!!n,u=e.useMemo(()=>{if(c&&n)return lt({data:t,colorBy:n,colorScale:o,getColor:P})},[c,n,t,o]),h=e.useMemo(()=>{const e=Object.assign(Object.assign({},a),s);return u&&("right"===i&&110>e.right?e.right=110:"left"===i&&110>e.left?e.left=110:"top"===i&&50>e.top?e.top=50:"bottom"===i&&80>e.bottom&&(e.bottom=80)),e},[a,s,u,i]);return{legend:u,margin:h,legendPosition:i}}function ft(t,n,o){const[r,i]=e.useState(null),[s,a]=e.useState(new Set),l=e.useCallback(e=>{"highlight"===t&&i(e?e.label:null)},[t]),c=e.useCallback(e=>{"isolate"===t&&a(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===o.length?new Set:n})},[t,o.length]),u=e.useMemo(()=>{if(!t||"none"===t||!n)return null;const e="string"==typeof n?n:null;return"highlight"===t&&null!=r?{isActive:!0,predicate:t=>(e?t[e]:"function"==typeof n?n(t):null)===r}:"isolate"===t&&s.size>0?{isActive:!0,predicate:t=>{const o=e?t[e]:"function"==typeof n?n(t):null;return s.has(o)}}:null},[t,n,r,s]);return{highlightedCategory:"highlight"===t?r:null,isolatedCategories:"isolate"===t?s:new Set,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}const mt={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function vt(e,t,n){var o,r,i,s,a,l;const c=mt[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:c.width,height:null!==(r=t.height)&&void 0!==r?r:c.height,showAxes:c.showAxes,showGrid:null!==(i=t.showGrid)&&void 0!==i?i:c.showGrid,enableHover:null!==(s=t.enableHover)&&void 0!==s?s:!!t.linkedHover||c.enableHover,showLegend:null!==(a=t.showLegend)&&void 0!==a?a:c.showLegend,showLabels:null!==(l=t.showLabels)&&void 0!==l?l:c.showLabels,title:u?void 0:t.title,xLabel:u?void 0:t.xLabel,yLabel:u?void 0:t.yLabel,categoryLabel:u?void 0:t.categoryLabel,valueLabel:u?void 0:t.valueLabel,marginDefaults:c.marginDefaults}}const bt={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"8px 12px",borderRadius:"4px",fontSize:"14px",lineHeight:"1.5",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function xt(e,t){return"function"==typeof t?t(e):e[t]}function kt(e,t){return t?t(e):null==e?"":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function wt(e={}){const{fields:t,title:n,format:o,style:r={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let s;const a=[];if(n){const t=xt(e,n);s=kt(t,o)}if(t&&t.length>0)t.forEach(t=>{let n,r,i;"string"==typeof t?(n=t,r=t,i=o):(n=t.label,r=t.accessor||t.key||"",i=t.format||o);const s=xt(e,r);a.push({label:n,value:kt(s,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){s=kt(e[n],o);break}if(!s){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(s=kt(e[t[0]],o))}}const l=Object.assign(Object.assign({},bt),r);return d.createElement("div",{className:("semiotic-tooltip "+i).trim(),style:l},s&&d.createElement("div",{style:{fontWeight:a.length>0?"bold":"normal"}},s),a.map((e,t)=>d.createElement("div",{key:t,style:{marginTop:0===t&&s?"4px":0}},e.label&&d.createElement("span",null,e.label,": "),e.value)))}}function At(e){if(!0===e)return wt();if("function"==typeof e){const t=e;return e=>{const n=t(!e||"object"!=typeof e.data||null===e.data||"node"!==e.type&&"edge"!==e.type?e:e.data);return null==n?null:d.createElement("div",{className:"semiotic-tooltip",style:bt},n)}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?wt(e):wt())}function St(e){return"string"==typeof e?e:"value"}function Ot(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function Mt(e,t){return"function"==typeof t?t(e):e[t]}function Et(e){const t=e.find(e=>"title"===e.role),n=e.filter(e=>"title"!==e.role);return e=>{const o=e.data;if(!o)return null;const r=t?Ot(Mt(o,t.accessor)):null;return d.createElement("div",{className:"semiotic-tooltip",style:bt},r&&d.createElement("div",{style:{fontWeight:"bold",marginBottom:n.length>0?4:0}},r),n.map((e,t)=>{const n=Ot(Mt(o,e.accessor));return d.createElement("div",{key:t,style:t>0?{marginTop:2}:void 0},d.createElement("span",{style:{opacity:.7}},e.label,": "),d.createElement("span",null,n))}))}}function jt({componentName:e,message:t,diagnosticHint:n,width:o,height:r}){return d.createElement("div",{role:"alert",style:{width:o,height:Math.max(r,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},d.createElement("div",{style:{textAlign:"center",maxWidth:400}},d.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),d.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t),n&&d.createElement("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6}},n)))}class Ct extends d.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:d.createElement(jt,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function Pt(e,t){const n=e.length,o=t.length,r=Array(o+1);for(let e=0;o>=e;e++)r[e]=e;for(let i=1;n>=i;i++){let n=r[0];r[0]=i;for(let s=1;o>=s;s++){const o=r[s];r[s]=e[i-1]===t[s-1]?n:1+Math.min(n,r[s],r[s-1]),n=o}}return r[o]}function _t(e,t,n=3){let o,r=n+1;for(const n of t){const t=Pt(e.toLowerCase(),n.toLowerCase());r>t&&(r=t,o=n)}return r>n?void 0:o}function Lt(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function Bt(e,t){var n;if(0===t.length)return null;const o=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(o)||o.includes(e.toLowerCase()))||(null!==(n=_t(e,t,3))&&void 0!==n?n:null)}function Nt({componentName:e,data:t,accessors:n,requiredProps:o}){if(o)for(const[t,n]of Object.entries(o))if(null==n)return`${e}: ${t} is required. Provide a field name or function.`;if(null==t)return null;if(!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(n){const o=Lt(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[r,i]of Object.entries(n))if(i&&"string"==typeof i&&!(i in o)){const n=Bt(i,t),o=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}const Ht={width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},frameProps:{type:"object"}},zt={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},$t={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"}},Tt=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],Wt=["vertical","horizontal"],It={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),zt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Tt},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},fillArea:{type:"boolean"},areaOpacity:{type:"number"}})},AreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),zt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Tt},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),zt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Tt},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},normalize:{type:"boolean"}})},Scatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),zt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},BubbleChart:{required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),zt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},bubbleOpacity:{type:"number"},bubbleStrokeWidth:{type:"number"},bubbleStrokeColor:{type:"string"}})},Heatmap:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),zt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},colorScheme:{type:"string",enum:["blues","reds","greens","viridis","custom"]},customColorScale:{type:["object","function"]},showValues:{type:"boolean"},valueFormat:{type:"function"},cellBorderColor:{type:"string"},cellBorderWidth:{type:"number"},showLegend:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},QuadrantChart:{required:["quadrants"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),zt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},quadrants:{type:"object"},xCenter:{type:"number"},yCenter:{type:"number"},centerlineStyle:{type:"object"},showQuadrantLabels:{type:"boolean"},quadrantLabelSize:{type:"number"},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},ConnectedScatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),zt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},orderAccessor:{type:["string","function"]},orderLabel:{type:"string"},pointRadius:{type:"number"},pointIdAccessor:{type:["string","function"]},annotations:{type:"array"}})},BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),$t),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Wt},sort:{type:["boolean","string","function"]},barPadding:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),$t),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Wt},normalize:{type:"boolean"},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),$t),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Wt},barPadding:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),$t),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Wt},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"}})},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),$t),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Wt},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),$t),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"}})},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),$t),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Wt},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"}})},DotPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),$t),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Wt},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},Ht),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"},slicePadding:{type:"number"}})},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},Ht),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"},slicePadding:{type:"number"}})},ForceDirectedGraph:{required:["nodes","edges"],dataShape:"network",dataAccessors:["nodeIDAccessor","sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Ht),{nodes:{type:"array"},edges:{type:"array"},nodeIDAccessor:{type:["string","function"]},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},nodeLabel:{type:["string","function"]},nodeSize:{type:["number","string","function"]},nodeSizeRange:{type:"array"},edgeWidth:{type:["number","string","function"]},edgeColor:{type:"string"},edgeOpacity:{type:"number"},iterations:{type:"number"},forceStrength:{type:"number"},showLabels:{type:"boolean"}})},SankeyDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Ht),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target","gradient"]},orientation:{type:"string",enum:Wt},nodeAlign:{type:"string",enum:["justify","left","right","center"]},nodePaddingRatio:{type:"number"},nodeWidth:{type:"number"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"},edgeSort:{type:"function"}})},ChordDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Ht),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target"]},padAngle:{type:"number"},groupWidth:{type:"number"},sortGroups:{type:"function"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"}})},TreeDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Ht),{data:{type:"object"},layout:{type:"string",enum:["tree","cluster","partition","treemap","circlepack"]},orientation:{type:"string",enum:["vertical","horizontal","radial"]},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},edgeStyle:{type:"string",enum:["line","curve"]},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},nodeSize:{type:"number"}})},Treemap:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Ht),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]}})},CirclePack:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Ht),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]},circleOpacity:{type:"number"}})},OrbitDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Ht),{data:{type:"object"},childrenAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},orbitMode:{type:["string","array"]},speed:{type:"number"},revolution:{type:"function"},eccentricity:{type:["number","function"]},orbitSize:{type:["number","function"]},nodeRadius:{type:["number","function"]},showRings:{type:"boolean"},showLabels:{type:"boolean"},animated:{type:"boolean"},colorByDepth:{type:"boolean"},annotations:{type:"array"},foregroundGraphics:{type:"object"}})},RealtimeLineChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},stroke:{type:"string"},strokeWidth:{type:"number"},strokeDasharray:{type:"string"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHistogram:{required:["binSize"],dataShape:"realtime",dataAccessors:[],props:{binSize:{type:"number"},size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeSwarmChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},radius:{type:"number"},fill:{type:"string"},opacity:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeWaterfallChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},positiveColor:{type:"string"},negativeColor:{type:"string"},connectorStroke:{type:"string"},connectorWidth:{type:"number"},gap:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHeatmap:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},heatmapXBins:{type:"number"},heatmapYBins:{type:"number"},aggregation:{type:"string",enum:["count","sum","mean"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"}}}};function Ft(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}const Dt=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),Rt=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),Gt=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),qt=new Set(["LineChart","AreaChart","StackedAreaChart"]),Yt=new Set(["BarChart","StackedBarChart","GroupedBarChart"]);function Xt(e,t){const n=[],o=function(e,t){const n=[],o=It[e];if(!o)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(It).join(", ")}`]};for(const r of o.required)null==t[r]&&n.push(`"${r}" is required for ${e}.`);for(const[e,r]of Object.entries(t)){if(null==r)continue;const t=o.props[e];if(t){if(!Ft(r,t.type)){const o=Array.isArray(t.type)?t.type.join(" | "):t.type;n.push(`"${e}" should be ${o}, got ${Array.isArray(r)?"array":typeof r}.`);continue}t.enum&&"string"==typeof r&&!t.enum.includes(r)&&n.push(`"${e}" value "${r}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const r=Object.keys(o.props),i=new Set(r);for(const o of Object.keys(t))if(void 0!==t[o]&&!i.has(o)){const t=_t(o,r),i=t?`Unknown prop "${o}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${o}" for ${e}. Valid props: ${r.join(", ")}.`;n.push(i)}if("array"===o.dataShape){const r=t.data,i={};for(const e of o.dataAccessors){const n=t[e];"string"==typeof n&&(i[e]=n)}const s=Nt({componentName:e,data:r,accessors:Object.keys(i).length>0?i:void 0});s&&n.push(s)}else if("object"===o.dataShape){const o=function({componentName:e,data:t,dataLabel:n="data"}){return null==t?`${e}: No ${n} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${n} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}({componentName:e,data:t.data});o&&n.push(o)}else if("network"===o.dataShape){const r=function({componentName:e,nodes:t,edges:n,nodesRequired:o=!1,edgesRequired:r=!0,accessors:i}){if(null==t&&null==n)return null;if(r&&(!n||!Array.isArray(n)||0===n.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(o&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){const n=Lt(t).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[o,r]of Object.entries(i))if(r&&"string"==typeof r&&!(r in n)){const n=Bt(r,t),i=n?` Try ${o}="${n}".`:"";return`${e}: ${o} "${r}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}return null}({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:o.required.includes("nodes"),edgesRequired:o.required.includes("edges")});r&&n.push(r)}return{valid:0===n.length,errors:n}}(e,t);for(const e of o.errors)n.push({severity:"error",code:"VALIDATION",message:e,fix:""});return It[e]?(function(e,t,n){const o=It[e];if(o){if("array"===o.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&n.push({severity:"error",code:"EMPTY_DATA",message:"data is an empty array — chart will render blank.",fix:"Provide at least one data point: data={[{ x: 1, y: 2 }]}."})}"network"===o.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&n.push({severity:"error",code:"EMPTY_EDGES",message:"edges is an empty array — network chart will render blank.",fix:'Provide at least one edge: edges={[{ source: "A", target: "B" }]}.'})}}(e,t,n),function(e,t,n){const o=t.width,r=t.height;if(void 0===o||"number"==typeof o&&o>0||n.push({severity:"error",code:"BAD_WIDTH",message:`width=${JSON.stringify(o)} — chart needs a positive number.`,fix:"Set width={600} or use responsiveWidth={true}."}),void 0===r||"number"==typeof r&&r>0||n.push({severity:"error",code:"BAD_HEIGHT",message:`height=${JSON.stringify(r)} — chart needs a positive number.`,fix:"Set height={400} or use responsiveHeight={true}."}),t.size&&Array.isArray(t.size)){const[e,o]=t.size;(null!=e&&0>=e||null!=o&&0>=o)&&n.push({severity:"error",code:"BAD_SIZE",message:`size=[${e}, ${o}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}(0,t,n),function(e,t,n){const o=It[e];if(!o||"array"!==o.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const i=r[0];if(!i||"object"!=typeof i)return;const s=Object.keys(i);for(const e of o.dataAccessors){const o=t[e];"string"==typeof o&&(o in i||n.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${o}" not found in data. Available fields: ${s.join(", ")}.`,fix:`Change ${e} to one of: ${s.map(e=>`"${e}"`).join(", ")}.`}))}}(e,t,n),function(e,t,n){Dt.has(e)&&Array.isArray(t.data)&&n.push({severity:"error",code:"HIERARCHY_FLAT_ARRAY",message:e+" expects hierarchical data but received a flat array.",fix:'Pass a root object: data={{ name: "root", children: [...] }}. For flat data, use BarChart or LineChart.'})}(e,t,n),function(e,t,n){Rt.has(e)&&(t.edges||t.data||n.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}(e,t,n),function(e,t,n){const o=It[e];if(!o||"array"!==o.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const i=r[0];if(!i||"object"!=typeof i)return;const s=t.xAccessor;"string"==typeof s&&i[s]instanceof Date&&!t.xFormat&&n.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${s}" contains Date objects but no xFormat is provided. Axis ticks may display "[object Object]".`,fix:"Add xFormat={d => d.toLocaleDateString()} or use timestamps (d.getTime()) instead of Date objects."})}(e,t,n),function(e,t,n){t.linkedHover&&!t.selection&&n.push({severity:"warning",code:"LINKED_HOVER_NO_SELECTION",message:"linkedHover is set but selection is not — this chart emits hover events but won't highlight from others.",fix:`Add selection={{ name: "${"object"==typeof t.linkedHover&&t.linkedHover.name||"hl"}" }} to receive cross-highlights.`})}(0,t,n),function(e,t,n){var o;if(!Gt.has(e))return;const r=t.rExtent||t.yExtent;r&&Array.isArray(r)&&r.length>=1&&null!=r[0]&&0!==r[0]&&n.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${r[0]}). Bar and area charts should start at zero to avoid exaggerating differences.`,fix:`Remove the custom extent minimum or set it to 0: rExtent={[0, ${null!==(o=r[1])&&void 0!==o?o:"auto"}]}. For trend-focused charts, use LineChart instead.`})}(e,t,n),function(e,t,n){if(!qt.has(e))return;if(t.gapStrategy)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const r=t.yAccessor||"y";"string"==typeof r&&o.some(e=>{const t=e[r];return null==t||Number.isNaN(t)})&&n.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${r}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}(e,t,n),function(e,t,n){var o,r;const i=null!==(o=t.width)&&void 0!==o?o:600,s=null!==(r=t.height)&&void 0!==r?r:400,a=t.margin;if(!a||"object"!=typeof a)return;const l=(a.left||0)+(a.right||0),c=(a.top||0)+(a.bottom||0);i>l||n.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${l}px) >= width (${i}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),s>c||n.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${c}px) >= height (${s}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}(0,t,n),function(e,t,n){var o;const r=It[e];if(!r||"array"!==r.dataShape)return;const i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;const s=[];t.xAccessor&&"string"==typeof t.xAccessor&&s.push({prop:"xAccessor",name:t.xAccessor}),t.yAccessor&&"string"==typeof t.yAccessor&&s.push({prop:"yAccessor",name:t.yAccessor}),t.valueAccessor&&"string"==typeof t.valueAccessor&&s.push({prop:"valueAccessor",name:t.valueAccessor});const a=Math.min(i.length,5);for(const e of s){let t=!0;for(let n=0;a>n;n++){const r=null===(o=i[n])||void 0===o?void 0:o[e.name];if("number"==typeof r&&Number.isFinite(r)){t=!1;break}}t&&n.push({severity:"error",code:"DEGENERATE_EXTENT",message:`${e.prop}="${e.name}" produces NaN or non-finite values for all sampled data points — chart extents will be invalid.`,fix:`Ensure data[].${e.name} contains finite numbers, or use a function accessor to transform values.`})}}(e,t,n),function(e,t,n){if(!Yt.has(e))return;const o=t.barPadding;"number"==typeof o&&10>o&&n.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${o} is very small — bars may appear to have no spacing between them.`,fix:"Increase barPadding to at least 10 for visible gaps, e.g. barPadding={12}."})}(e,t,n),function(e,t,n){if("bottom"!==t.legendPosition)return;const o=t.margin;if(!o||"object"!=typeof o)return;const r=o.bottom;"number"==typeof r&&70>r&&n.push({severity:"warning",code:"BOTTOM_MARGIN_WITH_LEGEND",message:`legendPosition="bottom" with margin.bottom=${r}px — legend may overlap axis labels.`,fix:"Increase margin.bottom to at least 70, e.g. margin={{ ...margin, bottom: 80 }}."})}(0,t,n),function(e,t,n){var o;if(!t.showLegend)return;if("right"!==(null!==(o=t.legendPosition)&&void 0!==o?o:"right"))return;const r=t.margin;if(!r||"object"!=typeof r)return;const i=r.right;"number"==typeof i&&100>i&&n.push({severity:"warning",code:"LEGEND_MARGIN_TIGHT",message:`showLegend is true with legendPosition="right" but margin.right=${i}px — legend may be clipped or overlap the chart.`,fix:"Increase margin.right to at least 100, e.g. margin={{ ...margin, right: 120 }}."})}(0,t,n),function(e,t,n){if("Heatmap"!==e)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const r=o[0];if(r&&"object"==typeof r)for(const e of["xAccessor","yAccessor"]){const o=t[e];if("string"!=typeof o)continue;const i=r[o];"string"==typeof i&&n.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${o}" resolves to string values (e.g. "${i}"). Heatmap will use categorical axis handling which may produce unexpected cell layout.`,fix:"If you intend categorical axes this is fine. Otherwise, convert values to numbers before passing data."})}}(e,t,n),{ok:n.every(e=>"warning"===e.severity),diagnoses:n}):{ok:0===n.length,diagnoses:n}}var Vt;const Qt="undefined"!=typeof process&&"production"!==(null===(Vt=process.env)||void 0===Vt?void 0:Vt.NODE_ENV);function Ut({componentName:e,width:t,height:n,chartProps:o,children:r}){return d.createElement(Ct,{fallback:r=>{let i="";if(Qt&&o)try{const t=Xt(e,o);t.ok||(i=t.diagnoses.map(e=>`${"error"===e.severity?"✗":"⚠"} ${e.message}${e.fix?" — Fix: "+e.fix:""}`).join("\n"))}catch(e){}return d.createElement(jt,{componentName:e,message:r.message,diagnosticHint:i,width:t,height:n})}},r)}const Kt={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Zt={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Jt(e,t,n,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?d.createElement("div",{style:Object.assign(Object.assign({},Kt),{width:t,height:n})},o||"No data available"):null}function en(e,t,n){if(!e)return null;const o=Math.min(5,Math.floor(n/40)),r=Math.max(8,Math.floor(n/(3*o))),i=Math.max(6,Math.floor(n/(2.5*o))),s=Math.floor((n-(o*(r+i)-i))/2);return d.createElement("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:o},(e,n)=>d.createElement("div",{key:n,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Zt),{position:"absolute",top:s+n*(r+i),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:r,opacity:.5+n%2*.2})})))}function tn(e,t,n,o){if(!Qt)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const r=t[0];if(!r||"object"!=typeof r)return;if(o in r)return;const i=Object.keys(r).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${i}`)}function nn(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;let on=null;function rn(){return nn(this,void 0,void 0,function*(){return on||(on=yield Promise.resolve().then(function(){return En})),on})}const sn=e.forwardRef(function(t,n){var o,r;const i=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const s=vt(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:a,margin:l,className:c,xFormat:u,yFormat:h,xAccessor:g="x",yAccessor:p="y",lineBy:y,lineDataAccessor:f="coordinates",colorBy:m,colorScheme:v="category10",curve:b="linear",showPoints:x=!1,pointRadius:k=3,fillArea:w=!1,areaOpacity:A=.3,lineWidth:S=2,tooltip:O,pointIdAccessor:M,annotations:E,directLabel:j,gapStrategy:C="break",anomaly:_,forecast:L,frameProps:B={},selection:N,linkedHover:H,onObservation:z,chartId:$,loading:T,emptyContent:W,legendInteraction:I,legendPosition:F,xScaleType:D,yScaleType:R}=t,G=s.width,q=s.height,Y=s.enableHover,X=s.showGrid,V=s.showLegend,Q=s.title,U=s.xLabel,K=s.yLabel,Z=en(T,G,q);if(Z)return Z;const J=Jt(a,G,q,W);if(J)return J;const ee=a||[];tn("LineChart",ee,"xAccessor",g),tn("LineChart",ee,"yAccessor",p);const te="string"==typeof g?g:"x",ne="string"==typeof p?p:"y",[oe,re]=e.useState(null),[ie,se]=e.useState([]);e.useEffect(()=>{if(!L&&!_)return;let e=!1;return re(null),se([]),L?function(...e){return nn(this,void 0,void 0,function*(){return(yield rn()).buildForecast(...e)})}(ee,te,ne,L,_).then(t=>{e||(re(t),se(t.annotations))}).catch(()=>{e||(re(null),se([]))}):_&&function(...e){return nn(this,void 0,void 0,function*(){return(yield rn()).buildAnomalyAnnotations(...e)})}(_).then(t=>{e||(re(null),se(t))}).catch(()=>{e||se([])}),()=>{e=!0}},[ee,L,_,te,ne]);const ae=oe?oe.processedData:ee,le=L&&!y?"__forecastSegment":y,{activeSelectionHook:ce,customHoverBehavior:ue}=pt({selection:N,linkedHover:H,fallbackFields:m?["string"==typeof m?m:""]:[],onObservation:z,chartType:"LineChart",chartId:$}),he=e.useCallback(e=>{const t="function"==typeof g?g(e):e[g],n="function"==typeof p?p(e):e[p];return null==t||null==n||Number.isNaN(t)||Number.isNaN(n)},[g,p]),de=void 0!==(null===(o=ae[0])||void 0===o?void 0:o[f]),ge=e.useMemo(()=>{if(de)return ae;if(le){const e=ae.reduce((e,t)=>{const n="function"==typeof le?le(t):t[le];if(!e[n]){const t={[f]:[]};"string"==typeof le&&(t[le]=n),e[n]=t}return e[n][f].push(t),e},{});return Object.values(e)}return[{[f]:ae}]},[ae,le,f,de]),{gapProcessedLineData:pe,hasGaps:ye}=e.useMemo(()=>{if("interpolate"===C){let e=!1;const t=[];for(const n of ge){const o=(n[f]||[]).filter(t=>!he(t)||(e=!0,!1));o.length>0&&t.push(Object.assign(Object.assign({},n),{[f]:o}))}return{gapProcessedLineData:t,hasGaps:e}}if("break"===C){let e=!1;const t=[];for(const n of ge){const o=n[f]||[];let r=[],i=0;const s=le&&"string"==typeof le?n[le]:void 0;for(const a of o)if(he(a))e=!0,r.length>0&&(t.push(Object.assign(Object.assign({},n),{[f]:r})),r=[],i++);else{const e=null!=s?`${s}__seg${i}`:"__seg"+i;r.push(Object.assign(Object.assign({},a),{_gapSegment:e}))}r.length>0&&t.push(Object.assign(Object.assign({},n),{[f]:r}))}return{gapProcessedLineData:t,hasGaps:e}}if("zero"===C){let e=!1;const t="string"==typeof p?p:"y",n=[];for(const o of ge){const r=o[f]||[],i=[];for(const n of r)he(n)?(e=!0,i.push(Object.assign(Object.assign({},n),{[t]:0}))):i.push(n);n.push(Object.assign(Object.assign({},o),{[f]:i}))}return{gapProcessedLineData:n,hasGaps:e}}return{gapProcessedLineData:ge,hasGaps:!1}},[ge,C,f,he,le,p]),fe=gt(ae,m,v),me=e.useMemo(()=>{if(!m)return[];const e=new Set;for(const t of ae){const n="function"==typeof m?m(t):t[m];null!=n&&e.add(n+"")}return Array.from(e)},[ae,m]),ve=ft(I,m,me),be=e.useMemo(()=>ve.legendSelectionHook?ve.legendSelectionHook:ce,[ve.legendSelectionHook,ce]),xe=e.useMemo(()=>e=>{const t={strokeWidth:S};return m?fe&&(t.stroke=P(e,m,fe),w&&(t.fill=t.stroke,t.fillOpacity=A)):(t.stroke=ht,w&&(t.fill=ht,t.fillOpacity=A)),t},[m,fe,S,w,A]),[ke,we]=e.useState(null);e.useEffect(()=>{if(!L)return void we(null);let e=!1;return function(...e){return nn(this,void 0,void 0,function*(){return(yield rn()).createSegmentLineStyle(...e)})}(xe,L).then(t=>{e||we(()=>t)}).catch(()=>{e||we(null)}),()=>{e=!0}},[xe,L]);const Ae=ke||xe,Se=e.useMemo(()=>ut(Ae,be,N),[Ae,be,N]),Oe=e.useMemo(()=>{if(x)return e=>{const t={r:k,fillOpacity:1};return m?fe&&(t.fill=P(e.parentLine||e,m,fe)):t.fill=ht,t}},[x,k,m,fe]),Me=w?"area":"line",Ee="object"==typeof j?j:{},je=Ee.position||"end",Ce=Ee.fontSize||11,Pe=e.useMemo(()=>{var e,t;if(!j||!m)return[];const n="function"==typeof g?g:e=>e[g],o="function"==typeof p?p:e=>e[p],r="function"==typeof m?m:e=>e[m],i=new Map;for(const n of pe){const o=n[f]||[];if(0===o.length)continue;const s="end"===je?o[o.length-1]:o[0],a=null!==(t=null!==(e=r(s))&&void 0!==e?e:r(n))&&void 0!==t?t:"";a&&!i.has(a+"")&&i.set(a+"",s)}const s=Array.from(i.entries()).map(([e,t])=>({type:"text",label:e,["string"==typeof g?g:"x"]:n(t),["string"==typeof p?p:"y"]:o(t),dx:"end"===je?6:-6,dy:0,color:fe?fe(e):ht,fontSize:Ce}));s.sort((e,t)=>{const n="string"==typeof p?p:"y";return e[n]-t[n]});for(let e=1;s.length>e;e++){const t="string"==typeof p?p:"y",n=s[e-1],o=s[e];Ce+2>Math.abs(o[t]+o.dy-(n[t]+n.dy))&&(o.dy+=Ce+2)}return s},[j,m,fe,pe,f,g,p,je,Ce]),_e=(!j||void 0!==V)&&V,Le=e.useMemo(()=>{if(!j)return s.marginDefaults;const e=Pe.reduce((e,t)=>{var n;const o=((null===(n=t.label)||void 0===n?void 0:n.length)||0)*(.6*Ce);return Math.max(e,o)},0),t=e+10,n="end"===je?"right":"left";return Object.assign(Object.assign({},s.marginDefaults),{[n]:Math.max(s.marginDefaults[n]||0,t)})},[j,Pe,Ce,je,s.marginDefaults]),{legend:Be,margin:Ne,legendPosition:He}=yt({data:pe,colorBy:m,colorScale:fe,showLegend:_e,legendPosition:F,userMargin:l,defaults:Le}),ze=y||m,$e=e.useMemo(()=>Et([{label:U||St(g),accessor:g,role:"x"},{label:K||St(p),accessor:p,role:"y"},...ze?[{label:St(ze),accessor:ze,role:"group"}]:[]]),[g,p,U,K,ze]),Te=Nt({componentName:"LineChart",data:de?(null===(r=ae[0])||void 0===r?void 0:r[f])||[]:a,accessors:{xAccessor:g,yAccessor:p}});if(Te)return d.createElement(jt,{componentName:"LineChart",message:Te,width:G,height:q});const We=e.useMemo(()=>de||le||ye?pe.flatMap(e=>{const t=e[f]||[];return le&&"string"==typeof le?t.map(t=>Object.assign(Object.assign({},t),{[le]:e[le]})):t}):ae,[pe,f,de,le,ae,ye]),Ie=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:Me},null!=a&&{data:We}),{xAccessor:g,yAccessor:p,xScaleType:D,yScaleType:R,groupAccessor:"break"===C&&ye?"_gapSegment":le||void 0,curve:b,lineStyle:Se}),x&&{pointStyle:Oe}),{size:[G,q],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Ne,showAxes:s.showAxes,xLabel:U,yLabel:K,xFormat:u,yFormat:h,enableHover:Y,showGrid:X}),Be&&{legend:Be,legendPosition:He}),I&&"none"!==I&&{legendHoverBehavior:ve.onLegendHover,legendClickBehavior:ve.onLegendClick,legendHighlightedCategory:ve.highlightedCategory,legendIsolatedCategories:ve.isolatedCategories}),Q&&{title:Q}),c&&{className:c}),{tooltipContent:!1===O?()=>null:At(O)||$e}),(H||z)&&{customHoverBehavior:ue}),M&&{pointIdAccessor:M}),((null==E?void 0:E.length)||ie.length||Pe.length)&&{annotations:[...E||[],...ie,...Pe]}),B);return d.createElement(Ut,{componentName:"LineChart",width:G,height:q},d.createElement(Ye,Object.assign({ref:i},Ie)))});sn.displayName="LineChart";const an=e.forwardRef(function(t,n){var o;const r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const i=vt(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:h="x",yAccessor:g="y",areaBy:p,y0Accessor:y,gradientFill:f=!1,lineDataAccessor:m="coordinates",colorBy:v,colorScheme:b="category10",curve:x="monotoneX",areaOpacity:k=.7,showLine:w=!0,lineWidth:A=2,tooltip:S,annotations:O,frameProps:M={},selection:E,linkedHover:j,onObservation:C,chartId:_,loading:L,emptyContent:B,legendInteraction:N,legendPosition:H}=t,z=i.width,$=i.height,T=i.enableHover,W=i.showGrid,I=i.showLegend,F=i.title,D=i.xLabel,R=i.yLabel,G=en(L,z,$);if(G)return G;const q=Jt(s,z,$,B);if(q)return q;const Y=s||[];tn("AreaChart",Y,"xAccessor",h),tn("AreaChart",Y,"yAccessor",g);const{activeSelectionHook:X,customHoverBehavior:V}=pt({selection:E,linkedHover:j,fallbackFields:v?["string"==typeof v?v:""]:[],onObservation:C,chartType:"AreaChart",chartId:_}),Q=void 0!==(null===(o=Y[0])||void 0===o?void 0:o[m]),U=e.useMemo(()=>{if(Q)return Y;if(p){const e=Y.reduce((e,t)=>{const n="function"==typeof p?p(t):t[p];if(!e[n]){const t={[m]:[]};"string"==typeof p&&(t[p]=n),e[n]=t}return e[n][m].push(t),e},{});return Object.values(e)}return[{[m]:Y}]},[Y,p,m,Q]),K=gt(Y,v,b),Z=e.useMemo(()=>{if(!v)return[];const e=new Set;for(const t of Y){const n="function"==typeof v?v(t):t[v];null!=n&&e.add(n+"")}return Array.from(e)},[Y,v]),J=ft(N,v,Z),ee=e.useMemo(()=>J.legendSelectionHook?J.legendSelectionHook:X,[J.legendSelectionHook,X]),te=e.useMemo(()=>e=>{const t={};if(v){if(K){const n=P(e,v,K);t.fill=n,w?(t.stroke=n,t.strokeWidth=A):t.stroke="none"}}else t.fill=ht,w?(t.stroke=ht,t.strokeWidth=A):t.stroke="none";return t.fillOpacity=k,t},[v,K,k,w,A]),ne=e.useMemo(()=>ut(te,ee,E),[te,ee,E]),{legend:oe,margin:re,legendPosition:ie}=yt({data:U,colorBy:v,colorScale:K,showLegend:I,legendPosition:H,userMargin:a,defaults:i.marginDefaults}),se=p||v,ae=e.useMemo(()=>Et([{label:D||St(h),accessor:h,role:"x"},{label:R||St(g),accessor:g,role:"y"},...se?[{label:St(se),accessor:se,role:"group"}]:[]]),[h,g,D,R,se]),le=Nt({componentName:"AreaChart",data:s,accessors:{xAccessor:h,yAccessor:g}});if(le)return d.createElement(jt,{componentName:"AreaChart",message:le,width:z,height:$});const ce=e.useMemo(()=>Q||p?U.flatMap(e=>{const t=e[m]||[];return p&&"string"==typeof p?t.map(t=>Object.assign(Object.assign({},t),{[p]:e[p]})):t}):Y,[U,m,Q,p,Y]),ue=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area"},null!=s&&{data:ce}),{xAccessor:h,yAccessor:g,groupAccessor:p||void 0}),y&&{y0Accessor:y}),f&&{gradientFill:f}),{curve:x,lineStyle:ne,size:[z,$],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:re,showAxes:i.showAxes,xLabel:D,yLabel:R,xFormat:c,yFormat:u,enableHover:T,showGrid:W}),oe&&{legend:oe,legendPosition:ie}),N&&"none"!==N&&{legendHoverBehavior:J.onLegendHover,legendClickBehavior:J.onLegendClick,legendHighlightedCategory:J.highlightedCategory,legendIsolatedCategories:J.isolatedCategories}),F&&{title:F}),l&&{className:l}),{tooltipContent:!1===S?()=>null:At(S)||ae}),(j||C)&&{customHoverBehavior:V}),O&&O.length>0&&{annotations:O}),M);return d.createElement(Ut,{componentName:"AreaChart",width:z,height:$},d.createElement(Ye,Object.assign({ref:r},ue)))});an.displayName="AreaChart";const ln=e.forwardRef(function(t,n){var o;const r=e.useRef(null),i=vt(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:h="x",yAccessor:g="y",areaBy:p,lineDataAccessor:y="coordinates",colorBy:f,colorScheme:m="category10",curve:v="monotoneX",areaOpacity:b=.7,showLine:x=!0,lineWidth:k=2,normalize:w=!1,tooltip:A,annotations:S,frameProps:O={},selection:M,linkedHover:E,onObservation:C,chartId:_,loading:L,emptyContent:B,legendInteraction:N,legendPosition:H}=t,z=i.width,$=i.height,T=i.enableHover,W=i.showGrid,I=i.showLegend,F=i.title,D=i.xLabel,R=i.yLabel,G=en(L,z,$);if(G)return G;const q=Jt(s,z,$,B);if(q)return q;const Y=s||[],X=function({isPushMode:t,colorBy:n,colorScheme:o,showLegend:r,legendPosition:i="right"}){const s=e.useRef(new Set),a=e.useRef([]),[l,c]=e.useState(0),u=e.useCallback(e=>{if(!n)return null;const t="function"==typeof n?n(e):e[n];return null!=t?t+"":null},[n]),h=e.useCallback(e=>{if(!t||!n)return;let o=!1;for(const t of e){if(!t||"object"!=typeof t)continue;const e=u(t);null==e||s.current.has(e)||(s.current.add(e),a.current.push(e),o=!0)}o&&c(e=>e+1)},[t,n,u]),d=e.useCallback(e=>t=>{h([t]),e(t)},[h]),g=e.useCallback(e=>t=>{h(t),e(t)},[h]),p=e.useCallback(()=>{s.current=new Set,a.current=[],c(e=>e+1)},[]),y=e.useMemo(()=>{if(!t||!n||!1===r)return;const e=a.current;if(0===e.length)return;const i=Array.isArray(o)?o:j,s=new Map;for(let t=0;e.length>t;t++)s.set(e[t],i[t%i.length]);const l="string"==typeof n?n:"__streamCat";return lt({data:e.map(e=>({[l]:e})),colorBy:l,colorScale:e=>s.get(e)||"#999",getColor:P})},[t,n,r,o,l]),f=e.useMemo(()=>{if(y)return"right"===i?{right:110}:"left"===i?{left:110}:"top"===i?{top:50}:"bottom"===i?{bottom:80}:{right:110}},[y,i]);return{wrapPush:d,wrapPushMany:g,resetCategories:p,streamingLegend:y,streamingMarginAdjust:f}}({isPushMode:void 0===s,colorBy:f||p,colorScheme:m,showLegend:I,legendPosition:H}),V=e.useCallback(X.wrapPush(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)}),[X.wrapPush]),Q=e.useCallback(X.wrapPushMany(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)}),[X.wrapPushMany]);e.useImperativeHandle(n,()=>({push:V,pushMany:Q,clear:()=>{var e;X.resetCategories(),null===(e=r.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}),[V,Q,X.resetCategories]);const{activeSelectionHook:U,customHoverBehavior:K}=pt({selection:M,linkedHover:E,fallbackFields:f?["string"==typeof f?f:""]:[],onObservation:C,chartType:"StackedAreaChart",chartId:_}),Z=void 0!==(null===(o=Y[0])||void 0===o?void 0:o[y]),J=e.useMemo(()=>{if(Z)return Y;if(p){const e=Y.reduce((e,t)=>{const n="function"==typeof p?p(t):t[p];if(!e[n]){const t={[y]:[]};"string"==typeof p&&(t[p]=n),e[n]=t}return e[n][y].push(t),e},{});return Object.values(e)}return[{[y]:Y}]},[Y,p,y,Z]),ee=gt(Y,f,m),te=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of Y){const n="function"==typeof f?f(t):t[f];null!=n&&e.add(n+"")}return Array.from(e)},[Y,f]),ne=ft(N,f,te),oe=e.useMemo(()=>ne.legendSelectionHook?ne.legendSelectionHook:U,[ne.legendSelectionHook,U]),re=e.useMemo(()=>e=>{const t={};if(f&&ee){const n=P(e,f,ee);t.fill=n,x?(t.stroke=n,t.strokeWidth=k):t.stroke="none"}else f||(t.fill=ht,t.stroke=x?ht:"none",x&&(t.strokeWidth=k));return t.fillOpacity=b,t},[f,ee,b,x,k]),ie=e.useMemo(()=>ut(re,oe,M),[re,oe,M]),{legend:se,margin:ae,legendPosition:le}=yt({data:J,colorBy:f,colorScale:ee,showLegend:I,legendPosition:H,userMargin:a,defaults:i.marginDefaults}),ce=X.streamingLegend||se,ue=H||le,he=e.useMemo(()=>{if(X.streamingMarginAdjust){const e=Object.assign({},ae);for(const[t,n]of Object.entries(X.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return ae},[ae,X.streamingMarginAdjust]),de=p||f,ge=e.useMemo(()=>Et([{label:D||St(h),accessor:h,role:"x"},{label:R||St(g),accessor:g,role:"y"},...de?[{label:St(de),accessor:de,role:"group"}]:[]]),[h,g,D,R,de]),pe=Nt({componentName:"StackedAreaChart",data:s,accessors:{xAccessor:h,yAccessor:g}});if(pe)return d.createElement(jt,{componentName:"StackedAreaChart",message:pe,width:z,height:$});const ye=e.useMemo(()=>Z||p?J.flatMap(e=>{const t=e[y]||[];return p&&"string"==typeof p?t.map(t=>Object.assign(Object.assign({},t),{[p]:e[p]})):t}):Y,[J,y,Z,p,Y]),fe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea"},null!=s&&{data:ye}),{xAccessor:h,yAccessor:g,groupAccessor:p||void 0,curve:v,normalize:w,lineStyle:ie,size:[z,$],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:he,showAxes:i.showAxes,xLabel:D,yLabel:R,xFormat:c,yFormat:u,enableHover:T,showGrid:W}),ce&&{legend:ce,legendPosition:ue}),N&&"none"!==N&&{legendHoverBehavior:ne.onLegendHover,legendClickBehavior:ne.onLegendClick,legendHighlightedCategory:ne.highlightedCategory,legendIsolatedCategories:ne.isolatedCategories}),F&&{title:F}),l&&{className:l}),{tooltipContent:!1===A?()=>null:At(A)||ge}),(E||C)&&{customHoverBehavior:K}),S&&S.length>0&&{annotations:S}),O);return d.createElement(Ut,{componentName:"StackedAreaChart",width:z,height:$},d.createElement(Ye,Object.assign({ref:r},fe)))});ln.displayName="StackedAreaChart";const cn=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const r=vt(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:s,className:a,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:h="y",colorBy:g,colorScheme:p="category10",sizeBy:y,sizeRange:f=[3,15],pointRadius:m=5,pointOpacity:v=.8,tooltip:b,marginalGraphics:x,pointIdAccessor:k,annotations:w,frameProps:A={},selection:S,linkedHover:O,linkedBrush:M,onObservation:E,chartId:j,loading:C,emptyContent:_,legendInteraction:B,legendPosition:N}=t,H=r.width,z=r.height,$=r.enableHover,T=r.showGrid,W=r.title,I=r.xLabel,F=r.yLabel,D=i||[],R=function(t){const{data:n,rawData:o,colorBy:r,colorScheme:i,legendInteraction:s,legendPosition:a,selection:l,linkedHover:c,fallbackFields:u,unwrapData:h=!1,onObservation:d,chartType:g,chartId:p,showLegend:y,userMargin:f,marginDefaults:m,loading:v,emptyContent:b,width:x,height:k}=t,{activeSelectionHook:w,customHoverBehavior:A,customClickBehavior:S}=pt({selection:l,linkedHover:c,fallbackFields:u,unwrapData:h,onObservation:d,chartType:g,chartId:p}),O=gt(n,r,i),M=e.useMemo(()=>{if(!r)return[];const e=new Set;for(const t of n){const n="function"==typeof r?r(t):t[r];null!=n&&e.add(n+"")}return Array.from(e)},[n,r]),E=ft(s,r,M),j=e.useMemo(()=>E.legendSelectionHook?E.legendSelectionHook:w,[E.legendSelectionHook,w]),{legend:C,margin:P,legendPosition:_}=yt({data:n,colorBy:r,colorScale:O,showLegend:y,legendPosition:a,userMargin:f,defaults:m}),L=e.useMemo(()=>{const e={};return C&&(e.legend=C,e.legendPosition=_),s&&"none"!==s&&(e.legendHoverBehavior=E.onLegendHover,e.legendClickBehavior=E.onLegendClick,e.legendHighlightedCategory=E.highlightedCategory,e.legendIsolatedCategories=E.isolatedCategories),e},[C,_,s,E.onLegendHover,E.onLegendClick,E.highlightedCategory,E.isolatedCategories]),B=en(v,x,k),N=B?null:Jt(o,x,k,b);return{colorScale:O,allCategories:M,legendState:E,effectiveSelectionHook:j,activeSelectionHook:w,customHoverBehavior:A,customClickBehavior:S,legend:C,margin:P,legendPosition:_,earlyReturn:B||N||null,legendBehaviorProps:L}}({data:D,rawData:i,colorBy:g,colorScheme:p,legendInteraction:B,legendPosition:N,selection:S,linkedHover:O,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!1,onObservation:E,chartType:"Scatterplot",chartId:j,showLegend:r.showLegend,userMargin:s,marginDefaults:r.marginDefaults,loading:C,emptyContent:_,width:H,height:z}),G=ct(M),q=ot({name:(null==G?void 0:G.name)||"__unused_brush__",xField:(null==G?void 0:G.xField)||("string"==typeof u?u:void 0),yField:(null==G?void 0:G.yField)||("string"==typeof h?h:void 0)}),Y=G?"xyBrush"===q.brushInteraction.brush?"xy":"xBrush"===q.brushInteraction.brush?"x":"y":void 0,X=d.useRef(q.brushInteraction);X.current=q.brushInteraction;const V=e.useCallback(e=>{const t=X.current;t.end(e?"xyBrush"===t.brush?[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:"xBrush"===t.brush?e.x:e.y:null)},[]);if(R.earlyReturn)return R.earlyReturn;tn("Scatterplot",D,"xAccessor",u),tn("Scatterplot",D,"yAccessor",h);const Q=e.useMemo(()=>{if(!y||0===D.length)return;const e=D.map(e=>"function"==typeof y?y(e):e[y]);return[Math.min(...e),Math.max(...e)]},[D,y]),U=e.useMemo(()=>e=>{const t={fillOpacity:v};return g?R.colorScale&&(t.fill=P(e,g,R.colorScale)):t.fill=ht,t.r=y?L(e,y,f,Q):m,t},[g,R.colorScale,y,f,Q,m,v]),K=e.useMemo(()=>ut(U,R.effectiveSelectionHook,S),[U,R.effectiveSelectionHook,S]),Z=e.useMemo(()=>Et([{label:I||St(u),accessor:u,role:"x"},{label:F||St(h),accessor:h,role:"y"},...g?[{label:St(g),accessor:g,role:"color"}]:[],...y?[{label:St(y),accessor:y,role:"size"}]:[]]),[u,h,I,F,g,y]),J=Nt({componentName:"Scatterplot",data:i,accessors:{xAccessor:u,yAccessor:h}});if(J)return d.createElement(jt,{componentName:"Scatterplot",message:J,width:H,height:z});const ee=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=i&&{data:D}),{xAccessor:u,yAccessor:h,colorAccessor:g||void 0,sizeAccessor:y||void 0,sizeRange:f,pointStyle:K,colorScheme:p,size:[H,z],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R.margin,showAxes:r.showAxes,xLabel:I,yLabel:F,xFormat:l,yFormat:c,enableHover:$,showGrid:T}),R.legendBehaviorProps),W&&{title:W}),a&&{className:a}),{tooltipContent:!1===b?()=>null:At(b)||Z}),(O||E)&&{customHoverBehavior:R.customHoverBehavior}),x&&{marginalGraphics:x}),k&&{pointIdAccessor:k}),w&&w.length>0&&{annotations:w}),G&&{brush:{dimension:Y},onBrush:V}),A);return d.createElement(Ut,{componentName:"Scatterplot",width:H,height:z},d.createElement(Ye,Object.assign({ref:o},ee)))});function un(e,t){return r.interpolateViridis(1===t?.5:e/(t-1))}cn.displayName="Scatterplot";const hn=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const r=vt(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,className:s,xFormat:a,yFormat:l,xAccessor:c="x",yAccessor:u="y",orderAccessor:h,orderLabel:g,pointRadius:p=4,tooltip:y,pointIdAccessor:f,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:k,chartId:w,loading:A,emptyContent:S,legendInteraction:O}=t,M=r.width,E=r.height,j=r.enableHover,C=r.showGrid,P=r.title,_=r.xLabel,L=r.yLabel,B=i||[],N=e.useMemo(()=>{if(!h||0===B.length)return B;const e="function"==typeof h?h:e=>e[h];return[...B].sort((t,n)=>{const o=e(t),r=e(n);return(o instanceof Date?o.getTime():+o)-(r instanceof Date?r.getTime():+r)})},[B,h]);tn("ConnectedScatterplot",N,"xAccessor",c),tn("ConnectedScatterplot",N,"yAccessor",u);const{activeSelectionHook:H,customHoverBehavior:z}=pt({selection:b,linkedHover:x,fallbackFields:[],onObservation:k,chartType:"ConnectedScatterplot",chartId:w}),$=ft(O,void 0,[]),T=e.useMemo(()=>$.legendSelectionHook?$.legendSelectionHook:H,[$.legendSelectionHook,H]),W=e.useMemo(()=>(e,t)=>{var n,o;const r=t.filter(e=>"point"===e.type);if(2>r.length)return;const i=null==T?void 0:T.isActive,s=null==T?void 0:T.predicate,a=100>r.length,l=r.length;e.lineCap="round";for(let t=0;l-1>t;t++){const c=r[t],u=r[t+1],h=un(t,l),d=!i||!s||s(null!==(n=c.datum)&&void 0!==n?n:c)||s(null!==(o=u.datum)&&void 0!==o?o:u),g=i?d?1:.2:1;a&&(e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle="white",e.lineWidth=p+2,e.globalAlpha=.5*g,e.stroke()),e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle=h,e.lineWidth=p,e.globalAlpha=g,e.stroke()}e.globalAlpha=1},[p,T]),I=e.useMemo(()=>[W],[W]),F=e.useRef({idx:0,total:0}),D=e.useMemo(()=>{const e="function"==typeof c?c:e=>e[c],t="function"==typeof u?u:e=>e[u];return n=>{var r,i;const s=F.current;if(0===s.idx){const n=null!==(i=null===(r=o.current)||void 0===r?void 0:r.getData())&&void 0!==i?i:N;s.total=n.filter(n=>{const o=e(n),r=t(n);return null!=o&&null!=r&&isFinite(o)&&isFinite(r)}).length}const a=s.total,l=s.idx;return s.idx++,a>s.idx||(s.idx=0),{fill:a>0?un(l,a):"#6366f1",stroke:"white",strokeWidth:1,r:p,fillOpacity:1}}},[p,N.length,c,u]),R=e.useMemo(()=>ut(D,T,b),[D,T,b]),G=Object.assign({top:50,right:40,bottom:60,left:70},t.margin),q=g||("string"==typeof h?h:"Order"),Y=e.useMemo(()=>Et([{label:_||St(c),accessor:c,role:"x"},{label:L||St(u),accessor:u,role:"y"},...h?[{label:q,accessor:h,role:"group"}]:[]]),[c,u,_,L,h,q]),X=Nt({componentName:"ConnectedScatterplot",data:i,accessors:{xAccessor:c,yAccessor:u}}),V=en(A,M,E);if(V)return V;const Q=Jt(i,M,E,S);if(Q)return Q;if(X)return d.createElement(jt,{componentName:"ConnectedScatterplot",message:X,width:M,height:E});const U=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=i&&{data:N}),{xAccessor:c,yAccessor:u,pointStyle:R,size:[M,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:G,showAxes:r.showAxes,xLabel:_,yLabel:L,xFormat:a,yFormat:l,enableHover:j,showGrid:C}),P&&{title:P}),s&&{className:s}),{tooltipContent:!1===y?()=>null:At(y)||Y}),(x||k)&&{customHoverBehavior:z}),f&&{pointIdAccessor:f}),{canvasPreRenderers:I}),m&&m.length>0&&{annotations:m}),v);return d.createElement(Ut,{componentName:"ConnectedScatterplot",width:M,height:E},d.createElement(Ye,Object.assign({ref:o},U)))});hn.displayName="ConnectedScatterplot";const dn=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const r=vt(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:s,className:a,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:h="y",sizeBy:g,sizeRange:p=[5,40],colorBy:y,colorScheme:f="category10",bubbleOpacity:m=.6,bubbleStrokeWidth:v=1,bubbleStrokeColor:b="white",tooltip:x,marginalGraphics:k,pointIdAccessor:w,annotations:A,frameProps:S={},selection:O,linkedHover:M,linkedBrush:E,onObservation:j,chartId:C,loading:_,emptyContent:B,legendInteraction:N,legendPosition:H}=t,z=r.width,$=r.height,T=r.enableHover,W=r.showGrid,I=r.showLegend,F=r.title,D=r.xLabel,R=r.yLabel,G=en(_,z,$);if(G)return G;const q=Jt(i,z,$,B);if(q)return q;const Y=i||[],{activeSelectionHook:X,customHoverBehavior:V}=pt({selection:O,linkedHover:M,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:j,chartType:"BubbleChart",chartId:C}),Q=ct(E);ot({name:(null==Q?void 0:Q.name)||"__unused_brush__",xField:(null==Q?void 0:Q.xField)||("string"==typeof u?u:void 0),yField:(null==Q?void 0:Q.yField)||("string"==typeof h?h:void 0)});const U=gt(Y,y,f),K=e.useMemo(()=>{if(!y)return[];const e=new Set;for(const t of Y){const n="function"==typeof y?y(t):t[y];null!=n&&e.add(n+"")}return Array.from(e)},[Y,y]),Z=ft(N,y,K),J=e.useMemo(()=>Z.legendSelectionHook?Z.legendSelectionHook:X,[Z.legendSelectionHook,X]),ee=e.useMemo(()=>{const e=Y.map(e=>"function"==typeof g?g(e):e[g]);return[Math.min(...e),Math.max(...e)]},[Y,g]),te=e.useMemo(()=>e=>{const t={fillOpacity:m,strokeWidth:v,stroke:b};return y?U&&(t.fill=P(e,y,U)):t.fill=ht,t.r=L(e,g,p,ee),t},[y,U,g,p,ee,m,v,b]),ne=e.useMemo(()=>ut(te,J,O),[te,J,O]),{legend:oe,margin:re,legendPosition:ie}=yt({data:Y,colorBy:y,colorScale:U,showLegend:I,legendPosition:H,userMargin:s,defaults:r.marginDefaults}),se=e.useMemo(()=>Et([{label:D||St(u),accessor:u,role:"x"},{label:R||St(h),accessor:h,role:"y"},{label:St(g),accessor:g,role:"size"},...y?[{label:St(y),accessor:y,role:"color"}]:[]]),[u,h,D,R,g,y]),ae=Nt({componentName:"BubbleChart",data:i,accessors:{xAccessor:u,yAccessor:h},requiredProps:{sizeBy:g}});if(ae)return d.createElement(jt,{componentName:"BubbleChart",message:ae,width:z,height:$});const le=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bubble"},null!=i&&{data:Y}),{xAccessor:u,yAccessor:h,colorAccessor:y||void 0,sizeAccessor:g,sizeRange:p,pointStyle:ne,colorScheme:f,size:[z,$],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:re,showAxes:r.showAxes,xLabel:D,yLabel:R,xFormat:l,yFormat:c,enableHover:T,showGrid:W}),oe&&{legend:oe,legendPosition:ie}),N&&"none"!==N&&{legendHoverBehavior:Z.onLegendHover,legendClickBehavior:Z.onLegendClick,legendHighlightedCategory:Z.highlightedCategory,legendIsolatedCategories:Z.isolatedCategories}),F&&{title:F}),a&&{className:a}),{tooltipContent:!1===x?()=>null:At(x)||se}),(M||j)&&{customHoverBehavior:V}),k&&{marginalGraphics:k}),w&&{pointIdAccessor:w}),A&&A.length>0&&{annotations:A}),S);return d.createElement(Ut,{componentName:"BubbleChart",width:z,height:$},d.createElement(Ye,Object.assign({ref:o},le)))});dn.displayName="BubbleChart";const gn=e.forwardRef(function(t,n){const i=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const s=vt(t.mode,{width:t.width,height:t.height,showGrid:void 0,enableHover:t.enableHover,showLegend:void 0,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:a,margin:l,className:c,xAccessor:u="x",yAccessor:h="y",valueAccessor:g="value",xFormat:p,yFormat:y,colorScheme:f="blues",customColorScale:m,showValues:v=!1,valueFormat:b,cellBorderColor:x="#fff",cellBorderWidth:k=1,tooltip:w,annotations:A,frameProps:S={},selection:O,linkedHover:M,onObservation:E,chartId:j,loading:C,emptyContent:P,showLegend:_,legendPosition:L,legendInteraction:B}=t,N=s.width,H=s.height,z=s.enableHover,$=s.title,T=s.xLabel,W=s.yLabel,I=en(C,N,H);if(I)return I;const F=Jt(a,N,H,P);if(F)return F;const D=a||[],R=null!=_&&_,G=null!=L?L:"right",{margin:q}=yt({data:D,colorBy:R?"value":void 0,colorScale:void 0,showLegend:R,legendPosition:G,userMargin:l,defaults:s.marginDefaults}),{activeSelectionHook:Y,customHoverBehavior:X}=pt({selection:O,linkedHover:M,fallbackFields:[],onObservation:E,chartType:"Heatmap",chartId:j}),V=ft(B,void 0,[]),Q=e.useMemo(()=>V.legendSelectionHook?V.legendSelectionHook:Y,[V.legendSelectionHook,Y]),U=e.useMemo(()=>"function"==typeof g?e=>g(e):e=>e[g],[g]),K=e.useMemo(()=>{const e=D.map(U);return[Math.min(...e),Math.max(...e)]},[D,U]),Z=e.useMemo(()=>"custom"===f&&m?m:o.scaleSequential({blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,viridis:r.interpolateViridis}[f]||r.interpolateBlues).domain(K),[f,m,K]);e.useMemo(()=>{const e=dt(u),t=dt(h);return{xBinCount:new Set(D.map(e)).size,yBinCount:new Set(D.map(t)).size}},[D,u,h]),e.useMemo(()=>({coordinates:D}),[D]);const J=e.useMemo(()=>e=>{const t=U(e);return{fill:Z(t),stroke:x,strokeWidth:k}},[U,Z,x,k]);e.useMemo(()=>ut(J,Q,O),[J,Q,O]);const ee=e.useMemo(()=>Et([{label:T||St(u),accessor:u,role:"x"},{label:W||St(h),accessor:h,role:"y"},{label:St(g),accessor:g,role:"value"}]),[u,h,T,W,g]),te=Nt({componentName:"Heatmap",data:a,accessors:{xAccessor:u,yAccessor:h,valueAccessor:g}});if(te)return d.createElement(jt,{componentName:"Heatmap",message:te,width:N,height:H});const ne=e.useMemo(()=>{if(R)return{gradient:{colorFn:e=>Z(e),domain:K,label:"string"==typeof g?g:"value",format:b}}},[R,Z,K,g,b]),oe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap"},null!=a&&{data:D}),{xAccessor:u,yAccessor:h,valueAccessor:g,colorScheme:"custom"!==f?f:void 0,showValues:v,heatmapValueFormat:b,size:[N,H],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:q,showAxes:s.showAxes,xLabel:T,yLabel:W,xFormat:p,yFormat:y,enableHover:z}),ne&&{legend:ne,legendPosition:G}),$&&{title:$}),c&&{className:c}),{tooltipContent:!1===w?()=>null:At(w)||ee}),(M||E)&&{customHoverBehavior:X}),A&&A.length>0&&{annotations:A}),S);return d.createElement(Ut,{componentName:"Heatmap",width:N,height:H},d.createElement(Ye,Object.assign({ref:i},oe)))});gn.displayName="Heatmap";const pn="__splomIdx",yn={top:4,bottom:4,left:4,right:4};function fn({frameRef:o,cellSize:r,onBrush:i}){const s=e.useRef(null),a=r-yn.left-yn.right,l=r-yn.top-yn.bottom;return e.useEffect(()=>{if(!s.current)return;const e=n.select(s.current).select(".brush-g"),r=t.brush().extent([[0,0],[a,l]]).on("brush end",e=>{var t;const n=null===(t=o.current)||void 0===t?void 0:t.getScales();if(!n)return;if(!e.selection)return void i(null);const[[r,s],[a,l]]=e.selection,c=[[n.x.invert(r),n.y.invert(s)],[n.x.invert(a),n.y.invert(l)]];i(c)});return e.call(r),e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null)}},[a,l,o,i]),d.createElement("svg",{ref:s,width:r,height:r,style:{position:"absolute",top:0,left:0}},d.createElement("g",{className:"brush-g",transform:`translate(${yn.left},${yn.top})`}))}function mn({data:t,xField:n,yField:o,cellSize:r,pointRadius:i,pointOpacity:s,colorBy:a,colorScale:l,brushSelectionName:c,hoverSelectionName:u,unselectedOpacity:h,mode:g,onPointHover:p}){const y=e.useRef(null),f=tt({name:c,clientId:`splom-${n}-${o}`}),m=ot({name:c,xField:n,yField:o}),v=tt({name:u,clientId:"splom-hover-source"}),b=v.selectPoints,x=e.useCallback(e=>{e?m.brushInteraction.during(e):m.brushInteraction.end(null)},[m.brushInteraction]),k=e.useCallback(e=>{if(!e)return void(null==p||p(null));const t=e.data,n=null==t?void 0:t[pn];void 0!==n&&(b({[pn]:[n]}),null==p||p(t,e.x+yn.left,e.y+yn.top))},[b,p]),w=e.useCallback(e=>{const t={opacity:s,r:i};return t.fill=a?P(e,a,l):ht,"hover"===g?v.isActive&&v.predicate(e)?(t.opacity=1,t.r=2.5*i,t.stroke="#333",t.strokeWidth=1.5):v.isActive&&(t.opacity=.6*s):f.isActive&&!f.predicate(e)&&(t.opacity=h),t},[a,l,s,i,g,f.isActive,f.predicate,v.isActive,v.predicate,h]);return d.createElement("div",{style:{position:"relative",width:r,height:r}},d.createElement(Ye,{ref:y,chartType:"scatter",data:t,size:[r,r],xAccessor:n,yAccessor:o,pointStyle:w,margin:yn,showAxes:!1,enableHover:"hover"===g,customHoverBehavior:"hover"===g?k:void 0,tooltipContent:"hover"===g?()=>null:void 0}),"brush"===g&&d.createElement(fn,{frameRef:y,cellSize:r,xField:n,yField:o,onBrush:x}))}function vn({data:t,field:n,label:o,cellSize:r,bins:i,colorBy:s,colorScale:a,brushSelectionName:l,hoverSelectionName:c,mode:u}){const h=tt({name:l,clientId:"splom-diag-"+n}),g=tt({name:c,clientId:`splom-diag-${n}-hover`}),p="hover"===u?g:h,y=p.isActive,f=p.predicate,m=e.useMemo(()=>{const e=t.map(e=>e[n]).filter(e=>null!=e&&!isNaN(e));if(0===e.length)return{bars:[],selectedBars:[],categoryBars:[],selectedCategoryBars:[],max:0,categories:[]};const o=Math.min(...e),a=(Math.max(...e)-o)/i||1,l="string"==typeof s?s:null,c=l?[...new Set(t.map(e=>e[l]).filter(e=>null!=e).map(String))]:[],u=new Map(c.map((e,t)=>[e,t])),h=Array(i).fill(0),d=Array(i).fill(0),g=Array.from({length:i},()=>Array(c.length).fill(0)),p=Array.from({length:i},()=>Array(c.length).fill(0));for(const e of t){const t=e[n];if(null==t||isNaN(t))continue;const r=Math.min(Math.floor((t-o)/a),i-1);if(h[r]++,y&&!f(e)||d[r]++,l){const t=u.get(e[l]+"");void 0!==t&&(g[r][t]++,y&&!f(e)||p[r][t]++)}}const m=Math.max(...h,1),v=g.map((e,t)=>{let n=0;return e.map((e,o)=>{const s=e/m*(r-24),a={x:t/i*r,w:r/i-1,h:s,y0:n,category:c[o]};return n+=s,a})}),b=p.map((e,t)=>{let n=0;return e.map((e,o)=>{const s=e/m*(r-24),a={x:t/i*r,w:r/i-1,h:s,y0:n,category:c[o]};return n+=s,a})});return{bars:h.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/m*(r-24),count:e})),selectedBars:d.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/m*(r-24),count:e})),categoryBars:v,selectedCategoryBars:b,max:m,categories:c}},[t,n,i,r,y,f,s]);return d.createElement("svg",{width:r,height:r,style:{overflow:"hidden"}},d.createElement("text",{x:r/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333"},o),m.categories.length>0?m.categoryBars.map((e,t)=>e.map((e,n)=>d.createElement("rect",{key:`bg-${t}-${n}`,x:e.x,y:r-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:a?a(e.category):ht,opacity:y?.3:.6}))):m.bars.map((e,t)=>d.createElement("rect",{key:"bg-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:ht,opacity:y?.3:.6})),y&&(m.categories.length>0?m.selectedCategoryBars.map((e,t)=>e.map((e,n)=>d.createElement("rect",{key:`sel-${t}-${n}`,x:e.x,y:r-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:a?a(e.category):ht,opacity:.7}))):m.selectedBars.map((e,t)=>d.createElement("rect",{key:"sel-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:ht,opacity:.7}))))}function bn({label:e,cellSize:t}){return d.createElement("svg",{width:t,height:t},d.createElement("text",{x:t/2,y:t/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333"},e))}function xn(t){const{data:n,fields:o,fieldLabels:r={},colorBy:i,colorScheme:s="category10",cellSize:a=150,cellGap:l=4,pointRadius:c=2,pointOpacity:u=.5,diagonal:h="histogram",histogramBins:g=20,brushMode:p="crossfilter",hoverMode:y=!0,unselectedOpacity:f=.1,showGrid:m=!1,tooltip:v,showLegend:b,idAccessor:x,className:k,onObservation:w,chartId:A}=t,S="splom",O="splom-hover",M=y?"hover":p?"brush":"hover",E=Ze(e=>e.clearSelection),[j,C]=e.useState(null),P=e.useCallback(()=>{E(O),C(null)},[E,O]),_=e.useMemo(()=>(n||[]).map((e,t)=>void 0!==e[pn]?e:Object.assign(Object.assign({},e),{[pn]:t})),[n]),L=gt(_,i,s),B=void 0!==b?b:!!i,N=e.useMemo(()=>{if(!B||!i)return null;const e="string"==typeof i?i:null;return e?[...new Set(_.map(t=>t[e]))].map(e=>({label:e+"",color:L?L(e+""):ht})):null},[B,i,_,L]),H=e.useMemo(()=>({display:"grid",gridTemplateColumns:"40px "+o.map(()=>a+"px").join(" "),gridTemplateRows:o.map(()=>a+"px").join(" ")+" 40px",gap:l+"px",width:"fit-content"}),[o,a,l,40]);return d.createElement("div",{className:k,style:{position:"relative"}},N&&d.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},N.map(e=>d.createElement("div",{key:e.label,style:{display:"flex",alignItems:"center",gap:4}},d.createElement("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:e.color}}),d.createElement("span",{style:{fontSize:11}},e.label)))),d.createElement("div",{style:H,onMouseLeave:"hover"===M?P:void 0},o.map((e,t)=>d.createElement(d.Fragment,{key:"row-"+e},d.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e),o.map((n,o)=>t===o?"label"===h?d.createElement(bn,{key:"diag-"+e,label:r[e]||e,cellSize:a}):d.createElement(vn,{key:"diag-"+e,data:_,field:e,label:r[e]||e,cellSize:a,bins:g,colorBy:i,colorScale:L,brushSelectionName:S,hoverSelectionName:O,unselectedOpacity:f,mode:M}):d.createElement(mn,{key:`cell-${e}-${n}`,data:_,xField:n,yField:e,fieldLabels:r,cellSize:a,pointRadius:c,pointOpacity:u,colorBy:i,colorScale:L,brushSelectionName:S,hoverSelectionName:O,unselectedOpacity:f,showGrid:m,tooltip:v,mode:M,onPointHover:"hover"===M?(r,i,s)=>{r?(C({datum:r,xField:n,yField:e,colIndex:o,rowIndex:t,px:null!=i?i:0,py:null!=s?s:0}),w&&w({type:"hover",datum:r,x:null!=i?i:0,y:null!=s?s:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A})):(C(null),w&&w({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A}))}:void 0})))),d.createElement("div",null)," ",o.map(e=>d.createElement("div",{key:"col-label-"+e,style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e))),j&&"hover"===M&&(()=>{const e=j.datum,t=r[j.xField]||j.xField,n=r[j.yField]||j.yField,o=i?"function"==typeof i?i(e):e[i]:null,s=x?"function"==typeof x?x(e):e[x]:"Row "+e[pn];return d.createElement("div",{style:{position:"absolute",left:40+j.colIndex*(a+l)+j.px,top:j.rowIndex*(a+l)+j.py-8,transform:"translate(-50%, -100%)",color:"#333",background:"rgba(255,255,255,0.95)",border:"1px solid #ddd",borderRadius:3,padding:"4px 8px",fontSize:11,lineHeight:1.4,whiteSpace:"nowrap",pointerEvents:"none",zIndex:10}},d.createElement("div",{style:{fontWeight:"bold",marginBottom:2}},s+""),d.createElement("div",null,t,": ",null!=e[j.xField]?Number(e[j.xField]).toFixed(1):"–"),d.createElement("div",null,n,": ",null!=e[j.yField]?Number(e[j.yField]).toFixed(1):"–"),null!=o&&d.createElement("div",{style:{opacity:.8}},"string"==typeof i?i:"group",": ",o+""))})())}function kn(e){const{brushMode:t="crossfilter",hoverMode:n=!0}=e,o={};return!n&&t&&(o.splom={resolution:t}),n&&(o["splom-hover"]={resolution:"union"}),d.createElement(at,{selections:o},d.createElement(xn,Object.assign({},e)))}function wn({width:o,height:r,margin:i,scales:s,brushDirection:a,extent:l,onBrush:c}){const u=e.useRef(null),h=e.useRef(null),g=e.useRef(!1),p=o+i.left+i.right,y=r+i.top+i.bottom;return e.useEffect(()=>{if(!u.current||!s)return;const e=n.select(u.current).select(".brush-group"),i="x"===a?t.brushX().extent([[0,0],[o,r]]):t.brushY().extent([[0,0],[o,r]]);return i.on("brush end",e=>{if(g.current)return;if(!e.sourceEvent)return;const t=e.selection;if(!t)return void c(null);const n=("x"===a?s.x:s.y).invert;if(!n)return;const o=[n(t[0]),n(t[1])];c(o)}),e.call(i),h.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null)}},[s,o,r,a,c]),e.useEffect(()=>{if(!h.current||!s||!u.current)return;const e=n.select(u.current).select(".brush-group"),t="x"===a?s.x:s.y;if(g.current=!0,l){const n=[t(l[0]),t(l[1])];e.call(h.current.move,n)}else e.call(h.current.move,null);g.current=!1},[l,s,a]),d.createElement("svg",{ref:u,width:p,height:y,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},d.createElement("g",{className:"brush-group",transform:`translate(${i.left},${i.top})`}))}function An(t){var n,o;const{data:r,width:i=600,height:s=400,margin:a,className:l,title:c,xLabel:u,yLabel:h,xFormat:g,yFormat:p,xAccessor:y="x",yAccessor:f="y",lineBy:m,lineDataAccessor:v="coordinates",colorBy:b,colorScheme:x="category10",curve:k="linear",lineWidth:w=2,fillArea:A=!1,areaOpacity:S=.3,showPoints:O=!1,pointRadius:M=3,enableHover:E=!0,showGrid:j=!1,showLegend:C,legendPosition:_,tooltip:L,minimap:B={},renderBefore:N=!1,onBrush:H,brushExtent:z,frameProps:$={},loading:T,emptyContent:W}=t,I=en(T,i,s);if(I)return I;const F=Jt(r,i,s,W);if(F)return F;const D=r||[],[R,G]=e.useState(null),q=null!=z?z:R,Y=e.useCallback(e=>{z||G(e),null==H||H(e)},[z,H]),X=e.useRef(null),[V,Q]=e.useState(null);e.useEffect(()=>{const e=()=>{var t,n;const o=null===(n=null===(t=X.current)||void 0===t?void 0:t.getScales)||void 0===n?void 0:n.call(t);o?Q(o):requestAnimationFrame(e)};requestAnimationFrame(e)},[r]);const U=void 0!==(null===(n=D[0])||void 0===n?void 0:n[v]),K=e.useMemo(()=>{if(U)return D;if(m){const e=D.reduce((e,t)=>{const n="function"==typeof m?m(t):t[m];if(!e[n]){const t={[v]:[]};"string"==typeof m&&(t[m]=n),e[n]=t}return e[n][v].push(t),e},{});return Object.values(e)}return[{[v]:D}]},[D,m,v,U]),Z=e.useMemo(()=>U||m?K.flatMap(e=>{const t=e[v]||[];return m&&"string"==typeof m?t.map(t=>Object.assign(Object.assign({},t),{[m]:e[m]})):t}):D,[K,v,U,m,D]),J=gt(D,b,x),ee=e.useMemo(()=>e=>{const t={strokeWidth:w};return t.stroke=b?P(e,b,J):ht,A&&(t.fill=t.stroke,t.fillOpacity=S),t},[b,J,w,A,S]),te=e.useMemo(()=>B.lineStyle?B.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=b?P(e,b,J):ht,t},[b,J,B.lineStyle]),ne=e.useMemo(()=>{if(O)return e=>{const t={r:M,fillOpacity:1};return t.fill=b?P(e.parentLine||e,b,J):ht,t}},[O,M,b,J]),{legend:oe,margin:re,legendPosition:ie}=yt({data:K,colorBy:b,colorScale:J,showLegend:C,legendPosition:_,userMargin:a}),se=B.height||60,ae=e.useMemo(()=>{var e,t,n,o,r,i,s,a;return{top:null!==(t=null===(e=B.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(o=null===(n=B.margin)||void 0===n?void 0:n.bottom)&&void 0!==o?o:20,left:null!==(i=null===(r=B.margin)||void 0===r?void 0:r.left)&&void 0!==i?i:re.left,right:null!==(a=null===(s=B.margin)||void 0===s?void 0:s.right)&&void 0!==a?a:re.right}},[B.margin,re]),le=B.brushDirection||"x",ce=Nt({componentName:"MinimapChart",data:r,accessors:{xAccessor:y,yAccessor:f}});if(ce)return d.createElement(jt,{componentName:"MinimapChart",message:ce,width:i,height:s});const ue=A?"area":"line",he=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:ue,data:Z,xAccessor:y,yAccessor:f,groupAccessor:m||void 0,curve:k,lineStyle:ee},O&&{pointStyle:ne}),{size:[i,s],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:re,showAxes:!0,xLabel:u,yLabel:h,xFormat:g,yFormat:p,enableHover:E,showGrid:j}),oe&&{legend:oe,legendPosition:ie}),c&&{title:c}),L&&{tooltipContent:At(L)||void 0}),q&&{xExtent:q}),$),de={chartType:ue,data:Z,xAccessor:y,yAccessor:f,groupAccessor:m||void 0,curve:k,lineStyle:te,size:[i,se+ae.top+ae.bottom],margin:ae,showAxes:null!==(o=B.showAxes)&&void 0!==o&&o,background:B.background,enableHover:!1},ge=d.createElement("div",{key:"minimap",style:{position:"relative",width:i,overflow:"hidden"}},d.createElement(Ye,Object.assign({ref:X},de)),d.createElement(wn,{width:i-ae.left-ae.right,height:se,margin:ae,scales:V,brushDirection:le,extent:q,onBrush:Y})),pe=d.createElement("div",{key:"main",style:{overflow:"hidden"}},d.createElement(Ye,Object.assign({},he)));return d.createElement(Ut,{componentName:"MinimapChart",width:i,height:s},d.createElement("div",{className:"minimap-chart"+(l?" "+l:"")},N?ge:pe,N?pe:ge))}kn.displayName="ScatterplotMatrix",An.displayName="MinimapChart";const Sn=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const r=vt(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:s,className:a,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:h="y",xCenter:g,yCenter:p,quadrants:y,centerlineStyle:f={},showQuadrantLabels:m=!0,quadrantLabelSize:v=12,colorBy:b,colorScheme:x="category10",sizeBy:k,sizeRange:w=[3,15],pointRadius:A=5,pointOpacity:S=.8,tooltip:O,pointIdAccessor:M,annotations:E,frameProps:j={},selection:C,linkedHover:_,onObservation:B,chartId:N,loading:H,emptyContent:z,legendInteraction:$,legendPosition:T}=t,W=r.width,I=r.height,F=r.enableHover,D=r.showGrid,R=r.showLegend,G=r.title,q=r.xLabel,Y=r.yLabel,X=en(H,W,I);if(X)return X;const V=Jt(i,W,I,z);if(V)return V;const Q=i||[];tn("QuadrantChart",Q,"xAccessor",u),tn("QuadrantChart",Q,"yAccessor",h);const{activeSelectionHook:U,customHoverBehavior:K}=pt({selection:C,linkedHover:_,fallbackFields:"string"==typeof b?[b]:[],onObservation:B,chartType:"QuadrantChart",chartId:N}),Z=gt(Q,b,x),J=e.useMemo(()=>{if(!b)return[];const e=new Set;for(const t of Q){const n="function"==typeof b?b(t):t[b];null!=n&&e.add(n+"")}return Array.from(e)},[Q,b]),ee=ft($,b,J),te=e.useMemo(()=>ee.legendSelectionHook?ee.legendSelectionHook:U,[ee.legendSelectionHook,U]),ne=e.useMemo(()=>{if(!Q.length)return;const e="function"==typeof u?u:e=>+e[u],t="function"==typeof h?h:e=>+e[h];let n=1/0,o=-1/0,r=1/0,i=-1/0;for(const s of Q){const a=e(s),l=t(s);isFinite(a)&&(n>a&&(n=a),a>o&&(o=a)),isFinite(l)&&(r>l&&(r=l),l>i&&(i=l))}if(null!=g&&isFinite(g)&&(n>g&&(n=g),g>o&&(o=g)),null!=p&&isFinite(p)&&(r>p&&(r=p),p>i&&(i=p)),n===1/0)return;const s=.1*(o-n)||1,a=.1*(i-r)||1;return{xExtent:[n-s,o+s],yExtent:[r-a,i+a]}},[Q,u,h,g,p]),oe=e.useMemo(()=>{if(!k||0===Q.length)return;const e=Q.map(e=>"function"==typeof k?k(e):e[k]).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0!==e.length?[Math.min(...e),Math.max(...e)]:void 0},[Q,k]),re=e.useMemo(()=>"function"==typeof u?u:e=>+e[u],[u]),ie=e.useMemo(()=>"function"==typeof h?h:e=>+e[h],[h]),se=e.useMemo(()=>e=>{const t={fillOpacity:S};if(b)Z&&(t.fill=P(e,b,Z));else{const n=re(e),o=ie(e),r=null!=g?n>=g:void 0,i=null!=p?o>=p:void 0;t.fill=void 0===i||void 0===r?ht:i&&r?y.topRight.color:i&&!r?y.topLeft.color:!i&&r?y.bottomRight.color:y.bottomLeft.color}return t.r=k?L(e,k,w,oe):A,t},[b,Z,k,w,oe,A,S,re,ie,g,p,y]),ae=e.useMemo(()=>ut(se,te,C),[se,te,C]),{legend:le,margin:ce,legendPosition:ue}=yt({data:Q,colorBy:b,colorScale:Z,showLegend:R,legendPosition:T,userMargin:s,defaults:r.marginDefaults}),he=e.useMemo(()=>{if(!Q.length)return;const e=new Set;"string"==typeof u&&e.add(u),"string"==typeof h&&e.add(h),"string"==typeof b&&e.add(b),"string"==typeof k&&e.add(k);const t=Q[0];for(const n of Object.keys(t))if(!n.startsWith("_")&&!e.has(n)&&"string"==typeof t[n])return n},[Q,u,h,b,k]),de=e.useMemo(()=>Et([...he?[{label:he,accessor:he,role:"title"}]:[],{label:q||St(u),accessor:u,role:"x"},{label:Y||St(h),accessor:h,role:"y"},...b?[{label:St(b),accessor:b,role:"color"}]:[],...k?[{label:St(k),accessor:k,role:"size"}]:[]]),[he,u,h,q,Y,b,k]),ge=Nt({componentName:"QuadrantChart",data:i,accessors:{xAccessor:u,yAccessor:h}});if(ge)return d.createElement(jt,{componentName:"QuadrantChart",message:ge,width:W,height:I});const pe=e.useMemo(()=>{var e;const t={stroke:f.stroke||"#999",strokeWidth:null!==(e=f.strokeWidth)&&void 0!==e?e:1,dashArray:f.strokeDasharray||[]};return[(e,n,o,r)=>{var i;if(!(null==o?void 0:o.x)||!(null==o?void 0:o.y))return;const s=r.width,a=r.height,l=null!=g?o.x(g):s/2,c=null!=p?o.y(p):a/2;if(null!=g&&!isFinite(l))return;if(null!=p&&!isFinite(c))return;const u=Math.max(0,Math.min(s,l)),h=Math.max(0,Math.min(a,c)),d=[{config:y.topLeft,x:0,y:0,w:u,h:h},{config:y.topRight,x:u,y:0,w:s-u,h:h},{config:y.bottomLeft,x:0,y:h,w:u,h:a-h},{config:y.bottomRight,x:u,y:h,w:s-u,h:a-h}];for(const t of d)t.w>0&&t.h>0&&(e.fillStyle=t.config.color,e.globalAlpha=null!==(i=t.config.opacity)&&void 0!==i?i:.08,e.fillRect(t.x,t.y,t.w,t.h));e.globalAlpha=1,e.strokeStyle=t.stroke,e.lineWidth=t.strokeWidth,t.dashArray.length>0&&e.setLineDash(t.dashArray),e.beginPath(),e.moveTo(u,0),e.lineTo(u,a),e.stroke(),e.beginPath(),e.moveTo(0,h),e.lineTo(s,h),e.stroke(),e.setLineDash([])}]},[g,p,y,f]),ye=e.useMemo(()=>m?[...pe,(e,t,n,o)=>{if(!(null==n?void 0:n.x)||!(null==n?void 0:n.y))return;const r=o.width,i=o.height,s=null!=g?n.x(g):r/2,a=null!=p?n.y(p):i/2;(null==g||isFinite(s))&&(null==p||isFinite(a))&&(e.font=`600 ${v}px sans-serif`,e.globalAlpha=.5,e.fillStyle=y.topLeft.color,e.textAlign="left",e.textBaseline="top",e.fillText(y.topLeft.label,8,8),e.fillStyle=y.topRight.color,e.textAlign="right",e.textBaseline="top",e.fillText(y.topRight.label,r-8,8),e.fillStyle=y.bottomLeft.color,e.textAlign="left",e.textBaseline="bottom",e.fillText(y.bottomLeft.label,8,i-8),e.fillStyle=y.bottomRight.color,e.textAlign="right",e.textBaseline="bottom",e.fillText(y.bottomRight.label,r-8,i-8),e.globalAlpha=1)}]:pe,[pe,m,v,y,g,p]),fe=e.useMemo(()=>{const e=j.canvasPreRenderers||[];return[...ye,...e]},[ye,j.canvasPreRenderers]),me=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=i&&{data:Q}),{xAccessor:u,yAccessor:h,colorAccessor:b||void 0,sizeAccessor:k||void 0,sizeRange:w,pointStyle:ae,colorScheme:x,size:[W,I],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ce,showAxes:r.showAxes,xLabel:q,yLabel:Y,xFormat:l,yFormat:c,enableHover:F,showGrid:D}),ne&&{xExtent:ne.xExtent,yExtent:ne.yExtent}),le&&{legend:le,legendPosition:ue}),$&&"none"!==$&&{legendHoverBehavior:ee.onLegendHover,legendClickBehavior:ee.onLegendClick,legendHighlightedCategory:ee.highlightedCategory,legendIsolatedCategories:ee.isolatedCategories}),G&&{title:G}),a&&{className:a}),{tooltipContent:!1===O?()=>null:!0===O||void 0===O?de:At(O)||de}),(_||B)&&{customHoverBehavior:K}),M&&{pointIdAccessor:M}),E&&E.length>0&&{annotations:E}),{canvasPreRenderers:fe}),j),fe.length>0&&{canvasPreRenderers:fe});return d.createElement(Ut,{componentName:"QuadrantChart",width:W,height:I},d.createElement(Ye,Object.assign({ref:o},me)))});Sn.displayName="QuadrantChart";const On="__forecastSegment";function Mn(e,t){return"function"==typeof t?t(e):!!e[t]}const En=Object.freeze({__proto__:null,SEGMENT_FIELD:On,buildAnomalyAnnotations:function(e){var t,n,o;return[{type:"anomaly-band",threshold:null!==(t=e.threshold)&&void 0!==t?t:2,showBand:!1!==e.showBand,fill:e.bandColor||"#6366f1",fillOpacity:null!==(n=e.bandOpacity)&&void 0!==n?n:.1,anomalyColor:e.anomalyColor||"#ef4444",anomalyRadius:null!==(o=e.anomalyRadius)&&void 0!==o?o:6,label:e.label}]},buildForecast:function(e,t,n,o,r){return(i=o).isTraining||i.isForecast||i.isAnomaly||i.upperBounds||i.lowerBounds?function(e,t,n,o,r){var i,s,a;const{isTraining:l,isForecast:c,isAnomaly:u,upperBounds:h,lowerBounds:d,color:g="#6366f1",bandOpacity:p=.15,anomalyColor:y="#ef4444",anomalyRadius:f=6,label:m}=o,v=e.map(e=>{let t="observed";return c&&Mn(e,c)?t="forecast":l&&Mn(e,l)&&(t="training"),Object.assign(Object.assign({},e),{[On]:t})}),b=[];for(let e=0;v.length>e;e++)b.push(v[e]),v.length-1>e&&v[e][On]!==v[e+1][On]&&b.push(Object.assign(Object.assign({},v[e]),{[On]:v[e+1][On]}));const x=[];if(h&&d){const e="string"==typeof h?h:"__envUpper",t="string"==typeof d?d:"__envLower";if("function"==typeof h||"function"==typeof d)for(const n of b)"function"==typeof h&&(n[e]=h(n)),"function"==typeof d&&(n[t]=d(n));x.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:g,fillOpacity:p,label:m})}return u&&x.push({type:"highlight",filter:e=>Mn(e,u),color:y,r:f,style:{stroke:y,strokeWidth:1.5,fill:y,fillOpacity:.7}}),r&&x.push({type:"anomaly-band",threshold:null!==(i=r.threshold)&&void 0!==i?i:2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:null!==(s=r.bandOpacity)&&void 0!==s?s:.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:null!==(a=r.anomalyRadius)&&void 0!==a?a:6,label:r.label}),{processedData:b,annotations:x}}(e,0,0,o,r):function(e,t,n,o,r){var i,s,a;const{trainEnd:l,steps:c=10,confidence:u=.95,color:h="#6366f1",bandOpacity:d=.15,label:g}=o;if(null==l)return{processedData:e,annotations:[]};const p=[],y=[];for(const n of e)n[t]>l?y.push(Object.assign(Object.assign({},n),{[On]:"observed"})):p.push(Object.assign(Object.assign({},n),{[On]:"training"}));const f=p.map(e=>[e[t],e[n]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),m=[],v=[];if(f.length>=3){const o=f.length;let r=0,i=0,s=0,a=0;for(const[e,t]of f)r+=e,i+=t,s+=e*e,a+=e*t;const l=o*s-r*r;if(Math.abs(l)>1e-12){const s=(o*a-r*i)/l,p=(i-s*r)/o,y=e=>p+s*e,b=f.map(([e,t])=>t-y(e)).reduce((e,t)=>e+t*t,0),x=Math.sqrt(b/Math.max(o-2,1)),k=f.reduce((e,t)=>e+t[0],0)/o,w=f.reduce((e,t)=>e+Math.pow(t[0]-k,2),0),A=.99>u?.95>u?.9>u?1:1.645:1.96:2.576,S=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),O=Math.max(...S),M=f.length>1?(f[o-1][0]-f[0][0])/(o-1):1;for(let e=1;c>=e;e++){const r=O+e*M,i=y(r),s=x*Math.sqrt(1+1/o+(w>0?Math.pow(r-k,2)/w:0))*A;v.push({[t]:r,[n]:i,[On]:"forecast",__forecastUpper:i+s,__forecastLower:i-s})}m.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:h,fillOpacity:d,label:g})}}m.push({type:"x-threshold",x:l,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),r&&m.push({type:"anomaly-band",threshold:null!==(i=r.threshold)&&void 0!==i?i:2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:null!==(s=r.bandOpacity)&&void 0!==s?s:.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:null!==(a=r.anomalyRadius)&&void 0!==a?a:6,label:r.label});const b=[];if(b.push(...p),p.length>0&&y.length>0&&b.push(Object.assign(Object.assign({},p[p.length-1]),{[On]:"observed"})),b.push(...y),v.length>0){const e=y.length>0?y[y.length-1]:p[p.length-1];e&&b.push(Object.assign(Object.assign({},e),{[On]:"forecast"})),b.push(...v)}return{processedData:b,annotations:m}}(e,t,n,o,r);var i},createSegmentLineStyle:function(e,t){var n,o;const r=null!==(n=t.trainDasharray)&&void 0!==n?n:"8,4",i=null!==(o=t.forecastDasharray)&&void 0!==o?o:"4,4",s=t.color||"#6366f1";return t=>{const n=e(t),o=t[On];return"training"===o?Object.assign(Object.assign({},n),{strokeDasharray:r}):"forecast"===o?Object.assign(Object.assign({},n),{stroke:s,strokeDasharray:i}):n}}});exports.AreaChart=an,exports.BubbleChart=dn,exports.ConnectedScatterplot=hn,exports.Heatmap=gn,exports.LineChart=sn,exports.MinimapChart=An,exports.QuadrantChart=Sn,exports.Scatterplot=cn,exports.ScatterplotMatrix=kn,exports.StackedAreaChart=ln,exports.StreamXYFrame=Ye;
1
+ "use strict";const e=require("react"),t=require("d3-brush"),n=require("d3-selection"),o=require("d3-scale"),r=require("d3-scale-chromatic"),i=require("d3-quadtree"),s=require("d3-array"),a=require("d3-hierarchy"),l=require("d3-shape"),c=require("regression");function u(e){return e&&e.__esModule?e:{default:e}}function h(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}return t.default=e,Object.freeze(t)}const d=h(e),g=u(c);class p{constructor(e,t){var n,o;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=null!==(n=null==t?void 0:t.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(o=null==t?void 0:t.chunkSize)&&void 0!==o?o:5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const o=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){this.pushBuffer.push(e),this.scheduleFlush()}pushMany(e){if(0!==e.length){for(let t=0;e.length>t;t++)this.pushBuffer.push(e[t]);this.scheduleFlush()}}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}class y{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class f{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function m(e,t,n,o,r){const i=new Map;for(const s of e){const e=t(s),a=n(s);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const l=Math.floor(e/o)*o;let c=i.get(l);if(c||(c={start:l,end:l+o,total:0,categories:new Map},i.set(l,c)),c.total+=a,r){const e=r(s);c.categories.set(e,(c.categories.get(e)||0)+a)}}return i}function b(e,t,n,o,r,i){const s=[];for(const r of e){const e=n(r),i=o(r);null==e||null==i||Number.isNaN(e)||Number.isNaN(i)||s.push({px:t.x(e),py:t.y(i),rawY:i,d:r})}s.sort((e,t)=>e.px-t.px);const a=Array(s.length),l=Array(s.length),c=Array(s.length);for(let e=0;s.length>e;e++){const t=s[e];a[e]=[t.px,t.py],l[e]=t.rawY,c[e]=t.d}return{type:"line",path:a,rawValues:l,style:r,datum:c,group:i}}function v(e,t,n,o,r,i,s,a){const l=[];for(const i of e){const e=n(i),s=o(i);if(null==e||null==s||Number.isNaN(e)||Number.isNaN(s))continue;const c=t.x(e),u=a?a(i):r;l.push({px:c,topY:t.y(s),botY:t.y(u)})}l.sort((e,t)=>e.px-t.px);const c=Array(l.length),u=Array(l.length);for(let e=0;l.length>e;e++){const t=l[e];c[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:c,bottomPath:u,style:i,datum:e,group:s}}function x(e,t,n,o,r,i,s){const a=n(e),l=o(e);if(null==a||null==l||Number.isNaN(a)||Number.isNaN(l))return null;const c={type:"point",x:t.x(a),y:t.y(l),r:r,style:i,datum:e};return void 0!==s&&(c.pointId=s),c}function k(e,t,n,o,r,i,s){return{type:"rect",x:e,y:t,w:n,h:o,style:r,datum:i,group:s}}function w(e,t,n,o,r,i,s){const a={type:"heatcell",x:e,y:t,w:n,h:o,fill:r,datum:i};return(null==s?void 0:s.showValues)&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function A(e,t){return e===t||typeof e==typeof t&&"function"==typeof e&&"function"==typeof t&&""+e==""+t}function S(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function O(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function M(e,t){return"function"==typeof e?e:e?t=>t[e]+"":void 0}const j={category10:r.schemeCategory10,tableau10:r.schemeTableau10,set3:r.schemeSet3,blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,oranges:r.interpolateOranges,purples:r.interpolatePurples,viridis:r.interpolateViridis,plasma:r.interpolatePlasma},E=r.schemeCategory10,C=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],P=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function _(e,t,n){if("function"==typeof t){const o=t(e);return n&&o&&"string"==typeof o&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||P.has(t)}(o)?n(o):o}const o=e[t];return n?n(o):E[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(o+""))%E.length]}function L(e,t,n="category10"){const r=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e))),i=r.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return o.scaleOrdinal().domain(r).range(n).unknown("#999");const s=j[n]||j.category10;if(i&&"function"==typeof s){let e=-1/0;for(const t of r){const n=Number(t);n>e&&(e=n)}return t=>s(Number(t)/e)}{const e=Array.isArray(s)?s:E;return o.scaleOrdinal().domain(r).range(e).unknown("#999")}}function B(e,t,n=[3,20],o){let r;if(r="function"==typeof t?t(e):e[t],!o)return r;const[i,s]=o,[a,l]=n;return s===i?(a+l)/2:a+(r-i)/(s-i)*(l-a)}function N(e,t,n){return e+(t-e)*n}class H{constructor(e){this.xExtent=new f,this.yExtent=new f,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.xIsDate=!1,this._quadtree=null,this.config=e,this.buffer=new y(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=S(e.timeAccessor||e.xAccessor,"time"),this.getY=S(e.valueAccessor||e.yAccessor,"value")):(this.getX=S(e.xAccessor,"x"),this.getY=S(e.yAccessor,"y")),this.getGroup=M(e.groupAccessor),this.getCategory=M(e.categoryAccessor),this.getSize=e.sizeAccessor?S(e.sizeAccessor,"size"):void 0,this.getColor=M(e.colorAccessor),this.getBounds=e.boundsAccessor?S(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?S(e.y0Accessor,"y0"):void 0,this.getPointId=M(e.pointIdAccessor),"candlestick"===e.chartType&&(this.getOpen=S(e.openAccessor,"open"),this.getHigh=S(e.highAccessor,"high"),this.getLow=S(e.lowAccessor,"low"),this.getClose=S(e.closeAccessor,"close")),e.pulse&&(this.timestampBuffer=new y(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){if(this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.getX=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?S(this.config.timeAccessor||this.config.xAccessor,"time"):S(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],n=this.config.xAccessor,o="function"==typeof n?n(t):t[n||"x"],r=o instanceof Date,i="string"==typeof o&&o.length>=10&&!isNaN(new Date(o).getTime())&&isNaN(Number(o));if(this.xIsDate=r||i,i){const e="string"==typeof n?n:void 0;this.getX=e?t=>+new Date(t[e]):e=>+(n(e)instanceof Date?n(e):new Date(n(e)))}}const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n)))}else for(const n of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity||1e6;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n))),null!=e&&(this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):this.yExtent.evict(this.getY(e)))}return!0}computeScene(e){var t,n,r,i,s,a;const{config:l,buffer:c}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);if(this.xExtent.dirty&&this.xExtent.recalculate(c,this.getX),this.yExtent.dirty)if("candlestick"===l.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of c)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(c,this.getY);const u=this.getBufferArray(),h=this.xExtent.extent,d=this.yExtent.extent;let g=l.xExtent?[null!==(t=l.xExtent[0])&&void 0!==t?t:h[0],null!==(n=l.xExtent[1])&&void 0!==n?n:h[1]]:h,p=l.yExtent?[null!==(r=l.yExtent[0])&&void 0!==r?r:d[0],null!==(i=l.yExtent[1])&&void 0!==i?i:d[1]]:d;const y=l.yExtent&&null!=l.yExtent[0]&&null!=l.yExtent[1];if("stackedarea"===l.chartType&&!y&&c.size>0)if(l.normalize)p=[0,1+l.extentPadding];else{const e=`${c.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===e)p=this._stackExtentCache.yDomain;else{const t=this.groupData(u),n=new Map;for(const e of t)for(const t of e.data){const e=this.getX(t),o=this.getY(t);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||n.set(e,(n.get(e)||0)+o)}let o=0;for(const e of n.values())e>o&&(o=e);p=[0,o+(o>0?o*l.extentPadding:1)],this._stackExtentCache={key:e,yDomain:p}}}else if("bar"===l.chartType&&l.binSize&&!y&&c.size>0){const[,e]=function(e,t,n,o,r){const i=m(e,t,n,o,r);if(0===i.size)return[0,0];let s=0;for(const e of i.values())e.total>s&&(s=e.total);return[0,s]}(c,this.getX,this.getY,l.binSize,this.getCategory);p=[0,e+e*l.extentPadding]}else if("waterfall"===l.chartType&&!y&&c.size>0){const[e,t]=function(e,t){let n=0,o=0,r=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(r+=e,n>r&&(n=r),r>o&&(o=r))}return[n,o]}(c,this.getY),n=t-e,o=n>0?n*l.extentPadding:1;p=[Math.min(0,e-Math.abs(o)),Math.max(0,t+Math.abs(o))]}else if(!y&&p[0]!==1/0){if(this.getBounds)for(const e of u){const t=this.getY(e),n=this.getBounds(e);null!=t&&!Number.isNaN(t)&&n&&(t+n>p[1]&&(p[1]=t+n),p[0]>t-n&&(p[0]=t-n))}const e=p[1]-p[0],t=e>0?e*l.extentPadding:1,n=null===(s=l.yExtent)||void 0===s?void 0:s[0],o=null===(a=l.yExtent)||void 0===a?void 0:a[1];p=[null!=n?p[0]:p[0]-t,null!=o?p[1]:p[1]+t],"log"===l.yScaleType&&0>=p[0]&&d[0]>0&&(p[0]=null!=n?p[0]:d[0]/(1+l.extentPadding))}if(g[0]!==1/0&&g[1]!==-1/0||(g=[0,1]),p[0]!==1/0&&p[1]!==-1/0||(p=[0,1]),"streaming"===l.runtimeMode)if("x"==("up"===(f=l.arrowOfTime)||"down"===f?"y":"x")){const t="right"===l.arrowOfTime?[0,e.width]:[e.width,0];this.scales={x:o.scaleLinear().domain(g).range(t),y:o.scaleLinear().domain(p).range([e.height,0])}}else{const t="down"===l.arrowOfTime?[0,e.height]:[e.height,0];this.scales={x:o.scaleLinear().domain(p).range([0,e.width]),y:o.scaleLinear().domain(g).range(t)}}else{const t=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return o.scaleLog().domain(e).range(n).clamp(!0)}return o.scaleLinear().domain(t).range(n)};this.scales={x:t(l.xScaleType,g,[0,e.width]),y:t(l.yScaleType,p,[e.height,0])}}var f;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(e,u),this.config.decay&&this.applyDecay(this.scene,u),this.config.pulse&&this.applyPulse(this.scene,u),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}rebuildQuadtree(){const e=this.config.chartType;if("scatter"!==e&&"bubble"!==e)return void(this._quadtree=null);const t=this.scene.filter(e=>"point"===e.type);this._quadtree=t.length>H.QUADTREE_THRESHOLD?i.quadtree().x(e=>e.x).y(e=>e.y).addAll(t):null}get quadtree(){return this._quadtree}remapScene(e){const t=e.width/this.lastLayout.width,n=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const o of e.path)o[0]*=t,o[1]*=n;break;case"area":for(const o of e.topPath)o[0]*=t,o[1]*=n;for(const o of e.bottomPath)o[0]*=t,o[1]*=n;break;case"point":e.x*=t,e.y*=n;break;case"rect":case"heatcell":e.x*=t,e.y*=n,e.w*=t,e.h*=n;break;case"candlestick":e.x*=t,e.openY*=n,e.closeY*=n,e.highY*=n,e.lowY*=n}const r=this.scales.x.domain(),i=this.scales.y.domain(),s=this.scales.x.range(),a=this.scales.y.range(),l=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return o.scaleLog().domain(e).range(n).clamp(!0)}return o.scaleLinear().domain(t).range(n)};this.scales={x:l(this.config.xScaleType,r,[s[0]*t,s[1]*t]),y:l(this.config.yScaleType,i,[a[0]*n,a[1]*n])},this.lastLayout={width:e.width,height:e.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(e,t){const{config:n,scales:o}=this;if(!o||0===t.length)return[];switch(n.chartType){case"line":return this.buildLineScene(t);case"area":return this.buildAreaScene(t);case"stackedarea":return this.buildStackedAreaScene(t);case"scatter":case"bubble":return this.buildPointScene(t);case"heatmap":return this.buildHeatmapScene(t,e);case"bar":return this.buildBarScene(t);case"swarm":return this.buildSwarmScene(t);case"waterfall":return this.buildWaterfallScene(t,e);case"candlestick":return this.buildCandlestickScene(t,e);default:return[]}}buildLineScene(e){var t;const n=this.groupData(e),o=[],r=null===(t=this.config.annotations)||void 0===t?void 0:t.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(this.getBounds)for(const e of n){const t=this.buildBoundsForGroup(e.data,e.key);t&&o.push(t)}for(const e of n){const t=this.resolveLineStyle(e.key,e.data[0]),n=b(e.data,this.scales,this.getX,this.getY,t,e.key);r&&r.length>0&&(n.colorThresholds=r),this.config.curve&&"linear"!==this.config.curve&&(n.curve=this.config.curve),o.push(n)}return o}buildAreaScene(e){const t=this.groupData(e),n=[],o=this.scales.y.domain()[0];for(const e of t){const t=this.resolveAreaStyle(e.key,e.data[0]),r=v(e.data,this.scales,this.getX,this.getY,o,t,e.key,this.getY0);this.config.gradientFill&&(r.fillGradient=this.config.gradientFill),this.config.curve&&"linear"!==this.config.curve&&(r.curve=this.config.curve),n.push(r)}return n}buildStackedAreaScene(e){const t=this.groupData(e);return t.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0),function(e,t,n,o,r,i,s){var a;const l=new Set;for(const t of e)for(const e of t.data){const t=n(e);null==t||Number.isNaN(t)||l.add(t)}const c=Array.from(l).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const r of t.data){const t=n(r),i=o(r);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||e.set(t,(e.get(t)||0)+i)}u.set(t.key,e)}let h;if(i){h=new Map;for(const t of c){let n=0;for(const o of e)n+=(null===(a=u.get(o.key))||void 0===a?void 0:a.get(t))||0;h.set(t,n||1)}}const d=[],g=new Map;for(const e of c)g.set(e,0);for(const n of e){const e=u.get(n.key),o=[],a=[];for(const n of c){let r=e.get(n)||0;const s=g.get(n);i&&(r/=h.get(n));const l=t.x(n);a.push([l,t.y(s)]),o.push([l,t.y(s+r)]),g.set(n,s+r)}const l={type:"area",topPath:o,bottomPath:a,style:r(n.key,n.data[0]),datum:n.data,group:n.key};s&&(l.curve=s),d.push(l)}return d}(t,this.scales,this.getX,this.getY,(e,t)=>this.resolveAreaStyle(e,t),this.config.normalize,this.config.curve&&"linear"!==this.config.curve?this.config.curve:void 0)}buildPointScene(e){const t=[],n="bubble"===this.config.chartType?10:5,o=this.config.sizeRange||[3,15];let r=null;if(this.getSize&&!this.config.pointStyle){const t=e.map(e=>this.getSize(e)).filter(e=>null!=e&&!Number.isNaN(e));if(t.length>0){let e=1/0,n=-1/0;for(const o of t)e>o&&(e=o),o>n&&(n=o);r=t=>e===n?(o[0]+o[1])/2:o[0]+(t-e)/(n-e)*(o[1]-o[0])}}const i=this.getColor?this.resolveColorMap(e):null;for(const o of e){let e=this.config.pointStyle?this.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},s=e.r||n;if(r&&this.getSize){const e=this.getSize(o);null==e||Number.isNaN(e)||(s=r(e))}if(i&&this.getColor&&!e.fill){const t=this.getColor(o);t&&i.has(t)&&(e=Object.assign(Object.assign({},e),{fill:i.get(t)}))}const a=this.getPointId?this.getPointId(o)+"":void 0,l=x(o,this.scales,this.getX,this.getY,s,e,a);l&&t.push(l)}return t}buildHeatmapScene(e,t){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(e,t);const i=S(this.config.valueAccessor,"value"),s=O(this.config.xAccessor,"x"),a=O(this.config.yAccessor,"y"),l=new Set,c=new Set;for(const t of e)l.add(s(t)),c.add(a(t));const u=Array.from(l),h=Array.from(c),d=u.every(e=>"number"==typeof e&&!isNaN(e)),g=h.every(e=>"number"==typeof e&&!isNaN(e)),p=d?u.sort((e,t)=>e-t):u,y=g?h.sort((e,t)=>e-t):h;if(0===p.length||0===y.length)return n;const f=t.width/p.length,m=t.height/y.length,b=new Map;for(const t of e){const e=`${s(t)}\0${a(t)}`;b.set(e,{val:i(t),datum:t})}let v=1/0,x=-1/0;for(const{val:e}of b.values())v>e&&(v=e),e>x&&(x=e);const k=o.scaleSequential({blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,viridis:r.interpolateViridis}["string"==typeof this.config.colorScheme?this.config.colorScheme:"blues"]||r.interpolateBlues).domain([v,x]);for(let e=0;p.length>e;e++)for(let t=0;y.length>t;t++){const o=b.get(`${p[e]}\0${y[t]}`);if(!o)continue;const r=k(o.val);n.push(w(e*f,(y.length-1-t)*m,f,m,r,o.datum,this.config.showValues?{value:o.val,showValues:!0,valueFormat:this.config.heatmapValueFormat}:void 0))}return n}buildStreamingHeatmapScene(e,t){var n,o,r;const i=[],s=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,a=null!==(o=this.config.heatmapYBins)&&void 0!==o?o:20,l=null!==(r=this.config.heatmapAggregation)&&void 0!==r?r:"count",c=S(this.config.valueAccessor,"value");if(!this.scales||0===e.length)return i;const[u,h]=this.scales.x.domain(),[d,g]=this.scales.y.domain(),p=(h-u||1)/s,y=(g-d||1)/a,f=new Map;for(const t of e){const e=this.getX(t),n=this.getY(t),o=Math.min(Math.floor((e-u)/p),s-1),r=Math.min(Math.floor((n-d)/y),a-1);if(0>o||0>r)continue;const i=`${o}_${r}`;let l=f.get(i);l||(l={sum:0,count:0,data:[]},f.set(i,l)),l.count++,l.sum+=c(t),l.data.push(t)}let m=1/0,b=-1/0;const v=new Map;for(const[e,t]of f){let n;switch(l){case"sum":n=t.sum;break;case"mean":n=t.count>0?t.sum/t.count:0;break;default:n=t.count}v.set(e,n),m>n&&(m=n),n>b&&(b=n)}const x=b-m||1,k=t.width/s,A=t.height/a;for(const[e,t]of v){const[n,o]=e.split("_"),r=+n,s=+o,l=(t-m)/x,c=`rgb(${Math.round(220-180*l)},${Math.round(220-100*l)},${Math.round(255-50*l)})`,u=f.get(e);i.push(w(r*k,(a-1-s)*A,k,A,c,{xi:r,yi:s,value:t,count:u.count,sum:u.sum,data:u.data},this.config.showValues?{value:t,showValues:!0,valueFormat:this.config.heatmapValueFormat}:void 0))}return i}buildBarScene(e){var t;if(!this.config.binSize)return[];const n=m(e,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===n.size)return[];let o=null;if(this.getCategory){const e=new Set;for(const t of n.values())for(const n of t.categories.keys())e.add(n);const t=this.config.barColors?Object.keys(this.config.barColors):[],r=new Set(t),i=Array.from(e).filter(e=>!r.has(e)).sort(),s=t.filter(t=>e.has(t)),a=s.join("\0")+""+i.join("\0");this._barCategoryCache&&this._barCategoryCache.key===a?o=this._barCategoryCache.order:(o=[...s,...i],this._barCategoryCache={key:a,order:o})}const r=[],i=this.scales,[s,a]=i.x.domain();for(const e of n.values()){const n=Math.max(e.start,s),l=Math.min(e.end,a);if(n>=l)continue;const c=i.x(n),u=i.x(l),h=Math.abs(u-c),d=h>2?1:0,g=Math.min(c,u)+d/2,p=Math.max(h-d,1);if(p>0)if(o&&e.categories.size>0){let n=0;for(const s of o){const o=e.categories.get(s)||0;if(0===o)continue;const a=i.y(n),l=i.y(n+o);r.push(k(g,Math.min(a,l),p,Math.abs(a-l),{fill:(null===(t=this.config.barColors)||void 0===t?void 0:t[s])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:s,categoryValue:o},s)),n+=o}}else{const t=i.y(0),n=i.y(e.total);r.push(k(g,Math.min(t,n),p,Math.abs(t-n),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}return r}buildSwarmScene(e){var t,n,o,r;const i=[],s=this.config.swarmStyle||{},a=null!==(t=s.radius)&&void 0!==t?t:3,l=null!==(n=s.fill)&&void 0!==n?n:"#007bff",c=null!==(o=s.opacity)&&void 0!==o?o:.7,u=s.stroke,h=s.strokeWidth;for(const t of e){const e=this.getX(t),n=this.getY(t);if(null==n||Number.isNaN(n))continue;const o=this.scales.x(e),s=this.scales.y(n);let d=l;if(this.getCategory){const e=this.getCategory(t);d=(null===(r=this.config.barColors)||void 0===r?void 0:r[e])||d}const g={type:"point",x:o,y:s,r:a,style:{fill:d,opacity:c,stroke:u,strokeWidth:h},datum:t};this.getPointId&&(g.pointId=this.getPointId(t)+""),i.push(g)}return i}buildWaterfallScene(e,t){var n,o,r;const i=[],s=this.scales,a=this.config.waterfallStyle,l=e.filter(e=>{const t=this.getY(e);return null!=t&&!Number.isNaN(t)});if(0===l.length)return i;const c=null!==(n=null==a?void 0:a.positiveColor)&&void 0!==n?n:"#28a745",u=null!==(o=null==a?void 0:a.negativeColor)&&void 0!==o?o:"#dc3545",h=null!==(r=null==a?void 0:a.gap)&&void 0!==r?r:1,d=null==a?void 0:a.stroke,g=null==a?void 0:a.strokeWidth;let p=0;for(let e=0;l.length>e;e++){const n=l[e],o=this.getX(n),r=this.getY(n),y=p+r;let f;f=l.length-1>e?this.getX(l[e+1])-o:e>0?o-this.getX(l[e-1]):0;const m=s.x(o),b=0!==f?s.x(o+f):m+t.width/10,v=Math.min(m,b)+h/2,x=Math.max(m,b)-h/2-v;if(0>=x){p=y;continue}const w=s.y(p),A=s.y(y);i.push(k(v,Math.min(w,A),x,Math.abs(w-A),{fill:0>r?u:c,stroke:d,strokeWidth:g},Object.assign(Object.assign({},n),{baseline:p,cumEnd:y,delta:r,_connectorStroke:null==a?void 0:a.connectorStroke,_connectorWidth:null==a?void 0:a.connectorWidth}))),p=y}return i}buildCandlestickScene(e,t){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],o=this.config.candlestickStyle||{},r=o.upColor||"#28a745",i=o.downColor||"#dc3545",s=o.wickColor||"#333",a=o.wickWidth||1,l=e.map(e=>this.getX(e)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let c=o.bodyWidth||6;if(!o.bodyWidth&&l.length>1){let e=1/0;for(let t=1;l.length>t;t++){const n=Math.abs(this.scales.x(l[t])-this.scales.x(l[t-1]));n>0&&e>n&&(e=n)}e!==1/0&&(c=Math.max(2,Math.min(.6*e,20)))}for(const t of e){const e=this.getX(t);if(null==e||Number.isNaN(e))continue;const o=this.getOpen(t),l=this.getHigh(t),u=this.getLow(t),h=this.getClose(t);if([o,l,u,h].some(e=>null==e||Number.isNaN(e)))continue;const d=h>=o;n.push({type:"candlestick",x:this.scales.x(e),openY:this.scales.y(o),closeY:this.scales.y(h),highY:this.scales.y(l),lowY:this.scales.y(u),bodyWidth:c,upColor:r,downColor:i,wickColor:s,wickWidth:a,isUp:d,datum:t})}return n}buildBoundsForGroup(e,t){if(!this.getBounds||!this.scales)return null;const n=[],o=[];for(const t of e){const e=this.getX(t),r=this.getY(t);if(null==e||null==r||Number.isNaN(e)||Number.isNaN(r))continue;const i=this.getBounds(t),s=this.scales.x(e);if(i&&0!==i)n.push([s,this.scales.y(r+i)]),o.push([s,this.scales.y(r-i)]);else{const e=this.scales.y(r);n.push([s,e]),o.push([s,e])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:o,style:this.resolveBoundsStyle(t,e[0]),datum:e,group:t,interactive:!1}}resolveBoundsStyle(e,t){const n=this.config.boundsStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(e,t).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){var n,o,r;const i=this.config.decay;if(!i||1>=t)return 1;const s=null!==(n=i.minOpacity)&&void 0!==n?n:.1,a=t-1-e;switch(i.type){case"linear":return s+(1-a/(t-1))*(1-s);case"exponential":{const e=null!==(o=i.halfLife)&&void 0!==o?o:t/2;return s+Math.pow(.5,a/e)*(1-s)}case"step":return(null!==(r=i.stepThreshold)&&void 0!==r?r:.5*t)>a?1:s;default:return 1}}applyDecay(e,t){var n,o;if(!this.config.decay)return;const r=t.length;if(1>=r)return;const i=new Map;for(let e=0;t.length>e;e++)i.set(t[e],e);for(const t of e){if("line"===t.type){const e=Array.isArray(t.datum)?t.datum:[];if(2>e.length)continue;const n=Array(e.length);let o=!1;for(let t=0;e.length>t;t++){const s=i.get(e[t]);null!=s?(n[t]=this.computeDecayOpacity(s,r),1>n[t]&&(o=!0)):n[t]=1}o&&(t._decayOpacities=n);continue}if("area"===t.type){const e=Array.isArray(t.datum)?t.datum:[],n=t.topPath?t.topPath.length:e.length;if(2>n)continue;if(e.length===n){const o=Array(n);let s=!1;for(let t=0;e.length>t;t++){const n=i.get(e[t]);null!=n?(o[t]=this.computeDecayOpacity(n,r),1>o[t]&&(s=!0)):o[t]=1}s&&(t._decayOpacities=o)}else{let o=1;for(const t of e){const e=i.get(t);if(null!=e){const t=this.computeDecayOpacity(e,r);o>t&&(o=t)}}if(1>o){const e=Array(n);e.fill(o),t._decayOpacities=e}}continue}const e=i.get(t.datum);if(null==e)continue;const s=this.computeDecayOpacity(e,r);if("heatcell"===t.type)t.style={opacity:s};else if("candlestick"===t.type)t._decayOpacity=s;else{const e=null!==(o=null===(n=t.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:e*s})}}}computePulseIntensity(e,t){var n;const o=this.config.pulse;if(!o)return 0;const r=null!==(n=o.duration)&&void 0!==n?n:500,i=t-e;return r>i?1-i/r:0}applyPulse(e,t){var n,o;if(!this.config.pulse||!this.timestampBuffer)return;const r="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",s=null!==(o=this.config.pulse.glowRadius)&&void 0!==o?o:4,a=new Map;for(let e=0;t.length>e;e++)a.set(t[e],e);for(const t of e){if("line"===t.type)continue;if("area"===t.type){const e=Array.isArray(t.datum)?t.datum:[t.datum];let n=0;for(const t of e){const e=a.get(t);if(null==e)continue;const o=this.timestampBuffer.get(e);if(null==o)continue;const i=this.computePulseIntensity(o,r);i>n&&(n=i)}n>0&&(t._pulseIntensity=n,t._pulseColor=i);continue}const e=a.get(t.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const o=this.computePulseIntensity(n,r);o>0&&(t._pulseIntensity=o,t._pulseColor=i,t._pulseGlowRadius=s)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}snapshotPositions(){var e,t,n;this.prevPositionMap.clear(),this.prevPathMap.clear();for(let o=0;this.scene.length>o;o++){const r=this.scene[o],i=this.getNodeIdentity(r,o);i&&("point"===r.type?this.prevPositionMap.set(i,{x:r.x,y:r.y,r:r.r,opacity:r.style.opacity}):"rect"===r.type?this.prevPositionMap.set(i,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:r.style.opacity}):"heatcell"===r.type?this.prevPositionMap.set(i,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:null===(e=r.style)||void 0===e?void 0:e.opacity}):"candlestick"===r.type?this.prevPositionMap.set(i,{x:r.x,y:r.openY}):"line"===r.type?this.prevPathMap.set(i,{path:r.path.map(e=>[e[0],e[1]]),opacity:null===(t=r.style)||void 0===t?void 0:t.opacity}):"area"===r.type&&this.prevPathMap.set(i,{topPath:r.topPath.map(e=>[e[0],e[1]]),bottomPath:r.bottomPath.map(e=>[e[0],e[1]]),opacity:null===(n=r.style)||void 0===n?void 0:n.opacity}))}}getNodeIdentity(e,t){var n,o,r,i;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===this.config.runtimeMode&&e.datum){if(this.getCategory)return`p:${this.getCategory(e.datum)}:${this.getY(e.datum)}`;const t=this.getX(e.datum),n=this.getY(e.datum);if(null!=t&&null!=n)return`p:${t}:${n}`}return"p:"+t;case"rect":return`r:${e.group||""}:${null!==(i=null!==(o=null===(n=e.datum)||void 0===n?void 0:n.binStart)&&void 0!==o?o:null===(r=e.datum)||void 0===r?void 0:r.category)&&void 0!==i?i:t}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+t:"c:"+this.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}startTransition(){var e,t,n,o,r,i,s,a,l,c,u,h,d,g,p,y,f,m,b,v,x,k,w,A,S,O;if(!this.config.transition||0===this.prevPositionMap.size&&0===this.prevPathMap.size)return;const M=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let j=!1;const E=new Set,C=new Set;for(let e=0;this.scene.length>e;e++){const f=this.scene[e],m=this.getNodeIdentity(f,e);if(!m)continue;if(f._transitionKey=m,"line"===f.type||"area"===f.type){const e=this.prevPathMap.get(m);if(e){if(C.add(m),"line"===f.type&&e.path&&e.path.length===f.path.length){f._targetPath=f.path.map(e=>[e[0],e[1]]),f._prevPath=e.path;for(let t=0;f.path.length>t;t++)f.path[t]=[e.path[t][0],e.path[t][1]];j=!0}else if("area"===f.type&&e.topPath&&e.bottomPath&&e.topPath.length===f.topPath.length&&e.bottomPath.length===f.bottomPath.length){f._targetTopPath=f.topPath.map(e=>[e[0],e[1]]),f._targetBottomPath=f.bottomPath.map(e=>[e[0],e[1]]),f._prevTopPath=e.topPath,f._prevBottomPath=e.bottomPath;for(let t=0;f.topPath.length>t;t++)f.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;f.bottomPath.length>t;t++)f.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];j=!0}f._targetOpacity=null!==(t=f.style.opacity)&&void 0!==t?t:1}else f._targetOpacity=null!==(n=f.style.opacity)&&void 0!==n?n:1,f.style=Object.assign(Object.assign({},f.style),{opacity:0}),j=!0;continue}const b=this.prevPositionMap.get(m);if("point"===f.type)if(b){E.add(m);const e={x:f.x,y:f.y,r:f.r};f._targetOpacity=null!==(o=f.style.opacity)&&void 0!==o?o:1,b.x===e.x&&b.y===e.y||(f._targetX=e.x,f._targetY=e.y,f._targetR=e.r,f.x=b.x,f.y=b.y,f.r=null!==(r=b.r)&&void 0!==r?r:f.r,j=!0)}else f._targetOpacity=null!==(i=f.style.opacity)&&void 0!==i?i:1,f.style=Object.assign(Object.assign({},f.style),{opacity:0}),j=!0;else if("rect"===f.type)if(b){E.add(m);const e={x:f.x,y:f.y,w:f.w,h:f.h};f._targetOpacity=null!==(s=f.style.opacity)&&void 0!==s?s:1,b.x===e.x&&b.y===e.y&&b.w===e.w&&b.h===e.h||(f._targetX=e.x,f._targetY=e.y,f._targetW=e.w,f._targetH=e.h,f.x=b.x,f.y=b.y,f.w=null!==(a=b.w)&&void 0!==a?a:f.w,f.h=null!==(l=b.h)&&void 0!==l?l:f.h,j=!0)}else f._targetOpacity=null!==(c=f.style.opacity)&&void 0!==c?c:1,f.style=Object.assign(Object.assign({},f.style),{opacity:0}),j=!0;else if("heatcell"===f.type)if(b){E.add(m);const e={x:f.x,y:f.y,w:f.w,h:f.h};f._targetOpacity=null!==(h=null===(u=f.style)||void 0===u?void 0:u.opacity)&&void 0!==h?h:1,b.x===e.x&&b.y===e.y||(f._targetX=e.x,f._targetY=e.y,f._targetW=e.w,f._targetH=e.h,f.x=b.x,f.y=b.y,f.w=null!==(d=b.w)&&void 0!==d?d:f.w,f.h=null!==(g=b.h)&&void 0!==g?g:f.h,j=!0)}else f._targetOpacity=null!==(y=null===(p=f.style)||void 0===p?void 0:p.opacity)&&void 0!==y?y:1,f.style=Object.assign(Object.assign({},f.style||{}),{opacity:0}),j=!0}for(const[e,t]of this.prevPathMap)if(!C.has(e))if(e.startsWith("l:")&&t.path){const n={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(f=t.opacity)&&void 0!==f?f:1},_targetOpacity:0,_transitionKey:e,datum:null};this.exitNodes.push(n),j=!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),j=!0}for(const[e,t]of this.prevPositionMap)if(!E.has(e)){if(e.startsWith("p:")){const n={type:"point",x:t.x,y:t.y,r:null!==(b=t.r)&&void 0!==b?b:3,style:{opacity:null!==(v=t.opacity)&&void 0!==v?v:1},datum:null,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}else if(e.startsWith("r:")){const n={type:"rect",x:t.x,y:t.y,w:null!==(x=t.w)&&void 0!==x?x:0,h:null!==(k=t.h)&&void 0!==k?k:0,style:{opacity:null!==(w=t.opacity)&&void 0!==w?w:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}else if(e.startsWith("h:")){const n={type:"heatcell",x:t.x,y:t.y,w:null!==(A=t.w)&&void 0!==A?A:0,h:null!==(S=t.h)&&void 0!==S?S:0,fill:"#999",datum:null,style:{opacity:null!==(O=t.opacity)&&void 0!==O?O:1},_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}j=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),j&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:M})}advanceTransition(e){var t,n,o,r,i,s;if(!this.activeTransition)return!1;const a=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,this.activeTransition),l=function(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}(a,"linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?"linear":"ease-out-cubic");for(const e of this.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const o=t?this.prevPositionMap.get(t):void 0,r=o?null!==(n=o.opacity)&&void 0!==n?n:1:0;e.style.opacity=N(r,e._targetOpacity,l)}if(void 0===e._targetX)continue;if(!t)continue;const o=this.prevPositionMap.get(t);if(!o)continue;e.x=N(o.x,e._targetX,l),e.y=N(o.y,e._targetY,l),void 0!==e._targetR&&void 0!==o.r&&(e.r=N(o.r,e._targetR,l))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?this.prevPositionMap.get(t):void 0,r=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;e.style.opacity=N(r,e._targetOpacity,l)}if(void 0===e._targetX)continue;if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=N(n.x,e._targetX,l),e.y=N(n.y,e._targetY,l),void 0!==n.w&&(e.w=N(n.w,e._targetW,l)),void 0!==n.h&&(e.h=N(n.h,e._targetH,l))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?this.prevPositionMap.get(t):void 0,o=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:N(o,e._targetOpacity,l)})}if(void 0===e._targetX)continue;if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=N(n.x,e._targetX,l),e.y=N(n.y,e._targetY,l),void 0!==n.w&&(e.w=N(n.w,e._targetW,l)),void 0!==n.h&&(e.h=N(n.h,e._targetH,l))}else if("line"===e.type){if(void 0!==e._targetOpacity){const t=void 0===e._prevPath&&e._targetOpacity>0?0:null!==(i=e.style.opacity)&&void 0!==i?i:1;e.style=Object.assign(Object.assign({},e.style),{opacity:N(t,e._targetOpacity,l)})}const t=e._prevPath,n=e._targetPath;if(t&&n&&t.length===e.path.length)for(let o=0;e.path.length>o;o++)e.path[o][0]=N(t[o][0],n[o][0],l),e.path[o][1]=N(t[o][1],n[o][1],l)}else if("area"===e.type){if(void 0!==e._targetOpacity){const t=void 0===e._prevTopPath&&e._targetOpacity>0?0:null!==(s=e.style.opacity)&&void 0!==s?s:1;e.style=Object.assign(Object.assign({},e.style),{opacity:N(t,e._targetOpacity,l)})}const t=e._prevTopPath,n=e._prevBottomPath,o=e._targetTopPath,r=e._targetBottomPath;if(t&&o&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=N(t[n][0],o[n][0],l),e.topPath[n][1]=N(t[n][1],o[n][1],l);if(n&&r&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=N(n[t][0],r[t][0],l),e.bottomPath[t][1]=N(n[t][1],r[t][1],l)}}if(a>=1){for(const e of this.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style=Object.assign(Object.assign({},"line"===e.type||"area"===e.type?e.style:e.style||{}),{opacity:0===t?0:t}),e._targetOpacity=void 0}if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("line"===e.type){const t=e._targetPath;if(t)for(let n=0;e.path.length>n;n++)e.path[n]=t[n];e._prevPath=void 0,e._targetPath=void 0}else if("area"===e.type){const t=e._targetTopPath,n=e._targetBottomPath;if(t)for(let n=0;e.topPath.length>n;n++)e.topPath[n]=t[n];if(n)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=n[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0}}if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const n of e){const e=this.getGroup(n);t.has(e)||t.set(e,[]),t.get(e).push(n)}return Array.from(t.entries()).map(([e,t])=>({key:e,data:t}))}resolveColorMap(e){const t=new Set;for(const n of e){const e=this.getColor(n);e&&t.add(e)}const n=Array.from(t).sort(),o=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===o)return this._colorMapCache.map;const r=Array.isArray(this.config.colorScheme)?this.config.colorScheme:C,i=new Map;for(let e=0;n.length>e;e++)i.set(n[e],r[e%r.length]);return this._colorMapCache={key:o,map:i},i}resolveLineStyle(e,t){const n=this.config.lineStyle;if("function"==typeof n){const o=n(t||{},e);if(o&&!o.stroke&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},o),{stroke:t})}return o}return n&&"object"==typeof n?{stroke:n.stroke||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var n;if(this.config.areaStyle){const n=this.config.areaStyle(t||{});if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}const o=this.config.lineStyle;if("function"==typeof o){const n=o(t||{},e);if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}return o&&"object"==typeof o?{fill:o.fill||o.stroke||"#4e79a7",fillOpacity:null!==(n=o.fillOpacity)&&void 0!==n?n:.7,stroke:o.stroke||"#4e79a7",strokeWidth:o.strokeWidth||2}:{fill:"#4e79a7",fillOpacity:.7,stroke:"#4e79a7",strokeWidth:2}}resolveGroupColor(e){if(this._colorMapCache){const t=this._colorMapCache.map.get(e);if(t)return t}const t=this._groupColorMap.get(e);if(t)return t;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme: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){var t,n,o,r;const i=Object.assign({},this.config);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);let s=!1;Object.assign(this.config,e);const a="chartType"in e&&e.chartType!==i.chartType||"runtimeMode"in e&&e.runtimeMode!==i.runtimeMode;if(a||void 0!==e.xAccessor||void 0!==e.yAccessor||void 0!==e.timeAccessor||void 0!==e.valueAccessor){const l=a||!A(null!==(t=e.xAccessor)&&void 0!==t?t:e.timeAccessor,null!==(n=i.xAccessor)&&void 0!==n?n:i.timeAccessor),c=a||!A(null!==(o=e.yAccessor)&&void 0!==o?o:e.valueAccessor,null!==(r=i.yAccessor)&&void 0!==r?r:i.valueAccessor);(l||c)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=S(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=S(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=S(this.config.xAccessor,"x"),this.getY=S(this.config.yAccessor,"y")),s=!0)}if("groupAccessor"in e&&!A(e.groupAccessor,i.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?M(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in e&&!A(e.categoryAccessor,i.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?M(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in e&&!A(e.sizeAccessor,i.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?S(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in e&&!A(e.colorAccessor,i.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?M(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in e&&!A(e.y0Accessor,i.y0Accessor)&&(this.getY0=this.config.y0Accessor?S(this.config.y0Accessor,"y0"):void 0,s=!0),"pointIdAccessor"in e&&!A(e.pointIdAccessor,i.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?M(this.config.pointIdAccessor):void 0,s=!0),!s){const t=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const n of t)if(e[n]!==i[n]){s=!0;break}}s&&(this.needsFullRebuild=!0)}}function z(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function $(e,t,n){const o=t-e.x,r=n-e.y,i=Math.sqrt(o*o+r*r);return i>e.r+5?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:i}}function F(e,t,n){var o,r,i,s;if(0===e.path.length)return null;const a=G(e.path,t);if(0>a)return null;const[l,c]=e.path[a];let u;if(e.path.length>1){let o=1/0;const r=Math.max(0,a-1),i=Math.min(e.path.length-2,a);for(let s=r;i>=s;s++){const[r,i]=e.path[s],[a,l]=e.path[s+1],c=I(t,n,r,i,a,l);o>c&&(o=c)}u=o}else{const e=t-l,o=n-c;u=Math.sqrt(e*e+o*o)}const h=null!==(s=null!==(r=null===(o=e.style)||void 0===o?void 0:o.strokeWidth)&&void 0!==r?r:null===(i=e.style)||void 0===i?void 0:i.lineWidth)&&void 0!==s?s:1;return u>Math.max(5,h/2+2)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[a]?e.datum[a]:e.datum,x:l,y:c,distance:u}}function I(e,t,n,o,r,i){const s=r-n,a=i-o,l=s*s+a*a;if(0===l)return Math.sqrt(Math.pow(e-n,2)+Math.pow(t-o,2));let c=((e-n)*s+(t-o)*a)/l;c=Math.max(0,Math.min(1,c));const u=o+c*a;return Math.sqrt(Math.pow(e-(n+c*s),2)+Math.pow(t-u,2))}function W(e,t,n){const o=z(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function D(e,t,n){const o=z(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function T(e,t,n){const o=e.bodyWidth/2,r=Math.min(e.openY,e.closeY);if(!(e.x-o-3>t||t>e.x+o+3||e.highY-3>n||n>e.lowY+3)){const o=r+Math.max(Math.max(e.openY,e.closeY)-r,1)/2,i=t-e.x,s=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(i*i+s*s)}}return null}function R(e,t,n){if(0===e.topPath.length)return null;const o=G(e.topPath,t);if(0>o)return null;const[r,i]=e.topPath[o],s=t-r,a=n-i,l=Math.sqrt(s*s+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:r,y:i,distance:l}}function G(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const r=n+o>>1;t>e[r][0]?n=r+1:o=r}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}H.QUADTREE_THRESHOLD=500;const q={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 r;return r="function"==typeof n?n(e):(0,q[n])(o(e,t)),r}function X(){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 V(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function U({config:e,orientation:t="vertical",width:n=100}){const{colorFn:o,domain:r,label:i,format:s}=e,a=s||(e=>Math.round(100*e)/100+""),l="grad-legend-"+d.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),s=Math.max(0,(n-t)/2),c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(d.createElement("stop",{key:e,offset:100*t+"%",stopColor:o(r[0]+t*(r[1]-r[0]))}))}return d.createElement("g",{"aria-label":i||"Gradient legend"},d.createElement("defs",null,d.createElement("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},c)),i&&d.createElement("text",{x:s+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),d.createElement("rect",{x:s,y:0,width:t,height:e,fill:`url(#${l})`,rx:2}),d.createElement("text",{x:s,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[0])),d.createElement("text",{x:s+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[1])))}const c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(d.createElement("stop",{key:e,offset:100*t+"%",stopColor:o(r[1]-t*(r[1]-r[0]))}))}return d.createElement("g",{"aria-label":i||"Gradient legend"},i&&d.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),d.createElement("defs",null,d.createElement("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},c)),d.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${l})`,rx:2}),d.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[1])),d.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[0])))}function Q(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,legendInteraction:s,title:a="Legend",width:l=100,height:c=20,orientation:u="vertical"}=e,[h,g]=d.useState(0),[p,y]=d.useState(0),f=d.useCallback((e,t)=>{g(e),y(t)},[]),m="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:l,legendInteraction:c})=>{let u=24;const h=[];return e.forEach((e,g)=>{u+=5,h.push(d.createElement("line",{key:"legend-top-line legend-symbol-"+g,stroke:"gray",x1:0,y1:u,x2:t,y2:u})),u+=8,e.label&&(u+=16,h.push(d.createElement("text",{key:"legend-text-"+g,y:u,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label)),u+=8),h.push(d.createElement("g",{key:"legend-group-"+g,className:"legend-item",transform:`translate(0,${u})`},((e,t,n,o,r,i,s,a,l,c)=>{const{type:u="fill",styleFn:h,items:g}=e,p=[];let y=0;const f=!(!t&&!n),m="isolate"===c||void 0===c&&null!=r;return g.forEach((e,c)=>{const b=Y(e,c,u,h),v=V(e,o,r),x=r&&r.size>0&&r.has(e.label);p.push(d.createElement("g",{key:"legend-item-"+c,transform:`translate(0,${y})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:f?a===i&&c===s?0:-1:void 0,role:f?"option":void 0,"aria-selected":f&&m?x||!1:void 0,"aria-current":f&&!m&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:f?n=>{var o;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(c+("ArrowDown"===n.key?1:-1)+g.length)%g.length;l(a,e);const t=null===(o=n.currentTarget.parentElement)||void 0===o?void 0:o.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:f?t=>{l(a,c),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:f?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:f?"pointer":"default",opacity:v,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},f&&d.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),b,x&&d.createElement(X,null),d.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),y+=22}),p})(e,n,o,r,i,s,a,g,l,c))),u+=22*e.items.length+8}),h})({legendGroups:t||[],width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:h,focusedItemIndex:p,onFocusedIndexChange:f,legendInteraction:s}):(({legendGroups:e,height:t,width:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u})=>{let h=0;const g=[];e.forEach((e,t)=>{let n=0;e.label&&(n+=16);const p=((e,t,n,o,r,i,s,a,l,c)=>{const{type:u="fill",styleFn:h,items:g}=e,p=[];let y=0;const f=!(!t&&!n),m="isolate"===c||void 0===c&&null!=r;return g.forEach((e,c)=>{const b=Y(e,c,u,h),v=V(e,o,r),x=r&&r.size>0&&r.has(e.label);p.push(d.createElement("g",{key:"legend-item-"+c,transform:`translate(${y},0)`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:f?a===i&&c===s?0:-1:void 0,role:f?"option":void 0,"aria-selected":f&&m?x||!1:void 0,"aria-current":f&&!m&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:f?n=>{var o;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(c+("ArrowRight"===n.key?1:-1)+g.length)%g.length;l(a,e);const t=null===(o=n.currentTarget.parentElement)||void 0===o?void 0:o.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:f?t=>{l(a,c),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:f?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:f?"pointer":"default",opacity:v,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},f&&d.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),b,x&&d.createElement(X,null),d.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),y+=26+7*e.label.length}),{items:p,offset:y}})(e,o,r,i,s,a,l,t,c,u);n+=p.offset+5,g.push(Object.assign(Object.assign({label:e.label},p),{offset:n})),h+=n+12});let p=Math.max(0,(n-h)/2);const y=[];return g.forEach((n,o)=>{const r=e[o];r.label&&(y.push(d.createElement("text",{key:"legend-text-"+o,transform:`translate(${p},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},r.label)),p+=16),y.push(d.createElement("g",{key:"legend-group-"+o,className:"legend-item",transform:`translate(${p},0)`},n.items)),p+=n.offset+5,e[o+1]&&y.push(d.createElement("line",{key:"legend-top-line legend-symbol-"+o,stroke:"gray",x1:p,y1:-8,x2:p,y2:t+0+8})),p+=12}),d.createElement("g",null,y)})({legendGroups:t||[],title:a,height:c,width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:h,focusedItemIndex:p,onFocusedIndexChange:f,legendInteraction:s}),b=!(!n&&!o);return d.createElement("g",{role:b?"listbox":void 0,"aria-multiselectable":!(!b||"isolate"!==s&&(void 0!==s||null==i))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},void 0!==a&&""!==a&&"vertical"===u&&d.createElement("text",{className:"legend-title",y:16,x:l/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},a),m)}function K(e){return"string"==typeof e?{type:e}:e}function Z({orient:t,config:n,values:o,scale:r,size:i,length:a}){const l=function(e){var t,n,o,r,i;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(n=e.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(o=e.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(r=e.stroke)&&void 0!==r?r:"none",strokeWidth:null!==(i=e.strokeWidth)&&void 0!==i?i:1}}(n),c="top"===t||"bottom"===t,u=e.useMemo(()=>{if(0===o.length)return null;const e=r.domain(),n=i-8;if("boxplot"===l.type){const e=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],r=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],s=i-o;return{q1:o,median:r,q3:i,whiskerLow:Math.max(t[0],o-1.5*s),whiskerHigh:Math.min(t[n-1],i+1.5*s)}}(o);if(!e)return null;const{q1:i,median:s,q3:a,whiskerLow:u,whiskerHigh:h}=e,g=Math.min(.5*n,20),p=(n-g)/2+4;if(c){const e=r(i),n=r(a),o=r(s),c=r(u),y=r(h),f="top"===t?-1:1,m=0;return d.createElement("g",{"data-testid":"marginal-boxplot-"+t},d.createElement("line",{x1:c,y1:m+f*(p+g/2),x2:y,y2:m+f*(p+g/2),stroke:l.fill,strokeWidth:l.strokeWidth}),d.createElement("line",{x1:c,y1:m+f*p,x2:c,y2:m+f*(p+g),stroke:l.fill,strokeWidth:l.strokeWidth}),d.createElement("line",{x1:y,y1:m+f*p,x2:y,y2:m+f*(p+g),stroke:l.fill,strokeWidth:l.strokeWidth}),d.createElement("rect",{x:Math.min(e,n),y:"top"===t?m-p-g:m+p,width:Math.abs(n-e),height:g,fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),d.createElement("line",{x1:o,y1:"top"===t?m-p-g:m+p,x2:o,y2:"top"===t?m-p:m+p+g,stroke:l.fill,strokeWidth:2}))}{const e=r(i),n=r(a),o=r(s),c=r(u),y=r(h),f="left"===t?-1:1,m=0;return d.createElement("g",{"data-testid":"marginal-boxplot-"+t},d.createElement("line",{x1:m+f*(p+g/2),y1:c,x2:m+f*(p+g/2),y2:y,stroke:l.fill,strokeWidth:l.strokeWidth}),d.createElement("line",{x1:m+f*p,y1:c,x2:m+f*(p+g),y2:c,stroke:l.fill,strokeWidth:l.strokeWidth}),d.createElement("line",{x1:m+f*p,y1:y,x2:m+f*(p+g),y2:y,stroke:l.fill,strokeWidth:l.strokeWidth}),d.createElement("rect",{x:"left"===t?m-p-g:m+p,y:Math.min(e,n),width:g,height:Math.abs(n-e),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),d.createElement("line",{x1:"left"===t?m-p-g:m+p,y1:o,x2:"left"===t?m-p:m+p+g,y2:o,stroke:l.fill,strokeWidth:2}))}}const u=s.bin().domain(e).thresholds(l.bins)(o);if(0===u.length)return null;const h=Math.max(...u.map(e=>e.length));if(0===h)return null;if("histogram"===l.type)return d.createElement("g",{"data-testid":"marginal-histogram-"+t},u.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const i=e.length/h*n;if(c){const n=r(e.x0),s=r(e.x1)-r(e.x0);return d.createElement("rect",{key:o,x:n,y:"top"===t?-4-i:4,width:Math.max(s,.5),height:i,fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}{const n=r(e.x0),s=r(e.x1)-r(e.x0);return d.createElement("rect",{key:o,x:"left"===t?-4-i:4,y:Math.min(n,n+s),width:i,height:Math.abs(s),fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}}));if("violin"===l.type){const e=n/2+4,o=[];for(const i of u){if(null==i.x0||null==i.x1)continue;const s=i.length/h*(n/2),a=r((i.x0+i.x1)/2);o.push(c?`${a},${"top"===t?-(e-s):e-s}`:`${"left"===t?-(e-s):e-s},${a}`)}for(let i=u.length-1;i>=0;i--){const s=u[i];if(null==s.x0||null==s.x1)continue;const a=s.length/h*(n/2),l=r((s.x0+s.x1)/2);o.push(c?`${l},${"top"===t?-(e+a):e+a}`:`${"left"===t?-(e+a):e+a},${l}`)}return d.createElement("g",{"data-testid":"marginal-violin-"+t},d.createElement("polygon",{points:o.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}if("ridgeline"===l.type){const e=[];if(c){const o=0,i=null!=u[0].x0?r(u[0].x0):0;e.push(`M${i},${o}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const i=o.length/h*n,s=r((o.x0+o.x1)/2);e.push(`L${s},${"top"===t?-i-4:i+4}`)}const s=null!=u[u.length-1].x1?r(u[u.length-1].x1):a;e.push(`L${s},${o}`),e.push("Z")}else{const o=0,i=null!=u[0].x0?r(u[0].x0):0;e.push(`M${o},${i}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const i=o.length/h*n,s=r((o.x0+o.x1)/2);e.push(`L${"left"===t?-i-4:i+4},${s}`)}const s=null!=u[u.length-1].x1?r(u[u.length-1].x1):a;e.push(`L${o},${s}`),e.push("Z")}return d.createElement("g",{"data-testid":"marginal-ridgeline-"+t},d.createElement("path",{d:e.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}return null},[o,r,l,i,a,t,c,4]);return u?d.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},u):null}function J(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=e.split(/\s+/),i=[];let s="";for(const e of r)s&&s.length+1+e.length>o?(i.push(s),s=e):s=s?`${s} ${e}`:e;return s&&i.push(s),i}function ee(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 te(e){const{x:t=0,y:n=0,dx:o,dy:r,nx:i,ny:s,note:a,connector:l,subject:c,type:u,color:h,className:g,disable:p,events:y={},"data-testid":f}=e,m=new Set(Array.isArray(p)?p:[]);let b=o||0,v=r||0;null!=i&&(b=i-t),null!=s&&(v=s-n);const x="string"==typeof u?u:"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 d.createElement("g",Object.assign({className:("annotation "+(g||"")).trim(),transform:`translate(${t},${n})`,"data-testid":f},y),!m.has("connector")&&function(e,t,n,o,r,i){const s=[];let a=0,l=0;if("callout-circle"!==r&&"label"!==r||!(null==i?void 0:i.radius)){if("callout-rect"===r&&i){const n=i.width||0,o=i.height||0;if(n>0||o>0){const r=n/2,i=o/2,s=e-r,c=t-i;if(0!==s||0!==c){const e=Math.abs(s),t=Math.abs(c),u=n/2,h=o/2,d=e*h>t*u?u/e:h/t;a=r+s*d,l=i+c*d}}}else if("bracket"===r&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(a=e/2,l=n):void 0!==t&&(a=n,l=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const o=Math.atan2(t,e);a=Math.cos(o)*n,l=Math.sin(o)*n}}if(Math.sqrt(Math.pow(e-a,2)+Math.pow(t-l,2))>.5&&(s.push(d.createElement("line",{key:"connector-line",x1:a,y1:l,x2:e,y2:t,stroke:o||"currentColor"})),"arrow"===(null==n?void 0:n.end))){const n=10,r=16/180*Math.PI,i=Math.atan2(t-l,e-a);s.push(d.createElement("path",{key:"connector-arrow",d:`M${a},${l}L${a+n*Math.cos(i+r)},${l+n*Math.sin(i+r)}L${a+n*Math.cos(i-r)},${l+n*Math.sin(i-r)}Z`,fill:o||"currentColor",stroke:"none"}))}return d.createElement("g",{className:"annotation-connector"},s)}(b,v,l,h,x,c),!m.has("subject")&&function(e,t,n,o,r){var i;const s=[];switch(e){case"callout-circle":{const e=((null==t?void 0:t.radius)||0)+((null==t?void 0:t.radiusPadding)||0);e>0&&s.push(d.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:n||"currentColor"}));break}case"callout-rect":{const e=(null==t?void 0:t.width)||0,o=(null==t?void 0:t.height)||0;(e>0||o>0)&&s.push(d.createElement("rect",{key:"subject-rect",width:e,height:o,fill:"none",stroke:n||"currentColor"}));break}case"callout-custom":(null==t?void 0:t.custom)&&s.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=o||0,i=r||0;if(void 0!==(null==t?void 0:t.x)){const o=(t.x||0)-e;s.push(d.createElement("line",{key:"threshold-line",x1:o,y1:(t.y1||0)-i,x2:o,y2:(t.y2||0)-i,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==t?void 0:t.y)){const o=(t.y||0)-i;s.push(d.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:o,x2:(t.x2||0)-e,y2:o,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==t?void 0:t.x1)||void 0!==(null==t?void 0:t.x2)?s.push(d.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"currentColor",strokeDasharray:"5,5"})):void 0===(null==t?void 0:t.y1)&&void 0===(null==t?void 0:t.y2)||s.push(d.createElement("line",{key:"threshold-line",x1:0,y1:(t.y1||0)-i,x2:0,y2:(t.y2||0)-i,stroke:n||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(i=null==t?void 0:t.width)&&void 0!==i?i:null==t?void 0:t.height;void 0!==e&&s.push(d.createElement("path",{key:"bracket-path",d:ee((null==t?void 0:t.type)||"curly",e,(null==t?void 0:t.depth)||30,void 0===(null==t?void 0:t.width)),fill:"none",stroke:n||"currentColor"}));break}}return d.createElement("g",{className:"annotation-subject"},s)}(x,c,h,t,n),!m.has("note")&&function(e,t,n,o){if(!e)return d.createElement("g",{className:"annotation-note"});const{label:r,title:i,orientation:s,align:a,wrap:l=120,noWrap:c}=e;if(!r&&!i)return d.createElement("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let h=a;h&&"dynamic"!==h||(h="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let g="start";"topBottom"===u?"right"===h?g="end":"middle"===h&&(g="middle"):g=0>t?"end":"start";const p=16,y=i?c?[i]:J(i,l):[],f=r?c?[r]:J(r,l):[],m="leftRight"===u?"end"===g?-4:4:0;let b=0;const v=[];y.length>0&&(v.push(d.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:o||void 0,textAnchor:g,fontWeight:"bold"},y.map((e,t)=>d.createElement("tspan",{key:t,x:m,dy:0===t?0:p},e)))),b=y.length*p),f.length>0&&v.push(d.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:o||void 0,textAnchor:g,y:b},f.map((e,t)=>d.createElement("tspan",{key:t,x:m,dy:0===t?0:p},e))));let x=null;if((i||r)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(l,120);let t=0,n=e;"end"===g?(t=-e,n=0):"middle"===g&&(t=-e/2,n=e/2),x=d.createElement("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"currentColor"})}else{const e=(y.length+f.length)*p+(f.length>0?p:0);let t=0,n=e;"bottom"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),x=d.createElement("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:o||"currentColor"})}const k=Math.max(0,y.length+f.length-1)*p;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===h?-(k+p+(f.length>0&&y.length>0?2:0))/2+8:"bottom"===h||0>n?-(k+2):18),d.createElement("g",{className:"annotation-note",transform:`translate(${t},${n})`},d.createElement("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0},v),x)}(a,b,v,h))}function ne(e){var t,n;const{noteData:o}=e,{screenCoordinates:r}=o,i="string"==typeof o.type?o.type:"label",s=o.eventListeners||o.events||{};if(o.coordinates&&r){const e=o.nx||r[0][0]+(null!==(t=o.dx)&&void 0!==t?t:0),s=o.ny||r[0][1]+(null!==(n=o.dy)&&void 0!==n?n:0),a=r.map((t,n)=>{const r=Object.assign({},o,{note:0===n?o.note:{label:""},x:t[0],y:t[1],nx:e,ny:s});return d.createElement(te,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},r,{type:i}))});return d.createElement("g",null,a)}const a=o.note||{title:"none",label:o.label};return d.createElement(te,Object.assign({"data-testid":"semiotic-annotation",key:`${a.label}-${a.title}-${o.i}`,events:s},o,{type:i}))}const oe={linear:l.curveLinear,monotoneX:l.curveMonotoneX,monotoneY:l.curveMonotoneY,step:l.curveStep,stepAfter:l.curveStepAfter,stepBefore:l.curveStepBefore,basis:l.curveBasis,cardinal:l.curveCardinal,catmullRom:l.curveCatmullRom};function re(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function ie(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function se(e,t,n){var o,r,i,s;const a=e.anchor||"fixed";if("latest"===a){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const i=n.pointNodes[r];if(i.pointId===e.pointId){const e={x:i.x,y:i.y};return null===(o=n.stickyPositionCache)||void 0===o||o.set(t,e),e}}const i=function(e){var t,n,o,r,i,s;const a=e.data;if(!a||0===a.length)return null;const l=a[a.length-1],c=null!==(n=null===(t=e.scales)||void 0===t?void 0:t.x)&&void 0!==n?n:null===(o=e.scales)||void 0===o?void 0:o.time,u=null!==(i=null===(r=e.scales)||void 0===r?void 0:r.y)&&void 0!==i?i:null===(s=e.scales)||void 0===s?void 0:s.value;if(!c||!u)return null;const h=l[e.xAccessor||"x"],d=l[e.yAccessor||"y"];return null==h||null==d?null:{x:c(h),y:u(d)}}(n);return i&&(null===(r=n.stickyPositionCache)||void 0===r||r.set(t,i)),i}let l=null,c=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(l=t.x,c=t.y)}if(null!=l&&null!=c||(l=re(e,n),c=ie(e,n)),null!=l&&null!=c)return null===(i=n.stickyPositionCache)||void 0===i||i.set(t,{x:l,y:c}),{x:l,y:c};if("sticky"===a){const e=null===(s=n.stickyPositionCache)||void 0===s?void 0:s.get(t);if(e)return e}return null}function ae(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function le(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,r="left"===e?-1:1,i=Math.ceil(t/8);let s="M0,"+o;for(let e=0;i>e;e++){const n=8*(e+1);s+=`L${Math.min(8*e+4,t)},${o+4*r}`,s+=`L${Math.min(n,t)},${o}`}return s}{const o="bottom"===e?0:t,r="bottom"===e?1:-1,i=Math.ceil(n/8);let s=`M${o},0`;for(let e=0;i>e;e++){const t=8*(e+1);s+=`L${o+4*r},${Math.min(8*e+4,n)}`,s+=`L${o},${Math.min(t,n)}`}return s}}function ce(t){const{width:n,height:o,totalWidth:r,totalHeight:i,margin:s,scales:a,showAxes:l,axes:c,showGrid:u,xFormat:h,yFormat:g}=t,p=e.useMemo(()=>{var e;if(!a)return[];const t=null==c?void 0:c.find(e=>"bottom"===e.orient),o=(null==t?void 0:t.tickFormat)||h||ue,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,i=a.x.ticks(Math.min(r,Math.max(2,Math.floor(n/70)))),s=i.map(e=>e.valueOf()),l=i.map((e,t)=>({value:e,pixel:a.x(e),label:o(e,t,s)})),u=l.reduce((e,t)=>Math.max(e,6.5*t.label.length),0);return he(l,Math.max(55,u+8))},[a,c,h,n]),y=e.useMemo(()=>{var e;if(!a)return[];const t=null==c?void 0:c.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||g||ue,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return he(a.y.ticks(Math.min(r,Math.max(2,Math.floor(o/30)))).map(e=>({value:e,pixel:a.y(e),label:n(e)})),22)},[a,c,g,o]),f=u&&a,m=l&&a;if(!f&&!m)return null;const b=null==c?void 0:c.find(e=>"bottom"===e.orient),v=null==c?void 0:c.find(e=>"left"===e.orient),x=m&&(!b||!1!==b.baseline),k=m&&(!v||!1!==v.baseline),w=(null==b?void 0:b.jaggedBase)||!1,A=(null==v?void 0:v.jaggedBase)||!1,S="var(--semiotic-border, #ccc)";return d.createElement("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},d.createElement("g",{transform:`translate(${s.left},${s.top})`},f&&d.createElement("g",{className:"stream-grid"},p.map((e,t)=>d.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),y.map((e,t)=>d.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:n,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),x&&!w&&d.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:S,strokeWidth:1}),w&&d.createElement("path",{d:le("bottom",n,o),fill:"none",stroke:S,strokeWidth:1}),k&&!A&&d.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:S,strokeWidth:1}),A&&d.createElement("path",{d:le("left",n,o),fill:"none",stroke:S,strokeWidth:1})))}function ue(e,t,n){return Math.round(100*e)/100+""}function he(e,t){if(2>=e.length)return e;const n=[e[0]];for(let o=1;e.length-1>o;o++)t>Math.abs(e[o].pixel-n[n.length-1].pixel)||n.push(e[o]);const o=e[e.length-1];return t>Math.abs(o.pixel-n[n.length-1].pixel)?n[n.length-1]=o:n.push(o),n}function de(e,t){return e instanceof Date&&(!(t&&t instanceof Date)||e.getFullYear()!==t.getFullYear()||e.getMonth()!==t.getMonth()||e.getDate()!==t.getDate())}function ge(t){var n,o;const{width:r,height:i,totalWidth:s,totalHeight:c,margin:u,scales:h,showAxes:p,axes:y,xLabel:f,yLabel:m,yLabelRight:b,xFormat:v,yFormat:x,showGrid:k,title:w,legend:A,legendHoverBehavior:S,legendClickBehavior:O,legendHighlightedCategory:M,legendIsolatedCategories:j,legendPosition:E="right",foregroundGraphics:C,marginalGraphics:P,xValues:_,yValues:L,annotations:B,svgAnnotationRules:N,xAccessor:H,yAccessor:z,annotationData:$,pointNodes:F,curve:I,underlayRendered:W,children:D}=t,T=e.useMemo(()=>{var e;if(!p||!h)return[];const t=null==y?void 0:y.find(e=>"bottom"===e.orient),n=(null==t?void 0:t.tickFormat)||v||ue,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,i=h.x.ticks(Math.min(o,Math.max(2,Math.floor(r/70)))),s=i.map(e=>e.valueOf()),a=i.map((e,t)=>({value:e,pixel:h.x(e),label:n(e,t,s)})),l=a.reduce((e,t)=>Math.max(e,6.5*t.label.length),0);return he(a,Math.max(55,l+8))},[p,h,y,v,r]),R=e.useMemo(()=>{var e;if(!p||!h)return[];const t=null==y?void 0:y.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||x||ue,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return he(h.y.ticks(Math.min(o,Math.max(2,Math.floor(i/30)))).map(e=>({value:e,pixel:h.y(e),label:n(e)})),22)},[p,h,y,x,i]),G=e.useMemo(()=>{var e;if(!p||!h)return[];const t=null==y?void 0:y.find(e=>"right"===e.orient);if(!t)return[];const n=t.tickFormat||x||ue,o=null!==(e=t.ticks)&&void 0!==e?e:5;return he(h.y.ticks(Math.min(o,Math.max(2,Math.floor(i/30)))).map(e=>({value:e,pixel:h.y(e),label:n(e)})),22)},[p,h,y,x,i]),q=e.useRef(new Map),Y=e.useRef(null!==(n=null==B?void 0:B.length)&&void 0!==n?n:0),X=null!==(o=null==B?void 0:B.length)&&void 0!==o?o:0;Y.current!==X&&(Y.current=X,q.current=new Map);const V=e.useMemo(()=>{if(!B||0===B.length)return null;const e=function(e,t,n){var o,r,i,s,c,u,h,p,y,f,m,b,v,x,k,w,A,S,O,M,j,E,C,P,_,L,B,N,H,z,$,F,I,W,D,T,R,G,q,Y,X,V,U,Q;switch(e.type){case"label":{const o=se(e,t,n);if(!o)return null;const{x:r,y:i}=o;return ae(r,i,n)?d.createElement(ne,{key:"ann-"+t,noteData:{x:r,y:i,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"label",connector:e.connector||{end:"arrow"},color:e.color}}):null}case"callout":{const o=se(e,t,n);if(!o)return null;const{x:r,y:i}=o;return ae(r,i,n)?d.createElement(ne,{key:"ann-"+t,noteData:{x:r,y:i,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"callout-circle",subject:{radius:e.radius||12},connector:e.connector||{end:"arrow"},color:e.color}}):null}case"x-threshold":{const o=re(e,n);if(null==o)return null;const r=e.color||"#f97316";return d.createElement("g",{key:"ann-"+t},d.createElement("line",{x1:o,y1:0,x2:o,y2:n.height||0,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&d.createElement("text",{x:o+4,y:12,fill:r,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const o=ie(e,n);if(null==o)return null;const r=e.color||"#f97316";return d.createElement("g",{key:"ann-"+t},d.createElement("line",{x1:0,y1:o,x2:n.width||0,y2:o,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&d.createElement("text",{x:(n.width||0)-4,y:o-4,textAnchor:"end",fill:r,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const o=(e.coordinates||[]).map(e=>({x:re(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 r=a.packEnclose(o),i=e.padding||10;return d.createElement("g",{key:"ann-"+t},d.createElement("circle",{cx:r.x,cy:r.y,r:r.r+i,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&d.createElement("text",{x:r.x,y:r.y-r.r-i-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12},e.label))}case"rect-enclose":{const o=(e.coordinates||[]).map(e=>({x:re(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 r=e.padding||10,i=o.map(e=>e.x),s=o.map(e=>e.y),a=Math.min(...i)-r,l=Math.max(...i)+r,c=Math.min(...s)-r,u=Math.max(...s)+r;return d.createElement("g",{key:"ann-"+t},d.createElement("rect",{x:a,y:c,width:l-a,height:u-c,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&d.createElement("text",{x:(a+l)/2,y:c-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12},e.label))}case"highlight":{const o=n.data||[],r="function"==typeof e.filter?o.filter(e.filter):e.field&&null!=e.value?o.filter(t=>t[e.field]===e.value):[],i={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return d.createElement("g",{key:"ann-"+t},r.map((t,o)=>{const r=re(t,n),s=ie(t,n);if(null==r||null==s)return null;const a="function"==typeof e.r?e.r(t):e.r||6,l="function"==typeof e.style?e.style(t):e.style||i;return d.createElement("circle",Object.assign({key:"hl-"+o,cx:r,cy:s,r:a},l))}))}case"bracket":{const o=re(e,n),r=ie(e,n);return d.createElement(ne,{key:"ann-"+t,noteData:{x:null!=o?o:0,y:null!=r?r:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}})}case"trend":{const a=n.data||[];if(2>a.length)return null;const l=n.xAccessor||"x",p=n.yAccessor||"y",y=a.map(e=>[e[l],e[p]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>y.length)return null;const f=null!==(r=null===(o=n.scales)||void 0===o?void 0:o.x)&&void 0!==r?r:null===(i=n.scales)||void 0===i?void 0:i.time,m=null!==(c=null===(s=n.scales)||void 0===s?void 0:s.y)&&void 0!==c?c:null===(u=n.scales)||void 0===u?void 0:u.value;if(!f||!m)return null;const 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]),r=o.map(e=>e[0]),i=o.map(e=>e[1]),s=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=r[e],o=r.map(e=>Math.abs(e-t)),l=o.slice().sort((e,t)=>e-t)[Math.min(s-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:o[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,h=0,d=0,g=0,p=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,h+=t*r[e],d+=t*i[e],g+=t*r[e]*r[e],p+=t*r[e]*i[e])}if(0===u){a.push([t,i[e]]);continue}const y=u*g-h*h;if(1e-12>Math.abs(y))a.push([t,d/u]);else{const e=(u*p-h*d)/y;a.push([t,(d-e*h)/u+e*t])}}return a}(y,null!==(h=e.bandwidth)&&void 0!==h?h:.3):("polynomial"===b?g.default.polynomial(y,{order:e.order||2}):g.default.linear(y)).points;const x=v.map(([e,t])=>`${f(e)},${m(t)}`).join(" "),k=e.color||"#6366f1";return d.createElement("g",{key:"ann-"+t},d.createElement("polyline",{points:x,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&d.createElement("text",{x:f(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!==(y=null===(p=n.scales)||void 0===p?void 0:p.y)&&void 0!==y?y:null===(f=n.scales)||void 0===f?void 0:f.value,r=null!==(m=null==o?void 0:o(e.y0))&&void 0!==m?m:0,i=null!==(b=null==o?void 0:o(e.y1))&&void 0!==b?b:n.height||0;return d.createElement("g",{key:"ann-"+t},d.createElement("rect",{x:0,y:Math.min(r,i),width:n.width||0,height:Math.abs(i-r),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&d.createElement("text",{x:(n.width||0)-4,y:Math.min(r,i)-4,textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11},e.label))}case"envelope":{const o=n.data||[];if(2>o.length)return null;const r=n.xAccessor||"x",i=null!==(x=null===(v=n.scales)||void 0===v?void 0:v.x)&&void 0!==x?x:null===(k=n.scales)||void 0===k?void 0:k.time,s=null!==(A=null===(w=n.scales)||void 0===w?void 0:w.y)&&void 0!==A?A:null===(S=n.scales)||void 0===S?void 0:S.value;if(!i||!s)return null;const a=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",u=e.filter,h=o.filter(e=>null!=e[a]&&null!=e[c]&&!(u&&!u(e))).sort((e,t)=>e[r]-t[r]);if(2>h.length)return null;const g=oe[n.curve||"linear"]||l.curveLinear,p=l.area().x(e=>i(e[r])).y0(e=>s(e[c])).y1(e=>s(e[a])).curve(g)(h);if(!p)return null;const y=e.fill||"#6366f1";return d.createElement("g",{key:"ann-"+t},d.createElement("path",{d:p,fill:y,fillOpacity:null!==(O=e.fillOpacity)&&void 0!==O?O:.15,stroke:"none"}),e.label&&h.length>0&&d.createElement("text",{x:i(h[h.length-1][r])+4,y:s(h[h.length-1][a])-4,fill:y,fontSize:11},e.label))}case"anomaly-band":{const o=n.data||[];if(2>o.length)return null;const r=n.yAccessor||"y",i=null!==(j=null===(M=n.scales)||void 0===M?void 0:M.x)&&void 0!==j?j:null===(E=n.scales)||void 0===E?void 0:E.time,s=null!==(P=null===(C=n.scales)||void 0===C?void 0:C.y)&&void 0!==P?P:null===(_=n.scales)||void 0===_?void 0:_.value;if(!i||!s)return null;const a=o.map(e=>e[r]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const l=a.reduce((e,t)=>e+t,0)/a.length,c=a.reduce((e,t)=>e+Math.pow(t-l,2),0)/a.length,u=Math.sqrt(c),h=null!==(L=e.threshold)&&void 0!==L?L:2,g=l-h*u,p=!1!==e.showBand,y=e.fill||"#6366f1",f=null!==(B=e.fillOpacity)&&void 0!==B?B:.1,m=e.anomalyColor||"#ef4444",b=null!==(N=e.anomalyRadius)&&void 0!==N?N:6,v=s(l+h*u),x=s(g),k=o.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-l)>h*u});return d.createElement("g",{key:"ann-"+t},p&&d.createElement("rect",{x:0,y:Math.min(v,x),width:n.width||0,height:Math.abs(x-v),fill:y,fillOpacity:f}),k.map((e,t)=>{const o=re(e,n),r=ie(e,n);return null==o||null==r?null:d.createElement("circle",{key:"anomaly-"+t,cx:o,cy:r,r:b,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5})}),e.label&&d.createElement("text",{x:(n.width||0)-4,y:Math.min(v,x)-4,textAnchor:"end",fill:y,fontSize:11},e.label))}case"forecast":{const o=n.data||[];if(3>o.length)return null;const r=n.xAccessor||"x",i=n.yAccessor||"y",s=null!==(z=null===(H=n.scales)||void 0===H?void 0:H.x)&&void 0!==z?z:null===($=n.scales)||void 0===$?void 0:$.time,a=null!==(I=null===(F=n.scales)||void 0===F?void 0:F.y)&&void 0!==I?I:null===(W=n.scales)||void 0===W?void 0:W.value;if(!s||!a)return null;const l=o.map(e=>[e[r],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>l.length)return null;let c;if("polynomial"===(e.method||"linear")){const t=g.default.polynomial(l,{order:e.order||2}).equation;c=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}else{const e=l.length;let t=0,n=0,o=0,r=0;for(const[e,i]of l)t+=e,n+=i,o+=e*e,r+=e*i;const i=e*o-t*t;if(1e-12>Math.abs(i))return null;const s=(e*r-t*n)/i,a=(n-s*t)/e;c=e=>a+s*e}const u=l.length,h=l.map(([e,t])=>t-c(e)).reduce((e,t)=>e+t*t,0),p=Math.sqrt(h/Math.max(u-2,1)),y=l.reduce((e,t)=>e+t[0],0)/u,f=l.reduce((e,t)=>e+Math.pow(t[0]-y,2),0),m=null!==(D=e.confidence)&&void 0!==D?D:.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=l[u-1][0],k=(x-l[0][0])/Math.max(u-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=p*Math.sqrt(1+1/u+(f>0?Math.pow(e-y,2)/f:0))*b;A.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const S=`M${A.map(e=>`${s(e.x)},${a(e.yUpper)}`).join(" L")} L${A.slice().reverse().map(e=>`${s(e.x)},${a(e.yLower)}`).join(" L")} Z`,O=A.map(e=>`${s(e.x)},${a(e.yCenter)}`).join(" "),M=`${s(x)},${a(c(x))}`,j=e.strokeColor||"#6366f1";return d.createElement("g",{key:"ann-"+t},d.createElement("path",{d:S,fill:e.fill||"#6366f1",fillOpacity:null!==(R=e.fillOpacity)&&void 0!==R?R:.15,stroke:"none"}),d.createElement("polyline",{points:`${M} ${O}`,fill:"none",stroke:j,strokeWidth:null!==(G=e.strokeWidth)&&void 0!==G?G:2,strokeDasharray:null!==(q=e.strokeDasharray)&&void 0!==q?q:"6,3"}),e.label&&A.length>0&&d.createElement("text",{x:s(A[A.length-1].x)+4,y:a(A[A.length-1].yCenter)-4,fill:j,fontSize:11},e.label))}case"widget":{let o=null,r=null;if(null!=e.px&&null!=e.py)o=e.px,r=e.py;else{const i=se(e,t,n);if(!i)return null;o=i.x,r=i.y}if(null==o||null==r)return null;if(!ae(o,r,n))return null;const i=null!==(Y=e.dx)&&void 0!==Y?Y:0,s=null!==(X=e.dy)&&void 0!==X?X:0,a=null!==(V=e.width)&&void 0!==V?V:32,l=null!==(U=e.height)&&void 0!==U?U:32,c=null!==(Q=e.content)&&void 0!==Q?Q:d.createElement("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info"},"ℹ️");return d.createElement("foreignObject",{key:"ann-"+t,x:o+i-a/2,y:r+s-l/2,width:a,height:l,style:{overflow:"visible",pointerEvents:"auto"}},d.createElement("div",{style:{width:a,height:l,display:"flex",alignItems:"center",justifyContent:"center"}},c))}case"text":{const o=se(e,t,n);if(!o)return null;const{x:r,y:i}=o;return d.createElement("text",{key:"ann-text-"+t,x:r+(e.dx||0),y:i+(e.dy||0),fill:e.color||"var(--semiotic-text, #333)",fontSize:e.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},e.label)}default:return null}},t={scales:h?{x:h.x,y:h.y,time:h.x,value:h.y}:null,timeAxis:"x",xAccessor:H,yAccessor:z,width:r,height:i,data:$,frameType:"xy",pointNodes:F,curve:I,stickyPositionCache:q.current};return B.map((n,o)=>{if(N){const r=N(n,o,t);return null!=r?r:e(n,o,t)}return e(n,o,t)}).filter(Boolean)},[B,N,r,i,H,z,$,h,F,I]);return p||w||A||C||P||V&&V.length>0||k||D?d.createElement("svg",{role:"img",width:s,height:c,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"}},d.createElement("title",null,"string"==typeof w?w:"XY Chart"),d.createElement("desc",null,"string"==typeof w?w+" — XY data visualization":"XY data visualization"),d.createElement("g",{transform:`translate(${u.left},${u.top})`},k&&h&&!W&&d.createElement("g",{className:"stream-grid"},T.map((e,t)=>d.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),R.map((e,t)=>d.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:r,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),p&&h&&(()=>{const e=null==y?void 0:y.find(e=>"left"===e.orient),t=null==y?void 0:y.find(e=>"bottom"===e.orient),n=!e||!1!==e.baseline,o=(null==e?void 0:e.jaggedBase)||!1,s=(null==t?void 0:t.jaggedBase)||!1,a=null==t?void 0:t.landmarkTicks,l=null==e?void 0:e.landmarkTicks,c="var(--semiotic-border, #ccc)",h="var(--semiotic-text-secondary, var(--semiotic-text, #666))",g="var(--semiotic-text, #333)";return d.createElement("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},!W&&(!t||!1!==t.baseline)&&!s&&d.createElement("line",{x1:0,y1:i,x2:r,y2:i,stroke:c,strokeWidth:1}),!W&&s&&d.createElement("path",{d:le("bottom",r,i),fill:"none",stroke:c,strokeWidth:1}),T.map((e,t)=>{const n=!!a&&("function"==typeof a?a(e.value,t):de(e.value,t>0?T[t-1].value:void 0));return d.createElement("g",{key:"xtick-"+t,transform:`translate(${e.pixel},${i})`},d.createElement("line",{y2:5,stroke:c,strokeWidth:1}),d.createElement("text",{y:18,textAnchor:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:h,style:{userSelect:"none"}},e.label))}),f&&d.createElement("text",{x:r/2,y:i+40,textAnchor:"middle",fontSize:12,fill:g,style:{userSelect:"none"}},f),!W&&n&&!o&&d.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:c,strokeWidth:1}),!W&&o&&d.createElement("path",{d:le("left",r,i),fill:"none",stroke:c,strokeWidth:1}),R.map((e,t)=>{const n=!!l&&("function"==typeof l?l(e.value,t):de(e.value,t>0?R[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))}),(()=>{const t=(null==e?void 0:e.label)||m;return t?d.createElement("text",{x:15-u.left,y:i/2,textAnchor:"middle",fontSize:12,fill:g,transform:`rotate(-90, ${15-u.left}, ${i/2})`,style:{userSelect:"none"}},t):null})(),(()=>{const e=null==y?void 0:y.find(e=>"right"===e.orient);if(!e||0===G.length)return null;const t=e.landmarkTicks,n=e.label||b;return d.createElement(d.Fragment,null,!1!==e.baseline&&d.createElement("line",{x1:r,y1:0,x2:r,y2:i,stroke:c,strokeWidth:1}),G.map((e,n)=>{const o=!!t&&("function"==typeof t?t(e.value,n):de(e.value,n>0?G[n-1].value:void 0));return d.createElement("g",{key:"ytick-r-"+n,transform:`translate(${r},${e.pixel})`},d.createElement("line",{x2:5,stroke:c,strokeWidth:1}),d.createElement("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:h,style:{userSelect:"none"}},e.label))}),n&&d.createElement("text",{x:r+u.right-15,y:i/2,textAnchor:"middle",fontSize:12,fill:g,transform:`rotate(90, ${r+u.right-15}, ${i/2})`,style:{userSelect:"none"}},n))})())})(),V,P&&h&&_&&L&&d.createElement(d.Fragment,null,P.top&&d.createElement("g",{transform:"translate(0, 0)"},d.createElement(Z,{orient:"top",config:K(P.top),values:_,scale:h.x,size:u.top,length:r})),P.bottom&&d.createElement("g",{transform:`translate(0, ${i})`},d.createElement(Z,{orient:"bottom",config:K(P.bottom),values:_,scale:h.x,size:u.bottom,length:r})),P.left&&d.createElement("g",{transform:"translate(0, 0)"},d.createElement(Z,{orient:"left",config:K(P.left),values:L,scale:h.y,size:u.left,length:i})),P.right&&d.createElement("g",{transform:`translate(${r}, 0)`},d.createElement(Z,{orient:"right",config:K(P.right),values:L,scale:h.y,size:u.right,length:i}))),C,D),w&&d.createElement("text",{x:s/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof w?w:null),function(e){const{legend:t,totalWidth:n,totalHeight:o,margin:r,legendPosition:i="right",title:s,legendHoverBehavior:a,legendClickBehavior:l,legendHighlightedCategory:c,legendIsolatedCategories:u,legendInteraction:h}=e;if(!t)return null;const g="top"===i||"bottom"===i;let p,y;return"left"===i?(p=4,y=r.top):"top"===i?(p=0,y=s?32:8):"bottom"===i?(p=0,y=o-r.bottom+50):(p=n-r.right+10,y=r.top),d.createElement("g",{transform:`translate(${p}, ${y})`},"object"==typeof(f=t)&&null!==f&&"gradient"in f?d.createElement(U,{config:t.gradient,orientation:g?"horizontal":"vertical",width:g?n:100}):function(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}(t)?d.createElement(Q,{legendGroups:t.legendGroups,title:"",width:g?n:100,orientation:g?"horizontal":"vertical",customHoverBehavior:a,customClickBehavior:l,highlightedCategory:c,isolatedCategories:u,legendInteraction:h}):t);var f}({legend:A,totalWidth:s,totalHeight:c,margin:u,legendPosition:E,title:w,legendHoverBehavior:S,legendClickBehavior:O,legendHighlightedCategory:M,legendIsolatedCategories:j})):null}function pe(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}const ye="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 me(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e)n[t.type]=(n[t.type]||0)+1;const o=[],r={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks"},i=["point","line","area","rect","heatcell","circle","candlestick"],s=Object.keys(n).sort((e,t)=>{const n=i.indexOf(e),o=i.indexOf(t);return(-1===n?999:n)-(-1===o?999:o)});for(const e of s)o.push(`${n[e]} ${r[e]||e}`);return`${t}, ${o.join(", ")}`}function be({scene:e,chartType:t}){var n,o,r,i;const s=[];for(const t of e){if(s.length>=50)break;"point"===t.type?s.push({label:"Point",values:{x:Math.round(100*t.x)/100+"",y:Math.round(100*t.y)/100+""}}):"rect"===t.type?s.push({label:"Bar",values:{category:(null===(n=t.datum)||void 0===n?void 0:n.category)||"",value:Math.round(100*(null!==(r=null===(o=t.datum)||void 0===o?void 0:o.value)&&void 0!==r?r:0))/100+""}}):"heatcell"===t.type&&s.push({label:"Cell",values:{x:Math.round(100*t.x)/100+"",y:Math.round(100*t.y)/100+"",value:Math.round(100*(null!==(i=t.value)&&void 0!==i?i:0))/100+""}})}if(0===s.length)return null;const a=new Set;for(const e of s)for(const t of Object.keys(e.values))a.add(t);const l=Array.from(a);return d.createElement("table",{style:fe,role:"table","aria-label":"Data table for "+t},d.createElement("thead",null,d.createElement("tr",null,l.map(e=>d.createElement("th",{key:e},e)))),d.createElement("tbody",null,s.map((e,t)=>d.createElement("tr",{key:t},l.map(t=>{var n;return d.createElement("td",{key:t},null!==(n=e.values[t])&&void 0!==n?n:"")}))),e.length>50&&d.createElement("tr",null,d.createElement("td",{colSpan:l.length},"...and ",e.length-50," more items"))))}function ve({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 xe(t){const n=e.createContext(null),o=ke(t);return[function({children:o}){const r=e.useMemo(()=>ke(t),[]);return d.createElement(n.Provider,{value:r,children:o})},t=>{var r;const i=null!==(r=e.useContext(n))&&void 0!==r?r:o,s=e.useRef(t);s.current=t;const a=e.useCallback(()=>s.current(i.getState()),[i]),l=e.useCallback(()=>s.current(i.getState()),[i]);return e.useSyncExternalStore(i.subscribe,a,l)}]}function 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)}}}const we={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}},Ae={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}},Se={mode:"light",colors:{primary:"#0000cc",categorical:["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],sequential:"blues",diverging:"RdBu",background:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"},[Oe,Me]=xe(e=>({theme:we,setTheme(t){e(e=>{if("light"===t)return{theme:we};if("dark"===t)return{theme:Ae};if("high-contrast"===t)return{theme:Se};if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?Ae:we;return{theme:Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{})})}}return{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 je(e,t,n,o){const r=e.getContext("2d");if(!r)return null;const i=t[0]*o,s=t[1]*o,a=t[0]+"px",l=t[1]+"px";return e.style.width!==a&&(e.style.width=a),e.style.height!==l&&(e.style.height=l),e.width===i&&e.height===s||(e.width=i,e.height=s),r.setTransform(o,0,0,o,0,0),r.translate(n.left,n.top),r}function Ee(e){switch(e){case"monotoneX":return l.curveMonotoneX;case"monotoneY":return l.curveMonotoneY;case"cardinal":return l.curveCardinal;case"catmullRom":return l.curveCatmullRom;case"step":return l.curveStep;case"stepBefore":return l.curveStepBefore;case"stepAfter":return l.curveStepAfter;case"basis":return l.curveBasis;case"natural":return l.curveNatural;default:return null}}function Ce(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 Pe(e,t,n,o,r,i){if(2>t.length)return;const s=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],o=t[e][1]-t[e-1][1];s.push(s[e-1]+Math.sqrt(n*n+o*o))}const a=s[s.length-1];if(0===a)return;const l=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=o,e.lineCap=i;for(let n=0;t.length-1>n;n++){const o=(s[n]+s[n+1])/2;let i=r;l>o&&(i*=o/l),l>a-o&&(i*=(a-o)/l),e.globalAlpha=Math.max(0,i),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}function _e(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Le(e,t,n=.3){_e(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 Be(e,t,n=.6){var o,r,i,s,a;if(!_e(t))return;const l=null!==(o=t._pulseGlowRadius)&&void 0!==o?o:4,c=t.r+l*t._pulseIntensity,u=null!==(i=null!==(r=t.cx)&&void 0!==r?r:t.x)&&void 0!==i?i:0,h=null!==(a=null!==(s=t.cy)&&void 0!==s?s:t.y)&&void 0!==a?a:0;e.beginPath(),e.arc(u,h,c,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function Ne(e,t,n,o=.35){_e(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill())}function He(e){switch(e){case"monotoneX":return l.curveMonotoneX;case"monotoneY":return l.curveMonotoneY;case"cardinal":return l.curveCardinal;case"catmullRom":return l.curveCatmullRom;case"step":return l.curveStep;case"stepBefore":return l.curveStepBefore;case"stepAfter":return l.curveStepAfter;case"basis":return l.curveBasis;case"natural":return l.curveNatural;default:return null}}function ze(e){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 $e(e,t){const n=He(t.curve);if(!n||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath()}else{const o=l.area().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),o(t.topPath)}}const Fe=(e,t,n,o)=>{var r,i,s;const a=t.filter(e=>"area"===e.type);for(const t of a){if(2>t.topPath.length)continue;const n=t.style.fill||"#4e79a7",o=t._decayOpacities;if(o&&o.length===t.topPath.length){const i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:.7;e.fillStyle=n;for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(o[n]+o[n+1])*i,e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.lineTo(t.bottomPath[n+1][0],t.bottomPath[n+1][1]),e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(o[n]+o[n+1]),e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.stroke()}e.globalAlpha=1;continue}const a=null!==(i=t.style.opacity)&&void 0!==i?i:1;if($e(e,t),t.fillGradient){let o=1/0;for(const e of t.topPath)o>e[1]&&(o=e[1]);let r=-1/0;for(const e of t.bottomPath)e[1]>r&&(r=e[1]);const i=ze("string"==typeof n?n:"#4e79a7"),s=t.fillGradient.topOpacity,l=t.fillGradient.bottomOpacity,c=e.createLinearGradient(0,o,0,r);c.addColorStop(0,`rgba(${i[0]},${i[1]},${i[2]},${s})`),c.addColorStop(1,`rgba(${i[0]},${i[1]},${i[2]},${l})`),e.fillStyle=c,e.globalAlpha=a}else{const o=null!==(s=t.style.fillOpacity)&&void 0!==s?s:.7;e.globalAlpha=o*a,e.fillStyle=n}if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&($e(e,t),Ne(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=a,e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const n=He(t.curve);if(e.beginPath(),n)l.line().x(e=>e[0]).y(e=>e[1]).curve(n).context(e)(t.topPath);else{e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1])}e.stroke()}e.globalAlpha=1}},Ie=(e,t,n,o)=>{var r;const i=t.filter(e=>"point"===e.type);e.save();try{for(const t of i){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(r=t.style.opacity)&&void 0!==r?r:t.style.fillOpacity;null!=n&&(e.globalAlpha=n),e.fillStyle=t.style.fill||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),Be(e,t),e.globalAlpha=1}}finally{e.restore()}},We=(e,t,n,o)=>{const r=t.filter(e=>"rect"===e.type);for(const t of r)null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon?De(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))),Le(e,t),e.globalAlpha=1};function De(e,t){const n=t.style.icon,o=t.style.iconPadding||2,r=Math.min(t.w,t.h)-o;if(0>=r)return;const i=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),i){const i=r+o,s=t.x+(t.w-r)/2;for(let o=t.y+t.h-r;o>=t.y-r;o-=i)e.drawImage(n,s,o,r,r)}else{const i=r+o,s=t.y+(t.h-r)/2;for(let o=t.x;t.x+t.w>o;o+=i)e.drawImage(n,o,s,r,r)}e.restore()}function Te(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>128?"#000":"#fff"}function Re(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}const Ge=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function qe(e){const t=e[1]-e[0],n=3156e7;return 864e5>t?e=>{const t=new Date(e);return`${(t.getUTCHours()+"").padStart(2,"0")}:${(t.getUTCMinutes()+"").padStart(2,"0")}`}:n>t?e=>{const t=new Date(e);return`${Ge[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*n>t?e=>{const t=new Date(e);return`${Ge[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}const Ye={line:[Fe,(e,t,n,o)=>{var r,i;const s=t.filter(e=>"line"===e.type);for(const a of s){if(2>a.path.length)continue;const c=a.style.stroke||"#007bff",u=a.style.strokeWidth||2,h=a.colorThresholds,d=a.rawValues;if(e.setLineDash(a.style.strokeDasharray?a.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=a.style.opacity&&(e.globalAlpha=a.style.opacity),e.lineWidth=u,e.lineCap=a.style.strokeLinecap||"butt",a.style._edgeFade){const f=null!==(r=a.style.opacity)&&void 0!==r?r:1;Pe(e,a.path,c,u,f,a.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const g=Ee(a.curve),p=h&&h.length>0&&d&&d.length===a.path.length,y=a._decayOpacities;if(y&&y.length===a.path.length&&!p){e.strokeStyle=c;const m=null!==(i=a.style.opacity)&&void 0!==i?i:1;for(let b=0;a.path.length-1>b;b++)e.globalAlpha=.5*(y[b]+y[b+1])*m,e.beginPath(),e.moveTo(a.path[b][0],a.path[b][1]),e.lineTo(a.path[b+1][0],a.path[b+1][1]),e.stroke()}else if(p){let v=null,x=null,k=null,w=null,A=!1;function S(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),A=!0}function O(){A&&(e.stroke(),A=!1)}for(let M=0;a.path.length>M;M++){const[j,E]=a.path[M],C=d[M],P=Ce(C,h,c);if(null!==v&&null!==w&&null!==k){if(P===w)e.lineTo(j,E);else{const _=[];for(const L of h){const B=L.value;(k>B||B>C)&&(B>k||C>B)||k===B||C===B||_.push({t:(B-k)/(C-k)})}_.sort((e,t)=>e.t-t.t);for(const N of _){const H=v+(j-v)*N.t,z=x+(E-x)*N.t,$=Ce(k+(C-k)*Math.min(N.t+1e-4,1),h,c);e.lineTo(H,z),O(),S($,H,z)}e.lineTo(j,E)}v=j,x=E,k=C,w=P}else S(P,j,E),v=j,x=E,k=C,w=P}O()}else{if(e.beginPath(),e.strokeStyle=c,g)l.line().x(e=>e[0]).y(e=>e[1]).curve(g).context(e)(a.path);else{const[F,I]=a.path[0];e.moveTo(F,I);for(let W=1;a.path.length>W;W++)e.lineTo(a.path[W][0],a.path[W][1])}e.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=a.style.fillOpacity,e.fillStyle=a.style.fill,g&&!p)l.line().x(e=>e[0]).y(e=>e[1]).curve(g).context(e)(a.path);else{const[T,R]=a.path[0];e.moveTo(T,R);for(let G=1;a.path.length>G;G++)e.lineTo(a.path[G][0],a.path[G][1])}const D=a.path[0][0];e.lineTo(a.path[a.path.length-1][0],o.height),e.lineTo(D,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}}],area:[Fe],stackedarea:[Fe],scatter:[Ie],bubble:[Ie],heatmap:[(e,t,n,o)=>{const r=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of r){const n=t.style;if(null!=(null==n?void 0:n.opacity)&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle="#fff",e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),Le(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):Re(t.value),o=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),r=t.x+t.w/2,i=t.y+t.h/2;e.fillStyle=Te(t.fill),e.font=o+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,r,i)}}}finally{e.restore()}}],bar:[We],swarm:[Ie],waterfall:[(e,t,n,o)=>{var r,i,s;We(e,t);const a=t.filter(e=>"rect"===e.type);if(2>a.length)return;const l=a[0].datum,c=null==l?void 0:l._connectorStroke;if(c){e.save(),e.strokeStyle=c,e.lineWidth=null!==(r=null==l?void 0:l._connectorWidth)&&void 0!==r?r:1,e.setLineDash([]);for(let t=0;a.length-1>t;t++){const o=a[t],r=a[t+1];if(!(null===(i=o.datum)||void 0===i?void 0:i.cumEnd)||!(null===(s=r.datum)||void 0===s?void 0:s.baseline))continue;const l=n.y(o.datum.cumEnd),c=o.x+o.w,u=r.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[(e,t,n,o)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const o=t._decayOpacity;null!=o&&1!==o&&(e.globalAlpha=o),e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=t.wickColor,e.lineWidth=t.wickWidth,e.stroke();const r=Math.min(t.openY,t.closeY),i=Math.abs(t.openY-t.closeY),s=t.isUp?t.upColor:t.downColor;e.fillStyle=s,e.fillRect(t.x-t.bodyWidth/2,r,t.bodyWidth,Math.max(i,1)),e.strokeStyle=s,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,r,t.bodyWidth,Math.max(i,1)),e.restore()}}]},Xe={top:20,right:20,bottom:30,left:40},Ve={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"},Ue={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 Qe({hover:e}){const t=e=>Number.isInteger(e)?e+"":e.toFixed(2);return d.createElement("div",{className:"semiotic-tooltip",style:Ue},d.createElement("div",{style:{fontWeight:600,marginBottom:2}},t(e.value)),d.createElement("div",{style:{opacity:.7,fontSize:11}},t(e.time)))}function Ke({width:o,height:r,totalWidth:i,totalHeight:s,margin:a,dimension:l,scales:c,onBrush:u}){const h=e.useRef(null),g=e.useRef(null),p=e.useRef(u);p.current=u;const y=e.useRef(c);return y.current=c,e.useEffect(()=>{if(!h.current)return;const e=n.select(h.current).select(".brush-g"),i="x"===l?t.brushX():"y"===l?t.brushY():t.brush();return i.extent([[0,0],[o,r]]),i.on("brush end",e=>{const t=y.current;if(!t)return;if(!e.selection)return void p.current(null);let n,i;if("x"===l){const[o,s]=e.selection;n=[t.x.invert(o),t.x.invert(s)],i=[t.y.invert(r),t.y.invert(0)]}else if("y"===l){const[r,s]=e.selection;n=[t.x.invert(0),t.x.invert(o)],i=[t.y.invert(s),t.y.invert(r)]}else{const[[o,r],[s,a]]=e.selection;n=[t.x.invert(o),t.x.invert(s)],i=[t.y.invert(a),t.y.invert(r)]}p.current({x:n,y:i})}),e.call(i),g.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),g.current=null}},[o,r,l]),d.createElement("svg",{ref:h,width:i,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},d.createElement("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`}))}const Ze=e.forwardRef(function(t,n){var o,r,i,s,a,l,c,u,h;const{chartType:g,runtimeMode:y,data:f,chunkThreshold:m,chunkSize:b,xAccessor:v,yAccessor:x,colorAccessor:k,sizeAccessor:w,groupAccessor:A,lineDataAccessor:S,curve:O,normalize:M,binSize:j,valueAccessor:E,arrowOfTime:C="right",windowMode:P="sliding",windowSize:_=200,timeAccessor:L,xExtent:B,yExtent:N,extentPadding:z=.1,sizeRange:I,size:G=[500,300],responsiveWidth:q,responsiveHeight:Y,margin:X,className:V,background:U,lineStyle:Q,pointStyle:K,areaStyle:Z,waterfallStyle:J,swarmStyle:ee,barColors:te,colorScheme:ne,boundsAccessor:oe,boundsStyle:re,y0Accessor:ie,gradientFill:se,openAccessor:ae,highAccessor:le,lowAccessor:ue,closeAccessor:he,candlestickStyle:de,showAxes:fe=!0,axes:xe,xLabel:ke,yLabel:we,yLabelRight:Ae,xFormat:Se,yFormat:Oe,tickFormatTime:Ee,tickFormatValue:Ce,hoverAnnotation:Pe,tooltipContent:_e,customHoverBehavior:Le,enableHover:Be,annotations:Ne,svgAnnotationRules:He,showGrid:ze,legend:$e,legendHoverBehavior:Fe,legendClickBehavior:Ie,legendHighlightedCategory:We,legendIsolatedCategories:De,legendPosition:Te,backgroundGraphics:Re,foregroundGraphics:Ge,canvasPreRenderers:Ue,svgPreRenderers:Ze,title:Je,categoryAccessor:et,brush:tt,onBrush:nt,decay:ot,pulse:rt,transition:it,staleness:st,heatmapAggregation:at,heatmapXBins:lt,heatmapYBins:ct,showValues:ut,heatmapValueFormat:ht,marginalGraphics:dt,pointIdAccessor:gt,xScaleType:pt,yScaleType:yt,accessibleTable:ft}=t,[mt,bt]=function(t,n,o){const r=e.useRef(null),[i,s]=e.useState(null);return e.useEffect(()=>{if(!n&&!o)return;const e=r.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;s(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[n,o]),[r,[n&&i?i.w:t[0],o&&i?i.h:t[1]]]}(G,q,Y),vt=Object.assign(Object.assign({},Xe),X);if(dt){const e=60;dt.top&&e>vt.top&&(vt.top=e),dt.bottom&&e>vt.bottom&&(vt.bottom=e),dt.left&&e>vt.left&&(vt.left=e),dt.right&&e>vt.right&&(vt.right=e)}const xt=bt[0]-vt.left-vt.right,kt=bt[1]-vt.top-vt.bottom,wt="function"==typeof Ge?Ge({size:bt,margin:vt}):Ge,At="function"==typeof Re?Re({size:bt,margin:vt}):Re,St=null!=Pe?Pe:Be,Ot=e.useRef(null),Mt=e.useRef(null),jt=e.useRef(0),Et=e.useRef(!1),Ct=Me(e=>e.theme),[Pt,_t]=e.useState(0),[Lt,Bt]=e.useState(null),Nt=e.useRef(null),Ht=e.useRef(null),[zt,$t]=e.useState(null),[Ft,It]=e.useState(!1),[Wt,Dt]=e.useState([]),[Tt,Rt]=e.useState([]),Gt=e.useRef(()=>{}),qt="streaming"===y||["bar","swarm","waterfall"].includes(g),Yt=e.useMemo(()=>({chartType:g,runtimeMode:qt?"streaming":"bounded",windowSize:_,windowMode:P,arrowOfTime:qt?C:"right",extentPadding:z,xAccessor:qt?void 0:v,yAccessor:qt?void 0:x,timeAccessor:qt?L:void 0,valueAccessor:E,colorAccessor:k,sizeAccessor:w,groupAccessor:A,categoryAccessor:et,lineDataAccessor:S,xScaleType:pt,yScaleType:yt,xExtent:B,yExtent:N,sizeRange:I,binSize:j,normalize:M,boundsAccessor:oe,boundsStyle:re,y0Accessor:ie,gradientFill:"boolean"==typeof se?se?{topOpacity:.8,bottomOpacity:.05}:void 0:se,openAccessor:ae,highAccessor:le,lowAccessor:ue,closeAccessor:he,candlestickStyle:de,lineStyle:Q,pointStyle:K,areaStyle:Z,swarmStyle:ee,waterfallStyle:J,colorScheme:ne,barColors:te,annotations:Ne,decay:ot,pulse:rt,transition:it,staleness:st,heatmapAggregation:at,heatmapXBins:lt,heatmapYBins:ct,showValues:ut,heatmapValueFormat:ht,pointIdAccessor:gt,curve:O}),[g,_,P,C,z,v,x,L,E,pt,yt,k,w,A,et,S,B,N,I,j,M,oe,re,ie,se,ae,le,ue,he,de,Q,K,Z,ee,J,ne,te,Ne,ot,rt,it,st,at,lt,ct,ut,ht,qt,gt,O]),Xt=e.useRef(null);Xt.current||(Xt.current=new H(Yt));const Vt=e.useCallback(()=>{jt.current||(jt.current=requestAnimationFrame(()=>Gt.current()))},[]);e.useEffect(()=>{var e;null===(e=Xt.current)||void 0===e||e.updateConfig(Yt),Et.current=!0,Vt()},[Yt,Vt]),e.useEffect(()=>{Et.current=!0,Vt()},[Ct,Vt]);const Ut=e.useRef(null);Ut.current||(Ut.current=new p(e=>{const t=Xt.current;t&&t.ingest(e)&&(Et.current=!0,Vt())},{chunkThreshold:m,chunkSize:b})),e.useEffect(()=>{var e;null===(e=Ut.current)||void 0===e||e.updateChunkOptions({chunkThreshold:m,chunkSize:b})},[m,b]);const Qt=e.useCallback(e=>{var t;null===(t=Ut.current)||void 0===t||t.push(e)},[]),Kt=e.useCallback(e=>{var t;null===(t=Ut.current)||void 0===t||t.pushMany(e)},[]),Zt=e.useCallback(()=>{var e,t;null===(e=Ut.current)||void 0===e||e.clear(),null===(t=Xt.current)||void 0===t||t.clear(),Et.current=!0,Vt()},[Vt]);e.useImperativeHandle(n,()=>({push:Qt,pushMany:Kt,clear:Zt,getData:()=>{var e,t,n;return null===(e=Ut.current)||void 0===e||e.flush(),null!==(n=null===(t=Xt.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},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}}),[Qt,Kt,Zt]),e.useEffect(()=>{var e;f&&(null===(e=Ut.current)||void 0===e||e.setBoundedData(f))},[f]);const Jt=e.useRef(()=>{}),en=e.useRef(()=>{});Jt.current=e=>{if(!St)return;const t=Ot.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-vt.left,r=e.clientY-n.top-vt.top;if(0>o||o>xt||0>r||r>kt)return void(Nt.current&&(Nt.current=null,Ht.current=null,$t(null),Le&&(Le(null),Et.current=!0),Vt()));const i=Xt.current;if(!i||0===i.scene.length)return;const s=function(e,t,n,o=30,r){let i=null,s=!1;if(r){const e=r.find(t,n,o);if(e){const r=$(e,t,n);r&&o>r.distance&&(i=r,s=!0)}}for(const a of e){let e=null;switch(a.type){case"point":if(r&&s)break;e=$(a,t,n);break;case"line":e=F(a,t,n);break;case"rect":e=W(a,t,n);break;case"heatcell":e=D(a,t,n);break;case"area":if(!1===a.interactive)break;e=R(a,t,n);break;case"candlestick":e=T(a,t,n)}e&&o>e.distance&&(i&&e.distance>=i.distance||(i=e))}return i}(i.scene,o,r,30,i.quadtree);if(!s)return void(Nt.current&&(Nt.current=null,Ht.current=null,$t(null),Le&&Le(null),Vt()));const a=s.datum||{},l=Object.assign(Object.assign({},"object"!=typeof a||null===a||Array.isArray(a)?{}:a),{data:a,time:s.x,value:s.y,x:s.x,y:s.y});Nt.current=l,Ht.current=s.node,$t(l),Le&&(Le(l),Et.current=!0),Vt()},en.current=()=>{Nt.current&&(Nt.current=null,Ht.current=null,$t(null),Le&&(Le(null),Et.current=!0),Vt())},e.useCallback(e=>Jt.current(e),[]);const tn=e.useCallback(()=>en.current(),[]),nn=e.useRef(-1),on=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>nn.current?-1:nn.current,r=function(e,t,n){switch(e){case"ArrowRight":case"ArrowDown":return n-1>t?t+1:t;case"ArrowLeft":case"ArrowUp":return t>0?t-1:t;case"Home":return 0;case"End":return n-1;case"Escape":return-1;default:return null}}(e.key,0>o?-1:o,n.length);if(null===r)return;if(e.preventDefault(),0>r)return nn.current=-1,Nt.current=null,Ht.current=null,$t(null),Le&&Le(null),void Vt();const i=0>o?0:r;nn.current=i;const s=function(e){const t=e.datum||{};return Object.assign(Object.assign({},"object"!=typeof t||null===t||Array.isArray(t)?{}:t),{data:t,x:e.x,y:e.y,time:e.x,value:e.y})}(n[i]);Nt.current=s,$t(s),Le&&Le(s),Vt()},[Le,Vt]),rn=e.useCallback(e=>{nn.current=-1,Jt.current(e)},[]);Gt.current=()=>{var e,t;jt.current=0;const n=Ot.current,o=Mt.current;if(!n||!o)return;const r=Xt.current;if(!r)return;const i="undefined"!=typeof performance?performance.now():Date.now(),s=r.advanceTransition(i),a=Et.current||s;a&&!s&&r.computeScene({width:xt,height:kt});const l="undefined"!=typeof window&&window.devicePixelRatio||1,c=function(e){if(!e)return Ve;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),r=t.getPropertyValue("--semiotic-bg").trim(),i=o||t.getPropertyValue("--text-secondary").trim(),s=t.getPropertyValue("--text-primary").trim(),a=n||t.getPropertyValue("--surface-3").trim(),l=r||t.getPropertyValue("--surface-0").trim();return i||s||n?{axisStroke:a||Ve.axisStroke,tickText:i||Ve.tickText,crosshair:i?i+"66":Ve.crosshair,hoverFill:l?l+"4D":Ve.hoverFill,hoverStroke:i?i+"99":Ve.hoverStroke,pointRing:l||Ve.pointRing}:Ve}(n),u=null!==(e=null==st?void 0:st.threshold)&&void 0!==e?e:5e3,h=st&&r.lastIngestTime>0&&i-r.lastIngestTime>u;if(a){const e=je(n,bt,vt,l);if(e){e.clearRect(-vt.left,-vt.top,bt[0],bt[1]),h&&(e.globalAlpha=null!==(t=null==st?void 0:st.dimOpacity)&&void 0!==t?t:.5);const o=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=U||(o&&"transparent"!==o?o:null);if(i&&(e.fillStyle=i,e.fillRect(-vt.left,-vt.top,bt[0],bt[1])),e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,xt,kt),e.clip()),Ue&&r.scales)for(const t of Ue)e.save(),t(e,r.scene,r.scales,{width:xt,height:kt}),e.restore();const s=Ye[g];if(s&&r.scales)for(const t of s)t(e,r.scene,r.scales,{width:xt,height:kt});e.restore(),h&&(e.globalAlpha=1)}}{const e=je(o,bt,vt,l);if(e&&(e.clearRect(-vt.left,-vt.top,bt[0],bt[1]),St&&Nt.current&&r.scales&&function(e,t,n,o,r,i,s){var a;if(!1===r.crosshair)return;e.save();const l="object"==typeof r.crosshair?r.crosshair:{};e.strokeStyle=l.stroke||s.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();let c="";try{(null===(a=e.canvas)||void 0===a?void 0:a.parentElement)&&(c=getComputedStyle(e.canvas).getPropertyValue("--semiotic-primary").trim())}catch(e){}const u=r.pointColor||function(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const n="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||n||null:n||t.stroke||null}(i)||c||"#007bff";e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=u,e.fill(),e.strokeStyle=s.pointRing,e.lineWidth=2,e.stroke()}(e,Nt.current,xt,kt,"object"==typeof St?St:{},Ht.current,c),Ht.current&&Array.isArray(Pe))){const t=Pe.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,o){var r;if(!n)return;const i=n.group;if(void 0!==i)for(const n of t){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const t="function"==typeof o.style?o.style(n.datum):o.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||"#007bff",e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=null!==(r=t.opacity)&&void 0!==r?r:1,e.stroke(),e.restore()}}(e,r.scene,Ht.current,t)}}a&&n&&n.setAttribute("aria-label",me(r.scene,g+" chart"));const d=Et.current;if(Et.current=!1,d&&r.scales&&((!Lt||Lt.x.domain()[0]!==r.scales.x.domain()[0]||Lt.x.domain()[1]!==r.scales.x.domain()[1]||Lt.y.domain()[0]!==r.scales.y.domain()[0]||Lt.y.domain()[1]!==r.scales.y.domain()[1]||Lt.x.range()[0]!==r.scales.x.range()[0]||Lt.x.range()[1]!==r.scales.x.range()[1]||Lt.y.range()[0]!==r.scales.y.range()[0]||Lt.y.range()[1]!==r.scales.y.range()[1])&&Bt(r.scales),dt)){const e=r.getData(),t="function"==typeof v?v:e=>e[v||"x"],n="function"==typeof x?x:e=>e[x||"y"];Dt(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),Rt(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}d&&Ne&&Ne.length>0&&_t(e=>e+1),(null==st?void 0:st.showBadge)&&It(!!h),(s||r.hasActivePulses)&&(jt.current=requestAnimationFrame(()=>Gt.current()))},e.useEffect(()=>(Vt(),()=>{jt.current&&(cancelAnimationFrame(jt.current),jt.current=0)}),[Vt]),e.useEffect(()=>{Et.current=!0,Vt()},[g,xt,kt,fe,U,Q,Ue,Vt]),function(t,n,o,r,i,s){e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{var e;const a=n.current;if(!a||0===a.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(e=t.threshold)&&void 0!==e?e:5e3,u=l-a.lastIngestTime>c;u!==i&&(s(u),o.current=!0,r())},1e3);return()=>clearInterval(e)},[t,i,r])}(st,Xt,Et,Vt,Ft,It);const sn=e.useMemo(()=>{if(Se||Ee)return;const e=Xt.current;return(null==e?void 0:e.xIsDate)&&Lt?qe(Lt.x.domain()):void 0},[Se,Ee,Lt]),an=Se||Ee||sn,ln=St&&zt?_e?_e(zt):d.createElement(Qe,{hover:zt}):null,cn=ln?d.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:vt.left+zt.x,top:vt.top+zt.y,transform:`translate(${zt.x>.7*xt?"calc(-100% - 12px)":"12px"}, ${.3*kt>zt.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1,width:"max-content"}},ln):null,un=nn.current>=0&&zt?d.createElement("svg",{style:{position:"absolute",left:0,top:0,width:bt[0],height:bt[1],pointerEvents:"none",zIndex:2}},d.createElement("circle",{cx:zt.x+vt.left,cy:zt.y+vt.top,r:8,fill:"none",stroke:"var(--accent, #6366f1)",strokeWidth:2,strokeDasharray:"4,2"})):null;if(ye){const e=Xt.current;e&&f&&(e.ingest({inserts:f,bounded:!0}),e.computeScene({width:xt,height:kt}));const t=null!==(o=null==e?void 0:e.scene)&&void 0!==o?o:[],n=null!==(r=null==e?void 0:e.scales)&&void 0!==r?r:null,i=an||(()=>{if((null==e?void 0:e.xIsDate)&&n)return qe(n.x.domain())})();return d.createElement("div",{className:"stream-xy-frame"+(V?" "+V:""),role:"img","aria-label":"string"==typeof Je?Je:"XY chart",style:{position:"relative",width:bt[0],height:bt[1]}},d.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:bt[0],height:bt[1],style:{position:"absolute",left:0,top:0}},At,d.createElement("g",{transform:`translate(${vt.left},${vt.top})`},U&&d.createElement("rect",{x:0,y:0,width:xt,height:kt,fill:U}),Ze&&n&&Ze.map((e,o)=>d.createElement(d.Fragment,{key:"svgpre-"+o},e(t,n,{width:xt,height:kt}))),t.map((e,t)=>function(e,t){var n,o,r;switch(e.type){case"line":{const n=e;if(0===n.path.length)return null;const o="M"+n.path.map(([e,t])=>`${e},${t}`).join("L");return d.createElement("path",{key:"line-"+t,d:o,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity})}case"area":{const r=e;if(0===r.topPath.length)return null;const i=r.topPath.map(([e,t])=>`${e},${t}`).join("L"),s=[...r.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L");return d.createElement("path",{key:"area-"+t,d:`M${i}L${s}Z`,fill:pe(r.style.fill),fillOpacity:null!==(o=null!==(n=r.style.fillOpacity)&&void 0!==n?n:r.style.opacity)&&void 0!==o?o:.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})}case"point":{const n=e;return d.createElement("circle",{key:"point-"+t,cx:n.x,cy:n.y,r:n.r,fill:pe(n.style.fill),opacity:null!==(r=n.style.opacity)&&void 0!==r?r:.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})}case"rect":{const n=e;return d.createElement("rect",{key:"rect-"+t,x:n.x,y:n.y,width:n.w,height:n.h,fill:pe(n.style.fill),opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})}case"heatcell":{const n=e;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const e=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[o,r,i]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(n.fill),s=.299*o+.587*r+.114*i>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return d.createElement("g",{key:"heatcell-"+t},d.createElement("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),d.createElement("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px"},e))}return d.createElement("rect",{key:"heatcell-"+t,x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill})}case"candlestick":{const n=e,o=Math.min(n.openY,n.closeY),r=Math.max(Math.abs(n.openY-n.closeY),1),i=n.isUp?n.upColor:n.downColor;return d.createElement("g",{key:"candle-"+t},d.createElement("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),d.createElement("rect",{x:n.x-n.bodyWidth/2,y:o,width:n.bodyWidth,height:r,fill:i,stroke:i,strokeWidth:1}))}default:return null}}(e,t)).filter(Boolean))),d.createElement(ge,{width:xt,height:kt,totalWidth:bt[0],totalHeight:bt[1],margin:vt,scales:n,showAxes:fe,axes:xe,xLabel:ke,yLabel:we,yLabelRight:Ae,xFormat:i,yFormat:Oe||Ce,showGrid:ze,title:Je,legend:$e,legendHoverBehavior:Fe,legendClickBehavior:Ie,legendHighlightedCategory:We,legendIsolatedCategories:De,legendPosition:Te,foregroundGraphics:wt,marginalGraphics:dt,xValues:[],yValues:[],annotations:Ne,svgAnnotationRules:He,annotationFrame:0,xAccessor:"string"==typeof v?v:"string"==typeof L?L:void 0,yAccessor:"string"==typeof x?x:"string"==typeof E?E:void 0,annotationData:null==e?void 0:e.getData(),pointNodes:null==e?void 0:e.scene.filter(e=>"point"===e.type),curve:"string"==typeof O?O:void 0}))}return d.createElement("div",{ref:mt,className:"stream-xy-frame"+(V?" "+V:""),role:"img","aria-label":"string"==typeof Je?Je:"XY chart",tabIndex:0,style:{position:"relative",width:q?"100%":bt[0],height:Y?"100%":bt[1],overflow:"visible"},onMouseMove:St?rn:void 0,onMouseLeave:St?tn:void 0,onKeyDown:on},At&&d.createElement("svg",{style:{position:"absolute",left:0,top:0,width:bt[0],height:bt[1],pointerEvents:"none"}},At),d.createElement(ce,{width:xt,height:kt,totalWidth:bt[0],totalHeight:bt[1],margin:vt,scales:Lt,showAxes:fe,axes:xe,showGrid:ze,xFormat:an,yFormat:Oe||Ce}),d.createElement("canvas",{ref:Ot,"aria-label":me(null!==(s=null===(i=Xt.current)||void 0===i?void 0:i.scene)&&void 0!==s?s:[],g+" chart"),style:{position:"absolute",left:0,top:0}}),d.createElement("canvas",{ref:Mt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),d.createElement(ve,{hoverPoint:zt}),ft&&d.createElement(be,{scene:null!==(l=null===(a=Xt.current)||void 0===a?void 0:a.scene)&&void 0!==l?l:[],chartType:g+" chart"}),d.createElement(ge,{width:xt,height:kt,totalWidth:bt[0],totalHeight:bt[1],margin:vt,scales:Lt,showAxes:fe,axes:xe,xLabel:ke,yLabel:we,yLabelRight:Ae,xFormat:an,yFormat:Oe||Ce,showGrid:ze,title:Je,legend:$e,legendHoverBehavior:Fe,legendClickBehavior:Ie,legendHighlightedCategory:We,legendIsolatedCategories:De,legendPosition:Te,foregroundGraphics:wt,marginalGraphics:dt,xValues:Wt,yValues:Tt,annotations:Ne,svgAnnotationRules:He,annotationFrame:Pt,xAccessor:"string"==typeof v?v:"string"==typeof L?L:void 0,yAccessor:"string"==typeof x?x:"string"==typeof E?E:void 0,annotationData:null===(c=Xt.current)||void 0===c?void 0:c.getData(),pointNodes:null===(u=Xt.current)||void 0===u?void 0:u.scene.filter(e=>"point"===e.type),curve:"string"==typeof O?O:void 0,underlayRendered:!0}),(tt||nt)&&d.createElement(Ke,{width:xt,height:kt,totalWidth:bt[0],totalHeight:bt[1],margin:vt,dimension:null!==(h=null==tt?void 0:tt.dimension)&&void 0!==h?h:"xy",scales:Lt,onBrush:null!=nt?nt:()=>{}}),(null==st?void 0:st.showBadge)&&d.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===st.badgePosition?{top:4,left:4}:"bottom-left"===st.badgePosition?{bottom:4,left:4}:"bottom-right"===st.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Ft?"#dc3545":"#28a745",color:"white"})},Ft?"STALE":"LIVE"),un,cn)});Ze.displayName="StreamXYFrame";const Je=e.createContext(null);function et(){return e.useContext(Je)}function tt(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,r]=o.range;t.push(t=>{const o=t[n];return o>=e&&r>=o})}return e=>t.every(t=>t(e))}function nt(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[ot,rt]=xe(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),r=nt(o,t),i=new Map(r.clauses);return i.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},r),{clauses:i})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const r=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),r.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:r}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),r=nt(o,t);return o.set(t,Object.assign(Object.assign({},r),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}})),[it,st]=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 at(t){const n=e.useId(),o=t.clientId||n,{name:r}=t,i=rt(e=>e.selections.get(r)),s=rt(e=>e.setClause),a=rt(e=>e.clearClause),l=e.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:e.useMemo(()=>i&&0!==i.clauses.size?function(e,t){const n=[];for(const[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(tt(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(i,o):()=>!0,[i,o]),isActive:l,selectPoints:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};s(r,{clientId:o,type:"point",fields:t})},[o,r,s]),selectInterval:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};s(r,{clientId:o,type:"interval",fields:t})},[o,r,s]),clear:e.useCallback(()=>{a(r,o)},[a,r,o]),clientId:o}}function lt(t){const n=t.name||"hover",{fields:o}=t,{predicate:r,isActive:i,selectPoints:s,clear:a}=at({name:n});return{onHover:e.useCallback(e=>{if(!e)return void a();const t={};for(const n of o){const o=e[n];void 0!==o&&(t[n]=[o])}Object.keys(t).length>0&&s(t)},[o,s,a,n]),predicate:r,isActive:i}}function ct(t){const{name:n,xField:o,yField:r}=t,{predicate:i,isActive:s,selectInterval:a,clear:l}=at({name:n}),c=o&&r?"xyBrush":o?"xBrush":"yBrush",u=e.useCallback(e=>{if(!e)return void l();const t={};"xyBrush"===c&&Array.isArray(e)&&2===e.length?(o&&(t[o]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),r&&(t[r]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&Array.isArray(e)?o&&(t[o]=[Math.min(...e),Math.max(...e)]):"yBrush"===c&&Array.isArray(e)&&r&&(t[r]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&a(t)},[c,o,r,a,l]);return{brushInteraction:e.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:i,isActive:s,clear:l}}const ut=e.createContext(!1);function ht({selections:t}){const n=rt(e=>e.setResolution);return e.useEffect(()=>{for(const[e,o]of Object.entries(t))o.resolution&&n(e,o.resolution)},[t,n]),null}function dt({categoryColors:t,interaction:n,selectionName:o,field:r}){const i=Object.entries(t);if(0===i.length)return null;const s=i.map(([e])=>e),a=[{styleFn:e=>({fill:e.color||"#333",stroke:e.color||"#333"}),type:"fill",items:i.map(([e,t])=>({label:e,color:t})),label:""}],l=lt({name:o,fields:[r]}),c=at({name:o,clientId:"__linked-legend-isolate__"}),[u,h]=e.useState(new Set),[g,p]=e.useState(null),y=e.useRef(c.selectPoints);y.current=c.selectPoints;const f=e.useRef(c.clear);f.current=c.clear,e.useEffect(()=>{"isolate"===n&&(u.size>0?y.current({[r]:Array.from(u)}):f.current())},[n,u,r]);const m=e.useCallback(e=>{"highlight"===n&&(e?(p(e.label),l.onHover({[r]:e.label})):(p(null),l.onHover(null)))},[n,r,l]),b=e.useCallback(e=>{"isolate"===n&&h(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===s.length?new Set:n})},[n,s.length]);return d.createElement("svg",{width:"100%",height:30,style:{display:"block",overflow:"visible"}},d.createElement(Q,{legendGroups:a,title:!1,orientation:"horizontal",height:20,customHoverBehavior:"highlight"===n?m:void 0,customClickBehavior:"isolate"===n?b:void 0,highlightedCategory:g,isolatedCategories:u}))}function gt({children:e,selections:t,showLegend:n,legendPosition:o="top",legendInteraction:r="none",legendSelectionName:i="legend",legendField:s="category"}){const a=et(),l=void 0!==n?n:!(!a||0>=Object.keys(a).length);return d.createElement(ot,null,d.createElement(it,null,t&&d.createElement(ht,{selections:t}),d.createElement(ut.Provider,{value:l},l&&"top"===o&&a&&d.createElement(dt,{categoryColors:a,interaction:r,selectionName:i,field:s}),e,l&&"bottom"===o&&a&&d.createElement(dt,{categoryColors:a,interaction:r,selectionName:i,field:s}))))}function pt({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:r,strokeWidth:i,categories:s}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==r&&(n.stroke=r),void 0!==i&&(n.strokeWidth=i),n},type:"fill",items:(s&&s.length>0?s:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((r,i)=>{const s=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),a=s?o(s,t,n):n?n(r):C[i%C.length];return{label:r+"",color:a}}),label:""}]}}function yt(e){return e?"string"==typeof e?{name:e}:e:null}function ft(e,t,n){return t?o=>{var r;const i=Object.assign({},e(o));if(t.isActive)if(t.predicate(o))(null==n?void 0:n.selectedStyle)&&Object.assign(i,n.selectedStyle);else{const e=null!==(r=null==n?void 0:n.unselectedOpacity)&&void 0!==r?r:.2;i.opacity=e,i.fillOpacity=e,i.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(i,n.unselectedStyle)}return i}:e}d.createContext(void 0);const mt="#007bff";function bt(e){return"function"==typeof e?e:t=>t[e]}function vt(t,n,o="category10"){const r=et();return e.useMemo(()=>{if(n){if(0===t.length)return r&&Object.keys(r).length>0?e=>r[e]||"#999":void 0;if("function"==typeof n){const e=Array.from(new Set(t.map(e=>n(e)+"")));return r&&Object.keys(r).length>0?e=>r[e]||"#999":L(e.map(e=>({_cat:e})),"_cat",o)}if(r&&Object.keys(r).length>0){const e=L(t,n,o);return t=>r[t]||e(t)}return L(t,n,o)}},[t,n,o,r])}function xt({selection:t,linkedHover:n,fallbackFields:o=[],unwrapData:r=!1,onObservation:i,chartType:s,chartId:a}){const l=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields}:null}(n,o),c=at({name:(null==t?void 0:t.name)||"__unused__"}),u=lt({name:(null==l?void 0:l.name)||"hover",fields:(null==l?void 0:l.fields)||o||[]}),h=st(e=>e.pushObservation),d=t?{isActive:c.isActive,predicate:c.predicate}:null,g=e.useCallback(e=>{var t,o;if(n)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]),u.onHover(t)}else u.onHover(null);if(i||h){const n={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const s=Object.assign(Object.assign({},n),{type:"hover",datum:r||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(s),h&&h(s)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(e),h&&h(e)}}},[n,u,i,s,a,h]),p=e.useCallback(e=>{var t,n;if(i||h){const o={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const s=Object.assign(Object.assign({},o),{type:"click",datum:r||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});i&&i(s),h&&h(s)}else{const e=Object.assign(Object.assign({},o),{type:"click-end"});i&&i(e),h&&h(e)}}},[i,h,s,a]);return{activeSelectionHook:d,customHoverBehavior:g,customClickBehavior:p}}function kt({data:t,colorBy:n,colorScale:o,showLegend:r,legendPosition:i="right",userMargin:s,defaults:a={top:50,bottom:60,left:70,right:40},categories:l}){const c=e.useContext(ut),u=void 0!==r?r:!c&&!!n,h=e.useMemo(()=>{if(u&&n)return pt({data:t,colorBy:n,colorScale:o,getColor:_,categories:l})},[u,n,t,o,l]),d=e.useMemo(()=>{const e=Object.assign(Object.assign({},a),s);return h&&("right"===i&&110>e.right?e.right=110:"left"===i&&110>e.left?e.left=110:"top"===i&&50>e.top?e.top=50:"bottom"===i&&80>e.bottom&&(e.bottom=80)),e},[a,s,h,i]);return{legend:h,margin:d,legendPosition:i}}function wt(t,n,o){const[r,i]=e.useState(null),[s,a]=e.useState(new Set),l=e.useCallback(e=>{"highlight"===t&&i(e?e.label:null)},[t]),c=e.useCallback(e=>{"isolate"===t&&a(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===o.length?new Set:n})},[t,o.length]),u=e.useMemo(()=>{if(!t||"none"===t||!n)return null;const e="string"==typeof n?n:null;return"highlight"===t&&null!=r?{isActive:!0,predicate:t=>(e?t[e]:"function"==typeof n?n(t):null)===r}:"isolate"===t&&s.size>0?{isActive:!0,predicate:t=>{const o=e?t[e]:"function"==typeof n?n(t):null;return s.has(o)}}:null},[t,n,r,s]);return{highlightedCategory:"highlight"===t?r:null,isolatedCategories:"isolate"===t?s:new Set,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}const At={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 St(e,t,n){var o,r,i,s,a,l;const c=At[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:e&&"primary"!==e||!(null==n?void 0:n.width)?c.width:n.width,height:null!==(r=t.height)&&void 0!==r?r:e&&"primary"!==e||!(null==n?void 0:n.height)?c.height:n.height,showAxes:c.showAxes,showGrid:null!==(i=t.showGrid)&&void 0!==i?i:c.showGrid,enableHover:null!==(s=t.enableHover)&&void 0!==s?s:!!t.linkedHover||c.enableHover,showLegend:null!==(a=t.showLegend)&&void 0!==a?a:c.showLegend,showLabels:null!==(l=t.showLabels)&&void 0!==l?l:c.showLabels,title:u?void 0:t.title,xLabel:u?void 0:t.xLabel,yLabel:u?void 0:t.yLabel,categoryLabel:u?void 0:t.categoryLabel,valueLabel:u?void 0:t.valueLabel,marginDefaults:Ot(c.marginDefaults,t.showCategoryTicks,t.orientation)}}function Ot(e,t,n){if(!1!==t)return e;const o=Object.assign({},e);return"horizontal"===n?o.left=Math.min(o.left,15):o.bottom=Math.min(o.bottom,15),o}const Mt={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function jt(e,t){return"function"==typeof t?t(e):e[t]}function Et(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 Ct(e={}){const{fields:t,title:n,format:o,style:r={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let s;const a=[];if(n){const t=jt(e,n);s=Et(t,o)}if(t&&t.length>0)t.forEach(t=>{let n,r,i;"string"==typeof t?(n=t,r=t,i=o):(n=t.label,r=t.accessor||t.key||"",i=t.format||o);const s=jt(e,r);a.push({label:n,value:Et(s,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){s=Et(e[n],o);break}if(!s){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(s=Et(e[t[0]],o))}}const l=Object.assign(Object.assign({},Mt),r);return d.createElement("div",{className:("semiotic-tooltip "+i).trim(),style:l},s&&d.createElement("div",{style:{fontWeight:a.length>0?"bold":"normal"}},s),a.map((e,t)=>d.createElement("div",{key:t,style:{marginTop:0===t&&s?"4px":0}},e.label&&d.createElement("span",null,e.label,": "),e.value)))}}function Pt(e){if(!0===e)return Ct();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:Mt},n)}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?Ct(e):Ct())}function _t(e){return"string"==typeof e?e:"value"}function Lt(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function Bt(e,t){return"function"==typeof t?t(e):e[t]}function Nt(e){const t=e.find(e=>"title"===e.role),n=e.filter(e=>"title"!==e.role);return e=>{const o=e.data;if(!o)return null;const r=t?Lt(Bt(o,t.accessor)):null;return d.createElement("div",{className:"semiotic-tooltip",style:Mt},r&&d.createElement("div",{style:{fontWeight:"bold",marginBottom:n.length>0?4:0}},r),n.map((e,t)=>{const n=Lt(Bt(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 Ht({componentName:e,message:t,diagnosticHint:n,width:o,height:r}){return d.createElement("div",{role:"alert",style:{width:o,height:Math.max(r,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},d.createElement("div",{style:{textAlign:"center",maxWidth:400}},d.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),d.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t),n&&d.createElement("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6}},n)))}class zt 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(Ht,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function $t(e,t){const n=e.length,o=t.length,r=Array(o+1);for(let e=0;o>=e;e++)r[e]=e;for(let i=1;n>=i;i++){let n=r[0];r[0]=i;for(let s=1;o>=s;s++){const o=r[s];r[s]=e[i-1]===t[s-1]?n:1+Math.min(n,r[s],r[s-1]),n=o}}return r[o]}function Ft(e,t,n=3){let o,r=n+1;for(const n of t){const t=$t(e.toLowerCase(),n.toLowerCase());r>t&&(r=t,o=n)}return r>n?void 0:o}function It(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function Wt(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=Ft(e,t,3))&&void 0!==n?n:null)}function Dt({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=It(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[r,i]of Object.entries(n))if(i&&"string"==typeof i&&!(i in o)){const n=Wt(i,t),o=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}const Tt={width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},frameProps:{type:"object"}},Rt={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},Gt={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"}},qt=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],Yt=["vertical","horizontal"],Xt={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Tt),Rt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:qt},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},fillArea:{type:"boolean"},areaOpacity:{type:"number"}})},AreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Tt),Rt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:qt},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Tt),Rt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:qt},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},normalize:{type:"boolean"}})},Scatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Tt),Rt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},BubbleChart:{required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Tt),Rt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},bubbleOpacity:{type:"number"},bubbleStrokeWidth:{type:"number"},bubbleStrokeColor:{type:"string"}})},Heatmap:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Tt),Rt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},colorScheme:{type:"string",enum:["blues","reds","greens","viridis","custom"]},customColorScale:{type:["object","function"]},showValues:{type:"boolean"},valueFormat:{type:"function"},cellBorderColor:{type:"string"},cellBorderWidth:{type:"number"},showLegend:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},QuadrantChart:{required:["quadrants"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Tt),Rt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},quadrants:{type:"object"},xCenter:{type:"number"},yCenter:{type:"number"},centerlineStyle:{type:"object"},showQuadrantLabels:{type:"boolean"},quadrantLabelSize:{type:"number"},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},MultiAxisLineChart:{required:["series"],dataShape:"array",dataAccessors:["xAccessor"],props:Object.assign(Object.assign(Object.assign({},Tt),Rt),{data:{type:"array"},xAccessor:{type:["string","function"]},series:{type:"array"},colorScheme:{type:["string","array"]},curve:{type:"string"},lineWidth:{type:"number"},annotations:{type:"array"}})},ConnectedScatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Tt),Rt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},orderAccessor:{type:["string","function"]},orderLabel:{type:"string"},pointRadius:{type:"number"},pointIdAccessor:{type:["string","function"]},annotations:{type:"array"}})},BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Tt),Gt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Yt},sort:{type:["boolean","string","function"]},barPadding:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Tt),Gt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Yt},normalize:{type:"boolean"},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Tt),Gt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Yt},barPadding:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Tt),Gt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Yt},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"}})},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Tt),Gt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Yt},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Tt),Gt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"}})},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Tt),Gt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Yt},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"}})},RidgelinePlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Tt),Gt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},amplitude:{type:"number"},categoryPadding:{type:"number"}})},DotPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Tt),Gt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Yt},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},Tt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"},slicePadding:{type:"number"}})},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},Tt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"},slicePadding:{type:"number"}})},FunnelChart:{required:["data"],dataShape:"array",dataAccessors:["stepAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Tt),Gt),{data:{type:"array"},stepAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},connectorOpacity:{type:"number"},showCategoryTicks:{type:"boolean"},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},ForceDirectedGraph:{required:["nodes","edges"],dataShape:"network",dataAccessors:["nodeIDAccessor","sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Tt),{nodes:{type:"array"},edges:{type:"array"},nodeIDAccessor:{type:["string","function"]},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},nodeLabel:{type:["string","function"]},nodeSize:{type:["number","string","function"]},nodeSizeRange:{type:"array"},edgeWidth:{type:["number","string","function"]},edgeColor:{type:"string"},edgeOpacity:{type:"number"},iterations:{type:"number"},forceStrength:{type:"number"},showLabels:{type:"boolean"}})},SankeyDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Tt),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target","gradient"]},orientation:{type:"string",enum:Yt},nodeAlign:{type:"string",enum:["justify","left","right","center"]},nodePaddingRatio:{type:"number"},nodeWidth:{type:"number"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"},edgeSort:{type:"function"}})},ChordDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Tt),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target"]},padAngle:{type:"number"},groupWidth:{type:"number"},sortGroups:{type:"function"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"}})},TreeDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Tt),{data:{type:"object"},layout:{type:"string",enum:["tree","cluster","partition","treemap","circlepack"]},orientation:{type:"string",enum:["vertical","horizontal","radial"]},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},edgeStyle:{type:"string",enum:["line","curve"]},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},nodeSize:{type:"number"}})},Treemap:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Tt),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]}})},CirclePack:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Tt),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]},circleOpacity:{type:"number"}})},OrbitDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Tt),{data:{type:"object"},childrenAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},orbitMode:{type:["string","array"]},speed:{type:"number"},revolution:{type:"function"},eccentricity:{type:["number","function"]},orbitSize:{type:["number","function"]},nodeRadius:{type:["number","function"]},showRings:{type:"boolean"},showLabels:{type:"boolean"},animated:{type:"boolean"},colorByDepth:{type:"boolean"},annotations:{type:"array"},foregroundGraphics:{type:"object"}})},RealtimeLineChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},stroke:{type:"string"},strokeWidth:{type:"number"},strokeDasharray:{type:"string"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHistogram:{required:["binSize"],dataShape:"realtime",dataAccessors:[],props:{binSize:{type:"number"},size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeSwarmChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},radius:{type:"number"},fill:{type:"string"},opacity:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeWaterfallChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},positiveColor:{type:"string"},negativeColor:{type:"string"},connectorStroke:{type:"string"},connectorWidth:{type:"number"},gap:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHeatmap:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},heatmapXBins:{type:"number"},heatmapYBins:{type:"number"},aggregation:{type:"string",enum:["count","sum","mean"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"}}}};function Vt(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}const Ut=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),Qt=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),Kt=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),Zt=new Set(["LineChart","AreaChart","StackedAreaChart"]),Jt=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]);function en(e){const t=e.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(!t)return null;const[n,o,r]=[parseInt(t[1],16)/255,parseInt(t[2],16)/255,parseInt(t[3],16)/255],i=e=>e>.03928?Math.pow((e+.055)/1.055,2.4):e/12.92;return.2126*i(n)+.7152*i(o)+.0722*i(r)}function tn(e,t){const n=en(e),o=en(t);return null===n||null===o?null:(Math.max(n,o)+.05)/(Math.min(n,o)+.05)}const nn=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIDAccessor","childrenAccessor","costAccessor"];function on(e,t){const n=[],o=function(e,t){const n=[],o=Xt[e];if(!o)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(Xt).join(", ")}`]};for(const r of o.required)null==t[r]&&n.push(`"${r}" is required for ${e}.`);for(const[e,r]of Object.entries(t)){if(null==r)continue;const t=o.props[e];if(t){if(!Vt(r,t.type)){const o=Array.isArray(t.type)?t.type.join(" | "):t.type;n.push(`"${e}" should be ${o}, got ${Array.isArray(r)?"array":typeof r}.`);continue}t.enum&&"string"==typeof r&&!t.enum.includes(r)&&n.push(`"${e}" value "${r}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const r=Object.keys(o.props),i=new Set(r);for(const o of Object.keys(t))if(void 0!==t[o]&&!i.has(o)){const t=Ft(o,r),i=t?`Unknown prop "${o}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${o}" for ${e}. Valid props: ${r.join(", ")}.`;n.push(i)}if("array"===o.dataShape){const r=t.data,i={};for(const e of o.dataAccessors){const n=t[e];"string"==typeof n&&(i[e]=n)}const s=Dt({componentName:e,data:r,accessors:Object.keys(i).length>0?i:void 0});s&&n.push(s)}else if("object"===o.dataShape){const o=function({componentName:e,data:t,dataLabel:n="data"}){return null==t?`${e}: No ${n} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${n} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}({componentName:e,data:t.data});o&&n.push(o)}else if("network"===o.dataShape){const r=function({componentName:e,nodes:t,edges:n,nodesRequired:o=!1,edgesRequired:r=!0,accessors:i}){if(null==t&&null==n)return null;if(r&&(!n||!Array.isArray(n)||0===n.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(o&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){const n=It(t).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[o,r]of Object.entries(i))if(r&&"string"==typeof r&&!(r in n)){const n=Wt(r,t),i=n?` Try ${o}="${n}".`:"";return`${e}: ${o} "${r}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}return null}({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:o.required.includes("nodes"),edgesRequired:o.required.includes("edges")});r&&n.push(r)}return{valid:0===n.length,errors:n}}(e,t);for(const e of o.errors)n.push({severity:"error",code:"VALIDATION",message:e,fix:""});return Xt[e]?(function(e,t,n){const o=Xt[e];if(o){if("array"===o.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&n.push({severity:"error",code:"EMPTY_DATA",message:"data is an empty array — chart will render blank.",fix:"Provide at least one data point: data={[{ x: 1, y: 2 }]}."})}"network"===o.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&n.push({severity:"error",code:"EMPTY_EDGES",message:"edges is an empty array — network chart will render blank.",fix:'Provide at least one edge: edges={[{ source: "A", target: "B" }]}.'})}}(e,t,n),function(e,t,n){const o=t.width,r=t.height;if(void 0===o||"number"==typeof o&&o>0||n.push({severity:"error",code:"BAD_WIDTH",message:`width=${JSON.stringify(o)} — chart needs a positive number.`,fix:"Set width={600} or use responsiveWidth={true}."}),void 0===r||"number"==typeof r&&r>0||n.push({severity:"error",code:"BAD_HEIGHT",message:`height=${JSON.stringify(r)} — chart needs a positive number.`,fix:"Set height={400} or use responsiveHeight={true}."}),t.size&&Array.isArray(t.size)){const[e,o]=t.size;(null!=e&&0>=e||null!=o&&0>=o)&&n.push({severity:"error",code:"BAD_SIZE",message:`size=[${e}, ${o}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}(0,t,n),function(e,t,n){const o=Xt[e];if(!o||"array"!==o.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const i=r[0];if(!i||"object"!=typeof i)return;const s=Object.keys(i);for(const e of o.dataAccessors){const o=t[e];"string"==typeof o&&(o in i||n.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${o}" not found in data. Available fields: ${s.join(", ")}.`,fix:`Change ${e} to one of: ${s.map(e=>`"${e}"`).join(", ")}.`}))}}(e,t,n),function(e,t,n){Ut.has(e)&&Array.isArray(t.data)&&n.push({severity:"error",code:"HIERARCHY_FLAT_ARRAY",message:e+" expects hierarchical data but received a flat array.",fix:'Pass a root object: data={{ name: "root", children: [...] }}. For flat data, use BarChart or LineChart.'})}(e,t,n),function(e,t,n){Qt.has(e)&&(t.edges||t.data||n.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}(e,t,n),function(e,t,n){const o=Xt[e];if(!o||"array"!==o.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const i=r[0];if(!i||"object"!=typeof i)return;const s=t.xAccessor;"string"==typeof s&&i[s]instanceof Date&&!t.xFormat&&n.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${s}" contains Date objects but no xFormat is provided. Axis ticks may display "[object Object]".`,fix:"Add xFormat={d => d.toLocaleDateString()} or use timestamps (d.getTime()) instead of Date objects."})}(e,t,n),function(e,t,n){t.linkedHover&&!t.selection&&n.push({severity:"warning",code:"LINKED_HOVER_NO_SELECTION",message:"linkedHover is set but selection is not — this chart emits hover events but won't highlight from others.",fix:`Add selection={{ name: "${"object"==typeof t.linkedHover&&t.linkedHover.name||"hl"}" }} to receive cross-highlights.`})}(0,t,n),function(e,t,n){var o;if(!Kt.has(e))return;const r=t.rExtent||t.yExtent;r&&Array.isArray(r)&&r.length>=1&&null!=r[0]&&0!==r[0]&&n.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${r[0]}). Bar and area charts should start at zero to avoid exaggerating differences.`,fix:`Remove the custom extent minimum or set it to 0: rExtent={[0, ${null!==(o=r[1])&&void 0!==o?o:"auto"}]}. For trend-focused charts, use LineChart instead.`})}(e,t,n),function(e,t,n){if(!Zt.has(e))return;if(t.gapStrategy)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const r=t.yAccessor||"y";"string"==typeof r&&o.some(e=>{const t=e[r];return null==t||Number.isNaN(t)})&&n.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${r}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}(e,t,n),function(e,t,n){var o,r;const i=null!==(o=t.width)&&void 0!==o?o:600,s=null!==(r=t.height)&&void 0!==r?r:400,a=t.margin;if(!a||"object"!=typeof a)return;const l=(a.left||0)+(a.right||0),c=(a.top||0)+(a.bottom||0);i>l||n.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${l}px) >= width (${i}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),s>c||n.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${c}px) >= height (${s}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}(0,t,n),function(e,t,n){var o;const r=Xt[e];if(!r||"array"!==r.dataShape)return;const i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;const s=[];t.xAccessor&&"string"==typeof t.xAccessor&&s.push({prop:"xAccessor",name:t.xAccessor}),t.yAccessor&&"string"==typeof t.yAccessor&&s.push({prop:"yAccessor",name:t.yAccessor}),t.valueAccessor&&"string"==typeof t.valueAccessor&&s.push({prop:"valueAccessor",name:t.valueAccessor});const a=Math.min(i.length,5);for(const e of s){let t=!0;for(let n=0;a>n;n++){const r=null===(o=i[n])||void 0===o?void 0:o[e.name];if("number"==typeof r&&Number.isFinite(r)){t=!1;break}}t&&n.push({severity:"error",code:"DEGENERATE_EXTENT",message:`${e.prop}="${e.name}" produces NaN or non-finite values for all sampled data points — chart extents will be invalid.`,fix:`Ensure data[].${e.name} contains finite numbers, or use a function accessor to transform values.`})}}(e,t,n),function(e,t,n){if(!Jt.has(e))return;const o=t.barPadding;"number"==typeof o&&10>o&&n.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${o} is very small — bars may appear to have no spacing between them.`,fix:"Increase barPadding to at least 10 for visible gaps, e.g. barPadding={12}."})}(e,t,n),function(e,t,n){if("bottom"!==t.legendPosition)return;const o=t.margin;if(!o||"object"!=typeof o)return;const r=o.bottom;"number"==typeof r&&70>r&&n.push({severity:"warning",code:"BOTTOM_MARGIN_WITH_LEGEND",message:`legendPosition="bottom" with margin.bottom=${r}px — legend may overlap axis labels.`,fix:"Increase margin.bottom to at least 70, e.g. margin={{ ...margin, bottom: 80 }}."})}(0,t,n),function(e,t,n){var o;if(!t.showLegend)return;if("right"!==(null!==(o=t.legendPosition)&&void 0!==o?o:"right"))return;const r=t.margin;if(!r||"object"!=typeof r)return;const i=r.right;"number"==typeof i&&100>i&&n.push({severity:"warning",code:"LEGEND_MARGIN_TIGHT",message:`showLegend is true with legendPosition="right" but margin.right=${i}px — legend may be clipped or overlap the chart.`,fix:"Increase margin.right to at least 100, e.g. margin={{ ...margin, right: 120 }}."})}(0,t,n),function(e,t,n){if("Heatmap"!==e)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const r=o[0];if(r&&"object"==typeof r)for(const e of["xAccessor","yAccessor"]){const o=t[e];if("string"!=typeof o)continue;const i=r[o];"string"==typeof i&&n.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${o}" resolves to string values (e.g. "${i}"). Heatmap will use categorical axis handling which may produce unexpected cell layout.`,fix:"If you intend categorical axes this is fine. Otherwise, convert values to numbers before passing data."})}}(e,t,n),function(e,t,n){const o=t.colorScheme;if(!o||!Array.isArray(o))return;const r="string"==typeof t.background?t.background:"#ffffff";if(!r.startsWith("#"))return;const i=[];for(const e of o){if("string"!=typeof e||!e.startsWith("#"))continue;const t=tn(e,r);null!==t&&3>t&&i.push(`${e} (${t.toFixed(1)}:1)`)}i.length>0&&n.push({severity:"warning",code:"LOW_COLOR_CONTRAST",message:`${i.length} color(s) in colorScheme have < 3:1 contrast against background "${r}": ${i.join(", ")}. Data marks may be hard to see.`,fix:'Use darker colors on light backgrounds or lighter colors on dark backgrounds. Import COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for an accessible preset.'})}(0,t,n),function(e,t,n){const o=[];for(const e of nn)"function"==typeof t[e]&&o.push(e);o.length>0&&n.push({severity:"warning",code:"FUNCTION_ACCESSOR",message:`Function accessor${o.length>1?"s":""} detected: ${o.join(", ")}. If defined inline (e.g. \`xAccessor={d => d.value}\`), every parent re-render creates a new reference which may trigger unnecessary scene rebuilds.`,fix:'Use string accessors when possible (e.g. xAccessor="value"), or memoize with useCallback / define outside the component.'})}(0,t,n),{ok:n.every(e=>"warning"===e.severity),diagnoses:n}):{ok:0===n.length,diagnoses:n}}var rn;const sn="undefined"!=typeof process&&"production"!==(null===(rn=process.env)||void 0===rn?void 0:rn.NODE_ENV);function an({componentName:e,width:t,height:n,chartProps:o,children:r}){return d.createElement(zt,{fallback:r=>{let i="";if(sn&&o)try{const t=on(e,o);t.ok||(i=t.diagnoses.map(e=>`${"error"===e.severity?"✗":"⚠"} ${e.message}${e.fix?" — Fix: "+e.fix:""}`).join("\n"))}catch(e){}return d.createElement(Ht,{componentName:e,message:r.message,diagnosticHint:i,width:t,height:n})}},r)}const ln={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"},cn={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function un(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({},ln),{width:t,height:n})},o||"No data available"):null}function hn(e,t,n){if(!e)return null;const o=Math.min(5,Math.floor(n/40)),r=Math.max(8,Math.floor(n/(3*o))),i=Math.max(6,Math.floor(n/(2.5*o))),s=Math.floor((n-(o*(r+i)-i))/2);return d.createElement("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:o},(e,n)=>d.createElement("div",{key:n,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},cn),{position:"absolute",top:s+n*(r+i),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:r,opacity:.5+n%2*.2})})))}function dn(e,t,n,o){if(!sn)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const r=t[0];if(!r||"object"!=typeof r)return;if(o in r)return;const i=Object.keys(r).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${i}`)}function gn(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const pn="__forecastSegment";let yn=null;function fn(){return gn(this,void 0,void 0,function*(){return yn||(yn=yield Promise.resolve().then(function(){return Xn})),yn})}const mn=e.forwardRef(function(t,n){var o,r;const i=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const s=St(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:a,margin:l,className:c,xFormat:u,yFormat:h,xAccessor:g="x",yAccessor:p="y",lineBy:y,lineDataAccessor:f="coordinates",colorBy:m,colorScheme:b="category10",curve:v="linear",showPoints:x=!1,pointRadius:k=3,fillArea:w=!1,areaOpacity:A=.3,lineWidth:S=2,tooltip:O,pointIdAccessor:M,annotations:j,directLabel:E,gapStrategy:C="break",anomaly:P,forecast:L,frameProps:B={},selection:N,linkedHover:H,onObservation:z,chartId:$,loading:F,emptyContent:I,legendInteraction:W,legendPosition:D,xScaleType:T,yScaleType:R}=t,G=s.width,q=s.height,Y=s.enableHover,X=s.showGrid,V=s.showLegend,U=s.title,Q=s.xLabel,K=s.yLabel,Z=hn(F,G,q),J=Z?null:un(a,G,q,I),ee=a||[];dn("LineChart",ee,"xAccessor",g),dn("LineChart",ee,"yAccessor",p);const te="string"==typeof g?g:"__semiotic_resolvedX",ne="string"==typeof p?p:"__semiotic_resolvedY",[oe,re]=e.useState(null),[ie,se]=e.useState([]),ae=e.useMemo(()=>{if(!L&&!P)return ee;const e="function"==typeof g,t="function"==typeof p;return e||t?ee.map(n=>{const o=Object.assign({},n);return e&&(o.__semiotic_resolvedX=g(n)),t&&(o.__semiotic_resolvedY=p(n)),o}):ee},[ee,L,P,g,p]);e.useEffect(()=>{if(!L&&!P)return;let e=!1;if(re(null),se([]),L){const t=y&&"string"==typeof y&&"object"==typeof L?Object.assign(Object.assign({},L),{_groupBy:y}):L;(function(...e){return gn(this,void 0,void 0,function*(){return(yield fn()).buildForecast(...e)})})(ae,te,ne,t,P).then(t=>{e||(re(t),se(t.annotations))}).catch(()=>{e||(re(null),se([]))})}else P&&function(...e){return gn(this,void 0,void 0,function*(){return(yield fn()).buildAnomalyAnnotations(...e)})}(P).then(t=>{e||(re(null),se(t))}).catch(()=>{e||se([])});return()=>{e=!0}},[ae,L,P,te,ne]);const le=oe?oe.processedData:ee,ce="__compoundGroup",ue=!(!L||!y),he=ue?ce:L?pn:y,de=e.useMemo(()=>{if(!ue)return le;const e="function"==typeof y?y:e=>e[y];return le.map(t=>{const n=Object.assign({},t);return n[ce]=`${e(t)}__${t[pn]||"observed"}`,n})},[le,ue,y]),ge=ue?de:le,pe=e.useMemo(()=>{if(!L)return;const e=L.upperBounds,t=L.lowerBounds;if(!e&&!t)return;const n="function"==typeof e?e:"string"==typeof e?t=>t[e]:null,o="function"==typeof t?t:"string"==typeof t?e=>e[t]:null;let r=1/0,i=-1/0;const s=oe?oe.processedData:ee;for(const e of s){const t="function"==typeof p?p(e):+e[p];if(isFinite(t)&&(r>t&&(r=t),t>i&&(i=t)),n){const t=n(e);null!=t&&isFinite(t)&&(t>i&&(i=t),r>t&&(r=t))}if(o){const t=o(e);null!=t&&isFinite(t)&&(r>t&&(r=t),t>i&&(i=t))}}return isFinite(r)&&isFinite(i)?[r,i]:void 0},[L,oe,ee,p]),{activeSelectionHook:ye,customHoverBehavior:fe}=xt({selection:N,linkedHover:H,fallbackFields:m?["string"==typeof m?m:""]:[],onObservation:z,chartType:"LineChart",chartId:$}),me=e.useCallback(e=>{const t="function"==typeof g?g(e):e[g],n="function"==typeof p?p(e):e[p];return null==t||null==n||Number.isNaN(t)||Number.isNaN(n)},[g,p]),be=void 0!==(null===(o=ge[0])||void 0===o?void 0:o[f]),ve=e.useMemo(()=>{if(be)return ge;if(he){const e=ge.reduce((e,t)=>{const n="function"==typeof he?he(t):t[he];if(!e[n]){const o={[f]:[]};"string"==typeof he&&(o[he]=n),ue&&(o[pn]=t[pn],"string"==typeof y&&(o[y]=t[y])),e[n]=o}return e[n][f].push(t),e},{});return Object.values(e)}return[{[f]:ge}]},[ge,he,f,be]),{gapProcessedLineData:xe,hasGaps:ke}=e.useMemo(()=>{if("interpolate"===C){let e=!1;const t=[];for(const n of ve){const o=(n[f]||[]).filter(t=>!me(t)||(e=!0,!1));o.length>0&&t.push(Object.assign(Object.assign({},n),{[f]:o}))}return{gapProcessedLineData:t,hasGaps:e}}if("break"===C){let e=!1;const t=[];for(const n of ve){const o=n[f]||[];let r=[],i=0;const s=he&&"string"==typeof he?n[he]:void 0;for(const a of o)if(me(a))e=!0,r.length>0&&(t.push(Object.assign(Object.assign({},n),{[f]:r})),r=[],i++);else{const e=null!=s?`${s}__seg${i}`:"__seg"+i;r.push(Object.assign(Object.assign({},a),{_gapSegment:e}))}r.length>0&&t.push(Object.assign(Object.assign({},n),{[f]:r}))}return{gapProcessedLineData:t,hasGaps:e}}if("zero"===C){let e=!1;const t="string"==typeof p?p:"y",n=[];for(const o of ve){const r=o[f]||[],i=[];for(const n of r)me(n)?(e=!0,i.push(Object.assign(Object.assign({},n),{[t]:0}))):i.push(n);n.push(Object.assign(Object.assign({},o),{[f]:i}))}return{gapProcessedLineData:n,hasGaps:e}}return{gapProcessedLineData:ve,hasGaps:!1}},[ve,C,f,me,he,p]),we=vt(le,m,b),Ae=e.useMemo(()=>{if(!m)return[];const e=new Set;for(const t of le){const n="function"==typeof m?m(t):t[m];null!=n&&e.add(n+"")}return Array.from(e)},[le,m]),Se=wt(W,m,Ae),Oe=e.useMemo(()=>Se.legendSelectionHook?Se.legendSelectionHook:ye,[Se.legendSelectionHook,ye]),Me=e.useMemo(()=>e=>{const t={strokeWidth:S};return m?we&&(t.stroke=_(e,m,we),w&&(t.fill=t.stroke,t.fillOpacity=A)):(t.stroke=mt,w&&(t.fill=mt,t.fillOpacity=A)),t},[m,we,S,w,A]),[je,Ee]=e.useState(null);e.useEffect(()=>{if(!L)return void Ee(null);let e=!1;return function(...e){return gn(this,void 0,void 0,function*(){return(yield fn()).createSegmentLineStyle(...e)})}(Me,L).then(t=>{e||Ee(()=>t)}).catch(()=>{e||Ee(null)}),()=>{e=!0}},[Me,L]);const Ce=je||Me,Pe=e.useMemo(()=>ft(Ce,Oe,N),[Ce,Oe,N]),_e=e.useMemo(()=>{if(x)return e=>{const t={r:k,fillOpacity:1};return m?we&&(t.fill=_(e.parentLine||e,m,we)):t.fill=mt,t}},[x,k,m,we]),Le=w?"area":"line",Be="object"==typeof E?E:{},Ne=Be.position||"end",He=Be.fontSize||11,ze=e.useMemo(()=>{var e,t;if(!E||!m)return[];const n="function"==typeof g?g:e=>e[g],o="function"==typeof p?p:e=>e[p],r="function"==typeof m?m:e=>e[m],i=new Map;for(const n of xe){const o=n[f]||[];if(0===o.length)continue;const s="end"===Ne?o[o.length-1]:o[0],a=null!==(t=null!==(e=r(s))&&void 0!==e?e:r(n))&&void 0!==t?t:"";a&&!i.has(a+"")&&i.set(a+"",s)}const s=Array.from(i.entries()).map(([e,t])=>({type:"text",label:e,["string"==typeof g?g:"x"]:n(t),["string"==typeof p?p:"y"]:o(t),dx:"end"===Ne?6:-6,dy:0,color:we?we(e):mt,fontSize:He}));s.sort((e,t)=>{const n="string"==typeof p?p:"y";return e[n]-t[n]});for(let e=1;s.length>e;e++){const t="string"==typeof p?p:"y",n=s[e-1],o=s[e];He+2>Math.abs(o[t]+o.dy-(n[t]+n.dy))&&(o.dy+=He+2)}return s},[E,m,we,xe,f,g,p,Ne,He]),$e=(!E||void 0!==V)&&V,Fe=e.useMemo(()=>{if(!E)return s.marginDefaults;const e=ze.reduce((e,t)=>{var n;const o=((null===(n=t.label)||void 0===n?void 0:n.length)||0)*(.6*He);return Math.max(e,o)},0),t=e+10,n="end"===Ne?"right":"left";return Object.assign(Object.assign({},s.marginDefaults),{[n]:Math.max(s.marginDefaults[n]||0,t)})},[E,ze,He,Ne,s.marginDefaults]),{legend:Ie,margin:We,legendPosition:De}=kt({data:xe,colorBy:m,colorScale:we,showLegend:$e,legendPosition:D,userMargin:l,defaults:Fe}),Te=y||m,Re=e.useMemo(()=>Nt([{label:Q||_t(g),accessor:g,role:"x"},{label:K||_t(p),accessor:p,role:"y"},...Te?[{label:_t(Te),accessor:Te,role:"group"}]:[]]),[g,p,Q,K,Te]),Ge=Dt({componentName:"LineChart",data:be?(null===(r=le[0])||void 0===r?void 0:r[f])||[]:a,accessors:{xAccessor:g,yAccessor:p}}),qe=e.useMemo(()=>be||he||ke?xe.flatMap(e=>{const t=e[f]||[];return he&&"string"==typeof he?t.map(t=>Object.assign(Object.assign({},t),{[he]:e[he]})):t}):ge,[xe,f,be,he,ge,ke]),Ye=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(Object.assign({chartType:Le},null!=a&&{data:qe}),{xAccessor:g,yAccessor:p,xScaleType:T,yScaleType:R}),pe&&{yExtent:pe}),{groupAccessor:"break"===C&&ke?"_gapSegment":he||void 0,curve:v,lineStyle:Pe}),x&&{pointStyle:_e}),{size:[G,q],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:We,showAxes:s.showAxes,xLabel:Q,yLabel:K,xFormat:u,yFormat:h,enableHover:Y,showGrid:X}),Ie&&{legend:Ie,legendPosition:De}),W&&"none"!==W&&{legendHoverBehavior:Se.onLegendHover,legendClickBehavior:Se.onLegendClick,legendHighlightedCategory:Se.highlightedCategory,legendIsolatedCategories:Se.isolatedCategories}),U&&{title:U}),c&&{className:c}),{tooltipContent:!1===O?()=>null:Pt(O)||Re}),(H||z)&&{customHoverBehavior:fe}),M&&{pointIdAccessor:M}),((null==j?void 0:j.length)||ie.length||ze.length)&&{annotations:[...j||[],...ie,...ze]}),B);return Z||J||(Ge?d.createElement(Ht,{componentName:"LineChart",message:Ge,width:G,height:q}):d.createElement(an,{componentName:"LineChart",width:G,height:q},d.createElement(Ze,Object.assign({ref:i},Ye))))});mn.displayName="LineChart";const bn=e.forwardRef(function(t,n){var o;const r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const i=St(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:h="x",yAccessor:g="y",areaBy:p,y0Accessor:y,gradientFill:f=!1,lineDataAccessor:m="coordinates",colorBy:b,colorScheme:v="category10",curve:x="monotoneX",areaOpacity:k=.7,showLine:w=!0,lineWidth:A=2,tooltip:S,annotations:O,frameProps:M={},selection:j,linkedHover:E,onObservation:C,chartId:P,loading:L,emptyContent:B,legendInteraction:N,legendPosition:H}=t,z=i.width,$=i.height,F=i.enableHover,I=i.showGrid,W=i.showLegend,D=i.title,T=i.xLabel,R=i.yLabel,G=hn(L,z,$),q=G?null:un(s,z,$,B),Y=s||[];dn("AreaChart",Y,"xAccessor",h),dn("AreaChart",Y,"yAccessor",g);const{activeSelectionHook:X,customHoverBehavior:V}=xt({selection:j,linkedHover:E,fallbackFields:b?["string"==typeof b?b:""]:[],onObservation:C,chartType:"AreaChart",chartId:P}),U=void 0!==(null===(o=Y[0])||void 0===o?void 0:o[m]),Q=e.useMemo(()=>{if(U)return Y;if(p){const e=Y.reduce((e,t)=>{const n="function"==typeof p?p(t):t[p];if(!e[n]){const t={[m]:[]};"string"==typeof p&&(t[p]=n),e[n]=t}return e[n][m].push(t),e},{});return Object.values(e)}return[{[m]:Y}]},[Y,p,m,U]),K=vt(Y,b,v),Z=e.useMemo(()=>{if(!b)return[];const e=new Set;for(const t of Y){const n="function"==typeof b?b(t):t[b];null!=n&&e.add(n+"")}return Array.from(e)},[Y,b]),J=wt(N,b,Z),ee=e.useMemo(()=>J.legendSelectionHook?J.legendSelectionHook:X,[J.legendSelectionHook,X]),te=e.useMemo(()=>e=>{const t={};if(b){if(K){const n=_(e,b,K);t.fill=n,w?(t.stroke=n,t.strokeWidth=A):t.stroke="none"}}else t.fill=mt,w?(t.stroke=mt,t.strokeWidth=A):t.stroke="none";return t.fillOpacity=k,t},[b,K,k,w,A]),ne=e.useMemo(()=>ft(te,ee,j),[te,ee,j]),{legend:oe,margin:re,legendPosition:ie}=kt({data:Q,colorBy:b,colorScale:K,showLegend:W,legendPosition:H,userMargin:a,defaults:i.marginDefaults}),se=p||b,ae=e.useMemo(()=>Nt([{label:T||_t(h),accessor:h,role:"x"},{label:R||_t(g),accessor:g,role:"y"},...se?[{label:_t(se),accessor:se,role:"group"}]:[]]),[h,g,T,R,se]),le=Dt({componentName:"AreaChart",data:s,accessors:{xAccessor:h,yAccessor:g}}),ce=e.useMemo(()=>U||p?Q.flatMap(e=>{const t=e[m]||[];return p&&"string"==typeof p?t.map(t=>Object.assign(Object.assign({},t),{[p]:e[p]})):t}):Y,[Q,m,U,p,Y]),ue=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area"},null!=s&&{data:ce}),{xAccessor:h,yAccessor:g,groupAccessor:p||void 0}),y&&{y0Accessor:y}),f&&{gradientFill:f}),{curve:x,lineStyle:ne,size:[z,$],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:re,showAxes:i.showAxes,xLabel:T,yLabel:R,xFormat:c,yFormat:u,enableHover:F,showGrid:I}),oe&&{legend:oe,legendPosition:ie}),N&&"none"!==N&&{legendHoverBehavior:J.onLegendHover,legendClickBehavior:J.onLegendClick,legendHighlightedCategory:J.highlightedCategory,legendIsolatedCategories:J.isolatedCategories}),D&&{title:D}),l&&{className:l}),{tooltipContent:!1===S?()=>null:Pt(S)||ae}),(E||C)&&{customHoverBehavior:V}),O&&O.length>0&&{annotations:O}),M);return G||q||(le?d.createElement(Ht,{componentName:"AreaChart",message:le,width:z,height:$}):d.createElement(an,{componentName:"AreaChart",width:z,height:$},d.createElement(Ze,Object.assign({ref:r},ue))))});function vn({isPushMode:t,colorBy:n,colorScheme:o,showLegend:r,legendPosition:i="right"}){const s=e.useRef(new Set),a=e.useRef([]),[l,c]=e.useState(0),u=e.useCallback(e=>{if(!n)return null;const t="function"==typeof n?n(e):e[n];return null!=t?t+"":null},[n]),h=e.useCallback(e=>{if(!t||!n)return;let o=!1;for(const t of e){if(!t||"object"!=typeof t)continue;const e=u(t);null==e||s.current.has(e)||(s.current.add(e),a.current.push(e),o=!0)}o&&c(e=>e+1)},[t,n,u]),d=e.useCallback(e=>t=>{h([t]),e(t)},[h]),g=e.useCallback(e=>t=>{h(t),e(t)},[h]),p=e.useCallback(()=>{s.current=new Set,a.current=[],c(e=>e+1)},[]),y=e.useMemo(()=>{if(!t||!n||!1===r)return;const e=a.current;if(0===e.length)return;const i=Array.isArray(o)?o:C,s=new Map;for(let t=0;e.length>t;t++)s.set(e[t],i[t%i.length]);const l="string"==typeof n?n:"__streamCat";return pt({data:e.map(e=>({[l]:e})),colorBy:l,colorScale:e=>s.get(e)||"#999",getColor:_})},[t,n,r,o,l]),f=e.useMemo(()=>{if(y)return"right"===i?{right:110}:"left"===i?{left:110}:"top"===i?{top:50}:"bottom"===i?{bottom:80}:{right:110}},[y,i]);return{wrapPush:d,wrapPushMany:g,resetCategories:p,streamingLegend:y,streamingMarginAdjust:f}}bn.displayName="AreaChart";const xn=e.forwardRef(function(t,n){var o;const r=e.useRef(null),i=St(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:h="x",yAccessor:g="y",areaBy:p,lineDataAccessor:y="coordinates",colorBy:f,colorScheme:m="category10",curve:b="monotoneX",areaOpacity:v=.7,showLine:x=!0,lineWidth:k=2,normalize:w=!1,tooltip:A,annotations:S,frameProps:O={},selection:M,linkedHover:j,onObservation:E,chartId:C,loading:P,emptyContent:L,legendInteraction:B,legendPosition:N}=t,H=i.width,z=i.height,$=i.enableHover,F=i.showGrid,I=i.showLegend,W=i.title,D=i.xLabel,T=i.yLabel,R=hn(P,H,z),G=R?null:un(s,H,z,L),q=s||[],Y=vn({isPushMode:void 0===s,colorBy:f||p,colorScheme:m,showLegend:I,legendPosition:N}),X=e.useCallback(Y.wrapPush(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)}),[Y.wrapPush]),V=e.useCallback(Y.wrapPushMany(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)}),[Y.wrapPushMany]);e.useImperativeHandle(n,()=>({push:X,pushMany:V,clear:()=>{var e;Y.resetCategories(),null===(e=r.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}),[X,V,Y.resetCategories]);const{activeSelectionHook:U,customHoverBehavior:Q}=xt({selection:M,linkedHover:j,fallbackFields:f?["string"==typeof f?f:""]:[],onObservation:E,chartType:"StackedAreaChart",chartId:C}),K=void 0!==(null===(o=q[0])||void 0===o?void 0:o[y]),Z=e.useMemo(()=>{if(K)return q;if(p){const e=q.reduce((e,t)=>{const n="function"==typeof p?p(t):t[p];if(!e[n]){const t={[y]:[]};"string"==typeof p&&(t[p]=n),e[n]=t}return e[n][y].push(t),e},{});return Object.values(e)}return[{[y]:q}]},[q,p,y,K]),J=vt(q,f,m),ee=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of q){const n="function"==typeof f?f(t):t[f];null!=n&&e.add(n+"")}return Array.from(e)},[q,f]),te=wt(B,f,ee),ne=e.useMemo(()=>te.legendSelectionHook?te.legendSelectionHook:U,[te.legendSelectionHook,U]),oe=e.useMemo(()=>e=>{const t={};if(f&&J){const n=_(e,f,J);t.fill=n,x?(t.stroke=n,t.strokeWidth=k):t.stroke="none"}else f||(t.fill=mt,t.stroke=x?mt:"none",x&&(t.strokeWidth=k));return t.fillOpacity=v,t},[f,J,v,x,k]),re=e.useMemo(()=>ft(oe,ne,M),[oe,ne,M]),{legend:ie,margin:se,legendPosition:ae}=kt({data:Z,colorBy:f,colorScale:J,showLegend:I,legendPosition:N,userMargin:a,defaults:i.marginDefaults}),le=Y.streamingLegend||ie,ce=N||ae,ue=e.useMemo(()=>{if(Y.streamingMarginAdjust){const e=Object.assign({},se);for(const[t,n]of Object.entries(Y.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return se},[se,Y.streamingMarginAdjust]),he=p||f,de=e.useMemo(()=>Nt([{label:D||_t(h),accessor:h,role:"x"},{label:T||_t(g),accessor:g,role:"y"},...he?[{label:_t(he),accessor:he,role:"group"}]:[]]),[h,g,D,T,he]),ge=Dt({componentName:"StackedAreaChart",data:s,accessors:{xAccessor:h,yAccessor:g}}),pe=e.useMemo(()=>K||p?Z.flatMap(e=>{const t=e[y]||[];return p&&"string"==typeof p?t.map(t=>Object.assign(Object.assign({},t),{[p]:e[p]})):t}):q,[Z,y,K,p,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!=s&&{data:pe}),{xAccessor:h,yAccessor:g,groupAccessor:p||void 0,curve:b,normalize:w,lineStyle:re,size:[H,z],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ue,showAxes:i.showAxes,xLabel:D,yLabel:T,xFormat:c,yFormat:u,enableHover:$,showGrid:F}),le&&{legend:le,legendPosition:ce}),B&&"none"!==B&&{legendHoverBehavior:te.onLegendHover,legendClickBehavior:te.onLegendClick,legendHighlightedCategory:te.highlightedCategory,legendIsolatedCategories:te.isolatedCategories}),W&&{title:W}),l&&{className:l}),{tooltipContent:!1===A?()=>null:Pt(A)||de}),(j||E)&&{customHoverBehavior:Q}),S&&S.length>0&&{annotations:S}),O);return R||G||(ge?d.createElement(Ht,{componentName:"StackedAreaChart",message:ge,width:H,height:z}):d.createElement(an,{componentName:"StackedAreaChart",width:H,height:z},d.createElement(Ze,Object.assign({ref:r},ye))))});function kn(t){const{data:n,rawData:o,colorBy:r,colorScheme:i,legendInteraction:s,legendPosition:a,selection:l,linkedHover:c,fallbackFields:u,unwrapData:h=!1,onObservation:d,chartType:g,chartId:p,showLegend:y,userMargin:f,marginDefaults:m,loading:b,emptyContent:v,width:x,height:k}=t,{activeSelectionHook:w,customHoverBehavior:A,customClickBehavior:S}=xt({selection:l,linkedHover:c,fallbackFields:u,unwrapData:h,onObservation:d,chartType:g,chartId:p}),O=vt(n,r,i),M=e.useMemo(()=>{if(!r)return[];const e=new Set;for(const t of n){const n="function"==typeof r?r(t):t[r];null!=n&&e.add(n+"")}return Array.from(e)},[n,r]),j=wt(s,r,M),E=e.useMemo(()=>j.legendSelectionHook?j.legendSelectionHook:w,[j.legendSelectionHook,w]),{legend:C,margin:P,legendPosition:_}=kt({data:n,colorBy:r,colorScale:O,showLegend:y,legendPosition:a,userMargin:f,defaults:m}),L=e.useMemo(()=>{const e={};return C&&(e.legend=C,e.legendPosition=_),s&&"none"!==s&&(e.legendHoverBehavior=j.onLegendHover,e.legendClickBehavior=j.onLegendClick,e.legendHighlightedCategory=j.highlightedCategory,e.legendIsolatedCategories=j.isolatedCategories),e},[C,_,s,j.onLegendHover,j.onLegendClick,j.highlightedCategory,j.isolatedCategories]),B=hn(b,x,k),N=B?null:un(o,x,k,v);return{colorScale:O,allCategories:M,legendState:j,effectiveSelectionHook:E,activeSelectionHook:w,customHoverBehavior:A,customClickBehavior:S,legend:C,margin:P,legendPosition:_,earlyReturn:B||N||null,legendBehaviorProps:L}}xn.displayName="StackedAreaChart";const wn=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const r=St(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:s,className:a,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:h="y",colorBy:g,colorScheme:p="category10",sizeBy:y,sizeRange:f=[3,15],pointRadius:m=5,pointOpacity:b=.8,tooltip:v,marginalGraphics:x,pointIdAccessor:k,annotations:w,frameProps:A={},selection:S,linkedHover:O,linkedBrush:M,onObservation:j,chartId:E,loading:C,emptyContent:P,legendInteraction:L,legendPosition:N}=t,H=r.width,z=r.height,$=r.enableHover,F=r.showGrid,I=r.title,W=r.xLabel,D=r.yLabel,T=i||[],R=kn({data:T,rawData:i,colorBy:g,colorScheme:p,legendInteraction:L,legendPosition:N,selection:S,linkedHover:O,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!1,onObservation:j,chartType:"Scatterplot",chartId:E,showLegend:r.showLegend,userMargin:s,marginDefaults:r.marginDefaults,loading:C,emptyContent:P,width:H,height:z}),G=yt(M),q=ct({name:(null==G?void 0:G.name)||"__unused_brush__",xField:(null==G?void 0:G.xField)||("string"==typeof u?u:void 0),yField:(null==G?void 0:G.yField)||("string"==typeof h?h:void 0)}),Y=G?"xyBrush"===q.brushInteraction.brush?"xy":"xBrush"===q.brushInteraction.brush?"x":"y":void 0,X=d.useRef(q.brushInteraction);X.current=q.brushInteraction;const V=e.useCallback(e=>{const t=X.current;t.end(e?"xyBrush"===t.brush?[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:"xBrush"===t.brush?e.x:e.y:null)},[]);if(R.earlyReturn)return R.earlyReturn;dn("Scatterplot",T,"xAccessor",u),dn("Scatterplot",T,"yAccessor",h);const U=e.useMemo(()=>{if(!y||0===T.length)return;const e=T.map(e=>"function"==typeof y?y(e):e[y]);return[Math.min(...e),Math.max(...e)]},[T,y]),Q=e.useMemo(()=>e=>{const t={fillOpacity:b};return g?R.colorScale&&(t.fill=_(e,g,R.colorScale)):t.fill=mt,t.r=y?B(e,y,f,U):m,t},[g,R.colorScale,y,f,U,m,b]),K=e.useMemo(()=>ft(Q,R.effectiveSelectionHook,S),[Q,R.effectiveSelectionHook,S]),Z=e.useMemo(()=>Nt([{label:W||_t(u),accessor:u,role:"x"},{label:D||_t(h),accessor:h,role:"y"},...g?[{label:_t(g),accessor:g,role:"color"}]:[],...y?[{label:_t(y),accessor:y,role:"size"}]:[]]),[u,h,W,D,g,y]),J=Dt({componentName:"Scatterplot",data:i,accessors:{xAccessor:u,yAccessor:h}});if(J)return d.createElement(Ht,{componentName:"Scatterplot",message:J,width:H,height:z});const ee=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=i&&{data:T}),{xAccessor:u,yAccessor:h,colorAccessor:g||void 0,sizeAccessor:y||void 0,sizeRange:f,pointStyle:K,colorScheme:p,size:[H,z],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R.margin,showAxes:r.showAxes,xLabel:W,yLabel:D,xFormat:l,yFormat:c,enableHover:$,showGrid:F}),R.legendBehaviorProps),I&&{title:I}),a&&{className:a}),{tooltipContent:!1===v?()=>null:Pt(v)||Z}),(O||j)&&{customHoverBehavior:R.customHoverBehavior}),x&&{marginalGraphics:x}),k&&{pointIdAccessor:k}),w&&w.length>0&&{annotations:w}),G&&{brush:{dimension:Y},onBrush:V}),A);return d.createElement(an,{componentName:"Scatterplot",width:H,height:z},d.createElement(Ze,Object.assign({ref:o},ee)))});function An(e,t){return r.interpolateViridis(1===t?.5:e/(t-1))}wn.displayName="Scatterplot";const Sn=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const r=St(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,className:s,xFormat:a,yFormat:l,xAccessor:c="x",yAccessor:u="y",orderAccessor:h,orderLabel:g,pointRadius:p=4,tooltip:y,pointIdAccessor:f,annotations:m,frameProps:b={},selection:v,linkedHover:x,onObservation:k,chartId:w,loading:A,emptyContent:S,legendInteraction:O}=t,M=r.width,j=r.height,E=r.enableHover,C=r.showGrid,P=r.title,_=r.xLabel,L=r.yLabel,B=i||[],{safeData:N,orderMap:H}=e.useMemo(()=>{const e="function"==typeof c?c:e=>e[c],t="function"==typeof u?u:e=>e[u];let n=B;if(h&&B.length>0){const e="function"==typeof h?h:e=>e[h];n=[...B].sort((t,n)=>{const o=e(t),r=e(n);return(o instanceof Date?o.getTime():+o)-(r instanceof Date?r.getTime():+r)})}const o=new WeakMap;let r=0;for(const o of n){const n=e(o),i=t(o);null!=n&&null!=i&&isFinite(n)&&isFinite(i)&&r++}let i=0;for(const s of n){const n=e(s),a=t(s);null!=n&&null!=a&&isFinite(n)&&isFinite(a)&&o.set(s,{idx:i++,total:r})}return{safeData:n,orderMap:o}},[B,h,c,u]);dn("ConnectedScatterplot",N,"xAccessor",c),dn("ConnectedScatterplot",N,"yAccessor",u);const{activeSelectionHook:z,customHoverBehavior:$}=xt({selection:v,linkedHover:x,fallbackFields:[],onObservation:k,chartType:"ConnectedScatterplot",chartId:w}),F=wt(O,void 0,[]),I=e.useMemo(()=>F.legendSelectionHook?F.legendSelectionHook:z,[F.legendSelectionHook,z]),W=e.useMemo(()=>(e,t)=>{var n,o;const r=t.filter(e=>"point"===e.type);if(2>r.length)return;const i=null==I?void 0:I.isActive,s=null==I?void 0:I.predicate,a=100>r.length,l=r.length;e.lineCap="round";for(let t=0;l-1>t;t++){const c=r[t],u=r[t+1],h=An(t,l),d=!i||!s||s(null!==(n=c.datum)&&void 0!==n?n:c)||s(null!==(o=u.datum)&&void 0!==o?o:u),g=i?d?1:.2:1;a&&(e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle="white",e.lineWidth=p+2,e.globalAlpha=.5*g,e.stroke()),e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle=h,e.lineWidth=p,e.globalAlpha=g,e.stroke()}e.globalAlpha=1},[p,I]),D=e.useMemo(()=>[W],[W]),T=e.useMemo(()=>(e,t,n)=>{var o,r;const i=e.filter(e=>"point"===e.type);if(2>i.length)return null;const s=i.length,a=100>s,l=[];for(let e=0;s-1>e;e++){const t=i[e],n=i[e+1],c=An(e,s),u="number"==typeof(null===(o=t.style)||void 0===o?void 0:o.opacity)?t.style.opacity:1,h="number"==typeof(null===(r=n.style)||void 0===r?void 0:r.opacity)?n.style.opacity:1,g=Math.min(u,h);a&&l.push(d.createElement("line",{key:"halo-"+e,x1:t.x,y1:t.y,x2:n.x,y2:n.y,stroke:"white",strokeWidth:p+2,strokeLinecap:"round",opacity:.5*g})),l.push(d.createElement("line",{key:"seg-"+e,x1:t.x,y1:t.y,x2:n.x,y2:n.y,stroke:c,strokeWidth:p,strokeLinecap:"round",opacity:g}))}return d.createElement(d.Fragment,null,l)},[p]),R=e.useMemo(()=>[T],[T]),G=e.useMemo(()=>e=>{var t,n;const o=H.get(e),r=null!==(t=null==o?void 0:o.idx)&&void 0!==t?t:0,i=null!==(n=null==o?void 0:o.total)&&void 0!==n?n:1;return{fill:i>0?An(r,i):"#6366f1",stroke:"white",strokeWidth:1,r:p,fillOpacity:1}},[p,H]),q=e.useMemo(()=>ft(G,I,v),[G,I,v]),Y=Object.assign({top:50,right:40,bottom:60,left:70},t.margin),X=g||("string"==typeof h?h:"Order"),V=e.useMemo(()=>Nt([{label:_||_t(c),accessor:c,role:"x"},{label:L||_t(u),accessor:u,role:"y"},...h?[{label:X,accessor:h,role:"group"}]:[]]),[c,u,_,L,h,X]),U=Dt({componentName:"ConnectedScatterplot",data:i,accessors:{xAccessor:c,yAccessor:u}}),Q=hn(A,M,j),K=Q?null:un(i,M,j,S),Z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=i&&{data:N}),{xAccessor:c,yAccessor:u,pointStyle:q,size:[M,j],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Y,showAxes:r.showAxes,xLabel:_,yLabel:L,xFormat:a,yFormat:l,enableHover:E,showGrid:C}),P&&{title:P}),s&&{className:s}),{tooltipContent:!1===y?()=>null:Pt(y)||V}),(x||k)&&{customHoverBehavior:$}),f&&{pointIdAccessor:f}),{canvasPreRenderers:D,svgPreRenderers:R}),m&&m.length>0&&{annotations:m}),b);return Q||K||(U?d.createElement(Ht,{componentName:"ConnectedScatterplot",message:U,width:M,height:j}):d.createElement(an,{componentName:"ConnectedScatterplot",width:M,height:j},d.createElement(Ze,Object.assign({ref:o},Z))))});Sn.displayName="ConnectedScatterplot";const On=e.forwardRef(function(t,n){const o=e.useRef(null),r=St(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:s,className:a,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:h="y",sizeBy:g,sizeRange:p=[5,40],colorBy:y,colorScheme:f="category10",bubbleOpacity:m=.6,bubbleStrokeWidth:b=1,bubbleStrokeColor:v="white",tooltip:x,marginalGraphics:k,pointIdAccessor:w,annotations:A,frameProps:S={},selection:O,linkedHover:M,linkedBrush:j,onObservation:E,chartId:C,loading:P,emptyContent:L,legendInteraction:N,legendPosition:H}=t,z=r.width,$=r.height,F=r.enableHover,I=r.showGrid,W=r.showLegend,D=r.title,T=r.xLabel,R=r.yLabel,G=hn(P,z,$),q=G?null:un(i,z,$,L),Y=i||[],X=void 0===i,V=e.useRef(null),[U,Q]=e.useState(0),K=e.useCallback(e=>{if(!X)return;let t=!1;for(const n of e){const e="function"==typeof g?g(n):n[g];null!=e&&isFinite(e)&&(V.current?(V.current[0]>e&&(V.current[0]=e,t=!0),e>V.current[1]&&(V.current[1]=e,t=!0)):(V.current=[e,e],t=!0))}t&&Q(e=>e+1)},[X,g]),Z=vn({isPushMode:X,colorBy:y,colorScheme:f,showLegend:W,legendPosition:H}),J=e.useCallback(Z.wrapPush(e=>{var t;K([e]),null===(t=o.current)||void 0===t||t.push(e)}),[Z.wrapPush,K]),ee=e.useCallback(Z.wrapPushMany(e=>{var t;K(e),null===(t=o.current)||void 0===t||t.pushMany(e)}),[Z.wrapPushMany,K]);e.useImperativeHandle(n,()=>({push:J,pushMany:ee,clear:()=>{var e;Z.resetCategories(),V.current=null,Q(e=>e+1),null===(e=o.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}),[J,ee,Z.resetCategories]);const{activeSelectionHook:te,customHoverBehavior:ne}=xt({selection:O,linkedHover:M,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:E,chartType:"BubbleChart",chartId:C}),oe=yt(j);ct({name:(null==oe?void 0:oe.name)||"__unused_brush__",xField:(null==oe?void 0:oe.xField)||("string"==typeof u?u:void 0),yField:(null==oe?void 0:oe.yField)||("string"==typeof h?h:void 0)});const re=vt(Y,y,f),ie=e.useMemo(()=>{if(!y)return[];const e=new Set;for(const t of Y){const n="function"==typeof y?y(t):t[y];null!=n&&e.add(n+"")}return Array.from(e)},[Y,y]),se=wt(N,y,ie),ae=e.useMemo(()=>se.legendSelectionHook?se.legendSelectionHook:te,[se.legendSelectionHook,te]),le=e.useMemo(()=>{if(X)return V.current||[0,1];const e=Y.map(e=>"function"==typeof g?g(e):e[g]);return[Math.min(...e),Math.max(...e)]},[Y,g,X,U]),ce=e.useMemo(()=>e=>{const t={fillOpacity:m,strokeWidth:b,stroke:v};return y?re&&(t.fill=_(e,y,re)):t.fill=mt,t.r=B(e,g,p,le),t},[y,re,g,p,le,m,b,v]),ue=e.useMemo(()=>ft(ce,ae,O),[ce,ae,O]),{legend:he,margin:de,legendPosition:ge}=kt({data:Y,colorBy:y,colorScale:re,showLegend:W,legendPosition:H,userMargin:s,defaults:r.marginDefaults}),pe=Z.streamingLegend||he,ye=H||ge,fe=e.useMemo(()=>{if(Z.streamingMarginAdjust){const e=Object.assign({},de);for(const[t,n]of Object.entries(Z.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return de},[de,Z.streamingMarginAdjust]),me=e.useMemo(()=>Nt([{label:T||_t(u),accessor:u,role:"x"},{label:R||_t(h),accessor:h,role:"y"},{label:_t(g),accessor:g,role:"size"},...y?[{label:_t(y),accessor:y,role:"color"}]:[]]),[u,h,T,R,g,y]),be=Dt({componentName:"BubbleChart",data:i,accessors:{xAccessor:u,yAccessor:h},requiredProps:{sizeBy:g}});if(be)return d.createElement(Ht,{componentName:"BubbleChart",message:be,width:z,height:$});const ve=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bubble"},null!=i&&{data:Y}),{xAccessor:u,yAccessor:h,colorAccessor:y||void 0,sizeAccessor:g,sizeRange:p,pointStyle:ue,colorScheme:f,size:[z,$],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:fe,showAxes:r.showAxes,xLabel:T,yLabel:R,xFormat:l,yFormat:c,enableHover:F,showGrid:I}),pe&&{legend:pe,legendPosition:ye}),N&&"none"!==N&&{legendHoverBehavior:se.onLegendHover,legendClickBehavior:se.onLegendClick,legendHighlightedCategory:se.highlightedCategory,legendIsolatedCategories:se.isolatedCategories}),D&&{title:D}),a&&{className:a}),{tooltipContent:!1===x?()=>null:Pt(x)||me}),(M||E)&&{customHoverBehavior:ne}),k&&{marginalGraphics:k}),w&&{pointIdAccessor:w}),A&&A.length>0&&{annotations:A}),S);return G||q||d.createElement(an,{componentName:"BubbleChart",width:z,height:$},d.createElement(Ze,Object.assign({ref:o},ve)))});On.displayName="BubbleChart";const Mn=e.forwardRef(function(t,n){const i=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const s=St(t.mode,{width:t.width,height:t.height,showGrid:void 0,enableHover:t.enableHover,showLegend:void 0,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:a,margin:l,className:c,xAccessor:u="x",yAccessor:h="y",valueAccessor:g="value",xFormat:p,yFormat:y,colorScheme:f="blues",customColorScale:m,showValues:b=!1,valueFormat:v,cellBorderColor:x="#fff",cellBorderWidth:k=1,tooltip:w,annotations:A,frameProps:S={},selection:O,linkedHover:M,onObservation:j,chartId:E,loading:C,emptyContent:P,showLegend:_,legendPosition:L,legendInteraction:B}=t,N=s.width,H=s.height,z=s.enableHover,$=s.title,F=s.xLabel,I=s.yLabel,W=hn(C,N,H),D=W?null:un(a,N,H,P),T=a||[],R=null!=_&&_,G=null!=L?L:"right",{margin:q}=kt({data:T,colorBy:R?"value":void 0,colorScale:void 0,showLegend:R,legendPosition:G,userMargin:l,defaults:s.marginDefaults}),{activeSelectionHook:Y,customHoverBehavior:X}=xt({selection:O,linkedHover:M,fallbackFields:[],onObservation:j,chartType:"Heatmap",chartId:E}),V=wt(B,void 0,[]),U=e.useMemo(()=>V.legendSelectionHook?V.legendSelectionHook:Y,[V.legendSelectionHook,Y]),Q=e.useMemo(()=>"function"==typeof g?e=>g(e):e=>e[g],[g]),K=e.useMemo(()=>{const e=T.map(Q);return[Math.min(...e),Math.max(...e)]},[T,Q]),Z=e.useMemo(()=>"custom"===f&&m?m:o.scaleSequential({blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,viridis:r.interpolateViridis}[f]||r.interpolateBlues).domain(K),[f,m,K]);e.useMemo(()=>{const e=bt(u),t=bt(h);return{xBinCount:new Set(T.map(e)).size,yBinCount:new Set(T.map(t)).size}},[T,u,h]),e.useMemo(()=>({coordinates:T}),[T]);const J=e.useMemo(()=>e=>{const t=Q(e);return{fill:Z(t),stroke:x,strokeWidth:k}},[Q,Z,x,k]);e.useMemo(()=>ft(J,U,O),[J,U,O]);const ee=e.useMemo(()=>Nt([{label:F||_t(u),accessor:u,role:"x"},{label:I||_t(h),accessor:h,role:"y"},{label:_t(g),accessor:g,role:"value"}]),[u,h,F,I,g]),te=Dt({componentName:"Heatmap",data:a,accessors:{xAccessor:u,yAccessor:h,valueAccessor:g}}),ne=e.useMemo(()=>{if(R)return{gradient:{colorFn:e=>Z(e),domain:K,label:"string"==typeof g?g:"value",format:v}}},[R,Z,K,g,v]),oe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap"},null!=a&&{data:T}),{xAccessor:u,yAccessor:h,valueAccessor:g,colorScheme:"custom"!==f?f:void 0,showValues:b,heatmapValueFormat:v,size:[N,H],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:q,showAxes:s.showAxes,xLabel:F,yLabel:I,xFormat:p,yFormat:y,enableHover:z}),ne&&{legend:ne,legendPosition:G}),$&&{title:$}),c&&{className:c}),{tooltipContent:!1===w?()=>null:Pt(w)||ee}),(M||j)&&{customHoverBehavior:X}),A&&A.length>0&&{annotations:A}),S);return W||D||(te?d.createElement(Ht,{componentName:"Heatmap",message:te,width:N,height:H}):d.createElement(an,{componentName:"Heatmap",width:N,height:H},d.createElement(Ze,Object.assign({ref:i},oe))))});Mn.displayName="Heatmap";const jn="__splomIdx",En={top:4,bottom:4,left:4,right:4};function Cn({frameRef:o,cellSize:r,onBrush:i}){const s=e.useRef(null),a=r-En.left-En.right,l=r-En.top-En.bottom;return e.useEffect(()=>{if(!s.current)return;const e=n.select(s.current).select(".brush-g"),r=t.brush().extent([[0,0],[a,l]]).on("brush end",e=>{var t;const n=null===(t=o.current)||void 0===t?void 0:t.getScales();if(!n)return;if(!e.selection)return void i(null);const[[r,s],[a,l]]=e.selection,c=[[n.x.invert(r),n.y.invert(s)],[n.x.invert(a),n.y.invert(l)]];i(c)});return e.call(r),e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null)}},[a,l,o,i]),d.createElement("svg",{ref:s,width:r,height:r,style:{position:"absolute",top:0,left:0}},d.createElement("g",{className:"brush-g",transform:`translate(${En.left},${En.top})`}))}function Pn({data:t,xField:n,yField:o,cellSize:r,pointRadius:i,pointOpacity:s,colorBy:a,colorScale:l,brushSelectionName:c,hoverSelectionName:u,unselectedOpacity:h,mode:g,onPointHover:p}){const y=e.useRef(null),f=at({name:c,clientId:`splom-${n}-${o}`}),m=ct({name:c,xField:n,yField:o}),b=at({name:u,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==p||p(null));const t=e.data,n=null==t?void 0:t[jn];void 0!==n&&(v({[jn]:[n]}),null==p||p(t,e.x+En.left,e.y+En.top))},[v,p]),w=e.useCallback(e=>{const t={opacity:s,r:i};return t.fill=a?_(e,a,l):mt,"hover"===g?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*s):f.isActive&&!f.predicate(e)&&(t.opacity=h),t},[a,l,s,i,g,f.isActive,f.predicate,b.isActive,b.predicate,h]);return d.createElement("div",{style:{position:"relative",width:r,height:r}},d.createElement(Ze,{ref:y,chartType:"scatter",data:t,size:[r,r],xAccessor:n,yAccessor:o,pointStyle:w,margin:En,showAxes:!1,enableHover:"hover"===g,customHoverBehavior:"hover"===g?k:void 0,tooltipContent:"hover"===g?()=>null:void 0}),"brush"===g&&d.createElement(Cn,{frameRef:y,cellSize:r,xField:n,yField:o,onBrush:x}))}function _n({data:t,field:n,label:o,cellSize:r,bins:i,colorBy:s,colorScale:a,brushSelectionName:l,hoverSelectionName:c,mode:u}){const h=at({name:l,clientId:"splom-diag-"+n}),g=at({name:c,clientId:`splom-diag-${n}-hover`}),p="hover"===u?g:h,y=p.isActive,f=p.predicate,m=e.useMemo(()=>{const e=t.map(e=>e[n]).filter(e=>null!=e&&!isNaN(e));if(0===e.length)return{bars:[],selectedBars:[],categoryBars:[],selectedCategoryBars:[],max:0,categories:[]};const o=Math.min(...e),a=(Math.max(...e)-o)/i||1,l="string"==typeof s?s:null,c=l?[...new Set(t.map(e=>e[l]).filter(e=>null!=e).map(String))]:[],u=new Map(c.map((e,t)=>[e,t])),h=Array(i).fill(0),d=Array(i).fill(0),g=Array.from({length:i},()=>Array(c.length).fill(0)),p=Array.from({length:i},()=>Array(c.length).fill(0));for(const e of t){const t=e[n];if(null==t||isNaN(t))continue;const r=Math.min(Math.floor((t-o)/a),i-1);if(h[r]++,y&&!f(e)||d[r]++,l){const t=u.get(e[l]+"");void 0!==t&&(g[r][t]++,y&&!f(e)||p[r][t]++)}}const m=Math.max(...h,1),b=g.map((e,t)=>{let n=0;return e.map((e,o)=>{const s=e/m*(r-24),a={x:t/i*r,w:r/i-1,h:s,y0:n,category:c[o]};return n+=s,a})}),v=p.map((e,t)=>{let n=0;return e.map((e,o)=>{const s=e/m*(r-24),a={x:t/i*r,w:r/i-1,h:s,y0:n,category:c[o]};return n+=s,a})});return{bars:h.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/m*(r-24),count:e})),selectedBars:d.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/m*(r-24),count:e})),categoryBars:b,selectedCategoryBars:v,max:m,categories:c}},[t,n,i,r,y,f,s]);return d.createElement("svg",{width:r,height:r,style:{overflow:"hidden"}},d.createElement("text",{x:r/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333"},o),m.categories.length>0?m.categoryBars.map((e,t)=>e.map((e,n)=>d.createElement("rect",{key:`bg-${t}-${n}`,x:e.x,y:r-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:a?a(e.category):mt,opacity:y?.3:.6}))):m.bars.map((e,t)=>d.createElement("rect",{key:"bg-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:mt,opacity:y?.3:.6})),y&&(m.categories.length>0?m.selectedCategoryBars.map((e,t)=>e.map((e,n)=>d.createElement("rect",{key:`sel-${t}-${n}`,x:e.x,y:r-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:a?a(e.category):mt,opacity:.7}))):m.selectedBars.map((e,t)=>d.createElement("rect",{key:"sel-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:mt,opacity:.7}))))}function Ln({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 Bn(t){const{data:n,fields:o,fieldLabels:r={},colorBy:i,colorScheme:s="category10",cellSize:a=150,cellGap:l=4,pointRadius:c=2,pointOpacity:u=.5,diagonal:h="histogram",histogramBins:g=20,brushMode:p="crossfilter",hoverMode:y=!0,unselectedOpacity:f=.1,showGrid:m=!1,tooltip:b,showLegend:v,idAccessor:x,className:k,onObservation:w,chartId:A}=t,S="splom",O="splom-hover",M=y?"hover":p?"brush":"hover",j=rt(e=>e.clearSelection),[E,C]=e.useState(null),P=e.useCallback(()=>{j(O),C(null)},[j,O]),_=e.useMemo(()=>(n||[]).map((e,t)=>void 0!==e[jn]?e:Object.assign(Object.assign({},e),{[jn]:t})),[n]),L=vt(_,i,s),B=void 0!==v?v:!!i,N=e.useMemo(()=>{if(!B||!i)return null;const e="string"==typeof i?i:null;return e?[...new Set(_.map(t=>t[e]))].map(e=>({label:e+"",color:L?L(e+""):mt})):null},[B,i,_,L]),H=e.useMemo(()=>({display:"grid",gridTemplateColumns:"40px "+o.map(()=>a+"px").join(" "),gridTemplateRows:o.map(()=>a+"px").join(" ")+" 40px",gap:l+"px",width:"fit-content"}),[o,a,l,40]);return d.createElement("div",{className:k,style:{position:"relative"}},N&&d.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},N.map(e=>d.createElement("div",{key:e.label,style:{display:"flex",alignItems:"center",gap:4}},d.createElement("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:e.color}}),d.createElement("span",{style:{fontSize:11}},e.label)))),d.createElement("div",{style:H,onMouseLeave:"hover"===M?P:void 0},o.map((e,t)=>d.createElement(d.Fragment,{key:"row-"+e},d.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e),o.map((n,o)=>t===o?"label"===h?d.createElement(Ln,{key:"diag-"+e,label:r[e]||e,cellSize:a}):d.createElement(_n,{key:"diag-"+e,data:_,field:e,label:r[e]||e,cellSize:a,bins:g,colorBy:i,colorScale:L,brushSelectionName:S,hoverSelectionName:O,unselectedOpacity:f,mode:M}):d.createElement(Pn,{key:`cell-${e}-${n}`,data:_,xField:n,yField:e,fieldLabels:r,cellSize:a,pointRadius:c,pointOpacity:u,colorBy:i,colorScale:L,brushSelectionName:S,hoverSelectionName:O,unselectedOpacity:f,showGrid:m,tooltip:b,mode:M,onPointHover:"hover"===M?(r,i,s)=>{r?(C({datum:r,xField:n,yField:e,colIndex:o,rowIndex:t,px:null!=i?i:0,py:null!=s?s:0}),w&&w({type:"hover",datum:r,x:null!=i?i:0,y:null!=s?s:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A})):(C(null),w&&w({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A}))}:void 0})))),d.createElement("div",null)," ",o.map(e=>d.createElement("div",{key:"col-label-"+e,style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e))),E&&"hover"===M&&(()=>{const e=E.datum,t=r[E.xField]||E.xField,n=r[E.yField]||E.yField,o=i?"function"==typeof i?i(e):e[i]:null,s=x?"function"==typeof x?x(e):e[x]:"Row "+e[jn];return d.createElement("div",{style:{position:"absolute",left:40+E.colIndex*(a+l)+E.px,top:E.rowIndex*(a+l)+E.py-8,transform:"translate(-50%, -100%)",color:"#333",background:"rgba(255,255,255,0.95)",border:"1px solid #ddd",borderRadius:3,padding:"4px 8px",fontSize:11,lineHeight:1.4,whiteSpace:"nowrap",pointerEvents:"none",zIndex:10}},d.createElement("div",{style:{fontWeight:"bold",marginBottom:2}},s+""),d.createElement("div",null,t,": ",null!=e[E.xField]?Number(e[E.xField]).toFixed(1):"–"),d.createElement("div",null,n,": ",null!=e[E.yField]?Number(e[E.yField]).toFixed(1):"–"),null!=o&&d.createElement("div",{style:{opacity:.8}},"string"==typeof i?i:"group",": ",o+""))})())}function Nn(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(gt,{selections:o},d.createElement(Bn,Object.assign({},e)))}function Hn({width:o,height:r,margin:i,scales:s,brushDirection:a,extent:l,onBrush:c}){const u=e.useRef(null),h=e.useRef(null),g=e.useRef(!1),p=o+i.left+i.right,y=r+i.top+i.bottom;return e.useEffect(()=>{if(!u.current||!s)return;const e=n.select(u.current).select(".brush-group"),i="x"===a?t.brushX().extent([[0,0],[o,r]]):t.brushY().extent([[0,0],[o,r]]);return i.on("brush end",e=>{if(g.current)return;if(!e.sourceEvent)return;const t=e.selection;if(!t)return void c(null);const n=("x"===a?s.x:s.y).invert;if(!n)return;const o=[n(t[0]),n(t[1])];c(o)}),e.call(i),h.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null)}},[s,o,r,a,c]),e.useEffect(()=>{if(!h.current||!s||!u.current)return;const e=n.select(u.current).select(".brush-group"),t="x"===a?s.x:s.y;if(g.current=!0,l){const n=[t(l[0]),t(l[1])];e.call(h.current.move,n)}else e.call(h.current.move,null);g.current=!1},[l,s,a]),d.createElement("svg",{ref:u,width:p,height:y,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},d.createElement("g",{className:"brush-group",transform:`translate(${i.left},${i.top})`}))}function zn(t){var n,o;const{data:r,width:i=600,height:s=400,margin:a,className:l,title:c,xLabel:u,yLabel:h,xFormat:g,yFormat:p,xAccessor:y="x",yAccessor:f="y",lineBy:m,lineDataAccessor:b="coordinates",colorBy:v,colorScheme:x="category10",curve:k="linear",lineWidth:w=2,fillArea:A=!1,areaOpacity:S=.3,showPoints:O=!1,pointRadius:M=3,enableHover:j=!0,showGrid:E=!1,showLegend:C,legendPosition:P,tooltip:L,minimap:B={},renderBefore:N=!1,onBrush:H,brushExtent:z,frameProps:$={},loading:F,emptyContent:I}=t,W=hn(F,i,s),D=W?null:un(r,i,s,I),T=r||[],[R,G]=e.useState(null),q=null!=z?z:R,Y=e.useCallback(e=>{z||G(e),null==H||H(e)},[z,H]),X=e.useRef(null),[V,U]=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?U(o):requestAnimationFrame(e)};requestAnimationFrame(e)},[r]);const Q=void 0!==(null===(n=T[0])||void 0===n?void 0:n[b]),K=e.useMemo(()=>{if(Q)return T;if(m){const e=T.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]:T}]},[T,m,b,Q]),Z=e.useMemo(()=>Q||m?K.flatMap(e=>{const t=e[b]||[];return m&&"string"==typeof m?t.map(t=>Object.assign(Object.assign({},t),{[m]:e[m]})):t}):T,[K,b,Q,m,T]),J=vt(T,v,x),ee=e.useMemo(()=>e=>{const t={strokeWidth:w};return t.stroke=v?_(e,v,J):mt,A&&(t.fill=t.stroke,t.fillOpacity=S),t},[v,J,w,A,S]),te=e.useMemo(()=>B.lineStyle?B.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=v?_(e,v,J):mt,t},[v,J,B.lineStyle]),ne=e.useMemo(()=>{if(O)return e=>{const t={r:M,fillOpacity:1};return t.fill=v?_(e.parentLine||e,v,J):mt,t}},[O,M,v,J]),{legend:oe,margin:re,legendPosition:ie}=kt({data:K,colorBy:v,colorScale:J,showLegend:C,legendPosition:P,userMargin:a}),se=B.height||60,ae=e.useMemo(()=>{var e,t,n,o,r,i,s,a;return{top:null!==(t=null===(e=B.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(o=null===(n=B.margin)||void 0===n?void 0:n.bottom)&&void 0!==o?o:20,left:null!==(i=null===(r=B.margin)||void 0===r?void 0:r.left)&&void 0!==i?i:re.left,right:null!==(a=null===(s=B.margin)||void 0===s?void 0:s.right)&&void 0!==a?a:re.right}},[B.margin,re]),le=B.brushDirection||"x",ce=Dt({componentName:"MinimapChart",data:r,accessors:{xAccessor:y,yAccessor:f}});if(ce)return d.createElement(Ht,{componentName:"MinimapChart",message:ce,width:i,height:s});const ue=A?"area":"line",he=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:ue,data:Z,xAccessor:y,yAccessor:f,groupAccessor:m||void 0,curve:k,lineStyle:ee},O&&{pointStyle:ne}),{size:[i,s],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:re,showAxes:!0,xLabel:u,yLabel:h,xFormat:g,yFormat:p,enableHover:j,showGrid:E}),oe&&{legend:oe,legendPosition:ie}),c&&{title:c}),L&&{tooltipContent:Pt(L)||void 0}),q&&{xExtent:q}),$),de={chartType:ue,data:Z,xAccessor:y,yAccessor:f,groupAccessor:m||void 0,curve:k,lineStyle:te,size:[i,se+ae.top+ae.bottom],margin:ae,showAxes:null!==(o=B.showAxes)&&void 0!==o&&o,background:B.background,enableHover:!1},ge=d.createElement("div",{key:"minimap",style:{position:"relative",width:i,overflow:"hidden"}},d.createElement(Ze,Object.assign({ref:X},de)),d.createElement(Hn,{width:i-ae.left-ae.right,height:se,margin:ae,scales:V,brushDirection:le,extent:q,onBrush:Y})),pe=d.createElement("div",{key:"main",style:{overflow:"hidden"}},d.createElement(Ze,Object.assign({},he)));return W||D||d.createElement(an,{componentName:"MinimapChart",width:i,height:s},d.createElement("div",{className:"minimap-chart"+(l?" "+l:"")},N?ge:pe,N?pe:ge))}Nn.displayName="ScatterplotMatrix",zn.displayName="MinimapChart";const $n=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const r=St(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:s,className:a,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:h="y",xCenter:g,yCenter:p,quadrants:y,centerlineStyle:f={},showQuadrantLabels:m=!0,quadrantLabelSize:b=12,colorBy:v,colorScheme:x="category10",sizeBy:k,sizeRange:w=[3,15],pointRadius:A=5,pointOpacity:S=.8,tooltip:O,pointIdAccessor:M,annotations:j,frameProps:E={},selection:C,linkedHover:P,onObservation:L,chartId:N,loading:H,emptyContent:z,legendInteraction:$,legendPosition:F}=t,I=r.width,W=r.height,D=r.enableHover,T=r.showGrid,R=r.showLegend,G=r.title,q=r.xLabel,Y=r.yLabel,X=hn(H,I,W),V=X?null:un(i,I,W,z),U=i||[];dn("QuadrantChart",U,"xAccessor",u),dn("QuadrantChart",U,"yAccessor",h);const{activeSelectionHook:Q,customHoverBehavior:K}=xt({selection:C,linkedHover:P,fallbackFields:"string"==typeof v?[v]:[],onObservation:L,chartType:"QuadrantChart",chartId:N}),Z=vt(U,v,x),J=e.useMemo(()=>{if(!v)return[];const e=new Set;for(const t of U){const n="function"==typeof v?v(t):t[v];null!=n&&e.add(n+"")}return Array.from(e)},[U,v]),ee=wt($,v,J),te=e.useMemo(()=>ee.legendSelectionHook?ee.legendSelectionHook:Q,[ee.legendSelectionHook,Q]),ne=e.useMemo(()=>{if(!U.length)return;const e="function"==typeof u?u:e=>+e[u],t="function"==typeof h?h:e=>+e[h];let n=1/0,o=-1/0,r=1/0,i=-1/0;for(const s of U){const a=e(s),l=t(s);isFinite(a)&&(n>a&&(n=a),a>o&&(o=a)),isFinite(l)&&(r>l&&(r=l),l>i&&(i=l))}if(null!=g&&isFinite(g)&&(n>g&&(n=g),g>o&&(o=g)),null!=p&&isFinite(p)&&(r>p&&(r=p),p>i&&(i=p)),n===1/0)return;const s=.1*(o-n)||1,a=.1*(i-r)||1;return{xExtent:[n-s,o+s],yExtent:[r-a,i+a]}},[U,u,h,g,p]),oe=e.useMemo(()=>{if(!k||0===U.length)return;const e=U.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},[U,k]),re=e.useMemo(()=>"function"==typeof u?u:e=>+e[u],[u]),ie=e.useMemo(()=>"function"==typeof h?h:e=>+e[h],[h]),se=e.useMemo(()=>e=>{const t={fillOpacity:S};if(v)Z&&(t.fill=_(e,v,Z));else{const n=re(e),o=ie(e),r=null!=g?n>=g:void 0,i=null!=p?o>=p:void 0;t.fill=void 0===i||void 0===r?mt:i&&r?y.topRight.color:i&&!r?y.topLeft.color:!i&&r?y.bottomRight.color:y.bottomLeft.color}return t.r=k?B(e,k,w,oe):A,t},[v,Z,k,w,oe,A,S,re,ie,g,p,y]),ae=e.useMemo(()=>ft(se,te,C),[se,te,C]),{legend:le,margin:ce,legendPosition:ue}=kt({data:U,colorBy:v,colorScale:Z,showLegend:R,legendPosition:F,userMargin:s,defaults:r.marginDefaults}),he=e.useMemo(()=>{if(!U.length)return;const e=new Set;"string"==typeof u&&e.add(u),"string"==typeof h&&e.add(h),"string"==typeof v&&e.add(v),"string"==typeof k&&e.add(k);const t=U[0];for(const n of Object.keys(t))if(!n.startsWith("_")&&!e.has(n)&&"string"==typeof t[n])return n},[U,u,h,v,k]),de=e.useMemo(()=>Nt([...he?[{label:he,accessor:he,role:"title"}]:[],{label:q||_t(u),accessor:u,role:"x"},{label:Y||_t(h),accessor:h,role:"y"},...v?[{label:_t(v),accessor:v,role:"color"}]:[],...k?[{label:_t(k),accessor:k,role:"size"}]:[]]),[he,u,h,q,Y,v,k]),ge=Dt({componentName:"QuadrantChart",data:i,accessors:{xAccessor:u,yAccessor:h}}),pe=e.useMemo(()=>{var e;const t={stroke:f.stroke||"#999",strokeWidth:null!==(e=f.strokeWidth)&&void 0!==e?e:1,dashArray:f.strokeDasharray||[]};return[(e,n,o,r)=>{var i;if(!(null==o?void 0:o.x)||!(null==o?void 0:o.y))return;const s=r.width,a=r.height,l=null!=g?o.x(g):s/2,c=null!=p?o.y(p):a/2;if(null!=g&&!isFinite(l))return;if(null!=p&&!isFinite(c))return;const u=Math.max(0,Math.min(s,l)),h=Math.max(0,Math.min(a,c)),d=[{config:y.topLeft,x:0,y:0,w:u,h:h},{config:y.topRight,x:u,y:0,w:s-u,h:h},{config:y.bottomLeft,x:0,y:h,w:u,h:a-h},{config:y.bottomRight,x:u,y:h,w:s-u,h:a-h}];for(const t of d)t.w>0&&t.h>0&&(e.fillStyle=t.config.color,e.globalAlpha=null!==(i=t.config.opacity)&&void 0!==i?i:.08,e.fillRect(t.x,t.y,t.w,t.h));e.globalAlpha=1,e.strokeStyle=t.stroke,e.lineWidth=t.strokeWidth,t.dashArray.length>0&&e.setLineDash(t.dashArray),e.beginPath(),e.moveTo(u,0),e.lineTo(u,a),e.stroke(),e.beginPath(),e.moveTo(0,h),e.lineTo(s,h),e.stroke(),e.setLineDash([])}]},[g,p,y,f]),ye=e.useMemo(()=>m?[...pe,(e,t,n,o)=>{if(!(null==n?void 0:n.x)||!(null==n?void 0:n.y))return;const r=o.width,i=o.height,s=null!=g?n.x(g):r/2,a=null!=p?n.y(p):i/2;(null==g||isFinite(s))&&(null==p||isFinite(a))&&(e.font=`600 ${b}px sans-serif`,e.globalAlpha=.5,e.fillStyle=y.topLeft.color,e.textAlign="left",e.textBaseline="top",e.fillText(y.topLeft.label,8,8),e.fillStyle=y.topRight.color,e.textAlign="right",e.textBaseline="top",e.fillText(y.topRight.label,r-8,8),e.fillStyle=y.bottomLeft.color,e.textAlign="left",e.textBaseline="bottom",e.fillText(y.bottomLeft.label,8,i-8),e.fillStyle=y.bottomRight.color,e.textAlign="right",e.textBaseline="bottom",e.fillText(y.bottomRight.label,r-8,i-8),e.globalAlpha=1)}]:pe,[pe,m,b,y,g,p]),fe=e.useMemo(()=>{const e=E.canvasPreRenderers||[];return[...ye,...e]},[ye,E.canvasPreRenderers]),me=e.useMemo(()=>{var e;const t={stroke:f.stroke||"#999",strokeWidth:null!==(e=f.strokeWidth)&&void 0!==e?e:1,dashArray:f.strokeDasharray?Array.isArray(f.strokeDasharray)?f.strokeDasharray.join(","):f.strokeDasharray:void 0};return[(e,n,o)=>{if(!(null==n?void 0:n.x)||!(null==n?void 0:n.y))return null;const r=o.width,i=o.height,s=null!=g?n.x(g):r/2,a=null!=p?n.y(p):i/2;if(null!=g&&!isFinite(s))return null;if(null!=p&&!isFinite(a))return null;const l=Math.max(0,Math.min(r,s)),c=Math.max(0,Math.min(i,a));return d.createElement(d.Fragment,null,[{config:y.topLeft,x:0,y:0,w:l,h:c},{config:y.topRight,x:l,y:0,w:r-l,h:c},{config:y.bottomLeft,x:0,y:c,w:l,h:i-c},{config:y.bottomRight,x:l,y:c,w:r-l,h:i-c}].map((e,t)=>{var n;return e.w>0&&e.h>0?d.createElement("rect",{key:"qf-"+t,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.config.color,opacity:null!==(n=e.config.opacity)&&void 0!==n?n:.08}):null}),d.createElement("line",{x1:l,y1:0,x2:l,y2:i,stroke:t.stroke,strokeWidth:t.strokeWidth,strokeDasharray:t.dashArray}),d.createElement("line",{x1:0,y1:c,x2:r,y2:c,stroke:t.stroke,strokeWidth:t.strokeWidth,strokeDasharray:t.dashArray}),m&&d.createElement(d.Fragment,null,d.createElement("text",{x:8,y:8+b,fill:y.topLeft.color,fontWeight:600,fontSize:b,opacity:.5},y.topLeft.label),d.createElement("text",{x:r-8,y:8+b,fill:y.topRight.color,fontWeight:600,fontSize:b,opacity:.5,textAnchor:"end"},y.topRight.label),d.createElement("text",{x:8,y:i-8,fill:y.bottomLeft.color,fontWeight:600,fontSize:b,opacity:.5},y.bottomLeft.label),d.createElement("text",{x:r-8,y:i-8,fill:y.bottomRight.color,fontWeight:600,fontSize:b,opacity:.5,textAnchor:"end"},y.bottomRight.label)))}]},[g,p,y,f,m,b]),be=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(Object.assign({chartType:"scatter"},null!=i&&{data:U}),{xAccessor:u,yAccessor:h,colorAccessor:v||void 0,sizeAccessor:k||void 0,sizeRange:w,pointStyle:ae,colorScheme:x,size:[I,W],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ce,showAxes:r.showAxes,xLabel:q,yLabel:Y,xFormat:l,yFormat:c,enableHover:D,showGrid:T}),ne&&{xExtent:ne.xExtent,yExtent:ne.yExtent}),le&&{legend:le,legendPosition:ue}),$&&"none"!==$&&{legendHoverBehavior:ee.onLegendHover,legendClickBehavior:ee.onLegendClick,legendHighlightedCategory:ee.highlightedCategory,legendIsolatedCategories:ee.isolatedCategories}),G&&{title:G}),a&&{className:a}),{tooltipContent:!1===O?()=>null:!0===O||void 0===O?de:Pt(O)||de}),(P||L)&&{customHoverBehavior:K}),M&&{pointIdAccessor:M}),j&&j.length>0&&{annotations:j}),{canvasPreRenderers:fe}),E),fe.length>0&&{canvasPreRenderers:fe}),{svgPreRenderers:me});return X||V||(ge?d.createElement(Ht,{componentName:"QuadrantChart",message:ge,width:I,height:W}):d.createElement(an,{componentName:"QuadrantChart",width:I,height:W},d.createElement(Ze,Object.assign({ref:o},be))))});$n.displayName="QuadrantChart";const Fn="__ma_unitized",In="__ma_series";function Wn(e,t){const n=t[1]-t[0];return 0===n?.5:(e-t[0])/n}function Dn(e,t){return t[0]+e*(t[1]-t[0])}const Tn=e.forwardRef(function(t,n){var o,r;const i=e.useRef(null),s=e.useRef([]);e.useImperativeHandle(n,()=>({push:e=>{if(!i.current)return;const n=e;for(let e=0;t.series.length>e&&2>e;e++){const o=t.series[e],r=o.extent||s.current[e];if(!r)continue;const a=("function"==typeof o.yAccessor?o.yAccessor:e=>e[o.yAccessor])(n);null!=a&&isFinite(a)&&i.current.push(Object.assign(Object.assign({},n),{[Fn]:Wn(a,r),[In]:o.label||"Series "+(e+1)}))}},pushMany:e=>{if(!i.current)return;const n=[];for(const o of e)for(let e=0;t.series.length>e&&2>e;e++){const r=t.series[e],i=r.extent||s.current[e];if(!i)continue;const a=("function"==typeof r.yAccessor?r.yAccessor:e=>e[r.yAccessor])(o);null!=a&&isFinite(a)&&n.push(Object.assign(Object.assign({},o),{[Fn]:Wn(a,i),[In]:r.label||"Series "+(e+1)}))}i.current.pushMany(n)},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const a=St(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel},{width:800,height:400}),{data:l,margin:c,className:u,xFormat:h,xAccessor:g="x",series:p,colorScheme:y="category10",curve:f="monotoneX",lineWidth:m=2,tooltip:b,annotations:v,frameProps:x={},selection:k,linkedHover:w,onObservation:A,chartId:S,loading:O,emptyContent:M,legendInteraction:C,legendPosition:P}=t,_=a.width,L=a.height,B=a.enableHover,N=a.showGrid,H=null===(o=a.showLegend)||void 0===o||o,z=a.title,$=a.xLabel,F=2===p.length;"undefined"==typeof process||"production"===(null===(r=process.env)||void 0===r?void 0:r.NODE_ENV)||F||console.warn(`[MultiAxisLineChart] Expected exactly 2 series for dual-axis mode, got ${p.length}. Rendering as a standard multi-line chart.`);const I=hn(O,_,L),W=I?null:un(l,_,L,M),D=l||[],T=function(){var e;const t=Me(e=>e.theme),n=null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.categorical;return n&&n.length>0?n:void 0}(),R=e.useMemo(()=>{let e;if(Array.isArray(y))e=y;else if(T&&T.length>0)e=T;else{const t=j[y];e=Array.isArray(t)?t:E}return p.map((t,n)=>t.color||e[n%e.length])},[p,y,T]),G=e.useMemo(()=>p.map((e,t)=>e.label||"Series "+(t+1)),[p]),{unitizedData:q,extents:Y}=e.useMemo(()=>{if(0===D.length){const e=p.map(e=>e.extent||null).filter(Boolean);return e.length===p.length&&(s.current=e),{unitizedData:[],extents:e.length===p.length?e:[]}}const e=p.map(e=>e.extent||function(e,t){let n=1/0,o=-1/0;const r="function"==typeof t?t:e=>e[t];for(const t of e){const e=r(t);null!=e&&isFinite(e)&&(n>e&&(n=e),e>o&&(o=e))}if(!isFinite(n)||!isFinite(o))return[0,1];if(n===o){const e=0===n?1:.1*Math.abs(n);return[n-e,o+e]}return[n,o]}(D,e.yAccessor));if(s.current=e,!F){const t=[];for(const e of D)for(let n=0;p.length>n;n++){const o=p[n],r=("function"==typeof o.yAccessor?o.yAccessor:e=>e[o.yAccessor])(e);null!=r&&t.push(Object.assign(Object.assign({},e),{[Fn]:r,[In]:G[n]}))}return{unitizedData:t,extents:e}}const t=[];for(const n of D)for(let o=0;2>o;o++){const r=p[o],i=("function"==typeof r.yAccessor?r.yAccessor:e=>e[r.yAccessor])(n);null!=i&&t.push(Object.assign(Object.assign({},n),{[Fn]:Wn(i,e[o]),[In]:G[o]}))}return{unitizedData:t,extents:e}},[D,p,F,G]),X=e.useMemo(()=>{if(F&&Y.length>=2)return[{orient:"left",label:G[0],tickFormat:p[0].format||(e=>{const t=Dn(e,Y[0]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"right",label:G[1],tickFormat:p[1].format||(e=>{const t=Dn(e,Y[1]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"bottom"}]},[F,Y,p,G]),V=kn({data:e.useMemo(()=>q.length>0?q:G.map(e=>({[In]:e})),[q,G]),rawData:l,colorBy:In,colorScheme:R,legendInteraction:C,legendPosition:P,selection:k,linkedHover:w,fallbackFields:[In],unwrapData:!1,onObservation:A,chartType:"MultiAxisLineChart",chartId:S,showLegend:H,userMargin:c,marginDefaults:F?Object.assign(Object.assign({},a.marginDefaults),{left:70,right:70}):a.marginDefaults,loading:O,emptyContent:M,width:_,height:L});if(V.earlyReturn)return V.earlyReturn;const U=e.useMemo(()=>{const e=new Map;return G.forEach((t,n)=>e.set(t,R[n])),t=>({stroke:e.get(t[In])||R[0],strokeWidth:m,fill:"none"})},[G,R,m]),Q=e.useMemo(()=>ft(U,V.effectiveSelectionHook,k),[U,V.effectiveSelectionHook,k]),K=e.useMemo(()=>{if(!1===b)return()=>null;return Pt(b)||(e=>{var t;const n=e.data||e,o=n[In],r=G.indexOf(o),i=n[Fn],s=F&&r>=0&&Y[r]?Dn(i,Y[r]):i,a=r>=0&&(null===(t=p[r])||void 0===t?void 0:t.format)?p[r].format:e=>Number.isInteger(e)?e+"":e.toFixed(2),l="function"==typeof g?g(n):n[g];return d.createElement("div",{style:{padding:"6px 10px",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-tooltip-font-size, 13px)"}},d.createElement("div",{style:{fontWeight:600,marginBottom:4,color:R[r]||"inherit"}},o),d.createElement("div",null,`${"string"==typeof g?g:"x"}: ${l}`),d.createElement("div",null,`${o}: ${a(s)}`))})},[b,G,R,Y,F,p,g]),Z=Dt({componentName:"MultiAxisLineChart",data:l,accessors:{xAccessor:g}}),J=F?[0,1]:void 0,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(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"line"},null!=l&&{data:q}),{xAccessor:g,yAccessor:Fn,groupAccessor:In,lineStyle:Q,colorScheme:R,size:[_,L],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:V.margin,showAxes:a.showAxes}),X&&{axes:X}),{xLabel:$}),F?{}:{yLabel:G[0]}),{xFormat:h}),F&&J&&{yExtent:J}),{enableHover:B,showGrid:N,curve:f}),V.legendBehaviorProps),z&&{title:z}),u&&{className:u}),{tooltipContent:K}),v&&{annotations:v}),(w||A)&&{customHoverBehavior:V.customHoverBehavior}),A&&{customClickBehavior:V.customClickBehavior}),x);return I||W||(Z?d.createElement(Ht,{componentName:"MultiAxisLineChart",message:Z,width:_,height:L}):d.createElement(an,{componentName:"MultiAxisLineChart",width:_,height:L},d.createElement(Ze,Object.assign({ref:i},ee))))});function Rn(e,t=.5){const n=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!n)return e;const o=Math.round(parseInt(n[1],16)*(1-t)),r=Math.round(parseInt(n[2],16)*(1-t)),i=Math.round(parseInt(n[3],16)*(1-t));return`#${o.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`}function Gn(e,t=.5){const n=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!n)return e;const o=Math.round(parseInt(n[1],16)+(255-parseInt(n[1],16))*t),r=Math.round(parseInt(n[2],16)+(255-parseInt(n[2],16))*t),i=Math.round(parseInt(n[3],16)+(255-parseInt(n[3],16))*t);return`#${o.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`}Tn.displayName="MultiAxisLineChart";const qn="__forecastSegment";function Yn(e,t){return"function"==typeof t?t(e):!!e[t]}const Xn=Object.freeze({__proto__:null,SEGMENT_FIELD:qn,buildAnomalyAnnotations:function(e){var t,n,o;return[{type:"anomaly-band",threshold:null!==(t=e.threshold)&&void 0!==t?t:2,showBand:!1!==e.showBand,fill:e.bandColor||"#6366f1",fillOpacity:null!==(n=e.bandOpacity)&&void 0!==n?n:.1,anomalyColor:e.anomalyColor||"#ef4444",anomalyRadius:null!==(o=e.anomalyRadius)&&void 0!==o?o:6,label:e.label}]},buildForecast:function(e,t,n,o,r){return(i=o).isTraining||i.isForecast||i.isAnomaly||i.upperBounds||i.lowerBounds?function(e,t,n,o,r){var i,s,a,l;const{isTraining:c,isForecast:u,isAnomaly:h,upperBounds:d,lowerBounds:g,color:p="#6366f1",bandOpacity:y=.15,anomalyColor:f="#ef4444",anomalyRadius:m=6,label:b}=o,v=e.map(e=>{let t="observed";return u&&Yn(e,u)?t="forecast":c&&Yn(e,c)&&(t="training"),Object.assign(Object.assign({},e),{[qn]:t})}),x=o._groupBy,k=[];if(x){const e=new Map;for(const t of v){const n=null!==(i=t[x])&&void 0!==i?i:"__default";e.has(n)||e.set(n,[]),e.get(n).push(t)}const t=[];for(const[,n]of e)for(let e=0;n.length-1>e;e++)n[e][qn]!==n[e+1][qn]&&(t.push(Object.assign(Object.assign({},n[e+1]),{[qn]:n[e][qn]})),t.push(Object.assign(Object.assign({},n[e]),{[qn]:n[e+1][qn]})));k.push(...v,...t)}else for(let e=0;v.length>e;e++)k.push(v[e]),v.length-1>e&&v[e][qn]!==v[e+1][qn]&&(k.push(Object.assign(Object.assign({},v[e+1]),{[qn]:v[e][qn]})),k.push(Object.assign(Object.assign({},v[e]),{[qn]:v[e+1][qn]})));if(o.trainUnderline){const e=[];for(const t of k)"training"===t[qn]&&e.push(Object.assign(Object.assign({},t),{[qn]:"training-base"}));k.unshift(...e)}const w=[];if(d&&g){const e="string"==typeof d?d:"__envUpper",t="string"==typeof g?g:"__envLower";if("function"==typeof d||"function"==typeof g)for(const n of k)"function"==typeof d&&(n[e]=d(n)),"function"==typeof g&&(n[t]=g(n));w.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:p,fillOpacity:y,label:b})}if(h){const e=o.anomalyStyle,t={type:"highlight",filter:e=>Yn(e,h)};e?(t.style=e,t.r=m):"function"==typeof f?(t.style=e=>{const t=f(e);return{stroke:t,strokeWidth:1.5,fill:t,fillOpacity:.7}},t.r=m):(t.color=f,t.r=m,t.style={stroke:f,strokeWidth:1.5,fill:f,fillOpacity:.7}),w.push(t)}return r&&w.push({type:"anomaly-band",threshold:null!==(s=r.threshold)&&void 0!==s?s:2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:null!==(a=r.bandOpacity)&&void 0!==a?a:.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:null!==(l=r.anomalyRadius)&&void 0!==l?l:6,label:r.label}),{processedData:k,annotations:w}}(e,0,0,o,r):function(e,t,n,o,r){var i,s,a;const{trainEnd:l,steps:c=10,confidence:u=.95,color:h="#6366f1",bandOpacity:d=.15,label:g}=o;if(null==l)return{processedData:e,annotations:[]};const p=[],y=[];for(const n of e)n[t]>l?y.push(Object.assign(Object.assign({},n),{[qn]:"observed"})):p.push(Object.assign(Object.assign({},n),{[qn]:"training"}));const f=p.map(e=>[e[t],e[n]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),m=[],b=[];if(f.length>=3){const o=f.length;let r=0,i=0,s=0,a=0;for(const[e,t]of f)r+=e,i+=t,s+=e*e,a+=e*t;const l=o*s-r*r;if(Math.abs(l)>1e-12){const s=(o*a-r*i)/l,p=(i-s*r)/o,y=e=>p+s*e,v=f.map(([e,t])=>t-y(e)).reduce((e,t)=>e+t*t,0),x=Math.sqrt(v/Math.max(o-2,1)),k=f.reduce((e,t)=>e+t[0],0)/o,w=f.reduce((e,t)=>e+Math.pow(t[0]-k,2),0),A=.99>u?.95>u?.9>u?1:1.645:1.96:2.576,S=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),O=Math.max(...S),M=f.length>1?(f[o-1][0]-f[0][0])/(o-1):1;for(let e=1;c>=e;e++){const r=O+e*M,i=y(r),s=x*Math.sqrt(1+1/o+(w>0?Math.pow(r-k,2)/w:0))*A;b.push({[t]:r,[n]:i,[qn]:"forecast",__forecastUpper:i+s,__forecastLower:i-s})}m.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:h,fillOpacity:d,label:g})}}m.push({type:"x-threshold",x:l,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),r&&m.push({type:"anomaly-band",threshold:null!==(i=r.threshold)&&void 0!==i?i:2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:null!==(s=r.bandOpacity)&&void 0!==s?s:.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:null!==(a=r.anomalyRadius)&&void 0!==a?a:6,label:r.label});const v=[];if(v.push(...p),p.length>0&&y.length>0&&v.push(Object.assign(Object.assign({},p[p.length-1]),{[qn]:"observed"})),v.push(...y),b.length>0){const e=y.length>0?y[y.length-1]:p[p.length-1];e&&v.push(Object.assign(Object.assign({},e),{[qn]:"forecast"})),v.push(...b)}return{processedData:v,annotations:m}}(e,t,n,o,r);var i},createSegmentLineStyle:function(e,t){var n,o;const r=null!==(n=t.trainDasharray)&&void 0!==n?n:"8,4",i=null!==(o=t.forecastDasharray)&&void 0!==o?o:"4,4",s=t.color||"#6366f1",a=t.trainOpacity,l=t.forecastOpacity,c=t.trainStroke,u=t.trainLinecap,h=t.trainUnderline;return t=>{const n=e(t),o=t[qn];if("training"===o){let e=n.stroke;return"darken"===c?e=Rn(n.stroke||"#666",.5):c&&(e=c),Object.assign(Object.assign(Object.assign(Object.assign({},n),{stroke:e,strokeDasharray:r}),u&&{strokeLinecap:u}),null!=a&&{strokeOpacity:a})}if("training-base"===o){let e=n.stroke||"#666";return"lighten"===h&&(e=Gn(e,.4)),Object.assign(Object.assign({},n),{stroke:e,strokeDasharray:void 0})}return"forecast"===o?Object.assign(Object.assign(Object.assign({},n),{stroke:s,strokeDasharray:i}),null!=l&&{strokeOpacity:l}):n}},darkenColor:Rn,lightenColor:Gn});exports.AreaChart=bn,exports.BubbleChart=On,exports.ConnectedScatterplot=Sn,exports.Heatmap=Mn,exports.LineChart=mn,exports.MinimapChart=zn,exports.MultiAxisLineChart=Tn,exports.QuadrantChart=$n,exports.Scatterplot=wn,exports.ScatterplotMatrix=Nn,exports.StackedAreaChart=xn,exports.StreamXYFrame=Ze;