semiotic 3.0.0-beta.6 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +1 -1
- package/README.md +2 -2
- 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.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +6 -5
package/CLAUDE.md
CHANGED
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
Push API: `chartRef.current.push({ time, value })`
|
|
58
58
|
|
|
59
59
|
**RealtimeLineChart** — `size`, `timeAccessor`, `valueAccessor`, `windowSize` (200), `windowMode`, `stroke`, `strokeWidth`
|
|
60
|
-
**
|
|
60
|
+
**RealtimeHistogram** — + `binSize` (required), `categoryAccessor`, `colors`
|
|
61
61
|
**RealtimeSwarmChart** — + `categoryAccessor`, `radius`, `opacity`
|
|
62
62
|
**RealtimeWaterfallChart** — + `positiveColor`, `negativeColor`
|
|
63
63
|
**RealtimeHeatmap** — + `heatmapXBins`, `heatmapYBins`, `aggregation`
|
package/README.md
CHANGED
|
@@ -102,10 +102,10 @@ highlights new services as they appear. Visualization as product navigation.
|
|
|
102
102
|
## Install
|
|
103
103
|
|
|
104
104
|
```bash
|
|
105
|
-
npm install semiotic@3.0.0
|
|
105
|
+
npm install semiotic@3.0.0
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
-
Requires React 18.1 or
|
|
108
|
+
Requires React 18.1+ or React 19.
|
|
109
109
|
|
|
110
110
|
## Quick Examples
|
|
111
111
|
|
package/dist/ordinal.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react"),t=require("d3-scale"),n=require("d3-array"),o=require("d3-hierarchy"),s=require("d3-scale-chromatic");function i(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 r=i(e),a=5e3;class l{constructor(e){this.lastBoundedData=null,this.chunkTimer=0,this.callback=e}clearLastData(){this.lastBoundedData=null,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(e===this.lastBoundedData)return;if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),5e3>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,a),bounded:!0,totalSize:e.length});let t=a;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const o=Math.min(t+a,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}push(e){this.callback({inserts:[e],bounded:!1})}pushMany(e){0!==e.length&&this.callback({inserts:e,bounded:!1})}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null}}class c{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}toArray(){const e=[];for(const t of this)e.push(t);return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class u{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 h(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function d(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}function m(e,t,n,o,s,i,r){return{type:"rect",x:e,y:t,w:n,h:o,style:s,datum:i,group:r}}function g(e,t){const{columns:n,config:o,resolvePieceStyle:s}=e,i=[],r=Math.min(t.width,t.height)/2-4,a="donut"===o.chartType?o.innerRadius||60:0,l=-Math.PI/2+(o.startAngle||0)*Math.PI/180,c=2*Math.PI;for(const e of Object.values(n)){const t=l+e.pctStart*c,n=l+(e.pctStart+e.pct)*c,o=s(e.pieceData[0],e.name);i.push({type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:r,startAngle:t,endAngle:n,style:o,datum:e.pieceData,category:e.name})}return i}function f(e){var t,o,s;const i=e.length,r=e[0],a=e[i-1];return{n:i,min:r,q1:null!==(t=n.quantile(e,.25))&&void 0!==t?t:r,median:null!==(o=n.quantile(e,.5))&&void 0!==o?o:(r+a)/2,q3:null!==(s=n.quantile(e,.75))&&void 0!==s?s:a,max:a,mean:e.reduce((e,t)=>e+t,0)/i}}const p={bar:function(e,t){const{scales:n,columns:o,config:s,getR:i,getStack:r,resolvePieceStyle:a}=e,{r:l,projection:c}=n,u=[],h="vertical"===c,d="horizontal"===c,g=s.normalize;for(const e of Object.values(o)){const t=new Map;for(const n of e.pieceData){const e=r?r(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const o=t.get(e);o.total+=i(n),o.pieces.push(n)}let n=0;if(g)for(const e of t.values())n+=Math.abs(e.total);let o=0,s=0;for(const[i,c]of t){let t=c.total;g&&n>0&&(t/=n);const f=a(c.pieces[0],r?i:e.name),p=Object.assign(Object.assign({},c.pieces[0]),{__aggregateValue:c.total,__pieceCount:c.pieces.length,category:e.name});if(h){const n=l(0>t?s:o+t),r=0>t?l(s+t)-l(s):l(o)-l(o+t);u.push(m(e.x,n,e.width,Math.abs(r),f,p,i)),0>t?s+=t:o+=t}else if(d){const n=l(0>t?s+t:o),r=0>t?l(s)-l(s+t):l(o+t)-l(o);u.push(m(n,e.x,Math.abs(r),e.width,f,p,i)),0>t?s+=t:o+=t}}}return u},clusterbar:function(e,t){const{scales:n,columns:o,getR:s,getGroup:i,resolvePieceStyle:r}=e,{r:a,projection:l}=n,c=[],u="vertical"===l,h=[],d=new Set;for(const e of Object.values(o))for(const t of e.pieceData){const e=i?i(t):"_default";d.has(e)||(d.add(e),h.push(e))}const g=h.length||1;for(const e of Object.values(o)){const t=e.width/g,n=new Map;for(const t of e.pieceData){const e=i?i(t):"_default";n.has(e)||n.set(e,[]),n.get(e).push(t)}for(let o=0;h.length>o;o++){const i=n.get(h[o])||[];for(const n of i){const i=s(n),l=r(n,e.name);if(u){const s=e.x+o*t,r=a(0),u=a(i);c.push(m(s,Math.min(r,u),t,Math.abs(r-u),l,n,h[o]))}else{const s=e.x+o*t,r=a(0),u=a(i);c.push(m(Math.min(r,u),s,Math.abs(u-r),t,l,n,h[o]))}}}}return c},point:function(e,t){var n,o;const{scales:s,columns:i,getR:r,multiScales:a,resolvePieceStyle:l}=e,{r:c,projection:u}=s,h=[],d="vertical"===u,m="radial"===u,g=a.length>0,f=2*Math.PI,p=-Math.PI/2;for(const e of Object.values(i))for(const t of e.pieceData){const s=null!==(n=t.__rIndex)&&void 0!==n?n:0,i=null!==(o=t.__rValue)&&void 0!==o?o:r(t),u=g&&a[s]||c,y=l(t,e.name),v=y.r||5;let b,x;if(m){const t=p+(e.pctStart+e.pct/2)*f,n=u(i);b=Math.cos(t)*n,x=Math.sin(t)*n}else d?(b=e.middle,x=u(i)):(b=u(i),x=e.middle);h.push({type:"point",x:b,y:x,r:v,style:y,datum:t})}return h},swarm:function(e,t){const{scales:n,columns:o,getR:s,resolvePieceStyle:i}=e,{r:r,projection:a}=n,l=[],c="vertical"===a;for(const e of Object.values(o)){const t=e.width/2;for(let n=0;e.pieceData.length>n;n++){const o=e.pieceData[n],a=s(o),u=i(o,e.name),h=u.r||4,d=(7919*n%100/100-.5)*t*.8,m=c?e.middle+d:r(a),g=c?r(a):e.middle+d;l.push({type:"point",x:m,y:g,r:h,style:u,datum:o})}}return l},pie:g,donut:g,boxplot:function(e,t){var o,s,i,r,a;const{scales:l,columns:c,config:u,getR:h,resolveSummaryStyle:d}=e,{r:m,projection:g}=l,f=[],p="vertical"===g,y=!1!==u.showOutliers;for(const e of Object.values(c)){const t=e.pieceData.map(e=>h(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===t.length)continue;const l=t[0],c=t[t.length-1],u=null!==(o=n.quantile(t,.25))&&void 0!==o?o:l,g=null!==(s=n.quantile(t,.5))&&void 0!==s?s:(l+c)/2,v=null!==(i=n.quantile(t,.75))&&void 0!==i?i:c,b=v-u,x=u-1.5*b,w=v+1.5*b,k=null!==(r=t.find(e=>e>=x))&&void 0!==r?r:l,A=null!==(a=[...t].reverse().find(e=>w>=e))&&void 0!==a?a:c,E=d(e.pieceData[0],e.name),M=[];if(y)for(const t of e.pieceData){const n=h(t);if(x>n||n>w){const o=p?e.middle:m(n),s=p?m(n):e.middle;M.push({px:o,py:s,value:n,datum:t})}}if(f.push({type:"boxplot",x:p?e.middle:0,y:p?0:e.middle,projection:p?"vertical":"horizontal",columnWidth:.6*e.width,minPos:m(k),q1Pos:m(u),medianPos:m(g),q3Pos:m(v),maxPos:m(A),stats:{min:k,q1:u,median:g,q3:v,max:A},style:E,datum:e.pieceData,category:e.name,outliers:M}),y)for(const e of M)f.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:E.fill||"#999",opacity:.6},datum:e.datum})}return f},violin:function(e,t){var o,s,i;const{scales:r,columns:a,config:l,getR:c,resolveSummaryStyle:u}=e,{r:h,projection:d}=r,m=[],g="vertical"===d,p=l.bins||20,y=!1!==l.showIQR;for(const e of Object.values(a)){const t=e.pieceData.map(e=>c(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const r=t[0],a=t[t.length-1],l=(a-r)/p||1,d=Array(p).fill(0);for(const e of t)d[Math.min(Math.floor((e-r)/l),p-1)]++;const v=Math.max(...d,1),b=e.width/2*.9;let x="";if(g){for(let t=0;p>t;t++){const n=h(r+(t+.5)*l),o=d[t]/v*b;x+=0===t?`M ${e.middle+o} ${n}`:` L ${e.middle+o} ${n}`}for(let t=p-1;t>=0;t--){const n=h(r+(t+.5)*l);x+=` L ${e.middle-d[t]/v*b} ${n}`}x+=" Z"}else{for(let t=0;p>t;t++){const n=h(r+(t+.5)*l),o=d[t]/v*b;x+=0===t?`M ${n} ${e.middle-o}`:` L ${n} ${e.middle-o}`}for(let t=p-1;t>=0;t--)x+=` L ${h(r+(t+.5)*l)} ${e.middle+d[t]/v*b}`;x+=" Z"}const w=u(e.pieceData[0],e.name);let k;if(y&&t.length>=4){const l=null!==(o=n.quantile(t,.25))&&void 0!==o?o:r,c=null!==(s=n.quantile(t,.5))&&void 0!==s?s:(r+a)/2,u=null!==(i=n.quantile(t,.75))&&void 0!==i?i:a;k={q1Pos:h(l),medianPos:h(c),q3Pos:h(u),centerPos:e.middle,isVertical:g}}const A=g?{x:e.x,y:Math.min(h(a),h(r)),width:e.width,height:Math.abs(h(a)-h(r))}:{x:Math.min(h(r),h(a)),y:e.x,width:Math.abs(h(a)-h(r)),height:e.width};m.push({type:"violin",pathString:x,translateX:0,translateY:0,bounds:A,iqrLine:k,stats:f(t),style:w,datum:e.pieceData,category:e.name})}return m},histogram:function(e,t){const{scales:n,columns:o,config:s,getR:i,resolveSummaryStyle:r}=e,{r:a}=n,l=[],c=s.bins||25,u=s.normalize;for(const e of Object.values(o)){const t=e.pieceData.map(e=>i(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const n=Math.min(...t),o=(Math.max(...t)-n)/c||1,s=Array(c).fill(0);for(const e of t)s[Math.min(Math.floor((e-n)/o),c-1)]++;const h=t.length,d=Math.max(...s,1),g=r(e.pieceData[0],e.name);for(let t=0;c>t;t++){if(0===s[t])continue;const i=(u?s[t]/h:s[t]/d)*e.width*.9,r=a(n+t*o),c=a(n+(t+1)*o);l.push(m(Math.min(r,c),e.x+e.width-i,Math.abs(c-r),i,g,{bin:t,count:s[t],range:[n+t*o,n+(t+1)*o],category:e.name},e.name))}}return l},ridgeline:function(e,t){var n;const{scales:o,columns:s,config:i,getR:r,resolveSummaryStyle:a}=e,{r:l,projection:c}=o,u=[],h=i.bins||20,d="horizontal"===c,m=i.amplitude||1.5;for(const e of Object.values(s)){const t=e.pieceData.map(e=>r(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const o=t[0],s=t[t.length-1],i=(s-o)/h||1,c=Array(h).fill(0);for(const e of t)c[Math.min(Math.floor((e-o)/i),h-1)]++;const g=Math.max(...c,1),p=a(e.pieceData[0],e.name),y=e.width*m;let v="";if(d){const t=e.x+e.width;v=`M ${l(o)} ${t}`;for(let e=0;h>e;e++)v+=` L ${l(o+(e+.5)*i)} ${t-c[e]/g*y}`;v+=` L ${l(s)} ${t} Z`}else{const t=e.x;v=`M ${t} ${l(o)}`;for(let e=0;h>e;e++){const n=l(o+(e+.5)*i);v+=` L ${t+c[e]/g*y} ${n}`}v+=` L ${t} ${l(s)} Z`}const b=d?{x:Math.min(l(o),l(s)),y:e.x,width:Math.abs(l(s)-l(o)),height:e.width}:{x:e.x,y:Math.min(l(s),l(o)),width:e.width,height:Math.abs(l(s)-l(o))};u.push({type:"violin",pathString:v,translateX:0,translateY:0,bounds:b,stats:f(t),style:Object.assign(Object.assign({},p),{fillOpacity:null!==(n=p.fillOpacity)&&void 0!==n?n:.5}),datum:e.pieceData,category:e.name})}return u},timeline:function(e,t){const{scales:n,columns:o,getRawRange:s,resolvePieceStyle:i}=e,{r:r,projection:a}=n,l=[],c="horizontal"===a;for(const e of Object.values(o))for(const t of e.pieceData){const n=s(t);if(!n)continue;const[o,a]=n,u=i(t,e.name);if(c){const n=r(Math.min(o,a)),s=r(Math.max(o,a));l.push(m(n,e.x,s-n,e.width,u,t,e.name))}else{const n=r(Math.max(o,a)),s=r(Math.min(o,a));l.push(m(e.x,n,e.width,s-n,u,t,e.name))}}return l}};class y{constructor(e){this.rExtent=new u,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.version=0,this.config=e,this.buffer=new c(e.windowSize),this.getO=d(e.oAccessor||e.categoryAccessor,"category");const t="streaming"===e.runtimeMode,n=e.rAccessor;Array.isArray(n)?(this.rAccessors=n.map(e=>h(e,"value")),this.getR=this.rAccessors[0],this.rExtents=n.map(()=>new u)):(this.getR=h(t&&(e.timeAccessor||e.valueAccessor)&&e.valueAccessor||n,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=d(e.stackBy),this.getGroup=d(e.groupBy),this.getColor=d(e.colorAccessor),this.getConnector=d(e.connectorAccessor),e.pulse&&(this.timestampBuffer=new c(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,e.bounded){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(n)),this.pushValueExtent(n)}else for(const n of e.inserts){const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(n)),this.pushValueExtent(n),null!=e&&this.evictValueExtent(e)}return!0}pushValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.push(t[0]),this.rExtent.push(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].push(this.rAccessors[t](e));this.rExtent.push(this.getR(e))}else this.rExtent.push(this.getR(e))}evictValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.evict(t[0]),this.rExtent.evict(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].evict(this.rAccessors[t](e));this.rExtent.evict(this.getR(e))}else this.rExtent.evict(this.getR(e))}getRawRange(e){const t=this.config.rAccessor;if(!t)return null;const n="function"==typeof t?t(e):e[t];return Array.isArray(n)&&n.length>=2?[+n[0],+n[1]]:null}computeScene(e){const{config:n,buffer:o}=this;if(0===o.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(o,this.getR);const s=o.toArray(),i=n.projection||"vertical",r=n.oExtent||this.resolveCategories(s),a=this.computeValueDomain(s,r),l="horizontal"===i,c=null!=n.barPadding?n.barPadding/("vertical"===i?e.width:e.height):.1;let u,h;if("radial"===i){u=t.scaleBand().domain(r).range([0,1]).padding(0);const o=Math.min(e.width,e.height)/2,s=n.innerRadius||0;h=t.scaleLinear().domain(a).range([s,o])}else l?(u=t.scaleBand().domain(r).range([0,e.height]).padding(c),h=t.scaleLinear().domain(a).range([0,e.width])):(u=t.scaleBand().domain(r).range([0,e.width]).padding(c),h=t.scaleLinear().domain(a).range([e.height,0]));this.scales={o:u,r:h,projection:i},this.multiScales=this.rAccessors.length>1&&n.multiAxis?this.rAccessors.map((s,i)=>{const r=this.rExtents[i];r.dirty&&r.recalculate(o,s);let[a,c]=r.extent;a===1/0&&(a=0,c=1);const u=c-a,h=u>0?u*(n.extentPadding||.05):1;return a-=h,c+=h,a>0&&(a=0),l?t.scaleLinear().domain([a,c]).range([0,e.width]):t.scaleLinear().domain([a,c]).range([e.height,0])}):[];let d=s;this.rAccessors.length>1&&(d=s.flatMap(e=>this.rAccessors.map((t,n)=>Object.assign(Object.assign({},e),{__rIndex:n,__rValue:t(e),__rName:this.resolveRAccessorName(n)})))),this.columns=this.buildColumns(d,r,u,i,e),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(d,e),this.config.decay&&this.applyDecay(this.scene,s),this.config.pulse&&this.applyPulse(this.scene,s),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(e){const t=Array.isArray(this.config.rAccessor)?this.config.rAccessor[e]:this.config.rAccessor;return"string"==typeof t?t:"value"+e}resolveCategories(e){const t=Array.from(this.categories),n=this.config.oSort;if("streaming"===this.config.runtimeMode&&void 0===n)return t;if(!1===n)return t;if("function"==typeof n)return t.sort(n);const o=new Map;for(const t of e){const e=this.getO(t);o.set(e,(o.get(e)||0)+Math.abs(this.getR(t)))}return t.sort("asc"===n?(e,t)=>(o.get(e)||0)-(o.get(t)||0):(e,t)=>(o.get(t)||0)-(o.get(e)||0))}computeValueDomain(e,t){var n,o;const s=this.config.chartType,i=this.config.extentPadding||.05;if("radial"===this.config.projection&&("pie"===s||"donut"===s))return[0,1];let r=0,a=0;if("bar"===s&&this.getStack){const t=new Map,n=new Map;for(const o of e){const e=this.getO(o),s=this.getR(o);0>s?n.set(e,(n.get(e)||0)+s):t.set(e,(t.get(e)||0)+s)}for(const e of t.values())e>a&&(a=e);for(const e of n.values())r>e&&(r=e)}else if("bar"===s){const t=new Map;for(const n of e){const e=this.getO(n),o=this.getR(n);t.set(e,(t.get(e)||0)+o)}for(const e of t.values())e>a&&(a=e),r>e&&(r=e)}else if("clusterbar"===s)for(const t of e){const e=this.getR(t);e>a&&(a=e),r>e&&(r=e)}else{const e=this.rExtent.extent[0],t=this.rExtent.extent[1];e!==1/0&&(r=e),t!==-1/0&&(a=t)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(r=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(a=this.config.rExtent[1]));const l=a-r,c=l>0?l*i:1;return(null===(n=this.config.rExtent)||void 0===n?void 0:n[0])||(r-=c),(null===(o=this.config.rExtent)||void 0===o?void 0:o[1])||(a+=c),"bar"!==s&&"clusterbar"!==s||(r>0&&(r=0),0>a&&(a=0)),[r,a]}buildColumns(e,t,n,o,s){var i;const r={},a=new Map;for(const t of e){const e=this.getO(t);a.has(e)||a.set(e,[]),a.get(e).push(t)}let l=0;if("radial"===o)for(const t of e)l+=Math.abs(this.getR(t));const c=this.config.dynamicColumnWidth;let u=null;if(c&&"radial"!==o){u=new Map;let e=0;for(const n of t){const t=a.get(n)||[];let o;o="string"==typeof c?t.reduce((e,t)=>e+(Number(t[c])||0),0):c(t),u.set(n,o),e+=o}const i=("horizontal"===o?s.height:s.width)-n.padding()*n.step()*t.length;if(e>0)for(const[t,n]of u)u.set(t,n/e*i)}let h=0,d=0;for(const e of t){const t=a.get(e)||[],o=t.reduce((e,t)=>e+Math.abs(this.getR(t)),0),s=l>0?o/l:0;let c,m;u?(c=d,m=u.get(e)||n.bandwidth(),d+=m+n.padding()*n.step()):(c=null!==(i=n(e))&&void 0!==i?i:0,m=n.bandwidth()),r[e]={name:e,x:c,y:0,width:m,middle:c+m/2,padding:n.padding()*n.step(),pieceData:t,pct:s,pctStart:h},h+=s}return r}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(e,t)=>this.resolvePieceStyle(e,t),resolveSummaryStyle:(e,t)=>this.resolveSummaryStyle(e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];const n=this.getSceneContext(),o=p[this.config.chartType];let s=o?o(n,t):[];if(this.getConnector&&this.scales){const e=function(e,t){const{scales:n,config:o,getConnector:s,getO:i}=e;if(!s||!n)return[];const r=[],{projection:a}=n,l=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const n=s(t);if(!n)continue;let o,r;"point"===e.type?(o=e.x,r=e.y):(o=e.x+e.w/2,r=e.y+("vertical"===a?0:e.h/2)),l.has(n)||l.set(n,[]),l.get(n).push({x:o,y:r,datum:t,category:i(t)})}const c=n.o.domain(),u=o.connectorStyle;for(const[e,t]of l)if(t.length>=2){t.sort((e,t)=>c.indexOf(e.category)-c.indexOf(t.category));for(let n=0;t.length-1>n;n++){const o=t[n],s=t[n+1],i="function"==typeof u?u(o.datum):u||{stroke:"#999",strokeWidth:1,opacity:.5};r.push({type:"connector",x1:o.x,y1:o.y,x2:s.x,y2:s.y,style:i,datum:o.datum,group:e})}}return r}(n,s);s=[...e,...s]}return s}resolvePieceStyle(e,t){return"function"==typeof this.config.pieceStyle?this.config.pieceStyle(e,t):this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&t?{fill:this.config.barColors[t]||"#007bff"}:t?{fill:this.getColorFromScheme(t)}:{fill:"#007bff"}}getColorFromScheme(e){this._colorSchemeMap||(this._colorSchemeMap=new Map);const t=this._colorSchemeMap.get(e);if(t)return t;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],o=n[this._colorSchemeIndex%n.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(e,o),o}resolveSummaryStyle(e,t){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(e,t):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(e,t){var n,o,s;const i=this.config.decay;if(!i||1>=t)return 1;const r=null!==(n=i.minOpacity)&&void 0!==n?n:.1,a=t-1-e;switch(i.type){case"linear":return r+(1-a/(t-1))*(1-r);case"exponential":{const e=null!==(o=i.halfLife)&&void 0!==o?o:t/2;return r+Math.pow(.5,a/e)*(1-r)}case"step":return(null!==(s=i.stepThreshold)&&void 0!==s?s:.5*t)>a?1:r;default:return 1}}applyDecay(e,t){var n,o;if(!this.config.decay)return;const s=t.length;if(1>=s)return;const i=new Map;for(let e=0;t.length>e;e++)i.set(t[e],e);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=i.get(t.datum);if(null==e)continue;const r=this.computeDecayOpacity(e,s),a=null!==(o=null===(n=t.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:a*r})}}applyPulse(e,t){var n,o,s;if(!this.config.pulse||!this.timestampBuffer)return;const i="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(n=this.config.pulse.duration)&&void 0!==n?n:500,a=null!==(o=this.config.pulse.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",l=null!==(s=this.config.pulse.glowRadius)&&void 0!==s?s:4,c=new Map;for(let e=0;t.length>e;e++)c.set(t[e],e);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=c.get(t.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const o=i-n;r>o&&(t._pulseIntensity=1-o/r,t._pulseColor=a,t._pulseGlowRadius=l)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}snapshotPositions(){var e,t;this.prevPositionMap.clear();for(let n=0;this.scene.length>n;n++){const o=this.scene[n];if("point"===o.type)this.prevPositionMap.set("p:"+n,{x:o.x,y:o.y,r:o.r});else if("rect"===o.type){const s=`r:${o.group||""}:${null!==(t=null===(e=o.datum)||void 0===e?void 0:e.category)&&void 0!==t?t:n}`;this.prevPositionMap.set(s,{x:o.x,y:o.y,w:o.w,h:o.h})}}}startTransition(){var e,t,n,o,s;if(!this.config.transition||0===this.prevPositionMap.size)return;const i=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;let r=!1;for(let e=0;this.scene.length>e;e++){const i=this.scene[e];let a=null;if("point"===i.type?a="p:"+e:"rect"===i.type&&(a=`r:${i.group||""}:${null!==(n=null===(t=i.datum)||void 0===t?void 0:t.category)&&void 0!==n?n:e}`),!a)continue;const l=this.prevPositionMap.get(a);l&&("point"===i.type?l.x===i.x&&l.y===i.y||(i._targetX=i.x,i._targetY=i.y,i.x=l.x,i.y=l.y,r=!0):"rect"===i.type&&(l.x===i.x&&l.y===i.y&&l.w===i.w&&l.h===i.h||(i._targetX=i.x,i._targetY=i.y,i._targetW=i.w,i._targetH=i.h,i.x=l.x,i.y=l.y,i.w=null!==(o=l.w)&&void 0!==o?o:i.w,i.h=null!==(s=l.h)&&void 0!==s?s:i.h,r=!0)))}r&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:i})}advanceTransition(e){var t,n,o;if(!this.activeTransition)return!1;const s=Math.min((e-this.activeTransition.startTime)/this.activeTransition.duration,1),i="linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?s:1-Math.pow(1-s,3);for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;const t=this.prevPositionMap.get("p:0");if(!t)continue;e.x=t.x+(e._targetX-t.x)*i,e.y=t.y+(e._targetY-t.y)*i}else if("rect"===e.type){if(void 0===e._targetX)continue;const t=`r:${e.group||""}:${null!==(o=null===(n=e.datum)||void 0===n?void 0:n.category)&&void 0!==o?o:0}`,s=this.prevPositionMap.get(t);if(!s)continue;e.x=s.x+(e._targetX-s.x)*i,e.y=s.y+(e._targetY-s.y)*i,void 0!==s.w&&(e.w=s.w+(e._targetW-s.w)*i,e.h=s.h+(e._targetH-s.h)*i)}if(s>=1){for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}return this.activeTransition=null,!1}return!0}getData(){return this.buffer.toArray()}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}updateConfig(e){e.colorScheme!==this.config.colorScheme&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),Object.assign(this.config,e)}}function v(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{datum:e.datum,x:e.x+e.w/2,y:e.y,distance:0,category:e.group}}function b(e,t,n){const o=t-e.x,s=n-e.y,i=Math.sqrt(o*o+s*s);return i>Math.max(e.r,5)?null:{datum:e.datum,x:e.x,y:e.y,distance:i}}function x(e,t,n){const o=t-e.cx,s=n-e.cy,i=Math.sqrt(o*o+s*s);if(e.innerRadius>i||i>e.outerRadius)return null;let r=Math.atan2(s,o);0>r&&(r+=2*Math.PI);let a=e.startAngle%(2*Math.PI),l=e.endAngle%(2*Math.PI);if(0>a&&(a+=2*Math.PI),0>l&&(l+=2*Math.PI),!(a>l?r>=a||l>=r:r>=a&&l>=r))return null;const c=(e.startAngle+e.endAngle)/2,u=(e.innerRadius+e.outerRadius)/2;return{datum:e.datum,x:e.cx+Math.cos(c)*u,y:e.cy+Math.sin(c)*u,distance:0,category:e.category}}function w(e,t,n){const o=e.columnWidth/2,s=e.stats?Object.assign(Object.assign({},e.stats),{n:Array.isArray(e.datum)?e.datum.length:0,mean:(e.stats.q1+e.stats.median+e.stats.q3)/3}):void 0;if("vertical"===e.projection){if(!(e.x-o>t||t>e.x+o||Math.min(e.minPos,e.maxPos)>n||n>Math.max(e.minPos,e.maxPos)))return{datum:e.datum,x:e.x,y:e.medianPos,distance:0,category:e.category,stats:s}}else{const i=e.y-o,r=e.y+o;if(!(Math.min(e.minPos,e.maxPos)>t||t>Math.max(e.minPos,e.maxPos)||i>n||n>r))return{datum:e.datum,x:e.medianPos,y:e.y,distance:0,category:e.category,stats:s}}return null}function k(e,t,n){if(!e.bounds)return null;const{x:o,y:s,width:i,height:r}=e.bounds;return o>t||t>o+i||s>n||n>s+r?null:{datum:e.datum,x:o+i/2,y:s+r/2,distance:0,category:e.category,stats:e.stats}}const A={fill:e=>r.createElement("rect",{style:e,width:20,height:20}),line:e=>r.createElement("line",{style:e,x1:0,y1:0,x2:20,y2:20})};function E(e,t,n,o){let s;return s="function"==typeof n?n(e):(0,A[n])(o(e,t)),s}function M(e){const{legendGroups:t,customClickBehavior:n,title:o="Legend",width:s=100,height:i=20,orientation:a="vertical"}=e,l="vertical"===a?(({legendGroups:e,width:t,customClickBehavior:n})=>{let o=30;const s=[];return e.forEach((e,i)=>{o+=5,s.push(r.createElement("line",{key:"legend-top-line legend-symbol-"+i,stroke:"gray",x1:0,y1:o,x2:t,y2:o})),o+=10,e.label&&(o+=20,s.push(r.createElement("text",{key:"legend-text-"+i,y:o,className:"legend-group-label"},e.label)),o+=10),s.push(r.createElement("g",{key:"legend-group-"+i,className:"legend-item",transform:`translate(0,${o})`},((e,t)=>{const{type:n="fill",styleFn:o,items:s}=e,i=[];let a=0;return s.forEach((e,s)=>{const l=E(e,s,n,o);i.push(r.createElement("g",{key:"legend-item-"+s,transform:`translate(0,${a})`,onClick:t?()=>t(e):void 0,style:{cursor:t?"pointer":"default"}},l,r.createElement("text",{y:15,x:30},e.label))),a+=25}),i})(e,n))),o+=25*e.items.length+10}),s})({legendGroups:t,width:s,customClickBehavior:n}):(({legendGroups:e,title:t,height:n,customClickBehavior:o})=>{let s=0;const i=[],a=!1===t?10:40;return e.forEach((t,l)=>{t.label&&(i.push(r.createElement("text",{key:"legend-text-"+l,transform:`translate(${s},${a}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},t.label)),s+=20);const c=((e,t)=>{const{type:n="fill",styleFn:o,items:s}=e,i=[];let a=0;return s.forEach((e,s)=>{const l=E(e,s,n,o);i.push(r.createElement("g",{key:"legend-item-"+s,transform:`translate(${a},0)`,onClick:t?()=>t(e):void 0,style:{cursor:t?"pointer":"default"}},l,r.createElement("text",{y:15,x:25},e.label))),a+=35,a+=8*e.label.length}),{items:i,offset:a}})(t,o);i.push(r.createElement("g",{key:"legend-group-"+l,className:"legend-item",transform:`translate(${s},${a})`},c.items)),s+=c.offset+5,e[l+1]&&i.push(r.createElement("line",{key:"legend-top-line legend-symbol-"+l,stroke:"gray",x1:s,y1:a-10,x2:s,y2:n+a+10})),s+=15}),r.createElement("g",null,!1!==t&&r.createElement("line",{x1:0,x2:s+10,y1:a-10,y2:a-10,stroke:"gray",className:"title-neatline"}),i)})({legendGroups:t,title:o,height:i,customClickBehavior:n});return r.createElement("g",null,void 0!==o&&r.createElement("text",{className:"legend-title",y:20,x:"horizontal"===a?0:s/2,textAnchor:"horizontal"===a?"start":"middle"},o),l)}function S(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),s=e.split(/\s+/),i=[];let r="";for(const e of s)r&&r.length+1+e.length>o?(i.push(r),r=e):r=r?`${r} ${e}`:e;return r&&i.push(r),i}function O(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 j(e){const{x:t=0,y:n=0,dx:o,dy:s,nx:i,ny:a,note:l,connector:c,subject:u,type:h,color:d,className:m,disable:g,events:f={},"data-testid":p}=e,y=new Set(Array.isArray(g)?g:[]);let v=o||0,b=s||0;null!=i&&(v=i-t),null!=a&&(b=a-n);const x="string"==typeof h?h:"label";if("bracket"===x&&u&&0===v&&0===b)if(void 0!==u.width){v=u.width/2;const e=u.depth||30;b=e+(0>e?-5:5)}else if(void 0!==u.height){const e=u.depth||30;v=e+(0>e?-5:5),b=u.height/2}return r.createElement("g",Object.assign({className:("annotation "+(m||"")).trim(),transform:`translate(${t},${n})`,"data-testid":p},f),!y.has("connector")&&function(e,t,n,o,s,i){const a=[];let l=0,c=0;if("callout-circle"!==s&&"label"!==s||!(null==i?void 0:i.radius)){if("callout-rect"===s&&i){const n=i.width||0,o=i.height||0;if(n>0||o>0){const s=n/2,i=o/2,r=e-s,a=t-i;if(0!==r||0!==a){const e=Math.abs(r),t=Math.abs(a),u=n/2,h=o/2,d=e*h>t*u?u/e:h/t;l=s+r*d,c=i+a*d}}}else if("bracket"===s&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(l=e/2,c=n):void 0!==t&&(l=n,c=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const o=Math.atan2(t,e);l=Math.cos(o)*n,c=Math.sin(o)*n}}if(Math.sqrt(Math.pow(e-l,2)+Math.pow(t-c,2))>.5&&(a.push(r.createElement("line",{key:"connector-line",x1:l,y1:c,x2:e,y2:t,stroke:o||"currentColor"})),"arrow"===(null==n?void 0:n.end))){const n=10,s=16/180*Math.PI,i=Math.atan2(t-c,e-l);a.push(r.createElement("path",{key:"connector-arrow",d:`M${l},${c}L${l+n*Math.cos(i+s)},${c+n*Math.sin(i+s)}L${l+n*Math.cos(i-s)},${c+n*Math.sin(i-s)}Z`,fill:o||"currentColor",stroke:"none"}))}return r.createElement("g",{className:"annotation-connector"},a)}(v,b,c,d,x,u),!y.has("subject")&&function(e,t,n,o,s){var i;const a=[];switch(e){case"callout-circle":{const e=((null==t?void 0:t.radius)||0)+((null==t?void 0:t.radiusPadding)||0);e>0&&a.push(r.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:n||"currentColor"}));break}case"callout-rect":{const e=(null==t?void 0:t.width)||0,o=(null==t?void 0:t.height)||0;(e>0||o>0)&&a.push(r.createElement("rect",{key:"subject-rect",width:e,height:o,fill:"none",stroke:n||"currentColor"}));break}case"callout-custom":(null==t?void 0:t.custom)&&a.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=o||0,i=s||0;if(void 0!==(null==t?void 0:t.x)){const o=(t.x||0)-e;a.push(r.createElement("line",{key:"threshold-line",x1:o,y1:(t.y1||0)-i,x2:o,y2:(t.y2||0)-i,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==t?void 0:t.y)){const o=(t.y||0)-i;a.push(r.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:o,x2:(t.x2||0)-e,y2:o,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==t?void 0:t.x1)||void 0!==(null==t?void 0:t.x2)?a.push(r.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"currentColor",strokeDasharray:"5,5"})):void 0===(null==t?void 0:t.y1)&&void 0===(null==t?void 0:t.y2)||a.push(r.createElement("line",{key:"threshold-line",x1:0,y1:(t.y1||0)-i,x2:0,y2:(t.y2||0)-i,stroke:n||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(i=null==t?void 0:t.width)&&void 0!==i?i:null==t?void 0:t.height;void 0!==e&&a.push(r.createElement("path",{key:"bracket-path",d:O((null==t?void 0:t.type)||"curly",e,(null==t?void 0:t.depth)||30,void 0===(null==t?void 0:t.width)),fill:"none",stroke:n||"currentColor"}));break}}return r.createElement("g",{className:"annotation-subject"},a)}(x,u,d,t,n),!y.has("note")&&function(e,t,n,o){if(!e)return r.createElement("g",{className:"annotation-note"});const{label:s,title:i,orientation:a,align:l,wrap:c=120,noWrap:u}=e;if(!s&&!i)return r.createElement("g",{className:"annotation-note"});let h=a;h||(h=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=l;d&&"dynamic"!==d||(d="topBottom"===h?0>t?"right":"left":0>n?"bottom":"top");let m="start";"topBottom"===h?"right"===d?m="end":"middle"===d&&(m="middle"):m=0>t?"end":"start";const g=16,f=i?u?[i]:S(i,c):[],p=s?u?[s]:S(s,c):[],y="leftRight"===h?"end"===m?-4:4:0;let v=0;const b=[];f.length>0&&(b.push(r.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:o||void 0,textAnchor:m,fontWeight:"bold"},f.map((e,t)=>r.createElement("tspan",{key:t,x:y,dy:0===t?0:g},e)))),v=f.length*g),p.length>0&&b.push(r.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:o||void 0,textAnchor:m,y:v},p.map((e,t)=>r.createElement("tspan",{key:t,x:y,dy:0===t?0:g},e))));let x=null;if((i||s)&&(0!==t||0!==n))if("topBottom"===h){const e=Math.min(c,120);let t=0,n=e;"end"===m?(t=-e,n=0):"middle"===m&&(t=-e/2,n=e/2),x=r.createElement("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"currentColor"})}else{const e=(f.length+p.length)*g+(p.length>0?g:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),x=r.createElement("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:o||"currentColor"})}const w=Math.max(0,f.length+p.length-1)*g;let k=0;return"topBottom"===h?k=0>n?-(w+2):18:"leftRight"===h&&(k="middle"===d?-(w+g+(p.length>0&&f.length>0?2:0))/2+8:"bottom"===d||0>n?-(w+2):18),r.createElement("g",{className:"annotation-note",transform:`translate(${t},${n})`},r.createElement("g",{className:"annotation-note-content",transform:0!==k?`translate(0,${k})`:void 0},b),x)}(l,v,b,d))}function L(e){var t,n;const{noteData:o}=e,{screenCoordinates:s}=o,i="string"==typeof o.type?o.type:"label",a=o.eventListeners||o.events||{};if(o.coordinates&&s){const e=o.nx||s[0][0]+(null!==(t=o.dx)&&void 0!==t?t:0),a=o.ny||s[0][1]+(null!==(n=o.dy)&&void 0!==n?n:0),l=s.map((t,n)=>{const s=Object.assign({},o,{note:0===n?o.note:{label:""},x:t[0],y:t[1],nx:e,ny:a});return r.createElement(j,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},s,{type:i}))});return r.createElement("g",null,l)}const l=o.note||{title:"none",label:o.label};return r.createElement(j,Object.assign({"data-testid":"semiotic-annotation",key:`${l.label}-${l.title}-${o.i}`,events:a},o,{type:i}))}function P(e,t){var n,o,s;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(s=t.scales)||void 0===s?void 0:s.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function C(e,t){var n,o,s;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(s=t.scales)||void 0===s?void 0:s.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function H(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function N(e){return Math.round(100*e)/100+""}function B(t){const{width:n,height:s,totalWidth:i,totalHeight:a,margin:l,scales:c,showAxes:u,oLabel:h,rLabel:d,oFormat:m,rFormat:g,showGrid:f,title:p,legend:y,foregroundGraphics:v,annotations:b,svgAnnotationRules:x,annotationFrame:w,xAccessor:k,yAccessor:A,annotationData:E,children:S}=t,O="radial"===(null==c?void 0:c.projection),j="horizontal"===(null==c?void 0:c.projection),B=e.useMemo(()=>u&&c&&!O?c.o.domain().map(e=>{var t;return{value:e,pixel:(null!==(t=c.o(e))&&void 0!==t?t:0)+c.o.bandwidth()/2,label:m?m(e):e}}):[],[u,c,m,O]),_=e.useMemo(()=>u&&c&&!O?c.r.ticks(5).map(e=>({value:e,pixel:c.r(e),label:(g||N)(e)})):[],[u,c,g,O]),$=e.useMemo(()=>{if(!b||0===b.length)return null;const e=function(e,t,n){var s,i,a,l,c,u,h,d,m,g,f,p,y,v,b,x,w,k,A,E,M,S,O,j,N,B,_,$,D,R,z,W,T,I,q,G,F,V,X;switch(e.type){case"label":{let o=null,s=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);if(!t)return null;o=t.x,s=t.y}else o=P(e,n),s=C(e,n);return null==o||null==s?null:H(o,s,n)?r.createElement(L,{key:"ann-"+t,noteData:{x:o,y:s,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"label",connector:e.connector||{end:"arrow"},color:e.color}}):null}case"callout":{let o=null,s=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);if(!t)return null;o=t.x,s=t.y}else o=P(e,n),s=C(e,n);return null==o||null==s?null:H(o,s,n)?r.createElement(L,{key:"ann-"+t,noteData:{x:o,y:s,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"callout-circle",subject:{radius:e.radius||12},connector:e.connector||{end:"arrow"},color:e.color}}):null}case"x-threshold":{const o=P(e,n);if(null==o)return null;const s=e.color||"#f97316";return r.createElement("g",{key:"ann-"+t},r.createElement("line",{x1:o,y1:0,x2:o,y2:n.height||0,stroke:s,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&r.createElement("text",{x:o+4,y:12,fill:s,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const o=C(e,n);if(null==o)return null;const s=e.color||"#f97316";return r.createElement("g",{key:"ann-"+t},r.createElement("line",{x1:0,y1:o,x2:n.width||0,y2:o,stroke:s,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&r.createElement("text",{x:(n.width||0)-4,y:o-4,textAnchor:"end",fill:s,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const s=(e.coordinates||[]).map(e=>({x:P(Object.assign(Object.assign({},e),{type:"point"}),n),y:C(Object.assign(Object.assign({},e),{type:"point"}),n),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>s.length)return null;const i=o.packEnclose(s),a=e.padding||10;return r.createElement("g",{key:"ann-"+t},r.createElement("circle",{cx:i.x,cy:i.y,r:i.r+a,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&r.createElement("text",{x:i.x,y:i.y-i.r-a-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"rect-enclose":{const o=(e.coordinates||[]).map(e=>({x:P(Object.assign(Object.assign({},e),{type:"point"}),n),y:C(Object.assign(Object.assign({},e),{type:"point"}),n)})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const s=e.padding||10,i=o.map(e=>e.x),a=o.map(e=>e.y),l=Math.min(...i)-s,c=Math.max(...i)+s,u=Math.min(...a)-s,h=Math.max(...a)+s;return r.createElement("g",{key:"ann-"+t},r.createElement("rect",{x:l,y:u,width:c-l,height:h-u,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&r.createElement("text",{x:(l+c)/2,y:u-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"highlight":{const o=n.data||[],s="function"==typeof e.filter?o.filter(e.filter):e.field&&null!=e.value?o.filter(t=>t[e.field]===e.value):[],i=e.style||{stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return r.createElement("g",{key:"ann-"+t},s.map((t,o)=>{const s=P(t,n),a=C(t,n);return null==s||null==a?null:r.createElement("circle",Object.assign({key:o,cx:s,cy:a,r:e.r||6},i))}))}case"bracket":{const o=P(e,n),s=C(e,n);return r.createElement(L,{key:"ann-"+t,noteData:{x:null!=o?o:0,y:null!=s?s:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}})}case"trend":{const o=n.data||[];if(2>o.length)return null;const d=n.xAccessor||"x",m=n.yAccessor||"y",g=o.map(e=>[e[d],e[m]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>g.length)return null;const f=null!==(i=null===(s=n.scales)||void 0===s?void 0:s.x)&&void 0!==i?i:null===(a=n.scales)||void 0===a?void 0:a.time,p=null!==(c=null===(l=n.scales)||void 0===l?void 0:l.y)&&void 0!==c?c:null===(u=n.scales)||void 0===u?void 0:u.value;if(!f||!p)return null;const y=e.method||"linear";let v;if("loess"===y)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]),s=o.map(e=>e[0]),i=o.map(e=>e[1]),r=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=s[e],o=s.map(e=>Math.abs(e-t)),l=o.slice().sort((e,t)=>e-t)[Math.min(r-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:o[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,h=0,d=0,m=0,g=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,h+=t*s[e],d+=t*i[e],m+=t*s[e]*s[e],g+=t*s[e]*i[e])}if(0===u){a.push([t,i[e]]);continue}const f=u*m-h*h;if(1e-12>Math.abs(f))a.push([t,d/u]);else{const e=(u*g-h*d)/f;a.push([t,(d-e*h)/u+e*t])}}return a}(g,null!==(h=e.bandwidth)&&void 0!==h?h:.3);else{let t;try{const n=require("regression");t="polynomial"===y?n.polynomial(g,{order:e.order||2}):n.linear(g)}catch(e){return null}v=t.points}const b=v.map(([e,t])=>`${f(e)},${p(t)}`).join(" "),x=e.color||"#6366f1";return r.createElement("g",{key:"ann-"+t},r.createElement("polyline",{points:b,fill:"none",stroke:x,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&r.createElement("text",{x:f(v[v.length-1][0])+4,y:p(v[v.length-1][1])-4,fill:x,fontSize:11},e.label))}case"band":{const o=null!==(m=null===(d=n.scales)||void 0===d?void 0:d.y)&&void 0!==m?m:null===(g=n.scales)||void 0===g?void 0:g.value,s=null!==(f=null==o?void 0:o(e.y0))&&void 0!==f?f:0,i=null!==(p=null==o?void 0:o(e.y1))&&void 0!==p?p:n.height||0;return r.createElement("g",{key:"ann-"+t},r.createElement("rect",{x:0,y:Math.min(s,i),width:n.width||0,height:Math.abs(i-s),fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity||.1}),e.label&&r.createElement("text",{x:(n.width||0)-4,y:Math.min(s,i)-4,textAnchor:"end",fill:e.color||"#6366f1",fontSize:11},e.label))}case"envelope":{const o=n.data||[];if(2>o.length)return null;const s=n.xAccessor||"x",i=null!==(v=null===(y=n.scales)||void 0===y?void 0:y.x)&&void 0!==v?v:null===(b=n.scales)||void 0===b?void 0:b.time,a=null!==(w=null===(x=n.scales)||void 0===x?void 0:x.y)&&void 0!==w?w:null===(k=n.scales)||void 0===k?void 0:k.value;if(!i||!a)return null;const l=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",u=e.filter,h=o.filter(e=>null!=e[l]&&null!=e[c]&&!(u&&!u(e))).sort((e,t)=>e[s]-t[s]);if(2>h.length)return null;const d=h.map(e=>`${i(e[s])},${a(e[l])}`).join(" L"),m=h.slice().reverse().map(e=>`${i(e[s])},${a(e[c])}`).join(" L"),g=e.fill||"#6366f1";return r.createElement("g",{key:"ann-"+t},r.createElement("path",{d:`M${d} L${m} Z`,fill:g,fillOpacity:null!==(A=e.fillOpacity)&&void 0!==A?A:.15,stroke:"none"}),e.label&&h.length>0&&r.createElement("text",{x:i(h[h.length-1][s])+4,y:a(h[h.length-1][l])-4,fill:g,fontSize:11},e.label))}case"anomaly-band":{const o=n.data||[];if(2>o.length)return null;const s=n.yAccessor||"y",i=null!==(M=null===(E=n.scales)||void 0===E?void 0:E.x)&&void 0!==M?M:null===(S=n.scales)||void 0===S?void 0:S.time,a=null!==(j=null===(O=n.scales)||void 0===O?void 0:O.y)&&void 0!==j?j:null===(N=n.scales)||void 0===N?void 0:N.value;if(!i||!a)return null;const l=o.map(e=>e[s]).filter(e=>null!=e&&isFinite(e));if(2>l.length)return null;const c=l.reduce((e,t)=>e+t,0)/l.length,u=l.reduce((e,t)=>e+Math.pow(t-c,2),0)/l.length,h=Math.sqrt(u),d=null!==(B=e.threshold)&&void 0!==B?B:2,m=c-d*h,g=!1!==e.showBand,f=e.fill||"#6366f1",p=null!==(_=e.fillOpacity)&&void 0!==_?_:.1,y=e.anomalyColor||"#ef4444",v=null!==($=e.anomalyRadius)&&void 0!==$?$:6,b=a(c+d*h),x=a(m),w=o.filter(e=>{const t=e[s];return null!=t&&Math.abs(t-c)>d*h});return r.createElement("g",{key:"ann-"+t},g&&r.createElement("rect",{x:0,y:Math.min(b,x),width:n.width||0,height:Math.abs(x-b),fill:f,fillOpacity:p}),w.map((e,t)=>{const o=P(e,n),s=C(e,n);return null==o||null==s?null:r.createElement("circle",{key:t,cx:o,cy:s,r:v,fill:y,fillOpacity:.7,stroke:y,strokeWidth:1.5})}),e.label&&r.createElement("text",{x:(n.width||0)-4,y:Math.min(b,x)-4,textAnchor:"end",fill:f,fontSize:11},e.label))}case"forecast":{const o=n.data||[];if(3>o.length)return null;const s=n.xAccessor||"x",i=n.yAccessor||"y",a=null!==(R=null===(D=n.scales)||void 0===D?void 0:D.x)&&void 0!==R?R:null===(z=n.scales)||void 0===z?void 0:z.time,l=null!==(T=null===(W=n.scales)||void 0===W?void 0:W.y)&&void 0!==T?T:null===(I=n.scales)||void 0===I?void 0:I.value;if(!a||!l)return null;const c=o.map(e=>[e[s],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let u;if("polynomial"===(e.method||"linear"))try{const t=require("regression").polynomial(c,{order:e.order||2}).equation;u=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}catch(e){return null}else{const e=c.length;let t=0,n=0,o=0,s=0;for(const[e,i]of c)t+=e,n+=i,o+=e*e,s+=e*i;const i=e*o-t*t;if(1e-12>Math.abs(i))return null;const r=(e*s-t*n)/i,a=(n-r*t)/e;u=e=>a+r*e}const h=c.length,d=c.map(([e,t])=>t-u(e)).reduce((e,t)=>e+t*t,0),m=Math.sqrt(d/Math.max(h-2,1)),g=c.reduce((e,t)=>e+t[0],0)/h,f=c.reduce((e,t)=>e+Math.pow(t[0]-g,2),0),p=null!==(q=e.confidence)&&void 0!==q?q:.95,y=.99>p?.95>p?.9>p?1:1.645:1.96:2.576,v=null!==(G=e.steps)&&void 0!==G?G:5,b=c[h-1][0],x=(b-c[0][0])/Math.max(h-1,1),w=[];for(let e=1;v>=e;e++)w.push(b+e*x);const k=[];for(const e of w){const t=u(e),n=m*Math.sqrt(1+1/h+(f>0?Math.pow(e-g,2)/f:0))*y;k.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const A=`M${k.map(e=>`${a(e.x)},${l(e.yUpper)}`).join(" L")} L${k.slice().reverse().map(e=>`${a(e.x)},${l(e.yLower)}`).join(" L")} Z`,E=k.map(e=>`${a(e.x)},${l(e.yCenter)}`).join(" "),M=`${a(b)},${l(u(b))}`,S=e.strokeColor||"#6366f1";return r.createElement("g",{key:"ann-"+t},r.createElement("path",{d:A,fill:e.fill||"#6366f1",fillOpacity:null!==(F=e.fillOpacity)&&void 0!==F?F:.15,stroke:"none"}),r.createElement("polyline",{points:`${M} ${E}`,fill:"none",stroke:S,strokeWidth:null!==(V=e.strokeWidth)&&void 0!==V?V:2,strokeDasharray:null!==(X=e.strokeDasharray)&&void 0!==X?X:"6,3"}),e.label&&k.length>0&&r.createElement("text",{x:a(k[k.length-1].x)+4,y:l(k[k.length-1].yCenter)-4,fill:S,fontSize:11},e.label))}default:return null}},t={scales:c?{x:c.r,y:c.r,time:c.r,value:c.r}:null,timeAxis:"x",xAccessor:k,yAccessor:A,width:n,height:s,data:E,frameType:"ordinal"};return b.map((n,o)=>{if(x){const s=x(n,o,t);return null!=s?s:e(n,o,t)}return e(n,o,t)}).filter(Boolean)},[b,x,n,s,w,k,A,E]);return u||p||y||v||$&&$.length>0||f||S?r.createElement("svg",{width:i,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},r.createElement("g",{transform:`translate(${l.left},${l.top})`},f&&c&&!O&&r.createElement("g",{className:"ordinal-grid"},_.map((e,t)=>r.createElement("line",{key:"grid-"+t,x1:j?e.pixel:0,y1:j?0:e.pixel,x2:j?e.pixel:n,y2:j?s:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),u&&c&&!O&&r.createElement("g",{className:"ordinal-axes"},j?r.createElement(r.Fragment,null,r.createElement("line",{x1:0,y1:0,x2:0,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),B.map((e,t)=>r.createElement("g",{key:"cat-"+t,transform:`translate(0,${e.pixel})`},r.createElement("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),r.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),h&&r.createElement("text",{x:15-l.left,y:s/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-l.left}, ${s/2})`,style:{userSelect:"none"}},h),r.createElement("line",{x1:0,y1:s,x2:n,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),_.map((e,t)=>r.createElement("g",{key:"val-"+t,transform:`translate(${e.pixel},${s})`},r.createElement("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),r.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),d&&r.createElement("text",{x:n/2,y:s+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},d)):r.createElement(r.Fragment,null,r.createElement("line",{x1:0,y1:s,x2:n,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),B.map((e,t)=>r.createElement("g",{key:"cat-"+t,transform:`translate(${e.pixel},${s})`},r.createElement("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),r.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),h&&r.createElement("text",{x:n/2,y:s+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},h),r.createElement("line",{x1:0,y1:0,x2:0,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),_.map((e,t)=>r.createElement("g",{key:"val-"+t,transform:`translate(0,${e.pixel})`},r.createElement("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),r.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),d&&r.createElement("text",{x:15-l.left,y:s/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-l.left}, ${s/2})`,style:{userSelect:"none"}},d))),$,v,S),p&&r.createElement("text",{x:i/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof p?p:null),y&&r.createElement("g",{transform:`translate(${i-l.right+10}, ${l.top})`},"object"==typeof(D=y)&&null!==D&&!r.isValidElement(D)&&"legendGroups"in D?r.createElement(M,{legendGroups:y.legendGroups,title:"",width:100}):y)):null;var D}const _=(e,t,n,o)=>{const s=t.filter(e=>"rect"===e.type);for(const t of s)null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon?$(e,t):(e.fillStyle=t.style.fill||"#007bff",e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.globalAlpha=1};function $(e,t){const n=t.style.icon,o=t.style.iconPadding||2,s=Math.min(t.w,t.w)-o;if(0>=s)return;const i=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),i){const i=s+o,r=t.x+(t.w-s)/2;for(let o=t.y+t.h-s;o>=t.y-s;o-=i)e.drawImage(n,r,o,s,s)}else{const i=s+o,r=t.y+(t.h-s)/2;for(let o=t.x;t.x+t.w>o;o+=i)e.drawImage(n,o,r,s,s)}e.restore()}const D=(e,t,n,o)=>{var s,i;const r=t.filter(e=>"point"===e.type);for(const t of r){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(s=t.style.opacity)&&void 0!==s?s:t.style.fillOpacity;if(null!=n&&(e.globalAlpha=n),e.fillStyle=t.style.fill||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0){const n=null!==(i=t._pulseGlowRadius)&&void 0!==i?i:4,o=t.r+n*t._pulseIntensity;e.beginPath(),e.arc(t.x,t.y,o,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=.6*t._pulseIntensity,e.stroke()}e.globalAlpha=1}},R=(e,t,n,o)=>{const s=t.filter(e=>"wedge"===e.type);for(const t of s)e.beginPath(),t.innerRadius>0?(e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerRadius,t.endAngle,t.startAngle,!0)):(e.moveTo(t.cx,t.cy),e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle)),e.closePath(),null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),null!=t.style.fillOpacity&&(e.globalAlpha=t.style.fillOpacity),e.fillStyle=t.style.fill||"#007bff",e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),e.globalAlpha=1},z=(e,t,n,o)=>{var s,i;const r=t.filter(e=>"violin"===e.type);for(const t of r){e.save(),(t.translateX||t.translateY)&&e.translate(t.translateX,t.translateY);const n=new Path2D(t.pathString);if(e.globalAlpha=null!==(i=null!==(s=t.style.fillOpacity)&&void 0!==s?s:t.style.opacity)&&void 0!==i?i:.6,e.fillStyle=t.style.fill||"#007bff",e.fill(n),e.globalAlpha=1,t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke(n)),t.iqrLine){e.strokeStyle="#333",e.lineWidth=2,e.globalAlpha=.8;const n=t.iqrLine.centerPos,o=!1!==t.iqrLine.isVertical;e.beginPath(),o?(e.moveTo(n,t.iqrLine.q1Pos),e.lineTo(n,t.iqrLine.q3Pos)):(e.moveTo(t.iqrLine.q1Pos,n),e.lineTo(t.iqrLine.q3Pos,n)),e.stroke(),e.beginPath(),o?e.arc(n,t.iqrLine.medianPos,3,0,2*Math.PI):e.arc(t.iqrLine.medianPos,n,3,0,2*Math.PI),e.fillStyle="#fff",e.fill(),e.strokeStyle="#333",e.lineWidth=1,e.stroke(),e.globalAlpha=1}e.restore()}},W=(e,t,n,o)=>{var s,i,r;const a=t.filter(e=>"connector"===e.type);if(0===a.length)return;const l=new Map;for(const e of a){const t=e.group||"_default";l.has(t)||l.set(t,[]),l.get(t).push(e)}for(const[,t]of l){if(0===t.length)continue;const n=t[0].style;if(n.fill&&"none"!==n.fill){e.beginPath(),e.moveTo(t[0].x1,t[0].y1);for(const n of t)e.lineTo(n.x2,n.y2);e.closePath(),e.globalAlpha=null!==(i=null!==(s=n.fillOpacity)&&void 0!==s?s:n.opacity)&&void 0!==i?i:.3,e.fillStyle=n.fill,e.fill(),e.globalAlpha=1}for(const n of t)e.beginPath(),e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.strokeStyle=n.style.stroke||n.style.fill||"#999",e.lineWidth=n.style.strokeWidth||1,e.globalAlpha=null!==(r=n.style.opacity)&&void 0!==r?r:.5,e.stroke(),e.globalAlpha=1}},T=e=>[W,...e],I={bar:T([_]),clusterbar:T([_]),point:T([D]),swarm:T([D]),pie:[R],donut:[R],boxplot:T([(e,t,n,o)=>{var s,i;const r=t.filter(e=>"boxplot"===e.type);for(const t of r){const n=t.columnWidth/2,o="vertical"===t.projection,r=t.style.fill||"#007bff",a=t.style.stroke||"#333",l=t.style.strokeWidth||1,c=null!==(i=null!==(s=t.style.fillOpacity)&&void 0!==s?s:t.style.opacity)&&void 0!==i?i:.6;if(e.save(),e.strokeStyle=a,e.lineWidth=l,e.beginPath(),o?(e.moveTo(t.x,t.minPos),e.lineTo(t.x,t.maxPos)):(e.moveTo(t.minPos,t.y),e.lineTo(t.maxPos,t.y)),e.stroke(),e.beginPath(),o?(e.moveTo(t.x-.4*n,t.minPos),e.lineTo(t.x+.4*n,t.minPos),e.moveTo(t.x-.4*n,t.maxPos),e.lineTo(t.x+.4*n,t.maxPos)):(e.moveTo(t.minPos,t.y-.4*n),e.lineTo(t.minPos,t.y+.4*n),e.moveTo(t.maxPos,t.y-.4*n),e.lineTo(t.maxPos,t.y+.4*n)),e.stroke(),e.globalAlpha=c,e.fillStyle=r,o){const o=Math.min(t.q1Pos,t.q3Pos),s=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(t.x-n,o,t.columnWidth,s),e.globalAlpha=1,e.strokeRect(t.x-n,o,t.columnWidth,s)}else{const o=Math.min(t.q1Pos,t.q3Pos),s=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(o,t.y-n,s,t.columnWidth),e.globalAlpha=1,e.strokeRect(o,t.y-n,s,t.columnWidth)}e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),o?(e.moveTo(t.x-n,t.medianPos),e.lineTo(t.x+n,t.medianPos)):(e.moveTo(t.medianPos,t.y-n),e.lineTo(t.medianPos,t.y+n)),e.stroke(),e.restore()}},D]),violin:T([z]),histogram:T([_]),ridgeline:T([z]),timeline:T([_])},q={top:50,right:40,bottom:60,left:70},G={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:"4px",fontSize:"13px",lineHeight:"1.4",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function F({hover:e}){var t,n,o,s;const i=e.data||{},a=e.stats,l=e.category;if(Array.isArray(i)){const e=l||(null===(t=i[0])||void 0===t?void 0:t.category)||"";if(a)return r.createElement("div",{className:"semiotic-tooltip",style:G},e&&r.createElement("div",{style:{fontWeight:"bold"}},e+""),r.createElement("div",null,"n = ",a.n),r.createElement("div",null,"Min: ",a.min.toLocaleString()),r.createElement("div",null,"Q1: ",a.q1.toLocaleString()),r.createElement("div",null,"Median: ",a.median.toLocaleString()),r.createElement("div",null,"Q3: ",a.q3.toLocaleString()),r.createElement("div",null,"Max: ",a.max.toLocaleString()),r.createElement("div",{style:{opacity:.8}},"Mean: ",a.mean.toLocaleString(void 0,{maximumFractionDigits:2})));const n=i.length;return r.createElement("div",{className:"semiotic-tooltip",style:G},e&&r.createElement("div",{style:{fontWeight:"bold"}},e+""),r.createElement("div",null,n," items"))}if(null!=i.bin&&null!=i.count){const e=i.range||[];return r.createElement("div",{className:"semiotic-tooltip",style:G},i.category&&r.createElement("div",{style:{fontWeight:"bold"}},i.category+""),r.createElement("div",null,"Count: ",i.count),2===e.length&&r.createElement("div",{style:{opacity:.8}},Number(e[0]).toFixed(1)," – ",Number(e[1]).toFixed(1)))}const c=i.category||i.name||i.group||i.__rName||"",u=null!==(s=null!==(o=null!==(n=i.value)&&void 0!==n?n:i.__rValue)&&void 0!==o?o:i.pct)&&void 0!==s?s:"";if(!c&&""===u){const e=Object.entries(i).filter(([e])=>!e.startsWith("_")&&"data"!==e);return r.createElement("div",{className:"semiotic-tooltip",style:G},e.map(([e,t])=>r.createElement("div",{key:e},r.createElement("span",{style:{opacity:.7}},e,":")," ","number"==typeof t?t.toLocaleString():t+"")))}return r.createElement("div",{className:"semiotic-tooltip",style:G},c&&r.createElement("div",{style:{fontWeight:"bold"}},c+""),""!==u&&r.createElement("div",null,"number"==typeof u?u.toLocaleString():u+""))}const V=e.forwardRef(function(t,n){var o;const{chartType:s,runtimeMode:i,data:a,oAccessor:c="category",rAccessor:u="value",colorAccessor:h,stackBy:d,groupBy:m,multiAxis:g,timeAccessor:f,valueAccessor:p,categoryAccessor:A,projection:E="vertical",size:M=[600,400],responsiveWidth:S,responsiveHeight:O,margin:j,barPadding:L,innerRadius:P,normalize:C,startAngle:H,dynamicColumnWidth:N,bins:_,showOutliers:$,showIQR:D,amplitude:R,connectorAccessor:z,connectorStyle:W,rExtent:T,oExtent:G,extentPadding:V=.05,oSort:X,windowMode:Y="sliding",windowSize:Q=200,pieceStyle:Z,summaryStyle:U,colorScheme:J,barColors:K,showAxes:ee=!0,oLabel:te,rLabel:ne,oFormat:oe,rFormat:se,enableHover:ie=!0,hoverAnnotation:re,tooltipContent:ae,customHoverBehavior:le,annotations:ce,svgAnnotationRules:ue,showGrid:he=!1,legend:de,backgroundGraphics:me,foregroundGraphics:ge,title:fe,className:pe,background:ye,centerContent:ve,decay:be,pulse:xe,transition:we,staleness:ke}=t,[Ae,Ee]=function(t,n,o){const s=e.useRef(null),[i,r]=e.useState(null);return e.useEffect(()=>{if(!n&&!o)return;const e=s.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;r(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[n,o]),[s,[n&&i?i.w:t[0],o&&i?i.h:t[1]]]}(M,S,O),Me=e.useMemo(()=>Object.assign(Object.assign({},q),j),[j]),Se=Ee[0]-Me.left-Me.right,Oe=Ee[1]-Me.top-Me.bottom,je=e.useRef(null),Le=e.useRef(!0),Pe=e.useRef(0),Ce=e.useRef(null),He=e.useRef(()=>{}),[Ne,Be]=e.useState(null),[_e,$e]=e.useState(null),[De,Re]=e.useState(0),[ze,We]=e.useState(!1),Te=ie||re,Ie="streaming"===i,qe=e.useMemo(()=>({chartType:s,runtimeMode:Ie?"streaming":"bounded",windowSize:Q,windowMode:Y,extentPadding:V,projection:E,oAccessor:Ie?void 0:c,rAccessor:Ie?void 0:u,colorAccessor:h,stackBy:d,groupBy:m,multiAxis:g,timeAccessor:Ie?f:void 0,valueAccessor:Ie?p||("string"==typeof u||"function"==typeof u?u:void 0):void 0,categoryAccessor:Ie?A||c:void 0,rExtent:T,oExtent:G,barPadding:L,innerRadius:P,normalize:C,startAngle:H,dynamicColumnWidth:N,bins:_,showOutliers:$,showIQR:D,amplitude:R,connectorAccessor:z,connectorStyle:W,oSort:X,pieceStyle:Z,summaryStyle:U,colorScheme:J,barColors:K,decay:be,pulse:xe,transition:we,staleness:ke}),[s,Q,Y,V,E,c,u,h,d,m,g,f,p,A,T,G,L,P,C,H,N,_,$,D,R,z,W,X,Z,U,J,K,be,xe,we,ke,Ie]),Ge=e.useRef(null);Ge.current||(Ge.current=new y(qe));const Fe=e.useCallback(()=>{Pe.current||(Pe.current=requestAnimationFrame(()=>He.current()))},[]);e.useEffect(()=>{var e;null===(e=Ge.current)||void 0===e||e.updateConfig(qe),Le.current=!0,Fe()},[qe,Fe]);const Ve=e.useRef(null);Ve.current||(Ve.current=new l(e=>{const t=Ge.current;t&&t.ingest(e)&&(Le.current=!0,Fe())}));const Xe=e.useCallback(e=>{var t;null===(t=Ve.current)||void 0===t||t.push(e)},[]),Ye=e.useCallback(e=>{var t;null===(t=Ve.current)||void 0===t||t.pushMany(e)},[]),Qe=e.useCallback(()=>{var e,t;null===(e=Ve.current)||void 0===e||e.clear(),null===(t=Ge.current)||void 0===t||t.clear(),Le.current=!0,Fe()},[Fe]);e.useImperativeHandle(n,()=>({push:Xe,pushMany:Ye,clear:Qe,getData:()=>{var e,t;return null!==(t=null===(e=Ge.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=Ge.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null}}),[Xe,Ye,Qe]),e.useEffect(()=>{var e;if(a)return null===(e=Ve.current)||void 0===e||e.setBoundedData(a),()=>{var e;null===(e=Ve.current)||void 0===e||e.clearLastData()}},[a]);const Ze=e.useRef(()=>{}),Ue=e.useRef(()=>{});Ze.current=e=>{if(!Te)return;const t=je.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Me.left,s=e.clientY-n.top-Me.top;if(0>o||o>Se||0>s||s>Oe)return void(Ce.current&&(Ce.current=null,Be(null),le&&le(null),Fe()));const i=Ge.current;if(!i||0===i.scene.length)return;const r="radial"===E,a=function(e,t,n,o=30){let s=null;for(const i of e){let e=null;switch(i.type){case"rect":e=v(i,t,n);break;case"point":e=b(i,t,n);break;case"wedge":e=x(i,t,n);break;case"boxplot":e=w(i,t,n);break;case"violin":e=k(i,t,n)}e&&o>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}(i.scene,r?o-Se/2:o,r?s-Oe/2:s);if(!a)return void(Ce.current&&(Ce.current=null,Be(null),le&&le(null),Fe()));const l=Object.assign(Object.assign({data:a.datum,time:a.x,value:a.y,x:a.x,y:a.y},a.stats&&{stats:a.stats}),a.category&&{category:a.category});Ce.current=l,Be(l),le&&(le(l),Le.current=!0),Fe()},Ue.current=()=>{Ce.current&&(Ce.current=null,Be(null),le&&(le(null),Le.current=!0),Fe())},e.useCallback(e=>Ze.current(e),[]);const Je=e.useCallback(()=>Ue.current(),[]),Ke=e.useRef(-1),et=e.useCallback(e=>{const t=Ge.current;if(!t||0===t.scene.length)return;const n=function(e){const t=[];for(const n of e)if("rect"===n.type&&null!=n.x)t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum});else if("point"===n.type)t.push({x:n.x,y:n.y,datum:n.datum});else if("wedge"===n.type&&null!=n.cx){const e=((n.startAngle||0)+(n.endAngle||0))/2,o=((n.innerRadius||0)+(n.outerRadius||50))/2;t.push({x:n.cx+Math.cos(e)*o,y:n.cy+Math.sin(e)*o,datum:n.datum})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.scene);if(0===n.length)return;const o=Ke.current,s=function(e,t,n){switch(e){case"ArrowRight":case"ArrowDown":return n-1>t?t+1:t;case"ArrowLeft":case"ArrowUp":return t>0?t-1:t;case"Home":return 0;case"End":return n-1;case"Escape":return-1;default:return null}}(e.key,0>o?-1:o,n.length);if(null===s)return;if(e.preventDefault(),0>s)return Ke.current=-1,Ce.current=null,Be(null),le&&le(null),void Fe();const i=0>o?0:s;Ke.current=i;const r={data:(a=n[i]).datum,x:a.x,y:a.y,time:a.x,value:a.y};var a;Ce.current=r,Be(r),le&&le(r),Fe()},[le,Fe]),tt=e.useCallback(e=>{Ke.current=-1,Ze.current(e)},[]);He.current=()=>{var e,t;Pe.current=0;const n=je.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const i=Ge.current;if(!i)return;const r="undefined"!=typeof performance?performance.now():Date.now(),a=i.advanceTransition(r),l=Le.current;l&&!a&&(i.computeScene({width:Se,height:Oe}),Le.current=!1);const c="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=Ee[0]*c,n.height=Ee[1]*c,n.style.width=Ee[0]+"px",n.style.height=Ee[1]+"px",o.scale(c,c),o.clearRect(0,0,Ee[0],Ee[1]);const u=null!==(e=null==ke?void 0:ke.threshold)&&void 0!==e?e:5e3,h=ke&&i.lastIngestTime>0&&r-i.lastIngestTime>u;h&&(o.globalAlpha=null!==(t=null==ke?void 0:ke.dimOpacity)&&void 0!==t?t:.5);const d=n?getComputedStyle(n).getPropertyValue("--semiotic-bg").trim():"",m=ye||(d&&"transparent"!==d?d:null);m&&(o.fillStyle=m,o.fillRect(0,0,Ee[0],Ee[1]));const g="radial"===E;g?(o.save(),o.translate(Me.left+Se/2,Me.top+Oe/2)):o.translate(Me.left,Me.top);const f=I[s]||[],p={width:Se,height:Oe};for(const e of f)e(o,i.scene,i.scales,p);g&&o.restore(),h&&(o.globalAlpha=1),l&&i.scales&&($e(i.scales),Re(e=>e+1)),(null==ke?void 0:ke.showBadge)&&We(!!h),(a||i.hasActivePulses)&&(Pe.current=requestAnimationFrame(()=>He.current()))},e.useEffect(()=>(Fe(),()=>{Pe.current&&(cancelAnimationFrame(Pe.current),Pe.current=0)}),[Fe]),e.useEffect(()=>{Le.current=!0,Fe()},[s,Se,Oe,ee,ye,Fe]),e.useEffect(()=>{if(!ke)return;const e=setInterval(()=>{var e;const t=Ge.current;if(!t||0===t.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=ke.threshold)&&void 0!==e?e:5e3,s=n-t.lastIngestTime>o;s!==ze&&(We(s),Le.current=!0,Fe())},1e3);return()=>clearInterval(e)},[ke,ze,Fe]);const nt=Te&&Ne?ae?ae(Ne):r.createElement(F,{hover:Ne}):null,ot="radial"===E,st=Ne?ot?Ne.x+Se/2:Ne.x:0,it=Ne?ot?Ne.y+Oe/2:Ne.y:0,rt=nt?r.createElement("div",{className:"stream-ordinal-tooltip",style:{position:"absolute",left:Me.left+st,top:Me.top+it,transform:`translate(${st>.7*Se?"calc(-100% - 12px)":"12px"}, ${.3*Oe>it?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},nt):null;return r.createElement("div",{ref:Ae,className:"stream-ordinal-frame"+(pe?" "+pe:""),role:"img","aria-label":"string"==typeof fe?fe:"Ordinal chart",tabIndex:0,style:{position:"relative",width:S?"100%":Ee[0],height:O?"100%":Ee[1]},onMouseMove:Te?tt:void 0,onMouseLeave:Te?Je:void 0,onKeyDown:et},me&&r.createElement("svg",{style:{position:"absolute",top:0,left:0,width:Ee[0],height:Ee[1],pointerEvents:"none"}},r.createElement("g",{transform:`translate(${Me.left},${Me.top})`},me)),r.createElement("canvas",{ref:je,style:{position:"absolute",top:0,left:0,width:Ee[0],height:Ee[1]}}),r.createElement(B,{width:Se,height:Oe,totalWidth:Ee[0],totalHeight:Ee[1],margin:Me,scales:_e,showAxes:ee,oLabel:te,rLabel:ne,oFormat:oe,rFormat:se,showGrid:he,title:fe,legend:de,foregroundGraphics:ge,annotations:ce,svgAnnotationRules:ue,annotationFrame:De,xAccessor:"string"==typeof c?c:void 0,yAccessor:"string"==typeof u?u:void 0,annotationData:null===(o=Ge.current)||void 0===o?void 0:o.getData()}),ve&&"radial"===E&&r.createElement("div",{style:{position:"absolute",left:Me.left+Se/2,top:Me.top+Oe/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"}},ve),(null==ke?void 0:ke.showBadge)&&r.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ke.badgePosition?{top:4,left:4}:"bottom-left"===ke.badgePosition?{bottom:4,left:4}:"bottom-right"===ke.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:ze?"#dc3545":"#28a745",color:"white"})},ze?"STALE":"LIVE"),rt)});V.displayName="StreamOrdinalFrame";const X={category10:s.schemeCategory10,tableau10:s.schemeTableau10,set3:s.schemeSet3,blues:s.interpolateBlues,reds:s.interpolateReds,greens:s.interpolateGreens,oranges:s.interpolateOranges,purples:s.interpolatePurples,viridis:s.interpolateViridis,plasma:s.interpolatePlasma},Y=s.schemeCategory10;function Q(e,t,n){if("function"==typeof t)return t(e);const o=e[t];return n?n(o):Y[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+""))%Y.length]}function Z(e,n,o="category10"){const s=Array.from(new Set(e.map(e=>e[n]))),i=s.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(o))return t.scaleOrdinal().domain(s).range(o).unknown("#999");const r=X[o]||X.category10;if(i&&"function"==typeof r)return e=>r(Number(e)/Math.max(...s.map(Number)));{const e=Array.isArray(r)?r:Y;return t.scaleOrdinal().domain(s).range(e).unknown("#999")}}const U=e.createContext(null);function J(e,t,n){return t?o=>{var s;const i=Object.assign({},e(o));if(t.isActive)if(t.predicate(o))(null==n?void 0:n.selectedStyle)&&Object.assign(i,n.selectedStyle);else{const e=null!==(s=null==n?void 0:n.unselectedOpacity)&&void 0!==s?s:.2;i.opacity=e,i.fillOpacity=e,i.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(i,n.unselectedStyle)}return i}:e}function K(t){const n=e.createContext(null),o=ee(t);return[function({children:o}){const s=e.useMemo(()=>ee(t),[]);return r.createElement(n.Provider,{value:s,children:o})},t=>{var s;const i=null!==(s=e.useContext(n))&&void 0!==s?s:o;return function(t,n){const[o,s]=e.useState(n);return e.useLayoutEffect(()=>t(()=>s(n)),[t]),o}(i.subscribe,()=>t(i.getState()))}]}function ee(e){const t=new EventTarget;let n=e(function(e){n=Object.assign(Object.assign({},n),e(n)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}function te(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,s]=o.range;t.push(t=>{const o=t[n];return o>=e&&s>=o})}return e=>t.every(t=>t(e))}function ne(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[oe,se]=K(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),s=ne(o,t),i=new Map(s.clauses);return i.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},s),{clauses:i})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const s=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),s.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:s}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),s=ne(o,t);return o.set(t,Object.assign(Object.assign({},s),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}}));function ie(t){const n=e.useId(),o=t.clientId||n,{name:s}=t,i=se(e=>e.selections.get(s)),r=se(e=>e.setClause),a=se(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,s]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(te(s));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(i,o):()=>!0,[i,o]),isActive:l,selectPoints:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};r(s,{clientId:o,type:"point",fields:t})},[o,s,r]),selectInterval:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};r(s,{clientId:o,type:"interval",fields:t})},[o,s,r]),clear:e.useCallback(()=>{a(s,o)},[a,s,o]),clientId:o}}const[re,ae]=K(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}))}})),le="#007bff";function ce(t,n,o="category10"){const s=e.useContext(U);return e.useMemo(()=>{if(n&&"function"!=typeof n)return s&&Object.keys(s).length>0?e=>s[e]||Z(t,n,o)(e):Z(t,n,o)},[t,n,o,s])}function ue(t,n,o){return e.useMemo(()=>{if(!n)return t;const e=[...t];if("function"==typeof n)return e.sort(n);const s="function"==typeof(i=o)?i:e=>e[i];var i;return e.sort("asc"===n?(e,t)=>s(e)-s(t):(e,t)=>s(t)-s(e))},[t,n,o])}function he({selection:t,linkedHover:n,fallbackFields:o=[],unwrapData:s=!1,onObservation:i,chartType:r,chartId:a}){const l=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields}:null}(n,o),c=ie({name:(null==t?void 0:t.name)||"__unused__"}),u=function(t){const n=t.name||"hover",{fields:o}=t,{predicate:s,isActive:i,selectPoints:r,clear:a}=ie({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&&r(t)},[o,r,a,n]),predicate:s,isActive:i}}({name:(null==l?void 0:l.name)||"hover",fields:(null==l?void 0:l.fields)||o||[]}),h=ae(e=>e.pushObservation),d=t?{isActive:c.isActive,predicate:c.predicate}:null,m=e.useCallback(e=>{var t,o;if(n)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]),u.onHover(t)}else u.onHover(null);if(i||h){const n={timestamp:Date.now(),chartType:r||"unknown",chartId:a};if(e){let s=e.data||e.datum||e;Array.isArray(s)&&(s=s[0]);const r=Object.assign(Object.assign({},n),{type:"hover",datum:s||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(r),h&&h(r)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(e),h&&h(e)}}},[n,u,i,r,a,h]),g=e.useCallback(e=>{var t,n;if(i||h){const o={timestamp:Date.now(),chartType:r||"unknown",chartId:a};if(e){let s=e.data||e.datum||e;Array.isArray(s)&&(s=s[0]);const r=Object.assign(Object.assign({},o),{type:"click",datum:s||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});i&&i(r),h&&h(r)}else{const e=Object.assign(Object.assign({},o),{type:"click-end"});i&&i(e),h&&h(e)}}},[i,h,r,a]);return{activeSelectionHook:d,customHoverBehavior:m,customClickBehavior:g}}function de({data:t,colorBy:n,colorScale:o,showLegend:s,userMargin:i,defaults:r={top:50,bottom:60,left:70,right:40}}){const a=void 0!==s?s:!!n,l=e.useMemo(()=>{if(a&&n)return function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:s,strokeWidth:i}){return{legendGroups:[{styleFn:e=>{const t={fill:e.color,stroke:e.color};return void 0!==s&&(t.stroke=s),void 0!==i&&(t.strokeWidth=i),t},type:"fill",items:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(s=>{const i=e.find("function"==typeof t?e=>t(e)===s:e=>e[t]===s),r=i?o(i,t,n):n?n(s):"#000000";return{label:s+"",color:r}}),label:""}]}}({data:t,colorBy:n,colorScale:o,getColor:Q})},[a,n,t,o]),c=e.useMemo(()=>{const e=Object.assign(Object.assign({},r),i);return l&&120>e.right&&(e.right=120),e},[r,i,l]);return{legend:l,margin:c}}const me={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 ge(e,t,n){var o,s,i,r,a,l;const c=me[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:c.width,height:null!==(s=t.height)&&void 0!==s?s:c.height,showAxes:c.showAxes,showGrid:null!==(i=t.showGrid)&&void 0!==i?i:c.showGrid,enableHover:null!==(r=t.enableHover)&&void 0!==r?r:!!t.linkedHover||c.enableHover,showLegend:null!==(a=t.showLegend)&&void 0!==a?a:c.showLegend,showLabels:null!==(l=t.showLabels)&&void 0!==l?l:c.showLabels,title:u?void 0:t.title,xLabel:u?void 0:t.xLabel,yLabel:u?void 0:t.yLabel,categoryLabel:u?void 0:t.categoryLabel,valueLabel:u?void 0:t.valueLabel,marginDefaults:c.marginDefaults}}const fe={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"8px 12px",borderRadius:"4px",fontSize:"14px",lineHeight:"1.5",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function pe(e,t){return"function"==typeof t?t(e):e[t]}function ye(e,t){return t?t(e):null==e?"":"number"==typeof e?e.toLocaleString():e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function ve(e){return!0===e||("function"==typeof e?e:!1!==e&&void 0!==e&&("object"!=typeof e||null===e||!("fields"in e)&&!("title"in e)||function(e={}){const{fields:t,title:n,format:o,style:s={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let a;const l=[];if(n){const t=pe(e,n);a=ye(t,o)}if(t&&t.length>0)t.forEach(t=>{let n,s,i;"string"==typeof t?(n=t,s=t,i=o):(n=t.label,s=t.accessor||t.key||"",i=t.format||o);const r=pe(e,s);l.push({label:n,value:ye(r,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){a=ye(e[n],o);break}if(!a){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(a=ye(e[t[0]],o))}}const c=Object.assign(Object.assign({},fe),s);return r.createElement("div",{className:("semiotic-tooltip "+i).trim(),style:c},a&&r.createElement("div",{style:{fontWeight:l.length>0?"bold":"normal"}},a),l.map((e,t)=>r.createElement("div",{key:t,style:{marginTop:0===t&&a?"4px":0}},e.label&&r.createElement("span",null,e.label,": "),e.value)))}}(e)))}function be(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function xe(e,t){return"function"==typeof t?t(e):e[t]}function we({categoryAccessor:e,valueAccessor:t,groupAccessor:n,groupLabel:o,pieData:s=!1}){return i=>{var a;const l=s?(null===(a=i.data)||void 0===a?void 0:a[0])||i.data||i:i.data||i,c=xe(l,e),u=xe(l,t),h=n?xe(l,n):void 0;return r.createElement("div",{className:"semiotic-tooltip",style:fe},r.createElement("div",{style:{fontWeight:"bold"}},be(c)),r.createElement("div",{style:{marginTop:4}},be(u)),null!=h&&r.createElement("div",{style:{marginTop:2,opacity:.8}},o||("string"==typeof(d=n)?d:"value"),": ",be(h)));var d}}function ke({componentName:e,message:t,width:n,height:o}){return r.createElement("div",{role:"alert",style:{width:n,height:Math.max(o,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},r.createElement("div",{style:{textAlign:"center",maxWidth:400}},r.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),r.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t)))}class Ae extends r.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:r.createElement(ke,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}var Ee;const Me="undefined"!=typeof process&&"production"!==(null===(Ee=process.env)||void 0===Ee?void 0:Ee.NODE_ENV);function Se({componentName:e,width:t,height:n,children:o}){return r.createElement(Ae,{fallback:o=>r.createElement(ke,{componentName:e,message:o.message,width:t,height:n})},o)}function Oe(e,t,n,o){if(!Me)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const s=t[0];if(!s||"object"!=typeof s)return;if(o in s)return;const i=Object.keys(s).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${i}`)}function je(e,t){if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||t[0]}function Le({componentName:e,data:t,accessors:n,requiredProps:o}){if(o)for(const[t,n]of Object.entries(o))if(null==n)return`${e}: ${t} is required. Provide a field name or function.`;if(!t||!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(n){const o=function(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[s,i]of Object.entries(n))if(i&&"string"==typeof i&&!(i in o)){const n=je(i,t),o=n?` Try ${s}="${n}".`:"";return`${e}: ${s} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}function Pe(t){const n=ge(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:s,className:i,categoryAccessor:a="category",valueAccessor:l="value",orientation:c="vertical",valueFormat:u,colorBy:h,colorScheme:d="category10",sort:m=!1,barPadding:g=5,tooltip:f,annotations:p,frameProps:y={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,k=n.width,A=n.height,E=n.enableHover,M=n.showGrid,S=n.showLegend,O=n.title,j=n.categoryLabel,L=n.valueLabel,P=o||[];Oe("BarChart",P,"categoryAccessor",a),Oe("BarChart",P,"valueAccessor",l);const{activeSelectionHook:C,customHoverBehavior:H}=he({selection:v,linkedHover:b,fallbackFields:h?["string"==typeof h?h:""]:[],unwrapData:!0,onObservation:x,chartType:"BarChart",chartId:w}),N=ue(P,m,l),B=ce(P,h,d),_=e.useMemo(()=>e=>{const t={};return t.fill=h?Q(e,h,B):le,t},[h,B]),$=e.useMemo(()=>J(_,C,v),[_,C,v]),{legend:D,margin:R}=de({data:N,colorBy:h,colorScale:B,showLegend:S,userMargin:s,defaults:n.marginDefaults}),z=e.useMemo(()=>we({categoryAccessor:a,valueAccessor:l,groupAccessor:h&&h!==a?h:void 0,groupLabel:"string"==typeof h?h:"group"}),[a,l,h]),W=Le({componentName:"BarChart",data:P,accessors:{categoryAccessor:a,valueAccessor:l}});if(W)return r.createElement(ke,{componentName:"BarChart",message:W,width:k,height:A});const T=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar",data:N,oAccessor:a,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",pieceStyle:$,size:[k,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R,barPadding:g,enableHover:E,showAxes:n.showAxes,oLabel:j,rLabel:L,rFormat:u,showGrid:M,oSort:m},D&&{legend:D}),O&&{title:O}),i&&{className:i}),{tooltipContent:f?ve(f):z}),(b||x)&&{customHoverBehavior:H}),p&&p.length>0&&{annotations:p}),y);return r.createElement(Se,{componentName:"BarChart",width:k,height:A},r.createElement(V,Object.assign({},T)))}function Ce(t){const n=ge(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:s,className:i,categoryAccessor:a="category",stackBy:l,valueAccessor:c="value",orientation:u="vertical",valueFormat:h,colorBy:d,colorScheme:m="category10",normalize:g=!1,barPadding:f=5,tooltip:p,annotations:y,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:k}=t,A=n.width,E=n.height,M=n.enableHover,S=n.showGrid,O=n.showLegend,j=n.title,L=n.categoryLabel,P=n.valueLabel,C=o||[],H=d||l,{activeSelectionHook:N,customHoverBehavior:B}=he({selection:b,linkedHover:x,fallbackFields:H?["string"==typeof H?H:""]:[],unwrapData:!0,onObservation:w,chartType:"StackedBarChart",chartId:k}),_=ce(C,H,m),$=e.useMemo(()=>e=>H?{fill:Q(e,H,_)}:{fill:le},[H,_]),D=e.useMemo(()=>J($,N,b),[$,N,b]),{legend:R,margin:z}=de({data:C,colorBy:H,colorScale:_,showLegend:O,userMargin:s,defaults:n.marginDefaults}),W=e.useMemo(()=>we({categoryAccessor:l,valueAccessor:c,groupAccessor:a}),[l,a,c]),T=Le({componentName:"StackedBarChart",data:C,accessors:{categoryAccessor:a,valueAccessor:c},requiredProps:{stackBy:l}});if(T)return r.createElement(ke,{componentName:"StackedBarChart",message:T,width:A,height:E});const I=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar",data:C,oAccessor:a,rAccessor:c,stackBy:l,normalize:g,projection:"horizontal"===u?"horizontal":"vertical",pieceStyle:D,size:[A,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:z,barPadding:f,enableHover:M,showAxes:n.showAxes,oLabel:L,rLabel:P,rFormat:h,showGrid:S},R&&{legend:R}),j&&{title:j}),i&&{className:i}),{tooltipContent:p?ve(p):W}),(x||w)&&{customHoverBehavior:B}),y&&y.length>0&&{annotations:y}),v);return r.createElement(Se,{componentName:"StackedBarChart",width:A,height:E},r.createElement(V,Object.assign({},I)))}function He(t){const n=ge(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:s,className:i,categoryAccessor:a="category",groupBy:l,valueAccessor:c="value",orientation:u="vertical",valueFormat:h,colorBy:d,colorScheme:m="category10",barPadding:g=5,tooltip:f,annotations:p,frameProps:y={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,k=n.width,A=n.height,E=n.enableHover,M=n.showGrid,S=n.showLegend,O=n.title,j=n.categoryLabel,L=n.valueLabel,P=o||[],C=d||l,{activeSelectionHook:H,customHoverBehavior:N}=he({selection:v,linkedHover:b,fallbackFields:C?["string"==typeof C?C:""]:[],unwrapData:!0,onObservation:x,chartType:"GroupedBarChart",chartId:w}),B=ce(P,C,m),_=e.useMemo(()=>e=>C?{fill:Q(e,C,B)}:{fill:le},[C,B]),$=e.useMemo(()=>J(_,H,v),[_,H,v]),{legend:D,margin:R}=de({data:P,colorBy:C,colorScale:B,showLegend:S,userMargin:s,defaults:n.marginDefaults}),z=e.useMemo(()=>we({categoryAccessor:l,valueAccessor:c,groupAccessor:a}),[l,a,c]),W=Le({componentName:"GroupedBarChart",data:P,accessors:{categoryAccessor:a,valueAccessor:c},requiredProps:{groupBy:l}});if(W)return r.createElement(ke,{componentName:"GroupedBarChart",message:W,width:k,height:A});const T=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"clusterbar",data:P,oAccessor:a,rAccessor:c,groupBy:l,projection:"horizontal"===u?"horizontal":"vertical",pieceStyle:$,size:[k,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R,barPadding:g,enableHover:E,showAxes:n.showAxes,oLabel:j,rLabel:L,rFormat:h,showGrid:M},D&&{legend:D}),O&&{title:O}),i&&{className:i}),{tooltipContent:f?ve(f):z}),(b||x)&&{customHoverBehavior:N}),p&&p.length>0&&{annotations:p}),y);return r.createElement(Se,{componentName:"GroupedBarChart",width:k,height:A},r.createElement(V,Object.assign({},T)))}function Ne(t){const n=ge(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:s,className:i,categoryAccessor:a="category",valueAccessor:l="value",orientation:c="vertical",valueFormat:u,colorBy:h,colorScheme:d="category10",sizeBy:m,sizeRange:g=[3,8],pointRadius:f=4,pointOpacity:p=.7,categoryPadding:y=20,tooltip:v,annotations:b,frameProps:x={},selection:w,linkedHover:k,onObservation:A,chartId:E}=t,M=n.width,S=n.height,O=n.enableHover,j=n.showGrid,L=n.showLegend,P=n.title,C=n.categoryLabel,H=n.valueLabel,N=o||[],{activeSelectionHook:B,customHoverBehavior:_}=he({selection:w,linkedHover:k,fallbackFields:h?["string"==typeof h?h:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:A,chartType:"SwarmPlot",chartId:E}),$=ce(N,h,d),D=e.useMemo(()=>{if(!m)return;const e=N.map(e=>"function"==typeof m?m(e):e[m]);return[Math.min(...e),Math.max(...e)]},[N,m]),R=e.useMemo(()=>e=>{const t={fillOpacity:p};return t.fill=h?Q(e,h,$):le,t.r=m?function(e,t,n=[3,20],o){let s;if(s="function"==typeof t?t(e):e[t],!o)return s;const[i,r]=o,[a,l]=n;return r===i?(a+l)/2:a+(s-i)/(r-i)*(l-a)}(e,m,g,D):f,t},[h,$,m,g,D,f,p]),z=e.useMemo(()=>J(R,B,w),[R,B,w]),{legend:W,margin:T}=de({data:N,colorBy:h,colorScale:$,showLegend:L,userMargin:s,defaults:n.marginDefaults}),I=e.useMemo(()=>we({categoryAccessor:a,valueAccessor:l,groupAccessor:h||void 0}),[a,l,h]),q=Le({componentName:"SwarmPlot",data:N,accessors:{categoryAccessor:a,valueAccessor:l}});if(q)return r.createElement(ke,{componentName:"SwarmPlot",message:q,width:M,height:S});const G=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"swarm",data:N,oAccessor:a,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",pieceStyle:z,size:[M,S],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:T,barPadding:y,enableHover:O,showAxes:n.showAxes,oLabel:C,rLabel:H,rFormat:u,showGrid:j},W&&{legend:W}),P&&{title:P}),i&&{className:i}),{tooltipContent:v?ve(v):I}),(k||A)&&{customHoverBehavior:_}),b&&b.length>0&&{annotations:b}),x);return r.createElement(Se,{componentName:"SwarmPlot",width:M,height:S},r.createElement(V,Object.assign({},G)))}function Be(t){const n=ge(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:s,className:i,categoryAccessor:a="category",valueAccessor:l="value",orientation:c="vertical",valueFormat:u,colorBy:h,colorScheme:d="category10",showOutliers:m=!0,categoryPadding:g=20,tooltip:f,annotations:p,frameProps:y={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,k=n.width,A=n.height,E=n.enableHover,M=n.showGrid,S=n.showLegend,O=n.title,j=n.categoryLabel,L=n.valueLabel,P=o||[],{activeSelectionHook:C,customHoverBehavior:H}=he({selection:v,linkedHover:b,fallbackFields:h?["string"==typeof h?h:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:x,chartType:"BoxPlot",chartId:w}),N=ce(P,h,d),B=e.useMemo(()=>e=>{const t=h?Q(e,h,N):le;return{fill:t,stroke:t,fillOpacity:.8}},[h,N]),_=e.useMemo(()=>J(B,C,v),[B,C,v]),{legend:$,margin:D}=de({data:P,colorBy:h,colorScale:N,showLegend:S,userMargin:s,defaults:n.marginDefaults}),R=e.useMemo(()=>e=>{const t=e.stats||(e.data||e).stats||{};return r.createElement("div",{className:"semiotic-tooltip",style:fe},r.createElement("div",{style:{fontWeight:"bold",marginBottom:"4px"}},(e.category||(e.data||e).category||"")+""),null!=t.median&&r.createElement(r.Fragment,null,null!=t.n&&r.createElement("div",null,"n = ",t.n),r.createElement("div",null,"Median: ",t.median.toLocaleString()),r.createElement("div",null,"Q1: ",t.q1.toLocaleString()),r.createElement("div",null,"Q3: ",t.q3.toLocaleString()),r.createElement("div",null,"Min: ",t.min.toLocaleString()),r.createElement("div",null,"Max: ",t.max.toLocaleString())))},[]),z=Le({componentName:"BoxPlot",data:P,accessors:{categoryAccessor:a,valueAccessor:l}});if(z)return r.createElement(ke,{componentName:"BoxPlot",message:z,width:k,height:A});const W=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"boxplot",data:P,oAccessor:a,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",summaryStyle:_,showOutliers:m,size:[k,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:D,barPadding:g,enableHover:E,showAxes:n.showAxes,oLabel:j,rLabel:L,rFormat:u,showGrid:M},$&&{legend:$}),O&&{title:O}),i&&{className:i}),{tooltipContent:f?ve(f):R}),(b||x)&&{customHoverBehavior:H}),p&&p.length>0&&{annotations:p}),y);return r.createElement(Se,{componentName:"BoxPlot",width:k,height:A},r.createElement(V,Object.assign({},W)))}function _e(t){const n=ge(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:s,className:i,categoryAccessor:a="category",valueAccessor:l="value",bins:c=25,relative:u=!1,valueFormat:h,colorBy:d,colorScheme:m="category10",categoryPadding:g=20,tooltip:f,annotations:p,frameProps:y={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,k=n.width,A=n.height,E=n.enableHover,M=n.showGrid,S=n.showLegend,O=n.title,j=n.categoryLabel,L=n.valueLabel,P=o||[],{activeSelectionHook:C,customHoverBehavior:H}=he({selection:v,linkedHover:b,fallbackFields:d?["string"==typeof d?d:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:x,chartType:"Histogram",chartId:w}),N=ce(P,d,m),B=e.useMemo(()=>e=>{const t=d?Q(e,d,N):le;return{fill:t,stroke:t,fillOpacity:.8}},[d,N]),_=e.useMemo(()=>J(B,C,v),[B,C,v]),{legend:$,margin:D}=de({data:P,colorBy:d,colorScale:N,showLegend:S,userMargin:s,defaults:n.marginDefaults}),R=e.useMemo(()=>e=>{const t=e.data||e,n=t.category||e.category||"",o=t.count,s=t.range;return r.createElement("div",{className:"semiotic-tooltip",style:fe},n&&r.createElement("div",{style:{fontWeight:"bold"}},n+""),null!=o&&r.createElement("div",null,"Count: ",o),s&&2===s.length&&r.createElement("div",{style:{opacity:.8}},Number(s[0]).toFixed(1)," – ",Number(s[1]).toFixed(1)))},[]),z=Le({componentName:"Histogram",data:P,accessors:{categoryAccessor:a,valueAccessor:l}});if(z)return r.createElement(ke,{componentName:"Histogram",message:z,width:k,height:A});const W=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"histogram",data:P,oAccessor:a,rAccessor:l,projection:"horizontal",summaryStyle:_,bins:c,normalize:u,size:[k,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:D,barPadding:g,enableHover:E,showAxes:n.showAxes,oLabel:j,rLabel:L,rFormat:h,showGrid:M},$&&{legend:$}),O&&{title:O}),i&&{className:i}),{tooltipContent:f?ve(f):R}),(b||x)&&{customHoverBehavior:H}),p&&p.length>0&&{annotations:p}),y);return r.createElement(Se,{componentName:"Histogram",width:k,height:A},r.createElement(V,Object.assign({},W)))}function $e(t){const n=ge(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:s,className:i,categoryAccessor:a="category",valueAccessor:l="value",orientation:c="vertical",bins:u=25,showIQR:h=!0,valueFormat:d,colorBy:m,colorScheme:g="category10",categoryPadding:f=20,tooltip:p,annotations:y,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:k}=t,A=n.width,E=n.height,M=n.enableHover,S=n.showGrid,O=n.showLegend,j=n.title,L=n.categoryLabel,P=n.valueLabel,C=o||[],{activeSelectionHook:H,customHoverBehavior:N}=he({selection:b,linkedHover:x,fallbackFields:m?["string"==typeof m?m:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:w,chartType:"ViolinPlot",chartId:k}),B=ce(C,m,g),_=e.useMemo(()=>e=>{const t=m?Q(e,m,B):le;return{fill:t,stroke:t,fillOpacity:.6}},[m,B]),$=e.useMemo(()=>J(_,H,b),[_,H,b]),{legend:D,margin:R}=de({data:C,colorBy:m,colorScale:B,showLegend:O,userMargin:s,defaults:n.marginDefaults}),z=e.useMemo(()=>e=>{var t;const n=e.category||e.data&&(null===(t=e.data[0])||void 0===t?void 0:t.category)||"",o=e.stats;if(o)return r.createElement("div",{className:"semiotic-tooltip",style:fe},n&&r.createElement("div",{style:{fontWeight:"bold"}},n+""),r.createElement("div",null,"n = ",o.n),r.createElement("div",null,"Min: ",o.min.toLocaleString()),r.createElement("div",null,"Q1: ",o.q1.toLocaleString()),r.createElement("div",null,"Median: ",o.median.toLocaleString()),r.createElement("div",null,"Q3: ",o.q3.toLocaleString()),r.createElement("div",null,"Max: ",o.max.toLocaleString()),r.createElement("div",{style:{opacity:.8}},"Mean: ",o.mean.toLocaleString(void 0,{maximumFractionDigits:2})));const s=(Array.isArray(e.data)?e.data:[]).map(e=>{const t="function"==typeof l?l(e):e[l];return Number(t)}).filter(e=>!isNaN(e)).sort((e,t)=>e-t),i=s.length,a=i>0?s[Math.floor(i/2)]:null;return r.createElement("div",{className:"semiotic-tooltip",style:fe},n&&r.createElement("div",{style:{fontWeight:"bold"}},n+""),i>0&&r.createElement("div",null,"n = ",i),null!=a&&r.createElement("div",null,"Median: ",a.toLocaleString()))},[l]),W=Le({componentName:"ViolinPlot",data:C,accessors:{categoryAccessor:a,valueAccessor:l}});if(W)return r.createElement(ke,{componentName:"ViolinPlot",message:W,width:A,height:E});const T=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"violin",data:C,oAccessor:a,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",summaryStyle:$,bins:u,showIQR:h,size:[A,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R,barPadding:f,enableHover:M,showAxes:n.showAxes,oLabel:L,rLabel:P,rFormat:d,showGrid:S},D&&{legend:D}),j&&{title:j}),i&&{className:i}),{tooltipContent:p?ve(p):z}),(x||w)&&{customHoverBehavior:N}),y&&y.length>0&&{annotations:y}),v);return r.createElement(Se,{componentName:"ViolinPlot",width:A,height:E},r.createElement(V,Object.assign({},T)))}function De(t){var n;const o=ge(t.mode,{width:t.width,height:t.height,showGrid:null===(n=t.showGrid)||void 0===n||n,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:s,margin:i,className:a,categoryAccessor:l="category",valueAccessor:c="value",orientation:u="horizontal",valueFormat:h,colorBy:d,colorScheme:m="category10",sort:g=!0,dotRadius:f=5,categoryPadding:p=10,tooltip:y,annotations:v,frameProps:b={},selection:x,linkedHover:w,onObservation:k,chartId:A}=t,E=o.width,M=o.height,S=o.enableHover,O=o.showGrid,j=o.showLegend,L=o.title,P=o.categoryLabel,C=o.valueLabel,H=s||[],{activeSelectionHook:N,customHoverBehavior:B}=he({selection:x,linkedHover:w,fallbackFields:d?["string"==typeof d?d:""]:["string"==typeof l?l:""],unwrapData:!0,onObservation:k,chartType:"DotPlot",chartId:A}),_=ue(H,g,c),$=ce(H,d,m),D=e.useMemo(()=>e=>{const t={r:f,fillOpacity:.8};return t.fill=d?Q(e,d,$):le,t},[d,$,f]),R=e.useMemo(()=>J(D,N,x),[D,N,x]),{legend:z,margin:W}=de({data:_,colorBy:d,colorScale:$,showLegend:j,userMargin:i,defaults:o.marginDefaults}),T=e.useMemo(()=>we({categoryAccessor:l,valueAccessor:c}),[l,c]),I=Le({componentName:"DotPlot",data:H,accessors:{categoryAccessor:l,valueAccessor:c}});if(I)return r.createElement(ke,{componentName:"DotPlot",message:I,width:E,height:M});const q=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"point",data:_,oAccessor:l,rAccessor:c,projection:"horizontal"===u?"horizontal":"vertical",pieceStyle:R,size:[E,M],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:W,barPadding:p,enableHover:S,showAxes:o.showAxes,oLabel:P,rLabel:C,rFormat:h,showGrid:O,oSort:g},z&&{legend:z}),L&&{title:L}),a&&{className:a}),{tooltipContent:y?ve(y):T}),(w||k)&&{customHoverBehavior:B}),v&&v.length>0&&{annotations:v}),b);return r.createElement(Se,{componentName:"DotPlot",width:E,height:M},r.createElement(V,Object.assign({},q)))}function Re(t){var n,o;const s=ge(t.mode,{width:null!==(n=t.width)&&void 0!==n?n:400,height:null!==(o=t.height)&&void 0!==o?o:400,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title}),{data:i,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",colorBy:h,colorScheme:d="category10",startAngle:m=0,tooltip:g,annotations:f,frameProps:p={},selection:y,linkedHover:v,onObservation:b,chartId:x}=t,w=s.width,k=s.height,A=s.enableHover,E=s.showLegend,M=s.title,S=i||[],O=h||c,{activeSelectionHook:j,customHoverBehavior:L}=he({selection:y,linkedHover:v,fallbackFields:O?["string"==typeof O?O:""]:[],unwrapData:!0,onObservation:b,chartType:"PieChart",chartId:x}),P=ce(S,O,d),C=e.useMemo(()=>e=>O?{fill:Q(e,O,P)}:{fill:le},[O,P]),H=e.useMemo(()=>J(C,j,y),[C,j,y]),{legend:N,margin:B}=de({data:S,colorBy:O,colorScale:P,showLegend:E,userMargin:a,defaults:s.marginDefaults}),_=e.useMemo(()=>we({categoryAccessor:c,valueAccessor:u,groupAccessor:h&&h!==c?h:void 0,groupLabel:"string"==typeof h?h:"group",pieData:!0}),[c,u,h]),$=Le({componentName:"PieChart",data:S,accessors:{categoryAccessor:c,valueAccessor:u}});if($)return r.createElement(ke,{componentName:"PieChart",message:$,width:w,height:k});const D=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"pie",data:S,oAccessor:c,rAccessor:u,projection:"radial",pieceStyle:H,startAngle:m,size:[w,k],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:B,enableHover:A,showAxes:!1},N&&{legend:N}),M&&{title:M}),l&&{className:l}),{tooltipContent:g?ve(g):_}),(v||b)&&{customHoverBehavior:L}),f&&f.length>0&&{annotations:f}),p);return r.createElement(Se,{componentName:"PieChart",width:w,height:k},r.createElement(V,Object.assign({},D)))}function ze(t){var n,o;const s=ge(t.mode,{width:null!==(n=t.width)&&void 0!==n?n:400,height:null!==(o=t.height)&&void 0!==o?o:400,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,linkedHover:t.linkedHover}),{data:i,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",innerRadius:h=60,centerContent:d,colorBy:m,colorScheme:g="category10",startAngle:f=0,tooltip:p,annotations:y,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:k}=t,A=s.width,E=s.height,M=s.enableHover,S=s.showLegend,O=s.title,j=i||[],L=m||c,{activeSelectionHook:P,customHoverBehavior:C}=he({selection:b,linkedHover:x,fallbackFields:L?["string"==typeof L?L:""]:[],unwrapData:!0,onObservation:w,chartType:"DonutChart",chartId:k}),H=ce(j,L,g),N=e.useMemo(()=>e=>L?{fill:Q(e,L,H)}:{fill:le},[L,H]),B=e.useMemo(()=>J(N,P,b),[N,P,b]),{legend:_,margin:$}=de({data:j,colorBy:L,colorScale:H,showLegend:S,userMargin:a,defaults:s.marginDefaults}),D=e.useMemo(()=>we({categoryAccessor:c,valueAccessor:u,groupAccessor:m&&m!==c?m:void 0,groupLabel:"string"==typeof m?m:"group",pieData:!0}),[c,u,m]),R=Le({componentName:"DonutChart",data:j,accessors:{categoryAccessor:c,valueAccessor:u}});if(R)return r.createElement(ke,{componentName:"DonutChart",message:R,width:A,height:E});const z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"donut",data:j,oAccessor:c,rAccessor:u,projection:"radial",pieceStyle:B,innerRadius:h,startAngle:f,centerContent:d,size:[A,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:$,enableHover:M,showAxes:!1},_&&{legend:_}),O&&{title:O}),l&&{className:l}),{tooltipContent:p?ve(p):D}),(x||w)&&{customHoverBehavior:C}),y&&y.length>0&&{annotations:y}),v);return r.createElement(Se,{componentName:"DonutChart",width:A,height:E},r.createElement(V,Object.assign({},z)))}Pe.displayName="BarChart",Ce.displayName="StackedBarChart",He.displayName="GroupedBarChart",Ne.displayName="SwarmPlot",Be.displayName="BoxPlot",_e.displayName="Histogram",$e.displayName="ViolinPlot",De.displayName="DotPlot",Re.displayName="PieChart",ze.displayName="DonutChart",exports.BarChart=Pe,exports.BoxPlot=Be,exports.DonutChart=ze,exports.DotPlot=De,exports.GroupedBarChart=He,exports.Histogram=_e,exports.PieChart=Re,exports.StackedBarChart=Ce,exports.StreamOrdinalFrame=V,exports.SwarmPlot=Ne,exports.ViolinPlot=$e;
|
|
1
|
+
"use strict";const e=require("react"),t=require("d3-scale"),n=require("d3-array"),o=require("d3-hierarchy"),s=require("d3-scale-chromatic");function i(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 r=i(e),a=5e3;class l{constructor(e){this.lastBoundedData=null,this.chunkTimer=0,this.callback=e}clearLastData(){this.lastBoundedData=null,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),5e3>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,a),bounded:!0,totalSize:e.length});let t=a;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const o=Math.min(t+a,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}push(e){this.callback({inserts:[e],bounded:!1})}pushMany(e){0!==e.length&&this.callback({inserts:e,bounded:!1})}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null}}class c{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}toArray(){const e=[];for(const t of this)e.push(t);return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class u{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 h(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function d(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}function m(e,t,n,o,s,i,r){return{type:"rect",x:e,y:t,w:n,h:o,style:s,datum:i,group:r}}function g(e,t){const{columns:n,config:o,resolvePieceStyle:s}=e,i=[],r=Math.min(t.width,t.height)/2-4,a="donut"===o.chartType?o.innerRadius||60:0,l=-Math.PI/2+(o.startAngle||0)*Math.PI/180,c=2*Math.PI;for(const e of Object.values(n)){const t=l+e.pctStart*c,n=l+(e.pctStart+e.pct)*c,o=s(e.pieceData[0],e.name);i.push({type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:r,startAngle:t,endAngle:n,style:o,datum:e.pieceData,category:e.name})}return i}function f(e){var t,o,s;const i=e.length,r=e[0],a=e[i-1];return{n:i,min:r,q1:null!==(t=n.quantile(e,.25))&&void 0!==t?t:r,median:null!==(o=n.quantile(e,.5))&&void 0!==o?o:(r+a)/2,q3:null!==(s=n.quantile(e,.75))&&void 0!==s?s:a,max:a,mean:e.reduce((e,t)=>e+t,0)/i}}const p={bar:function(e,t){const{scales:n,columns:o,config:s,getR:i,getStack:r,resolvePieceStyle:a}=e,{r:l,projection:c}=n,u=[],h="vertical"===c,d="horizontal"===c,g=s.normalize;for(const e of Object.values(o)){const t=new Map;for(const n of e.pieceData){const e=r?r(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const o=t.get(e);o.total+=i(n),o.pieces.push(n)}let n=0;if(g)for(const e of t.values())n+=Math.abs(e.total);let o=0,s=0;for(const[i,c]of t){let t=c.total;g&&n>0&&(t/=n);const f=a(c.pieces[0],r?i:e.name),p=Object.assign(Object.assign({},c.pieces[0]),{__aggregateValue:c.total,__pieceCount:c.pieces.length,category:e.name});if(h){const n=l(0>t?s:o+t),r=0>t?l(s+t)-l(s):l(o)-l(o+t);u.push(m(e.x,n,e.width,Math.abs(r),f,p,i)),0>t?s+=t:o+=t}else if(d){const n=l(0>t?s+t:o),r=0>t?l(s)-l(s+t):l(o+t)-l(o);u.push(m(n,e.x,Math.abs(r),e.width,f,p,i)),0>t?s+=t:o+=t}}}return u},clusterbar:function(e,t){const{scales:n,columns:o,getR:s,getGroup:i,resolvePieceStyle:r}=e,{r:a,projection:l}=n,c=[],u="vertical"===l,h=[],d=new Set;for(const e of Object.values(o))for(const t of e.pieceData){const e=i?i(t):"_default";d.has(e)||(d.add(e),h.push(e))}const g=h.length||1;for(const e of Object.values(o)){const t=e.width/g,n=new Map;for(const t of e.pieceData){const e=i?i(t):"_default";n.has(e)||n.set(e,[]),n.get(e).push(t)}for(let o=0;h.length>o;o++){const i=n.get(h[o])||[];for(const n of i){const i=s(n),l=r(n,e.name);if(u){const s=e.x+o*t,r=a(0),u=a(i);c.push(m(s,Math.min(r,u),t,Math.abs(r-u),l,n,h[o]))}else{const s=e.x+o*t,r=a(0),u=a(i);c.push(m(Math.min(r,u),s,Math.abs(u-r),t,l,n,h[o]))}}}}return c},point:function(e,t){var n,o;const{scales:s,columns:i,getR:r,multiScales:a,resolvePieceStyle:l}=e,{r:c,projection:u}=s,h=[],d="vertical"===u,m="radial"===u,g=a.length>0,f=2*Math.PI,p=-Math.PI/2;for(const e of Object.values(i))for(const t of e.pieceData){const s=null!==(n=t.__rIndex)&&void 0!==n?n:0,i=null!==(o=t.__rValue)&&void 0!==o?o:r(t),u=g&&a[s]||c,y=l(t,e.name),v=y.r||5;let b,x;if(m){const t=p+(e.pctStart+e.pct/2)*f,n=u(i);b=Math.cos(t)*n,x=Math.sin(t)*n}else d?(b=e.middle,x=u(i)):(b=u(i),x=e.middle);h.push({type:"point",x:b,y:x,r:v,style:y,datum:t})}return h},swarm:function(e,t){const{scales:n,columns:o,getR:s,resolvePieceStyle:i}=e,{r:r,projection:a}=n,l=[],c="vertical"===a;for(const e of Object.values(o)){const t=e.width/2;for(let n=0;e.pieceData.length>n;n++){const o=e.pieceData[n],a=s(o),u=i(o,e.name),h=u.r||4,d=(7919*n%100/100-.5)*t*.8,m=c?e.middle+d:r(a),g=c?r(a):e.middle+d;l.push({type:"point",x:m,y:g,r:h,style:u,datum:o})}}return l},pie:g,donut:g,boxplot:function(e,t){var o,s,i,r,a;const{scales:l,columns:c,config:u,getR:h,resolveSummaryStyle:d}=e,{r:m,projection:g}=l,f=[],p="vertical"===g,y=!1!==u.showOutliers;for(const e of Object.values(c)){const t=e.pieceData.map(e=>h(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===t.length)continue;const l=t[0],c=t[t.length-1],u=null!==(o=n.quantile(t,.25))&&void 0!==o?o:l,g=null!==(s=n.quantile(t,.5))&&void 0!==s?s:(l+c)/2,v=null!==(i=n.quantile(t,.75))&&void 0!==i?i:c,b=v-u,x=u-1.5*b,w=v+1.5*b,k=null!==(r=t.find(e=>e>=x))&&void 0!==r?r:l,A=null!==(a=[...t].reverse().find(e=>w>=e))&&void 0!==a?a:c,E=d(e.pieceData[0],e.name),M=[];if(y)for(const t of e.pieceData){const n=h(t);if(x>n||n>w){const o=p?e.middle:m(n),s=p?m(n):e.middle;M.push({px:o,py:s,value:n,datum:t})}}if(f.push({type:"boxplot",x:p?e.middle:0,y:p?0:e.middle,projection:p?"vertical":"horizontal",columnWidth:.6*e.width,minPos:m(k),q1Pos:m(u),medianPos:m(g),q3Pos:m(v),maxPos:m(A),stats:{min:k,q1:u,median:g,q3:v,max:A},style:E,datum:e.pieceData,category:e.name,outliers:M}),y)for(const e of M)f.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:E.fill||"#999",opacity:.6},datum:e.datum})}return f},violin:function(e,t){var o,s,i;const{scales:r,columns:a,config:l,getR:c,resolveSummaryStyle:u}=e,{r:h,projection:d}=r,m=[],g="vertical"===d,p=l.bins||20,y=!1!==l.showIQR;for(const e of Object.values(a)){const t=e.pieceData.map(e=>c(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const r=t[0],a=t[t.length-1],l=(a-r)/p||1,d=Array(p).fill(0);for(const e of t)d[Math.min(Math.floor((e-r)/l),p-1)]++;const v=Math.max(...d,1),b=e.width/2*.9;let x="";if(g){for(let t=0;p>t;t++){const n=h(r+(t+.5)*l),o=d[t]/v*b;x+=0===t?`M ${e.middle+o} ${n}`:` L ${e.middle+o} ${n}`}for(let t=p-1;t>=0;t--){const n=h(r+(t+.5)*l);x+=` L ${e.middle-d[t]/v*b} ${n}`}x+=" Z"}else{for(let t=0;p>t;t++){const n=h(r+(t+.5)*l),o=d[t]/v*b;x+=0===t?`M ${n} ${e.middle-o}`:` L ${n} ${e.middle-o}`}for(let t=p-1;t>=0;t--)x+=` L ${h(r+(t+.5)*l)} ${e.middle+d[t]/v*b}`;x+=" Z"}const w=u(e.pieceData[0],e.name);let k;if(y&&t.length>=4){const l=null!==(o=n.quantile(t,.25))&&void 0!==o?o:r,c=null!==(s=n.quantile(t,.5))&&void 0!==s?s:(r+a)/2,u=null!==(i=n.quantile(t,.75))&&void 0!==i?i:a;k={q1Pos:h(l),medianPos:h(c),q3Pos:h(u),centerPos:e.middle,isVertical:g}}const A=g?{x:e.x,y:Math.min(h(a),h(r)),width:e.width,height:Math.abs(h(a)-h(r))}:{x:Math.min(h(r),h(a)),y:e.x,width:Math.abs(h(a)-h(r)),height:e.width};m.push({type:"violin",pathString:x,translateX:0,translateY:0,bounds:A,iqrLine:k,stats:f(t),style:w,datum:e.pieceData,category:e.name})}return m},histogram:function(e,t){const{scales:n,columns:o,config:s,getR:i,resolveSummaryStyle:r}=e,{r:a}=n,l=[],c=s.bins||25,u=s.normalize;for(const e of Object.values(o)){const t=e.pieceData.map(e=>i(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const n=Math.min(...t),o=(Math.max(...t)-n)/c||1,s=Array(c).fill(0);for(const e of t)s[Math.min(Math.floor((e-n)/o),c-1)]++;const h=t.length,d=Math.max(...s,1),g=r(e.pieceData[0],e.name);for(let t=0;c>t;t++){if(0===s[t])continue;const i=(u?s[t]/h:s[t]/d)*e.width*.9,r=a(n+t*o),c=a(n+(t+1)*o);l.push(m(Math.min(r,c),e.x+e.width-i,Math.abs(c-r),i,g,{bin:t,count:s[t],range:[n+t*o,n+(t+1)*o],category:e.name},e.name))}}return l},ridgeline:function(e,t){var n;const{scales:o,columns:s,config:i,getR:r,resolveSummaryStyle:a}=e,{r:l,projection:c}=o,u=[],h=i.bins||20,d="horizontal"===c,m=i.amplitude||1.5;for(const e of Object.values(s)){const t=e.pieceData.map(e=>r(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const o=t[0],s=t[t.length-1],i=(s-o)/h||1,c=Array(h).fill(0);for(const e of t)c[Math.min(Math.floor((e-o)/i),h-1)]++;const g=Math.max(...c,1),p=a(e.pieceData[0],e.name),y=e.width*m;let v="";if(d){const t=e.x+e.width;v=`M ${l(o)} ${t}`;for(let e=0;h>e;e++)v+=` L ${l(o+(e+.5)*i)} ${t-c[e]/g*y}`;v+=` L ${l(s)} ${t} Z`}else{const t=e.x;v=`M ${t} ${l(o)}`;for(let e=0;h>e;e++){const n=l(o+(e+.5)*i);v+=` L ${t+c[e]/g*y} ${n}`}v+=` L ${t} ${l(s)} Z`}const b=d?{x:Math.min(l(o),l(s)),y:e.x,width:Math.abs(l(s)-l(o)),height:e.width}:{x:e.x,y:Math.min(l(s),l(o)),width:e.width,height:Math.abs(l(s)-l(o))};u.push({type:"violin",pathString:v,translateX:0,translateY:0,bounds:b,stats:f(t),style:Object.assign(Object.assign({},p),{fillOpacity:null!==(n=p.fillOpacity)&&void 0!==n?n:.5}),datum:e.pieceData,category:e.name})}return u},timeline:function(e,t){const{scales:n,columns:o,getRawRange:s,resolvePieceStyle:i}=e,{r:r,projection:a}=n,l=[],c="horizontal"===a;for(const e of Object.values(o))for(const t of e.pieceData){const n=s(t);if(!n)continue;const[o,a]=n,u=i(t,e.name);if(c){const n=r(Math.min(o,a)),s=r(Math.max(o,a));l.push(m(n,e.x,s-n,e.width,u,t,e.name))}else{const n=r(Math.max(o,a)),s=r(Math.min(o,a));l.push(m(e.x,n,e.width,s-n,u,t,e.name))}}return l}};class y{constructor(e){this.rExtent=new u,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.version=0,this.config=e,this.buffer=new c(e.windowSize),this.getO=d(e.oAccessor||e.categoryAccessor,"category");const t="streaming"===e.runtimeMode,n=e.rAccessor;Array.isArray(n)?(this.rAccessors=n.map(e=>h(e,"value")),this.getR=this.rAccessors[0],this.rExtents=n.map(()=>new u)):(this.getR=h(t&&(e.timeAccessor||e.valueAccessor)&&e.valueAccessor||n,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=d(e.stackBy),this.getGroup=d(e.groupBy),this.getColor=d(e.colorAccessor),this.getConnector=d(e.connectorAccessor),e.pulse&&(this.timestampBuffer=new c(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,e.bounded){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(n)),this.pushValueExtent(n)}else for(const n of e.inserts){const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(n)),this.pushValueExtent(n),null!=e&&this.evictValueExtent(e)}return!0}pushValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.push(t[0]),this.rExtent.push(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].push(this.rAccessors[t](e));this.rExtent.push(this.getR(e))}else this.rExtent.push(this.getR(e))}evictValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.evict(t[0]),this.rExtent.evict(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].evict(this.rAccessors[t](e));this.rExtent.evict(this.getR(e))}else this.rExtent.evict(this.getR(e))}getRawRange(e){const t=this.config.rAccessor;if(!t)return null;const n="function"==typeof t?t(e):e[t];return Array.isArray(n)&&n.length>=2?[+n[0],+n[1]]:null}computeScene(e){const{config:n,buffer:o}=this;if(0===o.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(o,this.getR);const s=o.toArray(),i=n.projection||"vertical",r=n.oExtent||this.resolveCategories(s),a=this.computeValueDomain(s,r),l="horizontal"===i,c=null!=n.barPadding?n.barPadding/("vertical"===i?e.width:e.height):.1;let u,h;if("radial"===i){u=t.scaleBand().domain(r).range([0,1]).padding(0);const o=Math.min(e.width,e.height)/2,s=n.innerRadius||0;h=t.scaleLinear().domain(a).range([s,o])}else l?(u=t.scaleBand().domain(r).range([0,e.height]).padding(c),h=t.scaleLinear().domain(a).range([0,e.width])):(u=t.scaleBand().domain(r).range([0,e.width]).padding(c),h=t.scaleLinear().domain(a).range([e.height,0]));this.scales={o:u,r:h,projection:i},this.multiScales=this.rAccessors.length>1&&n.multiAxis?this.rAccessors.map((s,i)=>{const r=this.rExtents[i];r.dirty&&r.recalculate(o,s);let[a,c]=r.extent;a===1/0&&(a=0,c=1);const u=c-a,h=u>0?u*(n.extentPadding||.05):1;return a-=h,c+=h,a>0&&(a=0),l?t.scaleLinear().domain([a,c]).range([0,e.width]):t.scaleLinear().domain([a,c]).range([e.height,0])}):[];let d=s;this.rAccessors.length>1&&(d=s.flatMap(e=>this.rAccessors.map((t,n)=>Object.assign(Object.assign({},e),{__rIndex:n,__rValue:t(e),__rName:this.resolveRAccessorName(n)})))),this.columns=this.buildColumns(d,r,u,i,e),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(d,e),this.config.decay&&this.applyDecay(this.scene,s),this.config.pulse&&this.applyPulse(this.scene,s),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(e){const t=Array.isArray(this.config.rAccessor)?this.config.rAccessor[e]:this.config.rAccessor;return"string"==typeof t?t:"value"+e}resolveCategories(e){const t=Array.from(this.categories),n=this.config.oSort;if("streaming"===this.config.runtimeMode&&void 0===n)return t;if(!1===n)return t;if("function"==typeof n)return t.sort(n);const o=new Map;for(const t of e){const e=this.getO(t);o.set(e,(o.get(e)||0)+Math.abs(this.getR(t)))}return t.sort("asc"===n?(e,t)=>(o.get(e)||0)-(o.get(t)||0):(e,t)=>(o.get(t)||0)-(o.get(e)||0))}computeValueDomain(e,t){var n,o;const s=this.config.chartType,i=this.config.extentPadding||.05;if("radial"===this.config.projection&&("pie"===s||"donut"===s))return[0,1];let r=0,a=0;if("bar"===s&&this.getStack){const t=new Map,n=new Map;for(const o of e){const e=this.getO(o),s=this.getR(o);0>s?n.set(e,(n.get(e)||0)+s):t.set(e,(t.get(e)||0)+s)}for(const e of t.values())e>a&&(a=e);for(const e of n.values())r>e&&(r=e)}else if("bar"===s){const t=new Map;for(const n of e){const e=this.getO(n),o=this.getR(n);t.set(e,(t.get(e)||0)+o)}for(const e of t.values())e>a&&(a=e),r>e&&(r=e)}else if("clusterbar"===s)for(const t of e){const e=this.getR(t);e>a&&(a=e),r>e&&(r=e)}else{const e=this.rExtent.extent[0],t=this.rExtent.extent[1];e!==1/0&&(r=e),t!==-1/0&&(a=t)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(r=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(a=this.config.rExtent[1]));const l=a-r,c=l>0?l*i:1;return(null===(n=this.config.rExtent)||void 0===n?void 0:n[0])||(r-=c),(null===(o=this.config.rExtent)||void 0===o?void 0:o[1])||(a+=c),"bar"!==s&&"clusterbar"!==s||(r>0&&(r=0),0>a&&(a=0)),[r,a]}buildColumns(e,t,n,o,s){var i;const r={},a=new Map;for(const t of e){const e=this.getO(t);a.has(e)||a.set(e,[]),a.get(e).push(t)}let l=0;if("radial"===o)for(const t of e)l+=Math.abs(this.getR(t));const c=this.config.dynamicColumnWidth;let u=null;if(c&&"radial"!==o){u=new Map;let e=0;for(const n of t){const t=a.get(n)||[];let o;o="string"==typeof c?t.reduce((e,t)=>e+(Number(t[c])||0),0):c(t),u.set(n,o),e+=o}const i=("horizontal"===o?s.height:s.width)-n.padding()*n.step()*t.length;if(e>0)for(const[t,n]of u)u.set(t,n/e*i)}let h=0,d=0;for(const e of t){const t=a.get(e)||[],o=t.reduce((e,t)=>e+Math.abs(this.getR(t)),0),s=l>0?o/l:0;let c,m;u?(c=d,m=u.get(e)||n.bandwidth(),d+=m+n.padding()*n.step()):(c=null!==(i=n(e))&&void 0!==i?i:0,m=n.bandwidth()),r[e]={name:e,x:c,y:0,width:m,middle:c+m/2,padding:n.padding()*n.step(),pieceData:t,pct:s,pctStart:h},h+=s}return r}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(e,t)=>this.resolvePieceStyle(e,t),resolveSummaryStyle:(e,t)=>this.resolveSummaryStyle(e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];const n=this.getSceneContext(),o=p[this.config.chartType];let s=o?o(n,t):[];if(this.getConnector&&this.scales){const e=function(e,t){const{scales:n,config:o,getConnector:s,getO:i}=e;if(!s||!n)return[];const r=[],{projection:a}=n,l=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const n=s(t);if(!n)continue;let o,r;"point"===e.type?(o=e.x,r=e.y):(o=e.x+e.w/2,r=e.y+("vertical"===a?0:e.h/2)),l.has(n)||l.set(n,[]),l.get(n).push({x:o,y:r,datum:t,category:i(t)})}const c=n.o.domain(),u=o.connectorStyle;for(const[e,t]of l)if(t.length>=2){t.sort((e,t)=>c.indexOf(e.category)-c.indexOf(t.category));for(let n=0;t.length-1>n;n++){const o=t[n],s=t[n+1],i="function"==typeof u?u(o.datum):u||{stroke:"#999",strokeWidth:1,opacity:.5};r.push({type:"connector",x1:o.x,y1:o.y,x2:s.x,y2:s.y,style:i,datum:o.datum,group:e})}}return r}(n,s);s=[...e,...s]}return s}resolvePieceStyle(e,t){return"function"==typeof this.config.pieceStyle?this.config.pieceStyle(e,t):this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&t?{fill:this.config.barColors[t]||"#007bff"}:t?{fill:this.getColorFromScheme(t)}:{fill:"#007bff"}}getColorFromScheme(e){this._colorSchemeMap||(this._colorSchemeMap=new Map);const t=this._colorSchemeMap.get(e);if(t)return t;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],o=n[this._colorSchemeIndex%n.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(e,o),o}resolveSummaryStyle(e,t){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(e,t):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(e,t){var n,o,s;const i=this.config.decay;if(!i||1>=t)return 1;const r=null!==(n=i.minOpacity)&&void 0!==n?n:.1,a=t-1-e;switch(i.type){case"linear":return r+(1-a/(t-1))*(1-r);case"exponential":{const e=null!==(o=i.halfLife)&&void 0!==o?o:t/2;return r+Math.pow(.5,a/e)*(1-r)}case"step":return(null!==(s=i.stepThreshold)&&void 0!==s?s:.5*t)>a?1:r;default:return 1}}applyDecay(e,t){var n,o;if(!this.config.decay)return;const s=t.length;if(1>=s)return;const i=new Map;for(let e=0;t.length>e;e++)i.set(t[e],e);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=i.get(t.datum);if(null==e)continue;const r=this.computeDecayOpacity(e,s),a=null!==(o=null===(n=t.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:a*r})}}applyPulse(e,t){var n,o,s;if(!this.config.pulse||!this.timestampBuffer)return;const i="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(n=this.config.pulse.duration)&&void 0!==n?n:500,a=null!==(o=this.config.pulse.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",l=null!==(s=this.config.pulse.glowRadius)&&void 0!==s?s:4,c=new Map;for(let e=0;t.length>e;e++)c.set(t[e],e);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=c.get(t.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const o=i-n;r>o&&(t._pulseIntensity=1-o/r,t._pulseColor=a,t._pulseGlowRadius=l)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}snapshotPositions(){var e,t;this.prevPositionMap.clear();for(let n=0;this.scene.length>n;n++){const o=this.scene[n];if("point"===o.type)this.prevPositionMap.set("p:"+n,{x:o.x,y:o.y,r:o.r});else if("rect"===o.type){const s=`r:${o.group||""}:${null!==(t=null===(e=o.datum)||void 0===e?void 0:e.category)&&void 0!==t?t:n}`;this.prevPositionMap.set(s,{x:o.x,y:o.y,w:o.w,h:o.h})}}}startTransition(){var e,t,n,o,s;if(!this.config.transition||0===this.prevPositionMap.size)return;const i=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;let r=!1;for(let e=0;this.scene.length>e;e++){const i=this.scene[e];let a=null;if("point"===i.type?a="p:"+e:"rect"===i.type&&(a=`r:${i.group||""}:${null!==(n=null===(t=i.datum)||void 0===t?void 0:t.category)&&void 0!==n?n:e}`),!a)continue;const l=this.prevPositionMap.get(a);l&&("point"===i.type?l.x===i.x&&l.y===i.y||(i._targetX=i.x,i._targetY=i.y,i.x=l.x,i.y=l.y,r=!0):"rect"===i.type&&(l.x===i.x&&l.y===i.y&&l.w===i.w&&l.h===i.h||(i._targetX=i.x,i._targetY=i.y,i._targetW=i.w,i._targetH=i.h,i.x=l.x,i.y=l.y,i.w=null!==(o=l.w)&&void 0!==o?o:i.w,i.h=null!==(s=l.h)&&void 0!==s?s:i.h,r=!0)))}r&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:i})}advanceTransition(e){var t,n,o;if(!this.activeTransition)return!1;const s=Math.min((e-this.activeTransition.startTime)/this.activeTransition.duration,1),i="linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?s:1-Math.pow(1-s,3);for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;const t=this.prevPositionMap.get("p:0");if(!t)continue;e.x=t.x+(e._targetX-t.x)*i,e.y=t.y+(e._targetY-t.y)*i}else if("rect"===e.type){if(void 0===e._targetX)continue;const t=`r:${e.group||""}:${null!==(o=null===(n=e.datum)||void 0===n?void 0:n.category)&&void 0!==o?o:0}`,s=this.prevPositionMap.get(t);if(!s)continue;e.x=s.x+(e._targetX-s.x)*i,e.y=s.y+(e._targetY-s.y)*i,void 0!==s.w&&(e.w=s.w+(e._targetW-s.w)*i,e.h=s.h+(e._targetH-s.h)*i)}if(s>=1){for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}return this.activeTransition=null,!1}return!0}getData(){return this.buffer.toArray()}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}updateConfig(e){e.colorScheme!==this.config.colorScheme&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),Object.assign(this.config,e)}}function v(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{datum:e.datum,x:e.x+e.w/2,y:e.y,distance:0,category:e.group}}function b(e,t,n){const o=t-e.x,s=n-e.y,i=Math.sqrt(o*o+s*s);return i>Math.max(e.r,5)?null:{datum:e.datum,x:e.x,y:e.y,distance:i}}function x(e,t,n){const o=t-e.cx,s=n-e.cy,i=Math.sqrt(o*o+s*s);if(e.innerRadius>i||i>e.outerRadius)return null;let r=Math.atan2(s,o);0>r&&(r+=2*Math.PI);let a=e.startAngle%(2*Math.PI),l=e.endAngle%(2*Math.PI);if(0>a&&(a+=2*Math.PI),0>l&&(l+=2*Math.PI),!(a>l?r>=a||l>=r:r>=a&&l>=r))return null;const c=(e.startAngle+e.endAngle)/2,u=(e.innerRadius+e.outerRadius)/2;return{datum:e.datum,x:e.cx+Math.cos(c)*u,y:e.cy+Math.sin(c)*u,distance:0,category:e.category}}function w(e,t,n){const o=e.columnWidth/2,s=e.stats?Object.assign(Object.assign({},e.stats),{n:Array.isArray(e.datum)?e.datum.length:0,mean:(e.stats.q1+e.stats.median+e.stats.q3)/3}):void 0;if("vertical"===e.projection){if(!(e.x-o>t||t>e.x+o||Math.min(e.minPos,e.maxPos)>n||n>Math.max(e.minPos,e.maxPos)))return{datum:e.datum,x:e.x,y:e.medianPos,distance:0,category:e.category,stats:s}}else{const i=e.y-o,r=e.y+o;if(!(Math.min(e.minPos,e.maxPos)>t||t>Math.max(e.minPos,e.maxPos)||i>n||n>r))return{datum:e.datum,x:e.medianPos,y:e.y,distance:0,category:e.category,stats:s}}return null}function k(e,t,n){if(!e.bounds)return null;const{x:o,y:s,width:i,height:r}=e.bounds;return o>t||t>o+i||s>n||n>s+r?null:{datum:e.datum,x:o+i/2,y:s+r/2,distance:0,category:e.category,stats:e.stats}}const A={fill:e=>r.createElement("rect",{style:e,width:20,height:20}),line:e=>r.createElement("line",{style:e,x1:0,y1:0,x2:20,y2:20})};function E(e,t,n,o){let s;return s="function"==typeof n?n(e):(0,A[n])(o(e,t)),s}function M(e){const{legendGroups:t,customClickBehavior:n,title:o="Legend",width:s=100,height:i=20,orientation:a="vertical"}=e,l="vertical"===a?(({legendGroups:e,width:t,customClickBehavior:n})=>{let o=30;const s=[];return e.forEach((e,i)=>{o+=5,s.push(r.createElement("line",{key:"legend-top-line legend-symbol-"+i,stroke:"gray",x1:0,y1:o,x2:t,y2:o})),o+=10,e.label&&(o+=20,s.push(r.createElement("text",{key:"legend-text-"+i,y:o,className:"legend-group-label"},e.label)),o+=10),s.push(r.createElement("g",{key:"legend-group-"+i,className:"legend-item",transform:`translate(0,${o})`},((e,t)=>{const{type:n="fill",styleFn:o,items:s}=e,i=[];let a=0;return s.forEach((e,s)=>{const l=E(e,s,n,o);i.push(r.createElement("g",{key:"legend-item-"+s,transform:`translate(0,${a})`,onClick:t?()=>t(e):void 0,style:{cursor:t?"pointer":"default"}},l,r.createElement("text",{y:15,x:30},e.label))),a+=25}),i})(e,n))),o+=25*e.items.length+10}),s})({legendGroups:t,width:s,customClickBehavior:n}):(({legendGroups:e,title:t,height:n,customClickBehavior:o})=>{let s=0;const i=[],a=!1===t?10:40;return e.forEach((t,l)=>{t.label&&(i.push(r.createElement("text",{key:"legend-text-"+l,transform:`translate(${s},${a}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},t.label)),s+=20);const c=((e,t)=>{const{type:n="fill",styleFn:o,items:s}=e,i=[];let a=0;return s.forEach((e,s)=>{const l=E(e,s,n,o);i.push(r.createElement("g",{key:"legend-item-"+s,transform:`translate(${a},0)`,onClick:t?()=>t(e):void 0,style:{cursor:t?"pointer":"default"}},l,r.createElement("text",{y:15,x:25},e.label))),a+=35,a+=8*e.label.length}),{items:i,offset:a}})(t,o);i.push(r.createElement("g",{key:"legend-group-"+l,className:"legend-item",transform:`translate(${s},${a})`},c.items)),s+=c.offset+5,e[l+1]&&i.push(r.createElement("line",{key:"legend-top-line legend-symbol-"+l,stroke:"gray",x1:s,y1:a-10,x2:s,y2:n+a+10})),s+=15}),r.createElement("g",null,!1!==t&&r.createElement("line",{x1:0,x2:s+10,y1:a-10,y2:a-10,stroke:"gray",className:"title-neatline"}),i)})({legendGroups:t,title:o,height:i,customClickBehavior:n});return r.createElement("g",null,void 0!==o&&r.createElement("text",{className:"legend-title",y:20,x:"horizontal"===a?0:s/2,textAnchor:"horizontal"===a?"start":"middle"},o),l)}function S(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),s=e.split(/\s+/),i=[];let r="";for(const e of s)r&&r.length+1+e.length>o?(i.push(r),r=e):r=r?`${r} ${e}`:e;return r&&i.push(r),i}function O(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 j(e){const{x:t=0,y:n=0,dx:o,dy:s,nx:i,ny:a,note:l,connector:c,subject:u,type:h,color:d,className:m,disable:g,events:f={},"data-testid":p}=e,y=new Set(Array.isArray(g)?g:[]);let v=o||0,b=s||0;null!=i&&(v=i-t),null!=a&&(b=a-n);const x="string"==typeof h?h:"label";if("bracket"===x&&u&&0===v&&0===b)if(void 0!==u.width){v=u.width/2;const e=u.depth||30;b=e+(0>e?-5:5)}else if(void 0!==u.height){const e=u.depth||30;v=e+(0>e?-5:5),b=u.height/2}return r.createElement("g",Object.assign({className:("annotation "+(m||"")).trim(),transform:`translate(${t},${n})`,"data-testid":p},f),!y.has("connector")&&function(e,t,n,o,s,i){const a=[];let l=0,c=0;if("callout-circle"!==s&&"label"!==s||!(null==i?void 0:i.radius)){if("callout-rect"===s&&i){const n=i.width||0,o=i.height||0;if(n>0||o>0){const s=n/2,i=o/2,r=e-s,a=t-i;if(0!==r||0!==a){const e=Math.abs(r),t=Math.abs(a),u=n/2,h=o/2,d=e*h>t*u?u/e:h/t;l=s+r*d,c=i+a*d}}}else if("bracket"===s&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(l=e/2,c=n):void 0!==t&&(l=n,c=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const o=Math.atan2(t,e);l=Math.cos(o)*n,c=Math.sin(o)*n}}if(Math.sqrt(Math.pow(e-l,2)+Math.pow(t-c,2))>.5&&(a.push(r.createElement("line",{key:"connector-line",x1:l,y1:c,x2:e,y2:t,stroke:o||"currentColor"})),"arrow"===(null==n?void 0:n.end))){const n=10,s=16/180*Math.PI,i=Math.atan2(t-c,e-l);a.push(r.createElement("path",{key:"connector-arrow",d:`M${l},${c}L${l+n*Math.cos(i+s)},${c+n*Math.sin(i+s)}L${l+n*Math.cos(i-s)},${c+n*Math.sin(i-s)}Z`,fill:o||"currentColor",stroke:"none"}))}return r.createElement("g",{className:"annotation-connector"},a)}(v,b,c,d,x,u),!y.has("subject")&&function(e,t,n,o,s){var i;const a=[];switch(e){case"callout-circle":{const e=((null==t?void 0:t.radius)||0)+((null==t?void 0:t.radiusPadding)||0);e>0&&a.push(r.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:n||"currentColor"}));break}case"callout-rect":{const e=(null==t?void 0:t.width)||0,o=(null==t?void 0:t.height)||0;(e>0||o>0)&&a.push(r.createElement("rect",{key:"subject-rect",width:e,height:o,fill:"none",stroke:n||"currentColor"}));break}case"callout-custom":(null==t?void 0:t.custom)&&a.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=o||0,i=s||0;if(void 0!==(null==t?void 0:t.x)){const o=(t.x||0)-e;a.push(r.createElement("line",{key:"threshold-line",x1:o,y1:(t.y1||0)-i,x2:o,y2:(t.y2||0)-i,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==t?void 0:t.y)){const o=(t.y||0)-i;a.push(r.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:o,x2:(t.x2||0)-e,y2:o,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==t?void 0:t.x1)||void 0!==(null==t?void 0:t.x2)?a.push(r.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"currentColor",strokeDasharray:"5,5"})):void 0===(null==t?void 0:t.y1)&&void 0===(null==t?void 0:t.y2)||a.push(r.createElement("line",{key:"threshold-line",x1:0,y1:(t.y1||0)-i,x2:0,y2:(t.y2||0)-i,stroke:n||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(i=null==t?void 0:t.width)&&void 0!==i?i:null==t?void 0:t.height;void 0!==e&&a.push(r.createElement("path",{key:"bracket-path",d:O((null==t?void 0:t.type)||"curly",e,(null==t?void 0:t.depth)||30,void 0===(null==t?void 0:t.width)),fill:"none",stroke:n||"currentColor"}));break}}return r.createElement("g",{className:"annotation-subject"},a)}(x,u,d,t,n),!y.has("note")&&function(e,t,n,o){if(!e)return r.createElement("g",{className:"annotation-note"});const{label:s,title:i,orientation:a,align:l,wrap:c=120,noWrap:u}=e;if(!s&&!i)return r.createElement("g",{className:"annotation-note"});let h=a;h||(h=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=l;d&&"dynamic"!==d||(d="topBottom"===h?0>t?"right":"left":0>n?"bottom":"top");let m="start";"topBottom"===h?"right"===d?m="end":"middle"===d&&(m="middle"):m=0>t?"end":"start";const g=16,f=i?u?[i]:S(i,c):[],p=s?u?[s]:S(s,c):[],y="leftRight"===h?"end"===m?-4:4:0;let v=0;const b=[];f.length>0&&(b.push(r.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:o||void 0,textAnchor:m,fontWeight:"bold"},f.map((e,t)=>r.createElement("tspan",{key:t,x:y,dy:0===t?0:g},e)))),v=f.length*g),p.length>0&&b.push(r.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:o||void 0,textAnchor:m,y:v},p.map((e,t)=>r.createElement("tspan",{key:t,x:y,dy:0===t?0:g},e))));let x=null;if((i||s)&&(0!==t||0!==n))if("topBottom"===h){const e=Math.min(c,120);let t=0,n=e;"end"===m?(t=-e,n=0):"middle"===m&&(t=-e/2,n=e/2),x=r.createElement("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"currentColor"})}else{const e=(f.length+p.length)*g+(p.length>0?g:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),x=r.createElement("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:o||"currentColor"})}const w=Math.max(0,f.length+p.length-1)*g;let k=0;return"topBottom"===h?k=0>n?-(w+2):18:"leftRight"===h&&(k="middle"===d?-(w+g+(p.length>0&&f.length>0?2:0))/2+8:"bottom"===d||0>n?-(w+2):18),r.createElement("g",{className:"annotation-note",transform:`translate(${t},${n})`},r.createElement("g",{className:"annotation-note-content",transform:0!==k?`translate(0,${k})`:void 0},b),x)}(l,v,b,d))}function L(e){var t,n;const{noteData:o}=e,{screenCoordinates:s}=o,i="string"==typeof o.type?o.type:"label",a=o.eventListeners||o.events||{};if(o.coordinates&&s){const e=o.nx||s[0][0]+(null!==(t=o.dx)&&void 0!==t?t:0),a=o.ny||s[0][1]+(null!==(n=o.dy)&&void 0!==n?n:0),l=s.map((t,n)=>{const s=Object.assign({},o,{note:0===n?o.note:{label:""},x:t[0],y:t[1],nx:e,ny:a});return r.createElement(j,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},s,{type:i}))});return r.createElement("g",null,l)}const l=o.note||{title:"none",label:o.label};return r.createElement(j,Object.assign({"data-testid":"semiotic-annotation",key:`${l.label}-${l.title}-${o.i}`,events:a},o,{type:i}))}function P(e,t){var n,o,s;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(s=t.scales)||void 0===s?void 0:s.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function C(e,t){var n,o,s;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(s=t.scales)||void 0===s?void 0:s.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function H(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function N(e){return Math.round(100*e)/100+""}function B(t){const{width:n,height:s,totalWidth:i,totalHeight:a,margin:l,scales:c,showAxes:u,oLabel:h,rLabel:d,oFormat:m,rFormat:g,showGrid:f,title:p,legend:y,foregroundGraphics:v,annotations:b,svgAnnotationRules:x,annotationFrame:w,xAccessor:k,yAccessor:A,annotationData:E,children:S}=t,O="radial"===(null==c?void 0:c.projection),j="horizontal"===(null==c?void 0:c.projection),B=e.useMemo(()=>u&&c&&!O?c.o.domain().map(e=>{var t;return{value:e,pixel:(null!==(t=c.o(e))&&void 0!==t?t:0)+c.o.bandwidth()/2,label:m?m(e):e}}):[],[u,c,m,O]),_=e.useMemo(()=>u&&c&&!O?c.r.ticks(5).map(e=>({value:e,pixel:c.r(e),label:(g||N)(e)})):[],[u,c,g,O]),$=e.useMemo(()=>{if(!b||0===b.length)return null;const e=function(e,t,n){var s,i,a,l,c,u,h,d,m,g,f,p,y,v,b,x,w,k,A,E,M,S,O,j,N,B,_,$,D,R,z,W,T,I,q,G,F,V,X;switch(e.type){case"label":{let o=null,s=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);if(!t)return null;o=t.x,s=t.y}else o=P(e,n),s=C(e,n);return null==o||null==s?null:H(o,s,n)?r.createElement(L,{key:"ann-"+t,noteData:{x:o,y:s,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"label",connector:e.connector||{end:"arrow"},color:e.color}}):null}case"callout":{let o=null,s=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);if(!t)return null;o=t.x,s=t.y}else o=P(e,n),s=C(e,n);return null==o||null==s?null:H(o,s,n)?r.createElement(L,{key:"ann-"+t,noteData:{x:o,y:s,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"callout-circle",subject:{radius:e.radius||12},connector:e.connector||{end:"arrow"},color:e.color}}):null}case"x-threshold":{const o=P(e,n);if(null==o)return null;const s=e.color||"#f97316";return r.createElement("g",{key:"ann-"+t},r.createElement("line",{x1:o,y1:0,x2:o,y2:n.height||0,stroke:s,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&r.createElement("text",{x:o+4,y:12,fill:s,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const o=C(e,n);if(null==o)return null;const s=e.color||"#f97316";return r.createElement("g",{key:"ann-"+t},r.createElement("line",{x1:0,y1:o,x2:n.width||0,y2:o,stroke:s,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&r.createElement("text",{x:(n.width||0)-4,y:o-4,textAnchor:"end",fill:s,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const s=(e.coordinates||[]).map(e=>({x:P(Object.assign(Object.assign({},e),{type:"point"}),n),y:C(Object.assign(Object.assign({},e),{type:"point"}),n),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>s.length)return null;const i=o.packEnclose(s),a=e.padding||10;return r.createElement("g",{key:"ann-"+t},r.createElement("circle",{cx:i.x,cy:i.y,r:i.r+a,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&r.createElement("text",{x:i.x,y:i.y-i.r-a-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"rect-enclose":{const o=(e.coordinates||[]).map(e=>({x:P(Object.assign(Object.assign({},e),{type:"point"}),n),y:C(Object.assign(Object.assign({},e),{type:"point"}),n)})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const s=e.padding||10,i=o.map(e=>e.x),a=o.map(e=>e.y),l=Math.min(...i)-s,c=Math.max(...i)+s,u=Math.min(...a)-s,h=Math.max(...a)+s;return r.createElement("g",{key:"ann-"+t},r.createElement("rect",{x:l,y:u,width:c-l,height:h-u,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&r.createElement("text",{x:(l+c)/2,y:u-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"highlight":{const o=n.data||[],s="function"==typeof e.filter?o.filter(e.filter):e.field&&null!=e.value?o.filter(t=>t[e.field]===e.value):[],i=e.style||{stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return r.createElement("g",{key:"ann-"+t},s.map((t,o)=>{const s=P(t,n),a=C(t,n);return null==s||null==a?null:r.createElement("circle",Object.assign({key:o,cx:s,cy:a,r:e.r||6},i))}))}case"bracket":{const o=P(e,n),s=C(e,n);return r.createElement(L,{key:"ann-"+t,noteData:{x:null!=o?o:0,y:null!=s?s:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}})}case"trend":{const o=n.data||[];if(2>o.length)return null;const d=n.xAccessor||"x",m=n.yAccessor||"y",g=o.map(e=>[e[d],e[m]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>g.length)return null;const f=null!==(i=null===(s=n.scales)||void 0===s?void 0:s.x)&&void 0!==i?i:null===(a=n.scales)||void 0===a?void 0:a.time,p=null!==(c=null===(l=n.scales)||void 0===l?void 0:l.y)&&void 0!==c?c:null===(u=n.scales)||void 0===u?void 0:u.value;if(!f||!p)return null;const y=e.method||"linear";let v;if("loess"===y)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]),s=o.map(e=>e[0]),i=o.map(e=>e[1]),r=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=s[e],o=s.map(e=>Math.abs(e-t)),l=o.slice().sort((e,t)=>e-t)[Math.min(r-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:o[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,h=0,d=0,m=0,g=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,h+=t*s[e],d+=t*i[e],m+=t*s[e]*s[e],g+=t*s[e]*i[e])}if(0===u){a.push([t,i[e]]);continue}const f=u*m-h*h;if(1e-12>Math.abs(f))a.push([t,d/u]);else{const e=(u*g-h*d)/f;a.push([t,(d-e*h)/u+e*t])}}return a}(g,null!==(h=e.bandwidth)&&void 0!==h?h:.3);else{let t;try{const n=require("regression");t="polynomial"===y?n.polynomial(g,{order:e.order||2}):n.linear(g)}catch(e){return null}v=t.points}const b=v.map(([e,t])=>`${f(e)},${p(t)}`).join(" "),x=e.color||"#6366f1";return r.createElement("g",{key:"ann-"+t},r.createElement("polyline",{points:b,fill:"none",stroke:x,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&r.createElement("text",{x:f(v[v.length-1][0])+4,y:p(v[v.length-1][1])-4,fill:x,fontSize:11},e.label))}case"band":{const o=null!==(m=null===(d=n.scales)||void 0===d?void 0:d.y)&&void 0!==m?m:null===(g=n.scales)||void 0===g?void 0:g.value,s=null!==(f=null==o?void 0:o(e.y0))&&void 0!==f?f:0,i=null!==(p=null==o?void 0:o(e.y1))&&void 0!==p?p:n.height||0;return r.createElement("g",{key:"ann-"+t},r.createElement("rect",{x:0,y:Math.min(s,i),width:n.width||0,height:Math.abs(i-s),fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity||.1}),e.label&&r.createElement("text",{x:(n.width||0)-4,y:Math.min(s,i)-4,textAnchor:"end",fill:e.color||"#6366f1",fontSize:11},e.label))}case"envelope":{const o=n.data||[];if(2>o.length)return null;const s=n.xAccessor||"x",i=null!==(v=null===(y=n.scales)||void 0===y?void 0:y.x)&&void 0!==v?v:null===(b=n.scales)||void 0===b?void 0:b.time,a=null!==(w=null===(x=n.scales)||void 0===x?void 0:x.y)&&void 0!==w?w:null===(k=n.scales)||void 0===k?void 0:k.value;if(!i||!a)return null;const l=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",u=e.filter,h=o.filter(e=>null!=e[l]&&null!=e[c]&&!(u&&!u(e))).sort((e,t)=>e[s]-t[s]);if(2>h.length)return null;const d=h.map(e=>`${i(e[s])},${a(e[l])}`).join(" L"),m=h.slice().reverse().map(e=>`${i(e[s])},${a(e[c])}`).join(" L"),g=e.fill||"#6366f1";return r.createElement("g",{key:"ann-"+t},r.createElement("path",{d:`M${d} L${m} Z`,fill:g,fillOpacity:null!==(A=e.fillOpacity)&&void 0!==A?A:.15,stroke:"none"}),e.label&&h.length>0&&r.createElement("text",{x:i(h[h.length-1][s])+4,y:a(h[h.length-1][l])-4,fill:g,fontSize:11},e.label))}case"anomaly-band":{const o=n.data||[];if(2>o.length)return null;const s=n.yAccessor||"y",i=null!==(M=null===(E=n.scales)||void 0===E?void 0:E.x)&&void 0!==M?M:null===(S=n.scales)||void 0===S?void 0:S.time,a=null!==(j=null===(O=n.scales)||void 0===O?void 0:O.y)&&void 0!==j?j:null===(N=n.scales)||void 0===N?void 0:N.value;if(!i||!a)return null;const l=o.map(e=>e[s]).filter(e=>null!=e&&isFinite(e));if(2>l.length)return null;const c=l.reduce((e,t)=>e+t,0)/l.length,u=l.reduce((e,t)=>e+Math.pow(t-c,2),0)/l.length,h=Math.sqrt(u),d=null!==(B=e.threshold)&&void 0!==B?B:2,m=c-d*h,g=!1!==e.showBand,f=e.fill||"#6366f1",p=null!==(_=e.fillOpacity)&&void 0!==_?_:.1,y=e.anomalyColor||"#ef4444",v=null!==($=e.anomalyRadius)&&void 0!==$?$:6,b=a(c+d*h),x=a(m),w=o.filter(e=>{const t=e[s];return null!=t&&Math.abs(t-c)>d*h});return r.createElement("g",{key:"ann-"+t},g&&r.createElement("rect",{x:0,y:Math.min(b,x),width:n.width||0,height:Math.abs(x-b),fill:f,fillOpacity:p}),w.map((e,t)=>{const o=P(e,n),s=C(e,n);return null==o||null==s?null:r.createElement("circle",{key:t,cx:o,cy:s,r:v,fill:y,fillOpacity:.7,stroke:y,strokeWidth:1.5})}),e.label&&r.createElement("text",{x:(n.width||0)-4,y:Math.min(b,x)-4,textAnchor:"end",fill:f,fontSize:11},e.label))}case"forecast":{const o=n.data||[];if(3>o.length)return null;const s=n.xAccessor||"x",i=n.yAccessor||"y",a=null!==(R=null===(D=n.scales)||void 0===D?void 0:D.x)&&void 0!==R?R:null===(z=n.scales)||void 0===z?void 0:z.time,l=null!==(T=null===(W=n.scales)||void 0===W?void 0:W.y)&&void 0!==T?T:null===(I=n.scales)||void 0===I?void 0:I.value;if(!a||!l)return null;const c=o.map(e=>[e[s],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let u;if("polynomial"===(e.method||"linear"))try{const t=require("regression").polynomial(c,{order:e.order||2}).equation;u=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}catch(e){return null}else{const e=c.length;let t=0,n=0,o=0,s=0;for(const[e,i]of c)t+=e,n+=i,o+=e*e,s+=e*i;const i=e*o-t*t;if(1e-12>Math.abs(i))return null;const r=(e*s-t*n)/i,a=(n-r*t)/e;u=e=>a+r*e}const h=c.length,d=c.map(([e,t])=>t-u(e)).reduce((e,t)=>e+t*t,0),m=Math.sqrt(d/Math.max(h-2,1)),g=c.reduce((e,t)=>e+t[0],0)/h,f=c.reduce((e,t)=>e+Math.pow(t[0]-g,2),0),p=null!==(q=e.confidence)&&void 0!==q?q:.95,y=.99>p?.95>p?.9>p?1:1.645:1.96:2.576,v=null!==(G=e.steps)&&void 0!==G?G:5,b=c[h-1][0],x=(b-c[0][0])/Math.max(h-1,1),w=[];for(let e=1;v>=e;e++)w.push(b+e*x);const k=[];for(const e of w){const t=u(e),n=m*Math.sqrt(1+1/h+(f>0?Math.pow(e-g,2)/f:0))*y;k.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const A=`M${k.map(e=>`${a(e.x)},${l(e.yUpper)}`).join(" L")} L${k.slice().reverse().map(e=>`${a(e.x)},${l(e.yLower)}`).join(" L")} Z`,E=k.map(e=>`${a(e.x)},${l(e.yCenter)}`).join(" "),M=`${a(b)},${l(u(b))}`,S=e.strokeColor||"#6366f1";return r.createElement("g",{key:"ann-"+t},r.createElement("path",{d:A,fill:e.fill||"#6366f1",fillOpacity:null!==(F=e.fillOpacity)&&void 0!==F?F:.15,stroke:"none"}),r.createElement("polyline",{points:`${M} ${E}`,fill:"none",stroke:S,strokeWidth:null!==(V=e.strokeWidth)&&void 0!==V?V:2,strokeDasharray:null!==(X=e.strokeDasharray)&&void 0!==X?X:"6,3"}),e.label&&k.length>0&&r.createElement("text",{x:a(k[k.length-1].x)+4,y:l(k[k.length-1].yCenter)-4,fill:S,fontSize:11},e.label))}default:return null}},t={scales:c?{x:c.r,y:c.r,time:c.r,value:c.r}:null,timeAxis:"x",xAccessor:k,yAccessor:A,width:n,height:s,data:E,frameType:"ordinal"};return b.map((n,o)=>{if(x){const s=x(n,o,t);return null!=s?s:e(n,o,t)}return e(n,o,t)}).filter(Boolean)},[b,x,n,s,w,k,A,E]);return u||p||y||v||$&&$.length>0||f||S?r.createElement("svg",{width:i,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},r.createElement("g",{transform:`translate(${l.left},${l.top})`},f&&c&&!O&&r.createElement("g",{className:"ordinal-grid"},_.map((e,t)=>r.createElement("line",{key:"grid-"+t,x1:j?e.pixel:0,y1:j?0:e.pixel,x2:j?e.pixel:n,y2:j?s:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),u&&c&&!O&&r.createElement("g",{className:"ordinal-axes"},j?r.createElement(r.Fragment,null,r.createElement("line",{x1:0,y1:0,x2:0,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),B.map((e,t)=>r.createElement("g",{key:"cat-"+t,transform:`translate(0,${e.pixel})`},r.createElement("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),r.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),h&&r.createElement("text",{x:15-l.left,y:s/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-l.left}, ${s/2})`,style:{userSelect:"none"}},h),r.createElement("line",{x1:0,y1:s,x2:n,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),_.map((e,t)=>r.createElement("g",{key:"val-"+t,transform:`translate(${e.pixel},${s})`},r.createElement("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),r.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),d&&r.createElement("text",{x:n/2,y:s+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},d)):r.createElement(r.Fragment,null,r.createElement("line",{x1:0,y1:s,x2:n,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),B.map((e,t)=>r.createElement("g",{key:"cat-"+t,transform:`translate(${e.pixel},${s})`},r.createElement("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),r.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),h&&r.createElement("text",{x:n/2,y:s+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},h),r.createElement("line",{x1:0,y1:0,x2:0,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),_.map((e,t)=>r.createElement("g",{key:"val-"+t,transform:`translate(0,${e.pixel})`},r.createElement("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),r.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),d&&r.createElement("text",{x:15-l.left,y:s/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-l.left}, ${s/2})`,style:{userSelect:"none"}},d))),$,v,S),p&&r.createElement("text",{x:i/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof p?p:null),y&&r.createElement("g",{transform:`translate(${i-l.right+10}, ${l.top})`},"object"==typeof(D=y)&&null!==D&&!r.isValidElement(D)&&"legendGroups"in D?r.createElement(M,{legendGroups:y.legendGroups,title:"",width:100}):y)):null;var D}const _=(e,t,n,o)=>{const s=t.filter(e=>"rect"===e.type);for(const t of s)null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon?$(e,t):(e.fillStyle=t.style.fill||"#007bff",e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.globalAlpha=1};function $(e,t){const n=t.style.icon,o=t.style.iconPadding||2,s=Math.min(t.w,t.w)-o;if(0>=s)return;const i=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),i){const i=s+o,r=t.x+(t.w-s)/2;for(let o=t.y+t.h-s;o>=t.y-s;o-=i)e.drawImage(n,r,o,s,s)}else{const i=s+o,r=t.y+(t.h-s)/2;for(let o=t.x;t.x+t.w>o;o+=i)e.drawImage(n,o,r,s,s)}e.restore()}const D=(e,t,n,o)=>{var s,i;const r=t.filter(e=>"point"===e.type);for(const t of r){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(s=t.style.opacity)&&void 0!==s?s:t.style.fillOpacity;if(null!=n&&(e.globalAlpha=n),e.fillStyle=t.style.fill||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0){const n=null!==(i=t._pulseGlowRadius)&&void 0!==i?i:4,o=t.r+n*t._pulseIntensity;e.beginPath(),e.arc(t.x,t.y,o,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=.6*t._pulseIntensity,e.stroke()}e.globalAlpha=1}},R=(e,t,n,o)=>{const s=t.filter(e=>"wedge"===e.type);for(const t of s)e.beginPath(),t.innerRadius>0?(e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerRadius,t.endAngle,t.startAngle,!0)):(e.moveTo(t.cx,t.cy),e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle)),e.closePath(),null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),null!=t.style.fillOpacity&&(e.globalAlpha=t.style.fillOpacity),e.fillStyle=t.style.fill||"#007bff",e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),e.globalAlpha=1},z=(e,t,n,o)=>{var s,i;const r=t.filter(e=>"violin"===e.type);for(const t of r){e.save(),(t.translateX||t.translateY)&&e.translate(t.translateX,t.translateY);const n=new Path2D(t.pathString);if(e.globalAlpha=null!==(i=null!==(s=t.style.fillOpacity)&&void 0!==s?s:t.style.opacity)&&void 0!==i?i:.6,e.fillStyle=t.style.fill||"#007bff",e.fill(n),e.globalAlpha=1,t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke(n)),t.iqrLine){e.strokeStyle="#333",e.lineWidth=2,e.globalAlpha=.8;const n=t.iqrLine.centerPos,o=!1!==t.iqrLine.isVertical;e.beginPath(),o?(e.moveTo(n,t.iqrLine.q1Pos),e.lineTo(n,t.iqrLine.q3Pos)):(e.moveTo(t.iqrLine.q1Pos,n),e.lineTo(t.iqrLine.q3Pos,n)),e.stroke(),e.beginPath(),o?e.arc(n,t.iqrLine.medianPos,3,0,2*Math.PI):e.arc(t.iqrLine.medianPos,n,3,0,2*Math.PI),e.fillStyle="#fff",e.fill(),e.strokeStyle="#333",e.lineWidth=1,e.stroke(),e.globalAlpha=1}e.restore()}},W=(e,t,n,o)=>{var s,i,r;const a=t.filter(e=>"connector"===e.type);if(0===a.length)return;const l=new Map;for(const e of a){const t=e.group||"_default";l.has(t)||l.set(t,[]),l.get(t).push(e)}for(const[,t]of l){if(0===t.length)continue;const n=t[0].style;if(n.fill&&"none"!==n.fill){e.beginPath(),e.moveTo(t[0].x1,t[0].y1);for(const n of t)e.lineTo(n.x2,n.y2);e.closePath(),e.globalAlpha=null!==(i=null!==(s=n.fillOpacity)&&void 0!==s?s:n.opacity)&&void 0!==i?i:.3,e.fillStyle=n.fill,e.fill(),e.globalAlpha=1}for(const n of t)e.beginPath(),e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.strokeStyle=n.style.stroke||n.style.fill||"#999",e.lineWidth=n.style.strokeWidth||1,e.globalAlpha=null!==(r=n.style.opacity)&&void 0!==r?r:.5,e.stroke(),e.globalAlpha=1}},T=e=>[W,...e],I={bar:T([_]),clusterbar:T([_]),point:T([D]),swarm:T([D]),pie:[R],donut:[R],boxplot:T([(e,t,n,o)=>{var s,i;const r=t.filter(e=>"boxplot"===e.type);for(const t of r){const n=t.columnWidth/2,o="vertical"===t.projection,r=t.style.fill||"#007bff",a=t.style.stroke||"#333",l=t.style.strokeWidth||1,c=null!==(i=null!==(s=t.style.fillOpacity)&&void 0!==s?s:t.style.opacity)&&void 0!==i?i:.6;if(e.save(),e.strokeStyle=a,e.lineWidth=l,e.beginPath(),o?(e.moveTo(t.x,t.minPos),e.lineTo(t.x,t.maxPos)):(e.moveTo(t.minPos,t.y),e.lineTo(t.maxPos,t.y)),e.stroke(),e.beginPath(),o?(e.moveTo(t.x-.4*n,t.minPos),e.lineTo(t.x+.4*n,t.minPos),e.moveTo(t.x-.4*n,t.maxPos),e.lineTo(t.x+.4*n,t.maxPos)):(e.moveTo(t.minPos,t.y-.4*n),e.lineTo(t.minPos,t.y+.4*n),e.moveTo(t.maxPos,t.y-.4*n),e.lineTo(t.maxPos,t.y+.4*n)),e.stroke(),e.globalAlpha=c,e.fillStyle=r,o){const o=Math.min(t.q1Pos,t.q3Pos),s=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(t.x-n,o,t.columnWidth,s),e.globalAlpha=1,e.strokeRect(t.x-n,o,t.columnWidth,s)}else{const o=Math.min(t.q1Pos,t.q3Pos),s=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(o,t.y-n,s,t.columnWidth),e.globalAlpha=1,e.strokeRect(o,t.y-n,s,t.columnWidth)}e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),o?(e.moveTo(t.x-n,t.medianPos),e.lineTo(t.x+n,t.medianPos)):(e.moveTo(t.medianPos,t.y-n),e.lineTo(t.medianPos,t.y+n)),e.stroke(),e.restore()}},D]),violin:T([z]),histogram:T([_]),ridgeline:T([z]),timeline:T([_])},q={top:50,right:40,bottom:60,left:70},G={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:"4px",fontSize:"13px",lineHeight:"1.4",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function F({hover:e}){var t,n,o,s;const i=e.data||{},a=e.stats,l=e.category;if(Array.isArray(i)){const e=l||(null===(t=i[0])||void 0===t?void 0:t.category)||"";if(a)return r.createElement("div",{className:"semiotic-tooltip",style:G},e&&r.createElement("div",{style:{fontWeight:"bold"}},e+""),r.createElement("div",null,"n = ",a.n),r.createElement("div",null,"Min: ",a.min.toLocaleString()),r.createElement("div",null,"Q1: ",a.q1.toLocaleString()),r.createElement("div",null,"Median: ",a.median.toLocaleString()),r.createElement("div",null,"Q3: ",a.q3.toLocaleString()),r.createElement("div",null,"Max: ",a.max.toLocaleString()),r.createElement("div",{style:{opacity:.8}},"Mean: ",a.mean.toLocaleString(void 0,{maximumFractionDigits:2})));const n=i.length;return r.createElement("div",{className:"semiotic-tooltip",style:G},e&&r.createElement("div",{style:{fontWeight:"bold"}},e+""),r.createElement("div",null,n," items"))}if(null!=i.bin&&null!=i.count){const e=i.range||[];return r.createElement("div",{className:"semiotic-tooltip",style:G},i.category&&r.createElement("div",{style:{fontWeight:"bold"}},i.category+""),r.createElement("div",null,"Count: ",i.count),2===e.length&&r.createElement("div",{style:{opacity:.8}},Number(e[0]).toFixed(1)," – ",Number(e[1]).toFixed(1)))}const c=i.category||i.name||i.group||i.__rName||"",u=null!==(s=null!==(o=null!==(n=i.value)&&void 0!==n?n:i.__rValue)&&void 0!==o?o:i.pct)&&void 0!==s?s:"";if(!c&&""===u){const e=Object.entries(i).filter(([e])=>!e.startsWith("_")&&"data"!==e);return r.createElement("div",{className:"semiotic-tooltip",style:G},e.map(([e,t])=>r.createElement("div",{key:e},r.createElement("span",{style:{opacity:.7}},e,":")," ","number"==typeof t?t.toLocaleString():t+"")))}return r.createElement("div",{className:"semiotic-tooltip",style:G},c&&r.createElement("div",{style:{fontWeight:"bold"}},c+""),""!==u&&r.createElement("div",null,"number"==typeof u?u.toLocaleString():u+""))}const V=e.forwardRef(function(t,n){var o;const{chartType:s,runtimeMode:i,data:a,oAccessor:c="category",rAccessor:u="value",colorAccessor:h,stackBy:d,groupBy:m,multiAxis:g,timeAccessor:f,valueAccessor:p,categoryAccessor:A,projection:E="vertical",size:M=[600,400],responsiveWidth:S,responsiveHeight:O,margin:j,barPadding:L,innerRadius:P,normalize:C,startAngle:H,dynamicColumnWidth:N,bins:_,showOutliers:$,showIQR:D,amplitude:R,connectorAccessor:z,connectorStyle:W,rExtent:T,oExtent:G,extentPadding:V=.05,oSort:X,windowMode:Y="sliding",windowSize:Q=200,pieceStyle:Z,summaryStyle:U,colorScheme:J,barColors:K,showAxes:ee=!0,oLabel:te,rLabel:ne,oFormat:oe,rFormat:se,enableHover:ie=!0,hoverAnnotation:re,tooltipContent:ae,customHoverBehavior:le,annotations:ce,svgAnnotationRules:ue,showGrid:he=!1,legend:de,backgroundGraphics:me,foregroundGraphics:ge,title:fe,className:pe,background:ye,centerContent:ve,decay:be,pulse:xe,transition:we,staleness:ke}=t,[Ae,Ee]=function(t,n,o){const s=e.useRef(null),[i,r]=e.useState(null);return e.useEffect(()=>{if(!n&&!o)return;const e=s.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;r(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[n,o]),[s,[n&&i?i.w:t[0],o&&i?i.h:t[1]]]}(M,S,O),Me=e.useMemo(()=>Object.assign(Object.assign({},q),j),[j]),Se=Ee[0]-Me.left-Me.right,Oe=Ee[1]-Me.top-Me.bottom,je=e.useRef(null),Le=e.useRef(!0),Pe=e.useRef(0),Ce=e.useRef(null),He=e.useRef(()=>{}),[Ne,Be]=e.useState(null),[_e,$e]=e.useState(null),[De,Re]=e.useState(0),[ze,We]=e.useState(!1),Te=ie||re,Ie="streaming"===i,qe=e.useMemo(()=>({chartType:s,runtimeMode:Ie?"streaming":"bounded",windowSize:Q,windowMode:Y,extentPadding:V,projection:E,oAccessor:Ie?void 0:c,rAccessor:Ie?void 0:u,colorAccessor:h,stackBy:d,groupBy:m,multiAxis:g,timeAccessor:Ie?f:void 0,valueAccessor:Ie?p||("string"==typeof u||"function"==typeof u?u:void 0):void 0,categoryAccessor:Ie?A||c:void 0,rExtent:T,oExtent:G,barPadding:L,innerRadius:P,normalize:C,startAngle:H,dynamicColumnWidth:N,bins:_,showOutliers:$,showIQR:D,amplitude:R,connectorAccessor:z,connectorStyle:W,oSort:X,pieceStyle:Z,summaryStyle:U,colorScheme:J,barColors:K,decay:be,pulse:xe,transition:we,staleness:ke}),[s,Q,Y,V,E,c,u,h,d,m,g,f,p,A,T,G,L,P,C,H,N,_,$,D,R,z,W,X,Z,U,J,K,be,xe,we,ke,Ie]),Ge=e.useRef(null);Ge.current||(Ge.current=new y(qe));const Fe=e.useCallback(()=>{Pe.current||(Pe.current=requestAnimationFrame(()=>He.current()))},[]);e.useEffect(()=>{var e;null===(e=Ge.current)||void 0===e||e.updateConfig(qe),Le.current=!0,Fe()},[qe,Fe]);const Ve=e.useRef(null);Ve.current||(Ve.current=new l(e=>{const t=Ge.current;t&&t.ingest(e)&&(Le.current=!0,Fe())}));const Xe=e.useCallback(e=>{var t;null===(t=Ve.current)||void 0===t||t.push(e)},[]),Ye=e.useCallback(e=>{var t;null===(t=Ve.current)||void 0===t||t.pushMany(e)},[]),Qe=e.useCallback(()=>{var e,t;null===(e=Ve.current)||void 0===e||e.clear(),null===(t=Ge.current)||void 0===t||t.clear(),Le.current=!0,Fe()},[Fe]);e.useImperativeHandle(n,()=>({push:Xe,pushMany:Ye,clear:Qe,getData:()=>{var e,t;return null!==(t=null===(e=Ge.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=Ge.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null}}),[Xe,Ye,Qe]),e.useEffect(()=>{var e;a&&(null===(e=Ve.current)||void 0===e||e.setBoundedData(a))},[a]);const Ze=e.useRef(()=>{}),Ue=e.useRef(()=>{});Ze.current=e=>{if(!Te)return;const t=je.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Me.left,s=e.clientY-n.top-Me.top;if(0>o||o>Se||0>s||s>Oe)return void(Ce.current&&(Ce.current=null,Be(null),le&&le(null),Fe()));const i=Ge.current;if(!i||0===i.scene.length)return;const r="radial"===E,a=function(e,t,n,o=30){let s=null;for(const i of e){let e=null;switch(i.type){case"rect":e=v(i,t,n);break;case"point":e=b(i,t,n);break;case"wedge":e=x(i,t,n);break;case"boxplot":e=w(i,t,n);break;case"violin":e=k(i,t,n)}e&&o>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}(i.scene,r?o-Se/2:o,r?s-Oe/2:s);if(!a)return void(Ce.current&&(Ce.current=null,Be(null),le&&le(null),Fe()));const l=Object.assign(Object.assign({data:a.datum,time:a.x,value:a.y,x:a.x,y:a.y},a.stats&&{stats:a.stats}),a.category&&{category:a.category});Ce.current=l,Be(l),le&&(le(l),Le.current=!0),Fe()},Ue.current=()=>{Ce.current&&(Ce.current=null,Be(null),le&&(le(null),Le.current=!0),Fe())},e.useCallback(e=>Ze.current(e),[]);const Je=e.useCallback(()=>Ue.current(),[]),Ke=e.useRef(-1),et=e.useCallback(e=>{const t=Ge.current;if(!t||0===t.scene.length)return;const n=function(e){const t=[];for(const n of e)if("rect"===n.type&&null!=n.x)t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum});else if("point"===n.type)t.push({x:n.x,y:n.y,datum:n.datum});else if("wedge"===n.type&&null!=n.cx){const e=((n.startAngle||0)+(n.endAngle||0))/2,o=((n.innerRadius||0)+(n.outerRadius||50))/2;t.push({x:n.cx+Math.cos(e)*o,y:n.cy+Math.sin(e)*o,datum:n.datum})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.scene);if(0===n.length)return;const o=Ke.current,s=function(e,t,n){switch(e){case"ArrowRight":case"ArrowDown":return n-1>t?t+1:t;case"ArrowLeft":case"ArrowUp":return t>0?t-1:t;case"Home":return 0;case"End":return n-1;case"Escape":return-1;default:return null}}(e.key,0>o?-1:o,n.length);if(null===s)return;if(e.preventDefault(),0>s)return Ke.current=-1,Ce.current=null,Be(null),le&&le(null),void Fe();const i=0>o?0:s;Ke.current=i;const r={data:(a=n[i]).datum,x:a.x,y:a.y,time:a.x,value:a.y};var a;Ce.current=r,Be(r),le&&le(r),Fe()},[le,Fe]),tt=e.useCallback(e=>{Ke.current=-1,Ze.current(e)},[]);He.current=()=>{var e,t;Pe.current=0;const n=je.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const i=Ge.current;if(!i)return;const r="undefined"!=typeof performance?performance.now():Date.now(),a=i.advanceTransition(r),l=Le.current;l&&!a&&(i.computeScene({width:Se,height:Oe}),Le.current=!1);const c="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=Ee[0]*c,n.height=Ee[1]*c,n.style.width=Ee[0]+"px",n.style.height=Ee[1]+"px",o.scale(c,c),o.clearRect(0,0,Ee[0],Ee[1]);const u=null!==(e=null==ke?void 0:ke.threshold)&&void 0!==e?e:5e3,h=ke&&i.lastIngestTime>0&&r-i.lastIngestTime>u;h&&(o.globalAlpha=null!==(t=null==ke?void 0:ke.dimOpacity)&&void 0!==t?t:.5);const d=n?getComputedStyle(n).getPropertyValue("--semiotic-bg").trim():"",m=ye||(d&&"transparent"!==d?d:null);m&&(o.fillStyle=m,o.fillRect(0,0,Ee[0],Ee[1]));const g="radial"===E;g?(o.save(),o.translate(Me.left+Se/2,Me.top+Oe/2)):o.translate(Me.left,Me.top);const f=I[s]||[],p={width:Se,height:Oe};for(const e of f)e(o,i.scene,i.scales,p);g&&o.restore(),h&&(o.globalAlpha=1),l&&i.scales&&($e(i.scales),Re(e=>e+1)),(null==ke?void 0:ke.showBadge)&&We(!!h),(a||i.hasActivePulses)&&(Pe.current=requestAnimationFrame(()=>He.current()))},e.useEffect(()=>(Fe(),()=>{Pe.current&&(cancelAnimationFrame(Pe.current),Pe.current=0)}),[Fe]),e.useEffect(()=>{Le.current=!0,Fe()},[s,Se,Oe,ee,ye,Fe]),e.useEffect(()=>{if(!ke)return;const e=setInterval(()=>{var e;const t=Ge.current;if(!t||0===t.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=ke.threshold)&&void 0!==e?e:5e3,s=n-t.lastIngestTime>o;s!==ze&&(We(s),Le.current=!0,Fe())},1e3);return()=>clearInterval(e)},[ke,ze,Fe]);const nt=Te&&Ne?ae?ae(Ne):r.createElement(F,{hover:Ne}):null,ot="radial"===E,st=Ne?ot?Ne.x+Se/2:Ne.x:0,it=Ne?ot?Ne.y+Oe/2:Ne.y:0,rt=nt?r.createElement("div",{className:"stream-ordinal-tooltip",style:{position:"absolute",left:Me.left+st,top:Me.top+it,transform:`translate(${st>.7*Se?"calc(-100% - 12px)":"12px"}, ${.3*Oe>it?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},nt):null;return r.createElement("div",{ref:Ae,className:"stream-ordinal-frame"+(pe?" "+pe:""),role:"img","aria-label":"string"==typeof fe?fe:"Ordinal chart",tabIndex:0,style:{position:"relative",width:S?"100%":Ee[0],height:O?"100%":Ee[1]},onMouseMove:Te?tt:void 0,onMouseLeave:Te?Je:void 0,onKeyDown:et},me&&r.createElement("svg",{style:{position:"absolute",top:0,left:0,width:Ee[0],height:Ee[1],pointerEvents:"none"}},r.createElement("g",{transform:`translate(${Me.left},${Me.top})`},me)),r.createElement("canvas",{ref:je,style:{position:"absolute",top:0,left:0,width:Ee[0],height:Ee[1]}}),r.createElement(B,{width:Se,height:Oe,totalWidth:Ee[0],totalHeight:Ee[1],margin:Me,scales:_e,showAxes:ee,oLabel:te,rLabel:ne,oFormat:oe,rFormat:se,showGrid:he,title:fe,legend:de,foregroundGraphics:ge,annotations:ce,svgAnnotationRules:ue,annotationFrame:De,xAccessor:"string"==typeof c?c:void 0,yAccessor:"string"==typeof u?u:void 0,annotationData:null===(o=Ge.current)||void 0===o?void 0:o.getData()}),ve&&"radial"===E&&r.createElement("div",{style:{position:"absolute",left:Me.left+Se/2,top:Me.top+Oe/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"}},ve),(null==ke?void 0:ke.showBadge)&&r.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ke.badgePosition?{top:4,left:4}:"bottom-left"===ke.badgePosition?{bottom:4,left:4}:"bottom-right"===ke.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:ze?"#dc3545":"#28a745",color:"white"})},ze?"STALE":"LIVE"),rt)});V.displayName="StreamOrdinalFrame";const X={category10:s.schemeCategory10,tableau10:s.schemeTableau10,set3:s.schemeSet3,blues:s.interpolateBlues,reds:s.interpolateReds,greens:s.interpolateGreens,oranges:s.interpolateOranges,purples:s.interpolatePurples,viridis:s.interpolateViridis,plasma:s.interpolatePlasma},Y=s.schemeCategory10;function Q(e,t,n){if("function"==typeof t)return t(e);const o=e[t];return n?n(o):Y[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+""))%Y.length]}function Z(e,n,o="category10"){const s=Array.from(new Set(e.map(e=>e[n]))),i=s.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(o))return t.scaleOrdinal().domain(s).range(o).unknown("#999");const r=X[o]||X.category10;if(i&&"function"==typeof r)return e=>r(Number(e)/Math.max(...s.map(Number)));{const e=Array.isArray(r)?r:Y;return t.scaleOrdinal().domain(s).range(e).unknown("#999")}}const U=e.createContext(null);function J(e,t,n){return t?o=>{var s;const i=Object.assign({},e(o));if(t.isActive)if(t.predicate(o))(null==n?void 0:n.selectedStyle)&&Object.assign(i,n.selectedStyle);else{const e=null!==(s=null==n?void 0:n.unselectedOpacity)&&void 0!==s?s:.2;i.opacity=e,i.fillOpacity=e,i.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(i,n.unselectedStyle)}return i}:e}function K(t){const n=e.createContext(null),o=ee(t);return[function({children:o}){const s=e.useMemo(()=>ee(t),[]);return r.createElement(n.Provider,{value:s,children:o})},t=>{var s;const i=null!==(s=e.useContext(n))&&void 0!==s?s:o;return function(t,n){const[o,s]=e.useState(n);return e.useLayoutEffect(()=>t(()=>s(n)),[t]),o}(i.subscribe,()=>t(i.getState()))}]}function ee(e){const t=new EventTarget;let n=e(function(e){n=Object.assign(Object.assign({},n),e(n)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}function te(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,s]=o.range;t.push(t=>{const o=t[n];return o>=e&&s>=o})}return e=>t.every(t=>t(e))}function ne(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[oe,se]=K(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),s=ne(o,t),i=new Map(s.clauses);return i.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},s),{clauses:i})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const s=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),s.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:s}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),s=ne(o,t);return o.set(t,Object.assign(Object.assign({},s),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}}));function ie(t){const n=e.useId(),o=t.clientId||n,{name:s}=t,i=se(e=>e.selections.get(s)),r=se(e=>e.setClause),a=se(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,s]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(te(s));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(i,o):()=>!0,[i,o]),isActive:l,selectPoints:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};r(s,{clientId:o,type:"point",fields:t})},[o,s,r]),selectInterval:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};r(s,{clientId:o,type:"interval",fields:t})},[o,s,r]),clear:e.useCallback(()=>{a(s,o)},[a,s,o]),clientId:o}}const[re,ae]=K(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}))}})),le="#007bff";function ce(t,n,o="category10"){const s=e.useContext(U);return e.useMemo(()=>{if(n&&"function"!=typeof n)return s&&Object.keys(s).length>0?e=>s[e]||Z(t,n,o)(e):Z(t,n,o)},[t,n,o,s])}function ue(t,n,o){return e.useMemo(()=>{if(!n)return t;const e=[...t];if("function"==typeof n)return e.sort(n);const s="function"==typeof(i=o)?i:e=>e[i];var i;return e.sort("asc"===n?(e,t)=>s(e)-s(t):(e,t)=>s(t)-s(e))},[t,n,o])}function he({selection:t,linkedHover:n,fallbackFields:o=[],unwrapData:s=!1,onObservation:i,chartType:r,chartId:a}){const l=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields}:null}(n,o),c=ie({name:(null==t?void 0:t.name)||"__unused__"}),u=function(t){const n=t.name||"hover",{fields:o}=t,{predicate:s,isActive:i,selectPoints:r,clear:a}=ie({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&&r(t)},[o,r,a,n]),predicate:s,isActive:i}}({name:(null==l?void 0:l.name)||"hover",fields:(null==l?void 0:l.fields)||o||[]}),h=ae(e=>e.pushObservation),d=t?{isActive:c.isActive,predicate:c.predicate}:null,m=e.useCallback(e=>{var t,o;if(n)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]),u.onHover(t)}else u.onHover(null);if(i||h){const n={timestamp:Date.now(),chartType:r||"unknown",chartId:a};if(e){let s=e.data||e.datum||e;Array.isArray(s)&&(s=s[0]);const r=Object.assign(Object.assign({},n),{type:"hover",datum:s||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(r),h&&h(r)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(e),h&&h(e)}}},[n,u,i,r,a,h]),g=e.useCallback(e=>{var t,n;if(i||h){const o={timestamp:Date.now(),chartType:r||"unknown",chartId:a};if(e){let s=e.data||e.datum||e;Array.isArray(s)&&(s=s[0]);const r=Object.assign(Object.assign({},o),{type:"click",datum:s||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});i&&i(r),h&&h(r)}else{const e=Object.assign(Object.assign({},o),{type:"click-end"});i&&i(e),h&&h(e)}}},[i,h,r,a]);return{activeSelectionHook:d,customHoverBehavior:m,customClickBehavior:g}}function de({data:t,colorBy:n,colorScale:o,showLegend:s,userMargin:i,defaults:r={top:50,bottom:60,left:70,right:40}}){const a=void 0!==s?s:!!n,l=e.useMemo(()=>{if(a&&n)return function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:s,strokeWidth:i}){return{legendGroups:[{styleFn:e=>{const t={fill:e.color,stroke:e.color};return void 0!==s&&(t.stroke=s),void 0!==i&&(t.strokeWidth=i),t},type:"fill",items:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(s=>{const i=e.find("function"==typeof t?e=>t(e)===s:e=>e[t]===s),r=i?o(i,t,n):n?n(s):"#000000";return{label:s+"",color:r}}),label:""}]}}({data:t,colorBy:n,colorScale:o,getColor:Q})},[a,n,t,o]),c=e.useMemo(()=>{const e=Object.assign(Object.assign({},r),i);return l&&120>e.right&&(e.right=120),e},[r,i,l]);return{legend:l,margin:c}}const me={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 ge(e,t,n){var o,s,i,r,a,l;const c=me[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:c.width,height:null!==(s=t.height)&&void 0!==s?s:c.height,showAxes:c.showAxes,showGrid:null!==(i=t.showGrid)&&void 0!==i?i:c.showGrid,enableHover:null!==(r=t.enableHover)&&void 0!==r?r:!!t.linkedHover||c.enableHover,showLegend:null!==(a=t.showLegend)&&void 0!==a?a:c.showLegend,showLabels:null!==(l=t.showLabels)&&void 0!==l?l:c.showLabels,title:u?void 0:t.title,xLabel:u?void 0:t.xLabel,yLabel:u?void 0:t.yLabel,categoryLabel:u?void 0:t.categoryLabel,valueLabel:u?void 0:t.valueLabel,marginDefaults:c.marginDefaults}}const fe={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"8px 12px",borderRadius:"4px",fontSize:"14px",lineHeight:"1.5",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function pe(e,t){return"function"==typeof t?t(e):e[t]}function ye(e,t){return t?t(e):null==e?"":"number"==typeof e?e.toLocaleString():e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function ve(e){return!0===e||("function"==typeof e?e:!1!==e&&void 0!==e&&("object"!=typeof e||null===e||!("fields"in e)&&!("title"in e)||function(e={}){const{fields:t,title:n,format:o,style:s={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let a;const l=[];if(n){const t=pe(e,n);a=ye(t,o)}if(t&&t.length>0)t.forEach(t=>{let n,s,i;"string"==typeof t?(n=t,s=t,i=o):(n=t.label,s=t.accessor||t.key||"",i=t.format||o);const r=pe(e,s);l.push({label:n,value:ye(r,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){a=ye(e[n],o);break}if(!a){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(a=ye(e[t[0]],o))}}const c=Object.assign(Object.assign({},fe),s);return r.createElement("div",{className:("semiotic-tooltip "+i).trim(),style:c},a&&r.createElement("div",{style:{fontWeight:l.length>0?"bold":"normal"}},a),l.map((e,t)=>r.createElement("div",{key:t,style:{marginTop:0===t&&a?"4px":0}},e.label&&r.createElement("span",null,e.label,": "),e.value)))}}(e)))}function be(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function xe(e,t){return"function"==typeof t?t(e):e[t]}function we({categoryAccessor:e,valueAccessor:t,groupAccessor:n,groupLabel:o,pieData:s=!1}){return i=>{var a;const l=s?(null===(a=i.data)||void 0===a?void 0:a[0])||i.data||i:i.data||i,c=xe(l,e),u=xe(l,t),h=n?xe(l,n):void 0;return r.createElement("div",{className:"semiotic-tooltip",style:fe},r.createElement("div",{style:{fontWeight:"bold"}},be(c)),r.createElement("div",{style:{marginTop:4}},be(u)),null!=h&&r.createElement("div",{style:{marginTop:2,opacity:.8}},o||("string"==typeof(d=n)?d:"value"),": ",be(h)));var d}}function ke({componentName:e,message:t,width:n,height:o}){return r.createElement("div",{role:"alert",style:{width:n,height:Math.max(o,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},r.createElement("div",{style:{textAlign:"center",maxWidth:400}},r.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),r.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t)))}class Ae extends r.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:r.createElement(ke,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}var Ee;const Me="undefined"!=typeof process&&"production"!==(null===(Ee=process.env)||void 0===Ee?void 0:Ee.NODE_ENV);function Se({componentName:e,width:t,height:n,children:o}){return r.createElement(Ae,{fallback:o=>r.createElement(ke,{componentName:e,message:o.message,width:t,height:n})},o)}function Oe(e,t,n,o){if(!Me)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const s=t[0];if(!s||"object"!=typeof s)return;if(o in s)return;const i=Object.keys(s).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${i}`)}function je(e,t){if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||t[0]}function Le({componentName:e,data:t,accessors:n,requiredProps:o}){if(o)for(const[t,n]of Object.entries(o))if(null==n)return`${e}: ${t} is required. Provide a field name or function.`;if(!t||!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(n){const o=function(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[s,i]of Object.entries(n))if(i&&"string"==typeof i&&!(i in o)){const n=je(i,t),o=n?` Try ${s}="${n}".`:"";return`${e}: ${s} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}function Pe(t){const n=ge(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:s,className:i,categoryAccessor:a="category",valueAccessor:l="value",orientation:c="vertical",valueFormat:u,colorBy:h,colorScheme:d="category10",sort:m=!1,barPadding:g=5,tooltip:f,annotations:p,frameProps:y={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,k=n.width,A=n.height,E=n.enableHover,M=n.showGrid,S=n.showLegend,O=n.title,j=n.categoryLabel,L=n.valueLabel,P=o||[];Oe("BarChart",P,"categoryAccessor",a),Oe("BarChart",P,"valueAccessor",l);const{activeSelectionHook:C,customHoverBehavior:H}=he({selection:v,linkedHover:b,fallbackFields:h?["string"==typeof h?h:""]:[],unwrapData:!0,onObservation:x,chartType:"BarChart",chartId:w}),N=ue(P,m,l),B=ce(P,h,d),_=e.useMemo(()=>e=>{const t={};return t.fill=h?Q(e,h,B):le,t},[h,B]),$=e.useMemo(()=>J(_,C,v),[_,C,v]),{legend:D,margin:R}=de({data:N,colorBy:h,colorScale:B,showLegend:S,userMargin:s,defaults:n.marginDefaults}),z=e.useMemo(()=>we({categoryAccessor:a,valueAccessor:l,groupAccessor:h&&h!==a?h:void 0,groupLabel:"string"==typeof h?h:"group"}),[a,l,h]),W=Le({componentName:"BarChart",data:P,accessors:{categoryAccessor:a,valueAccessor:l}});if(W)return r.createElement(ke,{componentName:"BarChart",message:W,width:k,height:A});const T=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar",data:N,oAccessor:a,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",pieceStyle:$,size:[k,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R,barPadding:g,enableHover:E,showAxes:n.showAxes,oLabel:j,rLabel:L,rFormat:u,showGrid:M,oSort:m},D&&{legend:D}),O&&{title:O}),i&&{className:i}),{tooltipContent:f?ve(f):z}),(b||x)&&{customHoverBehavior:H}),p&&p.length>0&&{annotations:p}),y);return r.createElement(Se,{componentName:"BarChart",width:k,height:A},r.createElement(V,Object.assign({},T)))}function Ce(t){const n=ge(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:s,className:i,categoryAccessor:a="category",stackBy:l,valueAccessor:c="value",orientation:u="vertical",valueFormat:h,colorBy:d,colorScheme:m="category10",normalize:g=!1,barPadding:f=5,tooltip:p,annotations:y,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:k}=t,A=n.width,E=n.height,M=n.enableHover,S=n.showGrid,O=n.showLegend,j=n.title,L=n.categoryLabel,P=n.valueLabel,C=o||[],H=d||l,{activeSelectionHook:N,customHoverBehavior:B}=he({selection:b,linkedHover:x,fallbackFields:H?["string"==typeof H?H:""]:[],unwrapData:!0,onObservation:w,chartType:"StackedBarChart",chartId:k}),_=ce(C,H,m),$=e.useMemo(()=>e=>H?{fill:Q(e,H,_)}:{fill:le},[H,_]),D=e.useMemo(()=>J($,N,b),[$,N,b]),{legend:R,margin:z}=de({data:C,colorBy:H,colorScale:_,showLegend:O,userMargin:s,defaults:n.marginDefaults}),W=e.useMemo(()=>we({categoryAccessor:l,valueAccessor:c,groupAccessor:a}),[l,a,c]),T=Le({componentName:"StackedBarChart",data:C,accessors:{categoryAccessor:a,valueAccessor:c},requiredProps:{stackBy:l}});if(T)return r.createElement(ke,{componentName:"StackedBarChart",message:T,width:A,height:E});const I=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar",data:C,oAccessor:a,rAccessor:c,stackBy:l,normalize:g,projection:"horizontal"===u?"horizontal":"vertical",pieceStyle:D,size:[A,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:z,barPadding:f,enableHover:M,showAxes:n.showAxes,oLabel:L,rLabel:P,rFormat:h,showGrid:S},R&&{legend:R}),j&&{title:j}),i&&{className:i}),{tooltipContent:p?ve(p):W}),(x||w)&&{customHoverBehavior:B}),y&&y.length>0&&{annotations:y}),v);return r.createElement(Se,{componentName:"StackedBarChart",width:A,height:E},r.createElement(V,Object.assign({},I)))}function He(t){const n=ge(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:s,className:i,categoryAccessor:a="category",groupBy:l,valueAccessor:c="value",orientation:u="vertical",valueFormat:h,colorBy:d,colorScheme:m="category10",barPadding:g=5,tooltip:f,annotations:p,frameProps:y={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,k=n.width,A=n.height,E=n.enableHover,M=n.showGrid,S=n.showLegend,O=n.title,j=n.categoryLabel,L=n.valueLabel,P=o||[],C=d||l,{activeSelectionHook:H,customHoverBehavior:N}=he({selection:v,linkedHover:b,fallbackFields:C?["string"==typeof C?C:""]:[],unwrapData:!0,onObservation:x,chartType:"GroupedBarChart",chartId:w}),B=ce(P,C,m),_=e.useMemo(()=>e=>C?{fill:Q(e,C,B)}:{fill:le},[C,B]),$=e.useMemo(()=>J(_,H,v),[_,H,v]),{legend:D,margin:R}=de({data:P,colorBy:C,colorScale:B,showLegend:S,userMargin:s,defaults:n.marginDefaults}),z=e.useMemo(()=>we({categoryAccessor:l,valueAccessor:c,groupAccessor:a}),[l,a,c]),W=Le({componentName:"GroupedBarChart",data:P,accessors:{categoryAccessor:a,valueAccessor:c},requiredProps:{groupBy:l}});if(W)return r.createElement(ke,{componentName:"GroupedBarChart",message:W,width:k,height:A});const T=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"clusterbar",data:P,oAccessor:a,rAccessor:c,groupBy:l,projection:"horizontal"===u?"horizontal":"vertical",pieceStyle:$,size:[k,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R,barPadding:g,enableHover:E,showAxes:n.showAxes,oLabel:j,rLabel:L,rFormat:h,showGrid:M},D&&{legend:D}),O&&{title:O}),i&&{className:i}),{tooltipContent:f?ve(f):z}),(b||x)&&{customHoverBehavior:N}),p&&p.length>0&&{annotations:p}),y);return r.createElement(Se,{componentName:"GroupedBarChart",width:k,height:A},r.createElement(V,Object.assign({},T)))}function Ne(t){const n=ge(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:s,className:i,categoryAccessor:a="category",valueAccessor:l="value",orientation:c="vertical",valueFormat:u,colorBy:h,colorScheme:d="category10",sizeBy:m,sizeRange:g=[3,8],pointRadius:f=4,pointOpacity:p=.7,categoryPadding:y=20,tooltip:v,annotations:b,frameProps:x={},selection:w,linkedHover:k,onObservation:A,chartId:E}=t,M=n.width,S=n.height,O=n.enableHover,j=n.showGrid,L=n.showLegend,P=n.title,C=n.categoryLabel,H=n.valueLabel,N=o||[],{activeSelectionHook:B,customHoverBehavior:_}=he({selection:w,linkedHover:k,fallbackFields:h?["string"==typeof h?h:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:A,chartType:"SwarmPlot",chartId:E}),$=ce(N,h,d),D=e.useMemo(()=>{if(!m)return;const e=N.map(e=>"function"==typeof m?m(e):e[m]);return[Math.min(...e),Math.max(...e)]},[N,m]),R=e.useMemo(()=>e=>{const t={fillOpacity:p};return t.fill=h?Q(e,h,$):le,t.r=m?function(e,t,n=[3,20],o){let s;if(s="function"==typeof t?t(e):e[t],!o)return s;const[i,r]=o,[a,l]=n;return r===i?(a+l)/2:a+(s-i)/(r-i)*(l-a)}(e,m,g,D):f,t},[h,$,m,g,D,f,p]),z=e.useMemo(()=>J(R,B,w),[R,B,w]),{legend:W,margin:T}=de({data:N,colorBy:h,colorScale:$,showLegend:L,userMargin:s,defaults:n.marginDefaults}),I=e.useMemo(()=>we({categoryAccessor:a,valueAccessor:l,groupAccessor:h||void 0}),[a,l,h]),q=Le({componentName:"SwarmPlot",data:N,accessors:{categoryAccessor:a,valueAccessor:l}});if(q)return r.createElement(ke,{componentName:"SwarmPlot",message:q,width:M,height:S});const G=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"swarm",data:N,oAccessor:a,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",pieceStyle:z,size:[M,S],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:T,barPadding:y,enableHover:O,showAxes:n.showAxes,oLabel:C,rLabel:H,rFormat:u,showGrid:j},W&&{legend:W}),P&&{title:P}),i&&{className:i}),{tooltipContent:v?ve(v):I}),(k||A)&&{customHoverBehavior:_}),b&&b.length>0&&{annotations:b}),x);return r.createElement(Se,{componentName:"SwarmPlot",width:M,height:S},r.createElement(V,Object.assign({},G)))}function Be(t){const n=ge(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:s,className:i,categoryAccessor:a="category",valueAccessor:l="value",orientation:c="vertical",valueFormat:u,colorBy:h,colorScheme:d="category10",showOutliers:m=!0,categoryPadding:g=20,tooltip:f,annotations:p,frameProps:y={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,k=n.width,A=n.height,E=n.enableHover,M=n.showGrid,S=n.showLegend,O=n.title,j=n.categoryLabel,L=n.valueLabel,P=o||[],{activeSelectionHook:C,customHoverBehavior:H}=he({selection:v,linkedHover:b,fallbackFields:h?["string"==typeof h?h:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:x,chartType:"BoxPlot",chartId:w}),N=ce(P,h,d),B=e.useMemo(()=>e=>{const t=h?Q(e,h,N):le;return{fill:t,stroke:t,fillOpacity:.8}},[h,N]),_=e.useMemo(()=>J(B,C,v),[B,C,v]),{legend:$,margin:D}=de({data:P,colorBy:h,colorScale:N,showLegend:S,userMargin:s,defaults:n.marginDefaults}),R=e.useMemo(()=>e=>{const t=e.stats||(e.data||e).stats||{};return r.createElement("div",{className:"semiotic-tooltip",style:fe},r.createElement("div",{style:{fontWeight:"bold",marginBottom:"4px"}},(e.category||(e.data||e).category||"")+""),null!=t.median&&r.createElement(r.Fragment,null,null!=t.n&&r.createElement("div",null,"n = ",t.n),r.createElement("div",null,"Median: ",t.median.toLocaleString()),r.createElement("div",null,"Q1: ",t.q1.toLocaleString()),r.createElement("div",null,"Q3: ",t.q3.toLocaleString()),r.createElement("div",null,"Min: ",t.min.toLocaleString()),r.createElement("div",null,"Max: ",t.max.toLocaleString())))},[]),z=Le({componentName:"BoxPlot",data:P,accessors:{categoryAccessor:a,valueAccessor:l}});if(z)return r.createElement(ke,{componentName:"BoxPlot",message:z,width:k,height:A});const W=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"boxplot",data:P,oAccessor:a,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",summaryStyle:_,showOutliers:m,size:[k,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:D,barPadding:g,enableHover:E,showAxes:n.showAxes,oLabel:j,rLabel:L,rFormat:u,showGrid:M},$&&{legend:$}),O&&{title:O}),i&&{className:i}),{tooltipContent:f?ve(f):R}),(b||x)&&{customHoverBehavior:H}),p&&p.length>0&&{annotations:p}),y);return r.createElement(Se,{componentName:"BoxPlot",width:k,height:A},r.createElement(V,Object.assign({},W)))}function _e(t){const n=ge(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:s,className:i,categoryAccessor:a="category",valueAccessor:l="value",bins:c=25,relative:u=!1,valueFormat:h,colorBy:d,colorScheme:m="category10",categoryPadding:g=20,tooltip:f,annotations:p,frameProps:y={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,k=n.width,A=n.height,E=n.enableHover,M=n.showGrid,S=n.showLegend,O=n.title,j=n.categoryLabel,L=n.valueLabel,P=o||[],{activeSelectionHook:C,customHoverBehavior:H}=he({selection:v,linkedHover:b,fallbackFields:d?["string"==typeof d?d:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:x,chartType:"Histogram",chartId:w}),N=ce(P,d,m),B=e.useMemo(()=>e=>{const t=d?Q(e,d,N):le;return{fill:t,stroke:t,fillOpacity:.8}},[d,N]),_=e.useMemo(()=>J(B,C,v),[B,C,v]),{legend:$,margin:D}=de({data:P,colorBy:d,colorScale:N,showLegend:S,userMargin:s,defaults:n.marginDefaults}),R=e.useMemo(()=>e=>{const t=e.data||e,n=t.category||e.category||"",o=t.count,s=t.range;return r.createElement("div",{className:"semiotic-tooltip",style:fe},n&&r.createElement("div",{style:{fontWeight:"bold"}},n+""),null!=o&&r.createElement("div",null,"Count: ",o),s&&2===s.length&&r.createElement("div",{style:{opacity:.8}},Number(s[0]).toFixed(1)," – ",Number(s[1]).toFixed(1)))},[]),z=Le({componentName:"Histogram",data:P,accessors:{categoryAccessor:a,valueAccessor:l}});if(z)return r.createElement(ke,{componentName:"Histogram",message:z,width:k,height:A});const W=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"histogram",data:P,oAccessor:a,rAccessor:l,projection:"horizontal",summaryStyle:_,bins:c,normalize:u,size:[k,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:D,barPadding:g,enableHover:E,showAxes:n.showAxes,oLabel:j,rLabel:L,rFormat:h,showGrid:M},$&&{legend:$}),O&&{title:O}),i&&{className:i}),{tooltipContent:f?ve(f):R}),(b||x)&&{customHoverBehavior:H}),p&&p.length>0&&{annotations:p}),y);return r.createElement(Se,{componentName:"Histogram",width:k,height:A},r.createElement(V,Object.assign({},W)))}function $e(t){const n=ge(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:s,className:i,categoryAccessor:a="category",valueAccessor:l="value",orientation:c="vertical",bins:u=25,showIQR:h=!0,valueFormat:d,colorBy:m,colorScheme:g="category10",categoryPadding:f=20,tooltip:p,annotations:y,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:k}=t,A=n.width,E=n.height,M=n.enableHover,S=n.showGrid,O=n.showLegend,j=n.title,L=n.categoryLabel,P=n.valueLabel,C=o||[],{activeSelectionHook:H,customHoverBehavior:N}=he({selection:b,linkedHover:x,fallbackFields:m?["string"==typeof m?m:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:w,chartType:"ViolinPlot",chartId:k}),B=ce(C,m,g),_=e.useMemo(()=>e=>{const t=m?Q(e,m,B):le;return{fill:t,stroke:t,fillOpacity:.6}},[m,B]),$=e.useMemo(()=>J(_,H,b),[_,H,b]),{legend:D,margin:R}=de({data:C,colorBy:m,colorScale:B,showLegend:O,userMargin:s,defaults:n.marginDefaults}),z=e.useMemo(()=>e=>{var t;const n=e.category||e.data&&(null===(t=e.data[0])||void 0===t?void 0:t.category)||"",o=e.stats;if(o)return r.createElement("div",{className:"semiotic-tooltip",style:fe},n&&r.createElement("div",{style:{fontWeight:"bold"}},n+""),r.createElement("div",null,"n = ",o.n),r.createElement("div",null,"Min: ",o.min.toLocaleString()),r.createElement("div",null,"Q1: ",o.q1.toLocaleString()),r.createElement("div",null,"Median: ",o.median.toLocaleString()),r.createElement("div",null,"Q3: ",o.q3.toLocaleString()),r.createElement("div",null,"Max: ",o.max.toLocaleString()),r.createElement("div",{style:{opacity:.8}},"Mean: ",o.mean.toLocaleString(void 0,{maximumFractionDigits:2})));const s=(Array.isArray(e.data)?e.data:[]).map(e=>{const t="function"==typeof l?l(e):e[l];return Number(t)}).filter(e=>!isNaN(e)).sort((e,t)=>e-t),i=s.length,a=i>0?s[Math.floor(i/2)]:null;return r.createElement("div",{className:"semiotic-tooltip",style:fe},n&&r.createElement("div",{style:{fontWeight:"bold"}},n+""),i>0&&r.createElement("div",null,"n = ",i),null!=a&&r.createElement("div",null,"Median: ",a.toLocaleString()))},[l]),W=Le({componentName:"ViolinPlot",data:C,accessors:{categoryAccessor:a,valueAccessor:l}});if(W)return r.createElement(ke,{componentName:"ViolinPlot",message:W,width:A,height:E});const T=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"violin",data:C,oAccessor:a,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",summaryStyle:$,bins:u,showIQR:h,size:[A,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R,barPadding:f,enableHover:M,showAxes:n.showAxes,oLabel:L,rLabel:P,rFormat:d,showGrid:S},D&&{legend:D}),j&&{title:j}),i&&{className:i}),{tooltipContent:p?ve(p):z}),(x||w)&&{customHoverBehavior:N}),y&&y.length>0&&{annotations:y}),v);return r.createElement(Se,{componentName:"ViolinPlot",width:A,height:E},r.createElement(V,Object.assign({},T)))}function De(t){var n;const o=ge(t.mode,{width:t.width,height:t.height,showGrid:null===(n=t.showGrid)||void 0===n||n,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:s,margin:i,className:a,categoryAccessor:l="category",valueAccessor:c="value",orientation:u="horizontal",valueFormat:h,colorBy:d,colorScheme:m="category10",sort:g=!0,dotRadius:f=5,categoryPadding:p=10,tooltip:y,annotations:v,frameProps:b={},selection:x,linkedHover:w,onObservation:k,chartId:A}=t,E=o.width,M=o.height,S=o.enableHover,O=o.showGrid,j=o.showLegend,L=o.title,P=o.categoryLabel,C=o.valueLabel,H=s||[],{activeSelectionHook:N,customHoverBehavior:B}=he({selection:x,linkedHover:w,fallbackFields:d?["string"==typeof d?d:""]:["string"==typeof l?l:""],unwrapData:!0,onObservation:k,chartType:"DotPlot",chartId:A}),_=ue(H,g,c),$=ce(H,d,m),D=e.useMemo(()=>e=>{const t={r:f,fillOpacity:.8};return t.fill=d?Q(e,d,$):le,t},[d,$,f]),R=e.useMemo(()=>J(D,N,x),[D,N,x]),{legend:z,margin:W}=de({data:_,colorBy:d,colorScale:$,showLegend:j,userMargin:i,defaults:o.marginDefaults}),T=e.useMemo(()=>we({categoryAccessor:l,valueAccessor:c}),[l,c]),I=Le({componentName:"DotPlot",data:H,accessors:{categoryAccessor:l,valueAccessor:c}});if(I)return r.createElement(ke,{componentName:"DotPlot",message:I,width:E,height:M});const q=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"point",data:_,oAccessor:l,rAccessor:c,projection:"horizontal"===u?"horizontal":"vertical",pieceStyle:R,size:[E,M],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:W,barPadding:p,enableHover:S,showAxes:o.showAxes,oLabel:P,rLabel:C,rFormat:h,showGrid:O,oSort:g},z&&{legend:z}),L&&{title:L}),a&&{className:a}),{tooltipContent:y?ve(y):T}),(w||k)&&{customHoverBehavior:B}),v&&v.length>0&&{annotations:v}),b);return r.createElement(Se,{componentName:"DotPlot",width:E,height:M},r.createElement(V,Object.assign({},q)))}function Re(t){var n,o;const s=ge(t.mode,{width:null!==(n=t.width)&&void 0!==n?n:400,height:null!==(o=t.height)&&void 0!==o?o:400,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title}),{data:i,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",colorBy:h,colorScheme:d="category10",startAngle:m=0,tooltip:g,annotations:f,frameProps:p={},selection:y,linkedHover:v,onObservation:b,chartId:x}=t,w=s.width,k=s.height,A=s.enableHover,E=s.showLegend,M=s.title,S=i||[],O=h||c,{activeSelectionHook:j,customHoverBehavior:L}=he({selection:y,linkedHover:v,fallbackFields:O?["string"==typeof O?O:""]:[],unwrapData:!0,onObservation:b,chartType:"PieChart",chartId:x}),P=ce(S,O,d),C=e.useMemo(()=>e=>O?{fill:Q(e,O,P)}:{fill:le},[O,P]),H=e.useMemo(()=>J(C,j,y),[C,j,y]),{legend:N,margin:B}=de({data:S,colorBy:O,colorScale:P,showLegend:E,userMargin:a,defaults:s.marginDefaults}),_=e.useMemo(()=>we({categoryAccessor:c,valueAccessor:u,groupAccessor:h&&h!==c?h:void 0,groupLabel:"string"==typeof h?h:"group",pieData:!0}),[c,u,h]),$=Le({componentName:"PieChart",data:S,accessors:{categoryAccessor:c,valueAccessor:u}});if($)return r.createElement(ke,{componentName:"PieChart",message:$,width:w,height:k});const D=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"pie",data:S,oAccessor:c,rAccessor:u,projection:"radial",pieceStyle:H,startAngle:m,size:[w,k],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:B,enableHover:A,showAxes:!1},N&&{legend:N}),M&&{title:M}),l&&{className:l}),{tooltipContent:g?ve(g):_}),(v||b)&&{customHoverBehavior:L}),f&&f.length>0&&{annotations:f}),p);return r.createElement(Se,{componentName:"PieChart",width:w,height:k},r.createElement(V,Object.assign({},D)))}function ze(t){var n,o;const s=ge(t.mode,{width:null!==(n=t.width)&&void 0!==n?n:400,height:null!==(o=t.height)&&void 0!==o?o:400,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,linkedHover:t.linkedHover}),{data:i,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",innerRadius:h=60,centerContent:d,colorBy:m,colorScheme:g="category10",startAngle:f=0,tooltip:p,annotations:y,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:k}=t,A=s.width,E=s.height,M=s.enableHover,S=s.showLegend,O=s.title,j=i||[],L=m||c,{activeSelectionHook:P,customHoverBehavior:C}=he({selection:b,linkedHover:x,fallbackFields:L?["string"==typeof L?L:""]:[],unwrapData:!0,onObservation:w,chartType:"DonutChart",chartId:k}),H=ce(j,L,g),N=e.useMemo(()=>e=>L?{fill:Q(e,L,H)}:{fill:le},[L,H]),B=e.useMemo(()=>J(N,P,b),[N,P,b]),{legend:_,margin:$}=de({data:j,colorBy:L,colorScale:H,showLegend:S,userMargin:a,defaults:s.marginDefaults}),D=e.useMemo(()=>we({categoryAccessor:c,valueAccessor:u,groupAccessor:m&&m!==c?m:void 0,groupLabel:"string"==typeof m?m:"group",pieData:!0}),[c,u,m]),R=Le({componentName:"DonutChart",data:j,accessors:{categoryAccessor:c,valueAccessor:u}});if(R)return r.createElement(ke,{componentName:"DonutChart",message:R,width:A,height:E});const z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"donut",data:j,oAccessor:c,rAccessor:u,projection:"radial",pieceStyle:B,innerRadius:h,startAngle:f,centerContent:d,size:[A,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:$,enableHover:M,showAxes:!1},_&&{legend:_}),O&&{title:O}),l&&{className:l}),{tooltipContent:p?ve(p):D}),(x||w)&&{customHoverBehavior:C}),y&&y.length>0&&{annotations:y}),v);return r.createElement(Se,{componentName:"DonutChart",width:A,height:E},r.createElement(V,Object.assign({},z)))}Pe.displayName="BarChart",Ce.displayName="StackedBarChart",He.displayName="GroupedBarChart",Ne.displayName="SwarmPlot",Be.displayName="BoxPlot",_e.displayName="Histogram",$e.displayName="ViolinPlot",De.displayName="DotPlot",Re.displayName="PieChart",ze.displayName="DonutChart",exports.BarChart=Pe,exports.BoxPlot=Be,exports.DonutChart=ze,exports.DotPlot=De,exports.GroupedBarChart=He,exports.Histogram=_e,exports.PieChart=Re,exports.StackedBarChart=Ce,exports.StreamOrdinalFrame=V,exports.SwarmPlot=Ne,exports.ViolinPlot=$e;
|