semiotic 3.3.0 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +7 -4
- package/ai/schema.json +97 -1
- package/dist/components/charts/ordinal/BarChart.d.ts +2 -0
- package/dist/components/charts/ordinal/DonutChart.d.ts +2 -0
- package/dist/components/charts/ordinal/GroupedBarChart.d.ts +4 -0
- package/dist/components/charts/ordinal/PieChart.d.ts +2 -0
- package/dist/components/charts/ordinal/StackedBarChart.d.ts +4 -0
- package/dist/components/realtime/types.d.ts +42 -3
- package/dist/components/server/renderToStaticSVG.d.ts +1 -0
- package/dist/components/server/serverChartConfigs.d.ts +17 -0
- package/dist/components/server/themeResolver.d.ts +4 -0
- package/dist/components/store/ThemeStore.d.ts +14 -0
- package/dist/components/stream/NetworkPipelineStore.d.ts +7 -1
- package/dist/components/stream/geoTypes.d.ts +4 -4
- package/dist/components/stream/hoverUtils.d.ts +22 -0
- package/dist/components/stream/networkTypes.d.ts +14 -22
- package/dist/components/stream/ordinalTypes.d.ts +10 -0
- package/dist/components/stream/pipelineDecay.d.ts +6 -5
- package/dist/components/stream/types.d.ts +4 -0
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-themes.min.js +1 -1
- package/dist/semiotic-themes.module.min.js +1 -1
- package/dist/semiotic-utils.min.js +1 -1
- package/dist/semiotic-utils.module.min.js +1 -1
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +1 -1
package/dist/xy.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react"),t=require("d3-selection"),n=require("d3-brush"),o=require("d3-scale"),r=require("d3-quadtree"),i=require("d3-scale-chromatic"),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 d(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}return t.default=e,Object.freeze(t)}const h=d(e),g=u(c);function f(e,t){let n=0,o=t.length-1;for(;o>n;){const r=n+o+1>>1;t[r]>e?o=r-1:n=r}return t[n]}function p(e,t){let n=0,o=t.length-1;for(;o>n;){const r=n+o>>1;e>t[r]?n=r+1:o=r}return t[n]}function y({width:o,height:r,totalWidth:i,totalHeight:s,margin:a,dimension:l,scales:c,onBrush:u,binSize:d,snap:g,binBoundaries:y,snapDuring:m,streaming:v}){const b=e.useRef(null),x=e.useRef(null),k=e.useRef(u);k.current=u;const w=e.useRef(c);w.current=c;const A=e.useMemo(()=>y?[...y].sort((e,t)=>e-t):void 0,[y]),O=e.useRef(A);O.current=A;const S=e.useRef(!1),j=e.useRef(null);return e.useEffect(()=>{if(!b.current)return;const e=t.select(b.current).select(".brush-g"),i="x"===l?n.brushX():"y"===l?n.brushY():n.brush();return i.extent([[0,0],[o,r]]),i.on("brush end",t=>{if(S.current)return;const n=w.current;if(!n)return;if(!t.selection)return j.current=null,void k.current(null);let s,a;if("x"===l){const[e,o]=t.selection;s=[n.x.invert(e),n.x.invert(o)],a=[n.y.invert(r),n.y.invert(0)]}else if("y"===l){const[e,r]=t.selection;s=[n.x.invert(0),n.x.invert(o)],a=[n.y.invert(r),n.y.invert(e)]}else{const[[e,o],[r,i]]=t.selection;s=[n.x.invert(e),n.x.invert(r)],a=[n.y.invert(i),n.y.invert(o)]}if("bin"===g&&"y"!==l&&("end"===t.type||"brush"===t.type&&m)){const o=O.current;o&&o.length>0?s=function(e,t){return 0===t.length?e:[f(e[0],t),p(e[1],t)]}(s,o):d&&d>0&&(s=[Math.floor(s[0]/d)*d,Math.ceil(s[1]/d)*d]);const r=n.x(s[0]),a=n.x(s[1]);if(S.current=!0,"x"===l)e.call(i.move,[r,a]);else if("xy"===l){const n=t.selection;e.call(i.move,[[r,n[0][1]],[a,n[1][1]]])}S.current=!1}const c={x:s,y:a};j.current=c,k.current(c)}),e.call(i),x.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),x.current=null}},[o,r,l,g,d,m]),e.useEffect(()=>{if(!(v&&c&&x.current&&j.current))return;if(!b.current)return;if("y"===l)return;const e=j.current,n=c.x.domain()[0],o=t.select(b.current).select(".brush-g");if(n>=e.x[1])return S.current=!0,o.call(x.current.move,null),S.current=!1,j.current=null,void k.current(null);let r=e.x[0],i=!1;if(n>e.x[0]){if(r=n,"bin"===g){const e=O.current;e&&e.length>0?r=p(n,e):d&&d>0&&(r=Math.ceil(n/d)*d)}if(r>=e.x[1])return S.current=!0,o.call(x.current.move,null),S.current=!1,j.current=null,void k.current(null);i=!0}const s=c.x(r),a=c.x(e.x[1]);if(S.current=!0,"x"===l)o.call(x.current.move,[s,a]);else{const t=c.y(e.y[1]),n=c.y(e.y[0]);o.call(x.current.move,[[s,t],[a,n]])}if(S.current=!1,i){const t={x:[r,e.x[1]],y:e.y};j.current=t,k.current(t)}},[c,v,l,g,d]),h.createElement("svg",{ref:b,width:i,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},h.createElement("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`}))}class m{constructor(e,t){var n,o;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=null!==(n=null==t?void 0:t.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(o=null==t?void 0:t.chunkSize)&&void 0!==o?o:5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const o=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){this.pushBuffer.push(e),this.scheduleFlush()}pushMany(e){if(0!==e.length){for(let t=0;e.length>t;t++)this.pushBuffer.push(e[t]);this.scheduleFlush()}}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}class v{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}update(e,t){const n=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++){const i=(o+r)%this._capacity,s=this.buffer[i];if(e(s)){let e;e="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:Object.assign({},s),n.push(e),this.buffer[i]=t(s)}}return n}remove(e){const t=[],n=[];if(this.forEach(o=>{e(o)?n.push(o):t.push(o)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class b{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function x(e,t,n,o,r){const i=new Map;for(const 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 k(e,t){return e===t||typeof e==typeof t&&"function"==typeof e&&"function"==typeof t&&""+e==""+t}function w(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function A(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 S={category10:i.schemeCategory10,tableau10:i.schemeTableau10,set3:i.schemeSet3,blues:i.interpolateBlues,reds:i.interpolateReds,greens:i.interpolateGreens,oranges:i.interpolateOranges,purples:i.interpolatePurples,viridis:i.interpolateViridis,plasma:i.interpolatePlasma},j=i.schemeCategory10,M=["#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 E(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=null==e?void 0:e[t];return n?n(o):j[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+""))%j.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=S[n]||S.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:j;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):null==e?void 0: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 P(e,t,n){var o,r,i;if(1>=n)return 1;const s=null!==(o=e.minOpacity)&&void 0!==o?o:.1,a=n-1-t;switch(e.type){case"linear":return s+(1-a/(n-1))*(1-s);case"exponential":{const t=null!==(r=e.halfLife)&&void 0!==r?r:n/2;return s+Math.pow(.5,a/t)*(1-s)}case"step":return(null!==(i=e.stepThreshold)&&void 0!==i?i:.5*n)>a?1:s;default:return 1}}function L(e,t,n){var o;const r=null!==(o=e.duration)&&void 0!==o?o:500,i=n-t;return r>i?1-i/r:0}function N(e,t,n){return e+(t-e)*n}function I(e,t,n){var o,r,i,s;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===e.runtimeMode&&t.datum){const n=e.getX(t.datum),o=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${n}:${o}`;if(null!=n&&null!=o)return`p:${n}:${o}`}return"p:"+n;case"rect":return`r:${t.group||""}:${null!==(s=null!==(r=null===(o=t.datum)||void 0===o?void 0:o.binStart)&&void 0!==r?r:null===(i=t.datum)||void 0===i?void 0:i.category)&&void 0!==s?s:n}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+n:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function H(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 F(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 T(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 z(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 $(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 R(e,t,n){if(!e.getBounds||!e.scales)return null;const o=[],r=[];for(const n of t){const t=e.getX(n),i=e.getY(n);if(null==t||null==i||Number.isNaN(t)||Number.isNaN(i))continue;const s=e.getBounds(n),a=e.scales.x(t);if(s&&0!==s)o.push([a,e.scales.y(i+s)]),r.push([a,e.scales.y(i-s)]);else{const t=e.scales.y(i);o.push([a,t]),r.push([a,t])}}return 2>o.length?null:{type:"area",topPath:o,bottomPath:r,style:e.resolveBoundsStyle(n,t[0]),datum:t,group:n,interactive:!1}}function D(e,t,n,o){var r;if(!e.config.pointStyle)return;const i=null!=o?o:e.getY;for(const o of t){const t=e.resolveGroupColor(o.key);for(const s of o.data){let o=e.config.pointStyle(s);!o.fill&&t&&(o=Object.assign(Object.assign({},o),{fill:t}));const a=null!==(r=o.r)&&void 0!==r?r:3,l=e.getPointId?e.getPointId(s)+"":void 0,c=T(s,e.scales,e.getX,i,a,o,l);c&&n.push(c)}}}const W={blues:i.interpolateBlues,reds:i.interpolateReds,greens:i.interpolateGreens,viridis:i.interpolateViridis},G=new Map;class Y{constructor(e){if(this.xExtent=new b,this.yExtent=new b,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._binBoundaries=[],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 v(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=w(e.timeAccessor||e.xAccessor,"time"),this.getY=w(e.valueAccessor||e.yAccessor,"value")):(this.getX=w(e.xAccessor,"x"),this.getY=w(e.yAccessor,"y")),this.getGroup=O(e.groupAccessor),this.getCategory=O(e.categoryAccessor),this.getSize=e.sizeAccessor?w(e.sizeAccessor,"size"):void 0,this.getColor=O(e.colorAccessor),this.getBounds=e.boundsAccessor?w(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?w(e.y0Accessor,"y0"):void 0,this.getPointId=O(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,n=null!=e.closeAccessor;this.getOpen=t?w(e.openAccessor,"open"):void 0,this.getHigh=w(e.highAccessor,"high"),this.getLow=w(e.lowAccessor,"low"),this.getClose=n?w(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!n}e.pulse&&(this.timestampBuffer=new v(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){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?w(this.config.timeAccessor||this.config.xAccessor,"time"):w(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,l;const{config:c,buffer:u}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(t=this.config.scalePadding)&&void 0!==t?t:0)&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);if(this.xExtent.dirty&&this.xExtent.recalculate(u,this.getX),this.yExtent.dirty)if("candlestick"===c.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of u)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(u,this.getY);const d=this.getBufferArray(),h=this.xExtent.extent,g=this.yExtent.extent;let f=c.xExtent?[null!==(n=c.xExtent[0])&&void 0!==n?n:h[0],null!==(r=c.xExtent[1])&&void 0!==r?r:h[1]]:h,p=c.yExtent?[null!==(i=c.yExtent[0])&&void 0!==i?i:g[0],null!==(s=c.yExtent[1])&&void 0!==s?s:g[1]]:g;const y=c.yExtent&&null!=c.yExtent[0]&&null!=c.yExtent[1];if("stackedarea"===c.chartType&&!y&&u.size>0)if(c.normalize)p=[0,1+c.extentPadding];else{const e=`${u.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===e)p=this._stackExtentCache.yDomain;else{const t=this.groupData(d),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*c.extentPadding:1)],this._stackExtentCache={key:e,yDomain:p}}}else if("bar"===c.chartType&&c.binSize&&!y&&u.size>0){const[,e]=function(e,t,n,o,r){const i=x(e,t,n,o,r);if(0===i.size)return[0,0];let s=0;for(const e of i.values())e.total>s&&(s=e.total);return[0,s]}(u,this.getX,this.getY,c.binSize,this.getCategory);p=[0,e+e*c.extentPadding]}else if("waterfall"===c.chartType&&!y&&u.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]}(u,this.getY),n=t-e,o=n>0?n*c.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 d){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*c.extentPadding:1,n=null===(a=c.yExtent)||void 0===a?void 0:a[0],o=null===(l=c.yExtent)||void 0===l?void 0:l[1];p=[null!=n?p[0]:p[0]-t,null!=o?p[1]:p[1]+t],"log"===c.yScaleType&&0>=p[0]&&g[0]>0&&(p[0]=null!=n?p[0]:g[0]/(1+c.extentPadding))}if(f[0]===1/0||f[1]===-1/0)if("time"===c.xScaleType){const e=Date.now();f=[e-864e5,e]}else f=[0,1];p[0]!==1/0&&p[1]!==-1/0||(p=[0,1]);const m="streaming"===c.runtimeMode,v=Math.max(0,Math.min(c.scalePadding||0,Math.min(e.width,e.height)/2-1));if(m)if("x"==("up"===(b=c.arrowOfTime)||"down"===b?"y":"x")){const t="right"===c.arrowOfTime?[v,e.width-v]:[e.width-v,v];this.scales={x:o.scaleLinear().domain(f).range(t),y:o.scaleLinear().domain(p).range([e.height-v,v])}}else{const t="down"===c.arrowOfTime?[v,e.height-v]:[e.height-v,v];this.scales={x:o.scaleLinear().domain(p).range([v,e.width-v]),y:o.scaleLinear().domain(f).range(t)}}else{const t=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return o.scaleLog().domain(e).range(n).clamp(!0)}return"time"===e?o.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(n):o.scaleLinear().domain(t).range(n)};this.scales={x:t(c.xScaleType,f,[v,e.width-v]),y:t(c.yScaleType,p,[e.height-v,v])}}var b;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(e,d),this.config.decay&&this.applyDecay(this.scene,d),this.config.pulse&&this.applyPulse(this.scene,d),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>Y.QUADTREE_THRESHOLD?r.quadtree().x(e=>e.x).y(e=>e.y).addAll(t):null}get quadtree(){return this._quadtree}remapScene(e){const t=e.width/this.lastLayout.width,n=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const o of e.path)o[0]*=t,o[1]*=n;break;case"area":for(const o of e.topPath)o[0]*=t,o[1]*=n;for(const o of e.bottomPath)o[0]*=t,o[1]*=n;break;case"point":e.x*=t,e.y*=n;break;case"rect":case"heatcell":e.x*=t,e.y*=n,e.w*=t,e.h*=n;break;case"candlestick":e.x*=t,e.openY*=n,e.closeY*=n,e.highY*=n,e.lowY*=n}const 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"time"===e?o.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(n):o.scaleLinear().domain(t).range(n)},c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),u=a[1]>a[0];this.scales={x:l(this.config.xScaleType,r,s[0]>s[1]?[e.width-c,c]:[c,e.width-c]),y:l(this.config.yScaleType,i,u?[c,e.height-c]:[e.height-c,c])},this.lastLayout={width:e.width,height:e.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(e,t){var n;const{config:o,scales:r}=this;if(!r||0===t.length)return[];const s={scales:r,config:o,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,getBounds:this.getBounds,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(e,t)=>this.resolveLineStyle(e,t),resolveAreaStyle:(e,t)=>this.resolveAreaStyle(e,t),resolveBoundsStyle:(e,t)=>this.resolveBoundsStyle(e,t),resolveColorMap:e=>this.resolveColorMap(e),resolveGroupColor:e=>this.resolveGroupColor(e),groupData:e=>this.groupData(e),barCategoryCache:this._barCategoryCache};switch(o.chartType){case"line":return function(e,t){var n;const o=e.groupData(t),r=[],i=null===(n=e.config.annotations)||void 0===n?void 0:n.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.getBounds)for(const t of o){const n=R(e,t.data,t.key);n&&r.push(n)}for(const t of o){const n=e.resolveLineStyle(t.key,t.data[0]),o=H(t.data,e.scales,e.getX,e.getY,n,t.key);i&&i.length>0&&(o.colorThresholds=i),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}return D(e,o,r),r}(s,t);case"area":return function(e,t){const n=e.groupData(t),o=[],r=e.scales.y.domain()[0],i=e.getY0?t=>{const n=e.getY0(t);return null==n?r:n}:void 0;for(const t of n){const n=e.resolveAreaStyle(t.key,t.data[0]),s=F(t.data,e.scales,e.getX,e.getY,r,n,t.key,i);e.config.gradientFill&&(s.fillGradient=e.config.gradientFill),e.config.curve&&"linear"!==e.config.curve&&(s.curve=e.config.curve),e.config.lineGradient&&(s.strokeGradient=e.config.lineGradient),o.push(s)}return D(e,n,o),o}(s,t);case"mixed":return function(e,t){const n=e.groupData(t),o=[],r=e.config.areaGroups||new Set,i=e.scales.y.domain()[0],s=e.getY0?t=>{const n=e.getY0(t);return null==n?i:n}:void 0;for(const t of n)if(r.has(t.key)){const n=e.resolveAreaStyle(t.key,t.data[0]),r=F(t.data,e.scales,e.getX,e.getY,i,n,t.key,s);e.config.gradientFill&&(r.fillGradient=e.config.gradientFill),e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),o.push(r)}else{const n=e.resolveLineStyle(t.key,t.data[0]),r=H(t.data,e.scales,e.getX,e.getY,n,t.key);e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),o.push(r)}return D(e,n,o),o}(s,t);case"stackedarea":return function(e,t){const n=e.groupData(t);n.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);const o=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,{nodes:r,stackedTops:i}=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 d;if(i){d=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;d.set(t,n||1)}}const h=[],g=new Map,f=new Map;for(const e of c)f.set(e,0);for(const n of e){const e=u.get(n.key),o=[],a=[],l=new Map;for(const n of c){let r=e.get(n)||0;const s=f.get(n);i&&(r/=d.get(n));const c=s+r,u=t.x(n);a.push([u,t.y(s)]),o.push([u,t.y(c)]),f.set(n,c),l.set(n,c)}g.set(n.key,l);const p={type:"area",topPath:o,bottomPath:a,style:r(n.key,n.data[0]),datum:n.data,group:n.key};s&&(p.curve=s),h.push(p)}return{nodes:h,stackedTops:g}}(n,e.scales,e.getX,e.getY,(t,n)=>e.resolveAreaStyle(t,n),e.config.normalize,o),s=r;if(e.config.pointStyle){const t=new WeakMap;for(const o of n){const n=i.get(o.key);if(n)for(const r of o.data){const o=e.getX(r),i=e.getY(r);null==o||Number.isNaN(o)||null==i||Number.isNaN(i)||!n.has(o)||t.set(r,n.get(o))}}const o=n=>{var o;return null!==(o=t.get(n))&&void 0!==o?o:e.getY(n)};D(e,n,s,o)}return s}(s,t);case"scatter":case"bubble":return function(e,t){const n=[],o="bubble"===e.config.chartType?10:5,r=e.config.sizeRange||[3,15];let i=null;if(e.getSize&&!e.config.pointStyle){const n=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(n.length>0){let e=1/0,t=-1/0;for(const o of n)e>o&&(e=o),o>t&&(t=o);i=n=>e===t?(r[0]+r[1])/2:r[0]+(n-e)/(t-e)*(r[1]-r[0])}}const s=e.getColor?e.resolveColorMap(t):null;for(const r of t){let t=e.config.pointStyle?e.config.pointStyle(r):{fill:"#4e79a7",opacity:.8},a=t.r||o;if(i&&e.getSize){const t=e.getSize(r);null==t||Number.isNaN(t)||(a=i(t))}if(s&&e.getColor&&!t.fill){const n=e.getColor(r);n&&s.has(n)&&(t=Object.assign(Object.assign({},t),{fill:s.get(n)}))}const l=e.getPointId?e.getPointId(r)+"":void 0,c=T(r,e.scales,e.getX,e.getY,a,t,l);c&&n.push(c)}return n}(s,t);case"heatmap":return function(e,t,n){if(e.config.heatmapAggregation)return function(e,t,n){var o,r,i;const s=Math.max(1,Math.floor(null!==(o=e.config.heatmapXBins)&&void 0!==o?o:20)),a=Math.max(1,Math.floor(null!==(r=e.config.heatmapYBins)&&void 0!==r?r:20)),l=null!==(i=e.config.heatmapAggregation)&&void 0!==i?i:"count",c=w(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[u,d]=e.scales.x.domain(),[h,g]=e.scales.y.domain(),f=(d-u||1)/s,p=(g-h||1)/a,y=s*a;if(y>1e6)return[];const m=new Int32Array(y),v=new Float64Array(y);for(let n=0;t.length>n;n++){const o=t[n],r=e.getX(o),i=e.getY(o);if(!isFinite(r)||!isFinite(i))continue;const l=Math.min(Math.floor((r-u)/f),s-1),d=Math.min(Math.floor((i-h)/p),a-1);if(0>l||0>d)continue;const g=d*s+l;m[g]++;const y=c(o);v[g]+=isFinite(y)?y:0}let b=1/0,x=-1/0;for(let e=0;y>e;e++){if(0===m[e])continue;let t;switch(l){case"sum":t=v[e];break;case"mean":t=v[e]/m[e];break;default:t=m[e]}b>t&&(b=t),t>x&&(x=t)}if(!isFinite(b))return[];const k=x-b||1,A=n.width/s,O=n.height/a,S=e.config.showValues,j=e.config.heatmapValueFormat,M=[];for(let e=0;a>e;e++){const t=e*s;for(let n=0;s>n;n++){const o=t+n;if(0===m[o])continue;let r;switch(l){case"sum":r=v[o];break;case"mean":r=v[o]/m[o];break;default:r=m[o]}const i=(r-b)/k;M.push($(n*A,(a-1-e)*O,A,O,`rgb(${220-(180*i+.5)|0},${220-(100*i+.5)|0},${255-(50*i+.5)|0})`,{xi:n,yi:e,value:r,count:m[o],sum:v[o]},S?{value:r,showValues:!0,valueFormat:j}:void 0))}}return M}(e,t,n);if(0===t.length)return[];const o=w(e.config.valueAccessor,"value"),r=A(e.config.xAccessor,"x"),s=A(e.config.yAccessor,"y"),a=new Map,l=new Map,c=Array(t.length),u=Array(t.length);for(let e=0;t.length>e;e++){const n=t[e],o=r(n),i=s(n);c[e]=o,u[e]=i,a.has(o)||a.set(o,a.size),l.has(i)||l.set(i,l.size)}const d=a.size,h=l.size;if(0===d||0===h)return[];const g=Array.from(a.keys()),f=Array.from(l.keys()),p=g.every(e=>"number"==typeof e&&!isNaN(e)),y=f.every(e=>"number"==typeof e&&!isNaN(e));if(p){g.sort((e,t)=>e-t),a.clear();for(let e=0;g.length>e;e++)a.set(g[e],e)}if(y){f.sort((e,t)=>e-t),l.clear();for(let e=0;f.length>e;e++)l.set(f[e],e)}const m=new Float64Array(t.length),v=new Float64Array(t.length),b=Array(t.length),x=new Map;let k=0;for(let e=0;t.length>e;e++){const n=t[e],r=a.get(c[e]),i=l.get(u[e]);if(void 0===r||void 0===i)continue;const s=o(n),h=i*d+r,g=x.get(h);let f;void 0!==g?f=g:(f=k++,x.set(h,f)),m[f]=h,v[f]=s,b[f]=n}let O=1/0,S=-1/0;for(let e=0;k>e;e++){const t=v[e];isFinite(t)&&(O>t&&(O=t),t>S&&(S=t))}if(!isFinite(O)||!isFinite(S))return[];const j=function(e){const t=e in W?e:"blues";let n=G.get(t);if(n)return n;n=Array(256);const o=W[t]||i.interpolateBlues;for(let e=0;256>e;e++)n[e]=o(e/255);return G.set(t,n),n}("string"==typeof e.config.colorScheme?e.config.colorScheme:"blues"),M=255/(S-O||1),C=n.width/d,E=n.height/h,_=e.config.showValues,B=e.config.heatmapValueFormat,P=[];for(let e=0;k>e;e++){const t=v[e];if(!isFinite(t))continue;const n=m[e],o=n%d;P.push($(o*C,(h-1-(n-o)/d)*E,C,E,j[Math.min((t-O)*M+.5|0,255)],b[e],_?{value:t,showValues:!0,valueFormat:B}:void 0))}return P}(s,t,e);case"bar":{const e=function(e,t){var n;if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const o=x(t,e.getX,e.getY,e.config.binSize,e.getCategory);if(0===o.size)return{nodes:[],binBoundaries:[]};let r=null;if(e.getCategory){const t=new Set;for(const e of o.values())for(const n of e.categories.keys())t.add(n);const n=e.config.barColors?Object.keys(e.config.barColors):[],i=new Set(n),s=Array.from(t).filter(e=>!i.has(e)).sort(),a=n.filter(e=>t.has(e)),l=a.join("\0")+""+s.join("\0");e.barCategoryCache&&e.barCategoryCache.key===l?r=e.barCategoryCache.order:(r=[...a,...s],e.barCategoryCache={key:l,order:r})}const i=[],s=e.scales,[a,l]=s.x.domain();for(const t of o.values()){const o=Math.max(t.start,a),c=Math.min(t.end,l);if(o>=c)continue;const u=s.x(o),d=s.x(c),h=Math.abs(d-u),g=h>2?1:0,f=Math.min(u,d)+g/2,p=Math.max(h-g,1);if(p>0)if(r&&t.categories.size>0){let o=0;for(const a of r){const r=t.categories.get(a)||0;if(0===r)continue;const l=s.y(o),c=s.y(o+r);i.push(z(f,Math.min(l,c),p,Math.abs(l-c),{fill:(null===(n=e.config.barColors)||void 0===n?void 0:n[a])||"#4e79a7"},{binStart:t.start,binEnd:t.end,total:t.total,category:a,categoryValue:r},a)),o+=r}}else{const e=s.y(0),n=s.y(t.total);i.push(z(f,Math.min(e,n),p,Math.abs(e-n),{fill:"#007bff"},{binStart:t.start,binEnd:t.end,total:t.total}))}}const c=new Set;for(const e of o.values())c.add(e.start),c.add(e.end);return{nodes:i,binBoundaries:Array.from(c).sort((e,t)=>e-t)}}(s,t);return this._barCategoryCache=null!==(n=s.barCategoryCache)&&void 0!==n?n:null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){var n,o,r,i;const s=[],a=e.config.swarmStyle||{},l=null!==(n=a.radius)&&void 0!==n?n:3,c=null!==(o=a.fill)&&void 0!==o?o:"#007bff",u=null!==(r=a.opacity)&&void 0!==r?r:.7,d=a.stroke,h=a.strokeWidth;for(const n of t){const t=e.getX(n),o=e.getY(n);if(null==o||Number.isNaN(o))continue;const r=e.scales.x(t),a=e.scales.y(o);let g=c;if(e.getCategory){const t=e.getCategory(n);g=(null===(i=e.config.barColors)||void 0===i?void 0:i[t])||g}const f={type:"point",x:r,y:a,r:l,style:{fill:g,opacity:u,stroke:d,strokeWidth:h},datum:n};e.getPointId&&(f.pointId=e.getPointId(n)+""),s.push(f)}return s}(s,t);case"waterfall":return function(e,t,n){var o,r,i;const s=[],a=e.scales,l=e.config.waterfallStyle,c=t.filter(t=>{const n=e.getY(t),o=e.getX(t);return null!=n&&!Number.isNaN(n)&&null!=o&&isFinite(o)});if(0===c.length)return s;const u=null!==(o=null==l?void 0:l.positiveColor)&&void 0!==o?o:"#28a745",d=null!==(r=null==l?void 0:l.negativeColor)&&void 0!==r?r:"#dc3545",h=null!==(i=null==l?void 0:l.gap)&&void 0!==i?i:1,g=null==l?void 0:l.stroke,f=null==l?void 0:l.strokeWidth;let p=0;for(let t=0;c.length>t;t++){const o=c[t],r=e.getX(o),i=e.getY(o),y=p+i;let m;m=c.length-1>t?e.getX(c[t+1])-r:t>0?r-e.getX(c[t-1]):0;const v=a.x(r),b=0!==m?a.x(r+m):v+n.width/10,x=Math.min(v,b)+h/2,k=Math.max(v,b)-h/2-x;if(0>=k){p=y;continue}const w=a.y(p),A=a.y(y);s.push(z(x,Math.min(w,A),k,Math.abs(w-A),{fill:0>i?d:u,stroke:g,strokeWidth:f},Object.assign(Object.assign({},o),{baseline:p,cumEnd:y,delta:i,_connectorStroke:null==l?void 0:l.connectorStroke,_connectorWidth:null==l?void 0:l.connectorWidth}))),p=y}return s}(s,t,e);case"candlestick":return function(e,t){var n,o;if(!e.getHigh||!e.getLow||!e.scales)return[];const r=null!==(n=e.config.candlestickRangeMode)&&void 0!==n&&n;if(!(r||e.getOpen&&e.getClose))return[];const i=[],s=e.config.candlestickStyle||{},a=s.rangeColor||"#6366f1",l=r?a:s.upColor||"#28a745",c=r?a:s.downColor||"#dc3545",u=r?a:s.wickColor||"#333",d=s.wickWidth||(r?2:1),h=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let g=r?0:null!==(o=s.bodyWidth)&&void 0!==o?o:0;if(!r&&null==s.bodyWidth&&h.length>1){let t=1/0;for(let n=1;h.length>n;n++){const o=Math.abs(e.scales.x(h[n])-e.scales.x(h[n-1]));o>0&&t>o&&(t=o)}g=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else r||null!=s.bodyWidth||(g=6);for(const n of t){const t=e.getX(n);if(null==t||Number.isNaN(t))continue;const o=e.getHigh(n),s=e.getLow(n);if(null==o||Number.isNaN(o)||null==s||Number.isNaN(s))continue;const a=r?o:e.getOpen(n),h=r?s:e.getClose(n);if(!r&&[a,h].some(e=>null==e||Number.isNaN(e)))continue;const f=h>=a,p={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(a),closeY:e.scales.y(h),highY:e.scales.y(o),lowY:e.scales.y(s),bodyWidth:g,upColor:l,downColor:c,wickColor:u,wickWidth:d,isUp:f,datum:n};r&&(p.isRange=!0),i.push(p)}return i}(s,t);default:return[]}}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){const n=this.config.decay;return n&&t>1?P(n,e,t):1}applyDecay(e,t){this.config.decay&&function(e,t,n){var o,r;const i=n.length;if(1>=i)return;const s=new Map;for(let e=0;n.length>e;e++)s.set(n[e],e);for(const n of t){if("line"===n.type){const t=Array.isArray(n.datum)?n.datum:[];if(2>t.length)continue;const o=Array(t.length);let r=!1;for(let n=0;t.length>n;n++){const a=s.get(t[n]);null!=a?(o[n]=P(e,a,i),1>o[n]&&(r=!0)):o[n]=1}r&&(n._decayOpacities=o);continue}if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[],o=n.topPath?n.topPath.length:t.length;if(2>o)continue;if(t.length===o){const r=Array(o);let a=!1;for(let n=0;t.length>n;n++){const o=s.get(t[n]);null!=o?(r[n]=P(e,o,i),1>r[n]&&(a=!0)):r[n]=1}a&&(n._decayOpacities=r)}else{let r=1;for(const n of t){const t=s.get(n);if(null!=t){const n=P(e,t,i);r>n&&(r=n)}}if(1>r){const e=Array(o);e.fill(r),n._decayOpacities=e}}continue}const t=s.get(n.datum);if(null==t)continue;const a=P(e,t,i);if("heatcell"===n.type)n.style={opacity:a};else if("candlestick"===n.type)n._decayOpacity=a;else{const e=null!==(r=null===(o=n.style)||void 0===o?void 0:o.opacity)&&void 0!==r?r:1;n.style=Object.assign(Object.assign({},n.style),{opacity:e*a})}}}(this.config.decay,e,t)}applyPulse(e,t){this.config.pulse&&this.timestampBuffer&&function(e,t,n,o){var r,i;const s="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(r=e.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",l=null!==(i=e.glowRadius)&&void 0!==i?i:4,c=new Map;for(let e=0;n.length>e;e++)c.set(n[e],e);for(const n of t){if("line"===n.type)continue;if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[n.datum];let r=0;for(const n of t){const t=c.get(n);if(null==t)continue;const i=o.get(t);if(null==i)continue;const a=L(e,i,s);a>r&&(r=a)}r>0&&(n._pulseIntensity=r,n._pulseColor=a);continue}const t=c.get(n.datum);if(null==t)continue;const r=o.get(t);if(null==r)continue;const i=L(e,r,s);i>0&&(n._pulseIntensity=i,n._pulseColor=a,n._pulseGlowRadius=l)}}(this.config.pulse,e,t,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(e,t){var n;if(!t||0===t.size)return!1;const o="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(n=e.duration)&&void 0!==n?n:500,i=t.peek();return null!=i&&r>o-i}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(e,t,n,o){var r,i,s;n.clear(),o.clear();for(let a=0;t.length>a;a++){const l=t[a],c=I(e,l,a);c&&("point"===l.type?n.set(c,{x:l.x,y:l.y,r:l.r,opacity:l.style.opacity}):"rect"===l.type?n.set(c,{x:l.x,y:l.y,w:l.w,h:l.h,opacity:l.style.opacity}):"heatcell"===l.type?n.set(c,{x:l.x,y:l.y,w:l.w,h:l.h,opacity:null===(r=l.style)||void 0===r?void 0:r.opacity}):"candlestick"===l.type?n.set(c,{x:l.x,y:l.openY}):"line"===l.type?o.set(c,{path:l.path.map(e=>[e[0],e[1]]),opacity:null===(i=l.style)||void 0===i?void 0:i.opacity}):"area"===l.type&&o.set(c,{topPath:l.topPath.map(e=>[e[0],e[1]]),bottomPath:l.bottomPath.map(e=>[e[0],e[1]]),opacity:null===(s=l.style)||void 0===s?void 0:s.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}startTransition(){if(!this.config.transition)return;const e=function(e,t,n,o,r){var i,s,a,l,c,u,d,h,g,f,p,y,m,v,b,x,k,w,A,O,S,j,M,C,E,_,B,P;if(0===o.size&&0===r.size)return n;const L=null!==(i=t.duration)&&void 0!==i?i:300;if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}let N=!1;const H=new Set,F=new Set;for(let t=0;n.scene.length>t;t++){const i=n.scene[t],A=I(e,i,t);if(!A)continue;if(i._transitionKey=A,"line"===i.type||"area"===i.type){const e=r.get(A);if(e){if(F.add(A),"line"===i.type&&e.path&&e.path.length===i.path.length){i._targetPath=i.path.map(e=>[e[0],e[1]]),i._prevPath=e.path;for(let t=0;i.path.length>t;t++)i.path[t]=[e.path[t][0],e.path[t][1]];N=!0}else if("area"===i.type&&e.topPath&&e.bottomPath&&e.topPath.length===i.topPath.length&&e.bottomPath.length===i.bottomPath.length){i._targetTopPath=i.topPath.map(e=>[e[0],e[1]]),i._targetBottomPath=i.bottomPath.map(e=>[e[0],e[1]]),i._prevTopPath=e.topPath,i._prevBottomPath=e.bottomPath;for(let t=0;i.topPath.length>t;t++)i.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;i.bottomPath.length>t;t++)i.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];N=!0}i._targetOpacity=null!==(s=i.style.opacity)&&void 0!==s?s:1,i._startOpacity=null!==(l=null!==(a=e.opacity)&&void 0!==a?a:i.style.opacity)&&void 0!==l?l:1}else i._targetOpacity=null!==(c=i.style.opacity)&&void 0!==c?c:1,i._startOpacity=0,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),N=!0;continue}const O=o.get(A);if("point"===i.type)if(O){H.add(A);const e={x:i.x,y:i.y,r:i.r};i._targetOpacity=null!==(u=i.style.opacity)&&void 0!==u?u:1,O.x===e.x&&O.y===e.y&&O.r===e.r||(i._targetX=e.x,i._targetY=e.y,i._targetR=e.r,i.x=O.x,i.y=O.y,i.r=null!==(d=O.r)&&void 0!==d?d:i.r,N=!0)}else i._targetOpacity=null!==(h=i.style.opacity)&&void 0!==h?h:1,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),N=!0;else if("rect"===i.type)if(O){H.add(A);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=null!==(g=i.style.opacity)&&void 0!==g?g:1,O.x===e.x&&O.y===e.y&&O.w===e.w&&O.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=O.x,i.y=O.y,i.w=null!==(f=O.w)&&void 0!==f?f:i.w,i.h=null!==(p=O.h)&&void 0!==p?p:i.h,N=!0)}else i._targetOpacity=null!==(y=i.style.opacity)&&void 0!==y?y:1,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),N=!0;else if("heatcell"===i.type)if(O){H.add(A);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=null!==(v=null===(m=i.style)||void 0===m?void 0:m.opacity)&&void 0!==v?v:1,O.x===e.x&&O.y===e.y&&O.w===e.w&&O.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=O.x,i.y=O.y,i.w=null!==(b=O.w)&&void 0!==b?b:i.w,i.h=null!==(x=O.h)&&void 0!==x?x:i.h,N=!0)}else i._targetOpacity=null!==(w=null===(k=i.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,i.style=Object.assign(Object.assign({},i.style||{}),{opacity:0}),N=!0}for(const[e,t]of r)if(!F.has(e))if(e.startsWith("l:")&&t.path){const o={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(A=t.opacity)&&void 0!==A?A:1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(o),N=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const o={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!==(O=t.opacity)&&void 0!==O?O:1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(o),N=!0}for(const[e,t]of o)if(!H.has(e)){if(e.startsWith("p:")){const o={type:"point",x:t.x,y:t.y,r:null!==(S=t.r)&&void 0!==S?S:3,style:{opacity:null!==(j=t.opacity)&&void 0!==j?j:1},datum:null,_targetOpacity:0,_transitionKey:e};n.exitNodes.push(o)}else if(e.startsWith("r:")){const o={type:"rect",x:t.x,y:t.y,w:null!==(M=t.w)&&void 0!==M?M:0,h:null!==(C=t.h)&&void 0!==C?C:0,style:{opacity:null!==(E=t.opacity)&&void 0!==E?E:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e};n.exitNodes.push(o)}else if(e.startsWith("h:")){const o={type:"heatcell",x:t.x,y:t.y,w:null!==(_=t.w)&&void 0!==_?_:0,h:null!==(B=t.h)&&void 0!==B?B:0,fill:"#999",datum:null,style:{opacity:null!==(P=t.opacity)&&void 0!==P?P:1},_targetOpacity:0,_transitionKey:e};n.exitNodes.push(o)}N=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),N&&(n.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:L}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition}advanceTransition(e){if(!this.activeTransition||!this.config.transition)return!1;const t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(e,t,n,o){var r,i,s,a,l;if(!n.activeTransition)return!1;const c=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,n.activeTransition),u=function(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}(c,"linear"===t.easing?"linear":"ease-out-cubic");for(const e of n.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0,i=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;e.style.opacity=N(i,e._targetOpacity,u)}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=N(n.x,e._targetX,u),e.y=N(n.y,e._targetY,u),void 0!==e._targetR&&void 0!==n.r&&(e.r=N(n.r,e._targetR,u))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0,r=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;e.style.opacity=N(r,e._targetOpacity,u)}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=N(n.x,e._targetX,u),e.y=N(n.y,e._targetY,u),void 0!==n.w&&(e.w=N(n.w,e._targetW,u)),void 0!==n.h&&(e.h=N(n.h,e._targetH,u))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0,r=n?null!==(s=n.opacity)&&void 0!==s?s:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:N(r,e._targetOpacity,u)})}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=N(n.x,e._targetX,u),e.y=N(n.y,e._targetY,u),void 0!==n.w&&(e.w=N(n.w,e._targetW,u)),void 0!==n.h&&(e.h=N(n.h,e._targetH,u))}else if("line"===e.type){if(void 0!==e._targetOpacity){const t=null!==(a=e._startOpacity)&&void 0!==a?a:0;e.style=Object.assign(Object.assign({},e.style),{opacity:N(t,e._targetOpacity,u)})}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],u),e.path[o][1]=N(t[o][1],n[o][1],u)}else if("area"===e.type){if(void 0!==e._targetOpacity){const t=null!==(l=e._startOpacity)&&void 0!==l?l:0;e.style=Object.assign(Object.assign({},e.style),{opacity:N(t,e._targetOpacity,u)})}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],u),e.topPath[n][1]=N(t[n][1],o[n][1],u);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],u),e.bottomPath[t][1]=N(n[t][1],r[t][1],u)}}if(c>=1){for(const e of n.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(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(e,this.config.transition,t,this.prevPositionMap);return this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition,n}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:M,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:this.resolveGroupColor(e)||"#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}if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||"#4e79a7",fillOpacity:null!==(n=o.fillOpacity)&&void 0!==n?n:.7,stroke:o.stroke||"#4e79a7",strokeWidth:o.strokeWidth||2};const r=this.resolveGroupColor(e)||"#4e79a7";return{fill:r,fillOpacity:.7,stroke:r,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:M,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()}remove(e){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");const t=new Set(Array.isArray(e)?e:[e]),n=this.getPointId,o=e=>t.has(n(e));if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),t=new Set;this.buffer.forEach((e,n)=>{o(e)&&t.add(n)}),this.timestampBuffer.clear();for(let n=0;e.length>n;n++)t.has(n)||this.timestampBuffer.push(e[n])}const r=this.buffer.remove(o);if(0===r.length)return r;for(const e of r)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)),this.getY0&&this.yExtent.evict(this.getY0(e)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,r}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=new Set(Array.isArray(e)?e:[e]),o=this.getPointId,r=new Set;this.buffer.forEach((e,t)=>{n.has(o(e))&&r.add(t)});const i=this.buffer.update(e=>n.has(o(e)),t);if(0===i.length)return i;for(const e of i)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)),this.getY0&&this.yExtent.evict(this.getY0(e)));return this.buffer.forEach((e,t)=>{r.has(t)&&(this.xExtent.push(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))):(this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,i}getBinBoundaries(){return this._binBoundaries}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._binBoundaries=[],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||!k(null!==(t=e.xAccessor)&&void 0!==t?t:e.timeAccessor,null!==(n=i.xAccessor)&&void 0!==n?n:i.timeAccessor),c=a||!k(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=w(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=w(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=w(this.config.xAccessor,"x"),this.getY=w(this.config.yAccessor,"y")),s=!0)}if("groupAccessor"in e&&!k(e.groupAccessor,i.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?O(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in e&&!k(e.categoryAccessor,i.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?O(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in e&&!k(e.sizeAccessor,i.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?w(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in e&&!k(e.colorAccessor,i.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?O(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in e&&!k(e.y0Accessor,i.y0Accessor)&&(this.getY0=this.config.y0Accessor?w(this.config.y0Accessor,"y0"):void 0,s=!0),"pointIdAccessor"in e&&!k(e.pointIdAccessor,i.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?O(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&("openAccessor"in e&&!k(e.openAccessor,i.openAccessor)||"closeAccessor"in e&&!k(e.closeAccessor,i.closeAccessor)||"highAccessor"in e&&!k(e.highAccessor,i.highAccessor)||"lowAccessor"in e&&!k(e.lowAccessor,i.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?w(this.config.openAccessor,"open"):void 0,this.getHigh=w(this.config.highAccessor,"high"),this.getLow=w(this.config.lowAccessor,"low"),this.getClose=t?w(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,s=!0}if(!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 q(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 X(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function V(e,t){const n=X(e);if(!n)return!1;const o=X(t);return!o||n.getFullYear()!==o.getFullYear()||n.getMonth()!==o.getMonth()}function U(e,t,n,o=30,r){let i=null,s=!1;if(r){const e=r.find(t,n,o);if(e){const r=K(e,t,n,o);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=K(a,t,n,o);break;case"line":e=J(a,t,n,o);break;case"rect":e=ee(a,t,n);break;case"heatcell":e=te(a,t,n);break;case"area":if(!1===a.interactive)break;e=oe(a,t,n);break;case"candlestick":e=ne(a,t,n)}e&&o>e.distance&&(i&&e.distance>=i.distance||(i=e))}return i}function Q(e,t,n){if(0===e.length)return null;const o=re(e,t);if(0>o)return null;if(Math.abs(e[o][0]-t)>n)return null;let r=o,i=o;o>0&&e[o][0]>=t?(r=o-1,i=o):e.length-1>o&&(r=o,i=o+1);const[s,a]=e[r],[l,c]=e[i];return l===s?a:a+Math.max(0,Math.min(1,(t-s)/(l-s)))*(c-a)}function K(e,t,n,o=30){const r=t-e.x,i=n-e.y,s=Math.sqrt(r*r+i*i),a=function(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}(e.r,o);return s>a?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function J(e,t,n,o=30){var r,i,s,a;if(0===e.path.length)return null;const l=re(e.path,t);if(0>l)return null;const[c,u]=e.path[l];let d;if(e.path.length>1){let o=1/0;const r=Math.max(0,l-1),i=Math.min(e.path.length-2,l);for(let s=r;i>=s;s++){const[r,i]=e.path[s],[a,l]=e.path[s+1],c=Z(t,n,r,i,a,l);o>c&&(o=c)}d=o}else{const e=t-c,o=n-u;d=Math.sqrt(e*e+o*o)}const h=null!==(a=null!==(i=null===(r=e.style)||void 0===r?void 0:r.strokeWidth)&&void 0!==i?i:null===(s=e.style)||void 0===s?void 0:s.lineWidth)&&void 0!==a?a:1;return d>Math.max(5,h/2+2,o)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[l]?e.datum[l]:e.datum,x:c,y:u,distance:d}}function Z(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 ee(e,t,n){const o=q(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function te(e,t,n){const o=q(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function ne(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 oe(e,t,n){if(0===e.topPath.length)return null;const o=re(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 re(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const r=n+o>>1;t>e[r][0]?n=r+1:o=r}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}function ie(e,t,n){const o=e.byGroup.get(t);let r=0,i=Math.abs(o[0].x-n.x);for(let e=1;o.length>e;e++){const t=Math.abs(o[e].x-n.x);i>t&&(i=t,r=e)}return o[r]._flatIndex}function se(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})}Y.QUADTREE_THRESHOLD=500;const ae={fill:e=>h.createElement("rect",{style:e,width:16,height:16}),line:e=>h.createElement("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function le(e,t,n,o){let r;return r="function"==typeof n?n(e):(0,ae[n])(o(e,t)),r}function ce(){return h.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function ue(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function de({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-"+h.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(h.createElement("stop",{key:e,offset:100*t+"%",stopColor:o(r[0]+t*(r[1]-r[0]))}))}return h.createElement("g",{"aria-label":i||"Gradient legend"},h.createElement("defs",null,h.createElement("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},c)),i&&h.createElement("text",{x:s+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),h.createElement("rect",{x:s,y:0,width:t,height:e,fill:`url(#${l})`,rx:2}),h.createElement("text",{x:s,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[0])),h.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(h.createElement("stop",{key:e,offset:100*t+"%",stopColor:o(r[1]-t*(r[1]-r[0]))}))}return h.createElement("g",{"aria-label":i||"Gradient legend"},i&&h.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),h.createElement("defs",null,h.createElement("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},c)),h.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${l})`,rx:2}),h.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[1])),h.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[0])))}function he(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,[d,g]=h.useState(0),[f,p]=h.useState(0),y=h.useCallback((e,t)=>{g(e),p(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 d=[];return e.forEach((e,g)=>{u+=5,d.push(h.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,d.push(h.createElement("text",{key:"legend-text-"+g,y:u,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label)),u+=8),d.push(h.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:d,items:g}=e,f=[];let p=0;const y=!(!t&&!n),m="isolate"===c||void 0===c&&null!=r;return g.forEach((e,c)=>{const v=le(e,c,u,d),b=ue(e,o,r),x=r&&r.size>0&&r.has(e.label);f.push(h.createElement("g",{key:"legend-item-"+c,transform:`translate(0,${p})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:y?a===i&&c===s?0:-1:void 0,role:y?"option":void 0,"aria-selected":y&&m?x||!1:void 0,"aria-current":y&&!m&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:y?n=>{var o;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(c+("ArrowDown"===n.key?1:-1)+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:y?t=>{l(a,c),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:y?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:y?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},y&&h.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&&h.createElement(ce,null),h.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),p+=22}),f})(e,n,o,r,i,s,a,g,l,c))),u+=22*e.items.length+8}),d})({legendGroups:t||[],width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:d,focusedItemIndex:f,onFocusedIndexChange:y,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 d=0;const g=[];e.forEach((e,t)=>{let f=0;e.label&&(f+=16);const p=((e,t,n,o,r,i,s,a,l,c,u)=>{const{type:d="fill",styleFn:g,items:f}=e,p=[];let y=0,m=0;const v=!(!t&&!n),b="isolate"===c||void 0===c&&null!=r;f.forEach((e,c)=>{const x=le(e,c,d,g),k=ue(e,o,r),w=r&&r.size>0&&r.has(e.label),A=26+7*e.label.length;u&&u>0&&y>0&&y+A>u&&(m++,y=0),p.push(h.createElement("g",{key:"legend-item-"+c,transform:`translate(${y},${22*m})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:v?a===i&&c===s?0:-1:void 0,role:v?"option":void 0,"aria-selected":v&&b?w||!1:void 0,"aria-current":v&&!b&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:v?n=>{var o;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(c+("ArrowRight"===n.key?1:-1)+f.length)%f.length;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:v?t=>{l(a,c),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:v?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:v?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},v&&h.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"}),x,w&&h.createElement(ce,null),h.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),y+=A});let x=0,k=0;for(const e of f){const t=26+7*e.label.length;u&&u>0&&k>0&&k+t>u?(x=Math.max(x,k),k=t):k+=t}x=Math.max(x,k);const w=m+1;return{items:p,offset:x,totalRows:w,totalHeight:22*w}})(e,o,r,i,s,a,l,t,c,u,n);f+=p.offset+5,g.push(Object.assign(Object.assign({label:e.label},p),{offset:f,totalRows:p.totalRows,totalHeight:p.totalHeight})),d+=f+12});let f=d>n?0:Math.max(0,(n-d)/2);const p=[];return g.forEach((n,o)=>{const r=e[o];r.label&&(p.push(h.createElement("text",{key:"legend-text-"+o,transform:`translate(${f},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},r.label)),f+=16),p.push(h.createElement("g",{key:"legend-group-"+o,className:"legend-item",transform:`translate(${f},0)`},n.items)),f+=n.offset+5,e[o+1]&&p.push(h.createElement("line",{key:"legend-top-line legend-symbol-"+o,stroke:"gray",x1:f,y1:-8,x2:f,y2:(n.totalHeight||t)+0+8})),f+=12}),h.createElement("g",null,p)})({legendGroups:t||[],title:a,height:c,width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:d,focusedItemIndex:f,onFocusedIndexChange:y,legendInteraction:s}),v=!(!n&&!o);return h.createElement("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"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&&h.createElement("text",{className:"legend-title",y:16,x:l/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},a),m)}function ge(e){return"string"==typeof e?{type:e}:e}function fe({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:d}=e,g=Math.min(.5*n,20),f=(n-g)/2+4;if(c){const e=r(i),n=r(a),o=r(s),c=r(u),p=r(d),y="top"===t?-1:1,m=0;return h.createElement("g",{"data-testid":"marginal-boxplot-"+t},h.createElement("line",{x1:c,y1:m+y*(f+g/2),x2:p,y2:m+y*(f+g/2),stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:c,y1:m+y*f,x2:c,y2:m+y*(f+g),stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:p,y1:m+y*f,x2:p,y2:m+y*(f+g),stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("rect",{x:Math.min(e,n),y:"top"===t?m-f-g:m+f,width:Math.abs(n-e),height:g,fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:o,y1:"top"===t?m-f-g:m+f,x2:o,y2:"top"===t?m-f:m+f+g,stroke:l.fill,strokeWidth:2}))}{const e=r(i),n=r(a),o=r(s),c=r(u),p=r(d),y="left"===t?-1:1,m=0;return h.createElement("g",{"data-testid":"marginal-boxplot-"+t},h.createElement("line",{x1:m+y*(f+g/2),y1:c,x2:m+y*(f+g/2),y2:p,stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:m+y*f,y1:c,x2:m+y*(f+g),y2:c,stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:m+y*f,y1:p,x2:m+y*(f+g),y2:p,stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("rect",{x:"left"===t?m-f-g:m+f,y:Math.min(e,n),width:g,height:Math.abs(n-e),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:"left"===t?m-f-g:m+f,y1:o,x2:"left"===t?m-f:m+f+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 d=Math.max(...u.map(e=>e.length));if(0===d)return null;if("histogram"===l.type)return h.createElement("g",{"data-testid":"marginal-histogram-"+t},u.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const i=e.length/d*n;if(c){const n=r(e.x0),s=r(e.x1)-r(e.x0);return h.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 h.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/d*(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/d*(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 h.createElement("g",{"data-testid":"marginal-violin-"+t},h.createElement("polygon",{points:o.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}if("ridgeline"===l.type){const e=[];if(c){const o=0,i=null!=u[0].x0?r(u[0].x0):0;e.push(`M${i},${o}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const i=o.length/d*n,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/d*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 h.createElement("g",{"data-testid":"marginal-ridgeline-"+t},h.createElement("path",{d:e.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}return null},[o,r,l,i,a,t,c,4]);return u?h.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},u):null}function pe(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 ye(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 me(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:d,className:g,disable:f,events:p={},"data-testid":y}=e,m=new Set(Array.isArray(f)?f:[]);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 h.createElement("g",Object.assign({className:("annotation "+(g||"")).trim(),transform:`translate(${t},${n})`,"data-testid":y},p),!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,d=o/2,h=e*d>t*u?u/e:d/t;a=r+s*h,l=i+c*h}}}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(h.createElement("line",{key:"connector-line",x1:a,y1:l,x2:e,y2:t,stroke:o||"var(--semiotic-text-secondary, 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(h.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||"var(--semiotic-text-secondary, currentColor)",stroke:"none"}))}return h.createElement("g",{className:"annotation-connector"},s)}(v,b,l,d,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(h.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, 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(h.createElement("rect",{key:"subject-rect",width:e,height:o,fill:"none",stroke:n||"var(--semiotic-text-secondary, 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(h.createElement("line",{key:"threshold-line",x1:o,y1:(t.y1||0)-i,x2:o,y2:(t.y2||0)-i,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}))}else if(void 0!==(null==t?void 0:t.y)){const o=(t.y||0)-i;s.push(h.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:o,x2:(t.x2||0)-e,y2:o,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}))}else void 0!==(null==t?void 0:t.x1)||void 0!==(null==t?void 0:t.x2)?s.push(h.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"})):void 0===(null==t?void 0:t.y1)&&void 0===(null==t?void 0:t.y2)||s.push(h.createElement("line",{key:"threshold-line",x1:0,y1:(t.y1||0)-i,x2:0,y2:(t.y2||0)-i,stroke:n||"var(--semiotic-text-secondary, 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(h.createElement("path",{key:"bracket-path",d:ye((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||"var(--semiotic-text-secondary, currentColor)"}));break}}return h.createElement("g",{className:"annotation-subject"},s)}(x,c,d,t,n),!m.has("note")&&function(e,t,n,o){if(!e)return h.createElement("g",{className:"annotation-note"});const{label:r,title:i,orientation:s,align:a,wrap:l=120,noWrap:c}=e;if(!r&&!i)return h.createElement("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=a;d&&"dynamic"!==d||(d="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let g="start";"topBottom"===u?"right"===d?g="end":"middle"===d&&(g="middle"):g=0>t?"end":"start";const f=16,p=i?c?[i]:pe(i,l):[],y=r?c?[r]:pe(r,l):[],m="leftRight"===u?"end"===g?-4:4:0;let v=0;const b=[],x=o||"var(--semiotic-text, #333)";p.length>0&&(b.push(h.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:x,textAnchor:g,fontWeight:"bold"},p.map((e,t)=>h.createElement("tspan",{key:t,x:m,dy:0===t?0:f},e)))),v=p.length*f),y.length>0&&b.push(h.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:x,textAnchor:g,y:v},y.map((e,t)=>h.createElement("tspan",{key:t,x:m,dy:0===t?0:f},e))));let k=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),k=h.createElement("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(p.length+y.length)*f+(y.length>0?f:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),k=h.createElement("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,p.length+y.length-1)*f;let A=0;return"topBottom"===u?A=0>n?-(w+2):18:"leftRight"===u&&(A="middle"===d?-(w+f+(y.length>0&&p.length>0?2:0))/2+8:"bottom"===d||0>n?-(w+2):18),h.createElement("g",{className:"annotation-note",transform:`translate(${t},${n})`},h.createElement("g",{className:"annotation-note-content",transform:0!==A?`translate(0,${A})`:void 0},b),k)}(a,v,b,d))}function ve(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 h.createElement(me,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},r,{type:i}))});return h.createElement("g",null,a)}const a=o.note||{title:"none",label:o.label};return h.createElement(me,Object.assign({"data-testid":"semiotic-annotation",key:`${a.label}-${a.title}-${o.i}`,events:s},o,{type:i}))}function be(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 xe(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 ke(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 d=l[e.xAccessor||"x"],h=l[e.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return i&&(null===(r=n.stickyPositionCache)||void 0===r||r.set(t,i)),i}let l=null,c=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(l=t.x,c=t.y)}if(null!=l&&null!=c||(l=be(e,n),c=xe(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 we(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}const Ae={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};let Oe={positions:new Map};const Se=new Set;function je(){for(const e of Se)e()}function Me(e,t){const n=Oe.positions.get(e);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==t)return;const o=new Map(Oe.positions);o.delete(e),Oe={positions:o},je()}function Ce(e,t){const n=Oe.positions.get(e);if(!(null==n?void 0:n.locked))return;if(t&&n.sourceId!==t)return;const o=new Map(Oe.positions);o.delete(e),Oe={positions:o},je()}function Ee(){return Oe}function _e(e){return Se.add(e),()=>Se.delete(e)}const Be={positions:new Map};function Pe(){return()=>{}}function Le(){return Be}function Ne(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Ie(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 He(t){const{width:n,height:o,totalWidth:r,totalHeight:i,margin:s,scales:a,showAxes:l,axes:c,showGrid:u,xFormat:d,yFormat:g}=t,f=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)||d||Fe,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,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0);return Te(l,Math.max(55,u+8))},[a,c,d,n]),p=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||Fe,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return Te(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]),y=u&&a,m=l&&a;if(!y&&!m)return null;const v=null==c?void 0:c.find(e=>"bottom"===e.orient),b=null==c?void 0:c.find(e=>"left"===e.orient),x=m&&(!v||!1!==v.baseline),k=m&&(!b||!1!==b.baseline),w=(null==v?void 0:v.jaggedBase)||!1,A=(null==b?void 0:b.jaggedBase)||!1,O="var(--semiotic-border, #ccc)";return h.createElement("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},h.createElement("g",{transform:`translate(${s.left},${s.top})`},y&&(()=>{var e,t;const r=Ne(null===(e=null==c?void 0:c.find(e=>"bottom"===e.orient))||void 0===e?void 0:e.gridStyle),i=Ne(null===(t=null==c?void 0:c.find(e=>"left"===e.orient))||void 0===t?void 0:t.gridStyle);return h.createElement("g",{className:"stream-grid"},f.map((e,t)=>h.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r})),p.map((e,t)=>h.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:n,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i})))})(),x&&!w&&h.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:O,strokeWidth:1}),w&&h.createElement("path",{d:Ie("bottom",n,o),fill:"none",stroke:O,strokeWidth:1}),k&&!A&&h.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:O,strokeWidth:1}),A&&h.createElement("path",{d:Ie("left",n,o),fill:"none",stroke:O,strokeWidth:1})))}function Fe(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function Te(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 ze(t){var n,o;const{width:r,height:i,totalWidth:s,totalHeight:c,margin:u,scales:d,showAxes:f,axes:p,xLabel:y,yLabel:m,yLabelRight:v,xFormat:b,yFormat:x,showGrid:k,title:w,legend:A,legendHoverBehavior:O,legendClickBehavior:S,legendHighlightedCategory:j,legendIsolatedCategories:M,legendPosition:C="right",foregroundGraphics:E,marginalGraphics:_,xValues:B,yValues:P,annotations:L,svgAnnotationRules:N,xAccessor:I,yAccessor:H,annotationData:F,pointNodes:T,curve:z,underlayRendered:$,linkedCrosshairName:R,linkedCrosshairSourceId:D,children:W}=t,G=e.useMemo(()=>{var e;if(!f||!d)return[];const t=null==p?void 0:p.find(e=>"bottom"===e.orient),n=(null==t?void 0:t.tickFormat)||b||Fe,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,i=d.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:d.x(e),label:n(e,t,s)})),l=a.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0),c=(null==t?void 0:t.autoRotate)?Math.max(20,Math.min(l+8,55)):Math.max(55,l+8);let u=Te(a,c);if(u.length>1&&(u=u.filter((e,t)=>0===t||e.label+""!=u[t-1].label+"")),(null==t?void 0:t.includeMax)&&u.length>0){const e=d.x.domain()[1],t=d.x(e),o=u[u.length-1].pixel;if(Math.abs(t-o)>1){const r=n(e,u.length,s);c>t-o&&u.length>1&&(u=u.slice(0,-1)),u.push({value:e,pixel:t,label:r})}}return u},[f,d,p,b,r]),Y=e.useMemo(()=>{var e;if(!f||!d)return[];const t=null==p?void 0:p.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||x||Fe,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;let r=Te(d.y.ticks(Math.min(o,Math.max(2,Math.floor(i/30)))).map(e=>({value:e,pixel:d.y(e),label:n(e)})),22);if(r.length>1&&(r=r.filter((e,t)=>0===t||e.label+""!=r[t-1].label+"")),(null==t?void 0:t.includeMax)&&r.length>0){const e=d.y.domain()[1],t=d.y(e),o=r[r.length-1].pixel;if(Math.abs(t-o)>1){const i=n(e);22>Math.abs(t-o)&&r.length>1&&(r=r.slice(0,-1)),r.push({value:e,pixel:t,label:i})}}return r},[f,d,p,x,i]),q=e.useMemo(()=>{var e;if(!f||!d)return[];const t=null==p?void 0:p.find(e=>"right"===e.orient);if(!t)return[];const n=t.tickFormat||x||Fe,o=null!==(e=t.ticks)&&void 0!==e?e:5;return Te(d.y.ticks(Math.min(o,Math.max(2,Math.floor(i/30)))).map(e=>({value:e,pixel:d.y(e),label:n(e)})),22)},[f,d,p,x,i]),X=e.useRef(new Map),U=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;U.current!==Q&&(U.current=Q,X.current=new Map);const K=e.useMemo(()=>{if(!L||0===L.length)return null;const e=function(e,t,n){var o,r,i,s,c,u,d,f,p,y,m,v,b,x,k,w,A,O,S,j,M,C,E,_,B,P,L,N,I,H,F,T,z,$,R,D,W,G,Y,q,X,V,U,Q,K,J,Z,ee;switch(e.type){case"label":{const o=ke(e,t,n);if(!o)return null;const{x:r,y:i}=o;return we(r,i,n)?h.createElement(ve,{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=ke(e,t,n);if(!o)return null;const{x:r,y:i}=o;return we(r,i,n)?h.createElement(ve,{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=be(e,n);if(null==o)return null;const r=e.color||"#f97316",i=e.labelPosition||"top";let s;return s="bottom"===i?(n.height||0)-4:"center"===i?(n.height||0)/2:12,h.createElement("g",{key:"ann-"+t},h.createElement("line",{x1:o,y1:0,x2:o,y2:n.height||0,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&h.createElement("text",{x:o+4,y:s,fill:r,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const o=xe(e,n);if(null==o)return null;const r=e.color||"#f97316",i=e.labelPosition||"right";let s,a;return"left"===i?(s=4,a="start"):"center"===i?(s=(n.width||0)/2,a="middle"):(s=(n.width||0)-4,a="end"),h.createElement("g",{key:"ann-"+t},h.createElement("line",{x1:0,y1:o,x2:n.width||0,y2:o,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&h.createElement("text",{x:s,y:o-4,textAnchor:a,fill:r,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const o=(e.coordinates||[]).map(e=>({x:be(Object.assign(Object.assign({},e),{type:"point"}),n),y:xe(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 h.createElement("g",{key:"ann-"+t},h.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&&h.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:be(Object.assign(Object.assign({},e),{type:"point"}),n),y:xe(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 h.createElement("g",{key:"ann-"+t},h.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&&h.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 h.createElement("g",{key:"ann-"+t},r.map((t,o)=>{const r=be(t,n),s=xe(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 h.createElement("circle",Object.assign({key:"hl-"+o,cx:r,cy:s,r:a},l))}))}case"bracket":{const o=be(e,n),r=xe(e,n);return h.createElement(ve,{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",f=n.yAccessor||"y",p=a.map(e=>[e[l],e[f]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>p.length)return null;const y=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(!y||!m)return null;const v=e.method||"linear";let b;b="loess"===v?function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),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,d=0,h=0,g=0,f=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*r[e],h+=t*i[e],g+=t*r[e]*r[e],f+=t*r[e]*i[e])}if(0===u){a.push([t,i[e]]);continue}const p=u*g-d*d;if(1e-12>Math.abs(p))a.push([t,h/u]);else{const e=(u*f-d*h)/p;a.push([t,(h-e*d)/u+e*t])}}return a}(p,null!==(d=e.bandwidth)&&void 0!==d?d:.3):("polynomial"===v?g.default.polynomial(p,{order:e.order||2}):g.default.linear(p)).points;const x=b.map(([e,t])=>`${y(e)},${m(t)}`).join(" "),k=e.color||"#6366f1";return h.createElement("g",{key:"ann-"+t},h.createElement("polyline",{points:x,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&h.createElement("text",{x:y(b[b.length-1][0])+4,y:m(b[b.length-1][1])-4,fill:k,fontSize:11},e.label))}case"band":{const o=null!==(p=null===(f=n.scales)||void 0===f?void 0:f.y)&&void 0!==p?p:null===(y=n.scales)||void 0===y?void 0:y.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 h.createElement("g",{key:"ann-"+t},h.createElement("rect",{x:0,y:Math.min(r,i),width:n.width||0,height:Math.abs(i-r),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&h.createElement("text",{x:(n.width||0)-4,y:Math.min(r,i)-4,textAnchor:"end",fill:e.color||"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===(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===(O=n.scales)||void 0===O?void 0:O.value;if(!i||!s)return null;const a=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",u=e.filter,d=o.filter(e=>null!=e[a]&&null!=e[c]&&!(u&&!u(e))).sort((e,t)=>e[r]-t[r]);if(2>d.length)return null;const g=Ae[n.curve||"linear"]||l.curveLinear,f=l.area().x(e=>i(e[r])).y0(e=>s(e[c])).y1(e=>s(e[a])).curve(g)(d);if(!f)return null;const p=e.fill||"#6366f1";return h.createElement("g",{key:"ann-"+t},h.createElement("path",{d:f,fill:p,fillOpacity:null!==(S=e.fillOpacity)&&void 0!==S?S:.15,stroke:"none"}),e.label&&d.length>0&&h.createElement("text",{x:i(d[d.length-1][r])+4,y:s(d[d.length-1][a])-4,fill:p,fontSize:11},e.label))}case"anomaly-band":{const o=n.data||[];if(2>o.length)return null;const r=n.yAccessor||"y",i=null!==(M=null===(j=n.scales)||void 0===j?void 0:j.x)&&void 0!==M?M:null===(C=n.scales)||void 0===C?void 0:C.time,s=null!==(_=null===(E=n.scales)||void 0===E?void 0:E.y)&&void 0!==_?_:null===(B=n.scales)||void 0===B?void 0:B.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),d=null!==(P=e.threshold)&&void 0!==P?P:2,g=l-d*u,f=!1!==e.showBand,p=e.fill||"#6366f1",y=null!==(L=e.fillOpacity)&&void 0!==L?L:.1,m=e.anomalyColor||"#ef4444",v=null!==(N=e.anomalyRadius)&&void 0!==N?N:6,b=s(l+d*u),x=s(g),k=o.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-l)>d*u});return h.createElement("g",{key:"ann-"+t},f&&h.createElement("rect",{x:0,y:Math.min(b,x),width:n.width||0,height:Math.abs(x-b),fill:p,fillOpacity:y}),k.map((e,t)=>{const o=be(e,n),r=xe(e,n);return null==o||null==r?null:h.createElement("circle",{key:"anomaly-"+t,cx:o,cy:r,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5})}),e.label&&h.createElement("text",{x:(n.width||0)-4,y:Math.min(b,x)-4,textAnchor:"end",fill:p,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!==(H=null===(I=n.scales)||void 0===I?void 0:I.x)&&void 0!==H?H:null===(F=n.scales)||void 0===F?void 0:F.time,a=null!==(z=null===(T=n.scales)||void 0===T?void 0:T.y)&&void 0!==z?z:null===($=n.scales)||void 0===$?void 0:$.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,d=l.map(([e,t])=>t-c(e)).reduce((e,t)=>e+t*t,0),f=Math.sqrt(d/Math.max(u-2,1)),p=l.reduce((e,t)=>e+t[0],0)/u,y=l.reduce((e,t)=>e+Math.pow(t[0]-p,2),0),m=null!==(R=e.confidence)&&void 0!==R?R:.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=f*Math.sqrt(1+1/u+(y>0?Math.pow(e-p,2)/y:0))*v;A.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const O=`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`,S=A.map(e=>`${s(e.x)},${a(e.yCenter)}`).join(" "),j=`${s(x)},${a(c(x))}`,M=e.strokeColor||"#6366f1";return h.createElement("g",{key:"ann-"+t},h.createElement("path",{d:O,fill:e.fill||"#6366f1",fillOpacity:null!==(W=e.fillOpacity)&&void 0!==W?W:.15,stroke:"none"}),h.createElement("polyline",{points:`${j} ${S}`,fill:"none",stroke:M,strokeWidth:null!==(G=e.strokeWidth)&&void 0!==G?G:2,strokeDasharray:null!==(Y=e.strokeDasharray)&&void 0!==Y?Y:"6,3"}),e.label&&A.length>0&&h.createElement("text",{x:s(A[A.length-1].x)+4,y:a(A[A.length-1].yCenter)-4,fill:M,fontSize:11},e.label))}case"widget":{let o=null,r=null;if(null!=e.px&&null!=e.py)o=e.px,r=e.py;else{const i=ke(e,t,n);if(!i)return null;o=i.x,r=i.y}if(null==o||null==r)return null;if(!we(o,r,n))return null;const i=null!==(q=e.dx)&&void 0!==q?q: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:h.createElement("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info"},"ℹ️");return h.createElement("foreignObject",{key:"ann-"+t,x:o+i-a/2,y:r+s-l/2,width:a,height:l,style:{overflow:"visible",pointerEvents:"auto"}},h.createElement("div",{style:{width:a,height:l,display:"flex",alignItems:"center",justifyContent:"center"}},c))}case"text":{const o=ke(e,t,n);if(!o)return null;const{x:r,y:i}=o;return h.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)}case"category-highlight":{const o=e.category;if(null==o)return null;const r=null===(K=n.scales)||void 0===K?void 0:K.o,i=null===(J=n.scales)||void 0===J?void 0:J.x,s=null===(Z=n.scales)||void 0===Z?void 0:Z.y,a=(null==r?void 0:r.bandwidth)?r:(null==i?void 0:i.bandwidth)?i:(null==s?void 0:s.bandwidth)?s:null;if(!a)return null;const l=a(o);if(null==l)return null;const c=a.bandwidth(),u=e.color||"var(--semiotic-primary, #4589ff)",d=null!==(ee=e.opacity)&&void 0!==ee?ee:.15,g=e.label;return(n.projection?"vertical"===n.projection:a===i)?h.createElement("g",{key:"ann-"+t},h.createElement("rect",{x:l,y:0,width:c,height:n.height||0,fill:u,fillOpacity:d}),g&&h.createElement("text",{x:l+c/2,y:12,textAnchor:"middle",fill:u,fontSize:12,fontWeight:"bold"},g)):h.createElement("g",{key:"ann-"+t},h.createElement("rect",{x:0,y:l,width:n.width||0,height:c,fill:u,fillOpacity:d}),g&&h.createElement("text",{x:12,y:l+c/2,dominantBaseline:"middle",fill:u,fontSize:12,fontWeight:"bold"},g))}default:return null}},t={scales:d?{x:d.x,y:d.y,time:d.x,value:d.y}:null,timeAxis:"x",xAccessor:I,yAccessor:H,width:r,height:i,data:F,frameType:"xy",pointNodes:T,curve:z,stickyPositionCache:X.current};return L.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)},[L,N,r,i,I,H,F,d,T,z]),J=function(t){var n;const o=e.useSyncExternalStore(t?_e:Pe,t?Ee:Le,t?Ee:Le);return t&&null!==(n=o.positions.get(t))&&void 0!==n?n:null}(R);return e.useEffect(()=>{if(!(null==J?void 0:J.locked)||!R)return;const e=e=>{"Escape"===e.key&&Ce(R)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[null==J?void 0:J.locked,R]),f||w||A||E||_||K&&K.length>0||k||W||J?h.createElement("svg",{role:"img",width:s,height:c,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"}},h.createElement("title",null,"string"==typeof w?w:"XY Chart"),h.createElement("desc",null,"string"==typeof w?w+" — XY data visualization":"XY data visualization"),h.createElement("g",{transform:`translate(${u.left},${u.top})`},k&&d&&!$&&(()=>{var e,t;const n=Ne(null===(e=null==p?void 0:p.find(e=>"bottom"===e.orient))||void 0===e?void 0:e.gridStyle),o=Ne(null===(t=null==p?void 0:p.find(e=>"left"===e.orient))||void 0===t?void 0:t.gridStyle);return h.createElement("g",{className:"stream-grid"},G.map((e,t)=>h.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:n})),Y.map((e,t)=>h.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:r,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o})))})(),f&&d&&(()=>{const e=null==p?void 0:p.find(e=>"left"===e.orient),t=null==p?void 0:p.find(e=>"bottom"===e.orient),n=!e||!1!==e.baseline,o=!t||!1!==t.baseline,s=(null==e?void 0:e.jaggedBase)||!1,a=(null==t?void 0:t.jaggedBase)||!1,l=null==t?void 0:t.landmarkTicks,c=null==e?void 0:e.landmarkTicks,d="var(--semiotic-border, #ccc)",g="var(--semiotic-text-secondary, var(--semiotic-text, #666))",f="var(--semiotic-text, #333)",b=!!(null==t?void 0:t.autoRotate)&&G.length>1&&(()=>{const e=r/Math.max(G.length-1,1);return G.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})();return h.createElement("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},!$&&o&&!a&&h.createElement("line",{x1:0,y1:i,x2:r,y2:i,stroke:d,strokeWidth:1}),!$&&a&&h.createElement("path",{d:Ie("bottom",r,i),fill:"none",stroke:d,strokeWidth:1}),G.map((e,t)=>{const n=!!l&&("function"==typeof l?l(e.value,t):V(e.value,t>0?G[t-1].value:void 0));return h.createElement("g",{key:"xtick-"+t,transform:`translate(${e.pixel},${i})`},h.createElement("line",{y2:5,stroke:d,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?h.createElement("text",{y:b?10:18,textAnchor:b?"end":"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:g,style:{userSelect:"none"},transform:b?"rotate(-45)":void 0},e.label):h.createElement("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"}},h.createElement("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"}},e.label)))}),y&&h.createElement("text",{x:r/2,y:i+40,textAnchor:"middle",fontSize:12,fill:f,style:{userSelect:"none"}},y),!$&&n&&!s&&h.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:d,strokeWidth:1}),!$&&s&&h.createElement("path",{d:Ie("left",r,i),fill:"none",stroke:d,strokeWidth:1}),Y.map((e,t)=>{const n=!!c&&("function"==typeof c?c(e.value,t):V(e.value,t>0?Y[t-1].value:void 0));return h.createElement("g",{key:"ytick-"+t,transform:`translate(0,${e.pixel})`},h.createElement("line",{x2:-5,stroke:d,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?h.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:g,style:{userSelect:"none"}},e.label):h.createElement("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"}},h.createElement("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"}},e.label)))}),(()=>{const t=(null==e?void 0:e.label)||m;return t?h.createElement("text",{x:15-u.left,y:i/2,textAnchor:"middle",fontSize:12,fill:f,transform:`rotate(-90, ${15-u.left}, ${i/2})`,style:{userSelect:"none"}},t):null})(),(()=>{const e=null==p?void 0:p.find(e=>"right"===e.orient);if(!e||0===q.length)return null;const t=e.landmarkTicks,n=e.label||v;return h.createElement(h.Fragment,null,!1!==e.baseline&&h.createElement("line",{x1:r,y1:0,x2:r,y2:i,stroke:d,strokeWidth:1}),q.map((e,n)=>{const o=!!t&&("function"==typeof t?t(e.value,n):V(e.value,n>0?q[n-1].value:void 0));return h.createElement("g",{key:"ytick-r-"+n,transform:`translate(${r},${e.pixel})`},h.createElement("line",{x2:5,stroke:d,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?h.createElement("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:g,style:{userSelect:"none"}},e.label):h.createElement("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"}},h.createElement("div",{style:{textAlign:"left",fontSize:10,userSelect:"none"}},e.label)))}),n&&h.createElement("text",{x:r+u.right-15,y:i/2,textAnchor:"middle",fontSize:12,fill:f,transform:`rotate(90, ${r+u.right-15}, ${i/2})`,style:{userSelect:"none"}},n))})())})(),K,_&&d&&B&&P&&h.createElement(h.Fragment,null,_.top&&h.createElement("g",{transform:"translate(0, 0)"},h.createElement(fe,{orient:"top",config:ge(_.top),values:B,scale:d.x,size:u.top,length:r})),_.bottom&&h.createElement("g",{transform:`translate(0, ${i})`},h.createElement(fe,{orient:"bottom",config:ge(_.bottom),values:B,scale:d.x,size:u.bottom,length:r})),_.left&&h.createElement("g",{transform:"translate(0, 0)"},h.createElement(fe,{orient:"left",config:ge(_.left),values:P,scale:d.y,size:u.left,length:i})),_.right&&h.createElement("g",{transform:`translate(${r}, 0)`},h.createElement(fe,{orient:"right",config:ge(_.right),values:P,scale:d.y,size:u.right,length:i}))),E,J&&J.sourceId!==D&&(null==d?void 0:d.x)&&(()=>{const e=d.x(J.xValue);if(null==e||0>e||e>r)return null;const t=J.locked;return h.createElement("line",{x1:e,y1:0,x2:e,y2:i,stroke:t?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:t?1.5:1,strokeDasharray:t?"6,3":"4,4",pointerEvents:"none"})})(),W),w&&h.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:d}=e;if(!t)return null;const g="top"===i||"bottom"===i;let f,p;return"left"===i?(f=4,p=r.top):"top"===i?(f=0,p=s?32:8):"bottom"===i?(f=0,p=o-r.bottom+50):(f=n-r.right+10,p=r.top),h.createElement("g",{transform:`translate(${f}, ${p})`},"object"==typeof(y=t)&&null!==y&&"gradient"in y?h.createElement(de,{config:t.gradient,orientation:g?"horizontal":"vertical",width:g?n:100}):function(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}(t)?h.createElement(he,{legendGroups:t.legendGroups,title:"",width:g?n:100,orientation:g?"horizontal":"vertical",customHoverBehavior:a,customClickBehavior:l,highlightedCategory:c,isolatedCategories:u,legendInteraction:d}):t);var y}({legend:A,totalWidth:s,totalHeight:c,margin:u,legendPosition:C,title:w,legendHoverBehavior:O,legendClickBehavior:S,legendHighlightedCategory:j,legendIsolatedCategories:M})):null}function $e(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}const Re="undefined"==typeof window||"undefined"==typeof document,De=h.createContext(null),We={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Ge(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e)n[t.type]=(n[t.type]||0)+1;const o=[],r={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},i=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],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(", ")}`}const Ye=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},qe={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},Xe={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},Ve={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},Ue={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Qe={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},Ke={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},Je={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function Ze({scene:e,chartType:t,tableId:n,chartTitle:o}){var r;const[i,s]=h.useState(!1),a=h.useContext(De),l=null!==(r=null==a?void 0:a.visible)&&void 0!==r&&r,c=i||l,u=h.useRef(null),d=o?"Data summary for "+o:n?`Data summary for ${t} ${n}`:"Data summary for "+t,g=h.useCallback(()=>{i||l||s(!0)},[i,l]),f=h.useCallback(e=>{var t;l||(null===(t=u.current)||void 0===t?void 0:t.contains(e.relatedTarget))||s(!1)},[l]);if(!e||0===e.length)return n?h.createElement("span",{id:n,tabIndex:-1,style:We}):null;if(!c)return h.createElement("div",{id:n,tabIndex:-1,onFocus:g,style:We,role:"region","aria-label":d},h.createElement("button",{type:"button",onClick:()=>s(!0)},"View data summary (",e.length," elements)"));const p=function(e){var t,n,o,r,i,s,a,l,c,u,d,h,g,f,p,y,m,v,b,x,k,w,A,O,S;const j=[];if(!Array.isArray(e))return j;for(const M of e)if(M&&"object"==typeof M)try{switch(M.type){case"point":j.push({label:"Point",values:{x:M.x,y:M.y}});break;case"line":{const e=M.path,t=Array.isArray(M.datum)?M.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&j.push({label:"Line point",values:{x:t[0],y:t[1]}})}break}case"area":{const e=M.topPath,t=Array.isArray(M.datum)?M.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&j.push({label:"Area point",values:{x:t[0],y:t[1]}})}break}case"rect":{const e=null!=M.datum&&"object"==typeof M.datum?M.datum:{},i=null!==(n=null!==(t=e.category)&&void 0!==t?t:M.group)&&void 0!==n?n:"",s=null!==(r=null!==(o=e.value)&&void 0!==o?o:e.__aggregateValue)&&void 0!==r?r:e.total;j.push({label:"Bar",values:{category:i,value:null!=s?s:""}});break}case"heatcell":j.push({label:"Cell",values:{x:M.x,y:M.y,value:M.value}});break;case"wedge":j.push({label:"Wedge",values:{category:null!==(l=null!==(s=null===(i=M.datum)||void 0===i?void 0:i.category)&&void 0!==s?s:null===(a=M.datum)||void 0===a?void 0:a.label)&&void 0!==l?l:"",value:null!==(u=null===(c=M.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":j.push({label:"Node",values:{id:null!==(h=null===(d=M.datum)||void 0===d?void 0:d.id)&&void 0!==h?h:"",x:null!==(g=M.cx)&&void 0!==g?g:M.x,y:null!==(f=M.cy)&&void 0!==f?f:M.y}});break;case"arc":j.push({label:"Arc",values:{id:null!==(y=null===(p=M.datum)||void 0===p?void 0:p.id)&&void 0!==y?y:"",x:null!==(m=M.cx)&&void 0!==m?m:M.x,y:null!==(v=M.cy)&&void 0!==v?v:M.y}});break;case"candlestick":j.push({label:"Candlestick",values:{x:M.x,open:M.open,high:M.high,low:M.low,close:M.close}});break;case"geoarea":j.push({label:"Region",values:{name:null!==(A=null!==(k=null===(x=null===(b=M.datum)||void 0===b?void 0:b.properties)||void 0===x?void 0:x.name)&&void 0!==k?k:null===(w=M.datum)||void 0===w?void 0:w.name)&&void 0!==A?A:"",value:null!==(S=null===(O=M.datum)||void 0===O?void 0:O.value)&&void 0!==S?S:""}})}}catch(e){}return j}(e),y=function(e){if(!e||0===e.length)return[];const t=new Set;for(const n of e)if(n&&n.values)for(const e of Object.keys(n.values))t.add(e);const n=[];for(const o of t){const t=[],r=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[o];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&r.add(e+""))}if(t.length>0){let e=t[0],r=t[0],i=0;for(const n of t)e>n&&(e=n),n>r&&(r=n),i+=n;n.push({name:o,count:t.length,numeric:!0,min:e,max:r,mean:i/t.length})}else if(r.size>0){const e=Array.from(r);n.push({name:o,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(p),m=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${Ye(e.min)} to ${Ye(e.max)}, mean ${Ye(e.mean)}.`);else{const t=e.uniqueValues,o=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${o}.`)}return n.join(" ")}(p.length,y),v=p.slice(0,5),b=new Set;for(const e of v)for(const t of Object.keys(e.values))b.add(t);const x=Array.from(b);return h.createElement("div",{ref:u,id:n,tabIndex:-1,onBlur:f,style:qe,role:"region","aria-label":d},h.createElement("button",{type:"button",onClick:()=>{l&&a&&a.setVisible(!1),s(!1)},"aria-label":"Close data summary",style:Ve},"×"),h.createElement("div",{role:"note",style:Xe},m),h.createElement("table",{role:"table","aria-label":"Sample data for "+t,style:Ue},h.createElement("caption",{style:Je},"First ",v.length," of ",p.length," data points"),h.createElement("thead",null,h.createElement("tr",null,h.createElement("th",{style:Qe},"type"),x.map(e=>h.createElement("th",{key:e,style:Qe},e)))),h.createElement("tbody",null,v.map((e,t)=>h.createElement("tr",{key:t},h.createElement("td",{style:Ke},e.label),x.map(t=>{return h.createElement("td",{key:t,style:Ke},null==(n=e.values[t])||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":Ye(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"");var n}))))))}function et({summary:e}){return e?h.createElement("div",{role:"note",style:We},e):null}function tt({tableId:e}){return h.createElement("a",{href:"#"+e,style:We,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,We)}},"Skip to data table")}function nt({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 h.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:We},t)}const ot="var(--semiotic-focus, #005fcc)";function rt({active:e,hoverPoint:t,margin:n,size:o,shape:r="circle",width:i,height:s}){if(!e||!t)return null;const a=t.x+n.left,l=t.y+n.top;let c;if("rect"===r&&null!=i&&null!=s){const e=Math.max(i,4),t=Math.max(s,4);c=h.createElement("rect",{x:a-e/2-3,y:l-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:ot,strokeWidth:2,strokeDasharray:"4,2"})}else c=h.createElement("circle","wedge"===r?{cx:a,cy:l,r:12,fill:"none",stroke:ot,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:a,cy:l,r:8,fill:"none",stroke:ot,strokeWidth:2,strokeDasharray:"4,2"});return h.createElement("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true"},c)}function it({x:e,y:t,containerWidth:n,containerHeight:o,margin:r,children:i,className:s="stream-frame-tooltip",zIndex:a=1}){const l=h.useRef(null),[c,u]=h.useState(null);h.useLayoutEffect(()=>{const e=l.current;if(!e)return;const t=e.getBoundingClientRect();u(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[i,s,n,o]);let d;return d=c?`translate(${c.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${c.height+12>o-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*o>t?"4px":"calc(-100% - 4px)"})`,h.createElement("div",{ref:l,className:s,style:{position:"absolute",left:r.left+e,top:r.top+t,transform:d,pointerEvents:"none",zIndex:a,width:"max-content"}},i)}function st(t){const n=e.createContext(null),o=at(t);return[function({children:o}){const r=e.useMemo(()=>at(t),[]);return h.createElement(n.Provider,{value:r,children:o})},t=>{var r;const i=null!==(r=e.useContext(n))&&void 0!==r?r:o,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 at(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 lt={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}},ct={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}},ut={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"},[dt,ht]=st(e=>({theme:lt,setTheme(t){e(e=>{if("light"===t)return{theme:lt};if("dark"===t)return{theme:ct};if("high-contrast"===t)return{theme:ut};if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?ct:lt;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 gt(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}const ft=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,pt=new WeakMap;function yt(e,t){var n,o;if(!t)return t;const r=ft.exec(t);if(!r)return t;const i=e.canvas;if(!i)return(null===(n=r[2])||void 0===n?void 0:n.trim())||t;let s=pt.get(i);if(s||(s=new Map,pt.set(i,s)),s.has(t))return s.get(t);const a=getComputedStyle(i).getPropertyValue(r[1]).trim()||(null===(o=r[2])||void 0===o?void 0:o.trim())||t;return s.set(t,a),a}function mt(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 vt(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 bt(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()}}const xt=(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,d=a.colorThresholds,h=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 y=null!==(r=a.style.opacity)&&void 0!==r?r:1;bt(e,a.path,c,u,y,a.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const g=mt(a.curve),f=d&&d.length>0&&h&&h.length===a.path.length,p=a._decayOpacities;if(p&&p.length===a.path.length&&!f){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*(p[v]+p[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(f){let b=null,x=null,k=null,w=null,A=!1;function O(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),A=!0}function S(){A&&(e.stroke(),A=!1)}for(let j=0;a.path.length>j;j++){const[M,C]=a.path[j],E=h[j],_=vt(E,d,c);if(null!==b&&null!==w&&null!==k){if(_===w)e.lineTo(M,C);else{const B=[];for(const P of d){const L=P.value;(k>L||L>E)&&(L>k||E>L)||k===L||E===L||B.push({t:(L-k)/(E-k)})}B.sort((e,t)=>e.t-t.t);for(const N of B){const I=b+(M-b)*N.t,H=x+(C-x)*N.t,F=vt(k+(E-k)*Math.min(N.t+1e-4,1),d,c);e.lineTo(I,H),S(),O(F,I,H)}e.lineTo(M,C)}b=M,x=C,k=E,w=_}else O(_,M,C),b=M,x=C,k=E,w=_}S()}else{if(e.beginPath(),!a.strokeGradient||2>a.strokeGradient.colorStops.length||2>a.path.length)e.strokeStyle=c;else{const T=e.createLinearGradient(a.path[0][0],0,a.path[a.path.length-1][0],0);for(const z of a.strokeGradient.colorStops)T.addColorStop(Math.max(0,Math.min(1,z.offset)),z.color);e.strokeStyle=T}if(g)l.line().x(e=>e[0]).y(e=>e[1]).curve(g).context(e)(a.path);else{const[$,R]=a.path[0];e.moveTo($,R);for(let D=1;a.path.length>D;D++)e.lineTo(a.path[D][0],a.path[D][1])}e.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=a.style.fillOpacity,e.fillStyle=("string"==typeof a.style.fill?yt(e,a.style.fill):a.style.fill)||a.style.fill,g&&!f)l.line().x(e=>e[0]).y(e=>e[1]).curve(g).context(e)(a.path);else{const[G,Y]=a.path[0];e.moveTo(G,Y);for(let q=1;a.path.length>q;q++)e.lineTo(a.path[q][0],a.path[q][1])}const W=a.path[0][0];e.lineTo(a.path[a.path.length-1][0],o.height),e.lineTo(W,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function kt(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function wt(e,t,n=.3){kt(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 At(e,t,n=.6){var o,r,i,s,a;if(!kt(t))return;const l=null!==(o=t._pulseGlowRadius)&&void 0!==o?o:4,c=t.r+l*t._pulseIntensity,u=null!==(i=null!==(r=t.cx)&&void 0!==r?r:t.x)&&void 0!==i?i:0,d=null!==(a=null!==(s=t.cy)&&void 0!==s?s:t.y)&&void 0!==a?a:0;e.beginPath(),e.arc(u,d,c,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function Ot(e,t,n,o=.35){kt(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill())}function St(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 jt(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 Mt(e,t){const n=St(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 Ct=(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=yt(e,t.style.stroke)||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(Mt(e,t),t.fillGradient&&("colorStops"in t.fillGradient&&t.fillGradient.colorStops.length>=2||"topOpacity"in t.fillGradient)&&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=e.createLinearGradient(0,o,0,r);if("colorStops"in t.fillGradient)for(const e of t.fillGradient.colorStops){const t=Math.max(0,Math.min(1,e.offset));isNaN(t)||i.addColorStop(t,e.color)}else if("topOpacity"in t.fillGradient){const e=jt("string"==typeof n?n:"#4e79a7");i.addColorStop(0,`rgba(${e[0]},${e[1]},${e[2]},${t.fillGradient.topOpacity})`),i.addColorStop(1,`rgba(${e[0]},${e[1]},${e[2]},${t.fillGradient.bottomOpacity})`)}e.fillStyle=i,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&&(Mt(e,t),Ot(e,t)),t.style.stroke&&"none"!==t.style.stroke){if(e.globalAlpha=a,!t.strokeGradient||2>t.strokeGradient.colorStops.length||2>t.topPath.length)e.strokeStyle=yt(e,t.style.stroke)||t.style.stroke;else{const n=e.createLinearGradient(t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0);for(const e of t.strokeGradient.colorStops)n.addColorStop(Math.max(0,Math.min(1,e.offset)),e.color);e.strokeStyle=n}e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const n=St(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}},Et=(e,t,n,o)=>{var r;const i=t.filter(e=>"point"===e.type);if(0!==i.length){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=("string"==typeof t.style.fill?yt(e,t.style.fill):t.style.fill)||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=("string"==typeof t.style.stroke?yt(e,t.style.stroke):t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),At(e,t),e.globalAlpha=1}}finally{e.restore()}}},_t=(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?Bt(e,t):(e.fillStyle=("string"==typeof t.style.fill?yt(e,t.style.fill):t.style.fill)||"#007bff",e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&(e.strokeStyle=yt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))),wt(e,t),e.globalAlpha=1};function Bt(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 Pt(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 Lt(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}const Nt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function It(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`${Nt[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*n>t?e=>{const t=new Date(e);return`${Nt[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}const Ht={line:[Ct,xt,Et],area:[Ct,Et],stackedarea:[Ct,Et],scatter:[Et],bubble:[Et],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),wt(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):Lt(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=Pt(t.fill),e.font=o+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,r,i)}}}finally{e.restore()}}],bar:[_t],swarm:[Et],waterfall:[(e,t,n,o)=>{var r,i,s;_t(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;if(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(),t.isRange){const n=Math.max(2*t.wickWidth,4);e.fillStyle=t.wickColor,e.beginPath(),e.arc(t.x,t.highY,n,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,n,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const n=Math.min(t.openY,t.closeY),o=Math.abs(t.openY-t.closeY),r=t.isUp?t.upColor:t.downColor;e.fillStyle=r,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1)),e.strokeStyle=r,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1))}e.restore()}}],mixed:[Ct,xt,Et]},Ft={top:20,right:20,bottom:30,left:40},Tt={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"},zt={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 $t({hover:e}){const t=e=>Number.isInteger(e)?e+"":e.toFixed(2);return h.createElement("div",{className:"semiotic-tooltip",style:zt},h.createElement("div",{style:{fontWeight:600,marginBottom:2}},t(e.value)),h.createElement("div",{style:{opacity:.7,fontSize:11}},t(e.time)))}const Rt=e.forwardRef(function(t,n){var o,r,i,s,a,l,c,u,d,g,f;const{chartType:p,runtimeMode:v,data:b,chunkThreshold:x,chunkSize:k,xAccessor:w,yAccessor:A,colorAccessor:O,sizeAccessor:S,groupAccessor:j,lineDataAccessor:M,curve:C,normalize:E,binSize:_,valueAccessor:B,arrowOfTime:P="right",windowMode:L="sliding",windowSize:N=200,timeAccessor:I,xExtent:H,yExtent:F,extentPadding:T=.1,scalePadding:z,sizeRange:$,size:R=[500,300],responsiveWidth:D,responsiveHeight:W,margin:G,className:q,background:X,lineStyle:V,pointStyle:K,areaStyle:J,waterfallStyle:Z,swarmStyle:ee,barColors:te,colorScheme:ne,boundsAccessor:oe,boundsStyle:ae,y0Accessor:le,gradientFill:ce,lineGradient:ue,areaGroups:de,openAccessor:he,highAccessor:ge,lowAccessor:fe,closeAccessor:pe,candlestickStyle:ye,showAxes:me=!0,axes:ve,xLabel:be,yLabel:xe,yLabelRight:ke,xFormat:we,yFormat:Ae,tickFormatTime:Oe,tickFormatValue:Se,hoverAnnotation:je,tooltipContent:Me,customHoverBehavior:Ce,customClickBehavior:Ee,enableHover:_e,hoverRadius:Be=30,tooltipMode:Pe,annotations:Le,svgAnnotationRules:Ne,showGrid:Ie,legend:Fe,legendHoverBehavior:Te,legendClickBehavior:De,legendHighlightedCategory:We,legendIsolatedCategories:Ye,legendPosition:qe,backgroundGraphics:Xe,foregroundGraphics:Ve,canvasPreRenderers:Ue,svgPreRenderers:Qe,title:Ke,categoryAccessor:Je,brush:ot,onBrush:st,decay:at,pulse:lt,transition:ct,staleness:ut,heatmapAggregation:dt,heatmapXBins:ft,heatmapYBins:yt,showValues:mt,heatmapValueFormat:vt,marginalGraphics:bt,pointIdAccessor:xt,xScaleType:kt,yScaleType:wt,accessibleTable:At=!0,description:Ot,summary:St,linkedCrosshairName:jt,linkedCrosshairSourceId:Mt}=t,Ct=function(){const[t,n]=e.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return e.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return n(e.matches),function(e,t){return"function"==typeof e.addEventListener?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))}(e,e=>n(e.matches))},[]),t}(),Et=e.useRef(Ct);Et.current=Ct;const[_t,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]]]}(R,D,W),Pt=Object.assign(Object.assign({},Ft),G);if(bt){const e=60;bt.top&&e>Pt.top&&(Pt.top=e),bt.bottom&&e>Pt.bottom&&(Pt.bottom=e),bt.left&&e>Pt.left&&(Pt.left=e),bt.right&&e>Pt.right&&(Pt.right=e)}const Lt=Bt[0]-Pt.left-Pt.right,Nt=Bt[1]-Pt.top-Pt.bottom,zt="function"==typeof Ve?Ve({size:Bt,margin:Pt}):Ve,Rt="function"==typeof Xe?Xe({size:Bt,margin:Pt}):Xe,Dt=null!=je?je:_e,Wt=e.useRef(null),Gt=e.useRef(null),Yt=e.useRef(0),qt=e.useRef(!1),Xt=ht(e=>e.theme),[Vt,Ut]=e.useState(0),[Qt,Kt]=e.useState(null),Jt=e.useRef(null),Zt=e.useRef(null),[en,tn]=e.useState(null),[nn,on]=e.useState(!1),[rn,sn]=e.useState([]),[an,ln]=e.useState([]),cn=e.useRef(()=>{}),un="streaming"===v||["bar","swarm","waterfall"].includes(p),dn=e.useMemo(()=>({chartType:p,runtimeMode:un?"streaming":"bounded",windowSize:N,windowMode:L,arrowOfTime:un?P:"right",extentPadding:T,scalePadding:z,xAccessor:un?void 0:w,yAccessor:un?void 0:A,timeAccessor:un?I:void 0,valueAccessor:B,colorAccessor:O,sizeAccessor:S,groupAccessor:j||(M?"_lineGroup":void 0),categoryAccessor:Je,lineDataAccessor:M,xScaleType:kt,yScaleType:wt,xExtent:H,yExtent:F,sizeRange:$,binSize:_,normalize:E,boundsAccessor:oe,boundsStyle:ae,y0Accessor:le,gradientFill:!0===ce?{topOpacity:.8,bottomOpacity:.05}:!1===ce?void 0:ce,areaGroups:de?new Set(de):void 0,lineGradient:ue,openAccessor:he,highAccessor:ge,lowAccessor:fe,closeAccessor:pe,candlestickStyle:ye,lineStyle:V,pointStyle:K,areaStyle:J,swarmStyle:ee,waterfallStyle:Z,colorScheme:ne,barColors:te,annotations:Le,decay:at,pulse:lt,transition:ct,staleness:ut,heatmapAggregation:dt,heatmapXBins:ft,heatmapYBins:yt,showValues:mt,heatmapValueFormat:vt,pointIdAccessor:xt,curve:C}),[p,N,L,P,T,z,w,A,I,B,kt,wt,O,S,j,Je,M,H,F,$,_,E,oe,ae,le,ce,ue,de,he,ge,fe,pe,ye,V,K,J,ee,Z,ne,te,Le,at,lt,ct,ut,dt,ft,yt,mt,vt,un,xt,C]),hn=e.useRef(null);hn.current||(hn.current=new Y(dn));const gn=e.useCallback(()=>{Yt.current||(Yt.current=requestAnimationFrame(()=>cn.current()))},[]);e.useEffect(()=>{var e;null===(e=hn.current)||void 0===e||e.updateConfig(dn),qt.current=!0,gn()},[dn,gn]),e.useEffect(()=>{Wt.current&&pt.delete(Wt.current),qt.current=!0,gn()},[Xt,gn]);const fn=e.useRef(null);fn.current||(fn.current=new m(e=>{const t=hn.current;t&&t.ingest(e)&&(qt.current=!0,gn())},{chunkThreshold:x,chunkSize:k})),e.useEffect(()=>{var e;null===(e=fn.current)||void 0===e||e.updateChunkOptions({chunkThreshold:x,chunkSize:k})},[x,k]);const pn=e.useCallback(e=>{var t;null===(t=fn.current)||void 0===t||t.push(e)},[]),yn=e.useCallback(e=>{var t;null===(t=fn.current)||void 0===t||t.pushMany(e)},[]),mn=e.useCallback(()=>{var e,t;null===(e=fn.current)||void 0===e||e.clear(),null===(t=hn.current)||void 0===t||t.clear(),qt.current=!0,gn()},[gn]);e.useImperativeHandle(n,()=>({push:pn,pushMany:yn,remove:e=>{var t,n,o;null===(t=fn.current)||void 0===t||t.flush();const r=null!==(o=null===(n=hn.current)||void 0===n?void 0:n.remove(e))&&void 0!==o?o:[];return r.length>0&&(qt.current=!0,gn()),r},update:(e,t)=>{var n,o,r;null===(n=fn.current)||void 0===n||n.flush();const i=null!==(r=null===(o=hn.current)||void 0===o?void 0:o.update(e,t))&&void 0!==r?r:[];return i.length>0&&(qt.current=!0,gn()),i},clear:mn,getData:()=>{var e,t,n;return null===(e=fn.current)||void 0===e||e.flush(),null!==(n=null===(t=hn.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var e,t;return null!==(t=null===(e=hn.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=hn.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[pn,yn,mn,gn]),e.useEffect(()=>{var e,t;if(b){if(M&&b.length>0&&"object"==typeof b[0]&&null!==b[0]){const t="string"==typeof M?M:"coordinates";if(Array.isArray(b[0][t])){const n=[];for(const e of b){const o=e[t];if(Array.isArray(o)){const t=e.label||e.id||e.key;if(null!=t)for(const e of o)n.push(Object.assign(Object.assign({},e),{_lineGroup:t}));else for(const e of o)n.push(e)}}return void(null===(e=fn.current)||void 0===e||e.setBoundedData(n))}}null===(t=fn.current)||void 0===t||t.setBoundedData(b)}},[b,M]);const vn=e.useRef(()=>{}),bn=e.useRef(()=>{});vn.current=e=>{if(!Dt)return;const t=Wt.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Pt.left,r=e.clientY-n.top-Pt.top;if(0>o||o>Lt||0>r||r>Nt)return void(Jt.current&&(Jt.current=null,Zt.current=null,tn(null),Ce&&(Ce(null),qt.current=!0),gn()));const i=hn.current;if(!i||0===i.scene.length)return;const s=U(i.scene,o,r,Be,i.quadtree);if(!s)return void(Jt.current&&(Jt.current=null,Zt.current=null,tn(null),Ce&&Ce(null),gn()));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});if("multi"===Pe&&i.scene.length>0&&i.scales){const e=function(e,t,n=30){const o=[];for(const r of e)if("line"===r.type){const e=r;if(2>e.path.length)continue;const i=Q(e.path,t,n);if(null===i)continue;const s=re(e.path,t);o.push({node:r,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:e.path[s][0],y:i,group:e.group,color:e.style.stroke})}else if("area"===r.type){const e=r;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const i=Q(e.topPath,t,n);if(null===i)continue;const s=re(e.topPath,t);o.push({node:r,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:e.topPath[s][0],y:i,group:e.group,color:"string"==typeof e.style.stroke?e.style.stroke:"string"==typeof e.style.fill?e.style.fill:void 0})}return o}(i.scene,s.x,Be),t=i.scales.y.invert,n=i.scales.x.invert;if(e.length>0){const o=n?n(s.x):s.x;l.xValue=o,l.xPx=s.x,l.allSeries=e.map(e=>({group:e.group||"",value:t?t(e.y):e.y,valuePx:e.y,color:e.color||"#007bff",datum:e.datum}))}}Jt.current=l,Zt.current=s.node,tn(l),Ce&&(Ce(l),qt.current=!0),gn()},bn.current=()=>{Jt.current&&(Jt.current=null,Zt.current=null,tn(null),Ce&&(Ce(null),qt.current=!0),gn())},e.useCallback(e=>vn.current(e),[]);const xn=e.useCallback(()=>bn.current(),[]),kn=e.useRef(()=>{});kn.current=e=>{if(!Ee)return;const t=Wt.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Pt.left,r=e.clientY-n.top-Pt.top;if(0>o||o>Lt||0>r||r>Nt)return void Ee(null);const i=hn.current;if(!i||0===i.scene.length)return void Ee(null);const s=U(i.scene,o,r,Be,i.quadtree);if(!s)return void Ee(null);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});Ee(l)};const wn=e.useCallback(e=>kn.current(e),[]),An=e.useRef(-1),On=e.useRef(null),Sn=e.useRef(null),jn=e.useCallback(e=>{const t=hn.current;if(!t||0===t.scene.length)return;const n=t.version;let o;if(Sn.current&&Sn.current.version===n)o=Sn.current.graph;else{const e=function(e){var t,n,o,r;const i=[];for(const s of e)switch(s.type){case"point":i.push({x:s.x,y:s.y,datum:s.datum,shape:"circle",group:null!==(t=s.group)&&void 0!==t?t:"_default"});break;case"line":{const e=s,t=Array.isArray(e.datum)?e.datum:[],o=null!==(n=e.group)&&void 0!==n?n:"_default";for(let n=0;e.path.length>n&&t.length>n;n++)i.push({x:e.path[n][0],y:e.path[n][1],datum:t[n],shape:"circle",group:o});break}case"area":{const e=s,t=Array.isArray(e.datum)?e.datum:[],n=null!==(o=e.group)&&void 0!==o?o:"_default";for(let o=0;e.topPath.length>o&&t.length>o;o++)i.push({x:e.topPath[o][0],y:e.topPath[o][1],datum:t[o],shape:"circle",group:n});break}case"rect":i.push({x:s.x+s.w/2,y:s.y+s.h/2,datum:s.datum,shape:"rect",w:s.w,h:s.h,group:null!==(r=s.group)&&void 0!==r?r:"_default"});break;case"heatcell":i.push({x:s.x+s.w/2,y:s.y+s.h/2,datum:s.datum,shape:"rect",w:s.w,h:s.h,group:"_default"})}return i.sort((e,t)=>e.x-t.x||e.y-t.y),i}(t.scene);if(0===e.length)return;o=function(e){var t,n;const o=new Map;for(const n of e){const e=null!==(t=n.group)&&void 0!==t?t:"_default";let r=o.get(e);r||(r=[],o.set(e,r)),r.push(n)}for(const e of o.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const r=Array.from(o.keys()).sort((e,t)=>{const n=o.get(e),r=o.get(t);return(n.length>0?n[0].y:0)-(r.length>0?r[0].y:0)}),i=Array.from(o.values()).flat();i.sort((e,t)=>e.x-t.x||e.y-t.y);const s=new Map;for(let e=0;i.length>e;e++){i[e]._flatIndex=e;const t=null===(n=i[e].datum)||void 0===n?void 0:n.id;null!=t&&s.set(t+"",e)}return{flat:i,groups:r,byGroup:o,idToIdx:s}}(e),Sn.current={version:n,graph:o}}const r=An.current;if(0>r){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),An.current=0;const t=o.flat[0];On.current={shape:t.shape,w:t.w,h:t.h};const n=se(t);return Jt.current=n,tn(n),Ce&&Ce(n),void gn()}const i=function(e,t){var n,o;if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const r=Math.max(0,Math.min(t,e.flat.length-1)),i=e.flat[r];return{flatIndex:r,group:null!==(n=i.group)&&void 0!==n?n:"_default",indexInGroup:null!==(o=i._groupIndex)&&void 0!==o?o:0}}(o,r),s=function(e,t,n){const{group:o,indexInGroup:r}=t,i=n.byGroup.get(o);switch(e){case"ArrowRight":return i.length-1>r?i[r+1]._flatIndex:t.flatIndex;case"ArrowLeft":return r>0?i[r-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(o);return n.groups.length-1>e?ie(n,n.groups[e+1],i[r]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(o);return e>0?ie(n,n.groups[e-1],i[r]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}(e.key,i,o);if(null===s)return;if(e.preventDefault(),0>s)return An.current=-1,On.current=null,Jt.current=null,Zt.current=null,tn(null),Ce&&Ce(null),void gn();An.current=s;const a=o.flat[s];On.current={shape:a.shape,w:a.w,h:a.h};const l=se(a);Jt.current=l,tn(l),Ce&&Ce(l),gn()},[Ce,gn]),Mn=e.useCallback(e=>{An.current=-1,On.current=null,vn.current(e)},[]);cn.current=()=>{var e,t;Yt.current=0;const n=Wt.current,o=Gt.current;if(!n||!o)return;const r=hn.current;if(!r)return;const i="undefined"!=typeof performance?performance.now():Date.now(),s=r.advanceTransition(Et.current?i+1e6:i),a=!Et.current&&s,l=qt.current||s;l&&!a&&r.computeScene({width:Lt,height:Nt});const c="undefined"!=typeof window&&window.devicePixelRatio||1,u=function(e){if(!e)return Tt;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||Tt.axisStroke,tickText:i||Tt.tickText,crosshair:i?i+"66":Tt.crosshair,hoverFill:l?l+"4D":Tt.hoverFill,hoverStroke:i?i+"99":Tt.hoverStroke,pointRing:l||Tt.pointRing}:Tt}(n),d=null!==(e=null==ut?void 0:ut.threshold)&&void 0!==e?e:5e3,h=ut&&r.lastIngestTime>0&&i-r.lastIngestTime>d;if(l){const e=gt(n,Bt,Pt,c);if(e){e.clearRect(-Pt.left,-Pt.top,Bt[0],Bt[1]),h&&(e.globalAlpha=null!==(t=null==ut?void 0:ut.dimOpacity)&&void 0!==t?t:.5);const o=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=X||(o&&"transparent"!==o?o:null);if(i&&(e.fillStyle=i,e.fillRect(-Pt.left,-Pt.top,Bt[0],Bt[1])),e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,Lt,Nt),e.clip()),Ue&&r.scales)for(const t of Ue)e.save(),t(e,r.scene,r.scales,{width:Lt,height:Nt}),e.restore();const s=Ht[p];if(s&&r.scales)for(const t of s)t(e,r.scene,r.scales,{width:Lt,height:Nt});e.restore(),h&&(e.globalAlpha=1)}}{const e=gt(o,Bt,Pt,c);if(e&&(e.clearRect(-Pt.left,-Pt.top,Bt[0],Bt[1]),Dt&&Jt.current&&r.scales&&function(e,t,n,o,r,i,s){var a,l;if(!1===r.crosshair)return;const c=t.allSeries,u=c&&c.length>0,d=null!==(a=t.xPx)&&void 0!==a?a:t.x;e.save();const h="object"==typeof r.crosshair?r.crosshair:{};if(e.strokeStyle=h.stroke||s.crosshair,e.lineWidth=h.strokeWidth||1,e.setLineDash(h.strokeDasharray?h.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(u?d:t.x,0),e.lineTo(u?d:t.x,o),e.stroke(),u||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke()),e.restore(),u){e.lineWidth=2,e.strokeStyle=s.pointRing;for(const t of c)null!=t.valuePx&&(e.beginPath(),e.arc(d,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||"#007bff",e.fill(),e.stroke())}else{let n="";try{(null===(l=e.canvas)||void 0===l?void 0:l.parentElement)&&(n=getComputedStyle(e.canvas).getPropertyValue("--semiotic-primary").trim())}catch(e){}const o=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)||n||"#007bff";e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=o,e.fill(),e.strokeStyle=s.pointRing,e.lineWidth=2,e.stroke()}}(e,Jt.current,Lt,Nt,"object"==typeof Dt?Dt:{},Zt.current,u),Zt.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,Zt.current,t)}}l&&n&&n.setAttribute("aria-label",Ge(r.scene,p+" chart"));const g=qt.current;if(qt.current=!1,g&&r.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!Qt||e(Qt.x.domain()[0])!==e(r.scales.x.domain()[0])||e(Qt.x.domain()[1])!==e(r.scales.x.domain()[1])||e(Qt.y.domain()[0])!==e(r.scales.y.domain()[0])||e(Qt.y.domain()[1])!==e(r.scales.y.domain()[1])||Qt.x.range()[0]!==r.scales.x.range()[0]||Qt.x.range()[1]!==r.scales.x.range()[1]||Qt.y.range()[0]!==r.scales.y.range()[0]||Qt.y.range()[1]!==r.scales.y.range()[1])&&Kt(r.scales),bt){const e=r.getData(),t="function"==typeof w?w:e=>e[w||"x"],n="function"==typeof A?A:e=>e[A||"y"];sn(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),ln(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}g&&Le&&Le.length>0&&Ut(e=>e+1),(null==ut?void 0:ut.showBadge)&&on(!!h),(a||r.hasActivePulses)&&(Yt.current=requestAnimationFrame(()=>cn.current()))},e.useEffect(()=>(gn(),()=>{Yt.current&&(cancelAnimationFrame(Yt.current),Yt.current=0)}),[gn]),e.useEffect(()=>{qt.current=!0,gn()},[p,Lt,Nt,me,X,V,Ue,gn]),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])}(ut,hn,qt,gn,nn,on);const Cn=e.useMemo(()=>{if(we||Oe)return;const e=hn.current;return(null==e?void 0:e.xIsDate)&&Qt?It(Qt.x.domain()):void 0},[we,Oe,Qt]),En=we||Oe||Cn,_n=Dt&&en?Me?Me(en):h.createElement($t,{hover:en}):null,Bn=_n?h.createElement(it,{x:en.x,y:en.y,containerWidth:Lt,containerHeight:Nt,margin:Pt,className:"stream-frame-tooltip"},_n):null,Pn=On.current,Ln=h.createElement(rt,{active:An.current>=0,hoverPoint:en,margin:Pt,size:Bt,shape:null==Pn?void 0:Pn.shape,width:null==Pn?void 0:Pn.w,height:null==Pn?void 0:Pn.h}),Nn=(e,t,n,o)=>"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:n,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:o,fn:t}:{key:void 0,fn:null},In=Nn(w,I,"__semiotic_resolvedX","__semiotic_resolvedTime"),Hn=Nn(A,B,"__semiotic_resolvedY","__semiotic_resolvedValue"),Fn=In.key,Tn=Hn.key,zn=Le&&Le.length>0,$n=e=>{if(!e||!zn||!In.fn&&!Hn.fn)return e;let t=!1;const n=e.map(e=>{const n=In.fn&&In.key&&!(In.key in e),o=Hn.fn&&Hn.key&&!(Hn.key in e);if(!n&&!o)return e;t=!0;const r=Object.assign({},e);return n&&(r[In.key]=In.fn(e)),o&&(r[Hn.key]=Hn.fn(e)),r});return t?n:e};if(Re){const e=hn.current;e&&b&&(e.ingest({inserts:b,bounded:!0}),e.computeScene({width:Lt,height:Nt}));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=En||(()=>{if((null==e?void 0:e.xIsDate)&&n)return It(n.x.domain())})();return h.createElement("div",{className:"stream-xy-frame"+(q?" "+q:""),role:"img","aria-label":Ot||("string"==typeof Ke?Ke:"XY chart"),style:{position:"relative",width:Bt[0],height:Bt[1]}},h.createElement(et,{summary:St}),h.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Bt[0],height:Bt[1],style:{position:"absolute",left:0,top:0}},h.createElement("g",{transform:`translate(${Pt.left},${Pt.top})`},Rt),h.createElement("g",{transform:`translate(${Pt.left},${Pt.top})`},X&&h.createElement("rect",{x:0,y:0,width:Lt,height:Nt,fill:X}),Qe&&n&&Qe.map((e,o)=>h.createElement(h.Fragment,{key:"svgpre-"+o},e(t,n,{width:Lt,height:Nt}))),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 h.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 h.createElement("path",{key:"area-"+t,d:`M${i}L${s}Z`,fill:$e(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 h.createElement("circle",{key:"point-"+t,cx:n.x,cy:n.y,r:n.r,fill:$e(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 h.createElement("rect",{key:"rect-"+t,x:n.x,y:n.y,width:n.w,height:n.h,fill:$e(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 h.createElement("g",{key:"heatcell-"+t},h.createElement("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),h.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 h.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 h.createElement("g",{key:"candle-"+t},h.createElement("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),h.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))),h.createElement(ze,{width:Lt,height:Nt,totalWidth:Bt[0],totalHeight:Bt[1],margin:Pt,scales:n,showAxes:me,axes:ve,xLabel:be,yLabel:xe,yLabelRight:ke,xFormat:i,yFormat:Ae||Se,showGrid:Ie,title:Ke,legend:Fe,legendHoverBehavior:Te,legendClickBehavior:De,legendHighlightedCategory:We,legendIsolatedCategories:Ye,legendPosition:qe,foregroundGraphics:zt,marginalGraphics:bt,xValues:[],yValues:[],annotations:Le,svgAnnotationRules:Ne,annotationFrame:0,xAccessor:Fn,yAccessor:Tn,annotationData:$n(null==e?void 0:e.getData()),pointNodes:null==e?void 0:e.scene.filter(e=>"point"===e.type),curve:"string"==typeof C?C:void 0,linkedCrosshairName:jt,linkedCrosshairSourceId:Mt}))}const Rn="semiotic-table-"+h.useId();return h.createElement("div",{ref:_t,className:"stream-xy-frame"+(q?" "+q:""),role:"group","aria-label":Ot||("string"==typeof Ke?Ke:"XY chart"),tabIndex:0,style:{position:"relative",width:D?"100%":Bt[0],height:W?"100%":Bt[1],overflow:"visible"},onKeyDown:jn},At&&h.createElement(tt,{tableId:Rn}),At&&h.createElement(Ze,{scene:null!==(s=null===(i=hn.current)||void 0===i?void 0:i.scene)&&void 0!==s?s:[],chartType:p+" chart",tableId:Rn,chartTitle:"string"==typeof Ke?Ke:void 0}),h.createElement(et,{summary:St}),h.createElement("div",{role:"img","aria-label":Ot||("string"==typeof Ke?Ke:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Dt?Mn:void 0,onMouseLeave:Dt?xn:void 0,onClick:Ee?wn:void 0},Rt&&h.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Bt[0],height:Bt[1],pointerEvents:"none"}},h.createElement("g",{transform:`translate(${Pt.left},${Pt.top})`},Rt)),h.createElement(He,{width:Lt,height:Nt,totalWidth:Bt[0],totalHeight:Bt[1],margin:Pt,scales:Qt,showAxes:me,axes:ve,showGrid:Ie,xFormat:En,yFormat:Ae||Se}),h.createElement("canvas",{ref:Wt,"aria-label":Ge(null!==(l=null===(a=hn.current)||void 0===a?void 0:a.scene)&&void 0!==l?l:[],p+" chart"),style:{position:"absolute",left:0,top:0}}),h.createElement("canvas",{ref:Gt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),h.createElement(nt,{hoverPoint:en}),h.createElement(ze,{width:Lt,height:Nt,totalWidth:Bt[0],totalHeight:Bt[1],margin:Pt,scales:Qt,showAxes:me,axes:ve,xLabel:be,yLabel:xe,yLabelRight:ke,xFormat:En,yFormat:Ae||Se,showGrid:Ie,title:Ke,legend:Fe,legendHoverBehavior:Te,legendClickBehavior:De,legendHighlightedCategory:We,legendIsolatedCategories:Ye,legendPosition:qe,foregroundGraphics:zt,marginalGraphics:bt,xValues:rn,yValues:an,annotations:Le,svgAnnotationRules:Ne,annotationFrame:Vt,xAccessor:Fn,yAccessor:Tn,annotationData:$n(null===(c=hn.current)||void 0===c?void 0:c.getData()),pointNodes:null===(u=hn.current)||void 0===u?void 0:u.scene.filter(e=>"point"===e.type),curve:"string"==typeof C?C:void 0,underlayRendered:!0,linkedCrosshairName:jt,linkedCrosshairSourceId:Mt}),(ot||st)&&h.createElement(y,{width:Lt,height:Nt,totalWidth:Bt[0],totalHeight:Bt[1],margin:Pt,dimension:null!==(d=null==ot?void 0:ot.dimension)&&void 0!==d?d:"xy",scales:Qt,onBrush:null!=st?st:()=>{},binSize:_,snap:null==ot?void 0:ot.snap,binBoundaries:null!==(g=null==ot?void 0:ot.binBoundaries)&&void 0!==g?g:"bar"===p?null===(f=hn.current)||void 0===f?void 0:f.getBinBoundaries():void 0,snapDuring:null==ot?void 0:ot.snapDuring,streaming:"streaming"===v}),(null==ut?void 0:ut.showBadge)&&h.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ut.badgePosition?{top:4,left:4}:"bottom-left"===ut.badgePosition?{bottom:4,left:4}:"bottom-right"===ut.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:nn?"#dc3545":"#28a745",color:"white"})},nn?"STALE":"LIVE"),Ln,Bn))});Rt.displayName="StreamXYFrame";const Dt=e.createContext(null);function Wt(){return e.useContext(Dt)}function Gt(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,r]=o.range;t.push(t=>{const o=t[n];return o>=e&&r>=o})}return e=>t.every(t=>t(e))}function Yt(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[qt,Xt]=st(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),r=Yt(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=Yt(o,t);return o.set(t,Object.assign(Object.assign({},r),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}})),[Vt,Ut]=st(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 Qt(t){const n=e.useId(),o=t.clientId||n,{name:r}=t,i=Xt(e=>e.selections.get(r)),s=Xt(e=>e.setClause),a=Xt(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(Gt(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 Kt(t){const n=t.name||"hover",{fields:o}=t,{predicate:r,isActive:i,selectPoints:s,clear:a}=Qt({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 Jt(t){const{name:n,xField:o,yField:r}=t,{predicate:i,isActive:s,selectInterval:a,clear:l}=Qt({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 Zt=e.createContext(!1);function en({selections:t}){const n=Xt(e=>e.setResolution);return e.useEffect(()=>{for(const[e,o]of Object.entries(t))o.resolution&&n(e,o.resolution)},[t,n]),null}function tn({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=Kt({name:o,fields:[r]}),c=Qt({name:o,clientId:"__linked-legend-isolate__"}),[u,d]=e.useState(new Set),[g,f]=e.useState(null),p=e.useRef(c.selectPoints);p.current=c.selectPoints;const y=e.useRef(c.clear);y.current=c.clear,e.useEffect(()=>{"isolate"===n&&(u.size>0?p.current({[r]:Array.from(u)}):y.current())},[n,u,r]);const m=e.useCallback(e=>{"highlight"===n&&(e?(f(e.label),l.onHover({[r]:e.label})):(f(null),l.onHover(null)))},[n,r,l]),v=e.useCallback(e=>{"isolate"===n&&d(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===s.length?new Set:n})},[n,s.length]);return h.createElement("svg",{width:"100%",height:30,style:{display:"block",overflow:"visible"}},h.createElement(he,{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 nn({children:e,selections:t,showLegend:n,legendPosition:o="top",legendInteraction:r="none",legendSelectionName:i="legend",legendField:s="category"}){const a=Wt(),l=void 0!==n?n:!(!a||0>=Object.keys(a).length);return h.createElement(qt,null,h.createElement(Vt,null,t&&h.createElement(en,{selections:t}),h.createElement(Zt.Provider,{value:l},l&&"top"===o&&a&&h.createElement(tn,{categoryColors:a,interaction:r,selectionName:i,field:s}),e,l&&"bottom"===o&&a&&h.createElement(tn,{categoryColors:a,interaction:r,selectionName:i,field:s}))))}function on({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):M[i%M.length];return{label:r+"",color:a}}),label:""}]}}function rn(e){return e?"string"==typeof e?{name:e}:e:null}function sn(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}h.createContext(void 0);const an="#007bff";function ln(){var e;const t=ht(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}function cn(e){return"function"==typeof e?e:t=>t[e]}function un(t,n,o){const r=Wt(),i=ln();return e.useMemo(()=>{var e;if(!n)return;const s=null!==(e=null!=o?o:i&&i.length>0?i:void 0)&&void 0!==e?e:"category10";if(0!==t.length){if("function"==typeof n){const e=Array.from(new Set(t.map(e=>n(e)+"")));if(r&&Object.keys(r).length>0){const t=_(e.map(e=>({_cat:e})),"_cat",s);return e=>r[e]||t(e)}return _(e.map(e=>({_cat:e})),"_cat",s)}if(r&&Object.keys(r).length>0){const e=_(t,n,s);return t=>r[t]||e(t)}return _(t,n,s)}if(r&&Object.keys(r).length>0){const e=_([{_:"a"}],"_",s);return t=>r[t]||e(t)}},[t,n,o,r,i])}function dn({selection:t,linkedHover:n,fallbackFields:o=[],unwrapData:r=!1,onObservation:i,chartType:s,chartId:a,onClick:l,hoverHighlight:c,colorByField:u}){const d=e.useId(),h=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||t||[],mode:e.mode,xField:e.xField}:null}(n,o),g=Qt({name:(null==t?void 0:t.name)||"__unused__"}),f=Kt({name:(null==h?void 0:h.name)||"hover",fields:(null==h?void 0:h.fields)||o||[]}),p=Ut(e=>e.pushObservation),y=t?{isActive:g.isActive,predicate:g.predicate}:null,[m,v]=e.useState(null),b=u||o[0],x=e.useMemo(()=>{if(!c||null==m||!b)return null;const e=m,t=b;return{isActive:!0,predicate:n=>{var o;return("string"==typeof n[t]?n[t]:(null!==(o=n[t])&&void 0!==o?o:"")+"")===e}}},[c,m,b]),k=e.useCallback(e=>{var t,o;if(n)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===(null==h?void 0:h.mode)&&h.xField){const e=null==t?void 0:t[h.xField];null!=e&&Number.isFinite(Number(e))&&function(e,t,n){const o=Oe.positions.get(e);(null==o?void 0:o.locked)||o&&o.xValue===t&&o.sourceId===n||(Oe={positions:new Map(Oe.positions).set(e,{xValue:t,sourceId:n})},je())}(h.name||"hover",Number(e),d)}"x-position"!==(null==h?void 0:h.mode)&&f.onHover(t)}else"x-position"===(null==h?void 0:h.mode)&&Me(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&f.onHover(null);if(c&&b)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[b];v(null!=n?n+"":null)}else v(null);if(i||p){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),p&&p(s)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(e),p&&p(e)}}},[n,f,h,d,i,s,a,p,c,b]),w=e.useCallback(e=>{var t,n,o,r;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[h.xField];null!=n&&Number.isFinite(Number(n))&&function(e,t,n){const o=Oe.positions.get(e);if(null==o?void 0:o.locked){const t=new Map(Oe.positions);return t.delete(e),Oe={positions:t},je(),!1}Oe={positions:new Map(Oe.positions).set(e,{xValue:t,sourceId:n,locked:!0})},je()}(h.name||"hover",Number(n),d)}if(e&&l){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]),l(o,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0})}if(i||p){const t={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){let n=e.data||e.datum||e;Array.isArray(n)&&(n=n[0]);const s=Object.assign(Object.assign({},t),{type:"click",datum:n||{},x:null!==(o=e.x)&&void 0!==o?o:0,y:null!==(r=e.y)&&void 0!==r?r:0});i&&i(s),p&&p(s)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});i&&i(e),p&&p(e)}}},[l,i,p,s,a,h,d]);return e.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const e=h.name||"hover";return()=>{Ce(e,d),Me(e,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:y,hoverSelectionHook:x,customHoverBehavior:k,customClickBehavior:w,crosshairSourceId:d}}function hn(e,t){const n="object"==typeof e&&null!==e?e:void 0;if("x-position"===(null==n?void 0:n.mode))return{linkedCrosshairName:n.name||"hover",linkedCrosshairSourceId:t}}function gn({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(Zt),u=void 0!==r?r:!c&&!!n,d=e.useMemo(()=>{if(u&&n)return on({data:t,colorBy:n,colorScale:o,getColor:E,categories:l})},[u,n,t,o,l]),h=e.useMemo(()=>{const e=Object.assign(Object.assign({},a),s);return d&&("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,d,i]);return{legend:d,margin:h,legendPosition:i}}function fn(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 pn={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 yn(e,t,n){var o,r,i,s,a,l,c;const u=pn[e||"primary"],d="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:e&&"primary"!==e||!(null==n?void 0:n.width)?u.width:n.width,height:null!==(r=t.height)&&void 0!==r?r:e&&"primary"!==e||!(null==n?void 0:n.height)?u.height:n.height,showAxes:null!==(i=t.showAxes)&&void 0!==i?i:u.showAxes,showGrid:null!==(s=t.showGrid)&&void 0!==s?s:u.showGrid,enableHover:null!==(a=t.enableHover)&&void 0!==a?a:!!t.linkedHover||u.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:u.showLegend,showLabels:null!==(c=t.showLabels)&&void 0!==c?c:u.showLabels,title:d?void 0:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:d?void 0:t.xLabel,yLabel:d?void 0:t.yLabel,categoryLabel:d?void 0:t.categoryLabel,valueLabel:d?void 0:t.valueLabel,marginDefaults:mn(u.marginDefaults,t.showCategoryTicks,t.orientation)}}function mn(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 vn={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 bn(e,t){return"function"==typeof t?t(e):e[t]}function xn(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return 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 kn(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=bn(e,n);s=xn(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=bn(e,r);a.push({label:n,value:xn(s,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){s=xn(e[n],o);break}if(!s){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(s=xn(e[t[0]],o))}}const l=Object.assign(Object.assign({},vn),r);return h.createElement("div",{className:("semiotic-tooltip "+i).trim(),style:l},s&&h.createElement("div",{style:{fontWeight:a.length>0?"bold":"normal"}},s),a.map((e,t)=>h.createElement("div",{key:t,style:{marginTop:0===t&&s?"4px":0}},e.label&&h.createElement("span",null,e.label,": "),e.value)))}}function wn(e){if(!0===e)return kn();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:h.createElement("div",{className:"semiotic-tooltip",style:vn},n)}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?kn(e):kn())}function An(e){return"string"==typeof e?e:"value"}function On(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function Sn(e,t){return"function"==typeof t?t(e):e[t]}function jn(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?On(Sn(o,t.accessor)):null;return h.createElement("div",{className:"semiotic-tooltip",style:vn},r&&h.createElement("div",{style:{fontWeight:"bold",marginBottom:n.length>0?4:0}},r),n.map((e,t)=>{const n=On(Sn(o,e.accessor));return h.createElement("div",{key:t,style:t>0?{marginTop:2}:void 0},h.createElement("span",{style:{opacity:.7}},e.label,": "),h.createElement("span",null,n))}))}}function Mn({componentName:e,message:t,diagnosticHint:n,width:o,height:r}){return h.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"}},h.createElement("div",{style:{textAlign:"center",maxWidth:400}},h.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),h.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t),n&&h.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 Cn extends h.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:h.createElement(Mn,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function En(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 _n(e,t,n=3){let o,r=n+1;for(const n of t){const t=En(e.toLowerCase(),n.toLowerCase());r>t&&(r=t,o=n)}return r>n?void 0:o}function Bn(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function Pn(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=_n(e,t,3))&&void 0!==n?n:null)}function Ln({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=Bn(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=Pn(i,t),o=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}const Nn={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"},onClick:{type:"function"}},In={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},Hn={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"}},Fn=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],Tn=["vertical","horizontal"],zn={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Nn),In),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Fn},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({},Nn),In),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Fn},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Nn),In),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Fn},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({},Nn),In),{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({},Nn),In),{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({},Nn),In),{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({},Nn),In),{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({},Nn),In),{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({},Nn),In),{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({},Nn),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Tn},sort:{type:["boolean","string","function"]},barPadding:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Nn),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Tn},normalize:{type:"boolean"},barPadding:{type:"number"}})},LikertChart:{required:["levels"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor","levelAccessor","countAccessor"],props:Object.assign(Object.assign(Object.assign({},Nn),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},levelAccessor:{type:["string","function"]},countAccessor:{type:["string","function"]},levels:{type:"array"},orientation:{type:"string",enum:Tn},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Nn),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Tn},barPadding:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Nn),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Tn},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Nn),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Tn},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Nn),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Nn),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Tn},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},RidgelinePlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Nn),Hn),{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({},Nn),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Tn},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},Nn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"}})},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},Nn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"}})},GaugeChart:{required:["value"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Nn),{value:{type:"number"},min:{type:"number"},max:{type:"number"},thresholds:{type:"array"},arcWidth:{type:"number"},sweep:{type:"number"},showNeedle:{type:"boolean"},needleColor:{type:"string"},centerContent:{type:["object","string","number","function"]},valueFormat:{type:"function"},showScaleLabels:{type:"boolean"},backgroundColor:{type:"string"}})},FunnelChart:{required:["data"],dataShape:"array",dataAccessors:["stepAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Nn),Hn),{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"]}})},SwimlaneChart:{required:["subcategoryAccessor"],dataShape:"array",dataAccessors:["categoryAccessor","subcategoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Nn),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},subcategoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},barPadding:{type:"number"},showCategoryTicks:{type:"boolean"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},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({},Nn),{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({},Nn),{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:Tn},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({},Nn),{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({},Nn),{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({},Nn),{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({},Nn),{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({},Nn),{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"},brush:{type:["boolean","string","object"]},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},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 $n(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}const Rn=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),Dn=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),Wn=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),Gn=new Set(["LineChart","AreaChart","StackedAreaChart"]),Yn=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]);function qn(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 Xn(e,t){const n=qn(e),o=qn(t);return null===n||null===o?null:(Math.max(n,o)+.05)/(Math.min(n,o)+.05)}const Vn=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIDAccessor","childrenAccessor","costAccessor"];function Un(e,t){const n=[],o=function(e,t){const n=[],o=zn[e];if(!o)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(zn).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(!$n(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=_n(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=Ln({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=Bn(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=Pn(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 zn[e]?(function(e,t,n){const o=zn[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=zn[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){Rn.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){Dn.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=zn[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(!Wn.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(!Gn.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=zn[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(!Yn.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=Xn(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=t.colorScheme;if(!o||!Array.isArray(o)||2>o.length)return;const r=o.filter(e=>"string"==typeof e&&e.startsWith("#"));if(2>r.length)return;const i=[];for(let e=0;r.length-1>e;e++){const t=Xn(r[e],r[e+1]);null!==t&&1.5>t&&i.push(`${r[e]} / ${r[e+1]} (${t.toFixed(1)}:1)`)}i.length>0&&n.push({severity:"warning",code:"LOW_ADJACENT_CONTRAST",message:`${i.length} adjacent color pair(s) in colorScheme have very similar luminance: ${i.join("; ")}. Categories may be hard to distinguish.`,fix:'Alternate light and dark colors in the scheme, or use COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for a pre-tested palette.'})}(0,t,n),function(e,t,n){const o="string"==typeof t.title&&t.title.trim().length>0,r="string"==typeof t.description&&t.description.trim().length>0,i="string"==typeof t.summary&&t.summary.trim().length>0;o||r||i||n.push({severity:"warning",code:"MISSING_DESCRIPTION",message:'No title, description, or summary provided. Screen readers will use a generic label like "XY chart".',fix:'Add a title="..." prop for a brief label, or description="..." for a detailed aria-label, or summary="..." for a screen-reader-only note describing the chart\'s purpose.'})}(0,t,n),function(e,t,n){const o=[];for(const e of Vn)"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 Qn;const Kn="undefined"!=typeof process&&"production"!==(null===(Qn=process.env)||void 0===Qn?void 0:Qn.NODE_ENV);function Jn({componentName:e,width:t,height:n,chartProps:o,children:r}){return h.createElement(Cn,{fallback:r=>{let i="";if(Kn&&o)try{const t=Un(e,o);t.ok||(i=t.diagnoses.map(e=>`${"error"===e.severity?"✗":"⚠"} ${e.message}${e.fix?" — Fix: "+e.fix:""}`).join("\n"))}catch(e){}return h.createElement(Mn,{componentName:e,message:r.message,diagnosticHint:i,width:t,height:n})}},r)}const Zn={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"},eo={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function to(e,t,n,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?h.createElement("div",{style:Object.assign(Object.assign({},Zn),{width:t,height:n})},o||"No data available"):null}function no(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 h.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)=>h.createElement("div",{key:n,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},eo),{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 oo(e,t,n,o){if(!Kn)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const r=t[0];if(!r||"object"!=typeof r)return;if(o in r)return;const i=Object.keys(r).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${i}`)}function ro(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 io="__forecastSegment";let so=null;function ao(){return ro(this,void 0,void 0,function*(){return so||(so=yield Promise.resolve().then(function(){return zo})),so})}const lo=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)},remove:e=>{var t,n;return null!==(n=null===(t=i.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=i.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},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=yn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:t.xLabel,yLabel:t.yLabel}),{data:a,margin:l,className:c,xFormat:u,yFormat:d,xAccessor:g="x",yAccessor:f="y",lineBy:p,lineDataAccessor:y="coordinates",colorBy:m,colorScheme:v,curve:b="linear",showPoints:x=!1,pointRadius:k=3,fillArea:w=!1,areaOpacity:A=.3,lineWidth:O=2,lineGradient:S,tooltip:j,pointIdAccessor:M,annotations:C,directLabel:_,gapStrategy:B="break",anomaly:P,forecast:L,frameProps:N={},selection:I,linkedHover:H,onObservation:F,onClick:T,hoverHighlight:z,hoverRadius:$,chartId:R,loading:D,emptyContent:W,legendInteraction:G,legendPosition:Y,xScaleType:q,yScaleType:X,color:V}=t,U=s.width,Q=s.height,K=s.enableHover,J=s.showGrid,Z=s.showLegend,ee=s.title,te=s.description,ne=s.summary,oe=s.accessibleTable,re=s.xLabel,ie=s.yLabel,se=no(D,U,Q),ae=se?null:to(a,U,Q,W),le=a||[];oo("LineChart",le,"xAccessor",g),oo("LineChart",le,"yAccessor",f);const ce="string"==typeof g?g:"__semiotic_resolvedX",ue="string"==typeof f?f:"__semiotic_resolvedY",[de,he]=e.useState(null),[ge,fe]=e.useState([]),pe=e.useMemo(()=>{if(!L&&!P)return le;const e="function"==typeof g,t="function"==typeof f;return e||t?le.map(n=>{const o=Object.assign({},n);return e&&(o.__semiotic_resolvedX=g(n)),t&&(o.__semiotic_resolvedY=f(n)),o}):le},[le,L,P,g,f]),ye=e.useRef(L),me=e.useRef(P);e.useEffect(()=>{if(!L&&!P)return void((ye.current||me.current)&&(he(null),fe([]),ye.current=L,me.current=P));let e=!1;const t=L!==ye.current||P!==me.current;if(ye.current=L,me.current=P,t&&(he(null),fe([])),L){const t=p&&"string"==typeof p&&"object"==typeof L?Object.assign(Object.assign({},L),{_groupBy:p}):L;(function(...e){return ro(this,void 0,void 0,function*(){return(yield ao()).buildForecast(...e)})})(pe,ce,ue,t,P).then(t=>{e||(he(t),fe(t.annotations))}).catch(()=>{e||(he(null),fe([]))})}else P&&function(...e){return ro(this,void 0,void 0,function*(){return(yield ao()).buildAnomalyAnnotations(...e)})}(P).then(t=>{e||(he(null),fe(t))}).catch(()=>{e||fe([])});return()=>{e=!0}},[pe,L,P,ce,ue]);const ve=de?de.processedData:le,be="__compoundGroup",xe=!(!L||!p),ke=xe?be:L?io:p,we=e.useMemo(()=>{if(!xe)return ve;const e="function"==typeof p?p:e=>e[p];return ve.map(t=>{const n=Object.assign({},t);return n[be]=`${e(t)}__${t[io]||"observed"}`,n})},[ve,xe,p]),Ae=xe?we:ve,Oe=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=de?de.processedData:le;for(const e of s){const t="function"==typeof f?f(e):+e[f];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,de,le,f]),{activeSelectionHook:Se,hoverSelectionHook:je,customHoverBehavior:Me,customClickBehavior:Ce,crosshairSourceId:Ee}=dn({selection:I,linkedHover:H,fallbackFields:m?["string"==typeof m?m:""]:[],onObservation:F,onClick:T,chartType:"LineChart",chartId:R,hoverHighlight:z,colorByField:"string"==typeof m?m:void 0}),_e=hn(H,Ee),Be=e.useCallback(e=>{const t="function"==typeof g?g(e):e[g],n="function"==typeof f?f(e):e[f];return null==t||null==n||Number.isNaN(t)||Number.isNaN(n)},[g,f]),Pe=void 0!==(null===(o=Ae[0])||void 0===o?void 0:o[y]),Le=e.useMemo(()=>{if(Pe)return Ae;if(ke){const e=Ae.reduce((e,t)=>{const n="function"==typeof ke?ke(t):t[ke];if(!e[n]){const o={[y]:[]};"string"==typeof ke&&(o[ke]=n),xe&&(o[io]=t[io],"string"==typeof p&&(o[p]=t[p])),e[n]=o}return e[n][y].push(t),e},{});return Object.values(e)}return[{[y]:Ae}]},[Ae,ke,y,Pe]),{gapProcessedLineData:Ne,hasGaps:Ie}=e.useMemo(()=>{if("interpolate"===B){let e=!1;const t=[];for(const n of Le){const o=(n[y]||[]).filter(t=>!Be(t)||(e=!0,!1));o.length>0&&t.push(Object.assign(Object.assign({},n),{[y]:o}))}return{gapProcessedLineData:t,hasGaps:e}}if("break"===B){let e=!1;const t=[];for(const n of Le){const o=n[y]||[];let r=[],i=0;const s=ke&&"string"==typeof ke?n[ke]:void 0;for(const a of o)if(Be(a))e=!0,r.length>0&&(t.push(Object.assign(Object.assign({},n),{[y]: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),{[y]:r}))}return{gapProcessedLineData:t,hasGaps:e}}if("zero"===B){let e=!1;const t="string"==typeof f?f:"y",n=[];for(const o of Le){const r=o[y]||[],i=[];for(const n of r)Be(n)?(e=!0,i.push(Object.assign(Object.assign({},n),{[t]:0}))):i.push(n);n.push(Object.assign(Object.assign({},o),{[y]:i}))}return{gapProcessedLineData:n,hasGaps:e}}return{gapProcessedLineData:Le,hasGaps:!1}},[Le,B,y,Be,ke,f]),He=un(ve,m,v),Fe=e.useMemo(()=>{if(!m)return[];const e=new Set;for(const t of ve){const n="function"==typeof m?m(t):t[m];null!=n&&e.add(n+"")}return Array.from(e)},[ve,m]),Te=fn(G,m,Fe),ze=e.useMemo(()=>je||(Te.legendSelectionHook?Te.legendSelectionHook:Se),[je,Te.legendSelectionHook,Se]),$e=e.useMemo(()=>(e,t)=>{const n={strokeWidth:O},o=!0===w||Array.isArray(w)&&null!=t&&w.includes(t);return m?He&&(n.stroke=E(e,m,He),o&&(n.fill=n.stroke,n.fillOpacity=A)):(n.stroke=V||an,o&&(n.fill=V||an,n.fillOpacity=A)),n},[m,He,O,w,A,V]),[Re,De]=e.useState(null);e.useEffect(()=>{if(!L)return void De(null);let e=!1;return function(...e){return ro(this,void 0,void 0,function*(){return(yield ao()).createSegmentLineStyle(...e)})}($e,L).then(t=>{e||De(()=>t)}).catch(()=>{e||De(null)}),()=>{e=!0}},[$e,L]);const We=Re||$e,Ge=e.useMemo(()=>sn(We,ze,I),[We,ze,I]),Ye=e.useMemo(()=>{if(x)return e=>{const t={r:k,fillOpacity:1};return m?He&&(t.fill=E(e.parentLine||e,m,He)):t.fill=V||an,t}},[x,k,m,He,V]),qe=Array.isArray(w)?"mixed":w?"area":"line",Xe="object"==typeof _?_:{},Ve=Xe.position||"end",Ue=Xe.fontSize||11,Qe=e.useMemo(()=>{var e,t;if(!_||!m)return[];const n="function"==typeof g?g:e=>e[g],o="function"==typeof f?f:e=>e[f],r="function"==typeof m?m:e=>e[m],i=new Map;for(const n of Ne){const o=n[y]||[];if(0===o.length)continue;const s="end"===Ve?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 f?f:"y"]:o(t),dx:"end"===Ve?6:-6,dy:0,color:He?He(e):an,fontSize:Ue}));s.sort((e,t)=>{const n="string"==typeof f?f:"y";return e[n]-t[n]});for(let e=1;s.length>e;e++){const t="string"==typeof f?f:"y",n=s[e-1],o=s[e];Ue+2>Math.abs(o[t]+o.dy-(n[t]+n.dy))&&(o.dy+=Ue+2)}return s},[_,m,He,Ne,y,g,f,Ve,Ue]),Ke=(!_||void 0!==Z)&&Z,Je=e.useMemo(()=>{if(!_)return s.marginDefaults;const e=Qe.reduce((e,t)=>{var n;const o=((null===(n=t.label)||void 0===n?void 0:n.length)||0)*(.6*Ue);return Math.max(e,o)},0),t=e+10,n="end"===Ve?"right":"left";return Object.assign(Object.assign({},s.marginDefaults),{[n]:Math.max(s.marginDefaults[n]||0,t)})},[_,Qe,Ue,Ve,s.marginDefaults]),{legend:Ze,margin:et,legendPosition:tt}=gn({data:Ne,colorBy:m,colorScale:He,showLegend:Ke,legendPosition:Y,userMargin:l,defaults:Je}),nt=p||m,ot=e.useMemo(()=>jn([{label:re||An(g),accessor:g,role:"x"},{label:ie||An(f),accessor:f,role:"y"},...nt?[{label:An(nt),accessor:nt,role:"group"}]:[]]),[g,f,re,ie,nt]),rt=Ln({componentName:"LineChart",data:Pe?(null===(r=ve[0])||void 0===r?void 0:r[y])||[]:a,accessors:{xAccessor:g,yAccessor:f}}),it=e.useMemo(()=>Pe||ke||Ie?Ne.flatMap(e=>{const t=e[y]||[];return ke&&"string"==typeof ke?t.map(t=>Object.assign(Object.assign({},t),{[ke]:e[ke]})):t}):Ae,[Ne,y,Pe,ke,Ae,Ie]),st=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(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:qe},Array.isArray(w)&&{areaGroups:w}),S&&{lineGradient:S}),null!=$&&{hoverRadius:$}),null!=a&&{data:it}),{xAccessor:g,yAccessor:f,xScaleType:q,yScaleType:X}),Oe&&{yExtent:Oe}),{groupAccessor:"break"===B&&Ie?"_gapSegment":ke||void 0,curve:b,lineStyle:Ge}),x&&{pointStyle:Ye}),{size:[U,Q],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:et,showAxes:s.showAxes,xLabel:re,yLabel:ie,xFormat:u,yFormat:d,enableHover:K,showGrid:J}),Ze&&{legend:Ze,legendPosition:tt}),G&&"none"!==G&&{legendHoverBehavior:Te.onLegendHover,legendClickBehavior:Te.onLegendClick,legendHighlightedCategory:Te.highlightedCategory,legendIsolatedCategories:Te.isolatedCategories}),ee&&{title:ee}),te&&{description:te}),ne&&{summary:ne}),void 0!==oe&&{accessibleTable:oe}),c&&{className:c}),{tooltipContent:!1===j?()=>null:"multi"===j?e=>{var t,n,o,r,i,s,a,l,c,u;const d=e.allSeries;if(!d||0===d.length){const s=null!==(i=null!==(r=null!==(n=null===(t=e.data)||void 0===t?void 0:t.value)&&void 0!==n?n:null===(o=e.data)||void 0===o?void 0:o.y)&&void 0!==r?r:e.value)&&void 0!==i?i:e.y;return h.createElement("div",{className:"semiotic-tooltip",style:vn},h.createElement("div",null,xn(s)))}const g=null!==(u=null!==(l=null!==(s=e.xValue)&&void 0!==s?s:null===(a=e.data)||void 0===a?void 0:a.time)&&void 0!==l?l:null===(c=e.data)||void 0===c?void 0:c.x)&&void 0!==u?u:e.time;return h.createElement("div",{className:"semiotic-tooltip",style:vn},null!=g&&h.createElement("div",{style:{fontWeight:600,marginBottom:4,fontSize:"0.9em",borderBottom:"1px solid var(--semiotic-border, #eee)",paddingBottom:4}},xn(g)),d.map((e,t)=>h.createElement("div",{key:t,style:{display:"flex",alignItems:"center",gap:6,padding:"1px 0"}},h.createElement("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:e.color,flexShrink:0}}),h.createElement("span",{style:{flex:1,fontSize:"0.85em"}},e.group),h.createElement("span",{style:{fontWeight:500,fontSize:"0.85em"}},xn(e.value)))))}:wn(j)||ot}),"multi"===j&&{tooltipMode:"multi"}),(H||F||T||z)&&{customHoverBehavior:Me}),(F||T||H)&&{customClickBehavior:Ce}),M&&{pointIdAccessor:M}),((null==C?void 0:C.length)||ge.length||Qe.length)&&{annotations:[...C||[],...ge,...Qe]}),_e),N);return se||ae||(rt?h.createElement(Mn,{componentName:"LineChart",message:rt,width:U,height:Q}):h.createElement(Jn,{componentName:"LineChart",width:U,height:Q},h.createElement(Rt,Object.assign({ref:i},st))))});lo.displayName="LineChart";const co=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)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},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=yn(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:d="x",yAccessor:g="y",areaBy:f,y0Accessor:p,gradientFill:y=!1,lineDataAccessor:m="coordinates",colorBy:v,colorScheme:b,curve:x="monotoneX",areaOpacity:k=.7,lineGradient:w,showLine:A=!0,lineWidth:O=2,showPoints:S=!1,pointRadius:j=3,tooltip:M,annotations:C,frameProps:_={},selection:B,linkedHover:P,onObservation:L,onClick:N,hoverHighlight:I,chartId:H,loading:F,emptyContent:T,legendInteraction:z,legendPosition:$,color:R}=t,D=i.width,W=i.height,G=i.enableHover,Y=i.showGrid,q=i.showLegend,X=i.title,V=i.description,U=i.summary,Q=i.accessibleTable,K=i.xLabel,J=i.yLabel,Z=no(F,D,W),ee=Z?null:to(s,D,W,T),te=s||[];oo("AreaChart",te,"xAccessor",d),oo("AreaChart",te,"yAccessor",g);const{activeSelectionHook:ne,hoverSelectionHook:oe,customHoverBehavior:re,customClickBehavior:ie,crosshairSourceId:se}=dn({selection:B,linkedHover:P,fallbackFields:v?["string"==typeof v?v:""]:[],onObservation:L,onClick:N,chartType:"AreaChart",chartId:H,hoverHighlight:I,colorByField:"string"==typeof v?v:void 0}),ae=hn(P,se),le=void 0!==(null===(o=te[0])||void 0===o?void 0:o[m]),ce=e.useMemo(()=>{if(le)return te;if(f){const e=te.reduce((e,t)=>{const n="function"==typeof f?f(t):t[f];if(!e[n]){const t={[m]:[]};"string"==typeof f&&(t[f]=n),e[n]=t}return e[n][m].push(t),e},{});return Object.values(e)}return[{[m]:te}]},[te,f,m,le]),ue=un(te,v,b),de=e.useMemo(()=>{if(!v)return[];const e=new Set;for(const t of te){const n="function"==typeof v?v(t):t[v];null!=n&&e.add(n+"")}return Array.from(e)},[te,v]),he=fn(z,v,de),ge=e.useMemo(()=>oe||(he.legendSelectionHook?he.legendSelectionHook:ne),[oe,he.legendSelectionHook,ne]),fe=e.useMemo(()=>e=>{const t={};if(v){if(ue){const n=E(e,v,ue);t.fill=n,A?(t.stroke=n,t.strokeWidth=O):t.stroke="none"}}else{const e=R||an;t.fill=e,A?(t.stroke=e,t.strokeWidth=O):t.stroke="none"}return t.fillOpacity=k,t},[v,ue,R,k,A,O]),pe=e.useMemo(()=>sn(fe,ge,B),[fe,ge,B]),ye=e.useMemo(()=>{if(S)return e=>{const t={r:j,fillOpacity:1};return v?ue&&(t.fill=E(e.parentLine||e,v,ue)):t.fill=an,t}},[S,j,v,ue]),{legend:me,margin:ve,legendPosition:be}=gn({data:ce,colorBy:v,colorScale:ue,showLegend:q,legendPosition:$,userMargin:a,defaults:i.marginDefaults}),xe=f||v,ke=e.useMemo(()=>jn([{label:K||An(d),accessor:d,role:"x"},{label:J||An(g),accessor:g,role:"y"},...xe?[{label:An(xe),accessor:xe,role:"group"}]:[]]),[d,g,K,J,xe]),we=Ln({componentName:"AreaChart",data:s,accessors:{xAccessor:d,yAccessor:g}}),Ae=e.useMemo(()=>le||f?ce.flatMap(e=>{const t=e[m]||[];return f&&"string"==typeof f?t.map(t=>Object.assign(Object.assign({},t),{[f]:e[f]})):t}):te,[ce,m,le,f,te]),Oe=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(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area"},null!=s&&{data:Ae}),{xAccessor:d,yAccessor:g,groupAccessor:f||void 0}),p&&{y0Accessor:p}),y&&{gradientFill:y}),w&&{lineGradient:w}),{curve:x,lineStyle:pe}),S&&ye&&{pointStyle:ye}),{size:[D,W],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ve,showAxes:i.showAxes,xLabel:K,yLabel:J,xFormat:c,yFormat:u,enableHover:G}),t.pointIdAccessor&&{pointIdAccessor:t.pointIdAccessor}),{showGrid:Y}),me&&{legend:me,legendPosition:be}),z&&"none"!==z&&{legendHoverBehavior:he.onLegendHover,legendClickBehavior:he.onLegendClick,legendHighlightedCategory:he.highlightedCategory,legendIsolatedCategories:he.isolatedCategories}),X&&{title:X}),V&&{description:V}),U&&{summary:U}),void 0!==Q&&{accessibleTable:Q}),l&&{className:l}),{tooltipContent:!1===M?()=>null:wn(M)||ke}),(P||L||N||I)&&{customHoverBehavior:re}),(L||N||P)&&{customClickBehavior:ie}),C&&C.length>0&&{annotations:C}),ae),_);return Z||ee||(we?h.createElement(Mn,{componentName:"AreaChart",message:we,width:D,height:W}):h.createElement(Jn,{componentName:"AreaChart",width:D,height:W},h.createElement(Rt,Object.assign({ref:r},Oe))))});function uo({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]),d=e.useCallback(e=>{if(!t||!n)return;let o=!1;for(const t of e){if(!t||"object"!=typeof t)continue;const e=u(t);null==e||s.current.has(e)||(s.current.add(e),a.current.push(e),o=!0)}o&&c(e=>e+1)},[t,n,u]),h=e.useCallback(e=>t=>{d([t]),e(t)},[d]),g=e.useCallback(e=>t=>{d(t),e(t)},[d]),f=e.useCallback(()=>{s.current=new Set,a.current=[],c(e=>e+1)},[]),p=e.useMemo(()=>{if(!t||!n||!1===r)return;const e=a.current;if(0===e.length)return;const i=Array.isArray(o)?o:M,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 on({data:e.map(e=>({[l]:e})),colorBy:l,colorScale:e=>s.get(e)||"#999",getColor:E})},[t,n,r,o,l]),y=e.useMemo(()=>{if(p)return"right"===i?{right:110}:"left"===i?{left:110}:"top"===i?{top:50}:"bottom"===i?{bottom:80}:{right:110}},[p,i]);return{wrapPush:h,wrapPushMany:g,resetCategories:f,streamingLegend:p,streamingMarginAdjust:y}}co.displayName="AreaChart";const ho=e.forwardRef(function(t,n){var o;const r=e.useRef(null),i=yn(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:d="x",yAccessor:g="y",areaBy:f,lineDataAccessor:p="coordinates",colorBy:y,colorScheme:m,curve:v="monotoneX",areaOpacity:b=.7,showLine:x=!0,lineWidth:k=2,showPoints:w=!1,pointRadius:A=3,normalize:O=!1,tooltip:S,annotations:j,frameProps:M={},selection:C,linkedHover:_,onObservation:B,onClick:P,hoverHighlight:L,chartId:N,loading:I,emptyContent:H,legendInteraction:F,legendPosition:T,color:z}=t,$=i.width,R=i.height,D=i.enableHover,W=i.showGrid,G=i.showLegend,Y=i.title,q=i.description,X=i.summary,V=i.accessibleTable,U=i.xLabel,Q=i.yLabel,K=no(I,$,R),J=K?null:to(s,$,R,H),Z=s||[],ee=uo({isPushMode:void 0===s,colorBy:y||f,colorScheme:m,showLegend:G,legendPosition:T}),te=e.useCallback(ee.wrapPush(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)}),[ee.wrapPush]),ne=e.useCallback(ee.wrapPushMany(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)}),[ee.wrapPushMany]);e.useImperativeHandle(n,()=>({push:te,pushMany:ne,remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;ee.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:[]}}),[te,ne,ee.resetCategories]);const{activeSelectionHook:oe,hoverSelectionHook:re,customHoverBehavior:ie,customClickBehavior:se,crosshairSourceId:ae}=dn({selection:C,linkedHover:_,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:B,onClick:P,chartType:"StackedAreaChart",chartId:N,hoverHighlight:L,colorByField:"string"==typeof y?y:void 0}),le=hn(_,ae),ce=void 0!==(null===(o=Z[0])||void 0===o?void 0:o[p]),ue=e.useMemo(()=>{if(ce)return Z;if(f){const e=Z.reduce((e,t)=>{const n="function"==typeof f?f(t):t[f];if(!e[n]){const t={[p]:[]};"string"==typeof f&&(t[f]=n),e[n]=t}return e[n][p].push(t),e},{});return Object.values(e)}return[{[p]:Z}]},[Z,f,p,ce]),de=un(Z,y,m),he=e.useMemo(()=>{if(!y)return[];const e=new Set;for(const t of Z){const n="function"==typeof y?y(t):t[y];null!=n&&e.add(n+"")}return Array.from(e)},[Z,y]),ge=fn(F,y,he),fe=e.useMemo(()=>re||(ge.legendSelectionHook?ge.legendSelectionHook:oe),[re,ge.legendSelectionHook,oe]),pe=e.useMemo(()=>e=>{const t={};if(y&&de){const n=E(e,y,de);t.fill=n,x?(t.stroke=n,t.strokeWidth=k):t.stroke="none"}else if(!y){const e=z||an;t.fill=e,t.stroke=x?e:"none",x&&(t.strokeWidth=k)}return t.fillOpacity=b,t},[y,de,b,x,k,z]),ye=e.useMemo(()=>sn(pe,fe,C),[pe,fe,C]),me=e.useMemo(()=>{if(w)return e=>{const t={r:A,fillOpacity:1};return y?de&&(t.fill=E(e.parentLine||e,y,de)):t.fill=z||an,t}},[w,A,y,de,z]),{legend:ve,margin:be,legendPosition:xe}=gn({data:ue,colorBy:y,colorScale:de,showLegend:G,legendPosition:T,userMargin:a,defaults:i.marginDefaults}),ke=ee.streamingLegend||ve,we=T||xe,Ae=e.useMemo(()=>{if(ee.streamingMarginAdjust){const e=Object.assign({},be);for(const[t,n]of Object.entries(ee.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return be},[be,ee.streamingMarginAdjust]),Oe=f||y,Se=e.useMemo(()=>jn([{label:U||An(d),accessor:d,role:"x"},{label:Q||An(g),accessor:g,role:"y"},...Oe?[{label:An(Oe),accessor:Oe,role:"group"}]:[]]),[d,g,U,Q,Oe]),je=Ln({componentName:"StackedAreaChart",data:s,accessors:{xAccessor:d,yAccessor:g}}),Me=e.useMemo(()=>ce||f?ue.flatMap(e=>{const t=e[p]||[];return f&&"string"==typeof f?t.map(t=>Object.assign(Object.assign({},t),{[f]:e[f]})):t}):Z,[ue,p,ce,f,Z]),Ce=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(Object.assign(Object.assign(Object.assign({chartType:"stackedarea"},null!=s&&{data:Me}),{xAccessor:d,yAccessor:g,groupAccessor:f||void 0,curve:v,normalize:O,lineStyle:ye}),w&&me&&{pointStyle:me}),{size:[$,R],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Ae,showAxes:i.showAxes,xLabel:U,yLabel:Q,xFormat:c,yFormat:u,enableHover:D}),t.pointIdAccessor&&{pointIdAccessor:t.pointIdAccessor}),{showGrid:W}),ke&&{legend:ke,legendPosition:we}),F&&"none"!==F&&{legendHoverBehavior:ge.onLegendHover,legendClickBehavior:ge.onLegendClick,legendHighlightedCategory:ge.highlightedCategory,legendIsolatedCategories:ge.isolatedCategories}),Y&&{title:Y}),q&&{description:q}),X&&{summary:X}),void 0!==V&&{accessibleTable:V}),l&&{className:l}),{tooltipContent:!1===S?()=>null:wn(S)||Se}),(_||B||P||L)&&{customHoverBehavior:ie}),(B||P||_)&&{customClickBehavior:se}),j&&j.length>0&&{annotations:j}),le),M);return K||J||(je?h.createElement(Mn,{componentName:"StackedAreaChart",message:je,width:$,height:R}):h.createElement(Jn,{componentName:"StackedAreaChart",width:$,height:R},h.createElement(Rt,Object.assign({ref:r},Ce))))});function go(t){const{data:n,rawData:o,colorBy:r,colorScheme:i,legendInteraction:s,legendPosition:a,selection:l,linkedHover:c,fallbackFields:u,unwrapData:d=!1,onObservation:h,chartType:g,chartId:f,showLegend:p,userMargin:y,marginDefaults:m,onClick:v,hoverHighlight:b,loading:x,emptyContent:k,width:w,height:A}=t,O="string"==typeof t.colorBy?t.colorBy:void 0,{activeSelectionHook:S,hoverSelectionHook:j,customHoverBehavior:M,customClickBehavior:C,crosshairSourceId:E}=dn({selection:l,linkedHover:c,fallbackFields:u,unwrapData:d,onObservation:h,chartType:g,chartId:f,onClick:v,hoverHighlight:b,colorByField:O}),_=hn(c,E),B=un(n,r,i),P=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]),L=fn(s,r,P),N=e.useMemo(()=>j||(L.legendSelectionHook?L.legendSelectionHook:S),[j,L.legendSelectionHook,S]),{legend:I,margin:H,legendPosition:F}=gn({data:n,colorBy:r,colorScale:B,showLegend:p,legendPosition:a,userMargin:y,defaults:m}),T=e.useMemo(()=>{const e={};return I&&(e.legend=I,e.legendPosition=F),s&&"none"!==s&&(e.legendHoverBehavior=L.onLegendHover,e.legendClickBehavior=L.onLegendClick,e.legendHighlightedCategory=L.highlightedCategory,e.legendIsolatedCategories=L.isolatedCategories),e},[I,F,s,L.onLegendHover,L.onLegendClick,L.highlightedCategory,L.isolatedCategories]),z=no(x,w,A),$=z?null:to(o,w,A,k);return{colorScale:B,allCategories:P,legendState:L,effectiveSelectionHook:N,activeSelectionHook:S,customHoverBehavior:M,customClickBehavior:C,legend:I,margin:H,legendPosition:F,earlyReturn:z||$||null,legendBehaviorProps:T,crosshairProps:_}}ho.displayName="StackedAreaChart";const fo=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)},remove:e=>{var t,n;return null!==(n=null===(t=o.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=o.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},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=yn(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:d="y",colorBy:g,colorScheme:f,sizeBy:p,sizeRange:y=[3,15],pointRadius:m=5,pointOpacity:v=.8,tooltip:b,marginalGraphics:x,pointIdAccessor:k,annotations:w,frameProps:A={},selection:O,linkedHover:S,linkedBrush:j,onObservation:M,onClick:C,hoverHighlight:_,chartId:P,loading:L,emptyContent:N,legendInteraction:I,legendPosition:H,color:F}=t,T=r.width,z=r.height,$=r.enableHover,R=r.showGrid,D=r.title,W=r.description,G=r.summary,Y=r.accessibleTable,q=r.xLabel,X=r.yLabel,V=i||[],U=go({data:V,rawData:i,colorBy:g,colorScheme:f,legendInteraction:I,legendPosition:H,selection:O,linkedHover:S,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!1,onObservation:M,onClick:C,hoverHighlight:_,chartType:"Scatterplot",chartId:P,showLegend:r.showLegend,userMargin:s,marginDefaults:r.marginDefaults,loading:L,emptyContent:N,width:T,height:z}),Q=rn(j),K=Jt({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 d?d:void 0)}),J=Q?"xyBrush"===K.brushInteraction.brush?"xy":"xBrush"===K.brushInteraction.brush?"x":"y":void 0,Z=h.useRef(K.brushInteraction);Z.current=K.brushInteraction;const ee=e.useCallback(e=>{const t=Z.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(U.earlyReturn)return U.earlyReturn;oo("Scatterplot",V,"xAccessor",u),oo("Scatterplot",V,"yAccessor",d);const te=e.useMemo(()=>{if(!p||0===V.length)return;const e=V.map(e=>"function"==typeof p?p(e):e[p]);return[Math.min(...e),Math.max(...e)]},[V,p]),ne=e.useMemo(()=>e=>{const t={fillOpacity:v};return g?U.colorScale&&(t.fill=E(e,g,U.colorScale)):t.fill=F||an,t.r=p?B(e,p,y,te):m,t},[g,U.colorScale,p,y,te,m,v,F]),oe=e.useMemo(()=>sn(ne,U.effectiveSelectionHook,O),[ne,U.effectiveSelectionHook,O]),re=e.useMemo(()=>jn([{label:q||An(u),accessor:u,role:"x"},{label:X||An(d),accessor:d,role:"y"},...g?[{label:An(g),accessor:g,role:"color"}]:[],...p?[{label:An(p),accessor:p,role:"size"}]:[]]),[u,d,q,X,g,p]),ie=Ln({componentName:"Scatterplot",data:i,accessors:{xAccessor:u,yAccessor:d}});if(ie)return h.createElement(Mn,{componentName:"Scatterplot",message:ie,width:T,height:z});const se=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(Object.assign({chartType:"scatter"},null!=i&&{data:V}),{xAccessor:u,yAccessor:d,colorAccessor:g||void 0,sizeAccessor:p||void 0,sizeRange:y,pointStyle:oe,colorScheme:f,size:[T,z],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:U.margin,showAxes:r.showAxes,xLabel:q,yLabel:X,xFormat:l,yFormat:c,enableHover:$,showGrid:R}),U.legendBehaviorProps),D&&{title:D}),W&&{description:W}),G&&{summary:G}),void 0!==Y&&{accessibleTable:Y}),a&&{className:a}),{tooltipContent:!1===b?()=>null:wn(b)||re}),(S||M||C||_)&&{customHoverBehavior:U.customHoverBehavior}),(M||C||S)&&{customClickBehavior:U.customClickBehavior}),x&&{marginalGraphics:x}),k&&{pointIdAccessor:k}),w&&w.length>0&&{annotations:w}),Q&&{brush:{dimension:J},onBrush:ee}),U.crosshairProps),A);return h.createElement(Jn,{componentName:"Scatterplot",width:T,height:z},h.createElement(Rt,Object.assign({ref:o},se)))});function po(e,t){return i.interpolateViridis(1===t?.5:e/(t-1))}fo.displayName="Scatterplot";const yo=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)},remove:e=>{var t,n;return null!==(n=null===(t=o.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=o.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},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=yn(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:d,orderLabel:g,pointRadius:f=4,tooltip:p,pointIdAccessor:y,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:k,onClick:w,hoverHighlight:A,chartId:O,loading:S,emptyContent:j,legendInteraction:M}=t,C=r.width,E=r.height,_=r.enableHover,B=r.showGrid,P=r.title,L=r.description,N=r.summary,I=r.accessibleTable,H=r.xLabel,F=r.yLabel,T=i||[],{safeData:z,orderMap:$}=e.useMemo(()=>{const e="function"==typeof c?c:e=>e[c],t="function"==typeof u?u:e=>e[u];let n=T;if(d&&T.length>0){const e="function"==typeof d?d:e=>e[d];n=[...T].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}},[T,d,c,u]);oo("ConnectedScatterplot",z,"xAccessor",c),oo("ConnectedScatterplot",z,"yAccessor",u);const{activeSelectionHook:R,hoverSelectionHook:D,customHoverBehavior:W,customClickBehavior:G,crosshairSourceId:Y}=dn({selection:b,linkedHover:x,fallbackFields:[],onObservation:k,onClick:w,chartType:"ConnectedScatterplot",chartId:O,hoverHighlight:A,colorByField:void 0}),q=hn(x,Y),X=fn(M,void 0,[]),V=e.useMemo(()=>D||(X.legendSelectionHook?X.legendSelectionHook:R),[D,X.legendSelectionHook,R]),U=e.useMemo(()=>(e,t)=>{var n,o;const r=t.filter(e=>"point"===e.type);if(2>r.length)return;const i=null==V?void 0:V.isActive,s=null==V?void 0:V.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],d=po(t,l),h=!i||!s||s(null!==(n=c.datum)&&void 0!==n?n:c)||s(null!==(o=u.datum)&&void 0!==o?o:u),g=i?h?1:.2:1;a&&(e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle="white",e.lineWidth=f+2,e.globalAlpha=.5*g,e.stroke()),e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle=d,e.lineWidth=f,e.globalAlpha=g,e.stroke()}e.globalAlpha=1},[f,V]),Q=e.useMemo(()=>[U],[U]),K=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=po(e,s),u="number"==typeof(null===(o=t.style)||void 0===o?void 0:o.opacity)?t.style.opacity:1,d="number"==typeof(null===(r=n.style)||void 0===r?void 0:r.opacity)?n.style.opacity:1,g=Math.min(u,d);a&&l.push(h.createElement("line",{key:"halo-"+e,x1:t.x,y1:t.y,x2:n.x,y2:n.y,stroke:"white",strokeWidth:f+2,strokeLinecap:"round",opacity:.5*g})),l.push(h.createElement("line",{key:"seg-"+e,x1:t.x,y1:t.y,x2:n.x,y2:n.y,stroke:c,strokeWidth:f,strokeLinecap:"round",opacity:g}))}return h.createElement(h.Fragment,null,l)},[f]),J=e.useMemo(()=>[K],[K]),Z=e.useMemo(()=>e=>{var t,n;const o=$.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?po(r,i):"#6366f1",stroke:"white",strokeWidth:1,r:f,fillOpacity:1}},[f,$]),ee=e.useMemo(()=>sn(Z,V,b),[Z,V,b]),te=Object.assign({top:50,right:40,bottom:60,left:70},t.margin),ne=g||("string"==typeof d?d:"Order"),oe=e.useMemo(()=>jn([{label:H||An(c),accessor:c,role:"x"},{label:F||An(u),accessor:u,role:"y"},...d?[{label:ne,accessor:d,role:"group"}]:[]]),[c,u,H,F,d,ne]),re=Ln({componentName:"ConnectedScatterplot",data:i,accessors:{xAccessor:c,yAccessor:u}}),ie=no(S,C,E),se=ie?null:to(i,C,E,j),ae=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=i&&{data:z}),{xAccessor:c,yAccessor:u,pointStyle:ee,size:[C,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:te,showAxes:r.showAxes,xLabel:H,yLabel:F,xFormat:a,yFormat:l,enableHover:_,showGrid:B}),P&&{title:P}),L&&{description:L}),N&&{summary:N}),void 0!==I&&{accessibleTable:I}),s&&{className:s}),{tooltipContent:!1===p?()=>null:wn(p)||oe}),(x||k||w||A)&&{customHoverBehavior:W}),(k||w||x)&&{customClickBehavior:G}),y&&{pointIdAccessor:y}),{canvasPreRenderers:Q,svgPreRenderers:J}),m&&m.length>0&&{annotations:m}),q),v);return ie||se||(re?h.createElement(Mn,{componentName:"ConnectedScatterplot",message:re,width:C,height:E}):h.createElement(Jn,{componentName:"ConnectedScatterplot",width:C,height:E},h.createElement(Rt,Object.assign({ref:o},ae))))});yo.displayName="ConnectedScatterplot";const mo=e.forwardRef(function(t,n){const o=e.useRef(null),r=yn(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:d="y",sizeBy:g,sizeRange:f=[5,40],colorBy:p,colorScheme:y,bubbleOpacity:m=.6,bubbleStrokeWidth:v=1,bubbleStrokeColor:b="white",tooltip:x,marginalGraphics:k,pointIdAccessor:w,annotations:A,frameProps:O={},selection:S,linkedHover:j,linkedBrush:M,onObservation:C,onClick:_,hoverHighlight:P,chartId:L,loading:N,emptyContent:I,legendInteraction:H,legendPosition:F,color:T}=t,z=r.width,$=r.height,R=r.enableHover,D=r.showGrid,W=r.showLegend,G=r.title,Y=r.description,q=r.summary,X=r.accessibleTable,V=r.xLabel,U=r.yLabel,Q=no(N,z,$),K=Q?null:to(i,z,$,I),J=i||[],Z=void 0===i,ee=e.useRef(null),[te,ne]=e.useState(0),oe=e.useCallback(e=>{if(!Z)return;let t=!1;for(const n of e){const e="function"==typeof g?g(n):n[g];null!=e&&isFinite(e)&&(ee.current?(ee.current[0]>e&&(ee.current[0]=e,t=!0),e>ee.current[1]&&(ee.current[1]=e,t=!0)):(ee.current=[e,e],t=!0))}t&&ne(e=>e+1)},[Z,g]),re=uo({isPushMode:Z,colorBy:p,colorScheme:y,showLegend:W,legendPosition:F}),ie=e.useCallback(re.wrapPush(e=>{var t;oe([e]),null===(t=o.current)||void 0===t||t.push(e)}),[re.wrapPush,oe]),se=e.useCallback(re.wrapPushMany(e=>{var t;oe(e),null===(t=o.current)||void 0===t||t.pushMany(e)}),[re.wrapPushMany,oe]);e.useImperativeHandle(n,()=>({push:ie,pushMany:se,remove:e=>{var t,n;return null!==(n=null===(t=o.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=o.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;re.resetCategories(),ee.current=null,ne(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:[]}}),[ie,se,re.resetCategories]);const{activeSelectionHook:ae,hoverSelectionHook:le,customHoverBehavior:ce,customClickBehavior:ue,crosshairSourceId:de}=dn({selection:S,linkedHover:j,fallbackFields:p?["string"==typeof p?p:""]:[],onObservation:C,onClick:_,chartType:"BubbleChart",chartId:L,hoverHighlight:P,colorByField:"string"==typeof p?p:void 0}),he=hn(j,de),ge=rn(M);Jt({name:(null==ge?void 0:ge.name)||"__unused_brush__",xField:(null==ge?void 0:ge.xField)||("string"==typeof u?u:void 0),yField:(null==ge?void 0:ge.yField)||("string"==typeof d?d:void 0)});const fe=un(J,p,y),pe=e.useMemo(()=>{if(!p)return[];const e=new Set;for(const t of J){const n="function"==typeof p?p(t):t[p];null!=n&&e.add(n+"")}return Array.from(e)},[J,p]),ye=fn(H,p,pe),me=e.useMemo(()=>le||(ye.legendSelectionHook?ye.legendSelectionHook:ae),[le,ye.legendSelectionHook,ae]),ve=e.useMemo(()=>{if(Z)return ee.current||[0,1];const e=J.map(e=>"function"==typeof g?g(e):e[g]);return[Math.min(...e),Math.max(...e)]},[J,g,Z,te]),be=e.useMemo(()=>e=>{const t={fillOpacity:m,strokeWidth:v,stroke:b};return p?fe&&(t.fill=E(e,p,fe)):t.fill=T||an,t.r=B(e,g,f,ve),t},[p,fe,g,f,ve,m,v,b,T]),xe=e.useMemo(()=>sn(be,me,S),[be,me,S]),{legend:ke,margin:we,legendPosition:Ae}=gn({data:J,colorBy:p,colorScale:fe,showLegend:W,legendPosition:F,userMargin:s,defaults:r.marginDefaults}),Oe=re.streamingLegend||ke,Se=F||Ae,je=e.useMemo(()=>{if(re.streamingMarginAdjust){const e=Object.assign({},we);for(const[t,n]of Object.entries(re.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return we},[we,re.streamingMarginAdjust]),Me=e.useMemo(()=>jn([{label:V||An(u),accessor:u,role:"x"},{label:U||An(d),accessor:d,role:"y"},{label:An(g),accessor:g,role:"size"},...p?[{label:An(p),accessor:p,role:"color"}]:[]]),[u,d,V,U,g,p]),Ce=Ln({componentName:"BubbleChart",data:i,accessors:{xAccessor:u,yAccessor:d},requiredProps:{sizeBy:g}});if(Ce)return h.createElement(Mn,{componentName:"BubbleChart",message:Ce,width:z,height:$});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(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bubble"},null!=i&&{data:J}),{xAccessor:u,yAccessor:d,colorAccessor:p||void 0,sizeAccessor:g,sizeRange:f,pointStyle:xe,colorScheme:y,size:[z,$],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:je,showAxes:r.showAxes,xLabel:V,yLabel:U,xFormat:l,yFormat:c,enableHover:R,showGrid:D}),Oe&&{legend:Oe,legendPosition:Se}),H&&"none"!==H&&{legendHoverBehavior:ye.onLegendHover,legendClickBehavior:ye.onLegendClick,legendHighlightedCategory:ye.highlightedCategory,legendIsolatedCategories:ye.isolatedCategories}),G&&{title:G}),Y&&{description:Y}),q&&{summary:q}),void 0!==X&&{accessibleTable:X}),a&&{className:a}),{tooltipContent:!1===x?()=>null:wn(x)||Me}),(j||C||_||P)&&{customHoverBehavior:ce}),(C||_||j)&&{customClickBehavior:ue}),k&&{marginalGraphics:k}),w&&{pointIdAccessor:w}),A&&A.length>0&&{annotations:A}),he),O);return Q||K||h.createElement(Jn,{componentName:"BubbleChart",width:z,height:$},h.createElement(Rt,Object.assign({ref:o},Ee)))});mo.displayName="BubbleChart";const vo=e.forwardRef(function(t,n){const r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},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 s=yn(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:d="y",valueAccessor:g="value",xFormat:f,yFormat:p,colorScheme:y="blues",customColorScale:m,showValues:v=!1,valueFormat:b,cellBorderColor:x="#fff",cellBorderWidth:k=1,tooltip:w,annotations:A,frameProps:O={},selection:S,linkedHover:j,onObservation:M,onClick:C,hoverHighlight:E,chartId:_,loading:B,emptyContent:P,showLegend:L,legendPosition:N,legendInteraction:I}=t,H=s.width,F=s.height,T=s.enableHover,z=s.title,$=s.description,R=s.summary,D=s.accessibleTable,W=s.xLabel,G=s.yLabel,Y=no(B,H,F),q=Y?null:to(a,H,F,P),X=a||[],V=null!=L&&L,U=null!=N?N:"right",{margin:Q}=gn({data:X,colorBy:V?"value":void 0,colorScale:void 0,showLegend:V,legendPosition:U,userMargin:l,defaults:s.marginDefaults}),{activeSelectionHook:K,hoverSelectionHook:J,customHoverBehavior:Z,customClickBehavior:ee,crosshairSourceId:te}=dn({selection:S,linkedHover:j,fallbackFields:[],onObservation:M,onClick:C,chartType:"Heatmap",chartId:_,hoverHighlight:E,colorByField:void 0}),ne=hn(j,te),oe=fn(I,void 0,[]),re=e.useMemo(()=>J||(oe.legendSelectionHook?oe.legendSelectionHook:K),[J,oe.legendSelectionHook,K]),ie=e.useMemo(()=>"function"==typeof g?e=>g(e):e=>e[g],[g]),se=e.useMemo(()=>{const e=X.map(ie);return[Math.min(...e),Math.max(...e)]},[X,ie]),ae=e.useMemo(()=>"custom"===y&&m?m:o.scaleSequential({blues:i.interpolateBlues,reds:i.interpolateReds,greens:i.interpolateGreens,viridis:i.interpolateViridis}[y]||i.interpolateBlues).domain(se),[y,m,se]);e.useMemo(()=>{const e=cn(u),t=cn(d);return{xBinCount:new Set(X.map(e)).size,yBinCount:new Set(X.map(t)).size}},[X,u,d]),e.useMemo(()=>({coordinates:X}),[X]);const le=e.useMemo(()=>e=>{const t=ie(e);return{fill:ae(t),stroke:x,strokeWidth:k}},[ie,ae,x,k]);e.useMemo(()=>sn(le,re,S),[le,re,S]);const ce=e.useMemo(()=>jn([{label:W||An(u),accessor:u,role:"x"},{label:G||An(d),accessor:d,role:"y"},{label:An(g),accessor:g,role:"value"}]),[u,d,W,G,g]),ue=Ln({componentName:"Heatmap",data:a,accessors:{xAccessor:u,yAccessor:d,valueAccessor:g}}),de=e.useMemo(()=>{if(V)return{gradient:{colorFn:e=>ae(e),domain:se,label:"string"==typeof g?g:"value",format:b}}},[V,ae,se,g,b]),he=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:"heatmap"},null!=a&&{data:X}),{xAccessor:u,yAccessor:d,valueAccessor:g,colorScheme:"custom"!==y?y:void 0,showValues:v,heatmapValueFormat:b,size:[H,F],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Q,showAxes:s.showAxes,xLabel:W,yLabel:G,xFormat:f,yFormat:p,enableHover:T}),t.pointIdAccessor&&{pointIdAccessor:t.pointIdAccessor}),de&&{legend:de,legendPosition:U}),z&&{title:z}),$&&{description:$}),R&&{summary:R}),void 0!==D&&{accessibleTable:D}),c&&{className:c}),{tooltipContent:!1===w?()=>null:wn(w)||ce}),(j||M||C||E)&&{customHoverBehavior:Z}),(M||C||j)&&{customClickBehavior:ee}),A&&A.length>0&&{annotations:A}),ne),O);return Y||q||(ue?h.createElement(Mn,{componentName:"Heatmap",message:ue,width:H,height:F}):h.createElement(Jn,{componentName:"Heatmap",width:H,height:F},h.createElement(Rt,Object.assign({ref:r},he))))});vo.displayName="Heatmap";const bo="__splomIdx",xo={top:4,bottom:4,left:4,right:4};function ko({frameRef:o,cellSize:r,onBrush:i}){const s=e.useRef(null),a=r-xo.left-xo.right,l=r-xo.top-xo.bottom;return e.useEffect(()=>{if(!s.current)return;const e=t.select(s.current).select(".brush-g"),r=n.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]),h.createElement("svg",{ref:s,width:r,height:r,style:{position:"absolute",top:0,left:0}},h.createElement("g",{className:"brush-g",transform:`translate(${xo.left},${xo.top})`}))}function wo({data:t,xField:n,yField:o,cellSize:r,pointRadius:i,pointOpacity:s,colorBy:a,colorScale:l,brushSelectionName:c,hoverSelectionName:u,unselectedOpacity:d,mode:g,onPointHover:f}){const p=e.useRef(null),y=Qt({name:c,clientId:`splom-${n}-${o}`}),m=Jt({name:c,xField:n,yField:o}),v=Qt({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==f||f(null));const t=e.data,n=null==t?void 0:t[bo];void 0!==n&&(b({[bo]:[n]}),null==f||f(t,e.x+xo.left,e.y+xo.top))},[b,f]),w=e.useCallback(e=>{const t={opacity:s,r:i};return t.fill=a?E(e,a,l):an,"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):y.isActive&&!y.predicate(e)&&(t.opacity=d),t},[a,l,s,i,g,y.isActive,y.predicate,v.isActive,v.predicate,d]);return h.createElement("div",{style:{position:"relative",width:r,height:r}},h.createElement(Rt,{ref:p,chartType:"scatter",data:t,size:[r,r],xAccessor:n,yAccessor:o,pointStyle:w,margin:xo,showAxes:!1,enableHover:"hover"===g,customHoverBehavior:"hover"===g?k:void 0,tooltipContent:"hover"===g?()=>null:void 0}),"brush"===g&&h.createElement(ko,{frameRef:p,cellSize:r,xField:n,yField:o,onBrush:x}))}function Ao({data:t,field:n,label:o,cellSize:r,bins:i,colorBy:s,colorScale:a,brushSelectionName:l,hoverSelectionName:c,mode:u}){const d=Qt({name:l,clientId:"splom-diag-"+n}),g=Qt({name:c,clientId:`splom-diag-${n}-hover`}),f="hover"===u?g:d,p=f.isActive,y=f.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])),d=Array(i).fill(0),h=Array(i).fill(0),g=Array.from({length:i},()=>Array(c.length).fill(0)),f=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(d[r]++,p&&!y(e)||h[r]++,l){const t=u.get(e[l]+"");void 0!==t&&(g[r][t]++,p&&!y(e)||f[r][t]++)}}const m=Math.max(...d,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=f.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:d.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/m*(r-24),count:e})),selectedBars:h.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/m*(r-24),count:e})),categoryBars:v,selectedCategoryBars:b,max:m,categories:c}},[t,n,i,r,p,y,s]);return h.createElement("svg",{width:r,height:r,style:{overflow:"hidden"}},h.createElement("text",{x:r/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333"},o),m.categories.length>0?m.categoryBars.map((e,t)=>e.map((e,n)=>h.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):an,opacity:p?.3:.6}))):m.bars.map((e,t)=>h.createElement("rect",{key:"bg-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:an,opacity:p?.3:.6})),p&&(m.categories.length>0?m.selectedCategoryBars.map((e,t)=>e.map((e,n)=>h.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):an,opacity:.7}))):m.selectedBars.map((e,t)=>h.createElement("rect",{key:"sel-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:an,opacity:.7}))))}function Oo({label:e,cellSize:t}){return h.createElement("svg",{width:t,height:t},h.createElement("text",{x:t/2,y:t/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333"},e))}function So(t){const{data:n,fields:o,fieldLabels:r={},colorBy:i,colorScheme:s,cellSize:a=150,cellGap:l=4,pointRadius:c=2,pointOpacity:u=.5,diagonal:d="histogram",histogramBins:g=20,brushMode:f="crossfilter",hoverMode:p=!0,unselectedOpacity:y=.1,showGrid:m=!1,tooltip:v,showLegend:b,idAccessor:x,className:k,onObservation:w,chartId:A}=t,O="splom",S="splom-hover",j=p?"hover":f?"brush":"hover",M=Xt(e=>e.clearSelection),[C,E]=e.useState(null),_=e.useCallback(()=>{M(S),E(null)},[M,S]),B=e.useMemo(()=>(n||[]).map((e,t)=>void 0!==e[bo]?e:Object.assign(Object.assign({},e),{[bo]:t})),[n]),P=un(B,i,s),L=void 0!==b?b:!!i,N=e.useMemo(()=>{if(!L||!i)return null;const e="string"==typeof i?i:null;return e?[...new Set(B.map(t=>t[e]))].map(e=>({label:e+"",color:P?P(e+""):an})):null},[L,i,B,P]),I=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 h.createElement("div",{className:k,style:{position:"relative"}},N&&h.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},N.map(e=>h.createElement("div",{key:e.label,style:{display:"flex",alignItems:"center",gap:4}},h.createElement("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:e.color}}),h.createElement("span",{style:{fontSize:11}},e.label)))),h.createElement("div",{style:I,onMouseLeave:"hover"===j?_:void 0},o.map((e,t)=>h.createElement(h.Fragment,{key:"row-"+e},h.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e),o.map((n,o)=>t===o?"label"===d?h.createElement(Oo,{key:"diag-"+e,label:r[e]||e,cellSize:a}):h.createElement(Ao,{key:"diag-"+e,data:B,field:e,label:r[e]||e,cellSize:a,bins:g,colorBy:i,colorScale:P,brushSelectionName:O,hoverSelectionName:S,unselectedOpacity:y,mode:j}):h.createElement(wo,{key:`cell-${e}-${n}`,data:B,xField:n,yField:e,fieldLabels:r,cellSize:a,pointRadius:c,pointOpacity:u,colorBy:i,colorScale:P,brushSelectionName:O,hoverSelectionName:S,unselectedOpacity:y,showGrid:m,tooltip:v,mode:j,onPointHover:"hover"===j?(r,i,s)=>{r?(E({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})):(E(null),w&&w({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A}))}:void 0})))),h.createElement("div",null)," ",o.map(e=>h.createElement("div",{key:"col-label-"+e,style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e))),C&&"hover"===j&&(()=>{const e=C.datum,t=r[C.xField]||C.xField,n=r[C.yField]||C.yField,o=i?"function"==typeof i?i(e):e[i]:null,s=x?"function"==typeof x?x(e):e[x]:"Row "+e[bo];return h.createElement("div",{style:{position:"absolute",left:40+C.colIndex*(a+l)+C.px,top:C.rowIndex*(a+l)+C.py-8,transform:"translate(-50%, -100%)",color:"#333",background:"rgba(255,255,255,0.95)",border:"1px solid #ddd",borderRadius:3,padding:"4px 8px",fontSize:11,lineHeight:1.4,whiteSpace:"nowrap",pointerEvents:"none",zIndex:10}},h.createElement("div",{style:{fontWeight:"bold",marginBottom:2}},s+""),h.createElement("div",null,t,": ",null!=e[C.xField]?Number(e[C.xField]).toFixed(1):"–"),h.createElement("div",null,n,": ",null!=e[C.yField]?Number(e[C.yField]).toFixed(1):"–"),null!=o&&h.createElement("div",{style:{opacity:.8}},"string"==typeof i?i:"group",": ",o+""))})())}function jo(e){const{brushMode:t="crossfilter",hoverMode:n=!0}=e,o={};return!n&&t&&(o.splom={resolution:t}),n&&(o["splom-hover"]={resolution:"union"}),h.createElement(nn,{selections:o},h.createElement(So,Object.assign({},e)))}function Mo({width:o,height:r,margin:i,scales:s,brushDirection:a,extent:l,onBrush:c}){const u=e.useRef(null),d=e.useRef(null),g=e.useRef(!1),f=o+i.left+i.right,p=r+i.top+i.bottom;return e.useEffect(()=>{if(!u.current||!s)return;const e=t.select(u.current).select(".brush-group"),i="x"===a?n.brushX().extent([[0,0],[o,r]]):n.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),d.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null)}},[s,o,r,a,c]),e.useEffect(()=>{if(!d.current||!s||!u.current)return;const e=t.select(u.current).select(".brush-group"),n="x"===a?s.x:s.y;if(g.current=!0,l){const t=[n(l[0]),n(l[1])];e.call(d.current.move,t)}else e.call(d.current.move,null);g.current=!1},[l,s,a]),h.createElement("svg",{ref:u,width:f,height:p,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},h.createElement("g",{className:"brush-group",transform:`translate(${i.left},${i.top})`}))}function Co(t){var n,o;const{data:r,width:i=600,height:s=400,margin:a,className:l,title:c,description:u,summary:d,xLabel:g,yLabel:f,xFormat:p,yFormat:y,xAccessor:m="x",yAccessor:v="y",lineBy:b,lineDataAccessor:x="coordinates",colorBy:k,colorScheme:w,curve:A="linear",lineWidth:O=2,fillArea:S=!1,areaOpacity:j=.3,showPoints:M=!1,pointRadius:C=3,enableHover:_=!0,showGrid:B=!1,showLegend:P,legendPosition:L,tooltip:N,minimap:I={},renderBefore:H=!1,onBrush:F,brushExtent:T,frameProps:z={},loading:$,emptyContent:R}=t,D=no($,i,s),W=D?null:to(r,i,s,R),G=r||[],[Y,q]=e.useState(null),X=null!=T?T:Y,V=e.useCallback(e=>{T||q(e),null==F||F(e)},[T,F]),U=e.useRef(null),[Q,K]=e.useState(null);e.useEffect(()=>{const e=()=>{var t,n;const o=null===(n=null===(t=U.current)||void 0===t?void 0:t.getScales)||void 0===n?void 0:n.call(t);o?K(o):requestAnimationFrame(e)};requestAnimationFrame(e)},[r]);const J=void 0!==(null===(n=G[0])||void 0===n?void 0:n[x]),Z=e.useMemo(()=>{if(J)return G;if(b){const e=G.reduce((e,t)=>{const n="function"==typeof b?b(t):t[b];if(!e[n]){const t={[x]:[]};"string"==typeof b&&(t[b]=n),e[n]=t}return e[n][x].push(t),e},{});return Object.values(e)}return[{[x]:G}]},[G,b,x,J]),ee=e.useMemo(()=>J||b?Z.flatMap(e=>{const t=e[x]||[];return b&&"string"==typeof b?t.map(t=>Object.assign(Object.assign({},t),{[b]:e[b]})):t}):G,[Z,x,J,b,G]),te=un(G,k,w),ne=e.useMemo(()=>e=>{const t={strokeWidth:O};return t.stroke=k?E(e,k,te):an,S&&(t.fill=t.stroke,t.fillOpacity=j),t},[k,te,O,S,j]),oe=e.useMemo(()=>I.lineStyle?I.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=k?E(e,k,te):an,t},[k,te,I.lineStyle]),re=e.useMemo(()=>{if(M)return e=>{const t={r:C,fillOpacity:1};return t.fill=k?E(e.parentLine||e,k,te):an,t}},[M,C,k,te]),{legend:ie,margin:se,legendPosition:ae}=gn({data:Z,colorBy:k,colorScale:te,showLegend:P,legendPosition:L,userMargin:a}),le=I.height||60,ce=e.useMemo(()=>{var e,t,n,o,r,i,s,a;return{top:null!==(t=null===(e=I.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(o=null===(n=I.margin)||void 0===n?void 0:n.bottom)&&void 0!==o?o:20,left:null!==(i=null===(r=I.margin)||void 0===r?void 0:r.left)&&void 0!==i?i:se.left,right:null!==(a=null===(s=I.margin)||void 0===s?void 0:s.right)&&void 0!==a?a:se.right}},[I.margin,se]),ue=I.brushDirection||"x",de=Ln({componentName:"MinimapChart",data:r,accessors:{xAccessor:m,yAccessor:v}});if(de)return h.createElement(Mn,{componentName:"MinimapChart",message:de,width:i,height:s});const he=S?"area":"line",ge=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:he,data:ee,xAccessor:m,yAccessor:v,groupAccessor:b||void 0,curve:A,lineStyle:ne},M&&{pointStyle:re}),{size:[i,s],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:se,showAxes:!0,xLabel:g,yLabel:f,xFormat:p,yFormat:y,enableHover:_,showGrid:B}),ie&&{legend:ie,legendPosition:ae}),c&&{title:c}),u&&{description:u}),d&&{summary:d}),N&&{tooltipContent:wn(N)||void 0}),X&&{xExtent:X}),z),fe={chartType:he,data:ee,xAccessor:m,yAccessor:v,groupAccessor:b||void 0,curve:A,lineStyle:oe,size:[i,le+ce.top+ce.bottom],margin:ce,showAxes:null!==(o=I.showAxes)&&void 0!==o&&o,background:I.background,enableHover:!1},pe=h.createElement("div",{key:"minimap",style:{position:"relative",width:i,overflow:"hidden"}},h.createElement(Rt,Object.assign({ref:U},fe)),h.createElement(Mo,{width:i-ce.left-ce.right,height:le,margin:ce,scales:Q,brushDirection:ue,extent:X,onBrush:V})),ye=h.createElement("div",{key:"main",style:{overflow:"hidden"}},h.createElement(Rt,Object.assign({},ge)));return D||W||h.createElement(Jn,{componentName:"MinimapChart",width:i,height:s},h.createElement("div",{className:"minimap-chart"+(l?" "+l:"")},H?pe:ye,H?ye:pe))}jo.displayName="ScatterplotMatrix",Co.displayName="MinimapChart";const Eo=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)},remove:e=>{var t,n;return null!==(n=null===(t=o.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=o.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},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=yn(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:d="y",xCenter:g,yCenter:f,quadrants:p,centerlineStyle:y={},showQuadrantLabels:m=!0,quadrantLabelSize:v=12,colorBy:b,colorScheme:x,sizeBy:k,sizeRange:w=[3,15],pointRadius:A=5,pointOpacity:O=.8,tooltip:S,pointIdAccessor:j,annotations:M,frameProps:C={},selection:_,linkedHover:P,onObservation:L,onClick:N,hoverHighlight:I,chartId:H,loading:F,emptyContent:T,legendInteraction:z,legendPosition:$,color:R}=t,D=r.width,W=r.height,G=r.enableHover,Y=r.showGrid,q=r.showLegend,X=r.title,V=r.description,U=r.summary,Q=r.accessibleTable,K=r.xLabel,J=r.yLabel,Z=no(F,D,W),ee=Z?null:to(i,D,W,T),te=i||[];oo("QuadrantChart",te,"xAccessor",u),oo("QuadrantChart",te,"yAccessor",d);const{activeSelectionHook:ne,hoverSelectionHook:oe,customHoverBehavior:re,customClickBehavior:ie,crosshairSourceId:se}=dn({selection:_,linkedHover:P,fallbackFields:"string"==typeof b?[b]:[],onObservation:L,onClick:N,chartType:"QuadrantChart",chartId:H,hoverHighlight:I,colorByField:"string"==typeof b?b:void 0}),ae=hn(P,se),le=un(te,b,x),ce=e.useMemo(()=>{if(!b)return[];const e=new Set;for(const t of te){const n="function"==typeof b?b(t):t[b];null!=n&&e.add(n+"")}return Array.from(e)},[te,b]),ue=fn(z,b,ce),de=e.useMemo(()=>oe||(ue.legendSelectionHook?ue.legendSelectionHook:ne),[oe,ue.legendSelectionHook,ne]),he=e.useMemo(()=>{if(!te.length)return;const e="function"==typeof u?u:e=>+e[u],t="function"==typeof d?d:e=>+e[d];let n=1/0,o=-1/0,r=1/0,i=-1/0;for(const s of te){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!=f&&isFinite(f)&&(r>f&&(r=f),f>i&&(i=f)),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]}},[te,u,d,g,f]),ge=e.useMemo(()=>{if(!k||0===te.length)return;const e=te.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},[te,k]),fe=e.useMemo(()=>"function"==typeof u?u:e=>+e[u],[u]),pe=e.useMemo(()=>"function"==typeof d?d:e=>+e[d],[d]),ye=e.useMemo(()=>e=>{const t={fillOpacity:O};if(b)le&&(t.fill=E(e,b,le));else{const n=fe(e),o=pe(e),r=null!=g?n>=g:void 0,i=null!=f?o>=f:void 0;t.fill=void 0===i||void 0===r?R||an:i&&r?p.topRight.color:i&&!r?p.topLeft.color:!i&&r?p.bottomRight.color:p.bottomLeft.color}return t.r=k?B(e,k,w,ge):A,t},[b,le,k,w,ge,A,O,fe,pe,g,f,p,R]),me=e.useMemo(()=>sn(ye,de,_),[ye,de,_]),{legend:ve,margin:be,legendPosition:xe}=gn({data:te,colorBy:b,colorScale:le,showLegend:q,legendPosition:$,userMargin:s,defaults:r.marginDefaults}),ke=e.useMemo(()=>{if(!te.length)return;const e=new Set;"string"==typeof u&&e.add(u),"string"==typeof d&&e.add(d),"string"==typeof b&&e.add(b),"string"==typeof k&&e.add(k);const t=te[0];for(const n of Object.keys(t))if(!n.startsWith("_")&&!e.has(n)&&"string"==typeof t[n])return n},[te,u,d,b,k]),we=e.useMemo(()=>jn([...ke?[{label:ke,accessor:ke,role:"title"}]:[],{label:K||An(u),accessor:u,role:"x"},{label:J||An(d),accessor:d,role:"y"},...b?[{label:An(b),accessor:b,role:"color"}]:[],...k?[{label:An(k),accessor:k,role:"size"}]:[]]),[ke,u,d,K,J,b,k]),Ae=Ln({componentName:"QuadrantChart",data:i,accessors:{xAccessor:u,yAccessor:d}}),Oe=e.useMemo(()=>{var e;const t={stroke:y.stroke||"#999",strokeWidth:null!==(e=y.strokeWidth)&&void 0!==e?e:1,dashArray:y.strokeDasharray||[]};return[(e,n,o,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!=f?o.y(f):a/2;if(null!=g&&!isFinite(l))return;if(null!=f&&!isFinite(c))return;const u=Math.max(0,Math.min(s,l)),d=Math.max(0,Math.min(a,c)),h=[{config:p.topLeft,x:0,y:0,w:u,h:d},{config:p.topRight,x:u,y:0,w:s-u,h:d},{config:p.bottomLeft,x:0,y:d,w:u,h:a-d},{config:p.bottomRight,x:u,y:d,w:s-u,h:a-d}];for(const t of h)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,d),e.lineTo(s,d),e.stroke(),e.setLineDash([])}]},[g,f,p,y]),Se=e.useMemo(()=>m?[...Oe,(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!=f?n.y(f):i/2;(null==g||isFinite(s))&&(null==f||isFinite(a))&&(e.font=`600 ${v}px sans-serif`,e.globalAlpha=.5,e.fillStyle=p.topLeft.color,e.textAlign="left",e.textBaseline="top",e.fillText(p.topLeft.label,8,8),e.fillStyle=p.topRight.color,e.textAlign="right",e.textBaseline="top",e.fillText(p.topRight.label,r-8,8),e.fillStyle=p.bottomLeft.color,e.textAlign="left",e.textBaseline="bottom",e.fillText(p.bottomLeft.label,8,i-8),e.fillStyle=p.bottomRight.color,e.textAlign="right",e.textBaseline="bottom",e.fillText(p.bottomRight.label,r-8,i-8),e.globalAlpha=1)}]:Oe,[Oe,m,v,p,g,f]),je=e.useMemo(()=>{const e=C.canvasPreRenderers||[];return[...Se,...e]},[Se,C.canvasPreRenderers]),Me=e.useMemo(()=>{var e;const t={stroke:y.stroke||"#999",strokeWidth:null!==(e=y.strokeWidth)&&void 0!==e?e:1,dashArray:y.strokeDasharray?Array.isArray(y.strokeDasharray)?y.strokeDasharray.join(","):y.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!=f?n.y(f):i/2;if(null!=g&&!isFinite(s))return null;if(null!=f&&!isFinite(a))return null;const l=Math.max(0,Math.min(r,s)),c=Math.max(0,Math.min(i,a));return h.createElement(h.Fragment,null,[{config:p.topLeft,x:0,y:0,w:l,h:c},{config:p.topRight,x:l,y:0,w:r-l,h:c},{config:p.bottomLeft,x:0,y:c,w:l,h:i-c},{config:p.bottomRight,x:l,y:c,w:r-l,h:i-c}].map((e,t)=>{var n;return e.w>0&&e.h>0?h.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}),h.createElement("line",{x1:l,y1:0,x2:l,y2:i,stroke:t.stroke,strokeWidth:t.strokeWidth,strokeDasharray:t.dashArray}),h.createElement("line",{x1:0,y1:c,x2:r,y2:c,stroke:t.stroke,strokeWidth:t.strokeWidth,strokeDasharray:t.dashArray}),m&&h.createElement(h.Fragment,null,h.createElement("text",{x:8,y:8+v,fill:p.topLeft.color,fontWeight:600,fontSize:v,opacity:.5},p.topLeft.label),h.createElement("text",{x:r-8,y:8+v,fill:p.topRight.color,fontWeight:600,fontSize:v,opacity:.5,textAnchor:"end"},p.topRight.label),h.createElement("text",{x:8,y:i-8,fill:p.bottomLeft.color,fontWeight:600,fontSize:v,opacity:.5},p.bottomLeft.label),h.createElement("text",{x:r-8,y:i-8,fill:p.bottomRight.color,fontWeight:600,fontSize:v,opacity:.5,textAnchor:"end"},p.bottomRight.label)))}]},[g,f,p,y,m,v]),Ce=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(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=i&&{data:te}),{xAccessor:u,yAccessor:d,colorAccessor:b||void 0,sizeAccessor:k||void 0,sizeRange:w,pointStyle:me,colorScheme:x,size:[D,W],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:be,showAxes:r.showAxes,xLabel:K,yLabel:J,xFormat:l,yFormat:c,enableHover:G,showGrid:Y}),he&&{xExtent:he.xExtent,yExtent:he.yExtent}),ve&&{legend:ve,legendPosition:xe}),z&&"none"!==z&&{legendHoverBehavior:ue.onLegendHover,legendClickBehavior:ue.onLegendClick,legendHighlightedCategory:ue.highlightedCategory,legendIsolatedCategories:ue.isolatedCategories}),X&&{title:X}),V&&{description:V}),U&&{summary:U}),void 0!==Q&&{accessibleTable:Q}),a&&{className:a}),{tooltipContent:!1===S?()=>null:!0===S||void 0===S?we:wn(S)||we}),(P||L||N||I)&&{customHoverBehavior:re}),(L||N||P)&&{customClickBehavior:ie}),j&&{pointIdAccessor:j}),M&&M.length>0&&{annotations:M}),{canvasPreRenderers:je}),ae),C),je.length>0&&{canvasPreRenderers:je}),{svgPreRenderers:Me});return Z||ee||(Ae?h.createElement(Mn,{componentName:"QuadrantChart",message:Ae,width:D,height:W}):h.createElement(Jn,{componentName:"QuadrantChart",width:D,height:W},h.createElement(Rt,Object.assign({ref:o},Ce))))});Eo.displayName="QuadrantChart";const _o="__ma_unitized",Bo="__ma_series";function Po(e,t){const n=t[1]-t[0];return 0===n?.5:(e-t[0])/n}function Lo(e,t){return t[0]+e*(t[1]-t[0])}const No=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),{[_o]:Po(a,r),[Bo]: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),{[_o]:Po(a,i),[Bo]:r.label||"Series "+(e+1)}))}i.current.pushMany(n)},remove:e=>{var t,n;return null!==(n=null===(t=i.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=i.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},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=yn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,accessibleTable:t.accessibleTable},{width:800,height:400}),{data:l,margin:c,className:u,xFormat:d,xAccessor:g="x",series:f,colorScheme:p,curve:y="monotoneX",lineWidth:m=2,tooltip:v,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:A,onClick:O,hoverHighlight:M,chartId:C,loading:E,emptyContent:_,legendInteraction:B,legendPosition:P}=t,L=a.width,N=a.height,I=a.enableHover,H=a.showGrid,F=null===(o=a.showLegend)||void 0===o||o,T=a.title,z=a.description,$=a.summary,R=a.accessibleTable,D=a.xLabel,W=2===f.length;"undefined"==typeof process||"production"===(null===(r=process.env)||void 0===r?void 0:r.NODE_ENV)||W||console.warn(`[MultiAxisLineChart] Expected exactly 2 series for dual-axis mode, got ${f.length}. Rendering as a standard multi-line chart.`);const G=no(E,L,N),Y=G?null:to(l,L,N,_),q=l||[],X=ln(),V=e.useMemo(()=>{let e;if(Array.isArray(p))e=p;else if(X&&X.length>0)e=X;else{const t=S[p];e=Array.isArray(t)?t:j}return f.map((t,n)=>t.color||e[n%e.length])},[f,p,X]),U=e.useMemo(()=>f.map((e,t)=>e.label||"Series "+(t+1)),[f]),{unitizedData:Q,extents:K}=e.useMemo(()=>{if(0===q.length){const e=f.map(e=>e.extent||null).filter(Boolean);return e.length===f.length&&(s.current=e),{unitizedData:[],extents:e.length===f.length?e:[]}}const e=f.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]}(q,e.yAccessor));if(s.current=e,!W){const t=[];for(const e of q)for(let n=0;f.length>n;n++){const o=f[n],r=("function"==typeof o.yAccessor?o.yAccessor:e=>e[o.yAccessor])(e);null!=r&&t.push(Object.assign(Object.assign({},e),{[_o]:r,[Bo]:U[n]}))}return{unitizedData:t,extents:e}}const t=[];for(const n of q)for(let o=0;2>o;o++){const r=f[o],i=("function"==typeof r.yAccessor?r.yAccessor:e=>e[r.yAccessor])(n);null!=i&&t.push(Object.assign(Object.assign({},n),{[_o]:Po(i,e[o]),[Bo]:U[o]}))}return{unitizedData:t,extents:e}},[q,f,W,U]),J=e.useMemo(()=>{if(W&&K.length>=2)return[{orient:"left",label:U[0],tickFormat:f[0].format||(e=>{const t=Lo(e,K[0]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"right",label:U[1],tickFormat:f[1].format||(e=>{const t=Lo(e,K[1]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"bottom"}]},[W,K,f,U]),Z=go({data:e.useMemo(()=>Q.length>0?Q:U.map(e=>({[Bo]:e})),[Q,U]),rawData:l,colorBy:Bo,colorScheme:V,legendInteraction:B,legendPosition:P,selection:k,linkedHover:w,fallbackFields:[Bo],unwrapData:!1,onObservation:A,onClick:O,hoverHighlight:M,chartType:"MultiAxisLineChart",chartId:C,showLegend:F,userMargin:c,marginDefaults:W?Object.assign(Object.assign({},a.marginDefaults),{left:70,right:70}):a.marginDefaults,loading:E,emptyContent:_,width:L,height:N});if(Z.earlyReturn)return Z.earlyReturn;const ee=e.useMemo(()=>{const e=new Map;return U.forEach((t,n)=>e.set(t,V[n])),t=>({stroke:e.get(t[Bo])||V[0],strokeWidth:m,fill:"none"})},[U,V,m]),te=e.useMemo(()=>sn(ee,Z.effectiveSelectionHook,k),[ee,Z.effectiveSelectionHook,k]),ne=e.useMemo(()=>{if(!1===v)return()=>null;return wn(v)||(e=>{var t;const n=e.data||e,o=n[Bo],r=U.indexOf(o),i=n[_o],s=W&&r>=0&&K[r]?Lo(i,K[r]):i,a=r>=0&&(null===(t=f[r])||void 0===t?void 0:t.format)?f[r].format:e=>Number.isInteger(e)?e+"":e.toFixed(2),l="function"==typeof g?g(n):n[g];return h.createElement("div",{style:{padding:"6px 10px",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-tooltip-font-size, 13px)"}},h.createElement("div",{style:{fontWeight:600,marginBottom:4,color:V[r]||"inherit"}},o),h.createElement("div",null,`${"string"==typeof g?g:"x"}: ${l}`),h.createElement("div",null,`${o}: ${a(s)}`))})},[v,U,V,K,W,f,g]),oe=Ln({componentName:"MultiAxisLineChart",data:l,accessors:{xAccessor:g}}),re=W?[0,1]:void 0,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(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:_o,groupAccessor:Bo,lineStyle:te,colorScheme:V,size:[L,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Z.margin,showAxes:a.showAxes}),J&&{axes:J}),{xLabel:D}),W?{}:{yLabel:U[0]}),{xFormat:d}),W&&re&&{yExtent:re}),{enableHover:I}),t.pointIdAccessor&&{pointIdAccessor:t.pointIdAccessor}),{showGrid:H,curve:y}),Z.legendBehaviorProps),T&&{title:T}),z&&{description:z}),$&&{summary:$}),void 0!==R&&{accessibleTable:R}),u&&{className:u}),{tooltipContent:ne}),b&&{annotations:b}),(w||A||O||M)&&{customHoverBehavior:Z.customHoverBehavior}),(A||O||w)&&{customClickBehavior:Z.customClickBehavior}),Z.crosshairProps),x);return G||Y||(oe?h.createElement(Mn,{componentName:"MultiAxisLineChart",message:oe,width:L,height:N}):h.createElement(Jn,{componentName:"MultiAxisLineChart",width:L,height:N},h.createElement(Rt,Object.assign({ref:i},ie))))});function Io(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 Ho(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")}`}No.displayName="MultiAxisLineChart";const Fo="__forecastSegment";function To(e,t){return"function"==typeof t?t(e):!!e[t]}const zo=Object.freeze({__proto__:null,SEGMENT_FIELD:Fo,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:d,upperBounds:h,lowerBounds:g,color:f="#6366f1",bandOpacity:p=.15,anomalyColor:y="#ef4444",anomalyRadius:m=6,label:v}=o,b=e.map(e=>{let t="observed";return u&&To(e,u)?t="forecast":c&&To(e,c)&&(t="training"),Object.assign(Object.assign({},e),{[Fo]:t})}),x=o._groupBy,k=[];if(x){const e=new Map;for(const t of b){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][Fo]!==n[e+1][Fo]&&(t.push(Object.assign(Object.assign({},n[e+1]),{[Fo]:n[e][Fo]})),t.push(Object.assign(Object.assign({},n[e]),{[Fo]:n[e+1][Fo]})));k.push(...b,...t)}else for(let e=0;b.length>e;e++)k.push(b[e]),b.length-1>e&&b[e][Fo]!==b[e+1][Fo]&&(k.push(Object.assign(Object.assign({},b[e+1]),{[Fo]:b[e][Fo]})),k.push(Object.assign(Object.assign({},b[e]),{[Fo]:b[e+1][Fo]})));if(o.trainUnderline){const e=[];for(const t of k)"training"===t[Fo]&&e.push(Object.assign(Object.assign({},t),{[Fo]:"training-base"}));k.unshift(...e)}const w=[];if(h&&g){const e="string"==typeof h?h:"__envUpper",t="string"==typeof g?g:"__envLower";if("function"==typeof h||"function"==typeof g)for(const n of k)"function"==typeof h&&(n[e]=h(n)),"function"==typeof g&&(n[t]=g(n));w.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:f,fillOpacity:p,label:v})}if(d){const e=o.anomalyStyle,t={type:"highlight",filter:e=>To(e,d)};e?(t.style=e,t.r=m):"function"==typeof y?(t.style=e=>{const t=y(e);return{stroke:t,strokeWidth:1.5,fill:t,fillOpacity:.7}},t.r=m):(t.color=y,t.r=m,t.style={stroke:y,strokeWidth:1.5,fill:y,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:d="#6366f1",bandOpacity:h=.15,label:g}=o;if(null==l)return{processedData:e,annotations:[]};const f=[],p=[];for(const n of e)n[t]>l?p.push(Object.assign(Object.assign({},n),{[Fo]:"observed"})):f.push(Object.assign(Object.assign({},n),{[Fo]:"training"}));const y=f.map(e=>[e[t],e[n]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),m=[],v=[];if(y.length>=3){const o=y.length;let r=0,i=0,s=0,a=0;for(const[e,t]of y)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,f=(i-s*r)/o,p=e=>f+s*e,b=y.map(([e,t])=>t-p(e)).reduce((e,t)=>e+t*t,0),x=Math.sqrt(b/Math.max(o-2,1)),k=y.reduce((e,t)=>e+t[0],0)/o,w=y.reduce((e,t)=>e+Math.pow(t[0]-k,2),0),A=.99>u?.95>u?.9>u?1:1.645:1.96:2.576,O=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),S=Math.max(...O),j=y.length>1?(y[o-1][0]-y[0][0])/(o-1):1;for(let e=1;c>=e;e++){const r=S+e*j,i=p(r),s=x*Math.sqrt(1+1/o+(w>0?Math.pow(r-k,2)/w:0))*A;v.push({[t]:r,[n]:i,[Fo]:"forecast",__forecastUpper:i+s,__forecastLower:i-s})}m.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:d,fillOpacity:h,label:g})}}m.push({type:"x-threshold",x:l,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),r&&m.push({type:"anomaly-band",threshold:null!==(i=r.threshold)&&void 0!==i?i:2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:null!==(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(...f),f.length>0&&p.length>0&&b.push(Object.assign(Object.assign({},f[f.length-1]),{[Fo]:"observed"})),b.push(...p),v.length>0){const e=p.length>0?p[p.length-1]:f[f.length-1];e&&b.push(Object.assign(Object.assign({},e),{[Fo]:"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",a=t.trainOpacity,l=t.forecastOpacity,c=t.trainStroke,u=t.trainLinecap,d=t.trainUnderline;return t=>{const n=e(t),o=t[Fo];if("training"===o){let e=n.stroke;return"darken"===c?e=Io(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"===d&&(e=Ho(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:Io,lightenColor:Ho});exports.AreaChart=co,exports.BubbleChart=mo,exports.ConnectedScatterplot=yo,exports.Heatmap=vo,exports.LineChart=lo,exports.MinimapChart=Co,exports.MultiAxisLineChart=No,exports.QuadrantChart=Eo,exports.Scatterplot=fo,exports.ScatterplotMatrix=jo,exports.StackedAreaChart=ho,exports.StreamXYFrame=Rt;
|
|
1
|
+
"use strict";const e=require("react"),t=require("d3-selection"),n=require("d3-brush"),o=require("d3-scale"),r=require("d3-quadtree"),i=require("d3-scale-chromatic"),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 d(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}return t.default=e,Object.freeze(t)}const h=d(e),g=u(c);function f(e,t){let n=0,o=t.length-1;for(;o>n;){const r=n+o+1>>1;t[r]>e?o=r-1:n=r}return t[n]}function p(e,t){let n=0,o=t.length-1;for(;o>n;){const r=n+o>>1;e>t[r]?n=r+1:o=r}return t[n]}function y({width:o,height:r,totalWidth:i,totalHeight:s,margin:a,dimension:l,scales:c,onBrush:u,binSize:d,snap:g,binBoundaries:y,snapDuring:m,streaming:v}){const b=e.useRef(null),x=e.useRef(null),k=e.useRef(u);k.current=u;const w=e.useRef(c);w.current=c;const A=e.useMemo(()=>y?[...y].sort((e,t)=>e-t):void 0,[y]),O=e.useRef(A);O.current=A;const S=e.useRef(!1),j=e.useRef(null);return e.useEffect(()=>{if(!b.current)return;const e=t.select(b.current).select(".brush-g"),i="x"===l?n.brushX():"y"===l?n.brushY():n.brush();return i.extent([[0,0],[o,r]]),i.on("brush end",t=>{if(S.current)return;const n=w.current;if(!n)return;if(!t.selection)return j.current=null,void k.current(null);let s,a;if("x"===l){const[e,o]=t.selection;s=[n.x.invert(e),n.x.invert(o)],a=[n.y.invert(r),n.y.invert(0)]}else if("y"===l){const[e,r]=t.selection;s=[n.x.invert(0),n.x.invert(o)],a=[n.y.invert(r),n.y.invert(e)]}else{const[[e,o],[r,i]]=t.selection;s=[n.x.invert(e),n.x.invert(r)],a=[n.y.invert(i),n.y.invert(o)]}if("bin"===g&&"y"!==l&&("end"===t.type||"brush"===t.type&&m)){const o=O.current;o&&o.length>0?s=function(e,t){return 0===t.length?e:[f(e[0],t),p(e[1],t)]}(s,o):d&&d>0&&(s=[Math.floor(s[0]/d)*d,Math.ceil(s[1]/d)*d]);const r=n.x(s[0]),a=n.x(s[1]);if(S.current=!0,"x"===l)e.call(i.move,[r,a]);else if("xy"===l){const n=t.selection;e.call(i.move,[[r,n[0][1]],[a,n[1][1]]])}S.current=!1}const c={x:s,y:a};j.current=c,k.current(c)}),e.call(i),x.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),x.current=null}},[o,r,l,g,d,m]),e.useEffect(()=>{if(!(v&&c&&x.current&&j.current))return;if(!b.current)return;if("y"===l)return;const e=j.current,n=c.x.domain()[0],o=t.select(b.current).select(".brush-g");if(n>=e.x[1])return S.current=!0,o.call(x.current.move,null),S.current=!1,j.current=null,void k.current(null);let r=e.x[0],i=!1;if(n>e.x[0]){if(r=n,"bin"===g){const e=O.current;e&&e.length>0?r=p(n,e):d&&d>0&&(r=Math.ceil(n/d)*d)}if(r>=e.x[1])return S.current=!0,o.call(x.current.move,null),S.current=!1,j.current=null,void k.current(null);i=!0}const s=c.x(r),a=c.x(e.x[1]);if(S.current=!0,"x"===l)o.call(x.current.move,[s,a]);else{const t=c.y(e.y[1]),n=c.y(e.y[0]);o.call(x.current.move,[[s,t],[a,n]])}if(S.current=!1,i){const t={x:[r,e.x[1]],y:e.y};j.current=t,k.current(t)}},[c,v,l,g,d]),h.createElement("svg",{ref:b,width:i,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},h.createElement("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`}))}class m{constructor(e,t){var n,o;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=null!==(n=null==t?void 0:t.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(o=null==t?void 0:t.chunkSize)&&void 0!==o?o:5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const o=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){this.pushBuffer.push(e),this.scheduleFlush()}pushMany(e){if(0!==e.length){for(let t=0;e.length>t;t++)this.pushBuffer.push(e[t]);this.scheduleFlush()}}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}class v{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}update(e,t){const n=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++){const i=(o+r)%this._capacity,s=this.buffer[i];if(e(s)){let e;e="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:Object.assign({},s),n.push(e),this.buffer[i]=t(s)}}return n}remove(e){const t=[],n=[];if(this.forEach(o=>{e(o)?n.push(o):t.push(o)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class b{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function x(e,t,n,o,r){const i=new Map;for(const 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 k(e,t){return e===t||typeof e==typeof t&&"function"==typeof e&&"function"==typeof t&&""+e==""+t}function w(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function A(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 S={category10:i.schemeCategory10,tableau10:i.schemeTableau10,set3:i.schemeSet3,blues:i.interpolateBlues,reds:i.interpolateReds,greens:i.interpolateGreens,oranges:i.interpolateOranges,purples:i.interpolatePurples,viridis:i.interpolateViridis,plasma:i.interpolatePlasma},j=i.schemeCategory10,M=["#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 E(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=null==e?void 0:e[t];return n?n(o):j[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+""))%j.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=S[n]||S.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:j;return o.scaleOrdinal().domain(r).range(e).unknown("#999")}}function P(e,t,n=[3,20],o){let r;if(r="function"==typeof t?t(e):null==e?void 0: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){var o,r,i;if(1>=n)return 1;const s=null!==(o=e.minOpacity)&&void 0!==o?o:.1,a=n-1-t;switch(e.type){case"linear":return s+(1-a/(n-1))*(1-s);case"exponential":{const t=null!==(r=e.halfLife)&&void 0!==r?r:n/2;return s+Math.pow(.5,a/t)*(1-s)}case"step":return(null!==(i=e.stepThreshold)&&void 0!==i?i:.5*n)>a?1:s;default:return 1}}function L(e,t,n){var o;const r=null!==(o=e.duration)&&void 0!==o?o:500,i=n-t;return r>i?1-i/r:0}function N(e,t,n){return e+(t-e)*n}function I(e,t,n){var o,r,i,s;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===e.runtimeMode&&t.datum){const n=e.getX(t.datum),o=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${n}:${o}`;if(null!=n&&null!=o)return`p:${n}:${o}`}return"p:"+n;case"rect":return`r:${t.group||""}:${null!==(s=null!==(r=null===(o=t.datum)||void 0===o?void 0:o.binStart)&&void 0!==r?r:null===(i=t.datum)||void 0===i?void 0:i.category)&&void 0!==s?s:n}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+n:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function T(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 H(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 F(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 z(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 R(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 $(e,t,n){if(!e.getBounds||!e.scales)return null;const o=[],r=[];for(const n of t){const t=e.getX(n),i=e.getY(n);if(null==t||null==i||Number.isNaN(t)||Number.isNaN(i))continue;const s=e.getBounds(n),a=e.scales.x(t);if(s&&0!==s)o.push([a,e.scales.y(i+s)]),r.push([a,e.scales.y(i-s)]);else{const t=e.scales.y(i);o.push([a,t]),r.push([a,t])}}return 2>o.length?null:{type:"area",topPath:o,bottomPath:r,style:e.resolveBoundsStyle(n,t[0]),datum:t,group:n,interactive:!1}}function D(e,t,n,o){var r;if(!e.config.pointStyle)return;const i=null!=o?o:e.getY;for(const o of t){const t=e.resolveGroupColor(o.key);for(const s of o.data){let o=e.config.pointStyle(s);!o.fill&&t&&(o=Object.assign(Object.assign({},o),{fill:t}));const a=null!==(r=o.r)&&void 0!==r?r:3,l=e.getPointId?e.getPointId(s)+"":void 0,c=F(s,e.scales,e.getX,i,a,o,l);c&&n.push(c)}}}const W={blues:i.interpolateBlues,reds:i.interpolateReds,greens:i.interpolateGreens,viridis:i.interpolateViridis},G=new Map;class Y{constructor(e){if(this.xExtent=new b,this.yExtent=new b,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._binBoundaries=[],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 v(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=w(e.timeAccessor||e.xAccessor,"time"),this.getY=w(e.valueAccessor||e.yAccessor,"value")):(this.getX=w(e.xAccessor,"x"),this.getY=w(e.yAccessor,"y")),this.getGroup=O(e.groupAccessor),this.getCategory=O(e.categoryAccessor),this.getSize=e.sizeAccessor?w(e.sizeAccessor,"size"):void 0,this.getColor=O(e.colorAccessor),this.getBounds=e.boundsAccessor?w(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?w(e.y0Accessor,"y0"):void 0,this.getPointId=O(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,n=null!=e.closeAccessor;this.getOpen=t?w(e.openAccessor,"open"):void 0,this.getHigh=w(e.highAccessor,"high"),this.getLow=w(e.lowAccessor,"low"),this.getClose=n?w(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!n}e.pulse&&(this.timestampBuffer=new v(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){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?w(this.config.timeAccessor||this.config.xAccessor,"time"):w(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,l;const{config:c,buffer:u}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(t=this.config.scalePadding)&&void 0!==t?t:0)&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);if(this.xExtent.dirty&&this.xExtent.recalculate(u,this.getX),this.yExtent.dirty)if("candlestick"===c.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of u)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(u,this.getY);const d=this.getBufferArray(),h=this.xExtent.extent,g=this.yExtent.extent;let f=c.xExtent?[null!==(n=c.xExtent[0])&&void 0!==n?n:h[0],null!==(r=c.xExtent[1])&&void 0!==r?r:h[1]]:h,p=c.yExtent?[null!==(i=c.yExtent[0])&&void 0!==i?i:g[0],null!==(s=c.yExtent[1])&&void 0!==s?s:g[1]]:g;const y=c.yExtent&&null!=c.yExtent[0]&&null!=c.yExtent[1];if("stackedarea"===c.chartType&&!y&&u.size>0)if(c.normalize)p=[0,1+c.extentPadding];else{const e=`${u.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===e)p=this._stackExtentCache.yDomain;else{const t=this.groupData(d),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*c.extentPadding:1)],this._stackExtentCache={key:e,yDomain:p}}}else if("bar"===c.chartType&&c.binSize&&!y&&u.size>0){const[,e]=function(e,t,n,o,r){const i=x(e,t,n,o,r);if(0===i.size)return[0,0];let s=0;for(const e of i.values())e.total>s&&(s=e.total);return[0,s]}(u,this.getX,this.getY,c.binSize,this.getCategory);p=[0,e+e*c.extentPadding]}else if("waterfall"===c.chartType&&!y&&u.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]}(u,this.getY),n=t-e,o=n>0?n*c.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 d){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*c.extentPadding:1,n=null===(a=c.yExtent)||void 0===a?void 0:a[0],o=null===(l=c.yExtent)||void 0===l?void 0:l[1];p=[null!=n?p[0]:p[0]-t,null!=o?p[1]:p[1]+t],"log"===c.yScaleType&&0>=p[0]&&g[0]>0&&(p[0]=null!=n?p[0]:g[0]/(1+c.extentPadding))}if(f[0]===1/0||f[1]===-1/0)if("time"===c.xScaleType){const e=Date.now();f=[e-864e5,e]}else f=[0,1];p[0]!==1/0&&p[1]!==-1/0||(p=[0,1]);const m="streaming"===c.runtimeMode,v=Math.max(0,Math.min(c.scalePadding||0,Math.min(e.width,e.height)/2-1));if(m)if("x"==("up"===(b=c.arrowOfTime)||"down"===b?"y":"x")){const t="right"===c.arrowOfTime?[v,e.width-v]:[e.width-v,v];this.scales={x:o.scaleLinear().domain(f).range(t),y:o.scaleLinear().domain(p).range([e.height-v,v])}}else{const t="down"===c.arrowOfTime?[v,e.height-v]:[e.height-v,v];this.scales={x:o.scaleLinear().domain(p).range([v,e.width-v]),y:o.scaleLinear().domain(f).range(t)}}else{const t=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return o.scaleLog().domain(e).range(n).clamp(!0)}return"time"===e?o.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(n):o.scaleLinear().domain(t).range(n)};this.scales={x:t(c.xScaleType,f,[v,e.width-v]),y:t(c.yScaleType,p,[e.height-v,v])}}var b;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(e,d),this.config.decay&&this.applyDecay(this.scene,d),this.config.pulse&&this.applyPulse(this.scene,d),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>Y.QUADTREE_THRESHOLD?r.quadtree().x(e=>e.x).y(e=>e.y).addAll(t):null}get quadtree(){return this._quadtree}remapScene(e){const t=e.width/this.lastLayout.width,n=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const o of e.path)o[0]*=t,o[1]*=n;break;case"area":for(const o of e.topPath)o[0]*=t,o[1]*=n;for(const o of e.bottomPath)o[0]*=t,o[1]*=n;break;case"point":e.x*=t,e.y*=n;break;case"rect":case"heatcell":e.x*=t,e.y*=n,e.w*=t,e.h*=n;break;case"candlestick":e.x*=t,e.openY*=n,e.closeY*=n,e.highY*=n,e.lowY*=n}const 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"time"===e?o.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(n):o.scaleLinear().domain(t).range(n)},c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),u=a[1]>a[0];this.scales={x:l(this.config.xScaleType,r,s[0]>s[1]?[e.width-c,c]:[c,e.width-c]),y:l(this.config.yScaleType,i,u?[c,e.height-c]:[e.height-c,c])},this.lastLayout={width:e.width,height:e.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(e,t){var n;const{config:o,scales:r}=this;if(!r||0===t.length)return[];const s={scales:r,config:o,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,getBounds:this.getBounds,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(e,t)=>this.resolveLineStyle(e,t),resolveAreaStyle:(e,t)=>this.resolveAreaStyle(e,t),resolveBoundsStyle:(e,t)=>this.resolveBoundsStyle(e,t),resolveColorMap:e=>this.resolveColorMap(e),resolveGroupColor:e=>this.resolveGroupColor(e),groupData:e=>this.groupData(e),barCategoryCache:this._barCategoryCache};switch(o.chartType){case"line":return function(e,t){var n;const o=e.groupData(t),r=[],i=null===(n=e.config.annotations)||void 0===n?void 0:n.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.getBounds)for(const t of o){const n=$(e,t.data,t.key);n&&r.push(n)}for(const t of o){const n=e.resolveLineStyle(t.key,t.data[0]),o=T(t.data,e.scales,e.getX,e.getY,n,t.key);i&&i.length>0&&(o.colorThresholds=i),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}return D(e,o,r),r}(s,t);case"area":return function(e,t){const n=e.groupData(t),o=[],r=e.scales.y.domain()[0],i=e.getY0?t=>{const n=e.getY0(t);return null==n?r:n}:void 0;for(const t of n){const n=e.resolveAreaStyle(t.key,t.data[0]),s=H(t.data,e.scales,e.getX,e.getY,r,n,t.key,i);e.config.gradientFill&&(s.fillGradient=e.config.gradientFill),e.config.curve&&"linear"!==e.config.curve&&(s.curve=e.config.curve),e.config.lineGradient&&(s.strokeGradient=e.config.lineGradient),o.push(s)}return D(e,n,o),o}(s,t);case"mixed":return function(e,t){const n=e.groupData(t),o=[],r=e.config.areaGroups||new Set,i=e.scales.y.domain()[0],s=e.getY0?t=>{const n=e.getY0(t);return null==n?i:n}:void 0;for(const t of n)if(r.has(t.key)){const n=e.resolveAreaStyle(t.key,t.data[0]),r=H(t.data,e.scales,e.getX,e.getY,i,n,t.key,s);e.config.gradientFill&&(r.fillGradient=e.config.gradientFill),e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),o.push(r)}else{const n=e.resolveLineStyle(t.key,t.data[0]),r=T(t.data,e.scales,e.getX,e.getY,n,t.key);e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),o.push(r)}return D(e,n,o),o}(s,t);case"stackedarea":return function(e,t){const n=e.groupData(t);n.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);const o=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,{nodes:r,stackedTops:i}=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 d;if(i){d=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;d.set(t,n||1)}}const h=[],g=new Map,f=new Map;for(const e of c)f.set(e,0);for(const n of e){const e=u.get(n.key),o=[],a=[],l=new Map;for(const n of c){let r=e.get(n)||0;const s=f.get(n);i&&(r/=d.get(n));const c=s+r,u=t.x(n);a.push([u,t.y(s)]),o.push([u,t.y(c)]),f.set(n,c),l.set(n,c)}g.set(n.key,l);const p={type:"area",topPath:o,bottomPath:a,style:r(n.key,n.data[0]),datum:n.data,group:n.key};s&&(p.curve=s),h.push(p)}return{nodes:h,stackedTops:g}}(n,e.scales,e.getX,e.getY,(t,n)=>e.resolveAreaStyle(t,n),e.config.normalize,o),s=r;if(e.config.pointStyle){const t=new WeakMap;for(const o of n){const n=i.get(o.key);if(n)for(const r of o.data){const o=e.getX(r),i=e.getY(r);null==o||Number.isNaN(o)||null==i||Number.isNaN(i)||!n.has(o)||t.set(r,n.get(o))}}const o=n=>{var o;return null!==(o=t.get(n))&&void 0!==o?o:e.getY(n)};D(e,n,s,o)}return s}(s,t);case"scatter":case"bubble":return function(e,t){const n=[],o="bubble"===e.config.chartType?10:5,r=e.config.sizeRange||[3,15];let i=null;if(e.getSize&&!e.config.pointStyle){const n=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(n.length>0){let e=1/0,t=-1/0;for(const o of n)e>o&&(e=o),o>t&&(t=o);i=n=>e===t?(r[0]+r[1])/2:r[0]+(n-e)/(t-e)*(r[1]-r[0])}}const s=e.getColor?e.resolveColorMap(t):null;for(const r of t){let t=e.config.pointStyle?e.config.pointStyle(r):{fill:"#4e79a7",opacity:.8},a=t.r||o;if(i&&e.getSize){const t=e.getSize(r);null==t||Number.isNaN(t)||(a=i(t))}if(s&&e.getColor&&!t.fill){const n=e.getColor(r);n&&s.has(n)&&(t=Object.assign(Object.assign({},t),{fill:s.get(n)}))}const l=e.getPointId?e.getPointId(r)+"":void 0,c=F(r,e.scales,e.getX,e.getY,a,t,l);c&&n.push(c)}return n}(s,t);case"heatmap":return function(e,t,n){if(e.config.heatmapAggregation)return function(e,t,n){var o,r,i;const s=Math.max(1,Math.floor(null!==(o=e.config.heatmapXBins)&&void 0!==o?o:20)),a=Math.max(1,Math.floor(null!==(r=e.config.heatmapYBins)&&void 0!==r?r:20)),l=null!==(i=e.config.heatmapAggregation)&&void 0!==i?i:"count",c=w(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[u,d]=e.scales.x.domain(),[h,g]=e.scales.y.domain(),f=(d-u||1)/s,p=(g-h||1)/a,y=s*a;if(y>1e6)return[];const m=new Int32Array(y),v=new Float64Array(y);for(let n=0;t.length>n;n++){const o=t[n],r=e.getX(o),i=e.getY(o);if(!isFinite(r)||!isFinite(i))continue;const l=Math.min(Math.floor((r-u)/f),s-1),d=Math.min(Math.floor((i-h)/p),a-1);if(0>l||0>d)continue;const g=d*s+l;m[g]++;const y=c(o);v[g]+=isFinite(y)?y:0}let b=1/0,x=-1/0;for(let e=0;y>e;e++){if(0===m[e])continue;let t;switch(l){case"sum":t=v[e];break;case"mean":t=v[e]/m[e];break;default:t=m[e]}b>t&&(b=t),t>x&&(x=t)}if(!isFinite(b))return[];const k=x-b||1,A=n.width/s,O=n.height/a,S=e.config.showValues,j=e.config.heatmapValueFormat,M=[];for(let e=0;a>e;e++){const t=e*s;for(let n=0;s>n;n++){const o=t+n;if(0===m[o])continue;let r;switch(l){case"sum":r=v[o];break;case"mean":r=v[o]/m[o];break;default:r=m[o]}const i=(r-b)/k;M.push(R(n*A,(a-1-e)*O,A,O,`rgb(${220-(180*i+.5)|0},${220-(100*i+.5)|0},${255-(50*i+.5)|0})`,{xi:n,yi:e,value:r,count:m[o],sum:v[o]},S?{value:r,showValues:!0,valueFormat:j}:void 0))}}return M}(e,t,n);if(0===t.length)return[];const o=w(e.config.valueAccessor,"value"),r=A(e.config.xAccessor,"x"),s=A(e.config.yAccessor,"y"),a=new Map,l=new Map,c=Array(t.length),u=Array(t.length);for(let e=0;t.length>e;e++){const n=t[e],o=r(n),i=s(n);c[e]=o,u[e]=i,a.has(o)||a.set(o,a.size),l.has(i)||l.set(i,l.size)}const d=a.size,h=l.size;if(0===d||0===h)return[];const g=Array.from(a.keys()),f=Array.from(l.keys()),p=g.every(e=>"number"==typeof e&&!isNaN(e)),y=f.every(e=>"number"==typeof e&&!isNaN(e));if(p){g.sort((e,t)=>e-t),a.clear();for(let e=0;g.length>e;e++)a.set(g[e],e)}if(y){f.sort((e,t)=>e-t),l.clear();for(let e=0;f.length>e;e++)l.set(f[e],e)}const m=new Float64Array(t.length),v=new Float64Array(t.length),b=Array(t.length),x=new Map;let k=0;for(let e=0;t.length>e;e++){const n=t[e],r=a.get(c[e]),i=l.get(u[e]);if(void 0===r||void 0===i)continue;const s=o(n),h=i*d+r,g=x.get(h);let f;void 0!==g?f=g:(f=k++,x.set(h,f)),m[f]=h,v[f]=s,b[f]=n}let O=1/0,S=-1/0;for(let e=0;k>e;e++){const t=v[e];isFinite(t)&&(O>t&&(O=t),t>S&&(S=t))}if(!isFinite(O)||!isFinite(S))return[];const j=function(e){const t=e in W?e:"blues";let n=G.get(t);if(n)return n;n=Array(256);const o=W[t]||i.interpolateBlues;for(let e=0;256>e;e++)n[e]=o(e/255);return G.set(t,n),n}("string"==typeof e.config.colorScheme?e.config.colorScheme:"blues"),M=255/(S-O||1),C=n.width/d,E=n.height/h,_=e.config.showValues,P=e.config.heatmapValueFormat,B=[];for(let e=0;k>e;e++){const t=v[e];if(!isFinite(t))continue;const n=m[e],o=n%d;B.push(R(o*C,(h-1-(n-o)/d)*E,C,E,j[Math.min((t-O)*M+.5|0,255)],b[e],_?{value:t,showValues:!0,valueFormat:P}:void 0))}return B}(s,t,e);case"bar":{const e=function(e,t){var n;if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const o=x(t,e.getX,e.getY,e.config.binSize,e.getCategory);if(0===o.size)return{nodes:[],binBoundaries:[]};let r=null;if(e.getCategory){const t=new Set;for(const e of o.values())for(const n of e.categories.keys())t.add(n);const n=e.config.barColors?Object.keys(e.config.barColors):[],i=new Set(n),s=Array.from(t).filter(e=>!i.has(e)).sort(),a=n.filter(e=>t.has(e)),l=a.join("\0")+""+s.join("\0");e.barCategoryCache&&e.barCategoryCache.key===l?r=e.barCategoryCache.order:(r=[...a,...s],e.barCategoryCache={key:l,order:r})}const i=[],s=e.scales,[a,l]=s.x.domain();for(const t of o.values()){const o=Math.max(t.start,a),c=Math.min(t.end,l);if(o>=c)continue;const u=s.x(o),d=s.x(c),h=Math.abs(d-u),g=h>2?1:0,f=Math.min(u,d)+g/2,p=Math.max(h-g,1);if(p>0)if(r&&t.categories.size>0){let o=0;for(const a of r){const r=t.categories.get(a)||0;if(0===r)continue;const l=s.y(o),c=s.y(o+r);i.push(z(f,Math.min(l,c),p,Math.abs(l-c),{fill:(null===(n=e.config.barColors)||void 0===n?void 0:n[a])||"#4e79a7"},{binStart:t.start,binEnd:t.end,total:t.total,category:a,categoryValue:r},a)),o+=r}}else{const e=s.y(0),n=s.y(t.total);i.push(z(f,Math.min(e,n),p,Math.abs(e-n),{fill:"#007bff"},{binStart:t.start,binEnd:t.end,total:t.total}))}}const c=new Set;for(const e of o.values())c.add(e.start),c.add(e.end);return{nodes:i,binBoundaries:Array.from(c).sort((e,t)=>e-t)}}(s,t);return this._barCategoryCache=null!==(n=s.barCategoryCache)&&void 0!==n?n:null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){var n,o,r,i;const s=[],a=e.config.swarmStyle||{},l=null!==(n=a.radius)&&void 0!==n?n:3,c=null!==(o=a.fill)&&void 0!==o?o:"#007bff",u=null!==(r=a.opacity)&&void 0!==r?r:.7,d=a.stroke,h=a.strokeWidth;for(const n of t){const t=e.getX(n),o=e.getY(n);if(null==o||Number.isNaN(o))continue;const r=e.scales.x(t),a=e.scales.y(o);let g=c;if(e.getCategory){const t=e.getCategory(n);g=(null===(i=e.config.barColors)||void 0===i?void 0:i[t])||g}const f={type:"point",x:r,y:a,r:l,style:{fill:g,opacity:u,stroke:d,strokeWidth:h},datum:n};e.getPointId&&(f.pointId=e.getPointId(n)+""),s.push(f)}return s}(s,t);case"waterfall":return function(e,t,n){var o,r,i;const s=[],a=e.scales,l=e.config.waterfallStyle,c=t.filter(t=>{const n=e.getY(t),o=e.getX(t);return null!=n&&!Number.isNaN(n)&&null!=o&&isFinite(o)});if(0===c.length)return s;const u=null!==(o=null==l?void 0:l.positiveColor)&&void 0!==o?o:"#28a745",d=null!==(r=null==l?void 0:l.negativeColor)&&void 0!==r?r:"#dc3545",h=null!==(i=null==l?void 0:l.gap)&&void 0!==i?i:1,g=null==l?void 0:l.stroke,f=null==l?void 0:l.strokeWidth;let p=0;for(let t=0;c.length>t;t++){const o=c[t],r=e.getX(o),i=e.getY(o),y=p+i;let m;m=c.length-1>t?e.getX(c[t+1])-r:t>0?r-e.getX(c[t-1]):0;const v=a.x(r),b=0!==m?a.x(r+m):v+n.width/10,x=Math.min(v,b)+h/2,k=Math.max(v,b)-h/2-x;if(0>=k){p=y;continue}const w=a.y(p),A=a.y(y);s.push(z(x,Math.min(w,A),k,Math.abs(w-A),{fill:0>i?d:u,stroke:g,strokeWidth:f},Object.assign(Object.assign({},o),{baseline:p,cumEnd:y,delta:i,_connectorStroke:null==l?void 0:l.connectorStroke,_connectorWidth:null==l?void 0:l.connectorWidth}))),p=y}return s}(s,t,e);case"candlestick":return function(e,t){var n,o;if(!e.getHigh||!e.getLow||!e.scales)return[];const r=null!==(n=e.config.candlestickRangeMode)&&void 0!==n&&n;if(!(r||e.getOpen&&e.getClose))return[];const i=[],s=e.config.candlestickStyle||{},a=s.rangeColor||"#6366f1",l=r?a:s.upColor||"#28a745",c=r?a:s.downColor||"#dc3545",u=r?a:s.wickColor||"#333",d=s.wickWidth||(r?2:1),h=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let g=r?0:null!==(o=s.bodyWidth)&&void 0!==o?o:0;if(!r&&null==s.bodyWidth&&h.length>1){let t=1/0;for(let n=1;h.length>n;n++){const o=Math.abs(e.scales.x(h[n])-e.scales.x(h[n-1]));o>0&&t>o&&(t=o)}g=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else r||null!=s.bodyWidth||(g=6);for(const n of t){const t=e.getX(n);if(null==t||Number.isNaN(t))continue;const o=e.getHigh(n),s=e.getLow(n);if(null==o||Number.isNaN(o)||null==s||Number.isNaN(s))continue;const a=r?o:e.getOpen(n),h=r?s:e.getClose(n);if(!r&&[a,h].some(e=>null==e||Number.isNaN(e)))continue;const f=h>=a,p={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(a),closeY:e.scales.y(h),highY:e.scales.y(o),lowY:e.scales.y(s),bodyWidth:g,upColor:l,downColor:c,wickColor:u,wickWidth:d,isUp:f,datum:n};r&&(p.isRange=!0),i.push(p)}return i}(s,t);default:return[]}}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){const n=this.config.decay;return n&&t>1?B(n,e,t):1}applyDecay(e,t){this.config.decay&&function(e,t,n){var o,r;const i=n.length;if(1>=i)return;const s=new Map;for(let e=0;n.length>e;e++)s.set(n[e],e);for(const n of t){if("line"===n.type){const t=Array.isArray(n.datum)?n.datum:[];if(2>t.length)continue;const o=Array(t.length);let r=!1;for(let n=0;t.length>n;n++){const a=s.get(t[n]);null!=a?(o[n]=B(e,a,i),1>o[n]&&(r=!0)):o[n]=1}r&&(n._decayOpacities=o);continue}if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[],o=n.topPath?n.topPath.length:t.length;if(2>o)continue;if(t.length===o){const r=Array(o);let a=!1;for(let n=0;t.length>n;n++){const o=s.get(t[n]);null!=o?(r[n]=B(e,o,i),1>r[n]&&(a=!0)):r[n]=1}a&&(n._decayOpacities=r)}else{let r=1;for(const n of t){const t=s.get(n);if(null!=t){const n=B(e,t,i);r>n&&(r=n)}}if(1>r){const e=Array(o);e.fill(r),n._decayOpacities=e}}continue}const t=s.get(n.datum);if(null==t)continue;const a=B(e,t,i);if("heatcell"===n.type)n.style={opacity:a};else if("candlestick"===n.type)n._decayOpacity=a;else{const e=null!==(r=null===(o=n.style)||void 0===o?void 0:o.opacity)&&void 0!==r?r:1;n.style=Object.assign(Object.assign({},n.style),{opacity:e*a})}}}(this.config.decay,e,t)}applyPulse(e,t){this.config.pulse&&this.timestampBuffer&&function(e,t,n,o){var r,i;const s="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(r=e.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",l=null!==(i=e.glowRadius)&&void 0!==i?i:4,c=new Map;for(let e=0;n.length>e;e++)c.set(n[e],e);for(const n of t){if("line"===n.type)continue;if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[n.datum];let r=0;for(const n of t){const t=c.get(n);if(null==t)continue;const i=o.get(t);if(null==i)continue;const a=L(e,i,s);a>r&&(r=a)}r>0&&(n._pulseIntensity=r,n._pulseColor=a);continue}const t=c.get(n.datum);if(null==t)continue;const r=o.get(t);if(null==r)continue;const i=L(e,r,s);i>0&&(n._pulseIntensity=i,n._pulseColor=a,n._pulseGlowRadius=l)}}(this.config.pulse,e,t,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(e,t){var n;if(!t||0===t.size)return!1;const o="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(n=e.duration)&&void 0!==n?n:500,i=t.peek();return null!=i&&r>o-i}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(e,t,n,o){var r,i,s;n.clear(),o.clear();for(let a=0;t.length>a;a++){const l=t[a],c=I(e,l,a);c&&("point"===l.type?n.set(c,{x:l.x,y:l.y,r:l.r,opacity:l.style.opacity}):"rect"===l.type?n.set(c,{x:l.x,y:l.y,w:l.w,h:l.h,opacity:l.style.opacity}):"heatcell"===l.type?n.set(c,{x:l.x,y:l.y,w:l.w,h:l.h,opacity:null===(r=l.style)||void 0===r?void 0:r.opacity}):"candlestick"===l.type?n.set(c,{x:l.x,y:l.openY}):"line"===l.type?o.set(c,{path:l.path.map(e=>[e[0],e[1]]),opacity:null===(i=l.style)||void 0===i?void 0:i.opacity}):"area"===l.type&&o.set(c,{topPath:l.topPath.map(e=>[e[0],e[1]]),bottomPath:l.bottomPath.map(e=>[e[0],e[1]]),opacity:null===(s=l.style)||void 0===s?void 0:s.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}startTransition(){if(!this.config.transition)return;const e=function(e,t,n,o,r){var i,s,a,l,c,u,d,h,g,f,p,y,m,v,b,x,k,w,A,O,S,j,M,C,E,_,P,B;if(0===o.size&&0===r.size)return n;const L=null!==(i=t.duration)&&void 0!==i?i:300;if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}let N=!1;const T=new Set,H=new Set;for(let t=0;n.scene.length>t;t++){const i=n.scene[t],A=I(e,i,t);if(!A)continue;if(i._transitionKey=A,"line"===i.type||"area"===i.type){const e=r.get(A);if(e){if(H.add(A),"line"===i.type&&e.path&&e.path.length===i.path.length){i._targetPath=i.path.map(e=>[e[0],e[1]]),i._prevPath=e.path;for(let t=0;i.path.length>t;t++)i.path[t]=[e.path[t][0],e.path[t][1]];N=!0}else if("area"===i.type&&e.topPath&&e.bottomPath&&e.topPath.length===i.topPath.length&&e.bottomPath.length===i.bottomPath.length){i._targetTopPath=i.topPath.map(e=>[e[0],e[1]]),i._targetBottomPath=i.bottomPath.map(e=>[e[0],e[1]]),i._prevTopPath=e.topPath,i._prevBottomPath=e.bottomPath;for(let t=0;i.topPath.length>t;t++)i.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;i.bottomPath.length>t;t++)i.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];N=!0}i._targetOpacity=null!==(s=i.style.opacity)&&void 0!==s?s:1,i._startOpacity=null!==(l=null!==(a=e.opacity)&&void 0!==a?a:i.style.opacity)&&void 0!==l?l:1}else i._targetOpacity=null!==(c=i.style.opacity)&&void 0!==c?c:1,i._startOpacity=0,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),N=!0;continue}const O=o.get(A);if("point"===i.type)if(O){T.add(A);const e={x:i.x,y:i.y,r:i.r};i._targetOpacity=null!==(u=i.style.opacity)&&void 0!==u?u:1,O.x===e.x&&O.y===e.y&&O.r===e.r||(i._targetX=e.x,i._targetY=e.y,i._targetR=e.r,i.x=O.x,i.y=O.y,i.r=null!==(d=O.r)&&void 0!==d?d:i.r,N=!0)}else i._targetOpacity=null!==(h=i.style.opacity)&&void 0!==h?h:1,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),N=!0;else if("rect"===i.type)if(O){T.add(A);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=null!==(g=i.style.opacity)&&void 0!==g?g:1,O.x===e.x&&O.y===e.y&&O.w===e.w&&O.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=O.x,i.y=O.y,i.w=null!==(f=O.w)&&void 0!==f?f:i.w,i.h=null!==(p=O.h)&&void 0!==p?p:i.h,N=!0)}else i._targetOpacity=null!==(y=i.style.opacity)&&void 0!==y?y:1,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),N=!0;else if("heatcell"===i.type)if(O){T.add(A);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=null!==(v=null===(m=i.style)||void 0===m?void 0:m.opacity)&&void 0!==v?v:1,O.x===e.x&&O.y===e.y&&O.w===e.w&&O.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=O.x,i.y=O.y,i.w=null!==(b=O.w)&&void 0!==b?b:i.w,i.h=null!==(x=O.h)&&void 0!==x?x:i.h,N=!0)}else i._targetOpacity=null!==(w=null===(k=i.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,i.style=Object.assign(Object.assign({},i.style||{}),{opacity:0}),N=!0}for(const[e,t]of r)if(!H.has(e))if(e.startsWith("l:")&&t.path){const o={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(A=t.opacity)&&void 0!==A?A:1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(o),N=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const o={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!==(O=t.opacity)&&void 0!==O?O:1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(o),N=!0}for(const[e,t]of o)if(!T.has(e)){if(e.startsWith("p:")){const o={type:"point",x:t.x,y:t.y,r:null!==(S=t.r)&&void 0!==S?S:3,style:{opacity:null!==(j=t.opacity)&&void 0!==j?j:1},datum:null,_targetOpacity:0,_transitionKey:e};n.exitNodes.push(o)}else if(e.startsWith("r:")){const o={type:"rect",x:t.x,y:t.y,w:null!==(M=t.w)&&void 0!==M?M:0,h:null!==(C=t.h)&&void 0!==C?C:0,style:{opacity:null!==(E=t.opacity)&&void 0!==E?E:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e};n.exitNodes.push(o)}else if(e.startsWith("h:")){const o={type:"heatcell",x:t.x,y:t.y,w:null!==(_=t.w)&&void 0!==_?_:0,h:null!==(P=t.h)&&void 0!==P?P:0,fill:"#999",datum:null,style:{opacity:null!==(B=t.opacity)&&void 0!==B?B:1},_targetOpacity:0,_transitionKey:e};n.exitNodes.push(o)}N=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),N&&(n.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:L}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition}advanceTransition(e){if(!this.activeTransition||!this.config.transition)return!1;const t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(e,t,n,o){var r,i,s,a,l;if(!n.activeTransition)return!1;const c=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,n.activeTransition),u=function(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}(c,"linear"===t.easing?"linear":"ease-out-cubic");for(const e of n.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0,i=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;e.style.opacity=N(i,e._targetOpacity,u)}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=N(n.x,e._targetX,u),e.y=N(n.y,e._targetY,u),void 0!==e._targetR&&void 0!==n.r&&(e.r=N(n.r,e._targetR,u))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0,r=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;e.style.opacity=N(r,e._targetOpacity,u)}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=N(n.x,e._targetX,u),e.y=N(n.y,e._targetY,u),void 0!==n.w&&(e.w=N(n.w,e._targetW,u)),void 0!==n.h&&(e.h=N(n.h,e._targetH,u))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0,r=n?null!==(s=n.opacity)&&void 0!==s?s:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:N(r,e._targetOpacity,u)})}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=N(n.x,e._targetX,u),e.y=N(n.y,e._targetY,u),void 0!==n.w&&(e.w=N(n.w,e._targetW,u)),void 0!==n.h&&(e.h=N(n.h,e._targetH,u))}else if("line"===e.type){if(void 0!==e._targetOpacity){const t=null!==(a=e._startOpacity)&&void 0!==a?a:0;e.style=Object.assign(Object.assign({},e.style),{opacity:N(t,e._targetOpacity,u)})}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],u),e.path[o][1]=N(t[o][1],n[o][1],u)}else if("area"===e.type){if(void 0!==e._targetOpacity){const t=null!==(l=e._startOpacity)&&void 0!==l?l:0;e.style=Object.assign(Object.assign({},e.style),{opacity:N(t,e._targetOpacity,u)})}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],u),e.topPath[n][1]=N(t[n][1],o[n][1],u);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],u),e.bottomPath[t][1]=N(n[t][1],r[t][1],u)}}if(c>=1){for(const e of n.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(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(e,this.config.transition,t,this.prevPositionMap);return this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition,n}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:M,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:this.resolveGroupColor(e)||"#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}if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||"#4e79a7",fillOpacity:null!==(n=o.fillOpacity)&&void 0!==n?n:.7,stroke:o.stroke||"#4e79a7",strokeWidth:o.strokeWidth||2};const r=this.resolveGroupColor(e)||"#4e79a7";return{fill:r,fillOpacity:.7,stroke:r,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:M,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()}remove(e){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=new Set(Array.isArray(e)?e:[e]),n=this.getPointId,o=e=>t.has(n(e));if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),t=new Set;this.buffer.forEach((e,n)=>{o(e)&&t.add(n)}),this.timestampBuffer.clear();for(let n=0;e.length>n;n++)t.has(n)||this.timestampBuffer.push(e[n])}const r=this.buffer.remove(o);if(0===r.length)return r;for(const e of r)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)),this.getY0&&this.yExtent.evict(this.getY0(e)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,r}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=new Set(Array.isArray(e)?e:[e]),o=this.getPointId,r=new Set;this.buffer.forEach((e,t)=>{n.has(o(e))&&r.add(t)});const i=this.buffer.update(e=>n.has(o(e)),t);if(0===i.length)return i;for(const e of i)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)),this.getY0&&this.yExtent.evict(this.getY0(e)));return this.buffer.forEach((e,t)=>{r.has(t)&&(this.xExtent.push(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))):(this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,i}getBinBoundaries(){return this._binBoundaries}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._binBoundaries=[],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||!k(null!==(t=e.xAccessor)&&void 0!==t?t:e.timeAccessor,null!==(n=i.xAccessor)&&void 0!==n?n:i.timeAccessor),c=a||!k(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=w(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=w(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=w(this.config.xAccessor,"x"),this.getY=w(this.config.yAccessor,"y")),s=!0)}if("groupAccessor"in e&&!k(e.groupAccessor,i.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?O(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in e&&!k(e.categoryAccessor,i.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?O(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in e&&!k(e.sizeAccessor,i.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?w(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in e&&!k(e.colorAccessor,i.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?O(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in e&&!k(e.y0Accessor,i.y0Accessor)&&(this.getY0=this.config.y0Accessor?w(this.config.y0Accessor,"y0"):void 0,s=!0),"pointIdAccessor"in e&&!k(e.pointIdAccessor,i.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?O(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&("openAccessor"in e&&!k(e.openAccessor,i.openAccessor)||"closeAccessor"in e&&!k(e.closeAccessor,i.closeAccessor)||"highAccessor"in e&&!k(e.highAccessor,i.highAccessor)||"lowAccessor"in e&&!k(e.lowAccessor,i.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?w(this.config.openAccessor,"open"):void 0,this.getHigh=w(this.config.highAccessor,"high"),this.getLow=w(this.config.lowAccessor,"low"),this.getClose=t?w(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,s=!0}if(!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 q(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 X(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function V(e,t){const n=X(e);if(!n)return!1;const o=X(t);return!o||n.getFullYear()!==o.getFullYear()||n.getMonth()!==o.getMonth()}function U(e,t,n,o=30,r){let i=null,s=!1;if(r){const e=r.find(t,n,o);if(e){const r=K(e,t,n,o);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=K(a,t,n,o);break;case"line":e=J(a,t,n,o);break;case"rect":e=ee(a,t,n);break;case"heatcell":e=te(a,t,n);break;case"area":if(!1===a.interactive)break;e=oe(a,t,n);break;case"candlestick":e=ne(a,t,n)}e&&o>e.distance&&(i&&e.distance>=i.distance||(i=e))}return i}function Q(e,t,n){if(0===e.length)return null;const o=re(e,t);if(0>o)return null;if(Math.abs(e[o][0]-t)>n)return null;let r=o,i=o;o>0&&e[o][0]>=t?(r=o-1,i=o):e.length-1>o&&(r=o,i=o+1);const[s,a]=e[r],[l,c]=e[i];return l===s?a:a+Math.max(0,Math.min(1,(t-s)/(l-s)))*(c-a)}function K(e,t,n,o=30){const r=t-e.x,i=n-e.y,s=Math.sqrt(r*r+i*i),a=function(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}(e.r,o);return s>a?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function J(e,t,n,o=30){var r,i,s,a;if(0===e.path.length)return null;const l=re(e.path,t);if(0>l)return null;const[c,u]=e.path[l];let d;if(e.path.length>1){let o=1/0;const r=Math.max(0,l-1),i=Math.min(e.path.length-2,l);for(let s=r;i>=s;s++){const[r,i]=e.path[s],[a,l]=e.path[s+1],c=Z(t,n,r,i,a,l);o>c&&(o=c)}d=o}else{const e=t-c,o=n-u;d=Math.sqrt(e*e+o*o)}const h=null!==(a=null!==(i=null===(r=e.style)||void 0===r?void 0:r.strokeWidth)&&void 0!==i?i:null===(s=e.style)||void 0===s?void 0:s.lineWidth)&&void 0!==a?a:1;return d>Math.max(5,h/2+2,o)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[l]?e.datum[l]:e.datum,x:c,y:u,distance:d}}function Z(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 ee(e,t,n){const o=q(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function te(e,t,n){const o=q(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function ne(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 oe(e,t,n){if(0===e.topPath.length)return null;const o=re(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 re(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const r=n+o>>1;t>e[r][0]?n=r+1:o=r}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}function ie(e,t,n){const o=e.byGroup.get(t);let r=0,i=Math.abs(o[0].x-n.x);for(let e=1;o.length>e;e++){const t=Math.abs(o[e].x-n.x);i>t&&(i=t,r=e)}return o[r]._flatIndex}function se(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})}Y.QUADTREE_THRESHOLD=500;const ae={fill:e=>h.createElement("rect",{style:e,width:16,height:16}),line:e=>h.createElement("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function le(e,t,n,o){let r;return r="function"==typeof n?n(e):(0,ae[n])(o(e,t)),r}function ce(){return h.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function ue(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function de({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-"+h.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(h.createElement("stop",{key:e,offset:100*t+"%",stopColor:o(r[0]+t*(r[1]-r[0]))}))}return h.createElement("g",{"aria-label":i||"Gradient legend"},h.createElement("defs",null,h.createElement("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},c)),i&&h.createElement("text",{x:s+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),h.createElement("rect",{x:s,y:0,width:t,height:e,fill:`url(#${l})`,rx:2}),h.createElement("text",{x:s,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[0])),h.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(h.createElement("stop",{key:e,offset:100*t+"%",stopColor:o(r[1]-t*(r[1]-r[0]))}))}return h.createElement("g",{"aria-label":i||"Gradient legend"},i&&h.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),h.createElement("defs",null,h.createElement("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},c)),h.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${l})`,rx:2}),h.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[1])),h.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[0])))}function he(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,[d,g]=h.useState(0),[f,p]=h.useState(0),y=h.useCallback((e,t)=>{g(e),p(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 d=[];return e.forEach((e,g)=>{u+=5,d.push(h.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,d.push(h.createElement("text",{key:"legend-text-"+g,y:u,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label)),u+=8),d.push(h.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:d,items:g}=e,f=[];let p=0;const y=!(!t&&!n),m="isolate"===c||void 0===c&&null!=r;return g.forEach((e,c)=>{const v=le(e,c,u,d),b=ue(e,o,r),x=r&&r.size>0&&r.has(e.label);f.push(h.createElement("g",{key:"legend-item-"+c,transform:`translate(0,${p})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:y?a===i&&c===s?0:-1:void 0,role:y?"option":void 0,"aria-selected":y&&m?x||!1:void 0,"aria-current":y&&!m&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:y?n=>{var o;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(c+("ArrowDown"===n.key?1:-1)+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:y?t=>{l(a,c),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:y?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:y?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},y&&h.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&&h.createElement(ce,null),h.createElement("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)"},e.label))),p+=22}),f})(e,n,o,r,i,s,a,g,l,c))),u+=22*e.items.length+8}),d})({legendGroups:t||[],width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:d,focusedItemIndex:f,onFocusedIndexChange:y,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 d=0;const g=[];e.forEach((e,t)=>{let f=0;e.label&&(f+=16);const p=((e,t,n,o,r,i,s,a,l,c,u)=>{const{type:d="fill",styleFn:g,items:f}=e,p=[];let y=0,m=0;const v=!(!t&&!n),b="isolate"===c||void 0===c&&null!=r;f.forEach((e,c)=>{const x=le(e,c,d,g),k=ue(e,o,r),w=r&&r.size>0&&r.has(e.label),A=26+7*e.label.length;u&&u>0&&y>0&&y+A>u&&(m++,y=0),p.push(h.createElement("g",{key:"legend-item-"+c,transform:`translate(${y},${22*m})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:v?a===i&&c===s?0:-1:void 0,role:v?"option":void 0,"aria-selected":v&&b?w||!1:void 0,"aria-current":v&&!b&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:v?n=>{var o;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(c+("ArrowRight"===n.key?1:-1)+f.length)%f.length;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:v?t=>{l(a,c),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:v?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:v?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},v&&h.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"}),x,w&&h.createElement(ce,null),h.createElement("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)"},e.label))),y+=A});let x=0,k=0;for(const e of f){const t=26+7*e.label.length;u&&u>0&&k>0&&k+t>u?(x=Math.max(x,k),k=t):k+=t}x=Math.max(x,k);const w=m+1;return{items:p,offset:x,totalRows:w,totalHeight:22*w}})(e,o,r,i,s,a,l,t,c,u,n);f+=p.offset+5,g.push(Object.assign(Object.assign({label:e.label},p),{offset:f,totalRows:p.totalRows,totalHeight:p.totalHeight})),d+=f+12});let f=d>n?0:Math.max(0,(n-d)/2);const p=[];return g.forEach((n,o)=>{const r=e[o];r.label&&(p.push(h.createElement("text",{key:"legend-text-"+o,transform:`translate(${f},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},r.label)),f+=16),p.push(h.createElement("g",{key:"legend-group-"+o,className:"legend-item",transform:`translate(${f},0)`},n.items)),f+=n.offset+5,e[o+1]&&p.push(h.createElement("line",{key:"legend-top-line legend-symbol-"+o,stroke:"gray",x1:f,y1:-8,x2:f,y2:(n.totalHeight||t)+0+8})),f+=12}),h.createElement("g",null,p)})({legendGroups:t||[],title:a,height:c,width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:d,focusedItemIndex:f,onFocusedIndexChange:y,legendInteraction:s}),v=!(!n&&!o);return h.createElement("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"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&&h.createElement("text",{className:"legend-title",y:16,x:l/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},a),m)}function ge(e){return"string"==typeof e?{type:e}:e}function fe({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:d}=e,g=Math.min(.5*n,20),f=(n-g)/2+4;if(c){const e=r(i),n=r(a),o=r(s),c=r(u),p=r(d),y="top"===t?-1:1,m=0;return h.createElement("g",{"data-testid":"marginal-boxplot-"+t},h.createElement("line",{x1:c,y1:m+y*(f+g/2),x2:p,y2:m+y*(f+g/2),stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:c,y1:m+y*f,x2:c,y2:m+y*(f+g),stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:p,y1:m+y*f,x2:p,y2:m+y*(f+g),stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("rect",{x:Math.min(e,n),y:"top"===t?m-f-g:m+f,width:Math.abs(n-e),height:g,fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:o,y1:"top"===t?m-f-g:m+f,x2:o,y2:"top"===t?m-f:m+f+g,stroke:l.fill,strokeWidth:2}))}{const e=r(i),n=r(a),o=r(s),c=r(u),p=r(d),y="left"===t?-1:1,m=0;return h.createElement("g",{"data-testid":"marginal-boxplot-"+t},h.createElement("line",{x1:m+y*(f+g/2),y1:c,x2:m+y*(f+g/2),y2:p,stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:m+y*f,y1:c,x2:m+y*(f+g),y2:c,stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:m+y*f,y1:p,x2:m+y*(f+g),y2:p,stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("rect",{x:"left"===t?m-f-g:m+f,y:Math.min(e,n),width:g,height:Math.abs(n-e),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:"left"===t?m-f-g:m+f,y1:o,x2:"left"===t?m-f:m+f+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 d=Math.max(...u.map(e=>e.length));if(0===d)return null;if("histogram"===l.type)return h.createElement("g",{"data-testid":"marginal-histogram-"+t},u.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const i=e.length/d*n;if(c){const n=r(e.x0),s=r(e.x1)-r(e.x0);return h.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 h.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/d*(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/d*(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 h.createElement("g",{"data-testid":"marginal-violin-"+t},h.createElement("polygon",{points:o.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}if("ridgeline"===l.type){const e=[];if(c){const o=0,i=null!=u[0].x0?r(u[0].x0):0;e.push(`M${i},${o}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const i=o.length/d*n,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/d*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 h.createElement("g",{"data-testid":"marginal-ridgeline-"+t},h.createElement("path",{d:e.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}return null},[o,r,l,i,a,t,c,4]);return u?h.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},u):null}function pe(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 ye(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 me(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:d,className:g,disable:f,events:p={},"data-testid":y}=e,m=new Set(Array.isArray(f)?f:[]);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 h.createElement("g",Object.assign({className:("annotation "+(g||"")).trim(),transform:`translate(${t},${n})`,"data-testid":y},p),!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,d=o/2,h=e*d>t*u?u/e:d/t;a=r+s*h,l=i+c*h}}}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(h.createElement("line",{key:"connector-line",x1:a,y1:l,x2:e,y2:t,stroke:o||"var(--semiotic-text-secondary, 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(h.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||"var(--semiotic-text-secondary, currentColor)",stroke:"none"}))}return h.createElement("g",{className:"annotation-connector"},s)}(v,b,l,d,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(h.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, 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(h.createElement("rect",{key:"subject-rect",width:e,height:o,fill:"none",stroke:n||"var(--semiotic-text-secondary, 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(h.createElement("line",{key:"threshold-line",x1:o,y1:(t.y1||0)-i,x2:o,y2:(t.y2||0)-i,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}))}else if(void 0!==(null==t?void 0:t.y)){const o=(t.y||0)-i;s.push(h.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:o,x2:(t.x2||0)-e,y2:o,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}))}else void 0!==(null==t?void 0:t.x1)||void 0!==(null==t?void 0:t.x2)?s.push(h.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"})):void 0===(null==t?void 0:t.y1)&&void 0===(null==t?void 0:t.y2)||s.push(h.createElement("line",{key:"threshold-line",x1:0,y1:(t.y1||0)-i,x2:0,y2:(t.y2||0)-i,stroke:n||"var(--semiotic-text-secondary, 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(h.createElement("path",{key:"bracket-path",d:ye((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||"var(--semiotic-text-secondary, currentColor)"}));break}}return h.createElement("g",{className:"annotation-subject"},s)}(x,c,d,t,n),!m.has("note")&&function(e,t,n,o){if(!e)return h.createElement("g",{className:"annotation-note"});const{label:r,title:i,orientation:s,align:a,wrap:l=120,noWrap:c}=e;if(!r&&!i)return h.createElement("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=a;d&&"dynamic"!==d||(d="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let g="start";"topBottom"===u?"right"===d?g="end":"middle"===d&&(g="middle"):g=0>t?"end":"start";const f=16,p=i?c?[i]:pe(i,l):[],y=r?c?[r]:pe(r,l):[],m="leftRight"===u?"end"===g?-4:4:0;let v=0;const b=[],x=o||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";p.length>0&&(b.push(h.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:x,textAnchor:g,fontWeight:"bold"},p.map((e,t)=>h.createElement("tspan",{key:t,x:m,dy:0===t?0:f},e)))),v=p.length*f),y.length>0&&b.push(h.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:x,textAnchor:g,y:v},y.map((e,t)=>h.createElement("tspan",{key:t,x:m,dy:0===t?0:f},e))));let k=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),k=h.createElement("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(p.length+y.length)*f+(y.length>0?f:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),k=h.createElement("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,p.length+y.length-1)*f;let A=0;return"topBottom"===u?A=0>n?-(w+2):18:"leftRight"===u&&(A="middle"===d?-(w+f+(y.length>0&&p.length>0?2:0))/2+8:"bottom"===d||0>n?-(w+2):18),h.createElement("g",{className:"annotation-note",transform:`translate(${t},${n})`},h.createElement("g",{className:"annotation-note-content",transform:0!==A?`translate(0,${A})`:void 0},b),k)}(a,v,b,d))}function ve(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 h.createElement(me,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},r,{type:i}))});return h.createElement("g",null,a)}const a=o.note||{title:"none",label:o.label};return h.createElement(me,Object.assign({"data-testid":"semiotic-annotation",key:`${a.label}-${a.title}-${o.i}`,events:s},o,{type:i}))}function be(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 xe(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 ke(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 d=l[e.xAccessor||"x"],h=l[e.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return i&&(null===(r=n.stickyPositionCache)||void 0===r||r.set(t,i)),i}let l=null,c=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(l=t.x,c=t.y)}if(null!=l&&null!=c||(l=be(e,n),c=xe(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 we(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}const Ae={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};let Oe={positions:new Map};const Se=new Set;function je(){for(const e of Se)e()}function Me(e,t){const n=Oe.positions.get(e);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==t)return;const o=new Map(Oe.positions);o.delete(e),Oe={positions:o},je()}function Ce(e,t){const n=Oe.positions.get(e);if(!(null==n?void 0:n.locked))return;if(t&&n.sourceId!==t)return;const o=new Map(Oe.positions);o.delete(e),Oe={positions:o},je()}function Ee(){return Oe}function _e(e){return Se.add(e),()=>Se.delete(e)}const Pe={positions:new Map};function Be(){return()=>{}}function Le(){return Pe}function Ne(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Ie(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 Te(t){const{width:n,height:o,totalWidth:r,totalHeight:i,margin:s,scales:a,showAxes:l,axes:c,showGrid:u,xFormat:d,yFormat:g}=t,f=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)||d||He,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,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0);return Fe(l,Math.max(55,u+8))},[a,c,d,n]),p=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||He,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return Fe(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]),y=u&&a,m=l&&a;if(!y&&!m)return null;const v=null==c?void 0:c.find(e=>"bottom"===e.orient),b=null==c?void 0:c.find(e=>"left"===e.orient),x=m&&(!v||!1!==v.baseline),k=m&&(!b||!1!==b.baseline),w=(null==v?void 0:v.jaggedBase)||!1,A=(null==b?void 0:b.jaggedBase)||!1,O="var(--semiotic-border, #ccc)";return h.createElement("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},h.createElement("g",{transform:`translate(${s.left},${s.top})`},y&&(()=>{var e,t;const r=Ne(null===(e=null==c?void 0:c.find(e=>"bottom"===e.orient))||void 0===e?void 0:e.gridStyle),i=Ne(null===(t=null==c?void 0:c.find(e=>"left"===e.orient))||void 0===t?void 0:t.gridStyle);return h.createElement("g",{className:"stream-grid"},f.map((e,t)=>h.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r})),p.map((e,t)=>h.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:n,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i})))})(),x&&!w&&h.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:O,strokeWidth:1}),w&&h.createElement("path",{d:Ie("bottom",n,o),fill:"none",stroke:O,strokeWidth:1}),k&&!A&&h.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:O,strokeWidth:1}),A&&h.createElement("path",{d:Ie("left",n,o),fill:"none",stroke:O,strokeWidth:1})))}function He(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function Fe(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 ze(t){var n,o;const{width:r,height:i,totalWidth:s,totalHeight:c,margin:u,scales:d,showAxes:f,axes:p,xLabel:y,yLabel:m,yLabelRight:v,xFormat:b,yFormat:x,showGrid:k,title:w,legend:A,legendHoverBehavior:O,legendClickBehavior:S,legendHighlightedCategory:j,legendIsolatedCategories:M,legendPosition:C="right",foregroundGraphics:E,marginalGraphics:_,xValues:P,yValues:B,annotations:L,svgAnnotationRules:N,xAccessor:I,yAccessor:T,annotationData:H,pointNodes:F,curve:z,underlayRendered:R,linkedCrosshairName:$,linkedCrosshairSourceId:D,children:W}=t,G=e.useMemo(()=>{var e;if(!f||!d)return[];const t=null==p?void 0:p.find(e=>"bottom"===e.orient),n=(null==t?void 0:t.tickFormat)||b||He,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,i=d.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:d.x(e),label:n(e,t,s)})),l=a.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0),c=(null==t?void 0:t.autoRotate)?Math.max(20,Math.min(l+8,55)):Math.max(55,l+8);let u=Fe(a,c);if(u.length>1&&(u=u.filter((e,t)=>0===t||e.label+""!=u[t-1].label+"")),(null==t?void 0:t.includeMax)&&u.length>0){const e=d.x.domain()[1],t=d.x(e),o=u[u.length-1].pixel;if(Math.abs(t-o)>1){const r=n(e,u.length,s);c>t-o&&u.length>1&&(u=u.slice(0,-1)),u.push({value:e,pixel:t,label:r})}}return u},[f,d,p,b,r]),Y=e.useMemo(()=>{var e;if(!f||!d)return[];const t=null==p?void 0:p.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||x||He,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;let r=Fe(d.y.ticks(Math.min(o,Math.max(2,Math.floor(i/30)))).map(e=>({value:e,pixel:d.y(e),label:n(e)})),22);if(r.length>1&&(r=r.filter((e,t)=>0===t||e.label+""!=r[t-1].label+"")),(null==t?void 0:t.includeMax)&&r.length>0){const e=d.y.domain()[1],t=d.y(e),o=r[r.length-1].pixel;if(Math.abs(t-o)>1){const i=n(e);22>Math.abs(t-o)&&r.length>1&&(r=r.slice(0,-1)),r.push({value:e,pixel:t,label:i})}}return r},[f,d,p,x,i]),q=e.useMemo(()=>{var e;if(!f||!d)return[];const t=null==p?void 0:p.find(e=>"right"===e.orient);if(!t)return[];const n=t.tickFormat||x||He,o=null!==(e=t.ticks)&&void 0!==e?e:5;return Fe(d.y.ticks(Math.min(o,Math.max(2,Math.floor(i/30)))).map(e=>({value:e,pixel:d.y(e),label:n(e)})),22)},[f,d,p,x,i]),X=e.useRef(new Map),U=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;U.current!==Q&&(U.current=Q,X.current=new Map);const K=e.useMemo(()=>{if(!L||0===L.length)return null;const e=function(e,t,n){var o,r,i,s,c,u,d,f,p,y,m,v,b,x,k,w,A,O,S,j,M,C,E,_,P,B,L,N,I,T,H,F,z,R,$,D,W,G,Y,q,X,V,U,Q,K,J,Z,ee;switch(e.type){case"label":{const o=ke(e,t,n);if(!o)return null;const{x:r,y:i}=o;return we(r,i,n)?h.createElement(ve,{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=ke(e,t,n);if(!o)return null;const{x:r,y:i}=o;return we(r,i,n)?h.createElement(ve,{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=be(e,n);if(null==o)return null;const r=e.color||"#f97316",i=e.labelPosition||"top";let s;return s="bottom"===i?(n.height||0)-4:"center"===i?(n.height||0)/2:12,h.createElement("g",{key:"ann-"+t},h.createElement("line",{x1:o,y1:0,x2:o,y2:n.height||0,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&h.createElement("text",{x:o+4,y:s,fill:r,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const o=xe(e,n);if(null==o)return null;const r=e.color||"#f97316",i=e.labelPosition||"right";let s,a;return"left"===i?(s=4,a="start"):"center"===i?(s=(n.width||0)/2,a="middle"):(s=(n.width||0)-4,a="end"),h.createElement("g",{key:"ann-"+t},h.createElement("line",{x1:0,y1:o,x2:n.width||0,y2:o,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&h.createElement("text",{x:s,y:o-4,textAnchor:a,fill:r,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const o=(e.coordinates||[]).map(e=>({x:be(Object.assign(Object.assign({},e),{type:"point"}),n),y:xe(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 h.createElement("g",{key:"ann-"+t},h.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&&h.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:be(Object.assign(Object.assign({},e),{type:"point"}),n),y:xe(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 h.createElement("g",{key:"ann-"+t},h.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&&h.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 h.createElement("g",{key:"ann-"+t},r.map((t,o)=>{const r=be(t,n),s=xe(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 h.createElement("circle",Object.assign({key:"hl-"+o,cx:r,cy:s,r:a},l))}))}case"bracket":{const o=be(e,n),r=xe(e,n);return h.createElement(ve,{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",f=n.yAccessor||"y",p=a.map(e=>[e[l],e[f]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>p.length)return null;const y=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(!y||!m)return null;const v=e.method||"linear";let b;b="loess"===v?function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),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,d=0,h=0,g=0,f=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*r[e],h+=t*i[e],g+=t*r[e]*r[e],f+=t*r[e]*i[e])}if(0===u){a.push([t,i[e]]);continue}const p=u*g-d*d;if(1e-12>Math.abs(p))a.push([t,h/u]);else{const e=(u*f-d*h)/p;a.push([t,(h-e*d)/u+e*t])}}return a}(p,null!==(d=e.bandwidth)&&void 0!==d?d:.3):("polynomial"===v?g.default.polynomial(p,{order:e.order||2}):g.default.linear(p)).points;const x=b.map(([e,t])=>`${y(e)},${m(t)}`).join(" "),k=e.color||"#6366f1";return h.createElement("g",{key:"ann-"+t},h.createElement("polyline",{points:x,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&h.createElement("text",{x:y(b[b.length-1][0])+4,y:m(b[b.length-1][1])-4,fill:k,fontSize:11},e.label))}case"band":{const o=null!==(p=null===(f=n.scales)||void 0===f?void 0:f.y)&&void 0!==p?p:null===(y=n.scales)||void 0===y?void 0:y.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 h.createElement("g",{key:"ann-"+t},h.createElement("rect",{x:0,y:Math.min(r,i),width:n.width||0,height:Math.abs(i-r),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&h.createElement("text",{x:(n.width||0)-4,y:Math.min(r,i)-4,textAnchor:"end",fill:e.color||"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===(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===(O=n.scales)||void 0===O?void 0:O.value;if(!i||!s)return null;const a=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",u=e.filter,d=o.filter(e=>null!=e[a]&&null!=e[c]&&!(u&&!u(e))).sort((e,t)=>e[r]-t[r]);if(2>d.length)return null;const g=Ae[n.curve||"linear"]||l.curveLinear,f=l.area().x(e=>i(e[r])).y0(e=>s(e[c])).y1(e=>s(e[a])).curve(g)(d);if(!f)return null;const p=e.fill||"#6366f1";return h.createElement("g",{key:"ann-"+t},h.createElement("path",{d:f,fill:p,fillOpacity:null!==(S=e.fillOpacity)&&void 0!==S?S:.15,stroke:"none"}),e.label&&d.length>0&&h.createElement("text",{x:i(d[d.length-1][r])+4,y:s(d[d.length-1][a])-4,fill:p,fontSize:11},e.label))}case"anomaly-band":{const o=n.data||[];if(2>o.length)return null;const r=n.yAccessor||"y",i=null!==(M=null===(j=n.scales)||void 0===j?void 0:j.x)&&void 0!==M?M:null===(C=n.scales)||void 0===C?void 0:C.time,s=null!==(_=null===(E=n.scales)||void 0===E?void 0:E.y)&&void 0!==_?_:null===(P=n.scales)||void 0===P?void 0:P.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),d=null!==(B=e.threshold)&&void 0!==B?B:2,g=l-d*u,f=!1!==e.showBand,p=e.fill||"#6366f1",y=null!==(L=e.fillOpacity)&&void 0!==L?L:.1,m=e.anomalyColor||"#ef4444",v=null!==(N=e.anomalyRadius)&&void 0!==N?N:6,b=s(l+d*u),x=s(g),k=o.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-l)>d*u});return h.createElement("g",{key:"ann-"+t},f&&h.createElement("rect",{x:0,y:Math.min(b,x),width:n.width||0,height:Math.abs(x-b),fill:p,fillOpacity:y}),k.map((e,t)=>{const o=be(e,n),r=xe(e,n);return null==o||null==r?null:h.createElement("circle",{key:"anomaly-"+t,cx:o,cy:r,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5})}),e.label&&h.createElement("text",{x:(n.width||0)-4,y:Math.min(b,x)-4,textAnchor:"end",fill:p,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!==(T=null===(I=n.scales)||void 0===I?void 0:I.x)&&void 0!==T?T:null===(H=n.scales)||void 0===H?void 0:H.time,a=null!==(z=null===(F=n.scales)||void 0===F?void 0:F.y)&&void 0!==z?z:null===(R=n.scales)||void 0===R?void 0:R.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,d=l.map(([e,t])=>t-c(e)).reduce((e,t)=>e+t*t,0),f=Math.sqrt(d/Math.max(u-2,1)),p=l.reduce((e,t)=>e+t[0],0)/u,y=l.reduce((e,t)=>e+Math.pow(t[0]-p,2),0),m=null!==($=e.confidence)&&void 0!==$?$:.95,v=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,b=null!==(D=e.steps)&&void 0!==D?D:5,x=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=f*Math.sqrt(1+1/u+(y>0?Math.pow(e-p,2)/y:0))*v;A.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const O=`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`,S=A.map(e=>`${s(e.x)},${a(e.yCenter)}`).join(" "),j=`${s(x)},${a(c(x))}`,M=e.strokeColor||"#6366f1";return h.createElement("g",{key:"ann-"+t},h.createElement("path",{d:O,fill:e.fill||"#6366f1",fillOpacity:null!==(W=e.fillOpacity)&&void 0!==W?W:.15,stroke:"none"}),h.createElement("polyline",{points:`${j} ${S}`,fill:"none",stroke:M,strokeWidth:null!==(G=e.strokeWidth)&&void 0!==G?G:2,strokeDasharray:null!==(Y=e.strokeDasharray)&&void 0!==Y?Y:"6,3"}),e.label&&A.length>0&&h.createElement("text",{x:s(A[A.length-1].x)+4,y:a(A[A.length-1].yCenter)-4,fill:M,fontSize:11},e.label))}case"widget":{let o=null,r=null;if(null!=e.px&&null!=e.py)o=e.px,r=e.py;else{const i=ke(e,t,n);if(!i)return null;o=i.x,r=i.y}if(null==o||null==r)return null;if(!we(o,r,n))return null;const i=null!==(q=e.dx)&&void 0!==q?q: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:h.createElement("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info"},"ℹ️");return h.createElement("foreignObject",{key:"ann-"+t,x:o+i-a/2,y:r+s-l/2,width:a,height:l,style:{overflow:"visible",pointerEvents:"auto"}},h.createElement("div",{style:{width:a,height:l,display:"flex",alignItems:"center",justifyContent:"center"}},c))}case"text":{const o=ke(e,t,n);if(!o)return null;const{x:r,y:i}=o;return h.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)}case"category-highlight":{const o=e.category;if(null==o)return null;const r=null===(K=n.scales)||void 0===K?void 0:K.o,i=null===(J=n.scales)||void 0===J?void 0:J.x,s=null===(Z=n.scales)||void 0===Z?void 0:Z.y,a=(null==r?void 0:r.bandwidth)?r:(null==i?void 0:i.bandwidth)?i:(null==s?void 0:s.bandwidth)?s:null;if(!a)return null;const l=a(o);if(null==l)return null;const c=a.bandwidth(),u=e.color||"var(--semiotic-primary, #4589ff)",d=null!==(ee=e.opacity)&&void 0!==ee?ee:.15,g=e.label;return(n.projection?"vertical"===n.projection:a===i)?h.createElement("g",{key:"ann-"+t},h.createElement("rect",{x:l,y:0,width:c,height:n.height||0,fill:u,fillOpacity:d}),g&&h.createElement("text",{x:l+c/2,y:12,textAnchor:"middle",fill:u,fontSize:12,fontWeight:"bold"},g)):h.createElement("g",{key:"ann-"+t},h.createElement("rect",{x:0,y:l,width:n.width||0,height:c,fill:u,fillOpacity:d}),g&&h.createElement("text",{x:12,y:l+c/2,dominantBaseline:"middle",fill:u,fontSize:12,fontWeight:"bold"},g))}default:return null}},t={scales:d?{x:d.x,y:d.y,time:d.x,value:d.y}:null,timeAxis:"x",xAccessor:I,yAccessor:T,width:r,height:i,data:H,frameType:"xy",pointNodes:F,curve:z,stickyPositionCache:X.current};return L.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)},[L,N,r,i,I,T,H,d,F,z]),J=function(t){var n;const o=e.useSyncExternalStore(t?_e:Be,t?Ee:Le,t?Ee:Le);return t&&null!==(n=o.positions.get(t))&&void 0!==n?n:null}($);return e.useEffect(()=>{if(!(null==J?void 0:J.locked)||!$)return;const e=e=>{"Escape"===e.key&&Ce($)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[null==J?void 0:J.locked,$]),f||w||A||E||_||K&&K.length>0||k||W||J?h.createElement("svg",{role:"img",width:s,height:c,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"}},h.createElement("title",null,"string"==typeof w?w:"XY Chart"),h.createElement("desc",null,"string"==typeof w?w+" — XY data visualization":"XY data visualization"),h.createElement("g",{transform:`translate(${u.left},${u.top})`},k&&d&&!R&&(()=>{var e,t;const n=Ne(null===(e=null==p?void 0:p.find(e=>"bottom"===e.orient))||void 0===e?void 0:e.gridStyle),o=Ne(null===(t=null==p?void 0:p.find(e=>"left"===e.orient))||void 0===t?void 0:t.gridStyle);return h.createElement("g",{className:"stream-grid"},G.map((e,t)=>h.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:n})),Y.map((e,t)=>h.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:r,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o})))})(),f&&d&&(()=>{const e=null==p?void 0:p.find(e=>"left"===e.orient),t=null==p?void 0:p.find(e=>"bottom"===e.orient),n=!e||!1!==e.baseline,o=!t||!1!==t.baseline,s=(null==e?void 0:e.jaggedBase)||!1,a=(null==t?void 0:t.jaggedBase)||!1,l=null==t?void 0:t.landmarkTicks,c=null==e?void 0:e.landmarkTicks,d="var(--semiotic-border, #ccc)",g="var(--semiotic-text-secondary, var(--semiotic-text, #666))",f="var(--semiotic-text, #333)",b=!!(null==t?void 0:t.autoRotate)&&G.length>1&&(()=>{const e=r/Math.max(G.length-1,1);return G.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})();return h.createElement("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},!R&&o&&!a&&h.createElement("line",{x1:0,y1:i,x2:r,y2:i,stroke:d,strokeWidth:1}),!R&&a&&h.createElement("path",{d:Ie("bottom",r,i),fill:"none",stroke:d,strokeWidth:1}),G.map((e,t)=>{const n=!!l&&("function"==typeof l?l(e.value,t):V(e.value,t>0?G[t-1].value:void 0));return h.createElement("g",{key:"xtick-"+t,transform:`translate(${e.pixel},${i})`},h.createElement("line",{y2:5,stroke:d,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?h.createElement("text",{y:b?10:18,textAnchor:b?"end":"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:g,style:{userSelect:"none"},transform:b?"rotate(-45)":void 0},e.label):h.createElement("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"}},h.createElement("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"}},e.label)))}),y&&h.createElement("text",{x:r/2,y:i+40,textAnchor:"middle",fontSize:12,fill:f,style:{userSelect:"none"}},y),!R&&n&&!s&&h.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:d,strokeWidth:1}),!R&&s&&h.createElement("path",{d:Ie("left",r,i),fill:"none",stroke:d,strokeWidth:1}),Y.map((e,t)=>{const n=!!c&&("function"==typeof c?c(e.value,t):V(e.value,t>0?Y[t-1].value:void 0));return h.createElement("g",{key:"ytick-"+t,transform:`translate(0,${e.pixel})`},h.createElement("line",{x2:-5,stroke:d,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?h.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:g,style:{userSelect:"none"}},e.label):h.createElement("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"}},h.createElement("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"}},e.label)))}),(()=>{const t=(null==e?void 0:e.label)||m;return t?h.createElement("text",{x:15-u.left,y:i/2,textAnchor:"middle",fontSize:12,fill:f,transform:`rotate(-90, ${15-u.left}, ${i/2})`,style:{userSelect:"none"}},t):null})(),(()=>{const e=null==p?void 0:p.find(e=>"right"===e.orient);if(!e||0===q.length)return null;const t=e.landmarkTicks,n=e.label||v;return h.createElement(h.Fragment,null,!1!==e.baseline&&h.createElement("line",{x1:r,y1:0,x2:r,y2:i,stroke:d,strokeWidth:1}),q.map((e,n)=>{const o=!!t&&("function"==typeof t?t(e.value,n):V(e.value,n>0?q[n-1].value:void 0));return h.createElement("g",{key:"ytick-r-"+n,transform:`translate(${r},${e.pixel})`},h.createElement("line",{x2:5,stroke:d,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?h.createElement("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:g,style:{userSelect:"none"}},e.label):h.createElement("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"}},h.createElement("div",{style:{textAlign:"left",fontSize:10,userSelect:"none"}},e.label)))}),n&&h.createElement("text",{x:r+u.right-15,y:i/2,textAnchor:"middle",fontSize:12,fill:f,transform:`rotate(90, ${r+u.right-15}, ${i/2})`,style:{userSelect:"none"}},n))})())})(),K,_&&d&&P&&B&&h.createElement(h.Fragment,null,_.top&&h.createElement("g",{transform:"translate(0, 0)"},h.createElement(fe,{orient:"top",config:ge(_.top),values:P,scale:d.x,size:u.top,length:r})),_.bottom&&h.createElement("g",{transform:`translate(0, ${i})`},h.createElement(fe,{orient:"bottom",config:ge(_.bottom),values:P,scale:d.x,size:u.bottom,length:r})),_.left&&h.createElement("g",{transform:"translate(0, 0)"},h.createElement(fe,{orient:"left",config:ge(_.left),values:B,scale:d.y,size:u.left,length:i})),_.right&&h.createElement("g",{transform:`translate(${r}, 0)`},h.createElement(fe,{orient:"right",config:ge(_.right),values:B,scale:d.y,size:u.right,length:i}))),E,J&&J.sourceId!==D&&(null==d?void 0:d.x)&&(()=>{const e=d.x(J.xValue);if(null==e||0>e||e>r)return null;const t=J.locked;return h.createElement("line",{x1:e,y1:0,x2:e,y2:i,stroke:t?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:t?1.5:1,strokeDasharray:t?"6,3":"4,4",pointerEvents:"none"})})(),W),w&&h.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:d}=e;if(!t)return null;const g="top"===i||"bottom"===i;let f,p;return"left"===i?(f=4,p=r.top):"top"===i?(f=0,p=s?32:8):"bottom"===i?(f=0,p=o-r.bottom+50):(f=n-r.right+10,p=r.top),h.createElement("g",{transform:`translate(${f}, ${p})`},"object"==typeof(y=t)&&null!==y&&"gradient"in y?h.createElement(de,{config:t.gradient,orientation:g?"horizontal":"vertical",width:g?n:100}):function(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}(t)?h.createElement(he,{legendGroups:t.legendGroups,title:"",width:g?n:100,orientation:g?"horizontal":"vertical",customHoverBehavior:a,customClickBehavior:l,highlightedCategory:c,isolatedCategories:u,legendInteraction:d}):t);var y}({legend:A,totalWidth:s,totalHeight:c,margin:u,legendPosition:C,title:w,legendHoverBehavior:O,legendClickBehavior:S,legendHighlightedCategory:j,legendIsolatedCategories:M})):null}function Re(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}const $e="undefined"==typeof window||"undefined"==typeof document,De=h.createContext(null),We={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Ge(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e)n[t.type]=(n[t.type]||0)+1;const o=[],r={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},i=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],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(", ")}`}const Ye=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},qe={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},Xe={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},Ve={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},Ue={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Qe={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},Ke={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},Je={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function Ze({scene:e,chartType:t,tableId:n,chartTitle:o}){var r;const[i,s]=h.useState(!1),a=h.useContext(De),l=null!==(r=null==a?void 0:a.visible)&&void 0!==r&&r,c=i||l,u=h.useRef(null),d=o?"Data summary for "+o:n?`Data summary for ${t} ${n}`:"Data summary for "+t,g=h.useCallback(()=>{i||l||s(!0)},[i,l]),f=h.useCallback(e=>{var t;l||(null===(t=u.current)||void 0===t?void 0:t.contains(e.relatedTarget))||s(!1)},[l]);if(!e||0===e.length)return n?h.createElement("span",{id:n,tabIndex:-1,style:We}):null;if(!c)return h.createElement("div",{id:n,tabIndex:-1,onFocus:g,style:We,role:"region","aria-label":d},h.createElement("button",{type:"button",onClick:()=>s(!0)},"View data summary (",e.length," elements)"));const p=function(e){var t,n,o,r,i,s,a,l,c,u,d,h,g,f,p,y,m,v,b,x,k,w,A,O,S;const j=[];if(!Array.isArray(e))return j;for(const M of e)if(M&&"object"==typeof M)try{switch(M.type){case"point":j.push({label:"Point",values:{x:M.x,y:M.y}});break;case"line":{const e=M.path,t=Array.isArray(M.datum)?M.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&j.push({label:"Line point",values:{x:t[0],y:t[1]}})}break}case"area":{const e=M.topPath,t=Array.isArray(M.datum)?M.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&j.push({label:"Area point",values:{x:t[0],y:t[1]}})}break}case"rect":{const e=null!=M.datum&&"object"==typeof M.datum?M.datum:{},i=null!==(n=null!==(t=e.category)&&void 0!==t?t:M.group)&&void 0!==n?n:"",s=null!==(r=null!==(o=e.value)&&void 0!==o?o:e.__aggregateValue)&&void 0!==r?r:e.total;j.push({label:"Bar",values:{category:i,value:null!=s?s:""}});break}case"heatcell":j.push({label:"Cell",values:{x:M.x,y:M.y,value:M.value}});break;case"wedge":j.push({label:"Wedge",values:{category:null!==(l=null!==(s=null===(i=M.datum)||void 0===i?void 0:i.category)&&void 0!==s?s:null===(a=M.datum)||void 0===a?void 0:a.label)&&void 0!==l?l:"",value:null!==(u=null===(c=M.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":j.push({label:"Node",values:{id:null!==(h=null===(d=M.datum)||void 0===d?void 0:d.id)&&void 0!==h?h:"",x:null!==(g=M.cx)&&void 0!==g?g:M.x,y:null!==(f=M.cy)&&void 0!==f?f:M.y}});break;case"arc":j.push({label:"Arc",values:{id:null!==(y=null===(p=M.datum)||void 0===p?void 0:p.id)&&void 0!==y?y:"",x:null!==(m=M.cx)&&void 0!==m?m:M.x,y:null!==(v=M.cy)&&void 0!==v?v:M.y}});break;case"candlestick":j.push({label:"Candlestick",values:{x:M.x,open:M.open,high:M.high,low:M.low,close:M.close}});break;case"geoarea":j.push({label:"Region",values:{name:null!==(A=null!==(k=null===(x=null===(b=M.datum)||void 0===b?void 0:b.properties)||void 0===x?void 0:x.name)&&void 0!==k?k:null===(w=M.datum)||void 0===w?void 0:w.name)&&void 0!==A?A:"",value:null!==(S=null===(O=M.datum)||void 0===O?void 0:O.value)&&void 0!==S?S:""}})}}catch(e){}return j}(e),y=function(e){if(!e||0===e.length)return[];const t=new Set;for(const n of e)if(n&&n.values)for(const e of Object.keys(n.values))t.add(e);const n=[];for(const o of t){const t=[],r=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[o];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&r.add(e+""))}if(t.length>0){let e=t[0],r=t[0],i=0;for(const n of t)e>n&&(e=n),n>r&&(r=n),i+=n;n.push({name:o,count:t.length,numeric:!0,min:e,max:r,mean:i/t.length})}else if(r.size>0){const e=Array.from(r);n.push({name:o,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(p),m=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${Ye(e.min)} to ${Ye(e.max)}, mean ${Ye(e.mean)}.`);else{const t=e.uniqueValues,o=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${o}.`)}return n.join(" ")}(p.length,y),v=p.slice(0,5),b=new Set;for(const e of v)for(const t of Object.keys(e.values))b.add(t);const x=Array.from(b);return h.createElement("div",{ref:u,id:n,tabIndex:-1,onBlur:f,style:qe,role:"region","aria-label":d},h.createElement("button",{type:"button",onClick:()=>{l&&a&&a.setVisible(!1),s(!1)},"aria-label":"Close data summary",style:Ve},"×"),h.createElement("div",{role:"note",style:Xe},m),h.createElement("table",{role:"table","aria-label":"Sample data for "+t,style:Ue},h.createElement("caption",{style:Je},"First ",v.length," of ",p.length," data points"),h.createElement("thead",null,h.createElement("tr",null,h.createElement("th",{style:Qe},"type"),x.map(e=>h.createElement("th",{key:e,style:Qe},e)))),h.createElement("tbody",null,v.map((e,t)=>h.createElement("tr",{key:t},h.createElement("td",{style:Ke},e.label),x.map(t=>{return h.createElement("td",{key:t,style:Ke},null==(n=e.values[t])||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":Ye(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"");var n}))))))}function et({summary:e}){return e?h.createElement("div",{role:"note",style:We},e):null}function tt({tableId:e}){return h.createElement("a",{href:"#"+e,style:We,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,We)}},"Skip to data table")}function nt({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 h.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:We},t)}const ot="var(--semiotic-focus, #005fcc)";function rt({active:e,hoverPoint:t,margin:n,size:o,shape:r="circle",width:i,height:s}){if(!e||!t)return null;const a=t.x+n.left,l=t.y+n.top;let c;if("rect"===r&&null!=i&&null!=s){const e=Math.max(i,4),t=Math.max(s,4);c=h.createElement("rect",{x:a-e/2-3,y:l-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:ot,strokeWidth:2,strokeDasharray:"4,2"})}else c=h.createElement("circle","wedge"===r?{cx:a,cy:l,r:12,fill:"none",stroke:ot,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:a,cy:l,r:8,fill:"none",stroke:ot,strokeWidth:2,strokeDasharray:"4,2"});return h.createElement("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true"},c)}function it({x:e,y:t,containerWidth:n,containerHeight:o,margin:r,children:i,className:s="stream-frame-tooltip",zIndex:a=1}){const l=h.useRef(null),[c,u]=h.useState(null);h.useLayoutEffect(()=>{const e=l.current;if(!e)return;const t=e.getBoundingClientRect();u(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[i,s,n,o]);let d;return d=c?`translate(${c.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${c.height+12>o-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*o>t?"4px":"calc(-100% - 4px)"})`,h.createElement("div",{ref:l,className:s,style:{position:"absolute",left:r.left+e,top:r.top+t,transform:d,pointerEvents:"none",zIndex:a,width:"max-content"}},i)}function st(t){const n=e.createContext(null),o=at(t);return[function({children:o}){const r=e.useMemo(()=>at(t),[]);return h.createElement(n.Provider,{value:r,children:o})},t=>{var r;const i=null!==(r=e.useContext(n))&&void 0!==r?r:o,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 at(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 lt={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},ct={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},ut={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"},[dt,ht]=st(e=>({theme:lt,setTheme(t){e(e=>{if("light"===t)return{theme:lt};if("dark"===t)return{theme:ct};if("high-contrast"===t)return{theme:ut};if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?ct:lt;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 gt(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}const ft=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,pt=new WeakMap;function yt(e,t){var n,o;if(!t)return t;const r=ft.exec(t);if(!r)return t;const i=e.canvas;if(!i)return(null===(n=r[2])||void 0===n?void 0:n.trim())||t;let s=pt.get(i);if(s||(s=new Map,pt.set(i,s)),s.has(t))return s.get(t);const a=getComputedStyle(i).getPropertyValue(r[1]).trim()||(null===(o=r[2])||void 0===o?void 0:o.trim())||t;return s.set(t,a),a}function mt(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 vt(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 bt(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()}}const xt=(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,d=a.colorThresholds,h=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 y=null!==(r=a.style.opacity)&&void 0!==r?r:1;bt(e,a.path,c,u,y,a.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const g=mt(a.curve),f=d&&d.length>0&&h&&h.length===a.path.length,p=a._decayOpacities;if(p&&p.length===a.path.length&&!f){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*(p[v]+p[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(f){let b=null,x=null,k=null,w=null,A=!1;function O(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),A=!0}function S(){A&&(e.stroke(),A=!1)}for(let j=0;a.path.length>j;j++){const[M,C]=a.path[j],E=h[j],_=vt(E,d,c);if(null!==b&&null!==w&&null!==k){if(_===w)e.lineTo(M,C);else{const P=[];for(const B of d){const L=B.value;(k>L||L>E)&&(L>k||E>L)||k===L||E===L||P.push({t:(L-k)/(E-k)})}P.sort((e,t)=>e.t-t.t);for(const N of P){const I=b+(M-b)*N.t,T=x+(C-x)*N.t,H=vt(k+(E-k)*Math.min(N.t+1e-4,1),d,c);e.lineTo(I,T),S(),O(H,I,T)}e.lineTo(M,C)}b=M,x=C,k=E,w=_}else O(_,M,C),b=M,x=C,k=E,w=_}S()}else{if(e.beginPath(),!a.strokeGradient||2>a.strokeGradient.colorStops.length||2>a.path.length)e.strokeStyle=c;else{const F=e.createLinearGradient(a.path[0][0],0,a.path[a.path.length-1][0],0);for(const z of a.strokeGradient.colorStops)F.addColorStop(Math.max(0,Math.min(1,z.offset)),z.color);e.strokeStyle=F}if(g)l.line().x(e=>e[0]).y(e=>e[1]).curve(g).context(e)(a.path);else{const[R,$]=a.path[0];e.moveTo(R,$);for(let D=1;a.path.length>D;D++)e.lineTo(a.path[D][0],a.path[D][1])}e.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=a.style.fillOpacity,e.fillStyle=("string"==typeof a.style.fill?yt(e,a.style.fill):a.style.fill)||a.style.fill,g&&!f)l.line().x(e=>e[0]).y(e=>e[1]).curve(g).context(e)(a.path);else{const[G,Y]=a.path[0];e.moveTo(G,Y);for(let q=1;a.path.length>q;q++)e.lineTo(a.path[q][0],a.path[q][1])}const W=a.path[0][0];e.lineTo(a.path[a.path.length-1][0],o.height),e.lineTo(W,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function kt(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function wt(e,t,n=.3){kt(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 At(e,t,n=.6){var o,r,i,s,a;if(!kt(t))return;const l=null!==(o=t._pulseGlowRadius)&&void 0!==o?o:4,c=t.r+l*t._pulseIntensity,u=null!==(i=null!==(r=t.cx)&&void 0!==r?r:t.x)&&void 0!==i?i:0,d=null!==(a=null!==(s=t.cy)&&void 0!==s?s:t.y)&&void 0!==a?a:0;e.beginPath(),e.arc(u,d,c,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function Ot(e,t,n,o=.35){kt(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill())}function St(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 jt(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 Mt(e,t){const n=St(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 Ct=(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=yt(e,t.style.stroke)||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(Mt(e,t),t.fillGradient&&("colorStops"in t.fillGradient&&t.fillGradient.colorStops.length>=2||"topOpacity"in t.fillGradient)&&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=e.createLinearGradient(0,o,0,r);if("colorStops"in t.fillGradient)for(const e of t.fillGradient.colorStops){const t=Math.max(0,Math.min(1,e.offset));isNaN(t)||i.addColorStop(t,e.color)}else if("topOpacity"in t.fillGradient){const e=jt("string"==typeof n?n:"#4e79a7");i.addColorStop(0,`rgba(${e[0]},${e[1]},${e[2]},${t.fillGradient.topOpacity})`),i.addColorStop(1,`rgba(${e[0]},${e[1]},${e[2]},${t.fillGradient.bottomOpacity})`)}e.fillStyle=i,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&&(Mt(e,t),Ot(e,t)),t.style.stroke&&"none"!==t.style.stroke){if(e.globalAlpha=a,!t.strokeGradient||2>t.strokeGradient.colorStops.length||2>t.topPath.length)e.strokeStyle=yt(e,t.style.stroke)||t.style.stroke;else{const n=e.createLinearGradient(t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0);for(const e of t.strokeGradient.colorStops)n.addColorStop(Math.max(0,Math.min(1,e.offset)),e.color);e.strokeStyle=n}e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const n=St(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}},Et=(e,t,n,o)=>{var r;const i=t.filter(e=>"point"===e.type);if(0!==i.length){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=("string"==typeof t.style.fill?yt(e,t.style.fill):t.style.fill)||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=("string"==typeof t.style.stroke?yt(e,t.style.stroke):t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),At(e,t),e.globalAlpha=1}}finally{e.restore()}}},_t=(e,t,n,o)=>{const r=t.filter(e=>"rect"===e.type);for(const t of r){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)Pt(e,t);else if(t.roundedTop&&t.roundedTop>0){e.fillStyle=("string"==typeof t.style.fill?yt(e,t.style.fill):t.style.fill)||"#007bff";const n=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:o,y:r,w:i,h:s}=t;switch(t.roundedEdge){case"right":e.moveTo(o,r),e.lineTo(o+i-n,r),e.arcTo(o+i,r,o+i,r+n,n),e.lineTo(o+i,r+s-n),e.arcTo(o+i,r+s,o+i-n,r+s,n),e.lineTo(o,r+s);break;case"left":e.moveTo(o+i,r),e.lineTo(o+n,r),e.arcTo(o,r,o,r+n,n),e.lineTo(o,r+s-n),e.arcTo(o,r+s,o+n,r+s,n),e.lineTo(o+i,r+s);break;case"bottom":e.moveTo(o,r),e.lineTo(o+i,r),e.lineTo(o+i,r+s-n),e.arcTo(o+i,r+s,o+i-n,r+s,n),e.lineTo(o+n,r+s),e.arcTo(o,r+s,o,r+s-n,n);break;default:e.moveTo(o,r+s),e.lineTo(o,r+n),e.arcTo(o,r,o+n,r,n),e.lineTo(o+i-n,r),e.arcTo(o+i,r,o+i,r+n,n),e.lineTo(o+i,r+s)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=yt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else e.fillStyle=("string"==typeof t.style.fill?yt(e,t.style.fill):t.style.fill)||"#007bff",e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=yt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h));wt(e,t),e.globalAlpha=1}};function Pt(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 Bt(e,t,n,o){return Object.assign(Object.assign(Object.assign({},function(e){return"object"!=typeof e||null===e||Array.isArray(e)?{}:e}(e)),{data:e,x:t,y:n,time:t,value:n}),o)}function Lt(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>128?"#000":"#fff"}function Nt(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}const It=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Tt(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`${It[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*n>t?e=>{const t=new Date(e);return`${It[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}const Ht={line:[Ct,xt,Et],area:[Ct,Et],stackedarea:[Ct,Et],scatter:[Et],bubble:[Et],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),wt(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const n=t.valueFormat?t.valueFormat(t.value):Nt(t.value),o=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),r=t.x+t.w/2,i=t.y+t.h/2;e.fillStyle=Lt(t.fill),e.font=o+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,r,i)}}}finally{e.restore()}}],bar:[_t],swarm:[Et],waterfall:[(e,t,n,o)=>{var r,i,s;_t(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;if(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(),t.isRange){const n=Math.max(2*t.wickWidth,4);e.fillStyle=t.wickColor,e.beginPath(),e.arc(t.x,t.highY,n,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,n,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const n=Math.min(t.openY,t.closeY),o=Math.abs(t.openY-t.closeY),r=t.isUp?t.upColor:t.downColor;e.fillStyle=r,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1)),e.strokeStyle=r,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1))}e.restore()}}],mixed:[Ct,xt,Et]},Ft={top:20,right:20,bottom:30,left:40},zt={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"},Rt={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 $t({hover:e}){const t=e=>Number.isInteger(e)?e+"":e.toFixed(2);return h.createElement("div",{className:"semiotic-tooltip",style:Rt},h.createElement("div",{style:{fontWeight:600,marginBottom:2}},t(e.value)),h.createElement("div",{style:{opacity:.7,fontSize:11}},t(e.time)))}const Dt=e.forwardRef(function(t,n){var o,r,i,s,a,l,c,u,d,g,f;const{chartType:p,runtimeMode:v,data:b,chunkThreshold:x,chunkSize:k,xAccessor:w,yAccessor:A,colorAccessor:O,sizeAccessor:S,groupAccessor:j,lineDataAccessor:M,curve:C,normalize:E,binSize:_,valueAccessor:P,arrowOfTime:B="right",windowMode:L="sliding",windowSize:N=200,timeAccessor:I,xExtent:T,yExtent:H,extentPadding:F=.1,scalePadding:z,sizeRange:R,size:$=[500,300],responsiveWidth:D,responsiveHeight:W,margin:G,className:q,background:X,lineStyle:V,pointStyle:K,areaStyle:J,waterfallStyle:Z,swarmStyle:ee,barColors:te,colorScheme:ne,boundsAccessor:oe,boundsStyle:ae,y0Accessor:le,gradientFill:ce,lineGradient:ue,areaGroups:de,openAccessor:he,highAccessor:ge,lowAccessor:fe,closeAccessor:pe,candlestickStyle:ye,showAxes:me=!0,axes:ve,xLabel:be,yLabel:xe,yLabelRight:ke,xFormat:we,yFormat:Ae,tickFormatTime:Oe,tickFormatValue:Se,hoverAnnotation:je,tooltipContent:Me,customHoverBehavior:Ce,customClickBehavior:Ee,enableHover:_e,hoverRadius:Pe=30,tooltipMode:Be,annotations:Le,svgAnnotationRules:Ne,showGrid:Ie,legend:He,legendHoverBehavior:Fe,legendClickBehavior:De,legendHighlightedCategory:We,legendIsolatedCategories:Ye,legendPosition:qe,backgroundGraphics:Xe,foregroundGraphics:Ve,canvasPreRenderers:Ue,svgPreRenderers:Qe,title:Ke,categoryAccessor:Je,brush:ot,onBrush:st,decay:at,pulse:lt,transition:ct,staleness:ut,heatmapAggregation:dt,heatmapXBins:ft,heatmapYBins:yt,showValues:mt,heatmapValueFormat:vt,marginalGraphics:bt,pointIdAccessor:xt,xScaleType:kt,yScaleType:wt,accessibleTable:At=!0,description:Ot,summary:St,linkedCrosshairName:jt,linkedCrosshairSourceId:Mt}=t,Ct=function(){const[t,n]=e.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return e.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return n(e.matches),function(e,t){return"function"==typeof e.addEventListener?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))}(e,e=>n(e.matches))},[]),t}(),Et=e.useRef(Ct);Et.current=Ct;const[_t,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]]]}($,D,W),Lt=Object.assign(Object.assign({},Ft),G);if(bt){const e=60;bt.top&&e>Lt.top&&(Lt.top=e),bt.bottom&&e>Lt.bottom&&(Lt.bottom=e),bt.left&&e>Lt.left&&(Lt.left=e),bt.right&&e>Lt.right&&(Lt.right=e)}const Nt=Pt[0]-Lt.left-Lt.right,It=Pt[1]-Lt.top-Lt.bottom,Rt="function"==typeof Ve?Ve({size:Pt,margin:Lt}):Ve,Dt="function"==typeof Xe?Xe({size:Pt,margin:Lt}):Xe,Wt=null!=je?je:_e,Gt=e.useRef(null),Yt=e.useRef(null),qt=e.useRef(0),Xt=e.useRef(!1),Vt=ht(e=>e.theme),[Ut,Qt]=e.useState(0),[Kt,Jt]=e.useState(null),Zt=e.useRef(null),en=e.useRef(null),[tn,nn]=e.useState(null),[on,rn]=e.useState(!1),[sn,an]=e.useState([]),[ln,cn]=e.useState([]),un=e.useRef(()=>{}),dn="streaming"===v||["bar","swarm","waterfall"].includes(p),hn=e.useMemo(()=>({chartType:p,runtimeMode:dn?"streaming":"bounded",windowSize:N,windowMode:L,arrowOfTime:dn?B:"right",extentPadding:F,scalePadding:z,xAccessor:dn?void 0:w,yAccessor:dn?void 0:A,timeAccessor:dn?I:void 0,valueAccessor:P,colorAccessor:O,sizeAccessor:S,groupAccessor:j||(M?"_lineGroup":void 0),categoryAccessor:Je,lineDataAccessor:M,xScaleType:kt,yScaleType:wt,xExtent:T,yExtent:H,sizeRange:R,binSize:_,normalize:E,boundsAccessor:oe,boundsStyle:ae,y0Accessor:le,gradientFill:!0===ce?{topOpacity:.8,bottomOpacity:.05}:!1===ce?void 0:ce,areaGroups:de?new Set(de):void 0,lineGradient:ue,openAccessor:he,highAccessor:ge,lowAccessor:fe,closeAccessor:pe,candlestickStyle:ye,lineStyle:V,pointStyle:K,areaStyle:J,swarmStyle:ee,waterfallStyle:Z,colorScheme:ne,barColors:te,annotations:Le,decay:at,pulse:lt,transition:ct,staleness:ut,heatmapAggregation:dt,heatmapXBins:ft,heatmapYBins:yt,showValues:mt,heatmapValueFormat:vt,pointIdAccessor:xt,curve:C}),[p,N,L,B,F,z,w,A,I,P,kt,wt,O,S,j,Je,M,T,H,R,_,E,oe,ae,le,ce,ue,de,he,ge,fe,pe,ye,V,K,J,ee,Z,ne,te,Le,at,lt,ct,ut,dt,ft,yt,mt,vt,dn,xt,C]),gn=e.useRef(null);gn.current||(gn.current=new Y(hn));const fn=e.useCallback(()=>{qt.current||(qt.current=requestAnimationFrame(()=>un.current()))},[]);e.useEffect(()=>{var e;null===(e=gn.current)||void 0===e||e.updateConfig(hn),Xt.current=!0,fn()},[hn,fn]),e.useEffect(()=>{Gt.current&&pt.delete(Gt.current),Xt.current=!0,fn()},[Vt,fn]);const pn=e.useRef(null);pn.current||(pn.current=new m(e=>{const t=gn.current;t&&t.ingest(e)&&(Xt.current=!0,fn())},{chunkThreshold:x,chunkSize:k})),e.useEffect(()=>{var e;null===(e=pn.current)||void 0===e||e.updateChunkOptions({chunkThreshold:x,chunkSize:k})},[x,k]);const yn=e.useCallback(e=>{var t;null===(t=pn.current)||void 0===t||t.push(e)},[]),mn=e.useCallback(e=>{var t;null===(t=pn.current)||void 0===t||t.pushMany(e)},[]),vn=e.useCallback(()=>{var e,t;null===(e=pn.current)||void 0===e||e.clear(),null===(t=gn.current)||void 0===t||t.clear(),Xt.current=!0,fn()},[fn]);e.useImperativeHandle(n,()=>({push:yn,pushMany:mn,remove:e=>{var t,n,o;null===(t=pn.current)||void 0===t||t.flush();const r=null!==(o=null===(n=gn.current)||void 0===n?void 0:n.remove(e))&&void 0!==o?o:[];return r.length>0&&(Zt.current&&r.some(e=>{var t;return e===(null===(t=Zt.current)||void 0===t?void 0:t.data)})&&(Zt.current=null,nn(null)),Xt.current=!0,fn()),r},update:(e,t)=>{var n,o,r;null===(n=pn.current)||void 0===n||n.flush();const i=null!==(r=null===(o=gn.current)||void 0===o?void 0:o.update(e,t))&&void 0!==r?r:[];return i.length>0&&(Xt.current=!0,fn()),i},clear:vn,getData:()=>{var e,t,n;return null===(e=pn.current)||void 0===e||e.flush(),null!==(n=null===(t=gn.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var e,t;return null!==(t=null===(e=gn.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=gn.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[yn,mn,vn,fn]),e.useEffect(()=>{var e,t;if(b){if(M&&b.length>0&&"object"==typeof b[0]&&null!==b[0]){const t="string"==typeof M?M:"coordinates";if(Array.isArray(b[0][t])){const n=[];for(const e of b){const o=e[t];if(Array.isArray(o)){const t=e.label||e.id||e.key;if(null!=t)for(const e of o)n.push(Object.assign(Object.assign({},e),{_lineGroup:t}));else for(const e of o)n.push(e)}}return void(null===(e=pn.current)||void 0===e||e.setBoundedData(n))}}null===(t=pn.current)||void 0===t||t.setBoundedData(b)}},[b,M]);const bn=e.useRef(()=>{}),xn=e.useRef(()=>{});bn.current=e=>{if(!Wt)return;const t=Gt.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Lt.left,r=e.clientY-n.top-Lt.top;if(0>o||o>Nt||0>r||r>It)return void(Zt.current&&(Zt.current=null,en.current=null,nn(null),Ce&&(Ce(null),Xt.current=!0),fn()));const i=gn.current;if(!i||0===i.scene.length)return;const s=U(i.scene,o,r,Pe,i.quadtree);if(!s)return void(Zt.current&&(Zt.current=null,en.current=null,nn(null),Ce&&Ce(null),fn()));const a=Bt(s.datum||{},s.x,s.y);if("multi"===Be&&i.scene.length>0&&i.scales){const e=function(e,t,n=30){const o=[];for(const r of e)if("line"===r.type){const e=r;if(2>e.path.length)continue;const i=Q(e.path,t,n);if(null===i)continue;const s=re(e.path,t);o.push({node:r,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:e.path[s][0],y:i,group:e.group,color:e.style.stroke})}else if("area"===r.type){const e=r;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const i=Q(e.topPath,t,n);if(null===i)continue;const s=re(e.topPath,t);o.push({node:r,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:e.topPath[s][0],y:i,group:e.group,color:"string"==typeof e.style.stroke?e.style.stroke:"string"==typeof e.style.fill?e.style.fill:void 0})}return o}(i.scene,s.x,Pe),t=i.scales.y.invert,n=i.scales.x.invert;if(e.length>0){const o=n?n(s.x):s.x;a.xValue=o,a.xPx=s.x,a.allSeries=e.map(e=>({group:e.group||"",value:t?t(e.y):e.y,valuePx:e.y,color:e.color||"#007bff",datum:e.datum}))}}Zt.current=a,en.current=s.node,nn(a),Ce&&(Ce(a),Xt.current=!0),fn()},xn.current=()=>{Zt.current&&(Zt.current=null,en.current=null,nn(null),Ce&&(Ce(null),Xt.current=!0),fn())},e.useCallback(e=>bn.current(e),[]);const kn=e.useCallback(()=>xn.current(),[]),wn=e.useRef(()=>{});wn.current=e=>{if(!Ee)return;const t=Gt.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Lt.left,r=e.clientY-n.top-Lt.top;if(0>o||o>Nt||0>r||r>It)return void Ee(null);const i=gn.current;if(!i||0===i.scene.length)return void Ee(null);const s=U(i.scene,o,r,Pe,i.quadtree);Ee(s?Bt(s.datum||{},s.x,s.y):null)};const An=e.useCallback(e=>wn.current(e),[]),On=e.useRef(-1),Sn=e.useRef(null),jn=e.useRef(null),Mn=e.useCallback(e=>{const t=gn.current;if(!t||0===t.scene.length)return;const n=t.version;let o;if(jn.current&&jn.current.version===n)o=jn.current.graph;else{const e=function(e){var t,n,o,r;const i=[];for(const s of e)switch(s.type){case"point":i.push({x:s.x,y:s.y,datum:s.datum,shape:"circle",group:null!==(t=s.group)&&void 0!==t?t:"_default"});break;case"line":{const e=s,t=Array.isArray(e.datum)?e.datum:[],o=null!==(n=e.group)&&void 0!==n?n:"_default";for(let n=0;e.path.length>n&&t.length>n;n++)i.push({x:e.path[n][0],y:e.path[n][1],datum:t[n],shape:"circle",group:o});break}case"area":{const e=s,t=Array.isArray(e.datum)?e.datum:[],n=null!==(o=e.group)&&void 0!==o?o:"_default";for(let o=0;e.topPath.length>o&&t.length>o;o++)i.push({x:e.topPath[o][0],y:e.topPath[o][1],datum:t[o],shape:"circle",group:n});break}case"rect":i.push({x:s.x+s.w/2,y:s.y+s.h/2,datum:s.datum,shape:"rect",w:s.w,h:s.h,group:null!==(r=s.group)&&void 0!==r?r:"_default"});break;case"heatcell":i.push({x:s.x+s.w/2,y:s.y+s.h/2,datum:s.datum,shape:"rect",w:s.w,h:s.h,group:"_default"})}return i.sort((e,t)=>e.x-t.x||e.y-t.y),i}(t.scene);if(0===e.length)return;o=function(e){var t,n;const o=new Map;for(const n of e){const e=null!==(t=n.group)&&void 0!==t?t:"_default";let r=o.get(e);r||(r=[],o.set(e,r)),r.push(n)}for(const e of o.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const r=Array.from(o.keys()).sort((e,t)=>{const n=o.get(e),r=o.get(t);return(n.length>0?n[0].y:0)-(r.length>0?r[0].y:0)}),i=Array.from(o.values()).flat();i.sort((e,t)=>e.x-t.x||e.y-t.y);const s=new Map;for(let e=0;i.length>e;e++){i[e]._flatIndex=e;const t=null===(n=i[e].datum)||void 0===n?void 0:n.id;null!=t&&s.set(t+"",e)}return{flat:i,groups:r,byGroup:o,idToIdx:s}}(e),jn.current={version:n,graph:o}}const r=On.current;if(0>r){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),On.current=0;const t=o.flat[0];Sn.current={shape:t.shape,w:t.w,h:t.h};const n=se(t);return Zt.current=n,nn(n),Ce&&Ce(n),void fn()}const i=function(e,t){var n,o;if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const r=Math.max(0,Math.min(t,e.flat.length-1)),i=e.flat[r];return{flatIndex:r,group:null!==(n=i.group)&&void 0!==n?n:"_default",indexInGroup:null!==(o=i._groupIndex)&&void 0!==o?o:0}}(o,r),s=function(e,t,n){const{group:o,indexInGroup:r}=t,i=n.byGroup.get(o);switch(e){case"ArrowRight":return i.length-1>r?i[r+1]._flatIndex:t.flatIndex;case"ArrowLeft":return r>0?i[r-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(o);return n.groups.length-1>e?ie(n,n.groups[e+1],i[r]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(o);return e>0?ie(n,n.groups[e-1],i[r]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}(e.key,i,o);if(null===s)return;if(e.preventDefault(),0>s)return On.current=-1,Sn.current=null,Zt.current=null,en.current=null,nn(null),Ce&&Ce(null),void fn();On.current=s;const a=o.flat[s];Sn.current={shape:a.shape,w:a.w,h:a.h};const l=se(a);Zt.current=l,nn(l),Ce&&Ce(l),fn()},[Ce,fn]),Cn=e.useCallback(e=>{On.current=-1,Sn.current=null,bn.current(e)},[]);un.current=()=>{var e,t;qt.current=0;const n=Gt.current,o=Yt.current;if(!n||!o)return;const r=gn.current;if(!r)return;const i="undefined"!=typeof performance?performance.now():Date.now(),s=r.advanceTransition(Et.current?i+1e6:i),a=!Et.current&&s,l=Xt.current||s;l&&!a&&r.computeScene({width:Nt,height:It});const c="undefined"!=typeof window&&window.devicePixelRatio||1,u=function(e){if(!e)return zt;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||zt.axisStroke,tickText:i||zt.tickText,crosshair:i?i+"66":zt.crosshair,hoverFill:l?l+"4D":zt.hoverFill,hoverStroke:i?i+"99":zt.hoverStroke,pointRing:l||zt.pointRing}:zt}(n),d=null!==(e=null==ut?void 0:ut.threshold)&&void 0!==e?e:5e3,h=ut&&r.lastIngestTime>0&&i-r.lastIngestTime>d;if(l){const e=gt(n,Pt,Lt,c);if(e){e.clearRect(-Lt.left,-Lt.top,Pt[0],Pt[1]),h&&(e.globalAlpha=null!==(t=null==ut?void 0:ut.dimOpacity)&&void 0!==t?t:.5);const o=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=X||(o&&"transparent"!==o?o:null);if(i&&(e.fillStyle=i,e.fillRect(-Lt.left,-Lt.top,Pt[0],Pt[1])),e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,Nt,It),e.clip()),Ue&&r.scales)for(const t of Ue)e.save(),t(e,r.scene,r.scales,{width:Nt,height:It}),e.restore();const s=Ht[p];if(s&&r.scales)for(const t of s)t(e,r.scene,r.scales,{width:Nt,height:It});e.restore(),h&&(e.globalAlpha=1)}}{const e=gt(o,Pt,Lt,c);if(e&&(e.clearRect(-Lt.left,-Lt.top,Pt[0],Pt[1]),Wt&&Zt.current&&r.scales&&function(e,t,n,o,r,i,s){var a,l;if(!1===r.crosshair)return;const c=t.allSeries,u=c&&c.length>0,d=null!==(a=t.xPx)&&void 0!==a?a:t.x;e.save();const h="object"==typeof r.crosshair?r.crosshair:{};if(e.strokeStyle=h.stroke||s.crosshair,e.lineWidth=h.strokeWidth||1,e.setLineDash(h.strokeDasharray?h.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(u?d:t.x,0),e.lineTo(u?d:t.x,o),e.stroke(),u||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke()),e.restore(),u){e.lineWidth=2,e.strokeStyle=s.pointRing;for(const t of c)null!=t.valuePx&&(e.beginPath(),e.arc(d,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||"#007bff",e.fill(),e.stroke())}else{let n="";try{(null===(l=e.canvas)||void 0===l?void 0:l.parentElement)&&(n=getComputedStyle(e.canvas).getPropertyValue("--semiotic-primary").trim())}catch(e){}const o=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)||n||"#007bff";e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=o,e.fill(),e.strokeStyle=s.pointRing,e.lineWidth=2,e.stroke()}}(e,Zt.current,Nt,It,"object"==typeof Wt?Wt:{},en.current,u),en.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,en.current,t)}}l&&n&&n.setAttribute("aria-label",Ge(r.scene,p+" chart"));const g=Xt.current;if(Xt.current=!1,g&&r.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!Kt||e(Kt.x.domain()[0])!==e(r.scales.x.domain()[0])||e(Kt.x.domain()[1])!==e(r.scales.x.domain()[1])||e(Kt.y.domain()[0])!==e(r.scales.y.domain()[0])||e(Kt.y.domain()[1])!==e(r.scales.y.domain()[1])||Kt.x.range()[0]!==r.scales.x.range()[0]||Kt.x.range()[1]!==r.scales.x.range()[1]||Kt.y.range()[0]!==r.scales.y.range()[0]||Kt.y.range()[1]!==r.scales.y.range()[1])&&Jt(r.scales),bt){const e=r.getData(),t="function"==typeof w?w:e=>e[w||"x"],n="function"==typeof A?A:e=>e[A||"y"];an(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),cn(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}g&&Le&&Le.length>0&&Qt(e=>e+1),(null==ut?void 0:ut.showBadge)&&rn(!!h),(a||r.hasActivePulses)&&(qt.current=requestAnimationFrame(()=>un.current()))},e.useEffect(()=>(fn(),()=>{qt.current&&(cancelAnimationFrame(qt.current),qt.current=0)}),[fn]),e.useEffect(()=>{Xt.current=!0,fn()},[p,Nt,It,me,X,V,Ue,fn]),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])}(ut,gn,Xt,fn,on,rn);const En=e.useMemo(()=>{if(we||Oe)return;const e=gn.current;return(null==e?void 0:e.xIsDate)&&Kt?Tt(Kt.x.domain()):void 0},[we,Oe,Kt]),_n=we||Oe||En,Pn=Wt&&tn?Me?Me(tn):h.createElement($t,{hover:tn}):null,Bn=Pn?h.createElement(it,{x:tn.x,y:tn.y,containerWidth:Nt,containerHeight:It,margin:Lt,className:"stream-frame-tooltip"},Pn):null,Ln=Sn.current,Nn=h.createElement(rt,{active:On.current>=0,hoverPoint:tn,margin:Lt,size:Pt,shape:null==Ln?void 0:Ln.shape,width:null==Ln?void 0:Ln.w,height:null==Ln?void 0:Ln.h}),In=(e,t,n,o)=>"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:n,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:o,fn:t}:{key:void 0,fn:null},Tn=In(w,I,"__semiotic_resolvedX","__semiotic_resolvedTime"),Hn=In(A,P,"__semiotic_resolvedY","__semiotic_resolvedValue"),Fn=Tn.key,zn=Hn.key,Rn=Le&&Le.length>0,$n=e=>{if(!e||!Rn||!Tn.fn&&!Hn.fn)return e;let t=!1;const n=e.map(e=>{const n=Tn.fn&&Tn.key&&!(Tn.key in e),o=Hn.fn&&Hn.key&&!(Hn.key in e);if(!n&&!o)return e;t=!0;const r=Object.assign({},e);return n&&(r[Tn.key]=Tn.fn(e)),o&&(r[Hn.key]=Hn.fn(e)),r});return t?n:e};if($e){const e=gn.current;e&&b&&(e.ingest({inserts:b,bounded:!0}),e.computeScene({width:Nt,height:It}));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=_n||(()=>{if((null==e?void 0:e.xIsDate)&&n)return Tt(n.x.domain())})();return h.createElement("div",{className:"stream-xy-frame"+(q?" "+q:""),role:"img","aria-label":Ot||("string"==typeof Ke?Ke:"XY chart"),style:{position:"relative",width:Pt[0],height:Pt[1]}},h.createElement(et,{summary:St}),h.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Pt[0],height:Pt[1],style:{position:"absolute",left:0,top:0}},h.createElement("g",{transform:`translate(${Lt.left},${Lt.top})`},Dt),h.createElement("g",{transform:`translate(${Lt.left},${Lt.top})`},X&&h.createElement("rect",{x:0,y:0,width:Nt,height:It,fill:X}),Qe&&n&&Qe.map((e,o)=>h.createElement(h.Fragment,{key:"svgpre-"+o},e(t,n,{width:Nt,height:It}))),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 h.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 h.createElement("path",{key:"area-"+t,d:`M${i}L${s}Z`,fill:Re(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 h.createElement("circle",{key:"point-"+t,cx:n.x,cy:n.y,r:n.r,fill:Re(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 h.createElement("rect",{key:"rect-"+t,x:n.x,y:n.y,width:n.w,height:n.h,fill:Re(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 h.createElement("g",{key:"heatcell-"+t},h.createElement("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),h.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 h.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 h.createElement("g",{key:"candle-"+t},h.createElement("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),h.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))),h.createElement(ze,{width:Nt,height:It,totalWidth:Pt[0],totalHeight:Pt[1],margin:Lt,scales:n,showAxes:me,axes:ve,xLabel:be,yLabel:xe,yLabelRight:ke,xFormat:i,yFormat:Ae||Se,showGrid:Ie,title:Ke,legend:He,legendHoverBehavior:Fe,legendClickBehavior:De,legendHighlightedCategory:We,legendIsolatedCategories:Ye,legendPosition:qe,foregroundGraphics:Rt,marginalGraphics:bt,xValues:[],yValues:[],annotations:Le,svgAnnotationRules:Ne,annotationFrame:0,xAccessor:Fn,yAccessor:zn,annotationData:$n(null==e?void 0:e.getData()),pointNodes:null==e?void 0:e.scene.filter(e=>"point"===e.type),curve:"string"==typeof C?C:void 0,linkedCrosshairName:jt,linkedCrosshairSourceId:Mt}))}const Dn="semiotic-table-"+h.useId();return h.createElement("div",{ref:_t,className:"stream-xy-frame"+(q?" "+q:""),role:"group","aria-label":Ot||("string"==typeof Ke?Ke:"XY chart"),tabIndex:0,style:{position:"relative",width:D?"100%":Pt[0],height:W?"100%":Pt[1],overflow:"visible"},onKeyDown:Mn},At&&h.createElement(tt,{tableId:Dn}),At&&h.createElement(Ze,{scene:null!==(s=null===(i=gn.current)||void 0===i?void 0:i.scene)&&void 0!==s?s:[],chartType:p+" chart",tableId:Dn,chartTitle:"string"==typeof Ke?Ke:void 0}),h.createElement(et,{summary:St}),h.createElement("div",{role:"img","aria-label":Ot||("string"==typeof Ke?Ke:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Wt?Cn:void 0,onMouseLeave:Wt?kn:void 0,onClick:Ee?An:void 0},Dt&&h.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Pt[0],height:Pt[1],pointerEvents:"none"}},h.createElement("g",{transform:`translate(${Lt.left},${Lt.top})`},Dt)),h.createElement(Te,{width:Nt,height:It,totalWidth:Pt[0],totalHeight:Pt[1],margin:Lt,scales:Kt,showAxes:me,axes:ve,showGrid:Ie,xFormat:_n,yFormat:Ae||Se}),h.createElement("canvas",{ref:Gt,"aria-label":Ge(null!==(l=null===(a=gn.current)||void 0===a?void 0:a.scene)&&void 0!==l?l:[],p+" chart"),style:{position:"absolute",left:0,top:0}}),h.createElement("canvas",{ref:Yt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),h.createElement(nt,{hoverPoint:tn}),h.createElement(ze,{width:Nt,height:It,totalWidth:Pt[0],totalHeight:Pt[1],margin:Lt,scales:Kt,showAxes:me,axes:ve,xLabel:be,yLabel:xe,yLabelRight:ke,xFormat:_n,yFormat:Ae||Se,showGrid:Ie,title:Ke,legend:He,legendHoverBehavior:Fe,legendClickBehavior:De,legendHighlightedCategory:We,legendIsolatedCategories:Ye,legendPosition:qe,foregroundGraphics:Rt,marginalGraphics:bt,xValues:sn,yValues:ln,annotations:Le,svgAnnotationRules:Ne,annotationFrame:Ut,xAccessor:Fn,yAccessor:zn,annotationData:$n(null===(c=gn.current)||void 0===c?void 0:c.getData()),pointNodes:null===(u=gn.current)||void 0===u?void 0:u.scene.filter(e=>"point"===e.type),curve:"string"==typeof C?C:void 0,underlayRendered:!0,linkedCrosshairName:jt,linkedCrosshairSourceId:Mt}),(ot||st)&&h.createElement(y,{width:Nt,height:It,totalWidth:Pt[0],totalHeight:Pt[1],margin:Lt,dimension:null!==(d=null==ot?void 0:ot.dimension)&&void 0!==d?d:"xy",scales:Kt,onBrush:null!=st?st:()=>{},binSize:_,snap:null==ot?void 0:ot.snap,binBoundaries:null!==(g=null==ot?void 0:ot.binBoundaries)&&void 0!==g?g:"bar"===p?null===(f=gn.current)||void 0===f?void 0:f.getBinBoundaries():void 0,snapDuring:null==ot?void 0:ot.snapDuring,streaming:"streaming"===v}),(null==ut?void 0:ut.showBadge)&&h.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ut.badgePosition?{top:4,left:4}:"bottom-left"===ut.badgePosition?{bottom:4,left:4}:"bottom-right"===ut.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:on?"#dc3545":"#28a745",color:"white"})},on?"STALE":"LIVE"),Nn,Bn))});Dt.displayName="StreamXYFrame";const Wt=e.createContext(null);function Gt(){return e.useContext(Wt)}function Yt(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 qt(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[Xt,Vt]=st(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),r=qt(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=qt(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}})}})),[Ut,Qt]=st(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 Kt(t){const n=e.useId(),o=t.clientId||n,{name:r}=t,i=Vt(e=>e.selections.get(r)),s=Vt(e=>e.setClause),a=Vt(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(Yt(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 Jt(t){const n=t.name||"hover",{fields:o}=t,{predicate:r,isActive:i,selectPoints:s,clear:a}=Kt({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 Zt(t){const{name:n,xField:o,yField:r}=t,{predicate:i,isActive:s,selectInterval:a,clear:l}=Kt({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 en=e.createContext(!1);function tn({selections:t}){const n=Vt(e=>e.setResolution);return e.useEffect(()=>{for(const[e,o]of Object.entries(t))o.resolution&&n(e,o.resolution)},[t,n]),null}function nn({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=Jt({name:o,fields:[r]}),c=Kt({name:o,clientId:"__linked-legend-isolate__"}),[u,d]=e.useState(new Set),[g,f]=e.useState(null),p=e.useRef(c.selectPoints);p.current=c.selectPoints;const y=e.useRef(c.clear);y.current=c.clear,e.useEffect(()=>{"isolate"===n&&(u.size>0?p.current({[r]:Array.from(u)}):y.current())},[n,u,r]);const m=e.useCallback(e=>{"highlight"===n&&(e?(f(e.label),l.onHover({[r]:e.label})):(f(null),l.onHover(null)))},[n,r,l]),v=e.useCallback(e=>{"isolate"===n&&d(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===s.length?new Set:n})},[n,s.length]);return h.createElement("svg",{width:"100%",height:30,style:{display:"block",overflow:"visible"}},h.createElement(he,{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 on({children:e,selections:t,showLegend:n,legendPosition:o="top",legendInteraction:r="none",legendSelectionName:i="legend",legendField:s="category"}){const a=Gt(),l=void 0!==n?n:!(!a||0>=Object.keys(a).length);return h.createElement(Xt,null,h.createElement(Ut,null,t&&h.createElement(tn,{selections:t}),h.createElement(en.Provider,{value:l},l&&"top"===o&&a&&h.createElement(nn,{categoryColors:a,interaction:r,selectionName:i,field:s}),e,l&&"bottom"===o&&a&&h.createElement(nn,{categoryColors:a,interaction:r,selectionName:i,field:s}))))}function rn({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):M[i%M.length];return{label:r+"",color:a}}),label:""}]}}function sn(e){return e?"string"==typeof e?{name:e}:e:null}function an(e,t,n){return t?o=>{var r;const i=Object.assign({},e(o));if(t.isActive)if(t.predicate(o))(null==n?void 0:n.selectedStyle)&&Object.assign(i,n.selectedStyle);else{const e=null!==(r=null==n?void 0:n.unselectedOpacity)&&void 0!==r?r:.2;i.opacity=e,i.fillOpacity=e,i.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(i,n.unselectedStyle)}return i}:e}h.createContext(void 0);const ln="#007bff";function cn(){var e;const t=ht(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}function un(e){return"function"==typeof e?e:t=>t[e]}function dn(t,n,o){const r=Gt(),i=cn();return e.useMemo(()=>{var e;if(!n)return;const s=null!==(e=null!=o?o:i&&i.length>0?i:void 0)&&void 0!==e?e:"category10";if(0!==t.length){if("function"==typeof n){const e=Array.from(new Set(t.map(e=>n(e)+"")));if(r&&Object.keys(r).length>0){const t=_(e.map(e=>({_cat:e})),"_cat",s);return e=>r[e]||t(e)}return _(e.map(e=>({_cat:e})),"_cat",s)}if(r&&Object.keys(r).length>0){const e=_(t,n,s);return t=>r[t]||e(t)}return _(t,n,s)}if(r&&Object.keys(r).length>0){const e=_([{_:"a"}],"_",s);return t=>r[t]||e(t)}},[t,n,o,r,i])}function hn({selection:t,linkedHover:n,fallbackFields:o=[],unwrapData:r=!1,onObservation:i,chartType:s,chartId:a,onClick:l,hoverHighlight:c,colorByField:u}){const d=e.useId(),h=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||t||[],mode:e.mode,xField:e.xField}:null}(n,o),g=Kt({name:(null==t?void 0:t.name)||"__unused__"}),f=Jt({name:(null==h?void 0:h.name)||"hover",fields:(null==h?void 0:h.fields)||o||[]}),p=Qt(e=>e.pushObservation),y=t?{isActive:g.isActive,predicate:g.predicate}:null,[m,v]=e.useState(null),b=u||o[0],x=e.useMemo(()=>{if(!c||null==m||!b)return null;const e=m,t=b;return{isActive:!0,predicate:n=>{var o;return("string"==typeof n[t]?n[t]:(null!==(o=n[t])&&void 0!==o?o:"")+"")===e}}},[c,m,b]),k=e.useCallback(e=>{var t,o;if(n)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===(null==h?void 0:h.mode)&&h.xField){const e=null==t?void 0:t[h.xField];null!=e&&Number.isFinite(Number(e))&&function(e,t,n){const o=Oe.positions.get(e);(null==o?void 0:o.locked)||o&&o.xValue===t&&o.sourceId===n||(Oe={positions:new Map(Oe.positions).set(e,{xValue:t,sourceId:n})},je())}(h.name||"hover",Number(e),d)}"x-position"!==(null==h?void 0:h.mode)&&f.onHover(t)}else"x-position"===(null==h?void 0:h.mode)&&Me(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&f.onHover(null);if(c&&b)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[b];v(null!=n?n+"":null)}else v(null);if(i||p){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),p&&p(s)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(e),p&&p(e)}}},[n,f,h,d,i,s,a,p,c,b]),w=e.useCallback(e=>{var t,n,o,r;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[h.xField];null!=n&&Number.isFinite(Number(n))&&function(e,t,n){const o=Oe.positions.get(e);if(null==o?void 0:o.locked){const t=new Map(Oe.positions);return t.delete(e),Oe={positions:t},je(),!1}Oe={positions:new Map(Oe.positions).set(e,{xValue:t,sourceId:n,locked:!0})},je()}(h.name||"hover",Number(n),d)}if(e&&l){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]),l(o,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0})}if(i||p){const t={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){let n=e.data||e.datum||e;Array.isArray(n)&&(n=n[0]);const s=Object.assign(Object.assign({},t),{type:"click",datum:n||{},x:null!==(o=e.x)&&void 0!==o?o:0,y:null!==(r=e.y)&&void 0!==r?r:0});i&&i(s),p&&p(s)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});i&&i(e),p&&p(e)}}},[l,i,p,s,a,h,d]);return e.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const e=h.name||"hover";return()=>{Ce(e,d),Me(e,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:y,hoverSelectionHook:x,customHoverBehavior:k,customClickBehavior:w,crosshairSourceId:d}}function gn(e,t){const n="object"==typeof e&&null!==e?e:void 0;if("x-position"===(null==n?void 0:n.mode))return{linkedCrosshairName:n.name||"hover",linkedCrosshairSourceId:t}}function fn({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(en),u=void 0!==r?r:!c&&!!n,d=e.useMemo(()=>{if(u&&n)return rn({data:t,colorBy:n,colorScale:o,getColor:E,categories:l})},[u,n,t,o,l]),h=e.useMemo(()=>{const e=Object.assign(Object.assign({},a),s);return d&&("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,d,i]);return{legend:d,margin:h,legendPosition:i}}function pn(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 yn={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 mn(e,t,n){var o,r,i,s,a,l,c;const u=yn[e||"primary"],d="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:e&&"primary"!==e||!(null==n?void 0:n.width)?u.width:n.width,height:null!==(r=t.height)&&void 0!==r?r:e&&"primary"!==e||!(null==n?void 0:n.height)?u.height:n.height,showAxes:null!==(i=t.showAxes)&&void 0!==i?i:u.showAxes,showGrid:null!==(s=t.showGrid)&&void 0!==s?s:u.showGrid,enableHover:null!==(a=t.enableHover)&&void 0!==a?a:!!t.linkedHover||u.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:u.showLegend,showLabels:null!==(c=t.showLabels)&&void 0!==c?c:u.showLabels,title:d?void 0:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:d?void 0:t.xLabel,yLabel:d?void 0:t.yLabel,categoryLabel:d?void 0:t.categoryLabel,valueLabel:d?void 0:t.valueLabel,marginDefaults:vn(u.marginDefaults,t.showCategoryTicks,t.orientation)}}function vn(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 bn={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 xn(e,t){return"function"==typeof t?t(e):e[t]}function kn(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return 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 wn(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=xn(e,n);s=kn(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=xn(e,r);a.push({label:n,value:kn(s,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){s=kn(e[n],o);break}if(!s){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(s=kn(e[t[0]],o))}}const l=Object.assign(Object.assign({},bn),r);return h.createElement("div",{className:("semiotic-tooltip "+i).trim(),style:l},s&&h.createElement("div",{style:{fontWeight:a.length>0?"bold":"normal"}},s),a.map((e,t)=>h.createElement("div",{key:t,style:{marginTop:0===t&&s?"4px":0}},e.label&&h.createElement("span",null,e.label,": "),e.value)))}}function An(e){if(!0===e)return wn();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:h.createElement("div",{className:"semiotic-tooltip",style:bn},n)}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?wn(e):wn())}function On(e){return"string"==typeof e?e:"value"}function Sn(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function jn(e,t){return"function"==typeof t?t(e):e[t]}function Mn(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?Sn(jn(o,t.accessor)):null;return h.createElement("div",{className:"semiotic-tooltip",style:bn},r&&h.createElement("div",{style:{fontWeight:"bold",marginBottom:n.length>0?4:0}},r),n.map((e,t)=>{const n=Sn(jn(o,e.accessor));return h.createElement("div",{key:t,style:t>0?{marginTop:2}:void 0},h.createElement("span",{style:{opacity:.7}},e.label,": "),h.createElement("span",null,n))}))}}function Cn({componentName:e,message:t,diagnosticHint:n,width:o,height:r}){return h.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"}},h.createElement("div",{style:{textAlign:"center",maxWidth:400}},h.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),h.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t),n&&h.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 En extends h.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:h.createElement(Cn,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function _n(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 Pn(e,t,n=3){let o,r=n+1;for(const n of t){const t=_n(e.toLowerCase(),n.toLowerCase());r>t&&(r=t,o=n)}return r>n?void 0:o}function Bn(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function Ln(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=Pn(e,t,3))&&void 0!==n?n:null)}function Nn({componentName:e,data:t,accessors:n,requiredProps:o}){if(o)for(const[t,n]of Object.entries(o))if(null==n)return`${e}: ${t} is required. Provide a field name or function.`;if(null==t)return null;if(!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(n){const o=Bn(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=Ln(i,t),o=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}const In={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"},onClick:{type:"function"}},Tn={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},Hn={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"}},Fn=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],zn=["vertical","horizontal"],Rn={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Tn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Fn},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({},In),Tn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Fn},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Tn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Fn},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({},In),Tn),{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({},In),Tn),{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({},In),Tn),{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({},In),Tn),{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({},In),Tn),{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({},In),Tn),{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({},In),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:zn},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:zn},normalize:{type:"boolean"},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},LikertChart:{required:["levels"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor","levelAccessor","countAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},levelAccessor:{type:["string","function"]},countAccessor:{type:["string","function"]},levels:{type:"array"},orientation:{type:"string",enum:zn},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:zn},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:zn},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:zn},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:zn},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},RidgelinePlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Hn),{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({},In),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:zn},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},In),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"},cornerRadius:{type:"number"}})},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},In),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"},cornerRadius:{type:"number"}})},GaugeChart:{required:["value"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},In),{value:{type:"number"},min:{type:"number"},max:{type:"number"},thresholds:{type:"array"},arcWidth:{type:"number"},sweep:{type:"number"},showNeedle:{type:"boolean"},needleColor:{type:"string"},centerContent:{type:["object","string","number","function"]},valueFormat:{type:"function"},showScaleLabels:{type:"boolean"},backgroundColor:{type:"string"}})},FunnelChart:{required:["data"],dataShape:"array",dataAccessors:["stepAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Hn),{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"]}})},SwimlaneChart:{required:["subcategoryAccessor"],dataShape:"array",dataAccessors:["categoryAccessor","subcategoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},subcategoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},barPadding:{type:"number"},showCategoryTicks:{type:"boolean"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},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({},In),{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({},In),{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:zn},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({},In),{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({},In),{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({},In),{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({},In),{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({},In),{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"},brush:{type:["boolean","string","object"]},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},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"}}},ScatterplotMatrix:{required:["data","fields"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},In),{data:{type:"array"},fields:{type:"array"}})},MinimapChart:{required:["data"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},In),{data:{type:"array"}})},ChoroplethMap:{required:["areas"],dataShape:"array",dataAccessors:["valueAccessor"],props:Object.assign(Object.assign({},In),{areas:{type:["array","string"]},valueAccessor:{type:["string","function"]},colorScheme:{type:["string","array"]},projection:{type:"string"}})},ProportionalSymbolMap:{required:["points"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign({},In),{points:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},areas:{type:["array","string"]}})},FlowMap:{required:["flows"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},In),{flows:{type:"array"},nodes:{type:"array"},valueAccessor:{type:["string","function"]}})},DistanceCartogram:{required:["points"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},In),{points:{type:"array"},center:{type:"array"},costAccessor:{type:["string","function"]}})}};function $n(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}const Dn=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),Wn=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),Gn=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),Yn=new Set(["LineChart","AreaChart","StackedAreaChart"]),qn=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]);function Xn(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 Vn(e,t){const n=Xn(e),o=Xn(t);return null===n||null===o?null:(Math.max(n,o)+.05)/(Math.min(n,o)+.05)}const Un=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIDAccessor","childrenAccessor","costAccessor"];function Qn(e,t){const n=[],o=function(e,t){const n=[],o=Rn[e];if(!o)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(Rn).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(!$n(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=Pn(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=Nn({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=Bn(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=Ln(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 Rn[e]?(function(e,t,n){const o=Rn[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=Rn[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){Dn.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){Wn.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=Rn[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(!Gn.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(!Yn.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=Rn[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(!qn.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=Vn(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=t.colorScheme;if(!o||!Array.isArray(o)||2>o.length)return;const r=o.filter(e=>"string"==typeof e&&e.startsWith("#"));if(2>r.length)return;const i=[];for(let e=0;r.length-1>e;e++){const t=Vn(r[e],r[e+1]);null!==t&&1.5>t&&i.push(`${r[e]} / ${r[e+1]} (${t.toFixed(1)}:1)`)}i.length>0&&n.push({severity:"warning",code:"LOW_ADJACENT_CONTRAST",message:`${i.length} adjacent color pair(s) in colorScheme have very similar luminance: ${i.join("; ")}. Categories may be hard to distinguish.`,fix:'Alternate light and dark colors in the scheme, or use COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for a pre-tested palette.'})}(0,t,n),function(e,t,n){const o="string"==typeof t.title&&t.title.trim().length>0,r="string"==typeof t.description&&t.description.trim().length>0,i="string"==typeof t.summary&&t.summary.trim().length>0;o||r||i||n.push({severity:"warning",code:"MISSING_DESCRIPTION",message:'No title, description, or summary provided. Screen readers will use a generic label like "XY chart".',fix:'Add a title="..." prop for a brief label, or description="..." for a detailed aria-label, or summary="..." for a screen-reader-only note describing the chart\'s purpose.'})}(0,t,n),function(e,t,n){const o=[];for(const e of Un)"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 Kn;const Jn="undefined"!=typeof process&&"production"!==(null===(Kn=process.env)||void 0===Kn?void 0:Kn.NODE_ENV);function Zn({componentName:e,width:t,height:n,chartProps:o,children:r}){return h.createElement(En,{fallback:r=>{let i="";if(Jn&&o)try{const t=Qn(e,o);t.ok||(i=t.diagnoses.map(e=>`${"error"===e.severity?"✗":"⚠"} ${e.message}${e.fix?" — Fix: "+e.fix:""}`).join("\n"))}catch(e){}return h.createElement(Cn,{componentName:e,message:r.message,diagnosticHint:i,width:t,height:n})}},r)}const eo={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"},to={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function no(e,t,n,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?h.createElement("div",{style:Object.assign(Object.assign({},eo),{width:t,height:n})},o||"No data available"):null}function oo(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 h.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)=>h.createElement("div",{key:n,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},to),{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 ro(e,t,n,o){if(!Jn)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 io(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 so="__forecastSegment";let ao=null;function lo(){return io(this,void 0,void 0,function*(){return ao||(ao=yield Promise.resolve().then(function(){return Ro})),ao})}const co=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)},remove:e=>{var t,n;return null!==(n=null===(t=i.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=i.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},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=mn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:t.xLabel,yLabel:t.yLabel}),{data:a,margin:l,className:c,xFormat:u,yFormat:d,xAccessor:g="x",yAccessor:f="y",lineBy:p,lineDataAccessor:y="coordinates",colorBy:m,colorScheme:v,curve:b="linear",showPoints:x=!1,pointRadius:k=3,fillArea:w=!1,areaOpacity:A=.3,lineWidth:O=2,lineGradient:S,tooltip:j,pointIdAccessor:M,annotations:C,directLabel:_,gapStrategy:P="break",anomaly:B,forecast:L,frameProps:N={},selection:I,linkedHover:T,onObservation:H,onClick:F,hoverHighlight:z,hoverRadius:R,chartId:$,loading:D,emptyContent:W,legendInteraction:G,legendPosition:Y,xScaleType:q,yScaleType:X,color:V}=t,U=s.width,Q=s.height,K=s.enableHover,J=s.showGrid,Z=s.showLegend,ee=s.title,te=s.description,ne=s.summary,oe=s.accessibleTable,re=s.xLabel,ie=s.yLabel,se=oo(D,U,Q),ae=se?null:no(a,U,Q,W),le=a||[];ro("LineChart",le,"xAccessor",g),ro("LineChart",le,"yAccessor",f);const ce="string"==typeof g?g:"__semiotic_resolvedX",ue="string"==typeof f?f:"__semiotic_resolvedY",[de,he]=e.useState(null),[ge,fe]=e.useState([]),pe=e.useMemo(()=>{if(!L&&!B)return le;const e="function"==typeof g,t="function"==typeof f;return e||t?le.map(n=>{const o=Object.assign({},n);return e&&(o.__semiotic_resolvedX=g(n)),t&&(o.__semiotic_resolvedY=f(n)),o}):le},[le,L,B,g,f]),ye=e.useRef(L),me=e.useRef(B);e.useEffect(()=>{if(!L&&!B)return void((ye.current||me.current)&&(he(null),fe([]),ye.current=L,me.current=B));let e=!1;const t=L!==ye.current||B!==me.current;if(ye.current=L,me.current=B,t&&(he(null),fe([])),L){const t=p&&"string"==typeof p&&"object"==typeof L?Object.assign(Object.assign({},L),{_groupBy:p}):L;(function(...e){return io(this,void 0,void 0,function*(){return(yield lo()).buildForecast(...e)})})(pe,ce,ue,t,B).then(t=>{e||(he(t),fe(t.annotations))}).catch(()=>{e||(he(null),fe([]))})}else B&&function(...e){return io(this,void 0,void 0,function*(){return(yield lo()).buildAnomalyAnnotations(...e)})}(B).then(t=>{e||(he(null),fe(t))}).catch(()=>{e||fe([])});return()=>{e=!0}},[pe,L,B,ce,ue]);const ve=de?de.processedData:le,be="__compoundGroup",xe=!(!L||!p),ke=xe?be:L?so:p,we=e.useMemo(()=>{if(!xe)return ve;const e="function"==typeof p?p:e=>e[p];return ve.map(t=>{const n=Object.assign({},t);return n[be]=`${e(t)}__${t[so]||"observed"}`,n})},[ve,xe,p]),Ae=xe?we:ve,Oe=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=de?de.processedData:le;for(const e of s){const t="function"==typeof f?f(e):+e[f];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,de,le,f]),{activeSelectionHook:Se,hoverSelectionHook:je,customHoverBehavior:Me,customClickBehavior:Ce,crosshairSourceId:Ee}=hn({selection:I,linkedHover:T,fallbackFields:m?["string"==typeof m?m:""]:[],onObservation:H,onClick:F,chartType:"LineChart",chartId:$,hoverHighlight:z,colorByField:"string"==typeof m?m:void 0}),_e=gn(T,Ee),Pe=e.useCallback(e=>{const t="function"==typeof g?g(e):e[g],n="function"==typeof f?f(e):e[f];return null==t||null==n||Number.isNaN(t)||Number.isNaN(n)},[g,f]),Be=void 0!==(null===(o=Ae[0])||void 0===o?void 0:o[y]),Le=e.useMemo(()=>{if(Be)return Ae;if(ke){const e=Ae.reduce((e,t)=>{const n="function"==typeof ke?ke(t):t[ke];if(!e[n]){const o={[y]:[]};"string"==typeof ke&&(o[ke]=n),xe&&(o[so]=t[so],"string"==typeof p&&(o[p]=t[p])),e[n]=o}return e[n][y].push(t),e},{});return Object.values(e)}return[{[y]:Ae}]},[Ae,ke,y,Be]),{gapProcessedLineData:Ne,hasGaps:Ie}=e.useMemo(()=>{if("interpolate"===P){let e=!1;const t=[];for(const n of Le){const o=(n[y]||[]).filter(t=>!Pe(t)||(e=!0,!1));o.length>0&&t.push(Object.assign(Object.assign({},n),{[y]:o}))}return{gapProcessedLineData:t,hasGaps:e}}if("break"===P){let e=!1;const t=[];for(const n of Le){const o=n[y]||[];let r=[],i=0;const s=ke&&"string"==typeof ke?n[ke]:void 0;for(const a of o)if(Pe(a))e=!0,r.length>0&&(t.push(Object.assign(Object.assign({},n),{[y]: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),{[y]:r}))}return{gapProcessedLineData:t,hasGaps:e}}if("zero"===P){let e=!1;const t="string"==typeof f?f:"y",n=[];for(const o of Le){const r=o[y]||[],i=[];for(const n of r)Pe(n)?(e=!0,i.push(Object.assign(Object.assign({},n),{[t]:0}))):i.push(n);n.push(Object.assign(Object.assign({},o),{[y]:i}))}return{gapProcessedLineData:n,hasGaps:e}}return{gapProcessedLineData:Le,hasGaps:!1}},[Le,P,y,Pe,ke,f]),Te=dn(ve,m,v),He=e.useMemo(()=>{if(!m)return[];const e=new Set;for(const t of ve){const n="function"==typeof m?m(t):t[m];null!=n&&e.add(n+"")}return Array.from(e)},[ve,m]),Fe=pn(G,m,He),ze=e.useMemo(()=>je||(Fe.legendSelectionHook?Fe.legendSelectionHook:Se),[je,Fe.legendSelectionHook,Se]),Re=e.useMemo(()=>(e,t)=>{const n={strokeWidth:O},o=!0===w||Array.isArray(w)&&null!=t&&w.includes(t);return m?Te&&(n.stroke=E(e,m,Te),o&&(n.fill=n.stroke,n.fillOpacity=A)):(n.stroke=V||ln,o&&(n.fill=V||ln,n.fillOpacity=A)),n},[m,Te,O,w,A,V]),[$e,De]=e.useState(null);e.useEffect(()=>{if(!L)return void De(null);let e=!1;return function(...e){return io(this,void 0,void 0,function*(){return(yield lo()).createSegmentLineStyle(...e)})}(Re,L).then(t=>{e||De(()=>t)}).catch(()=>{e||De(null)}),()=>{e=!0}},[Re,L]);const We=$e||Re,Ge=e.useMemo(()=>an(We,ze,I),[We,ze,I]),Ye=e.useMemo(()=>{if(x)return e=>{const t={r:k,fillOpacity:1};return m?Te&&(t.fill=E(e.parentLine||e,m,Te)):t.fill=V||ln,t}},[x,k,m,Te,V]),qe=Array.isArray(w)?"mixed":w?"area":"line",Xe="object"==typeof _?_:{},Ve=Xe.position||"end",Ue=Xe.fontSize||11,Qe=e.useMemo(()=>{var e,t;if(!_||!m)return[];const n="function"==typeof g?g:e=>e[g],o="function"==typeof f?f:e=>e[f],r="function"==typeof m?m:e=>e[m],i=new Map;for(const n of Ne){const o=n[y]||[];if(0===o.length)continue;const s="end"===Ve?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 f?f:"y"]:o(t),dx:"end"===Ve?6:-6,dy:0,color:Te?Te(e):ln,fontSize:Ue}));s.sort((e,t)=>{const n="string"==typeof f?f:"y";return e[n]-t[n]});for(let e=1;s.length>e;e++){const t="string"==typeof f?f:"y",n=s[e-1],o=s[e];Ue+2>Math.abs(o[t]+o.dy-(n[t]+n.dy))&&(o.dy+=Ue+2)}return s},[_,m,Te,Ne,y,g,f,Ve,Ue]),Ke=(!_||void 0!==Z)&&Z,Je=e.useMemo(()=>{if(!_)return s.marginDefaults;const e=Qe.reduce((e,t)=>{var n;const o=((null===(n=t.label)||void 0===n?void 0:n.length)||0)*(.6*Ue);return Math.max(e,o)},0),t=e+10,n="end"===Ve?"right":"left";return Object.assign(Object.assign({},s.marginDefaults),{[n]:Math.max(s.marginDefaults[n]||0,t)})},[_,Qe,Ue,Ve,s.marginDefaults]),{legend:Ze,margin:et,legendPosition:tt}=fn({data:Ne,colorBy:m,colorScale:Te,showLegend:Ke,legendPosition:Y,userMargin:l,defaults:Je}),nt=p||m,ot=e.useMemo(()=>Mn([{label:re||On(g),accessor:g,role:"x"},{label:ie||On(f),accessor:f,role:"y"},...nt?[{label:On(nt),accessor:nt,role:"group"}]:[]]),[g,f,re,ie,nt]),rt=Nn({componentName:"LineChart",data:Be?(null===(r=ve[0])||void 0===r?void 0:r[y])||[]:a,accessors:{xAccessor:g,yAccessor:f}}),it=e.useMemo(()=>Be||ke||Ie?Ne.flatMap(e=>{const t=e[y]||[];return ke&&"string"==typeof ke?t.map(t=>Object.assign(Object.assign({},t),{[ke]:e[ke]})):t}):Ae,[Ne,y,Be,ke,Ae,Ie]),st=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(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:qe},Array.isArray(w)&&{areaGroups:w}),S&&{lineGradient:S}),null!=R&&{hoverRadius:R}),null!=a&&{data:it}),{xAccessor:g,yAccessor:f,xScaleType:q,yScaleType:X}),Oe&&{yExtent:Oe}),{groupAccessor:"break"===P&&Ie?"_gapSegment":ke||void 0,curve:b,lineStyle:Ge}),x&&{pointStyle:Ye}),{size:[U,Q],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:et,showAxes:s.showAxes,xLabel:re,yLabel:ie,xFormat:u,yFormat:d,enableHover:K,showGrid:J}),Ze&&{legend:Ze,legendPosition:tt}),G&&"none"!==G&&{legendHoverBehavior:Fe.onLegendHover,legendClickBehavior:Fe.onLegendClick,legendHighlightedCategory:Fe.highlightedCategory,legendIsolatedCategories:Fe.isolatedCategories}),ee&&{title:ee}),te&&{description:te}),ne&&{summary:ne}),void 0!==oe&&{accessibleTable:oe}),c&&{className:c}),{tooltipContent:!1===j?()=>null:"multi"===j?e=>{var t,n,o,r,i,s,a,l,c,u;const d=e.allSeries;if(!d||0===d.length){const s=null!==(i=null!==(r=null!==(n=null===(t=e.data)||void 0===t?void 0:t.value)&&void 0!==n?n:null===(o=e.data)||void 0===o?void 0:o.y)&&void 0!==r?r:e.value)&&void 0!==i?i:e.y;return h.createElement("div",{className:"semiotic-tooltip",style:bn},h.createElement("div",null,kn(s)))}const g=null!==(u=null!==(l=null!==(s=e.xValue)&&void 0!==s?s:null===(a=e.data)||void 0===a?void 0:a.time)&&void 0!==l?l:null===(c=e.data)||void 0===c?void 0:c.x)&&void 0!==u?u:e.time;return h.createElement("div",{className:"semiotic-tooltip",style:bn},null!=g&&h.createElement("div",{style:{fontWeight:600,marginBottom:4,fontSize:"0.9em",borderBottom:"1px solid var(--semiotic-border, #eee)",paddingBottom:4}},kn(g)),d.map((e,t)=>h.createElement("div",{key:t,style:{display:"flex",alignItems:"center",gap:6,padding:"1px 0"}},h.createElement("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:e.color,flexShrink:0}}),h.createElement("span",{style:{flex:1,fontSize:"0.85em"}},e.group),h.createElement("span",{style:{fontWeight:500,fontSize:"0.85em"}},kn(e.value)))))}:An(j)||ot}),"multi"===j&&{tooltipMode:"multi"}),(T||H||F||z)&&{customHoverBehavior:Me}),(H||F||T)&&{customClickBehavior:Ce}),M&&{pointIdAccessor:M}),((null==C?void 0:C.length)||ge.length||Qe.length)&&{annotations:[...C||[],...ge,...Qe]}),_e),N);return se||ae||(rt?h.createElement(Cn,{componentName:"LineChart",message:rt,width:U,height:Q}):h.createElement(Zn,{componentName:"LineChart",width:U,height:Q},h.createElement(Dt,Object.assign({ref:i},st))))});co.displayName="LineChart";const uo=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)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},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=mn(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:d="x",yAccessor:g="y",areaBy:f,y0Accessor:p,gradientFill:y=!1,lineDataAccessor:m="coordinates",colorBy:v,colorScheme:b,curve:x="monotoneX",areaOpacity:k=.7,lineGradient:w,showLine:A=!0,lineWidth:O=2,showPoints:S=!1,pointRadius:j=3,tooltip:M,annotations:C,frameProps:_={},selection:P,linkedHover:B,onObservation:L,onClick:N,hoverHighlight:I,chartId:T,loading:H,emptyContent:F,legendInteraction:z,legendPosition:R,color:$}=t,D=i.width,W=i.height,G=i.enableHover,Y=i.showGrid,q=i.showLegend,X=i.title,V=i.description,U=i.summary,Q=i.accessibleTable,K=i.xLabel,J=i.yLabel,Z=oo(H,D,W),ee=Z?null:no(s,D,W,F),te=s||[];ro("AreaChart",te,"xAccessor",d),ro("AreaChart",te,"yAccessor",g);const{activeSelectionHook:ne,hoverSelectionHook:oe,customHoverBehavior:re,customClickBehavior:ie,crosshairSourceId:se}=hn({selection:P,linkedHover:B,fallbackFields:v?["string"==typeof v?v:""]:[],onObservation:L,onClick:N,chartType:"AreaChart",chartId:T,hoverHighlight:I,colorByField:"string"==typeof v?v:void 0}),ae=gn(B,se),le=void 0!==(null===(o=te[0])||void 0===o?void 0:o[m]),ce=e.useMemo(()=>{if(le)return te;if(f){const e=te.reduce((e,t)=>{const n="function"==typeof f?f(t):t[f];if(!e[n]){const t={[m]:[]};"string"==typeof f&&(t[f]=n),e[n]=t}return e[n][m].push(t),e},{});return Object.values(e)}return[{[m]:te}]},[te,f,m,le]),ue=dn(te,v,b),de=e.useMemo(()=>{if(!v)return[];const e=new Set;for(const t of te){const n="function"==typeof v?v(t):t[v];null!=n&&e.add(n+"")}return Array.from(e)},[te,v]),he=pn(z,v,de),ge=e.useMemo(()=>oe||(he.legendSelectionHook?he.legendSelectionHook:ne),[oe,he.legendSelectionHook,ne]),fe=e.useMemo(()=>e=>{const t={};if(v){if(ue){const n=E(e,v,ue);t.fill=n,A?(t.stroke=n,t.strokeWidth=O):t.stroke="none"}}else{const e=$||ln;t.fill=e,A?(t.stroke=e,t.strokeWidth=O):t.stroke="none"}return t.fillOpacity=k,t},[v,ue,$,k,A,O]),pe=e.useMemo(()=>an(fe,ge,P),[fe,ge,P]),ye=e.useMemo(()=>{if(S)return e=>{const t={r:j,fillOpacity:1};return v?ue&&(t.fill=E(e.parentLine||e,v,ue)):t.fill=ln,t}},[S,j,v,ue]),{legend:me,margin:ve,legendPosition:be}=fn({data:ce,colorBy:v,colorScale:ue,showLegend:q,legendPosition:R,userMargin:a,defaults:i.marginDefaults}),xe=f||v,ke=e.useMemo(()=>Mn([{label:K||On(d),accessor:d,role:"x"},{label:J||On(g),accessor:g,role:"y"},...xe?[{label:On(xe),accessor:xe,role:"group"}]:[]]),[d,g,K,J,xe]),we=Nn({componentName:"AreaChart",data:s,accessors:{xAccessor:d,yAccessor:g}}),Ae=e.useMemo(()=>le||f?ce.flatMap(e=>{const t=e[m]||[];return f&&"string"==typeof f?t.map(t=>Object.assign(Object.assign({},t),{[f]:e[f]})):t}):te,[ce,m,le,f,te]),Oe=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(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area"},null!=s&&{data:Ae}),{xAccessor:d,yAccessor:g,groupAccessor:f||void 0}),p&&{y0Accessor:p}),y&&{gradientFill:y}),w&&{lineGradient:w}),{curve:x,lineStyle:pe}),S&&ye&&{pointStyle:ye}),{size:[D,W],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ve,showAxes:i.showAxes,xLabel:K,yLabel:J,xFormat:c,yFormat:u,enableHover:G}),t.pointIdAccessor&&{pointIdAccessor:t.pointIdAccessor}),{showGrid:Y}),me&&{legend:me,legendPosition:be}),z&&"none"!==z&&{legendHoverBehavior:he.onLegendHover,legendClickBehavior:he.onLegendClick,legendHighlightedCategory:he.highlightedCategory,legendIsolatedCategories:he.isolatedCategories}),X&&{title:X}),V&&{description:V}),U&&{summary:U}),void 0!==Q&&{accessibleTable:Q}),l&&{className:l}),{tooltipContent:!1===M?()=>null:An(M)||ke}),(B||L||N||I)&&{customHoverBehavior:re}),(L||N||B)&&{customClickBehavior:ie}),C&&C.length>0&&{annotations:C}),ae),_);return Z||ee||(we?h.createElement(Cn,{componentName:"AreaChart",message:we,width:D,height:W}):h.createElement(Zn,{componentName:"AreaChart",width:D,height:W},h.createElement(Dt,Object.assign({ref:r},Oe))))});function ho({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]),d=e.useCallback(e=>{if(!t||!n)return;let o=!1;for(const t of e){if(!t||"object"!=typeof t)continue;const e=u(t);null==e||s.current.has(e)||(s.current.add(e),a.current.push(e),o=!0)}o&&c(e=>e+1)},[t,n,u]),h=e.useCallback(e=>t=>{d([t]),e(t)},[d]),g=e.useCallback(e=>t=>{d(t),e(t)},[d]),f=e.useCallback(()=>{s.current=new Set,a.current=[],c(e=>e+1)},[]),p=e.useMemo(()=>{if(!t||!n||!1===r)return;const e=a.current;if(0===e.length)return;const i=Array.isArray(o)?o:M,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 rn({data:e.map(e=>({[l]:e})),colorBy:l,colorScale:e=>s.get(e)||"#999",getColor:E})},[t,n,r,o,l]),y=e.useMemo(()=>{if(p)return"right"===i?{right:110}:"left"===i?{left:110}:"top"===i?{top:50}:"bottom"===i?{bottom:80}:{right:110}},[p,i]);return{wrapPush:h,wrapPushMany:g,resetCategories:f,streamingLegend:p,streamingMarginAdjust:y}}uo.displayName="AreaChart";const go=e.forwardRef(function(t,n){var o;const r=e.useRef(null),i=mn(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:d="x",yAccessor:g="y",areaBy:f,lineDataAccessor:p="coordinates",colorBy:y,colorScheme:m,curve:v="monotoneX",areaOpacity:b=.7,showLine:x=!0,lineWidth:k=2,showPoints:w=!1,pointRadius:A=3,normalize:O=!1,tooltip:S,annotations:j,frameProps:M={},selection:C,linkedHover:_,onObservation:P,onClick:B,hoverHighlight:L,chartId:N,loading:I,emptyContent:T,legendInteraction:H,legendPosition:F,color:z}=t,R=i.width,$=i.height,D=i.enableHover,W=i.showGrid,G=i.showLegend,Y=i.title,q=i.description,X=i.summary,V=i.accessibleTable,U=i.xLabel,Q=i.yLabel,K=oo(I,R,$),J=K?null:no(s,R,$,T),Z=s||[],ee=ho({isPushMode:void 0===s,colorBy:y||f,colorScheme:m,showLegend:G,legendPosition:F}),te=e.useCallback(ee.wrapPush(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)}),[ee.wrapPush]),ne=e.useCallback(ee.wrapPushMany(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)}),[ee.wrapPushMany]);e.useImperativeHandle(n,()=>({push:te,pushMany:ne,remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;ee.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:[]}}),[te,ne,ee.resetCategories]);const{activeSelectionHook:oe,hoverSelectionHook:re,customHoverBehavior:ie,customClickBehavior:se,crosshairSourceId:ae}=hn({selection:C,linkedHover:_,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:P,onClick:B,chartType:"StackedAreaChart",chartId:N,hoverHighlight:L,colorByField:"string"==typeof y?y:void 0}),le=gn(_,ae),ce=void 0!==(null===(o=Z[0])||void 0===o?void 0:o[p]),ue=e.useMemo(()=>{if(ce)return Z;if(f){const e=Z.reduce((e,t)=>{const n="function"==typeof f?f(t):t[f];if(!e[n]){const t={[p]:[]};"string"==typeof f&&(t[f]=n),e[n]=t}return e[n][p].push(t),e},{});return Object.values(e)}return[{[p]:Z}]},[Z,f,p,ce]),de=dn(Z,y,m),he=e.useMemo(()=>{if(!y)return[];const e=new Set;for(const t of Z){const n="function"==typeof y?y(t):t[y];null!=n&&e.add(n+"")}return Array.from(e)},[Z,y]),ge=pn(H,y,he),fe=e.useMemo(()=>re||(ge.legendSelectionHook?ge.legendSelectionHook:oe),[re,ge.legendSelectionHook,oe]),pe=e.useMemo(()=>e=>{const t={};if(y&&de){const n=E(e,y,de);t.fill=n,x?(t.stroke=n,t.strokeWidth=k):t.stroke="none"}else if(!y){const e=z||ln;t.fill=e,t.stroke=x?e:"none",x&&(t.strokeWidth=k)}return t.fillOpacity=b,t},[y,de,b,x,k,z]),ye=e.useMemo(()=>an(pe,fe,C),[pe,fe,C]),me=e.useMemo(()=>{if(w)return e=>{const t={r:A,fillOpacity:1};return y?de&&(t.fill=E(e.parentLine||e,y,de)):t.fill=z||ln,t}},[w,A,y,de,z]),{legend:ve,margin:be,legendPosition:xe}=fn({data:ue,colorBy:y,colorScale:de,showLegend:G,legendPosition:F,userMargin:a,defaults:i.marginDefaults}),ke=ee.streamingLegend||ve,we=F||xe,Ae=e.useMemo(()=>{if(ee.streamingMarginAdjust){const e=Object.assign({},be);for(const[t,n]of Object.entries(ee.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return be},[be,ee.streamingMarginAdjust]),Oe=f||y,Se=e.useMemo(()=>Mn([{label:U||On(d),accessor:d,role:"x"},{label:Q||On(g),accessor:g,role:"y"},...Oe?[{label:On(Oe),accessor:Oe,role:"group"}]:[]]),[d,g,U,Q,Oe]),je=Nn({componentName:"StackedAreaChart",data:s,accessors:{xAccessor:d,yAccessor:g}}),Me=e.useMemo(()=>ce||f?ue.flatMap(e=>{const t=e[p]||[];return f&&"string"==typeof f?t.map(t=>Object.assign(Object.assign({},t),{[f]:e[f]})):t}):Z,[ue,p,ce,f,Z]),Ce=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(Object.assign(Object.assign(Object.assign({chartType:"stackedarea"},null!=s&&{data:Me}),{xAccessor:d,yAccessor:g,groupAccessor:f||void 0,curve:v,normalize:O,lineStyle:ye}),w&&me&&{pointStyle:me}),{size:[R,$],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Ae,showAxes:i.showAxes,xLabel:U,yLabel:Q,xFormat:c,yFormat:u,enableHover:D}),t.pointIdAccessor&&{pointIdAccessor:t.pointIdAccessor}),{showGrid:W}),ke&&{legend:ke,legendPosition:we}),H&&"none"!==H&&{legendHoverBehavior:ge.onLegendHover,legendClickBehavior:ge.onLegendClick,legendHighlightedCategory:ge.highlightedCategory,legendIsolatedCategories:ge.isolatedCategories}),Y&&{title:Y}),q&&{description:q}),X&&{summary:X}),void 0!==V&&{accessibleTable:V}),l&&{className:l}),{tooltipContent:!1===S?()=>null:An(S)||Se}),(_||P||B||L)&&{customHoverBehavior:ie}),(P||B||_)&&{customClickBehavior:se}),j&&j.length>0&&{annotations:j}),le),M);return K||J||(je?h.createElement(Cn,{componentName:"StackedAreaChart",message:je,width:R,height:$}):h.createElement(Zn,{componentName:"StackedAreaChart",width:R,height:$},h.createElement(Dt,Object.assign({ref:r},Ce))))});function fo(t){const{data:n,rawData:o,colorBy:r,colorScheme:i,legendInteraction:s,legendPosition:a,selection:l,linkedHover:c,fallbackFields:u,unwrapData:d=!1,onObservation:h,chartType:g,chartId:f,showLegend:p,userMargin:y,marginDefaults:m,onClick:v,hoverHighlight:b,loading:x,emptyContent:k,width:w,height:A}=t,O="string"==typeof t.colorBy?t.colorBy:void 0,{activeSelectionHook:S,hoverSelectionHook:j,customHoverBehavior:M,customClickBehavior:C,crosshairSourceId:E}=hn({selection:l,linkedHover:c,fallbackFields:u,unwrapData:d,onObservation:h,chartType:g,chartId:f,onClick:v,hoverHighlight:b,colorByField:O}),_=gn(c,E),P=dn(n,r,i),B=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]),L=pn(s,r,B),N=e.useMemo(()=>j||(L.legendSelectionHook?L.legendSelectionHook:S),[j,L.legendSelectionHook,S]),{legend:I,margin:T,legendPosition:H}=fn({data:n,colorBy:r,colorScale:P,showLegend:p,legendPosition:a,userMargin:y,defaults:m}),F=e.useMemo(()=>{const e={};return I&&(e.legend=I,e.legendPosition=H),s&&"none"!==s&&(e.legendHoverBehavior=L.onLegendHover,e.legendClickBehavior=L.onLegendClick,e.legendHighlightedCategory=L.highlightedCategory,e.legendIsolatedCategories=L.isolatedCategories),e},[I,H,s,L.onLegendHover,L.onLegendClick,L.highlightedCategory,L.isolatedCategories]),z=oo(x,w,A),R=z?null:no(o,w,A,k);return{colorScale:P,allCategories:B,legendState:L,effectiveSelectionHook:N,activeSelectionHook:S,customHoverBehavior:M,customClickBehavior:C,legend:I,margin:T,legendPosition:H,earlyReturn:z||R||null,legendBehaviorProps:F,crosshairProps:_}}go.displayName="StackedAreaChart";const po=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)},remove:e=>{var t,n;return null!==(n=null===(t=o.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=o.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},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=mn(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:d="y",colorBy:g,colorScheme:f,sizeBy:p,sizeRange:y=[3,15],pointRadius:m=5,pointOpacity:v=.8,tooltip:b,marginalGraphics:x,pointIdAccessor:k,annotations:w,frameProps:A={},selection:O,linkedHover:S,linkedBrush:j,onObservation:M,onClick:C,hoverHighlight:_,chartId:B,loading:L,emptyContent:N,legendInteraction:I,legendPosition:T,color:H}=t,F=r.width,z=r.height,R=r.enableHover,$=r.showGrid,D=r.title,W=r.description,G=r.summary,Y=r.accessibleTable,q=r.xLabel,X=r.yLabel,V=i||[],U=fo({data:V,rawData:i,colorBy:g,colorScheme:f,legendInteraction:I,legendPosition:T,selection:O,linkedHover:S,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!1,onObservation:M,onClick:C,hoverHighlight:_,chartType:"Scatterplot",chartId:B,showLegend:r.showLegend,userMargin:s,marginDefaults:r.marginDefaults,loading:L,emptyContent:N,width:F,height:z}),Q=sn(j),K=Zt({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 d?d:void 0)}),J=Q?"xyBrush"===K.brushInteraction.brush?"xy":"xBrush"===K.brushInteraction.brush?"x":"y":void 0,Z=h.useRef(K.brushInteraction);Z.current=K.brushInteraction;const ee=e.useCallback(e=>{const t=Z.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(U.earlyReturn)return U.earlyReturn;ro("Scatterplot",V,"xAccessor",u),ro("Scatterplot",V,"yAccessor",d);const te=e.useMemo(()=>{if(!p||0===V.length)return;const e=V.map(e=>"function"==typeof p?p(e):e[p]);return[Math.min(...e),Math.max(...e)]},[V,p]),ne=e.useMemo(()=>e=>{const t={fillOpacity:v};return g?U.colorScale&&(t.fill=E(e,g,U.colorScale)):t.fill=H||ln,t.r=p?P(e,p,y,te):m,t},[g,U.colorScale,p,y,te,m,v,H]),oe=e.useMemo(()=>an(ne,U.effectiveSelectionHook,O),[ne,U.effectiveSelectionHook,O]),re=e.useMemo(()=>Mn([{label:q||On(u),accessor:u,role:"x"},{label:X||On(d),accessor:d,role:"y"},...g?[{label:On(g),accessor:g,role:"color"}]:[],...p?[{label:On(p),accessor:p,role:"size"}]:[]]),[u,d,q,X,g,p]),ie=Nn({componentName:"Scatterplot",data:i,accessors:{xAccessor:u,yAccessor:d}});if(ie)return h.createElement(Cn,{componentName:"Scatterplot",message:ie,width:F,height:z});const se=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(Object.assign({chartType:"scatter"},null!=i&&{data:V}),{xAccessor:u,yAccessor:d,colorAccessor:g||void 0,sizeAccessor:p||void 0,sizeRange:y,pointStyle:oe,colorScheme:f,size:[F,z],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:U.margin,showAxes:r.showAxes,xLabel:q,yLabel:X,xFormat:l,yFormat:c,enableHover:R,showGrid:$}),U.legendBehaviorProps),D&&{title:D}),W&&{description:W}),G&&{summary:G}),void 0!==Y&&{accessibleTable:Y}),a&&{className:a}),{tooltipContent:!1===b?()=>null:An(b)||re}),(S||M||C||_)&&{customHoverBehavior:U.customHoverBehavior}),(M||C||S)&&{customClickBehavior:U.customClickBehavior}),x&&{marginalGraphics:x}),k&&{pointIdAccessor:k}),w&&w.length>0&&{annotations:w}),Q&&{brush:{dimension:J},onBrush:ee}),U.crosshairProps),A);return h.createElement(Zn,{componentName:"Scatterplot",width:F,height:z},h.createElement(Dt,Object.assign({ref:o},se)))});function yo(e,t){return i.interpolateViridis(1===t?.5:e/(t-1))}po.displayName="Scatterplot";const mo=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)},remove:e=>{var t,n;return null!==(n=null===(t=o.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=o.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},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=mn(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:d,orderLabel:g,pointRadius:f=4,tooltip:p,pointIdAccessor:y,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:k,onClick:w,hoverHighlight:A,chartId:O,loading:S,emptyContent:j,legendInteraction:M}=t,C=r.width,E=r.height,_=r.enableHover,P=r.showGrid,B=r.title,L=r.description,N=r.summary,I=r.accessibleTable,T=r.xLabel,H=r.yLabel,F=i||[],{safeData:z,orderMap:R}=e.useMemo(()=>{const e="function"==typeof c?c:e=>e[c],t="function"==typeof u?u:e=>e[u];let n=F;if(d&&F.length>0){const e="function"==typeof d?d:e=>e[d];n=[...F].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}},[F,d,c,u]);ro("ConnectedScatterplot",z,"xAccessor",c),ro("ConnectedScatterplot",z,"yAccessor",u);const{activeSelectionHook:$,hoverSelectionHook:D,customHoverBehavior:W,customClickBehavior:G,crosshairSourceId:Y}=hn({selection:b,linkedHover:x,fallbackFields:[],onObservation:k,onClick:w,chartType:"ConnectedScatterplot",chartId:O,hoverHighlight:A,colorByField:void 0}),q=gn(x,Y),X=pn(M,void 0,[]),V=e.useMemo(()=>D||(X.legendSelectionHook?X.legendSelectionHook:$),[D,X.legendSelectionHook,$]),U=e.useMemo(()=>(e,t)=>{var n,o;const r=t.filter(e=>"point"===e.type);if(2>r.length)return;const i=null==V?void 0:V.isActive,s=null==V?void 0:V.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],d=yo(t,l),h=!i||!s||s(null!==(n=c.datum)&&void 0!==n?n:c)||s(null!==(o=u.datum)&&void 0!==o?o:u),g=i?h?1:.2:1;a&&(e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle="white",e.lineWidth=f+2,e.globalAlpha=.5*g,e.stroke()),e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle=d,e.lineWidth=f,e.globalAlpha=g,e.stroke()}e.globalAlpha=1},[f,V]),Q=e.useMemo(()=>[U],[U]),K=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=yo(e,s),u="number"==typeof(null===(o=t.style)||void 0===o?void 0:o.opacity)?t.style.opacity:1,d="number"==typeof(null===(r=n.style)||void 0===r?void 0:r.opacity)?n.style.opacity:1,g=Math.min(u,d);a&&l.push(h.createElement("line",{key:"halo-"+e,x1:t.x,y1:t.y,x2:n.x,y2:n.y,stroke:"white",strokeWidth:f+2,strokeLinecap:"round",opacity:.5*g})),l.push(h.createElement("line",{key:"seg-"+e,x1:t.x,y1:t.y,x2:n.x,y2:n.y,stroke:c,strokeWidth:f,strokeLinecap:"round",opacity:g}))}return h.createElement(h.Fragment,null,l)},[f]),J=e.useMemo(()=>[K],[K]),Z=e.useMemo(()=>e=>{var t,n;const o=R.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?yo(r,i):"#6366f1",stroke:"white",strokeWidth:1,r:f,fillOpacity:1}},[f,R]),ee=e.useMemo(()=>an(Z,V,b),[Z,V,b]),te=Object.assign({top:50,right:40,bottom:60,left:70},t.margin),ne=g||("string"==typeof d?d:"Order"),oe=e.useMemo(()=>Mn([{label:T||On(c),accessor:c,role:"x"},{label:H||On(u),accessor:u,role:"y"},...d?[{label:ne,accessor:d,role:"group"}]:[]]),[c,u,T,H,d,ne]),re=Nn({componentName:"ConnectedScatterplot",data:i,accessors:{xAccessor:c,yAccessor:u}}),ie=oo(S,C,E),se=ie?null:no(i,C,E,j),ae=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=i&&{data:z}),{xAccessor:c,yAccessor:u,pointStyle:ee,size:[C,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:te,showAxes:r.showAxes,xLabel:T,yLabel:H,xFormat:a,yFormat:l,enableHover:_,showGrid:P}),B&&{title:B}),L&&{description:L}),N&&{summary:N}),void 0!==I&&{accessibleTable:I}),s&&{className:s}),{tooltipContent:!1===p?()=>null:An(p)||oe}),(x||k||w||A)&&{customHoverBehavior:W}),(k||w||x)&&{customClickBehavior:G}),y&&{pointIdAccessor:y}),{canvasPreRenderers:Q,svgPreRenderers:J}),m&&m.length>0&&{annotations:m}),q),v);return ie||se||(re?h.createElement(Cn,{componentName:"ConnectedScatterplot",message:re,width:C,height:E}):h.createElement(Zn,{componentName:"ConnectedScatterplot",width:C,height:E},h.createElement(Dt,Object.assign({ref:o},ae))))});mo.displayName="ConnectedScatterplot";const vo=e.forwardRef(function(t,n){const o=e.useRef(null),r=mn(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:d="y",sizeBy:g,sizeRange:f=[5,40],colorBy:p,colorScheme:y,bubbleOpacity:m=.6,bubbleStrokeWidth:v=1,bubbleStrokeColor:b="white",tooltip:x,marginalGraphics:k,pointIdAccessor:w,annotations:A,frameProps:O={},selection:S,linkedHover:j,linkedBrush:M,onObservation:C,onClick:_,hoverHighlight:B,chartId:L,loading:N,emptyContent:I,legendInteraction:T,legendPosition:H,color:F}=t,z=r.width,R=r.height,$=r.enableHover,D=r.showGrid,W=r.showLegend,G=r.title,Y=r.description,q=r.summary,X=r.accessibleTable,V=r.xLabel,U=r.yLabel,Q=oo(N,z,R),K=Q?null:no(i,z,R,I),J=i||[],Z=void 0===i,ee=e.useRef(null),[te,ne]=e.useState(0),oe=e.useCallback(e=>{if(!Z)return;let t=!1;for(const n of e){const e="function"==typeof g?g(n):n[g];null!=e&&isFinite(e)&&(ee.current?(ee.current[0]>e&&(ee.current[0]=e,t=!0),e>ee.current[1]&&(ee.current[1]=e,t=!0)):(ee.current=[e,e],t=!0))}t&&ne(e=>e+1)},[Z,g]),re=ho({isPushMode:Z,colorBy:p,colorScheme:y,showLegend:W,legendPosition:H}),ie=e.useCallback(re.wrapPush(e=>{var t;oe([e]),null===(t=o.current)||void 0===t||t.push(e)}),[re.wrapPush,oe]),se=e.useCallback(re.wrapPushMany(e=>{var t;oe(e),null===(t=o.current)||void 0===t||t.pushMany(e)}),[re.wrapPushMany,oe]);e.useImperativeHandle(n,()=>({push:ie,pushMany:se,remove:e=>{var t,n;return null!==(n=null===(t=o.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=o.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;re.resetCategories(),ee.current=null,ne(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:[]}}),[ie,se,re.resetCategories]);const{activeSelectionHook:ae,hoverSelectionHook:le,customHoverBehavior:ce,customClickBehavior:ue,crosshairSourceId:de}=hn({selection:S,linkedHover:j,fallbackFields:p?["string"==typeof p?p:""]:[],onObservation:C,onClick:_,chartType:"BubbleChart",chartId:L,hoverHighlight:B,colorByField:"string"==typeof p?p:void 0}),he=gn(j,de),ge=sn(M);Zt({name:(null==ge?void 0:ge.name)||"__unused_brush__",xField:(null==ge?void 0:ge.xField)||("string"==typeof u?u:void 0),yField:(null==ge?void 0:ge.yField)||("string"==typeof d?d:void 0)});const fe=dn(J,p,y),pe=e.useMemo(()=>{if(!p)return[];const e=new Set;for(const t of J){const n="function"==typeof p?p(t):t[p];null!=n&&e.add(n+"")}return Array.from(e)},[J,p]),ye=pn(T,p,pe),me=e.useMemo(()=>le||(ye.legendSelectionHook?ye.legendSelectionHook:ae),[le,ye.legendSelectionHook,ae]),ve=e.useMemo(()=>{if(Z)return ee.current||[0,1];const e=J.map(e=>"function"==typeof g?g(e):e[g]);return[Math.min(...e),Math.max(...e)]},[J,g,Z,te]),be=e.useMemo(()=>e=>{const t={fillOpacity:m,strokeWidth:v,stroke:b};return p?fe&&(t.fill=E(e,p,fe)):t.fill=F||ln,t.r=P(e,g,f,ve),t},[p,fe,g,f,ve,m,v,b,F]),xe=e.useMemo(()=>an(be,me,S),[be,me,S]),{legend:ke,margin:we,legendPosition:Ae}=fn({data:J,colorBy:p,colorScale:fe,showLegend:W,legendPosition:H,userMargin:s,defaults:r.marginDefaults}),Oe=re.streamingLegend||ke,Se=H||Ae,je=e.useMemo(()=>{if(re.streamingMarginAdjust){const e=Object.assign({},we);for(const[t,n]of Object.entries(re.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return we},[we,re.streamingMarginAdjust]),Me=e.useMemo(()=>Mn([{label:V||On(u),accessor:u,role:"x"},{label:U||On(d),accessor:d,role:"y"},{label:On(g),accessor:g,role:"size"},...p?[{label:On(p),accessor:p,role:"color"}]:[]]),[u,d,V,U,g,p]),Ce=Nn({componentName:"BubbleChart",data:i,accessors:{xAccessor:u,yAccessor:d},requiredProps:{sizeBy:g}});if(Ce)return h.createElement(Cn,{componentName:"BubbleChart",message:Ce,width:z,height:R});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(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bubble"},null!=i&&{data:J}),{xAccessor:u,yAccessor:d,colorAccessor:p||void 0,sizeAccessor:g,sizeRange:f,pointStyle:xe,colorScheme:y,size:[z,R],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:je,showAxes:r.showAxes,xLabel:V,yLabel:U,xFormat:l,yFormat:c,enableHover:$,showGrid:D}),Oe&&{legend:Oe,legendPosition:Se}),T&&"none"!==T&&{legendHoverBehavior:ye.onLegendHover,legendClickBehavior:ye.onLegendClick,legendHighlightedCategory:ye.highlightedCategory,legendIsolatedCategories:ye.isolatedCategories}),G&&{title:G}),Y&&{description:Y}),q&&{summary:q}),void 0!==X&&{accessibleTable:X}),a&&{className:a}),{tooltipContent:!1===x?()=>null:An(x)||Me}),(j||C||_||B)&&{customHoverBehavior:ce}),(C||_||j)&&{customClickBehavior:ue}),k&&{marginalGraphics:k}),w&&{pointIdAccessor:w}),A&&A.length>0&&{annotations:A}),he),O);return Q||K||h.createElement(Zn,{componentName:"BubbleChart",width:z,height:R},h.createElement(Dt,Object.assign({ref:o},Ee)))});vo.displayName="BubbleChart";const bo=e.forwardRef(function(t,n){const r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},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 s=mn(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:d="y",valueAccessor:g="value",xFormat:f,yFormat:p,colorScheme:y="blues",customColorScale:m,showValues:v=!1,valueFormat:b,cellBorderColor:x="#fff",cellBorderWidth:k=1,tooltip:w,annotations:A,frameProps:O={},selection:S,linkedHover:j,onObservation:M,onClick:C,hoverHighlight:E,chartId:_,loading:P,emptyContent:B,showLegend:L,legendPosition:N,legendInteraction:I}=t,T=s.width,H=s.height,F=s.enableHover,z=s.title,R=s.description,$=s.summary,D=s.accessibleTable,W=s.xLabel,G=s.yLabel,Y=oo(P,T,H),q=Y?null:no(a,T,H,B),X=a||[],V=null!=L&&L,U=null!=N?N:"right",{margin:Q}=fn({data:X,colorBy:V?"value":void 0,colorScale:void 0,showLegend:V,legendPosition:U,userMargin:l,defaults:s.marginDefaults}),{activeSelectionHook:K,hoverSelectionHook:J,customHoverBehavior:Z,customClickBehavior:ee,crosshairSourceId:te}=hn({selection:S,linkedHover:j,fallbackFields:[],onObservation:M,onClick:C,chartType:"Heatmap",chartId:_,hoverHighlight:E,colorByField:void 0}),ne=gn(j,te),oe=pn(I,void 0,[]),re=e.useMemo(()=>J||(oe.legendSelectionHook?oe.legendSelectionHook:K),[J,oe.legendSelectionHook,K]),ie=e.useMemo(()=>"function"==typeof g?e=>g(e):e=>e[g],[g]),se=e.useMemo(()=>{const e=X.map(ie);return[Math.min(...e),Math.max(...e)]},[X,ie]),ae=e.useMemo(()=>"custom"===y&&m?m:o.scaleSequential({blues:i.interpolateBlues,reds:i.interpolateReds,greens:i.interpolateGreens,viridis:i.interpolateViridis}[y]||i.interpolateBlues).domain(se),[y,m,se]);e.useMemo(()=>{const e=un(u),t=un(d);return{xBinCount:new Set(X.map(e)).size,yBinCount:new Set(X.map(t)).size}},[X,u,d]),e.useMemo(()=>({coordinates:X}),[X]);const le=e.useMemo(()=>e=>{const t=ie(e);return{fill:ae(t),stroke:x,strokeWidth:k}},[ie,ae,x,k]);e.useMemo(()=>an(le,re,S),[le,re,S]);const ce=e.useMemo(()=>Mn([{label:W||On(u),accessor:u,role:"x"},{label:G||On(d),accessor:d,role:"y"},{label:On(g),accessor:g,role:"value"}]),[u,d,W,G,g]),ue=Nn({componentName:"Heatmap",data:a,accessors:{xAccessor:u,yAccessor:d,valueAccessor:g}}),de=e.useMemo(()=>{if(V)return{gradient:{colorFn:e=>ae(e),domain:se,label:"string"==typeof g?g:"value",format:b}}},[V,ae,se,g,b]),he=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:"heatmap"},null!=a&&{data:X}),{xAccessor:u,yAccessor:d,valueAccessor:g,colorScheme:"custom"!==y?y:void 0,showValues:v,heatmapValueFormat:b,size:[T,H],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Q,showAxes:s.showAxes,xLabel:W,yLabel:G,xFormat:f,yFormat:p,enableHover:F}),t.pointIdAccessor&&{pointIdAccessor:t.pointIdAccessor}),de&&{legend:de,legendPosition:U}),z&&{title:z}),R&&{description:R}),$&&{summary:$}),void 0!==D&&{accessibleTable:D}),c&&{className:c}),{tooltipContent:!1===w?()=>null:An(w)||ce}),(j||M||C||E)&&{customHoverBehavior:Z}),(M||C||j)&&{customClickBehavior:ee}),A&&A.length>0&&{annotations:A}),ne),O);return Y||q||(ue?h.createElement(Cn,{componentName:"Heatmap",message:ue,width:T,height:H}):h.createElement(Zn,{componentName:"Heatmap",width:T,height:H},h.createElement(Dt,Object.assign({ref:r},he))))});bo.displayName="Heatmap";const xo="__splomIdx",ko={top:4,bottom:4,left:4,right:4};function wo({frameRef:o,cellSize:r,onBrush:i}){const s=e.useRef(null),a=r-ko.left-ko.right,l=r-ko.top-ko.bottom;return e.useEffect(()=>{if(!s.current)return;const e=t.select(s.current).select(".brush-g"),r=n.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]),h.createElement("svg",{ref:s,width:r,height:r,style:{position:"absolute",top:0,left:0}},h.createElement("g",{className:"brush-g",transform:`translate(${ko.left},${ko.top})`}))}function Ao({data:t,xField:n,yField:o,cellSize:r,pointRadius:i,pointOpacity:s,colorBy:a,colorScale:l,brushSelectionName:c,hoverSelectionName:u,unselectedOpacity:d,mode:g,onPointHover:f}){const p=e.useRef(null),y=Kt({name:c,clientId:`splom-${n}-${o}`}),m=Zt({name:c,xField:n,yField:o}),v=Kt({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==f||f(null));const t=e.data,n=null==t?void 0:t[xo];void 0!==n&&(b({[xo]:[n]}),null==f||f(t,e.x+ko.left,e.y+ko.top))},[b,f]),w=e.useCallback(e=>{const t={opacity:s,r:i};return t.fill=a?E(e,a,l):ln,"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):y.isActive&&!y.predicate(e)&&(t.opacity=d),t},[a,l,s,i,g,y.isActive,y.predicate,v.isActive,v.predicate,d]);return h.createElement("div",{style:{position:"relative",width:r,height:r}},h.createElement(Dt,{ref:p,chartType:"scatter",data:t,size:[r,r],xAccessor:n,yAccessor:o,pointStyle:w,margin:ko,showAxes:!1,enableHover:"hover"===g,customHoverBehavior:"hover"===g?k:void 0,tooltipContent:"hover"===g?()=>null:void 0}),"brush"===g&&h.createElement(wo,{frameRef:p,cellSize:r,xField:n,yField:o,onBrush:x}))}function Oo({data:t,field:n,label:o,cellSize:r,bins:i,colorBy:s,colorScale:a,brushSelectionName:l,hoverSelectionName:c,mode:u}){const d=Kt({name:l,clientId:"splom-diag-"+n}),g=Kt({name:c,clientId:`splom-diag-${n}-hover`}),f="hover"===u?g:d,p=f.isActive,y=f.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])),d=Array(i).fill(0),h=Array(i).fill(0),g=Array.from({length:i},()=>Array(c.length).fill(0)),f=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(d[r]++,p&&!y(e)||h[r]++,l){const t=u.get(e[l]+"");void 0!==t&&(g[r][t]++,p&&!y(e)||f[r][t]++)}}const m=Math.max(...d,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=f.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:d.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/m*(r-24),count:e})),selectedBars:h.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/m*(r-24),count:e})),categoryBars:v,selectedCategoryBars:b,max:m,categories:c}},[t,n,i,r,p,y,s]);return h.createElement("svg",{width:r,height:r,style:{overflow:"hidden"}},h.createElement("text",{x:r/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333"},o),m.categories.length>0?m.categoryBars.map((e,t)=>e.map((e,n)=>h.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):ln,opacity:p?.3:.6}))):m.bars.map((e,t)=>h.createElement("rect",{key:"bg-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:ln,opacity:p?.3:.6})),p&&(m.categories.length>0?m.selectedCategoryBars.map((e,t)=>e.map((e,n)=>h.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):ln,opacity:.7}))):m.selectedBars.map((e,t)=>h.createElement("rect",{key:"sel-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:ln,opacity:.7}))))}function So({label:e,cellSize:t}){return h.createElement("svg",{width:t,height:t},h.createElement("text",{x:t/2,y:t/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333"},e))}function jo(t){const{data:n,fields:o,fieldLabels:r={},colorBy:i,colorScheme:s,cellSize:a=150,cellGap:l=4,pointRadius:c=2,pointOpacity:u=.5,diagonal:d="histogram",histogramBins:g=20,brushMode:f="crossfilter",hoverMode:p=!0,unselectedOpacity:y=.1,showGrid:m=!1,tooltip:v,showLegend:b,idAccessor:x,className:k,onObservation:w,chartId:A}=t,O="splom",S="splom-hover",j=p?"hover":f?"brush":"hover",M=Vt(e=>e.clearSelection),[C,E]=e.useState(null),_=e.useCallback(()=>{M(S),E(null)},[M,S]),P=e.useMemo(()=>(n||[]).map((e,t)=>void 0!==e[xo]?e:Object.assign(Object.assign({},e),{[xo]:t})),[n]),B=dn(P,i,s),L=void 0!==b?b:!!i,N=e.useMemo(()=>{if(!L||!i)return null;const e="string"==typeof i?i:null;return e?[...new Set(P.map(t=>t[e]))].map(e=>({label:e+"",color:B?B(e+""):ln})):null},[L,i,P,B]),I=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 h.createElement("div",{className:k,style:{position:"relative"}},N&&h.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},N.map(e=>h.createElement("div",{key:e.label,style:{display:"flex",alignItems:"center",gap:4}},h.createElement("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:e.color}}),h.createElement("span",{style:{fontSize:11}},e.label)))),h.createElement("div",{style:I,onMouseLeave:"hover"===j?_:void 0},o.map((e,t)=>h.createElement(h.Fragment,{key:"row-"+e},h.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e),o.map((n,o)=>t===o?"label"===d?h.createElement(So,{key:"diag-"+e,label:r[e]||e,cellSize:a}):h.createElement(Oo,{key:"diag-"+e,data:P,field:e,label:r[e]||e,cellSize:a,bins:g,colorBy:i,colorScale:B,brushSelectionName:O,hoverSelectionName:S,unselectedOpacity:y,mode:j}):h.createElement(Ao,{key:`cell-${e}-${n}`,data:P,xField:n,yField:e,fieldLabels:r,cellSize:a,pointRadius:c,pointOpacity:u,colorBy:i,colorScale:B,brushSelectionName:O,hoverSelectionName:S,unselectedOpacity:y,showGrid:m,tooltip:v,mode:j,onPointHover:"hover"===j?(r,i,s)=>{r?(E({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})):(E(null),w&&w({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A}))}:void 0})))),h.createElement("div",null)," ",o.map(e=>h.createElement("div",{key:"col-label-"+e,style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e))),C&&"hover"===j&&(()=>{const e=C.datum,t=r[C.xField]||C.xField,n=r[C.yField]||C.yField,o=i?"function"==typeof i?i(e):e[i]:null,s=x?"function"==typeof x?x(e):e[x]:"Row "+e[xo];return h.createElement("div",{style:{position:"absolute",left:40+C.colIndex*(a+l)+C.px,top:C.rowIndex*(a+l)+C.py-8,transform:"translate(-50%, -100%)",color:"#333",background:"rgba(255,255,255,0.95)",border:"1px solid #ddd",borderRadius:3,padding:"4px 8px",fontSize:11,lineHeight:1.4,whiteSpace:"nowrap",pointerEvents:"none",zIndex:10}},h.createElement("div",{style:{fontWeight:"bold",marginBottom:2}},s+""),h.createElement("div",null,t,": ",null!=e[C.xField]?Number(e[C.xField]).toFixed(1):"–"),h.createElement("div",null,n,": ",null!=e[C.yField]?Number(e[C.yField]).toFixed(1):"–"),null!=o&&h.createElement("div",{style:{opacity:.8}},"string"==typeof i?i:"group",": ",o+""))})())}function Mo(e){const{brushMode:t="crossfilter",hoverMode:n=!0}=e,o={};return!n&&t&&(o.splom={resolution:t}),n&&(o["splom-hover"]={resolution:"union"}),h.createElement(on,{selections:o},h.createElement(jo,Object.assign({},e)))}function Co({width:o,height:r,margin:i,scales:s,brushDirection:a,extent:l,onBrush:c}){const u=e.useRef(null),d=e.useRef(null),g=e.useRef(!1),f=o+i.left+i.right,p=r+i.top+i.bottom;return e.useEffect(()=>{if(!u.current||!s)return;const e=t.select(u.current).select(".brush-group"),i="x"===a?n.brushX().extent([[0,0],[o,r]]):n.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),d.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null)}},[s,o,r,a,c]),e.useEffect(()=>{if(!d.current||!s||!u.current)return;const e=t.select(u.current).select(".brush-group"),n="x"===a?s.x:s.y;if(g.current=!0,l){const t=[n(l[0]),n(l[1])];e.call(d.current.move,t)}else e.call(d.current.move,null);g.current=!1},[l,s,a]),h.createElement("svg",{ref:u,width:f,height:p,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},h.createElement("g",{className:"brush-group",transform:`translate(${i.left},${i.top})`}))}function Eo(t){var n,o;const{data:r,width:i=600,height:s=400,margin:a,className:l,title:c,description:u,summary:d,xLabel:g,yLabel:f,xFormat:p,yFormat:y,xAccessor:m="x",yAccessor:v="y",lineBy:b,lineDataAccessor:x="coordinates",colorBy:k,colorScheme:w,curve:A="linear",lineWidth:O=2,fillArea:S=!1,areaOpacity:j=.3,showPoints:M=!1,pointRadius:C=3,enableHover:_=!0,showGrid:P=!1,showLegend:B,legendPosition:L,tooltip:N,minimap:I={},renderBefore:T=!1,onBrush:H,brushExtent:F,frameProps:z={},loading:R,emptyContent:$}=t,D=oo(R,i,s),W=D?null:no(r,i,s,$),G=r||[],[Y,q]=e.useState(null),X=null!=F?F:Y,V=e.useCallback(e=>{F||q(e),null==H||H(e)},[F,H]),U=e.useRef(null),[Q,K]=e.useState(null);e.useEffect(()=>{const e=()=>{var t,n;const o=null===(n=null===(t=U.current)||void 0===t?void 0:t.getScales)||void 0===n?void 0:n.call(t);o?K(o):requestAnimationFrame(e)};requestAnimationFrame(e)},[r]);const J=void 0!==(null===(n=G[0])||void 0===n?void 0:n[x]),Z=e.useMemo(()=>{if(J)return G;if(b){const e=G.reduce((e,t)=>{const n="function"==typeof b?b(t):t[b];if(!e[n]){const t={[x]:[]};"string"==typeof b&&(t[b]=n),e[n]=t}return e[n][x].push(t),e},{});return Object.values(e)}return[{[x]:G}]},[G,b,x,J]),ee=e.useMemo(()=>J||b?Z.flatMap(e=>{const t=e[x]||[];return b&&"string"==typeof b?t.map(t=>Object.assign(Object.assign({},t),{[b]:e[b]})):t}):G,[Z,x,J,b,G]),te=dn(G,k,w),ne=e.useMemo(()=>e=>{const t={strokeWidth:O};return t.stroke=k?E(e,k,te):ln,S&&(t.fill=t.stroke,t.fillOpacity=j),t},[k,te,O,S,j]),oe=e.useMemo(()=>I.lineStyle?I.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=k?E(e,k,te):ln,t},[k,te,I.lineStyle]),re=e.useMemo(()=>{if(M)return e=>{const t={r:C,fillOpacity:1};return t.fill=k?E(e.parentLine||e,k,te):ln,t}},[M,C,k,te]),{legend:ie,margin:se,legendPosition:ae}=fn({data:Z,colorBy:k,colorScale:te,showLegend:B,legendPosition:L,userMargin:a}),le=I.height||60,ce=e.useMemo(()=>{var e,t,n,o,r,i,s,a;return{top:null!==(t=null===(e=I.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(o=null===(n=I.margin)||void 0===n?void 0:n.bottom)&&void 0!==o?o:20,left:null!==(i=null===(r=I.margin)||void 0===r?void 0:r.left)&&void 0!==i?i:se.left,right:null!==(a=null===(s=I.margin)||void 0===s?void 0:s.right)&&void 0!==a?a:se.right}},[I.margin,se]),ue=I.brushDirection||"x",de=Nn({componentName:"MinimapChart",data:r,accessors:{xAccessor:m,yAccessor:v}});if(de)return h.createElement(Cn,{componentName:"MinimapChart",message:de,width:i,height:s});const he=S?"area":"line",ge=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:he,data:ee,xAccessor:m,yAccessor:v,groupAccessor:b||void 0,curve:A,lineStyle:ne},M&&{pointStyle:re}),{size:[i,s],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:se,showAxes:!0,xLabel:g,yLabel:f,xFormat:p,yFormat:y,enableHover:_,showGrid:P}),ie&&{legend:ie,legendPosition:ae}),c&&{title:c}),u&&{description:u}),d&&{summary:d}),N&&{tooltipContent:An(N)||void 0}),X&&{xExtent:X}),z),fe={chartType:he,data:ee,xAccessor:m,yAccessor:v,groupAccessor:b||void 0,curve:A,lineStyle:oe,size:[i,le+ce.top+ce.bottom],margin:ce,showAxes:null!==(o=I.showAxes)&&void 0!==o&&o,background:I.background,enableHover:!1},pe=h.createElement("div",{key:"minimap",style:{position:"relative",width:i,overflow:"hidden"}},h.createElement(Dt,Object.assign({ref:U},fe)),h.createElement(Co,{width:i-ce.left-ce.right,height:le,margin:ce,scales:Q,brushDirection:ue,extent:X,onBrush:V})),ye=h.createElement("div",{key:"main",style:{overflow:"hidden"}},h.createElement(Dt,Object.assign({},ge)));return D||W||h.createElement(Zn,{componentName:"MinimapChart",width:i,height:s},h.createElement("div",{className:"minimap-chart"+(l?" "+l:"")},T?pe:ye,T?ye:pe))}Mo.displayName="ScatterplotMatrix",Eo.displayName="MinimapChart";const _o=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)},remove:e=>{var t,n;return null!==(n=null===(t=o.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=o.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},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=mn(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:d="y",xCenter:g,yCenter:f,quadrants:p,centerlineStyle:y={},showQuadrantLabels:m=!0,quadrantLabelSize:v=12,colorBy:b,colorScheme:x,sizeBy:k,sizeRange:w=[3,15],pointRadius:A=5,pointOpacity:O=.8,tooltip:S,pointIdAccessor:j,annotations:M,frameProps:C={},selection:_,linkedHover:B,onObservation:L,onClick:N,hoverHighlight:I,chartId:T,loading:H,emptyContent:F,legendInteraction:z,legendPosition:R,color:$}=t,D=r.width,W=r.height,G=r.enableHover,Y=r.showGrid,q=r.showLegend,X=r.title,V=r.description,U=r.summary,Q=r.accessibleTable,K=r.xLabel,J=r.yLabel,Z=oo(H,D,W),ee=Z?null:no(i,D,W,F),te=i||[];ro("QuadrantChart",te,"xAccessor",u),ro("QuadrantChart",te,"yAccessor",d);const{activeSelectionHook:ne,hoverSelectionHook:oe,customHoverBehavior:re,customClickBehavior:ie,crosshairSourceId:se}=hn({selection:_,linkedHover:B,fallbackFields:"string"==typeof b?[b]:[],onObservation:L,onClick:N,chartType:"QuadrantChart",chartId:T,hoverHighlight:I,colorByField:"string"==typeof b?b:void 0}),ae=gn(B,se),le=dn(te,b,x),ce=e.useMemo(()=>{if(!b)return[];const e=new Set;for(const t of te){const n="function"==typeof b?b(t):t[b];null!=n&&e.add(n+"")}return Array.from(e)},[te,b]),ue=pn(z,b,ce),de=e.useMemo(()=>oe||(ue.legendSelectionHook?ue.legendSelectionHook:ne),[oe,ue.legendSelectionHook,ne]),he=e.useMemo(()=>{if(!te.length)return;const e="function"==typeof u?u:e=>+e[u],t="function"==typeof d?d:e=>+e[d];let n=1/0,o=-1/0,r=1/0,i=-1/0;for(const s of te){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!=f&&isFinite(f)&&(r>f&&(r=f),f>i&&(i=f)),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]}},[te,u,d,g,f]),ge=e.useMemo(()=>{if(!k||0===te.length)return;const e=te.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},[te,k]),fe=e.useMemo(()=>"function"==typeof u?u:e=>+e[u],[u]),pe=e.useMemo(()=>"function"==typeof d?d:e=>+e[d],[d]),ye=e.useMemo(()=>e=>{const t={fillOpacity:O};if(b)le&&(t.fill=E(e,b,le));else{const n=fe(e),o=pe(e),r=null!=g?n>=g:void 0,i=null!=f?o>=f:void 0;t.fill=void 0===i||void 0===r?$||ln:i&&r?p.topRight.color:i&&!r?p.topLeft.color:!i&&r?p.bottomRight.color:p.bottomLeft.color}return t.r=k?P(e,k,w,ge):A,t},[b,le,k,w,ge,A,O,fe,pe,g,f,p,$]),me=e.useMemo(()=>an(ye,de,_),[ye,de,_]),{legend:ve,margin:be,legendPosition:xe}=fn({data:te,colorBy:b,colorScale:le,showLegend:q,legendPosition:R,userMargin:s,defaults:r.marginDefaults}),ke=e.useMemo(()=>{if(!te.length)return;const e=new Set;"string"==typeof u&&e.add(u),"string"==typeof d&&e.add(d),"string"==typeof b&&e.add(b),"string"==typeof k&&e.add(k);const t=te[0];for(const n of Object.keys(t))if(!n.startsWith("_")&&!e.has(n)&&"string"==typeof t[n])return n},[te,u,d,b,k]),we=e.useMemo(()=>Mn([...ke?[{label:ke,accessor:ke,role:"title"}]:[],{label:K||On(u),accessor:u,role:"x"},{label:J||On(d),accessor:d,role:"y"},...b?[{label:On(b),accessor:b,role:"color"}]:[],...k?[{label:On(k),accessor:k,role:"size"}]:[]]),[ke,u,d,K,J,b,k]),Ae=Nn({componentName:"QuadrantChart",data:i,accessors:{xAccessor:u,yAccessor:d}}),Oe=e.useMemo(()=>{var e;const t={stroke:y.stroke||"#999",strokeWidth:null!==(e=y.strokeWidth)&&void 0!==e?e:1,dashArray:y.strokeDasharray||[]};return[(e,n,o,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!=f?o.y(f):a/2;if(null!=g&&!isFinite(l))return;if(null!=f&&!isFinite(c))return;const u=Math.max(0,Math.min(s,l)),d=Math.max(0,Math.min(a,c)),h=[{config:p.topLeft,x:0,y:0,w:u,h:d},{config:p.topRight,x:u,y:0,w:s-u,h:d},{config:p.bottomLeft,x:0,y:d,w:u,h:a-d},{config:p.bottomRight,x:u,y:d,w:s-u,h:a-d}];for(const t of h)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,d),e.lineTo(s,d),e.stroke(),e.setLineDash([])}]},[g,f,p,y]),Se=e.useMemo(()=>m?[...Oe,(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!=f?n.y(f):i/2;(null==g||isFinite(s))&&(null==f||isFinite(a))&&(e.font=`600 ${v}px sans-serif`,e.globalAlpha=.5,e.fillStyle=p.topLeft.color,e.textAlign="left",e.textBaseline="top",e.fillText(p.topLeft.label,8,8),e.fillStyle=p.topRight.color,e.textAlign="right",e.textBaseline="top",e.fillText(p.topRight.label,r-8,8),e.fillStyle=p.bottomLeft.color,e.textAlign="left",e.textBaseline="bottom",e.fillText(p.bottomLeft.label,8,i-8),e.fillStyle=p.bottomRight.color,e.textAlign="right",e.textBaseline="bottom",e.fillText(p.bottomRight.label,r-8,i-8),e.globalAlpha=1)}]:Oe,[Oe,m,v,p,g,f]),je=e.useMemo(()=>{const e=C.canvasPreRenderers||[];return[...Se,...e]},[Se,C.canvasPreRenderers]),Me=e.useMemo(()=>{var e;const t={stroke:y.stroke||"#999",strokeWidth:null!==(e=y.strokeWidth)&&void 0!==e?e:1,dashArray:y.strokeDasharray?Array.isArray(y.strokeDasharray)?y.strokeDasharray.join(","):y.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!=f?n.y(f):i/2;if(null!=g&&!isFinite(s))return null;if(null!=f&&!isFinite(a))return null;const l=Math.max(0,Math.min(r,s)),c=Math.max(0,Math.min(i,a));return h.createElement(h.Fragment,null,[{config:p.topLeft,x:0,y:0,w:l,h:c},{config:p.topRight,x:l,y:0,w:r-l,h:c},{config:p.bottomLeft,x:0,y:c,w:l,h:i-c},{config:p.bottomRight,x:l,y:c,w:r-l,h:i-c}].map((e,t)=>{var n;return e.w>0&&e.h>0?h.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}),h.createElement("line",{x1:l,y1:0,x2:l,y2:i,stroke:t.stroke,strokeWidth:t.strokeWidth,strokeDasharray:t.dashArray}),h.createElement("line",{x1:0,y1:c,x2:r,y2:c,stroke:t.stroke,strokeWidth:t.strokeWidth,strokeDasharray:t.dashArray}),m&&h.createElement(h.Fragment,null,h.createElement("text",{x:8,y:8+v,fill:p.topLeft.color,fontWeight:600,fontSize:v,opacity:.5},p.topLeft.label),h.createElement("text",{x:r-8,y:8+v,fill:p.topRight.color,fontWeight:600,fontSize:v,opacity:.5,textAnchor:"end"},p.topRight.label),h.createElement("text",{x:8,y:i-8,fill:p.bottomLeft.color,fontWeight:600,fontSize:v,opacity:.5},p.bottomLeft.label),h.createElement("text",{x:r-8,y:i-8,fill:p.bottomRight.color,fontWeight:600,fontSize:v,opacity:.5,textAnchor:"end"},p.bottomRight.label)))}]},[g,f,p,y,m,v]),Ce=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(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=i&&{data:te}),{xAccessor:u,yAccessor:d,colorAccessor:b||void 0,sizeAccessor:k||void 0,sizeRange:w,pointStyle:me,colorScheme:x,size:[D,W],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:be,showAxes:r.showAxes,xLabel:K,yLabel:J,xFormat:l,yFormat:c,enableHover:G,showGrid:Y}),he&&{xExtent:he.xExtent,yExtent:he.yExtent}),ve&&{legend:ve,legendPosition:xe}),z&&"none"!==z&&{legendHoverBehavior:ue.onLegendHover,legendClickBehavior:ue.onLegendClick,legendHighlightedCategory:ue.highlightedCategory,legendIsolatedCategories:ue.isolatedCategories}),X&&{title:X}),V&&{description:V}),U&&{summary:U}),void 0!==Q&&{accessibleTable:Q}),a&&{className:a}),{tooltipContent:!1===S?()=>null:!0===S||void 0===S?we:An(S)||we}),(B||L||N||I)&&{customHoverBehavior:re}),(L||N||B)&&{customClickBehavior:ie}),j&&{pointIdAccessor:j}),M&&M.length>0&&{annotations:M}),{canvasPreRenderers:je}),ae),C),je.length>0&&{canvasPreRenderers:je}),{svgPreRenderers:Me});return Z||ee||(Ae?h.createElement(Cn,{componentName:"QuadrantChart",message:Ae,width:D,height:W}):h.createElement(Zn,{componentName:"QuadrantChart",width:D,height:W},h.createElement(Dt,Object.assign({ref:o},Ce))))});_o.displayName="QuadrantChart";const Po="__ma_unitized",Bo="__ma_series";function Lo(e,t){const n=t[1]-t[0];return 0===n?.5:(e-t[0])/n}function No(e,t){return t[0]+e*(t[1]-t[0])}const Io=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),{[Po]:Lo(a,r),[Bo]: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),{[Po]:Lo(a,i),[Bo]:r.label||"Series "+(e+1)}))}i.current.pushMany(n)},remove:e=>{var t,n;return null!==(n=null===(t=i.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=i.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},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=mn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,accessibleTable:t.accessibleTable},{width:800,height:400}),{data:l,margin:c,className:u,xFormat:d,xAccessor:g="x",series:f,colorScheme:p,curve:y="monotoneX",lineWidth:m=2,tooltip:v,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:A,onClick:O,hoverHighlight:M,chartId:C,loading:E,emptyContent:_,legendInteraction:P,legendPosition:B}=t,L=a.width,N=a.height,I=a.enableHover,T=a.showGrid,H=null===(o=a.showLegend)||void 0===o||o,F=a.title,z=a.description,R=a.summary,$=a.accessibleTable,D=a.xLabel,W=2===f.length;"undefined"==typeof process||"production"===(null===(r=process.env)||void 0===r?void 0:r.NODE_ENV)||W||console.warn(`[MultiAxisLineChart] Expected exactly 2 series for dual-axis mode, got ${f.length}. Rendering as a standard multi-line chart.`);const G=oo(E,L,N),Y=G?null:no(l,L,N,_),q=l||[],X=cn(),V=e.useMemo(()=>{let e;if(Array.isArray(p))e=p;else if(X&&X.length>0)e=X;else{const t=S[p];e=Array.isArray(t)?t:j}return f.map((t,n)=>t.color||e[n%e.length])},[f,p,X]),U=e.useMemo(()=>f.map((e,t)=>e.label||"Series "+(t+1)),[f]),{unitizedData:Q,extents:K}=e.useMemo(()=>{if(0===q.length){const e=f.map(e=>e.extent||null).filter(Boolean);return e.length===f.length&&(s.current=e),{unitizedData:[],extents:e.length===f.length?e:[]}}const e=f.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]}(q,e.yAccessor));if(s.current=e,!W){const t=[];for(const e of q)for(let n=0;f.length>n;n++){const o=f[n],r=("function"==typeof o.yAccessor?o.yAccessor:e=>e[o.yAccessor])(e);null!=r&&t.push(Object.assign(Object.assign({},e),{[Po]:r,[Bo]:U[n]}))}return{unitizedData:t,extents:e}}const t=[];for(const n of q)for(let o=0;2>o;o++){const r=f[o],i=("function"==typeof r.yAccessor?r.yAccessor:e=>e[r.yAccessor])(n);null!=i&&t.push(Object.assign(Object.assign({},n),{[Po]:Lo(i,e[o]),[Bo]:U[o]}))}return{unitizedData:t,extents:e}},[q,f,W,U]),J=e.useMemo(()=>{if(W&&K.length>=2)return[{orient:"left",label:U[0],tickFormat:f[0].format||(e=>{const t=No(e,K[0]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"right",label:U[1],tickFormat:f[1].format||(e=>{const t=No(e,K[1]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"bottom"}]},[W,K,f,U]),Z=fo({data:e.useMemo(()=>Q.length>0?Q:U.map(e=>({[Bo]:e})),[Q,U]),rawData:l,colorBy:Bo,colorScheme:V,legendInteraction:P,legendPosition:B,selection:k,linkedHover:w,fallbackFields:[Bo],unwrapData:!1,onObservation:A,onClick:O,hoverHighlight:M,chartType:"MultiAxisLineChart",chartId:C,showLegend:H,userMargin:c,marginDefaults:W?Object.assign(Object.assign({},a.marginDefaults),{left:70,right:70}):a.marginDefaults,loading:E,emptyContent:_,width:L,height:N});if(Z.earlyReturn)return Z.earlyReturn;const ee=e.useMemo(()=>{const e=new Map;return U.forEach((t,n)=>e.set(t,V[n])),t=>({stroke:e.get(t[Bo])||V[0],strokeWidth:m,fill:"none"})},[U,V,m]),te=e.useMemo(()=>an(ee,Z.effectiveSelectionHook,k),[ee,Z.effectiveSelectionHook,k]),ne=e.useMemo(()=>{if(!1===v)return()=>null;return An(v)||(e=>{var t;const n=e.data||e,o=n[Bo],r=U.indexOf(o),i=n[Po],s=W&&r>=0&&K[r]?No(i,K[r]):i,a=r>=0&&(null===(t=f[r])||void 0===t?void 0:t.format)?f[r].format:e=>Number.isInteger(e)?e+"":e.toFixed(2),l="function"==typeof g?g(n):n[g];return h.createElement("div",{style:{padding:"6px 10px",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-tooltip-font-size, 13px)"}},h.createElement("div",{style:{fontWeight:600,marginBottom:4,color:V[r]||"inherit"}},o),h.createElement("div",null,`${"string"==typeof g?g:"x"}: ${l}`),h.createElement("div",null,`${o}: ${a(s)}`))})},[v,U,V,K,W,f,g]),oe=Nn({componentName:"MultiAxisLineChart",data:l,accessors:{xAccessor:g}}),re=W?[0,1]:void 0,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(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:Po,groupAccessor:Bo,lineStyle:te,colorScheme:V,size:[L,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Z.margin,showAxes:a.showAxes}),J&&{axes:J}),{xLabel:D}),W?{}:{yLabel:U[0]}),{xFormat:d}),W&&re&&{yExtent:re}),{enableHover:I}),t.pointIdAccessor&&{pointIdAccessor:t.pointIdAccessor}),{showGrid:T,curve:y}),Z.legendBehaviorProps),F&&{title:F}),z&&{description:z}),R&&{summary:R}),void 0!==$&&{accessibleTable:$}),u&&{className:u}),{tooltipContent:ne}),b&&{annotations:b}),(w||A||O||M)&&{customHoverBehavior:Z.customHoverBehavior}),(A||O||w)&&{customClickBehavior:Z.customClickBehavior}),Z.crosshairProps),x);return G||Y||(oe?h.createElement(Cn,{componentName:"MultiAxisLineChart",message:oe,width:L,height:N}):h.createElement(Zn,{componentName:"MultiAxisLineChart",width:L,height:N},h.createElement(Dt,Object.assign({ref:i},ie))))});function To(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 Ho(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")}`}Io.displayName="MultiAxisLineChart";const Fo="__forecastSegment";function zo(e,t){return"function"==typeof t?t(e):!!e[t]}const Ro=Object.freeze({__proto__:null,SEGMENT_FIELD:Fo,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:d,upperBounds:h,lowerBounds:g,color:f="#6366f1",bandOpacity:p=.15,anomalyColor:y="#ef4444",anomalyRadius:m=6,label:v}=o,b=e.map(e=>{let t="observed";return u&&zo(e,u)?t="forecast":c&&zo(e,c)&&(t="training"),Object.assign(Object.assign({},e),{[Fo]:t})}),x=o._groupBy,k=[];if(x){const e=new Map;for(const t of b){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][Fo]!==n[e+1][Fo]&&(t.push(Object.assign(Object.assign({},n[e+1]),{[Fo]:n[e][Fo]})),t.push(Object.assign(Object.assign({},n[e]),{[Fo]:n[e+1][Fo]})));k.push(...b,...t)}else for(let e=0;b.length>e;e++)k.push(b[e]),b.length-1>e&&b[e][Fo]!==b[e+1][Fo]&&(k.push(Object.assign(Object.assign({},b[e+1]),{[Fo]:b[e][Fo]})),k.push(Object.assign(Object.assign({},b[e]),{[Fo]:b[e+1][Fo]})));if(o.trainUnderline){const e=[];for(const t of k)"training"===t[Fo]&&e.push(Object.assign(Object.assign({},t),{[Fo]:"training-base"}));k.unshift(...e)}const w=[];if(h&&g){const e="string"==typeof h?h:"__envUpper",t="string"==typeof g?g:"__envLower";if("function"==typeof h||"function"==typeof g)for(const n of k)"function"==typeof h&&(n[e]=h(n)),"function"==typeof g&&(n[t]=g(n));w.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:f,fillOpacity:p,label:v})}if(d){const e=o.anomalyStyle,t={type:"highlight",filter:e=>zo(e,d)};e?(t.style=e,t.r=m):"function"==typeof y?(t.style=e=>{const t=y(e);return{stroke:t,strokeWidth:1.5,fill:t,fillOpacity:.7}},t.r=m):(t.color=y,t.r=m,t.style={stroke:y,strokeWidth:1.5,fill:y,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:d="#6366f1",bandOpacity:h=.15,label:g}=o;if(null==l)return{processedData:e,annotations:[]};const f=[],p=[];for(const n of e)n[t]>l?p.push(Object.assign(Object.assign({},n),{[Fo]:"observed"})):f.push(Object.assign(Object.assign({},n),{[Fo]:"training"}));const y=f.map(e=>[e[t],e[n]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),m=[],v=[];if(y.length>=3){const o=y.length;let r=0,i=0,s=0,a=0;for(const[e,t]of y)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,f=(i-s*r)/o,p=e=>f+s*e,b=y.map(([e,t])=>t-p(e)).reduce((e,t)=>e+t*t,0),x=Math.sqrt(b/Math.max(o-2,1)),k=y.reduce((e,t)=>e+t[0],0)/o,w=y.reduce((e,t)=>e+Math.pow(t[0]-k,2),0),A=.99>u?.95>u?.9>u?1:1.645:1.96:2.576,O=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),S=Math.max(...O),j=y.length>1?(y[o-1][0]-y[0][0])/(o-1):1;for(let e=1;c>=e;e++){const r=S+e*j,i=p(r),s=x*Math.sqrt(1+1/o+(w>0?Math.pow(r-k,2)/w:0))*A;v.push({[t]:r,[n]:i,[Fo]:"forecast",__forecastUpper:i+s,__forecastLower:i-s})}m.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:d,fillOpacity:h,label:g})}}m.push({type:"x-threshold",x:l,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),r&&m.push({type:"anomaly-band",threshold:null!==(i=r.threshold)&&void 0!==i?i:2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:null!==(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(...f),f.length>0&&p.length>0&&b.push(Object.assign(Object.assign({},f[f.length-1]),{[Fo]:"observed"})),b.push(...p),v.length>0){const e=p.length>0?p[p.length-1]:f[f.length-1];e&&b.push(Object.assign(Object.assign({},e),{[Fo]:"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",a=t.trainOpacity,l=t.forecastOpacity,c=t.trainStroke,u=t.trainLinecap,d=t.trainUnderline;return t=>{const n=e(t),o=t[Fo];if("training"===o){let e=n.stroke;return"darken"===c?e=To(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"===d&&(e=Ho(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:To,lightenColor:Ho});exports.AreaChart=uo,exports.BubbleChart=vo,exports.ConnectedScatterplot=mo,exports.Heatmap=bo,exports.LineChart=co,exports.MinimapChart=Eo,exports.MultiAxisLineChart=Io,exports.QuadrantChart=_o,exports.Scatterplot=po,exports.ScatterplotMatrix=Mo,exports.StackedAreaChart=go,exports.StreamXYFrame=Dt;
|