semiotic 3.2.1 → 3.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CLAUDE.md +47 -5
  2. package/ai/dist/mcp-server.js +31925 -528
  3. package/ai/schema.json +76 -1
  4. package/dist/components/Tooltip/Tooltip.d.ts +6 -1
  5. package/dist/components/charts/index.d.ts +2 -0
  6. package/dist/components/charts/ordinal/BarChart.d.ts +2 -0
  7. package/dist/components/charts/ordinal/GaugeChart.d.ts +55 -0
  8. package/dist/components/charts/ordinal/GroupedBarChart.d.ts +1 -0
  9. package/dist/components/charts/ordinal/StackedBarChart.d.ts +1 -0
  10. package/dist/components/charts/shared/hooks.d.ts +4 -1
  11. package/dist/components/charts/shared/types.d.ts +10 -5
  12. package/dist/components/charts/shared/useChartSetup.d.ts +2 -0
  13. package/dist/components/charts/xy/AreaChart.d.ts +17 -2
  14. package/dist/components/charts/xy/LineChart.d.ts +14 -3
  15. package/dist/components/semiotic-ordinal.d.ts +2 -0
  16. package/dist/components/semiotic-utils.d.ts +2 -1
  17. package/dist/components/semiotic.d.ts +3 -3
  18. package/dist/components/store/LinkedCrosshairStore.d.ts +6 -2
  19. package/dist/components/stream/CanvasHitTester.d.ts +13 -0
  20. package/dist/components/stream/OrdinalSVGOverlay.d.ts +1 -1
  21. package/dist/components/stream/PipelineStore.d.ts +17 -1
  22. package/dist/components/stream/SVGOverlay.d.ts +11 -5
  23. package/dist/components/stream/devDataAccessWarning.d.ts +13 -0
  24. package/dist/components/stream/hitTestUtils.d.ts +15 -0
  25. package/dist/components/stream/ordinalTypes.d.ts +7 -1
  26. package/dist/components/stream/types.d.ts +54 -5
  27. package/dist/components/stream/xySceneBuilders/mixedScene.d.ts +12 -0
  28. package/dist/components/stream/xySceneBuilders/types.d.ts +15 -0
  29. package/dist/geo.min.js +1 -1
  30. package/dist/geo.module.min.js +1 -1
  31. package/dist/network.min.js +1 -1
  32. package/dist/network.module.min.js +1 -1
  33. package/dist/ordinal.min.js +1 -1
  34. package/dist/ordinal.module.min.js +1 -1
  35. package/dist/realtime.min.js +1 -1
  36. package/dist/realtime.module.min.js +1 -1
  37. package/dist/semiotic-ai.min.js +1 -1
  38. package/dist/semiotic-ai.module.min.js +1 -1
  39. package/dist/semiotic-ordinal.d.ts +2 -0
  40. package/dist/semiotic-utils.d.ts +2 -1
  41. package/dist/semiotic-utils.min.js +1 -1
  42. package/dist/semiotic-utils.module.min.js +1 -1
  43. package/dist/semiotic.d.ts +3 -3
  44. package/dist/semiotic.min.js +1 -1
  45. package/dist/semiotic.module.min.js +1 -1
  46. package/dist/server.min.js +1 -1
  47. package/dist/server.module.min.js +1 -1
  48. package/dist/xy.min.js +1 -1
  49. package/dist/xy.module.min.js +1 -1
  50. package/package.json +12 -8
@@ -1 +1 @@
1
- "use strict";const t=require("react"),e=require("d3-selection"),n=require("d3-brush"),r=require("d3-scale"),o=require("d3-quadtree"),i=require("d3-scale-chromatic"),l=require("d3-array"),a=require("d3-hierarchy"),s=require("d3-shape"),c=require("regression"),u=require("d3-interpolate"),h=require("d3-force"),d=require("d3-chord");function f(t){return t&&t.__esModule?t:{default:t}}function y(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const n in t)if("default"!==n){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}return e.default=t,Object.freeze(e)}const g=y(t),p=f(c);function m(t,e){let n=0,r=e.length-1;for(;r>n;){const o=n+r+1>>1;e[o]>t?r=o-1:n=o}return e[n]}function v(t,e){let n=0,r=e.length-1;for(;r>n;){const o=n+r>>1;t>e[o]?n=o+1:r=o}return e[n]}function x({width:r,height:o,totalWidth:i,totalHeight:l,margin:a,dimension:s,scales:c,onBrush:u,binSize:h,snap:d,binBoundaries:f,snapDuring:y,streaming:p}){const x=t.useRef(null),b=t.useRef(null),k=t.useRef(u);k.current=u;const w=t.useRef(c);w.current=c;const E=t.useMemo(()=>f?[...f].sort((t,e)=>t-e):void 0,[f]),A=t.useRef(E);A.current=E;const M=t.useRef(!1),S=t.useRef(null);return t.useEffect(()=>{if(!x.current)return;const t=e.select(x.current).select(".brush-g"),i="x"===s?n.brushX():"y"===s?n.brushY():n.brush();return i.extent([[0,0],[r,o]]),i.on("brush end",e=>{if(M.current)return;const n=w.current;if(!n)return;if(!e.selection)return S.current=null,void k.current(null);let l,a;if("x"===s){const[t,r]=e.selection;l=[n.x.invert(t),n.x.invert(r)],a=[n.y.invert(o),n.y.invert(0)]}else if("y"===s){const[t,o]=e.selection;l=[n.x.invert(0),n.x.invert(r)],a=[n.y.invert(o),n.y.invert(t)]}else{const[[t,r],[o,i]]=e.selection;l=[n.x.invert(t),n.x.invert(o)],a=[n.y.invert(i),n.y.invert(r)]}if("bin"===d&&"y"!==s&&("end"===e.type||"brush"===e.type&&y)){const r=A.current;r&&r.length>0?l=function(t,e){return 0===e.length?t:[m(t[0],e),v(t[1],e)]}(l,r):h&&h>0&&(l=[Math.floor(l[0]/h)*h,Math.ceil(l[1]/h)*h]);const o=n.x(l[0]),a=n.x(l[1]);if(M.current=!0,"x"===s)t.call(i.move,[o,a]);else if("xy"===s){const n=e.selection;t.call(i.move,[[o,n[0][1]],[a,n[1][1]]])}M.current=!1}const c={x:l,y:a};S.current=c,k.current(c)}),t.call(i),b.current=i,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),b.current=null}},[r,o,s,d,h,y]),t.useEffect(()=>{if(!(p&&c&&b.current&&S.current))return;if(!x.current)return;if("y"===s)return;const t=S.current,n=c.x.domain()[0],r=e.select(x.current).select(".brush-g");if(n>=t.x[1])return M.current=!0,r.call(b.current.move,null),M.current=!1,S.current=null,void k.current(null);let o=t.x[0],i=!1;if(n>t.x[0]){if(o=n,"bin"===d){const t=A.current;t&&t.length>0?o=v(n,t):h&&h>0&&(o=Math.ceil(n/h)*h)}if(o>=t.x[1])return M.current=!0,r.call(b.current.move,null),M.current=!1,S.current=null,void k.current(null);i=!0}const l=c.x(o),a=c.x(t.x[1]);if(M.current=!0,"x"===s)r.call(b.current.move,[l,a]);else{const e=c.y(t.y[1]),n=c.y(t.y[0]);r.call(b.current.move,[[l,e],[a,n]])}if(M.current=!1,i){const e={x:[o,t.x[1]],y:t.y};S.current=e,k.current(e)}},[c,p,s,d,h]),g.createElement("svg",{ref:x,width:i,height:l,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},g.createElement("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`}))}class b{constructor(t,e){var n,r;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=t,this.chunkThreshold=null!==(n=null==e?void 0:e.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(r=null==e?void 0:e.chunkSize)&&void 0!==r?r:5e3}updateChunkOptions(t){null!=t.chunkThreshold&&(this.chunkThreshold=t.chunkThreshold),null!=t.chunkSize&&(this.chunkSize=t.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(t){if(this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=t.length)return void this.callback({inserts:t,bounded:!0});this.callback({inserts:t.slice(0,this.chunkSize),bounded:!0,totalSize:t.length});let e=this.chunkSize;const n=()=>{if(e>=t.length)return;if(t!==this.lastBoundedData)return;const r=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,r),bounded:!1}),e=r,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const t=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:t,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(t){this.pushBuffer.push(t),this.scheduleFlush()}pushMany(t){if(0!==t.length){for(let e=0;t.length>e;e++)this.pushBuffer.push(t[e]);this.scheduleFlush()}}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}class k{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const n of t){const t=this.push(n);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+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 t=0;const e=this;return{next:()=>e._size>t?{done:!1,value:e.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t(this.buffer[(e+n)%this._capacity],n)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t[n]=this.buffer[(e+n)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),n=[];for(;e.length>t;)n.push(e.shift());this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(const t of e)this.push(t);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 w{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isNaN(t)||(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const n of t){const t=e?e(n):n;Number.isNaN(t)||(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}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 E(t,e,n,r,o){const i=new Map;for(const l of t){const t=e(l),a=n(l);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const s=Math.floor(t/r)*r;let c=i.get(s);if(c||(c={start:s,end:s+r,total:0,categories:new Map},i.set(s,c)),c.total+=a,o){const t=o(l);c.categories.set(t,(c.categories.get(t)||0)+a)}}return i}function A(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function M(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function S(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function _(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}const P=i.schemeCategory10,C=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function D(t,e,n){var r,o,i;if(1>=n)return 1;const l=null!==(r=t.minOpacity)&&void 0!==r?r:.1,a=n-1-e;switch(t.type){case"linear":return l+(1-a/(n-1))*(1-l);case"exponential":{const e=null!==(o=t.halfLife)&&void 0!==o?o:n/2;return l+Math.pow(.5,a/e)*(1-l)}case"step":return(null!==(i=t.stepThreshold)&&void 0!==i?i:.5*n)>a?1:l;default:return 1}}function L(t,e,n){var r;const o=null!==(r=t.duration)&&void 0!==r?r:500,i=n-e;return o>i?1-i/o:0}function T(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function N(t,e){return Math.min((t-e.startTime)/e.duration,1)}function $(t,e,n){return t+(e-t)*n}function O(t,e,n){var r,o,i,l;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const n=t.getX(e.datum),r=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${n}:${r}`;if(null!=n&&null!=r)return`p:${n}:${r}`}return"p:"+n;case"rect":return`r:${e.group||""}:${null!==(l=null!==(o=null===(r=e.datum)||void 0===r?void 0:r.binStart)&&void 0!==o?o:null===(i=e.datum)||void 0===i?void 0:i.category)&&void 0!==l?l:n}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+n:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function W(t,e,n,r,o,i){const l=[];for(const o of t){const t=n(o),i=r(o);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||l.push({px:e.x(t),py:e.y(i),rawY:i,d:o})}l.sort((t,e)=>t.px-e.px);const a=Array(l.length),s=Array(l.length),c=Array(l.length);for(let t=0;l.length>t;t++){const e=l[t];a[t]=[e.px,e.py],s[t]=e.rawY,c[t]=e.d}return{type:"line",path:a,rawValues:s,style:o,datum:c,group:i}}function I(t,e,n,r,o,i,l,a){const s=[];for(const i of t){const t=n(i),l=r(i);if(null==t||null==l||Number.isNaN(t)||Number.isNaN(l))continue;const c=e.x(t),u=a?a(i):o;s.push({px:c,topY:e.y(l),botY:e.y(u)})}s.sort((t,e)=>t.px-e.px);const c=Array(s.length),u=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];c[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:c,bottomPath:u,style:i,datum:t,group:l}}function z(t,e,n,r,o,i,l){const a=n(t),s=r(t);if(null==a||null==s||Number.isNaN(a)||Number.isNaN(s))return null;const c={type:"point",x:e.x(a),y:e.y(s),r:o,style:i,datum:t};return void 0!==l&&(c.pointId=l),c}function R(t,e,n,r,o,i,l){return{type:"rect",x:t,y:e,w:n,h:r,style:o,datum:i,group:l}}function B(t,e,n,r,o,i,l){const a={type:"heatcell",x:t,y:e,w:n,h:r,fill:o,datum:i};return(null==l?void 0:l.showValues)&&(a.showValues=!0,a.value=l.value,l.valueFormat&&(a.valueFormat=l.valueFormat)),a}function j(t,e,n){if(!t.getBounds||!t.scales)return null;const r=[],o=[];for(const n of e){const e=t.getX(n),i=t.getY(n);if(null==e||null==i||Number.isNaN(e)||Number.isNaN(i))continue;const l=t.getBounds(n),a=t.scales.x(e);if(l&&0!==l)r.push([a,t.scales.y(i+l)]),o.push([a,t.scales.y(i-l)]);else{const e=t.scales.y(i);r.push([a,e]),o.push([a,e])}}return 2>r.length?null:{type:"area",topPath:r,bottomPath:o,style:t.resolveBoundsStyle(n,e[0]),datum:e,group:n,interactive:!1}}function F(t,e,n,r){var o;if(!t.config.pointStyle)return;const i=null!=r?r:t.getY;for(const r of e){const e=t.resolveGroupColor(r.key);for(const l of r.data){let r=t.config.pointStyle(l);!r.fill&&e&&(r=Object.assign(Object.assign({},r),{fill:e}));const a=null!==(o=r.r)&&void 0!==o?o:3,s=t.getPointId?t.getPointId(l)+"":void 0,c=z(l,t.scales,t.getX,i,a,r,s);c&&n.push(c)}}}const Y={blues:i.interpolateBlues,reds:i.interpolateReds,greens:i.interpolateGreens,viridis:i.interpolateViridis};class H{constructor(t){this.xExtent=new w,this.yExtent=new w,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.xIsDate=!1,this._quadtree=null,this.config=t,this.buffer=new k(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=M(t.timeAccessor||t.xAccessor,"time"),this.getY=M(t.valueAccessor||t.yAccessor,"value")):(this.getX=M(t.xAccessor,"x"),this.getY=M(t.yAccessor,"y")),this.getGroup=_(t.groupAccessor),this.getCategory=_(t.categoryAccessor),this.getSize=t.sizeAccessor?M(t.sizeAccessor,"size"):void 0,this.getColor=_(t.colorAccessor),this.getBounds=t.boundsAccessor?M(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?M(t.y0Accessor,"y0"):void 0,this.getPointId=_(t.pointIdAccessor),"candlestick"===t.chartType&&(this.getOpen=M(t.openAccessor,"open"),this.getHigh=M(t.highAccessor,"high"),this.getLow=M(t.lowAccessor,"low"),this.getClose=M(t.closeAccessor,"close")),t.pulse&&(this.timestampBuffer=new k(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.bounded){if(this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.getX=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?M(this.config.timeAccessor||this.config.xAccessor,"time"):M(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],n=this.config.xAccessor,r="function"==typeof n?n(e):e[n||"x"],o=r instanceof Date,i="string"==typeof r&&r.length>=10&&!isNaN(new Date(r).getTime())&&isNaN(Number(r));if(this.xIsDate=o||i,i){const t="string"==typeof n?n:void 0;this.getX=t?e=>+new Date(e[t]):t=>+(n(t)instanceof Date?n(t):new Date(n(t)))}}const n=t.totalSize||t.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of t.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n)))}else for(const n of t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity||1e6;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const t=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n))),null!=t&&(this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):this.yExtent.evict(this.getY(t)))}return!0}computeScene(t){var e,n,o,i,l,a;const{config:s,buffer:c}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);if(this.xExtent.dirty&&this.xExtent.recalculate(c,this.getX),this.yExtent.dirty)if("candlestick"===s.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of c)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(c,this.getY);const u=this.getBufferArray(),h=this.xExtent.extent,d=this.yExtent.extent;let f=s.xExtent?[null!==(e=s.xExtent[0])&&void 0!==e?e:h[0],null!==(n=s.xExtent[1])&&void 0!==n?n:h[1]]:h,y=s.yExtent?[null!==(o=s.yExtent[0])&&void 0!==o?o:d[0],null!==(i=s.yExtent[1])&&void 0!==i?i:d[1]]:d;const g=s.yExtent&&null!=s.yExtent[0]&&null!=s.yExtent[1];if("stackedarea"===s.chartType&&!g&&c.size>0)if(s.normalize)y=[0,1+s.extentPadding];else{const t=`${c.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)y=this._stackExtentCache.yDomain;else{const e=this.groupData(u),n=new Map;for(const t of e)for(const e of t.data){const t=this.getX(e),r=this.getY(e);null==t||null==r||Number.isNaN(t)||Number.isNaN(r)||n.set(t,(n.get(t)||0)+r)}let r=0;for(const t of n.values())t>r&&(r=t);y=[0,r+(r>0?r*s.extentPadding:1)],this._stackExtentCache={key:t,yDomain:y}}}else if("bar"===s.chartType&&s.binSize&&!g&&c.size>0){const[,t]=function(t,e,n,r,o){const i=E(t,e,n,r,o);if(0===i.size)return[0,0];let l=0;for(const t of i.values())t.total>l&&(l=t.total);return[0,l]}(c,this.getX,this.getY,s.binSize,this.getCategory);y=[0,t+t*s.extentPadding]}else if("waterfall"===s.chartType&&!g&&c.size>0){const[t,e]=function(t,e){let n=0,r=0,o=0;for(const i of t){const t=e(i);null==t||Number.isNaN(t)||(o+=t,n>o&&(n=o),o>r&&(r=o))}return[n,r]}(c,this.getY),n=e-t,r=n>0?n*s.extentPadding:1;y=[Math.min(0,t-Math.abs(r)),Math.max(0,e+Math.abs(r))]}else if(!g&&y[0]!==1/0){if(this.getBounds)for(const t of u){const e=this.getY(t),n=this.getBounds(t);null!=e&&!Number.isNaN(e)&&n&&(e+n>y[1]&&(y[1]=e+n),y[0]>e-n&&(y[0]=e-n))}const t=y[1]-y[0],e=t>0?t*s.extentPadding:1,n=null===(l=s.yExtent)||void 0===l?void 0:l[0],r=null===(a=s.yExtent)||void 0===a?void 0:a[1];y=[null!=n?y[0]:y[0]-e,null!=r?y[1]:y[1]+e],"log"===s.yScaleType&&0>=y[0]&&d[0]>0&&(y[0]=null!=n?y[0]:d[0]/(1+s.extentPadding))}if(f[0]!==1/0&&f[1]!==-1/0||(f=[0,1]),y[0]!==1/0&&y[1]!==-1/0||(y=[0,1]),"streaming"===s.runtimeMode)if("x"==("up"===(p=s.arrowOfTime)||"down"===p?"y":"x")){const e="right"===s.arrowOfTime?[0,t.width]:[t.width,0];this.scales={x:r.scaleLinear().domain(f).range(e),y:r.scaleLinear().domain(y).range([t.height,0])}}else{const e="down"===s.arrowOfTime?[0,t.height]:[t.height,0];this.scales={x:r.scaleLinear().domain(y).range([0,t.width]),y:r.scaleLinear().domain(f).range(e)}}else{const e=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return r.scaleLog().domain(t).range(n).clamp(!0)}return r.scaleLinear().domain(e).range(n)};this.scales={x:e(s.xScaleType,f,[0,t.width]),y:e(s.yScaleType,y,[t.height,0])}}var p;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,u),this.config.decay&&this.applyDecay(this.scene,u),this.config.pulse&&this.applyPulse(this.scene,u),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}rebuildQuadtree(){const t=this.config.chartType;if("scatter"!==t&&"bubble"!==t)return void(this._quadtree=null);const e=this.scene.filter(t=>"point"===t.type);this._quadtree=e.length>H.QUADTREE_THRESHOLD?o.quadtree().x(t=>t.x).y(t=>t.y).addAll(e):null}get quadtree(){return this._quadtree}remapScene(t){const e=t.width/this.lastLayout.width,n=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const r of t.path)r[0]*=e,r[1]*=n;break;case"area":for(const r of t.topPath)r[0]*=e,r[1]*=n;for(const r of t.bottomPath)r[0]*=e,r[1]*=n;break;case"point":t.x*=e,t.y*=n;break;case"rect":case"heatcell":t.x*=e,t.y*=n,t.w*=e,t.h*=n;break;case"candlestick":t.x*=e,t.openY*=n,t.closeY*=n,t.highY*=n,t.lowY*=n}const o=this.scales.x.domain(),i=this.scales.y.domain(),l=this.scales.x.range(),a=this.scales.y.range(),s=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return r.scaleLog().domain(t).range(n).clamp(!0)}return r.scaleLinear().domain(e).range(n)};this.scales={x:s(this.config.xScaleType,o,[l[0]*e,l[1]*e]),y:s(this.config.yScaleType,i,[a[0]*n,a[1]*n])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){var n;const{config:o,scales:l}=this;if(!l||0===e.length)return[];const a={scales:l,config:o,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,getBounds:this.getBounds,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(t,e)=>this.resolveLineStyle(t,e),resolveAreaStyle:(t,e)=>this.resolveAreaStyle(t,e),resolveBoundsStyle:(t,e)=>this.resolveBoundsStyle(t,e),resolveColorMap:t=>this.resolveColorMap(t),resolveGroupColor:t=>this.resolveGroupColor(t),groupData:t=>this.groupData(t),barCategoryCache:this._barCategoryCache};switch(o.chartType){case"line":return function(t,e){var n;const r=t.groupData(e),o=[],i=null===(n=t.config.annotations)||void 0===n?void 0:n.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.getBounds)for(const e of r){const n=j(t,e.data,e.key);n&&o.push(n)}for(const e of r){const n=t.resolveLineStyle(e.key,e.data[0]),r=W(e.data,t.scales,t.getX,t.getY,n,e.key);i&&i.length>0&&(r.colorThresholds=i),t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),o.push(r)}return F(t,r,o),o}(a,e);case"area":return function(t,e){const n=t.groupData(e),r=[],o=t.scales.y.domain()[0],i=t.getY0?e=>{const n=t.getY0(e);return null==n?o:n}:void 0;for(const e of n){const n=t.resolveAreaStyle(e.key,e.data[0]),l=I(e.data,t.scales,t.getX,t.getY,o,n,e.key,i);t.config.gradientFill&&(l.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(l.curve=t.config.curve),r.push(l)}return F(t,n,r),r}(a,e);case"stackedarea":return function(t,e){const n=t.groupData(e);n.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);const r=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,{nodes:o,stackedTops:i}=function(t,e,n,r,o,i,l){var a;const s=new Set;for(const e of t)for(const t of e.data){const e=n(t);null==e||Number.isNaN(e)||s.add(e)}const c=Array.from(s).sort((t,e)=>t-e),u=new Map;for(const e of t){const t=new Map;for(const o of e.data){const e=n(o),i=r(o);null==e||null==i||Number.isNaN(e)||Number.isNaN(i)||t.set(e,(t.get(e)||0)+i)}u.set(e.key,t)}let h;if(i){h=new Map;for(const e of c){let n=0;for(const r of t)n+=(null===(a=u.get(r.key))||void 0===a?void 0:a.get(e))||0;h.set(e,n||1)}}const d=[],f=new Map,y=new Map;for(const t of c)y.set(t,0);for(const n of t){const t=u.get(n.key),r=[],a=[],s=new Map;for(const n of c){let o=t.get(n)||0;const l=y.get(n);i&&(o/=h.get(n));const c=l+o,u=e.x(n);a.push([u,e.y(l)]),r.push([u,e.y(c)]),y.set(n,c),s.set(n,c)}f.set(n.key,s);const g={type:"area",topPath:r,bottomPath:a,style:o(n.key,n.data[0]),datum:n.data,group:n.key};l&&(g.curve=l),d.push(g)}return{nodes:d,stackedTops:f}}(n,t.scales,t.getX,t.getY,(e,n)=>t.resolveAreaStyle(e,n),t.config.normalize,r),l=o;if(t.config.pointStyle){const e=new WeakMap;for(const r of n){const n=i.get(r.key);if(n)for(const o of r.data){const r=t.getX(o),i=t.getY(o);null==r||Number.isNaN(r)||null==i||Number.isNaN(i)||!n.has(r)||e.set(o,n.get(r))}}const r=n=>{var r;return null!==(r=e.get(n))&&void 0!==r?r:t.getY(n)};F(t,n,l,r)}return l}(a,e);case"scatter":case"bubble":return function(t,e){const n=[],r="bubble"===t.config.chartType?10:5,o=t.config.sizeRange||[3,15];let i=null;if(t.getSize&&!t.config.pointStyle){const n=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(n.length>0){let t=1/0,e=-1/0;for(const r of n)t>r&&(t=r),r>e&&(e=r);i=n=>t===e?(o[0]+o[1])/2:o[0]+(n-t)/(e-t)*(o[1]-o[0])}}const l=t.getColor?t.resolveColorMap(e):null;for(const o of e){let e=t.config.pointStyle?t.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},a=e.r||r;if(i&&t.getSize){const e=t.getSize(o);null==e||Number.isNaN(e)||(a=i(e))}if(l&&t.getColor&&!e.fill){const n=t.getColor(o);n&&l.has(n)&&(e=Object.assign(Object.assign({},e),{fill:l.get(n)}))}const s=t.getPointId?t.getPointId(o)+"":void 0,c=z(o,t.scales,t.getX,t.getY,a,e,s);c&&n.push(c)}return n}(a,e);case"heatmap":return function(t,e,n){if(t.config.heatmapAggregation)return function(t,e,n){var r,o,i;const l=[],a=Math.max(1,Math.floor(null!==(r=t.config.heatmapXBins)&&void 0!==r?r:20)),s=Math.max(1,Math.floor(null!==(o=t.config.heatmapYBins)&&void 0!==o?o:20)),c=null!==(i=t.config.heatmapAggregation)&&void 0!==i?i:"count",u=M(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return l;const[h,d]=t.scales.x.domain(),[f,y]=t.scales.y.domain(),g=(d-h||1)/a,p=(y-f||1)/s,m=new Map;for(const n of e){const e=t.getX(n),r=t.getY(n);if(!isFinite(e)||!isFinite(r))continue;const o=Math.min(Math.floor((e-h)/g),a-1),i=Math.min(Math.floor((r-f)/p),s-1);if(0>o||0>i)continue;const l=u(n),c=`${o}_${i}`;let d=m.get(c);d||(d={sum:0,count:0,data:[]},m.set(c,d)),d.count++,d.sum+=isFinite(l)?l:0,d.data.push(n)}let v=1/0,x=-1/0;const b=new Map;for(const[t,e]of m){let n;switch(c){case"sum":n=e.sum;break;case"mean":n=e.count>0?e.sum/e.count:0;break;default:n=e.count}b.set(t,n),v>n&&(v=n),n>x&&(x=n)}const k=x-v||1,w=n.width/a,E=n.height/s;for(const[e,n]of b){const[r,o]=e.split("_"),i=+r,a=+o,c=(n-v)/k,u=`rgb(${Math.round(220-180*c)},${Math.round(220-100*c)},${Math.round(255-50*c)})`,h=m.get(e);l.push(B(i*w,(s-1-a)*E,w,E,u,{xi:i,yi:a,value:n,count:h.count,sum:h.sum,data:h.data},t.config.showValues?{value:n,showValues:!0,valueFormat:t.config.heatmapValueFormat}:void 0))}return l}(t,e,n);const o=[],l=M(t.config.valueAccessor,"value"),a=S(t.config.xAccessor,"x"),s=S(t.config.yAccessor,"y"),c=new Set,u=new Set;for(const t of e)c.add(a(t)),u.add(s(t));const h=Array.from(c),d=Array.from(u),f=h.every(t=>"number"==typeof t&&!isNaN(t)),y=d.every(t=>"number"==typeof t&&!isNaN(t)),g=f?h.sort((t,e)=>t-e):h,p=y?d.sort((t,e)=>t-e):d;if(0===g.length||0===p.length)return o;const m=n.width/g.length,v=n.height/p.length,x=new Map;for(const t of e){const e=`${a(t)}\0${s(t)}`;x.set(e,{val:l(t),datum:t})}let b=1/0,k=-1/0;for(const{val:t}of x.values())isFinite(t)&&(b>t&&(b=t),t>k&&(k=t));if(!isFinite(b)||!isFinite(k))return o;const w=r.scaleSequential(Y["string"==typeof t.config.colorScheme?t.config.colorScheme:"blues"]||i.interpolateBlues).domain([b,k]);for(let e=0;g.length>e;e++)for(let n=0;p.length>n;n++){const r=x.get(`${g[e]}\0${p[n]}`);if(!r||!isFinite(r.val))continue;const i=w(r.val);o.push(B(e*m,(p.length-1-n)*v,m,v,i,r.datum,t.config.showValues?{value:r.val,showValues:!0,valueFormat:t.config.heatmapValueFormat}:void 0))}return o}(a,e,t);case"bar":{const t=function(t,e){var n;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const r=E(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===r.size)return{nodes:[],binBoundaries:[]};let o=null;if(t.getCategory){const e=new Set;for(const t of r.values())for(const n of t.categories.keys())e.add(n);const n=t.config.barColors?Object.keys(t.config.barColors):[],i=new Set(n),l=Array.from(e).filter(t=>!i.has(t)).sort(),a=n.filter(t=>e.has(t)),s=a.join("\0")+""+l.join("\0");t.barCategoryCache&&t.barCategoryCache.key===s?o=t.barCategoryCache.order:(o=[...a,...l],t.barCategoryCache={key:s,order:o})}const i=[],l=t.scales,[a,s]=l.x.domain();for(const e of r.values()){const r=Math.max(e.start,a),c=Math.min(e.end,s);if(r>=c)continue;const u=l.x(r),h=l.x(c),d=Math.abs(h-u),f=d>2?1:0,y=Math.min(u,h)+f/2,g=Math.max(d-f,1);if(g>0)if(o&&e.categories.size>0){let r=0;for(const a of o){const o=e.categories.get(a)||0;if(0===o)continue;const s=l.y(r),c=l.y(r+o);i.push(R(y,Math.min(s,c),g,Math.abs(s-c),{fill:(null===(n=t.config.barColors)||void 0===n?void 0:n[a])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:a,categoryValue:o},a)),r+=o}}else{const t=l.y(0),n=l.y(e.total);i.push(R(y,Math.min(t,n),g,Math.abs(t-n),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}const c=new Set;for(const t of r.values())c.add(t.start),c.add(t.end);return{nodes:i,binBoundaries:Array.from(c).sort((t,e)=>t-e)}}(a,e);return this._barCategoryCache=null!==(n=a.barCategoryCache)&&void 0!==n?n:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var n,r,o,i;const l=[],a=t.config.swarmStyle||{},s=null!==(n=a.radius)&&void 0!==n?n:3,c=null!==(r=a.fill)&&void 0!==r?r:"#007bff",u=null!==(o=a.opacity)&&void 0!==o?o:.7,h=a.stroke,d=a.strokeWidth;for(const n of e){const e=t.getX(n),r=t.getY(n);if(null==r||Number.isNaN(r))continue;const o=t.scales.x(e),a=t.scales.y(r);let f=c;if(t.getCategory){const e=t.getCategory(n);f=(null===(i=t.config.barColors)||void 0===i?void 0:i[e])||f}const y={type:"point",x:o,y:a,r:s,style:{fill:f,opacity:u,stroke:h,strokeWidth:d},datum:n};t.getPointId&&(y.pointId=t.getPointId(n)+""),l.push(y)}return l}(a,e);case"waterfall":return function(t,e,n){var r,o,i;const l=[],a=t.scales,s=t.config.waterfallStyle,c=e.filter(e=>{const n=t.getY(e),r=t.getX(e);return null!=n&&!Number.isNaN(n)&&null!=r&&isFinite(r)});if(0===c.length)return l;const u=null!==(r=null==s?void 0:s.positiveColor)&&void 0!==r?r:"#28a745",h=null!==(o=null==s?void 0:s.negativeColor)&&void 0!==o?o:"#dc3545",d=null!==(i=null==s?void 0:s.gap)&&void 0!==i?i:1,f=null==s?void 0:s.stroke,y=null==s?void 0:s.strokeWidth;let g=0;for(let e=0;c.length>e;e++){const r=c[e],o=t.getX(r),i=t.getY(r),p=g+i;let m;m=c.length-1>e?t.getX(c[e+1])-o:e>0?o-t.getX(c[e-1]):0;const v=a.x(o),x=0!==m?a.x(o+m):v+n.width/10,b=Math.min(v,x)+d/2,k=Math.max(v,x)-d/2-b;if(0>=k){g=p;continue}const w=a.y(g),E=a.y(p);l.push(R(b,Math.min(w,E),k,Math.abs(w-E),{fill:0>i?h:u,stroke:f,strokeWidth:y},Object.assign(Object.assign({},r),{baseline:g,cumEnd:p,delta:i,_connectorStroke:null==s?void 0:s.connectorStroke,_connectorWidth:null==s?void 0:s.connectorWidth}))),g=p}return l}(a,e,t);case"candlestick":return function(t,e){if(!(t.getOpen&&t.getHigh&&t.getLow&&t.getClose&&t.scales))return[];const n=[],r=t.config.candlestickStyle||{},o=r.upColor||"#28a745",i=r.downColor||"#dc3545",l=r.wickColor||"#333",a=r.wickWidth||1,s=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let c=r.bodyWidth||6;if(!r.bodyWidth&&s.length>1){let e=1/0;for(let n=1;s.length>n;n++){const r=Math.abs(t.scales.x(s[n])-t.scales.x(s[n-1]));r>0&&e>r&&(e=r)}e!==1/0&&(c=Math.max(2,Math.min(.6*e,20)))}for(const r of e){const e=t.getX(r);if(null==e||Number.isNaN(e))continue;const s=t.getOpen(r),u=t.getHigh(r),h=t.getLow(r),d=t.getClose(r);if([s,u,h,d].some(t=>null==t||Number.isNaN(t)))continue;const f=d>=s;n.push({type:"candlestick",x:t.scales.x(e),openY:t.scales.y(s),closeY:t.scales.y(d),highY:t.scales.y(u),lowY:t.scales.y(h),bodyWidth:c,upColor:o,downColor:i,wickColor:l,wickWidth:a,isUp:f,datum:r})}return n}(a,e);default:return[]}}resolveBoundsStyle(t,e){const n=this.config.boundsStyle;return"function"==typeof n?n(e||{},t):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(t,e).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const n=this.config.decay;return n&&e>1?D(n,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,n){var r,o;const i=n.length;if(1>=i)return;const l=new Map;for(let t=0;n.length>t;t++)l.set(n[t],t);for(const n of e){if("line"===n.type){const e=Array.isArray(n.datum)?n.datum:[];if(2>e.length)continue;const r=Array(e.length);let o=!1;for(let n=0;e.length>n;n++){const a=l.get(e[n]);null!=a?(r[n]=D(t,a,i),1>r[n]&&(o=!0)):r[n]=1}o&&(n._decayOpacities=r);continue}if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[],r=n.topPath?n.topPath.length:e.length;if(2>r)continue;if(e.length===r){const o=Array(r);let a=!1;for(let n=0;e.length>n;n++){const r=l.get(e[n]);null!=r?(o[n]=D(t,r,i),1>o[n]&&(a=!0)):o[n]=1}a&&(n._decayOpacities=o)}else{let o=1;for(const n of e){const e=l.get(n);if(null!=e){const n=D(t,e,i);o>n&&(o=n)}}if(1>o){const t=Array(r);t.fill(o),n._decayOpacities=t}}continue}const e=l.get(n.datum);if(null==e)continue;const a=D(t,e,i);if("heatcell"===n.type)n.style={opacity:a};else if("candlestick"===n.type)n._decayOpacity=a;else{const t=null!==(o=null===(r=n.style)||void 0===r?void 0:r.opacity)&&void 0!==o?o:1;n.style=Object.assign(Object.assign({},n.style),{opacity:t*a})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,n,r){var o,i;const l="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(o=t.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",s=null!==(i=t.glowRadius)&&void 0!==i?i:4,c=new Map;for(let t=0;n.length>t;t++)c.set(n[t],t);for(const n of e){if("line"===n.type)continue;if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[n.datum];let o=0;for(const n of e){const e=c.get(n);if(null==e)continue;const i=r.get(e);if(null==i)continue;const a=L(t,i,l);a>o&&(o=a)}o>0&&(n._pulseIntensity=o,n._pulseColor=a);continue}const e=c.get(n.datum);if(null==e)continue;const o=r.get(e);if(null==o)continue;const i=L(t,o,l);i>0&&(n._pulseIntensity=i,n._pulseColor=a,n._pulseGlowRadius=s)}}(this.config.pulse,t,e,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(t,e){var n;if(!e||0===e.size)return!1;const r="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(n=t.duration)&&void 0!==n?n:500,i=e.peek();return null!=i&&o>r-i}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,n,r){var o,i,l;n.clear(),r.clear();for(let a=0;e.length>a;a++){const s=e[a],c=O(t,s,a);c&&("point"===s.type?n.set(c,{x:s.x,y:s.y,r:s.r,opacity:s.style.opacity}):"rect"===s.type?n.set(c,{x:s.x,y:s.y,w:s.w,h:s.h,opacity:s.style.opacity}):"heatcell"===s.type?n.set(c,{x:s.x,y:s.y,w:s.w,h:s.h,opacity:null===(o=s.style)||void 0===o?void 0:o.opacity}):"candlestick"===s.type?n.set(c,{x:s.x,y:s.openY}):"line"===s.type?r.set(c,{path:s.path.map(t=>[t[0],t[1]]),opacity:null===(i=s.style)||void 0===i?void 0:i.opacity}):"area"===s.type&&r.set(c,{topPath:s.topPath.map(t=>[t[0],t[1]]),bottomPath:s.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(l=s.style)||void 0===l?void 0:l.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}startTransition(){if(!this.config.transition)return;const t=function(t,e,n,r,o){var i,l,a,s,c,u,h,d,f,y,g,p,m,v,x,b,k,w,E,A,M,S,_,P,C,D,L,T;if(0===r.size&&0===o.size)return n;const N=null!==(i=e.duration)&&void 0!==i?i:300;if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}let $=!1;const W=new Set,I=new Set;for(let e=0;n.scene.length>e;e++){const i=n.scene[e],E=O(t,i,e);if(!E)continue;if(i._transitionKey=E,"line"===i.type||"area"===i.type){const t=o.get(E);if(t){if(I.add(E),"line"===i.type&&t.path&&t.path.length===i.path.length){i._targetPath=i.path.map(t=>[t[0],t[1]]),i._prevPath=t.path;for(let e=0;i.path.length>e;e++)i.path[e]=[t.path[e][0],t.path[e][1]];$=!0}else if("area"===i.type&&t.topPath&&t.bottomPath&&t.topPath.length===i.topPath.length&&t.bottomPath.length===i.bottomPath.length){i._targetTopPath=i.topPath.map(t=>[t[0],t[1]]),i._targetBottomPath=i.bottomPath.map(t=>[t[0],t[1]]),i._prevTopPath=t.topPath,i._prevBottomPath=t.bottomPath;for(let e=0;i.topPath.length>e;e++)i.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;i.bottomPath.length>e;e++)i.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];$=!0}i._targetOpacity=null!==(l=i.style.opacity)&&void 0!==l?l:1,i._startOpacity=null!==(s=null!==(a=t.opacity)&&void 0!==a?a:i.style.opacity)&&void 0!==s?s:1}else i._targetOpacity=null!==(c=i.style.opacity)&&void 0!==c?c:1,i._startOpacity=0,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),$=!0;continue}const A=r.get(E);if("point"===i.type)if(A){W.add(E);const t={x:i.x,y:i.y,r:i.r};i._targetOpacity=null!==(u=i.style.opacity)&&void 0!==u?u:1,A.x===t.x&&A.y===t.y&&A.r===t.r||(i._targetX=t.x,i._targetY=t.y,i._targetR=t.r,i.x=A.x,i.y=A.y,i.r=null!==(h=A.r)&&void 0!==h?h:i.r,$=!0)}else i._targetOpacity=null!==(d=i.style.opacity)&&void 0!==d?d:1,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),$=!0;else if("rect"===i.type)if(A){W.add(E);const t={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=null!==(f=i.style.opacity)&&void 0!==f?f:1,A.x===t.x&&A.y===t.y&&A.w===t.w&&A.h===t.h||(i._targetX=t.x,i._targetY=t.y,i._targetW=t.w,i._targetH=t.h,i.x=A.x,i.y=A.y,i.w=null!==(y=A.w)&&void 0!==y?y:i.w,i.h=null!==(g=A.h)&&void 0!==g?g:i.h,$=!0)}else i._targetOpacity=null!==(p=i.style.opacity)&&void 0!==p?p:1,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),$=!0;else if("heatcell"===i.type)if(A){W.add(E);const t={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=null!==(v=null===(m=i.style)||void 0===m?void 0:m.opacity)&&void 0!==v?v:1,A.x===t.x&&A.y===t.y&&A.w===t.w&&A.h===t.h||(i._targetX=t.x,i._targetY=t.y,i._targetW=t.w,i._targetH=t.h,i.x=A.x,i.y=A.y,i.w=null!==(x=A.w)&&void 0!==x?x:i.w,i.h=null!==(b=A.h)&&void 0!==b?b:i.h,$=!0)}else i._targetOpacity=null!==(w=null===(k=i.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,i.style=Object.assign(Object.assign({},i.style||{}),{opacity:0}),$=!0}for(const[t,e]of o)if(!I.has(t))if(t.startsWith("l:")&&e.path){const r={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(E=e.opacity)&&void 0!==E?E:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(r),$=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const r={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:null!==(A=e.opacity)&&void 0!==A?A:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(r),$=!0}for(const[t,e]of r)if(!W.has(t)){if(t.startsWith("p:")){const r={type:"point",x:e.x,y:e.y,r:null!==(M=e.r)&&void 0!==M?M:3,style:{opacity:null!==(S=e.opacity)&&void 0!==S?S:1},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(r)}else if(t.startsWith("r:")){const r={type:"rect",x:e.x,y:e.y,w:null!==(_=e.w)&&void 0!==_?_:0,h:null!==(P=e.h)&&void 0!==P?P:0,style:{opacity:null!==(C=e.opacity)&&void 0!==C?C:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(r)}else if(t.startsWith("h:")){const r={type:"heatcell",x:e.x,y:e.y,w:null!==(D=e.w)&&void 0!==D?D:0,h:null!==(L=e.h)&&void 0!==L?L:0,fill:"#999",datum:null,style:{opacity:null!==(T=e.opacity)&&void 0!==T?T:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(r)}$=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),$&&(n.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:N}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(t,e,n,r){var o,i,l,a,s;if(!n.activeTransition)return!1;const c=N(t,n.activeTransition),u=T(c,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of n.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const n=e?r.get(e):void 0,i=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;t.style.opacity=$(i,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const n=r.get(e);if(!n)continue;t.x=$(n.x,t._targetX,u),t.y=$(n.y,t._targetY,u),void 0!==t._targetR&&void 0!==n.r&&(t.r=$(n.r,t._targetR,u))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=e?r.get(e):void 0,o=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;t.style.opacity=$(o,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const n=r.get(e);if(!n)continue;t.x=$(n.x,t._targetX,u),t.y=$(n.y,t._targetY,u),void 0!==n.w&&(t.w=$(n.w,t._targetW,u)),void 0!==n.h&&(t.h=$(n.h,t._targetH,u))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const n=e?r.get(e):void 0,o=n?null!==(l=n.opacity)&&void 0!==l?l:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:$(o,t._targetOpacity,u)})}if(void 0===t._targetX)continue;if(!e)continue;const n=r.get(e);if(!n)continue;t.x=$(n.x,t._targetX,u),t.y=$(n.y,t._targetY,u),void 0!==n.w&&(t.w=$(n.w,t._targetW,u)),void 0!==n.h&&(t.h=$(n.h,t._targetH,u))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=null!==(a=t._startOpacity)&&void 0!==a?a:0;t.style=Object.assign(Object.assign({},t.style),{opacity:$(e,t._targetOpacity,u)})}const e=t._prevPath,n=t._targetPath;if(e&&n&&e.length===t.path.length)for(let r=0;t.path.length>r;r++)t.path[r][0]=$(e[r][0],n[r][0],u),t.path[r][1]=$(e[r][1],n[r][1],u)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(s=t._startOpacity)&&void 0!==s?s:0;t.style=Object.assign(Object.assign({},t.style),{opacity:$(e,t._targetOpacity,u)})}const e=t._prevTopPath,n=t._prevBottomPath,r=t._targetTopPath,o=t._targetBottomPath;if(e&&r&&e.length===t.topPath.length)for(let n=0;t.topPath.length>n;n++)t.topPath[n][0]=$(e[n][0],r[n][0],u),t.topPath[n][1]=$(e[n][1],r[n][1],u);if(n&&o&&n.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=$(n[e][0],o[e][0],u),t.bottomPath[e][1]=$(n[e][1],o[e][1],u)}}if(c>=1){for(const t of n.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style=Object.assign(Object.assign({},"line"===t.type||"area"===t.type?t.style:t.style||{}),{opacity:0===e?0:e}),t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let n=0;t.path.length>n;n++)t.path[n]=e[n];t._prevPath=void 0,t._targetPath=void 0}else if("area"===t.type){const e=t._targetTopPath,n=t._targetBottomPath;if(e)for(let n=0;t.topPath.length>n;n++)t.topPath[n]=e[n];if(n)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=n[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0}}if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,n}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const n of t){const t=this.getGroup(n);e.has(t)||e.set(t,[]),e.get(t).push(n)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveColorMap(t){const e=new Set;for(const n of t){const t=this.getColor(n);t&&e.add(t)}const n=Array.from(e).sort(),r=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===r)return this._colorMapCache.map;const o=Array.isArray(this.config.colorScheme)?this.config.colorScheme:C,i=new Map;for(let t=0;n.length>t;t++)i.set(n[t],o[t%o.length]);return this._colorMapCache={key:r,map:i},i}resolveLineStyle(t,e){const n=this.config.lineStyle;if("function"==typeof n){const r=n(e||{},t);if(r&&!r.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},r),{stroke:e})}return r}return n&&"object"==typeof n?{stroke:n.stroke||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var n;if(this.config.areaStyle){const n=this.config.areaStyle(e||{});if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}const r=this.config.lineStyle;if("function"==typeof r){const n=r(e||{},t);if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}return r&&"object"==typeof r?{fill:r.fill||r.stroke||"#4e79a7",fillOpacity:null!==(n=r.fillOpacity)&&void 0!==n?n:.7,stroke:r.stroke||"#4e79a7",strokeWidth:r.strokeWidth||2}:{fill:"#4e79a7",fillOpacity:.7,stroke:"#4e79a7",strokeWidth:2}}resolveGroupColor(t){if(this._colorMapCache){const e=this._colorMapCache.map.get(t);if(e)return e}const e=this._groupColorMap.get(t);if(e)return e;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:C,r=n[this._groupColorMap.size%n.length];return this._groupColorMap.set(t,r),r}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(t){var e,n,r,o;const i=Object.assign({},this.config);void 0!==t.colorScheme&&(this._colorMapCache=null,this._groupColorMap=new Map),void 0===t.barColors&&void 0===t.colorScheme||(this._barCategoryCache=null),void 0===t.normalize&&void 0===t.extentPadding&&void 0===t.xAccessor&&void 0===t.yAccessor&&void 0===t.groupAccessor&&void 0===t.categoryAccessor&&void 0===t.chartType||(this._stackExtentCache=null);let l=!1;Object.assign(this.config,t);const a="chartType"in t&&t.chartType!==i.chartType||"runtimeMode"in t&&t.runtimeMode!==i.runtimeMode;if(a||void 0!==t.xAccessor||void 0!==t.yAccessor||void 0!==t.timeAccessor||void 0!==t.valueAccessor){const s=a||!A(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(n=i.xAccessor)&&void 0!==n?n:i.timeAccessor),c=a||!A(null!==(r=t.yAccessor)&&void 0!==r?r:t.valueAccessor,null!==(o=i.yAccessor)&&void 0!==o?o:i.valueAccessor);(s||c)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=M(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=M(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=M(this.config.xAccessor,"x"),this.getY=M(this.config.yAccessor,"y")),l=!0)}if("groupAccessor"in t&&!A(t.groupAccessor,i.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?_(this.config.groupAccessor):void 0,l=!0),"categoryAccessor"in t&&!A(t.categoryAccessor,i.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?_(this.config.categoryAccessor):void 0,l=!0),"sizeAccessor"in t&&!A(t.sizeAccessor,i.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?M(this.config.sizeAccessor,"size"):void 0,l=!0),"colorAccessor"in t&&!A(t.colorAccessor,i.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?_(this.config.colorAccessor):void 0,l=!0),"y0Accessor"in t&&!A(t.y0Accessor,i.y0Accessor)&&(this.getY0=this.config.y0Accessor?M(this.config.y0Accessor,"y0"):void 0,l=!0),"pointIdAccessor"in t&&!A(t.pointIdAccessor,i.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?_(this.config.pointIdAccessor):void 0,l=!0),!l){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const n of e)if(t[n]!==i[n]){l=!0;break}}l&&(this.needsFullRebuild=!0)}}function X(t,e,n){return n.x>t||t>n.x+n.w||n.y>e||e>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function G(t){let e=t%(2*Math.PI);return 0>e&&(e+=2*Math.PI),e}function V(t,e,n){const r=e-t.x,o=n-t.y,i=Math.sqrt(r*r+o*o);return i>Math.max(t.r+5,12)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:i}}function q(t,e,n){var r,o,i,l;if(0===t.path.length)return null;const a=tt(t.path,e);if(0>a)return null;const[s,c]=t.path[a];let u;if(t.path.length>1){let r=1/0;const o=Math.max(0,a-1),i=Math.min(t.path.length-2,a);for(let l=o;i>=l;l++){const[o,i]=t.path[l],[a,s]=t.path[l+1],c=K(e,n,o,i,a,s);r>c&&(r=c)}u=r}else{const t=e-s,r=n-c;u=Math.sqrt(t*t+r*r)}const h=null!==(l=null!==(o=null===(r=t.style)||void 0===r?void 0:r.strokeWidth)&&void 0!==o?o:null===(i=t.style)||void 0===i?void 0:i.lineWidth)&&void 0!==l?l:1;return u>Math.max(5,h/2+2)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[a]?t.datum[a]:t.datum,x:s,y:c,distance:u}}function K(t,e,n,r,o,i){const l=o-n,a=i-r,s=l*l+a*a;if(0===s)return Math.sqrt(Math.pow(t-n,2)+Math.pow(e-r,2));let c=((t-n)*l+(e-r)*a)/s;c=Math.max(0,Math.min(1,c));const u=r+c*a;return Math.sqrt(Math.pow(t-(n+c*l),2)+Math.pow(e-u,2))}function U(t,e,n){const r=X(e,n,t);return r.hit?{node:t,datum:t.datum,x:r.cx,y:r.cy,distance:0}:null}function Z(t,e,n){const r=X(e,n,t);return r.hit?{node:t,datum:t.datum,x:r.cx,y:r.cy,distance:0}:null}function Q(t,e,n){const r=t.bodyWidth/2,o=Math.min(t.openY,t.closeY);if(!(t.x-r-3>e||e>t.x+r+3||t.highY-3>n||n>t.lowY+3)){const r=o+Math.max(Math.max(t.openY,t.closeY)-o,1)/2,i=e-t.x,l=n-r;return{node:t,datum:t.datum,x:t.x,y:r,distance:Math.sqrt(i*i+l*l)}}return null}function J(t,e,n){if(0===t.topPath.length)return null;const r=tt(t.topPath,e);if(0>r)return null;const[o,i]=t.topPath[r],l=e-o,a=n-i,s=Math.sqrt(l*l+a*a);return{node:t,datum:Array.isArray(t.datum)&&t.datum[r]?t.datum[r]:t.datum,x:o,y:i,distance:s}}function tt(t,e){if(0===t.length)return-1;let n=0,r=t.length-1;for(;r>n;){const o=n+r>>1;e>t[o][0]?n=o+1:r=o}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}function et(t){var e,n;const r=new Map;for(const n of t){const t=null!==(e=n.group)&&void 0!==e?e:"_default";let o=r.get(t);o||(o=[],r.set(t,o)),o.push(n)}for(const t of r.values()){t.sort((t,e)=>t.x-e.x||t.y-e.y);for(let e=0;t.length>e;e++)t[e]._groupIndex=e}const o=Array.from(r.keys()).sort((t,e)=>{const n=r.get(t),o=r.get(e);return(n.length>0?n[0].y:0)-(o.length>0?o[0].y:0)}),i=Array.from(r.values()).flat();i.sort((t,e)=>t.x-e.x||t.y-e.y);const l=new Map;for(let t=0;i.length>t;t++){i[t]._flatIndex=t;const e=null===(n=i[t].datum)||void 0===n?void 0:n.id;null!=e&&l.set(e+"",t)}return{flat:i,groups:o,byGroup:r,idToIdx:l}}function nt(t,e){var n,r;if(0===t.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const o=Math.max(0,Math.min(e,t.flat.length-1)),i=t.flat[o];return{flatIndex:o,group:null!==(n=i.group)&&void 0!==n?n:"_default",indexInGroup:null!==(r=i._groupIndex)&&void 0!==r?r:0}}function rt(t,e,n){const{group:r,indexInGroup:o}=e,i=n.byGroup.get(r);switch(t){case"ArrowRight":return i.length-1>o?i[o+1]._flatIndex:e.flatIndex;case"ArrowLeft":return o>0?i[o-1]._flatIndex:e.flatIndex;case"ArrowDown":{const t=n.groups.indexOf(r);return n.groups.length-1>t?ot(n,n.groups[t+1],i[o]):e.flatIndex}case"ArrowUp":{const t=n.groups.indexOf(r);return t>0?ot(n,n.groups[t-1],i[o]):e.flatIndex}case"PageDown":return Math.min(e.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(e.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function ot(t,e,n){const r=t.byGroup.get(e);let o=0,i=Math.abs(r[0].x-n.x);for(let t=1;r.length>t;t++){const e=Math.abs(r[t].x-n.x);i>e&&(i=e,o=t)}return r[o]._flatIndex}function it(t){const e=t.datum||{};return Object.assign(Object.assign({},"object"!=typeof e||null===e||Array.isArray(e)?{}:e),{data:e,x:t.x,y:t.y,time:t.x,value:t.y})}function lt(e,n,r){const o=t.useRef(null),[i,l]=t.useState(null);return t.useEffect(()=>{if(!n&&!r)return;const t=o.current;if(!t)return;const e=new ResizeObserver(t=>{for(const e of t){const{width:t,height:n}=e.contentRect;l(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n})}});return e.observe(t),()=>e.disconnect()},[n,r]),[o,[n&&i?i.w:e[0],r&&i?i.h:e[1]]]}function at(e,n,r,o,i,l){t.useEffect(()=>{if(!e)return;const t=setInterval(()=>{var t;const a=n.current;if(!a||0===a.lastIngestTime)return;const s="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(t=e.threshold)&&void 0!==t?t:5e3,u=s-a.lastIngestTime>c;u!==i&&(l(u),r.current=!0,o())},1e3);return()=>clearInterval(t)},[e,i,o])}H.QUADTREE_THRESHOLD=500;const st={fill:t=>g.createElement("rect",{style:t,width:16,height:16}),line:t=>g.createElement("line",{style:t,x1:0,y1:0,x2:16,y2:16})};function ct(t,e,n,r){let o;return o="function"==typeof n?n(t):(0,st[n])(r(t,e)),o}function ut(){return g.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function ht(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}function dt({config:t,orientation:e="vertical",width:n=100}){const{colorFn:r,domain:o,label:i,format:l}=t,a=l||(t=>Math.round(100*t)/100+""),s="grad-legend-"+g.useId();if("horizontal"===e){const t=12,e=Math.min(n,200),l=Math.max(0,(n-e)/2),c=[];for(let t=0;64>=t;t++){const e=t/64;c.push(g.createElement("stop",{key:t,offset:100*e+"%",stopColor:r(o[0]+e*(o[1]-o[0]))}))}return g.createElement("g",{"aria-label":i||"Gradient legend"},g.createElement("defs",null,g.createElement("linearGradient",{id:s,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},c)),i&&g.createElement("text",{x:l+e/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),g.createElement("rect",{x:l,y:0,width:e,height:t,fill:`url(#${s})`,rx:2}),g.createElement("text",{x:l,y:t+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(o[0])),g.createElement("text",{x:l+e,y:t+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(o[1])))}const c=[];for(let t=0;64>=t;t++){const e=t/64;c.push(g.createElement("stop",{key:t,offset:100*e+"%",stopColor:r(o[1]-e*(o[1]-o[0]))}))}return g.createElement("g",{"aria-label":i||"Gradient legend"},i&&g.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),g.createElement("defs",null,g.createElement("linearGradient",{id:s,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},c)),g.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${s})`,rx:2}),g.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(o[1])),g.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(o[0])))}function ft(t){const{legendGroups:e,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,legendInteraction:l,title:a="Legend",width:s=100,height:c=20,orientation:u="vertical"}=t,[h,d]=g.useState(0),[f,y]=g.useState(0),p=g.useCallback((t,e)=>{d(t),y(e)},[]),m="vertical"===u?(({legendGroups:t,width:e,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:l,focusedItemIndex:a,onFocusedIndexChange:s,legendInteraction:c})=>{let u=24;const h=[];return t.forEach((t,d)=>{u+=5,h.push(g.createElement("line",{key:"legend-top-line legend-symbol-"+d,stroke:"gray",x1:0,y1:u,x2:e,y2:u})),u+=8,t.label&&(u+=16,h.push(g.createElement("text",{key:"legend-text-"+d,y:u,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label)),u+=8),h.push(g.createElement("g",{key:"legend-group-"+d,className:"legend-item",transform:`translate(0,${u})`},((t,e,n,r,o,i,l,a,s,c)=>{const{type:u="fill",styleFn:h,items:d}=t,f=[];let y=0;const p=!(!e&&!n),m="isolate"===c||void 0===c&&null!=o;return d.forEach((t,c)=>{const v=ct(t,c,u,h),x=ht(t,r,o),b=o&&o.size>0&&o.has(t.label);f.push(g.createElement("g",{key:"legend-item-"+c,transform:`translate(0,${y})`,onClick:e?()=>e(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:p?a===i&&c===l?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&m?b||!1:void 0,"aria-current":p&&!m&&null!=r&&t.label===r||void 0,"aria-label":t.label,onKeyDown:p?n=>{var r;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),e&&e(t)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const t=(c+("ArrowDown"===n.key?1:-1)+d.length)%d.length;s(a,t);const e=null===(r=n.currentTarget.parentElement)||void 0===r?void 0:r.children[t];e instanceof SVGElement&&e.focus()}}:void 0,onFocus:p?e=>{s(a,c),n&&n(t);const r=e.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:p?t=>{n&&n(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:p?"pointer":"default",opacity:x,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},p&&g.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,b&&g.createElement(ut,null),g.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label))),y+=22}),f})(t,n,r,o,i,l,a,d,s,c))),u+=22*t.items.length+8}),h})({legendGroups:e||[],width:s,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:h,focusedItemIndex:f,onFocusedIndexChange:p,legendInteraction:l}):(({legendGroups:t,height:e,width:n,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:l,focusedGroupIndex:a,focusedItemIndex:s,onFocusedIndexChange:c,legendInteraction:u})=>{let h=0;const d=[];t.forEach((t,e)=>{let f=0;t.label&&(f+=16);const y=((t,e,n,r,o,i,l,a,s,c,u)=>{const{type:h="fill",styleFn:d,items:f}=t,y=[];let p=0,m=0;const v=!(!e&&!n),x="isolate"===c||void 0===c&&null!=o;f.forEach((t,c)=>{const b=ct(t,c,h,d),k=ht(t,r,o),w=o&&o.size>0&&o.has(t.label),E=26+7*t.label.length;u&&u>0&&p>0&&p+E>u&&(m++,p=0),y.push(g.createElement("g",{key:"legend-item-"+c,transform:`translate(${p},${22*m})`,onClick:e?()=>e(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:v?a===i&&c===l?0:-1:void 0,role:v?"option":void 0,"aria-selected":v&&x?w||!1:void 0,"aria-current":v&&!x&&null!=r&&t.label===r||void 0,"aria-label":t.label,onKeyDown:v?n=>{var r;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),e&&e(t)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const t=(c+("ArrowRight"===n.key?1:-1)+f.length)%f.length;s(a,t);const e=null===(r=n.currentTarget.parentElement)||void 0===r?void 0:r.children[t];e instanceof SVGElement&&e.focus()}}:void 0,onFocus:v?e=>{s(a,c),n&&n(t);const r=e.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:v?t=>{n&&n(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:v?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},v&&g.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),b,w&&g.createElement(ut,null),g.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label))),p+=E});let b=0,k=0;for(const t of f){const e=26+7*t.label.length;u&&u>0&&k>0&&k+e>u?(b=Math.max(b,k),k=e):k+=e}b=Math.max(b,k);const w=m+1;return{items:y,offset:b,totalRows:w,totalHeight:22*w}})(t,r,o,i,l,a,s,e,c,u,n);f+=y.offset+5,d.push(Object.assign(Object.assign({label:t.label},y),{offset:f,totalRows:y.totalRows,totalHeight:y.totalHeight})),h+=f+12});let f=h>n?0:Math.max(0,(n-h)/2);const y=[];return d.forEach((n,r)=>{const o=t[r];o.label&&(y.push(g.createElement("text",{key:"legend-text-"+r,transform:`translate(${f},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},o.label)),f+=16),y.push(g.createElement("g",{key:"legend-group-"+r,className:"legend-item",transform:`translate(${f},0)`},n.items)),f+=n.offset+5,t[r+1]&&y.push(g.createElement("line",{key:"legend-top-line legend-symbol-"+r,stroke:"gray",x1:f,y1:-8,x2:f,y2:(n.totalHeight||e)+0+8})),f+=12}),g.createElement("g",null,y)})({legendGroups:e||[],title:a,height:c,width:s,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:h,focusedItemIndex:f,onFocusedIndexChange:p,legendInteraction:l}),v=!(!n&&!r);return g.createElement("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==l&&(void 0!==l||null==i))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},void 0!==a&&""!==a&&"vertical"===u&&g.createElement("text",{className:"legend-title",y:16,x:s/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},a),m)}function yt(t){const{legend:e,totalWidth:n,totalHeight:r,margin:o,legendPosition:i="right",title:l,legendHoverBehavior:a,legendClickBehavior:s,legendHighlightedCategory:c,legendIsolatedCategories:u,legendInteraction:h}=t;if(!e)return null;const d="top"===i||"bottom"===i;let f,y;return"left"===i?(f=4,y=o.top):"top"===i?(f=0,y=l?32:8):"bottom"===i?(f=0,y=r-o.bottom+50):(f=n-o.right+10,y=o.top),g.createElement("g",{transform:`translate(${f}, ${y})`},function(t){return"object"==typeof t&&null!==t&&"gradient"in t}(e)?g.createElement(dt,{config:e.gradient,orientation:d?"horizontal":"vertical",width:d?n:100}):function(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}(e)?g.createElement(ft,{legendGroups:e.legendGroups,title:"",width:d?n:100,orientation:d?"horizontal":"vertical",customHoverBehavior:a,customClickBehavior:s,highlightedCategory:c,isolatedCategories:u,legendInteraction:h}):e)}function gt(t){return"string"==typeof t?{type:t}:t}function pt({orient:e,config:n,values:r,scale:o,size:i,length:a}){const s=function(t){var e,n,r,o,i;return{type:t.type,bins:null!==(e=t.bins)&&void 0!==e?e:20,fill:null!==(n=t.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(r=t.fillOpacity)&&void 0!==r?r:.5,stroke:null!==(o=t.stroke)&&void 0!==o?o:"none",strokeWidth:null!==(i=t.strokeWidth)&&void 0!==i?i:1}}(n),c="top"===e||"bottom"===e,u=t.useMemo(()=>{if(0===r.length)return null;const t=o.domain(),n=i-8;if("boxplot"===s.type){const t=function(t){const e=[...t].sort((t,e)=>t-e),n=e.length;if(0===n)return null;const r=e[Math.floor(.25*n)],o=e[Math.floor(.5*n)],i=e[Math.floor(.75*n)],l=i-r;return{q1:r,median:o,q3:i,whiskerLow:Math.max(e[0],r-1.5*l),whiskerHigh:Math.min(e[n-1],i+1.5*l)}}(r);if(!t)return null;const{q1:i,median:l,q3:a,whiskerLow:u,whiskerHigh:h}=t,d=Math.min(.5*n,20),f=(n-d)/2+4;if(c){const t=o(i),n=o(a),r=o(l),c=o(u),y=o(h),p="top"===e?-1:1,m=0;return g.createElement("g",{"data-testid":"marginal-boxplot-"+e},g.createElement("line",{x1:c,y1:m+p*(f+d/2),x2:y,y2:m+p*(f+d/2),stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:c,y1:m+p*f,x2:c,y2:m+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:y,y1:m+p*f,x2:y,y2:m+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("rect",{x:Math.min(t,n),y:"top"===e?m-f-d:m+f,width:Math.abs(n-t),height:d,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:r,y1:"top"===e?m-f-d:m+f,x2:r,y2:"top"===e?m-f:m+f+d,stroke:s.fill,strokeWidth:2}))}{const t=o(i),n=o(a),r=o(l),c=o(u),y=o(h),p="left"===e?-1:1,m=0;return g.createElement("g",{"data-testid":"marginal-boxplot-"+e},g.createElement("line",{x1:m+p*(f+d/2),y1:c,x2:m+p*(f+d/2),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:m+p*f,y1:c,x2:m+p*(f+d),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:m+p*f,y1:y,x2:m+p*(f+d),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("rect",{x:"left"===e?m-f-d:m+f,y:Math.min(t,n),width:d,height:Math.abs(n-t),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:"left"===e?m-f-d:m+f,y1:r,x2:"left"===e?m-f:m+f+d,y2:r,stroke:s.fill,strokeWidth:2}))}}const u=l.bin().domain(t).thresholds(s.bins)(r);if(0===u.length)return null;const h=Math.max(...u.map(t=>t.length));if(0===h)return null;if("histogram"===s.type)return g.createElement("g",{"data-testid":"marginal-histogram-"+e},u.map((t,r)=>{if(null==t.x0||null==t.x1)return null;const i=t.length/h*n;if(c){const n=o(t.x0),l=o(t.x1)-o(t.x0);return g.createElement("rect",{key:r,x:n,y:"top"===e?-4-i:4,width:Math.max(l,.5),height:i,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}{const n=o(t.x0),l=o(t.x1)-o(t.x0);return g.createElement("rect",{key:r,x:"left"===e?-4-i:4,y:Math.min(n,n+l),width:i,height:Math.abs(l),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}}));if("violin"===s.type){const t=n/2+4,r=[];for(const i of u){if(null==i.x0||null==i.x1)continue;const l=i.length/h*(n/2),a=o((i.x0+i.x1)/2);r.push(c?`${a},${"top"===e?-(t-l):t-l}`:`${"left"===e?-(t-l):t-l},${a}`)}for(let i=u.length-1;i>=0;i--){const l=u[i];if(null==l.x0||null==l.x1)continue;const a=l.length/h*(n/2),s=o((l.x0+l.x1)/2);r.push(c?`${s},${"top"===e?-(t+a):t+a}`:`${"left"===e?-(t+a):t+a},${s}`)}return g.createElement("g",{"data-testid":"marginal-violin-"+e},g.createElement("polygon",{points:r.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}if("ridgeline"===s.type){const t=[];if(c){const r=0,i=null!=u[0].x0?o(u[0].x0):0;t.push(`M${i},${r}`);for(const r of u){if(null==r.x0||null==r.x1)continue;const i=r.length/h*n,l=o((r.x0+r.x1)/2);t.push(`L${l},${"top"===e?-i-4:i+4}`)}const l=null!=u[u.length-1].x1?o(u[u.length-1].x1):a;t.push(`L${l},${r}`),t.push("Z")}else{const r=0,i=null!=u[0].x0?o(u[0].x0):0;t.push(`M${r},${i}`);for(const r of u){if(null==r.x0||null==r.x1)continue;const i=r.length/h*n,l=o((r.x0+r.x1)/2);t.push(`L${"left"===e?-i-4:i+4},${l}`)}const l=null!=u[u.length-1].x1?o(u[u.length-1].x1):a;t.push(`L${r},${l}`),t.push("Z")}return g.createElement("g",{"data-testid":"marginal-ridgeline-"+e},g.createElement("path",{d:t.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}return null},[r,o,s,i,a,e,c,4]);return u?g.createElement("g",{className:"marginal-"+e,"data-testid":"marginal-"+e},u):null}function mt(t,e=120,n=8){if(!t)return[];const r=Math.max(1,Math.floor(e/n)),o=t.split(/\s+/),i=[];let l="";for(const t of o)l&&l.length+1+t.length>r?(i.push(l),l=t):l=l?`${l} ${t}`:t;return l&&i.push(l),i}function vt(t,e,n,r){return"curly"===t?r?`M0,0 C${.6*n},0 ${.4*n},${e/2} ${n},${e/2} C${.4*n},${e/2} ${.6*n},${e} 0,${e}`:`M0,0 C0,${.6*n} ${e/2},${.4*n} ${e/2},${n} C${e/2},${.4*n} ${e},${.6*n} ${e},0`:r?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function xt(t){const{x:e=0,y:n=0,dx:r,dy:o,nx:i,ny:l,note:a,connector:s,subject:c,type:u,color:h,className:d,disable:f,events:y={},"data-testid":p}=t,m=new Set(Array.isArray(f)?f:[]);let v=r||0,x=o||0;null!=i&&(v=i-e),null!=l&&(x=l-n);const b="string"==typeof u?u:"label";if("bracket"===b&&c&&0===v&&0===x)if(void 0!==c.width){v=c.width/2;const t=c.depth||30;x=t+(0>t?-5:5)}else if(void 0!==c.height){const t=c.depth||30;v=t+(0>t?-5:5),x=c.height/2}return g.createElement("g",Object.assign({className:("annotation "+(d||"")).trim(),transform:`translate(${e},${n})`,"data-testid":p},y),!m.has("connector")&&function(t,e,n,r,o,i){const l=[];let a=0,s=0;if("callout-circle"!==o&&"label"!==o||!(null==i?void 0:i.radius)){if("callout-rect"===o&&i){const n=i.width||0,r=i.height||0;if(n>0||r>0){const o=n/2,i=r/2,l=t-o,c=e-i;if(0!==l||0!==c){const t=Math.abs(l),e=Math.abs(c),u=n/2,h=r/2,d=t*h>e*u?u/t:h/e;a=o+l*d,s=i+c*d}}}else if("bracket"===o&&i){const t=i.width,e=i.height,n=i.depth||30;void 0!==t?(a=t/2,s=n):void 0!==e&&(a=n,s=e/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==t||0!==e)){const r=Math.atan2(e,t);a=Math.cos(r)*n,s=Math.sin(r)*n}}if(Math.sqrt(Math.pow(t-a,2)+Math.pow(e-s,2))>.5&&(l.push(g.createElement("line",{key:"connector-line",x1:a,y1:s,x2:t,y2:e,stroke:r||"currentColor"})),"arrow"===(null==n?void 0:n.end))){const n=10,o=16/180*Math.PI,i=Math.atan2(e-s,t-a);l.push(g.createElement("path",{key:"connector-arrow",d:`M${a},${s}L${a+n*Math.cos(i+o)},${s+n*Math.sin(i+o)}L${a+n*Math.cos(i-o)},${s+n*Math.sin(i-o)}Z`,fill:r||"currentColor",stroke:"none"}))}return g.createElement("g",{className:"annotation-connector"},l)}(v,x,s,h,b,c),!m.has("subject")&&function(t,e,n,r,o){var i;const l=[];switch(t){case"callout-circle":{const t=((null==e?void 0:e.radius)||0)+((null==e?void 0:e.radiusPadding)||0);t>0&&l.push(g.createElement("circle",{key:"subject-circle",r:t,fill:"none",stroke:n||"currentColor"}));break}case"callout-rect":{const t=(null==e?void 0:e.width)||0,r=(null==e?void 0:e.height)||0;(t>0||r>0)&&l.push(g.createElement("rect",{key:"subject-rect",width:t,height:r,fill:"none",stroke:n||"currentColor"}));break}case"callout-custom":(null==e?void 0:e.custom)&&l.push(...Array.isArray(e.custom)?e.custom:[e.custom]);break;case"xy-threshold":{const t=r||0,i=o||0;if(void 0!==(null==e?void 0:e.x)){const r=(e.x||0)-t;l.push(g.createElement("line",{key:"threshold-line",x1:r,y1:(e.y1||0)-i,x2:r,y2:(e.y2||0)-i,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==e?void 0:e.y)){const r=(e.y||0)-i;l.push(g.createElement("line",{key:"threshold-line",x1:(e.x1||0)-t,y1:r,x2:(e.x2||0)-t,y2:r,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==e?void 0:e.x1)||void 0!==(null==e?void 0:e.x2)?l.push(g.createElement("line",{key:"threshold-line",x1:(e.x1||0)-t,y1:0,x2:(e.x2||0)-t,y2:0,stroke:n||"currentColor",strokeDasharray:"5,5"})):void 0===(null==e?void 0:e.y1)&&void 0===(null==e?void 0:e.y2)||l.push(g.createElement("line",{key:"threshold-line",x1:0,y1:(e.y1||0)-i,x2:0,y2:(e.y2||0)-i,stroke:n||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const t=null!==(i=null==e?void 0:e.width)&&void 0!==i?i:null==e?void 0:e.height;void 0!==t&&l.push(g.createElement("path",{key:"bracket-path",d:vt((null==e?void 0:e.type)||"curly",t,(null==e?void 0:e.depth)||30,void 0===(null==e?void 0:e.width)),fill:"none",stroke:n||"currentColor"}));break}}return g.createElement("g",{className:"annotation-subject"},l)}(b,c,h,e,n),!m.has("note")&&function(t,e,n,r){if(!t)return g.createElement("g",{className:"annotation-note"});const{label:o,title:i,orientation:l,align:a,wrap:s=120,noWrap:c}=t;if(!o&&!i)return g.createElement("g",{className:"annotation-note"});let u=l;u||(u=Math.abs(e)>Math.abs(n)?"leftRight":"topBottom");let h=a;h&&"dynamic"!==h||(h="topBottom"===u?0>e?"right":"left":0>n?"bottom":"top");let d="start";"topBottom"===u?"right"===h?d="end":"middle"===h&&(d="middle"):d=0>e?"end":"start";const f=16,y=i?c?[i]:mt(i,s):[],p=o?c?[o]:mt(o,s):[],m="leftRight"===u?"end"===d?-4:4:0;let v=0;const x=[];y.length>0&&(x.push(g.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:r||void 0,textAnchor:d,fontWeight:"bold"},y.map((t,e)=>g.createElement("tspan",{key:e,x:m,dy:0===e?0:f},t)))),v=y.length*f),p.length>0&&x.push(g.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:r||void 0,textAnchor:d,y:v},p.map((t,e)=>g.createElement("tspan",{key:e,x:m,dy:0===e?0:f},t))));let b=null;if((i||o)&&(0!==e||0!==n))if("topBottom"===u){const t=Math.min(s,120);let e=0,n=t;"end"===d?(e=-t,n=0):"middle"===d&&(e=-t/2,n=t/2),b=g.createElement("line",{className:"note-line",x1:e,x2:n,y1:0,y2:0,stroke:r||"currentColor"})}else{const t=(y.length+p.length)*f+(p.length>0?f:0);let e=0,n=t;"bottom"===h?(e=-t,n=0):"middle"===h&&(e=-t/2,n=t/2),b=g.createElement("line",{className:"note-line",x1:0,x2:0,y1:e,y2:n,stroke:r||"currentColor"})}const k=Math.max(0,y.length+p.length-1)*f;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===h?-(k+f+(p.length>0&&y.length>0?2:0))/2+8:"bottom"===h||0>n?-(k+2):18),g.createElement("g",{className:"annotation-note",transform:`translate(${e},${n})`},g.createElement("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0},x),b)}(a,v,x,h))}function bt(t){var e,n;const{noteData:r}=t,{screenCoordinates:o}=r,i="string"==typeof r.type?r.type:"label",l=r.eventListeners||r.events||{};if(r.coordinates&&o){const t=r.nx||o[0][0]+(null!==(e=r.dx)&&void 0!==e?e:0),l=r.ny||o[0][1]+(null!==(n=r.dy)&&void 0!==n?n:0),a=o.map((e,n)=>{const o=Object.assign({},r,{note:0===n?r.note:{label:""},x:e[0],y:e[1],nx:t,ny:l});return g.createElement(xt,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},o,{type:i}))});return g.createElement("g",null,a)}const a=r.note||{title:"none",label:r.label};return g.createElement(xt,Object.assign({"data-testid":"semiotic-annotation",key:`${a.label}-${a.title}-${r.i}`,events:l},r,{type:i}))}function kt(t,e){var n,r,o;const i=null!==(r=null===(n=e.scales)||void 0===n?void 0:n.x)&&void 0!==r?r:null===(o=e.scales)||void 0===o?void 0:o.time;return i?null!=t.x?i(t.x):e.xAccessor&&null!=t[e.xAccessor]?i(t[e.xAccessor]):null:null}function wt(t,e){var n,r,o;const i=null!==(r=null===(n=e.scales)||void 0===n?void 0:n.y)&&void 0!==r?r:null===(o=e.scales)||void 0===o?void 0:o.value;return i?null!=t.y?i(t.y):e.yAccessor&&null!=t[e.yAccessor]?i(t[e.yAccessor]):null:null}function Et(t,e,n){var r,o,i,l;const a=t.anchor||"fixed";if("latest"===a){if(null!=t.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const i=n.pointNodes[o];if(i.pointId===t.pointId){const t={x:i.x,y:i.y};return null===(r=n.stickyPositionCache)||void 0===r||r.set(e,t),t}}const i=function(t){var e,n,r,o,i,l;const a=t.data;if(!a||0===a.length)return null;const s=a[a.length-1],c=null!==(n=null===(e=t.scales)||void 0===e?void 0:e.x)&&void 0!==n?n:null===(r=t.scales)||void 0===r?void 0:r.time,u=null!==(i=null===(o=t.scales)||void 0===o?void 0:o.y)&&void 0!==i?i:null===(l=t.scales)||void 0===l?void 0:l.value;if(!c||!u)return null;const h=s[t.xAccessor||"x"],d=s[t.yAccessor||"y"];return null==h||null==d?null:{x:c(h),y:u(d)}}(n);return i&&(null===(o=n.stickyPositionCache)||void 0===o||o.set(e,i)),i}let s=null,c=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);e&&(s=e.x,c=e.y)}if(null!=s&&null!=c||(s=kt(t,n),c=wt(t,n)),null!=s&&null!=c)return null===(i=n.stickyPositionCache)||void 0===i||i.set(e,{x:s,y:c}),{x:s,y:c};if("sticky"===a){const t=null===(l=n.stickyPositionCache)||void 0===l?void 0:l.get(e);if(t)return t}return null}function At(t,e,n,r=50){return!(-r>t||t>(n.width||0)+r||-r>e||e>(n.height||0)+r)}const Mt={linear:s.curveLinear,monotoneX:s.curveMonotoneX,monotoneY:s.curveMonotoneY,step:s.curveStep,stepAfter:s.curveStepAfter,stepBefore:s.curveStepBefore,basis:s.curveBasis,cardinal:s.curveCardinal,catmullRom:s.curveCatmullRom};let St={positions:new Map};const _t=new Set;function Pt(){for(const t of _t)t()}function Ct(t,e){const n=St.positions.get(t);if(!n||n.sourceId!==e)return;const r=new Map(St.positions);r.delete(t),St={positions:r},Pt()}function Dt(){return St}function Lt(t){return _t.add(t),()=>_t.delete(t)}const Tt={positions:new Map};function Nt(){return()=>{}}function $t(){return Tt}function Ot(t,e,n){if("left"===t||"right"===t){const r="left"===t?n:0,o="left"===t?-1:1,i=Math.ceil(e/8);let l="M0,"+r;for(let t=0;i>t;t++){const n=8*(t+1);l+=`L${Math.min(8*t+4,e)},${r+4*o}`,l+=`L${Math.min(n,e)},${r}`}return l}{const r="bottom"===t?0:e,o="bottom"===t?1:-1,i=Math.ceil(n/8);let l=`M${r},0`;for(let t=0;i>t;t++){const e=8*(t+1);l+=`L${r+4*o},${Math.min(8*t+4,n)}`,l+=`L${r},${Math.min(e,n)}`}return l}}function Wt(e){const{width:n,height:r,totalWidth:o,totalHeight:i,margin:l,scales:a,showAxes:s,axes:c,showGrid:u,xFormat:h,yFormat:d}=e,f=t.useMemo(()=>{var t;if(!a)return[];const e=null==c?void 0:c.find(t=>"bottom"===t.orient),r=(null==e?void 0:e.tickFormat)||h||It,o=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,i=a.x.ticks(Math.min(o,Math.max(2,Math.floor(n/70)))),l=i.map(t=>t.valueOf()),s=i.map((t,e)=>({value:t,pixel:a.x(t),label:r(t,e,l)})),u=s.reduce((t,e)=>Math.max(t,6.5*e.label.length),0);return zt(s,Math.max(55,u+8))},[a,c,h,n]),y=t.useMemo(()=>{var t;if(!a)return[];const e=null==c?void 0:c.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||d||It,o=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return zt(a.y.ticks(Math.min(o,Math.max(2,Math.floor(r/30)))).map(t=>({value:t,pixel:a.y(t),label:n(t)})),22)},[a,c,d,r]),p=u&&a,m=s&&a;if(!p&&!m)return null;const v=null==c?void 0:c.find(t=>"bottom"===t.orient),x=null==c?void 0:c.find(t=>"left"===t.orient),b=m&&(!v||!1!==v.baseline),k=m&&(!x||!1!==x.baseline),w=(null==v?void 0:v.jaggedBase)||!1,E=(null==x?void 0:x.jaggedBase)||!1,A="var(--semiotic-border, #ccc)";return g.createElement("svg",{width:o,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},g.createElement("g",{transform:`translate(${l.left},${l.top})`},p&&g.createElement("g",{className:"stream-grid"},f.map((t,e)=>g.createElement("line",{key:"xgrid-"+e,x1:t.pixel,y1:0,x2:t.pixel,y2:r,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),y.map((t,e)=>g.createElement("line",{key:"ygrid-"+e,x1:0,y1:t.pixel,x2:n,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),b&&!w&&g.createElement("line",{x1:0,y1:r,x2:n,y2:r,stroke:A,strokeWidth:1}),w&&g.createElement("path",{d:Ot("bottom",n,r),fill:"none",stroke:A,strokeWidth:1}),k&&!E&&g.createElement("line",{x1:0,y1:0,x2:0,y2:r,stroke:A,strokeWidth:1}),E&&g.createElement("path",{d:Ot("left",n,r),fill:"none",stroke:A,strokeWidth:1})))}function It(t,e,n){return Math.round(100*t)/100+""}function zt(t,e){if(2>=t.length)return t;const n=[t[0]];for(let r=1;t.length-1>r;r++)e>Math.abs(t[r].pixel-n[n.length-1].pixel)||n.push(t[r]);const r=t[t.length-1];return e>Math.abs(r.pixel-n[n.length-1].pixel)?n[n.length-1]=r:n.push(r),n}function Rt(t,e){return t instanceof Date&&(!(e&&e instanceof Date)||t.getFullYear()!==e.getFullYear()||t.getMonth()!==e.getMonth()||t.getDate()!==e.getDate())}function Bt(e){var n,r;const{width:o,height:i,totalWidth:l,totalHeight:c,margin:u,scales:h,showAxes:d,axes:f,xLabel:y,yLabel:m,yLabelRight:v,xFormat:x,yFormat:b,showGrid:k,title:w,legend:E,legendHoverBehavior:A,legendClickBehavior:M,legendHighlightedCategory:S,legendIsolatedCategories:_,legendPosition:P="right",foregroundGraphics:C,marginalGraphics:D,xValues:L,yValues:T,annotations:N,svgAnnotationRules:$,xAccessor:O,yAccessor:W,annotationData:I,pointNodes:z,curve:R,underlayRendered:B,linkedCrosshairName:j,linkedCrosshairSourceId:F,children:Y}=e,H=t.useMemo(()=>{var t;if(!d||!h)return[];const e=null==f?void 0:f.find(t=>"bottom"===t.orient),n=(null==e?void 0:e.tickFormat)||x||It,r=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,i=h.x.ticks(Math.min(r,Math.max(2,Math.floor(o/70)))),l=i.map(t=>t.valueOf()),a=i.map((t,e)=>({value:t,pixel:h.x(t),label:n(t,e,l)})),s=a.reduce((t,e)=>Math.max(t,6.5*e.label.length),0);return zt(a,Math.max(55,s+8))},[d,h,f,x,o]),X=t.useMemo(()=>{var t;if(!d||!h)return[];const e=null==f?void 0:f.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||b||It,r=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return zt(h.y.ticks(Math.min(r,Math.max(2,Math.floor(i/30)))).map(t=>({value:t,pixel:h.y(t),label:n(t)})),22)},[d,h,f,b,i]),G=t.useMemo(()=>{var t;if(!d||!h)return[];const e=null==f?void 0:f.find(t=>"right"===t.orient);if(!e)return[];const n=e.tickFormat||b||It,r=null!==(t=e.ticks)&&void 0!==t?t:5;return zt(h.y.ticks(Math.min(r,Math.max(2,Math.floor(i/30)))).map(t=>({value:t,pixel:h.y(t),label:n(t)})),22)},[d,h,f,b,i]),V=t.useRef(new Map),q=t.useRef(null!==(n=null==N?void 0:N.length)&&void 0!==n?n:0),K=null!==(r=null==N?void 0:N.length)&&void 0!==r?r:0;q.current!==K&&(q.current=K,V.current=new Map);const U=t.useMemo(()=>{if(!N||0===N.length)return null;const t=function(t,e,n){var r,o,i,l,c,u,h,d,f,y,m,v,x,b,k,w,E,A,M,S,_,P,C,D,L,T,N,$,O,W,I,z,R,B,j,F,Y,H,X,G,V,q,K,U,Z,Q,J,tt;switch(t.type){case"label":{const r=Et(t,e,n);if(!r)return null;const{x:o,y:i}=r;return At(o,i,n)?g.createElement(bt,{key:"ann-"+e,noteData:{x:o,y:i,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"label",connector:t.connector||{end:"arrow"},color:t.color}}):null}case"callout":{const r=Et(t,e,n);if(!r)return null;const{x:o,y:i}=r;return At(o,i,n)?g.createElement(bt,{key:"ann-"+e,noteData:{x:o,y:i,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"callout-circle",subject:{radius:t.radius||12},connector:t.connector||{end:"arrow"},color:t.color}}):null}case"x-threshold":{const r=kt(t,n);if(null==r)return null;const o=t.color||"#f97316",i=t.labelPosition||"top";let l;return l="bottom"===i?(n.height||0)-4:"center"===i?(n.height||0)/2:12,g.createElement("g",{key:"ann-"+e},g.createElement("line",{x1:r,y1:0,x2:r,y2:n.height||0,stroke:o,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&g.createElement("text",{x:r+4,y:l,fill:o,fontSize:12,fontWeight:"bold"},t.label))}case"y-threshold":{const r=wt(t,n);if(null==r)return null;const o=t.color||"#f97316",i=t.labelPosition||"right";let l,a;return"left"===i?(l=4,a="start"):"center"===i?(l=(n.width||0)/2,a="middle"):(l=(n.width||0)-4,a="end"),g.createElement("g",{key:"ann-"+e},g.createElement("line",{x1:0,y1:r,x2:n.width||0,y2:r,stroke:o,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&g.createElement("text",{x:l,y:r-4,textAnchor:a,fill:o,fontSize:12,fontWeight:"bold"},t.label))}case"enclose":{const r=(t.coordinates||[]).map(t=>({x:kt(Object.assign(Object.assign({},t),{type:"point"}),n),y:wt(Object.assign(Object.assign({},t),{type:"point"}),n),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const o=a.packEnclose(r),i=t.padding||10;return g.createElement("g",{key:"ann-"+e},g.createElement("circle",{cx:o.x,cy:o.y,r:o.r+i,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&g.createElement("text",{x:o.x,y:o.y-o.r-i-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12},t.label))}case"rect-enclose":{const r=(t.coordinates||[]).map(t=>({x:kt(Object.assign(Object.assign({},t),{type:"point"}),n),y:wt(Object.assign(Object.assign({},t),{type:"point"}),n)})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const o=t.padding||10,i=r.map(t=>t.x),l=r.map(t=>t.y),a=Math.min(...i)-o,s=Math.max(...i)+o,c=Math.min(...l)-o,u=Math.max(...l)+o;return g.createElement("g",{key:"ann-"+e},g.createElement("rect",{x:a,y:c,width:s-a,height:u-c,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&g.createElement("text",{x:(a+s)/2,y:c-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12},t.label))}case"highlight":{const r=n.data||[],o="function"==typeof t.filter?r.filter(t.filter):t.field&&null!=t.value?r.filter(e=>e[t.field]===t.value):[],i={stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return g.createElement("g",{key:"ann-"+e},o.map((e,r)=>{const o=kt(e,n),l=wt(e,n);if(null==o||null==l)return null;const a="function"==typeof t.r?t.r(e):t.r||6,s="function"==typeof t.style?t.style(e):t.style||i;return g.createElement("circle",Object.assign({key:"hl-"+r,cx:o,cy:l,r:a},s))}))}case"bracket":{const r=kt(t,n),o=wt(t,n);return g.createElement(bt,{key:"ann-"+e,noteData:{x:null!=r?r:0,y:null!=o?o:0,dx:t.dx||0,dy:t.dy||0,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"bracket",subject:{type:t.bracketType||"curly",width:t.width,height:t.height,depth:t.depth||30},color:t.color}})}case"trend":{const a=n.data||[];if(2>a.length)return null;const s=n.xAccessor||"x",d=n.yAccessor||"y",f=a.map(t=>[t[s],t[d]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>f.length)return null;const y=null!==(o=null===(r=n.scales)||void 0===r?void 0:r.x)&&void 0!==o?o:null===(i=n.scales)||void 0===i?void 0:i.time,m=null!==(c=null===(l=n.scales)||void 0===l?void 0:l.y)&&void 0!==c?c:null===(u=n.scales)||void 0===u?void 0:u.value;if(!y||!m)return null;const v=t.method||"linear";let x;x="loess"===v?function(t,e=.3){const n=t.length;if(2>n)return t.slice();const r=t.slice().sort((t,e)=>t[0]-e[0]),o=r.map(t=>t[0]),i=r.map(t=>t[1]),l=Math.max(2,Math.ceil(e*n)),a=[];for(let t=0;n>t;t++){const e=o[t],r=o.map(t=>Math.abs(t-e)),s=r.slice().sort((t,e)=>t-e)[Math.min(l-1,n-1)]||1,c=[];for(let t=0;n>t;t++){const e=0===s?0:r[t]/s;c[t]=1>e?Math.pow(1-Math.pow(e,3),3):0}let u=0,h=0,d=0,f=0,y=0;for(let t=0;n>t;t++){const e=c[t];0!==e&&(u+=e,h+=e*o[t],d+=e*i[t],f+=e*o[t]*o[t],y+=e*o[t]*i[t])}if(0===u){a.push([e,i[t]]);continue}const g=u*f-h*h;if(1e-12>Math.abs(g))a.push([e,d/u]);else{const t=(u*y-h*d)/g;a.push([e,(d-t*h)/u+t*e])}}return a}(f,null!==(h=t.bandwidth)&&void 0!==h?h:.3):("polynomial"===v?p.default.polynomial(f,{order:t.order||2}):p.default.linear(f)).points;const b=x.map(([t,e])=>`${y(t)},${m(e)}`).join(" "),k=t.color||"#6366f1";return g.createElement("g",{key:"ann-"+e},g.createElement("polyline",{points:b,fill:"none",stroke:k,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&g.createElement("text",{x:y(x[x.length-1][0])+4,y:m(x[x.length-1][1])-4,fill:k,fontSize:11},t.label))}case"band":{const r=null!==(f=null===(d=n.scales)||void 0===d?void 0:d.y)&&void 0!==f?f:null===(y=n.scales)||void 0===y?void 0:y.value,o=null!==(m=null==r?void 0:r(t.y0))&&void 0!==m?m:0,i=null!==(v=null==r?void 0:r(t.y1))&&void 0!==v?v:n.height||0;return g.createElement("g",{key:"ann-"+e},g.createElement("rect",{x:0,y:Math.min(o,i),width:n.width||0,height:Math.abs(i-o),fill:t.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:t.fillOpacity||.1}),t.label&&g.createElement("text",{x:(n.width||0)-4,y:Math.min(o,i)-4,textAnchor:"end",fill:t.color||"var(--semiotic-primary, #6366f1)",fontSize:11},t.label))}case"envelope":{const r=n.data||[];if(2>r.length)return null;const o=n.xAccessor||"x",i=null!==(b=null===(x=n.scales)||void 0===x?void 0:x.x)&&void 0!==b?b:null===(k=n.scales)||void 0===k?void 0:k.time,l=null!==(E=null===(w=n.scales)||void 0===w?void 0:w.y)&&void 0!==E?E:null===(A=n.scales)||void 0===A?void 0:A.value;if(!i||!l)return null;const a=t.upperAccessor||"upperBounds",c=t.lowerAccessor||"lowerBounds",u=t.filter,h=r.filter(t=>null!=t[a]&&null!=t[c]&&!(u&&!u(t))).sort((t,e)=>t[o]-e[o]);if(2>h.length)return null;const d=Mt[n.curve||"linear"]||s.curveLinear,f=s.area().x(t=>i(t[o])).y0(t=>l(t[c])).y1(t=>l(t[a])).curve(d)(h);if(!f)return null;const y=t.fill||"#6366f1";return g.createElement("g",{key:"ann-"+e},g.createElement("path",{d:f,fill:y,fillOpacity:null!==(M=t.fillOpacity)&&void 0!==M?M:.15,stroke:"none"}),t.label&&h.length>0&&g.createElement("text",{x:i(h[h.length-1][o])+4,y:l(h[h.length-1][a])-4,fill:y,fontSize:11},t.label))}case"anomaly-band":{const r=n.data||[];if(2>r.length)return null;const o=n.yAccessor||"y",i=null!==(_=null===(S=n.scales)||void 0===S?void 0:S.x)&&void 0!==_?_:null===(P=n.scales)||void 0===P?void 0:P.time,l=null!==(D=null===(C=n.scales)||void 0===C?void 0:C.y)&&void 0!==D?D:null===(L=n.scales)||void 0===L?void 0:L.value;if(!i||!l)return null;const a=r.map(t=>t[o]).filter(t=>null!=t&&isFinite(t));if(2>a.length)return null;const s=a.reduce((t,e)=>t+e,0)/a.length,c=a.reduce((t,e)=>t+Math.pow(e-s,2),0)/a.length,u=Math.sqrt(c),h=null!==(T=t.threshold)&&void 0!==T?T:2,d=s-h*u,f=!1!==t.showBand,y=t.fill||"#6366f1",p=null!==(N=t.fillOpacity)&&void 0!==N?N:.1,m=t.anomalyColor||"#ef4444",v=null!==($=t.anomalyRadius)&&void 0!==$?$:6,x=l(s+h*u),b=l(d),k=r.filter(t=>{const e=t[o];return null!=e&&Math.abs(e-s)>h*u});return g.createElement("g",{key:"ann-"+e},f&&g.createElement("rect",{x:0,y:Math.min(x,b),width:n.width||0,height:Math.abs(b-x),fill:y,fillOpacity:p}),k.map((t,e)=>{const r=kt(t,n),o=wt(t,n);return null==r||null==o?null:g.createElement("circle",{key:"anomaly-"+e,cx:r,cy:o,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5})}),t.label&&g.createElement("text",{x:(n.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:y,fontSize:11},t.label))}case"forecast":{const r=n.data||[];if(3>r.length)return null;const o=n.xAccessor||"x",i=n.yAccessor||"y",l=null!==(W=null===(O=n.scales)||void 0===O?void 0:O.x)&&void 0!==W?W:null===(I=n.scales)||void 0===I?void 0:I.time,a=null!==(R=null===(z=n.scales)||void 0===z?void 0:z.y)&&void 0!==R?R:null===(B=n.scales)||void 0===B?void 0:B.value;if(!l||!a)return null;const s=r.map(t=>[t[o],t[i]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>s.length)return null;let c;if("polynomial"===(t.method||"linear")){const e=p.default.polynomial(s,{order:t.order||2}).equation;c=t=>e.reduce((e,n,r)=>e+n*Math.pow(t,r),0)}else{const t=s.length;let e=0,n=0,r=0,o=0;for(const[t,i]of s)e+=t,n+=i,r+=t*t,o+=t*i;const i=t*r-e*e;if(1e-12>Math.abs(i))return null;const l=(t*o-e*n)/i,a=(n-l*e)/t;c=t=>a+l*t}const u=s.length,h=s.map(([t,e])=>e-c(t)).reduce((t,e)=>t+e*e,0),d=Math.sqrt(h/Math.max(u-2,1)),f=s.reduce((t,e)=>t+e[0],0)/u,y=s.reduce((t,e)=>t+Math.pow(e[0]-f,2),0),m=null!==(j=t.confidence)&&void 0!==j?j:.95,v=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,x=null!==(F=t.steps)&&void 0!==F?F:5,b=s[u-1][0],k=(b-s[0][0])/Math.max(u-1,1),w=[];for(let t=1;x>=t;t++)w.push(b+t*k);const E=[];for(const t of w){const e=c(t),n=d*Math.sqrt(1+1/u+(y>0?Math.pow(t-f,2)/y:0))*v;E.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const A=`M${E.map(t=>`${l(t.x)},${a(t.yUpper)}`).join(" L")} L${E.slice().reverse().map(t=>`${l(t.x)},${a(t.yLower)}`).join(" L")} Z`,M=E.map(t=>`${l(t.x)},${a(t.yCenter)}`).join(" "),S=`${l(b)},${a(c(b))}`,_=t.strokeColor||"#6366f1";return g.createElement("g",{key:"ann-"+e},g.createElement("path",{d:A,fill:t.fill||"#6366f1",fillOpacity:null!==(Y=t.fillOpacity)&&void 0!==Y?Y:.15,stroke:"none"}),g.createElement("polyline",{points:`${S} ${M}`,fill:"none",stroke:_,strokeWidth:null!==(H=t.strokeWidth)&&void 0!==H?H:2,strokeDasharray:null!==(X=t.strokeDasharray)&&void 0!==X?X:"6,3"}),t.label&&E.length>0&&g.createElement("text",{x:l(E[E.length-1].x)+4,y:a(E[E.length-1].yCenter)-4,fill:_,fontSize:11},t.label))}case"widget":{let r=null,o=null;if(null!=t.px&&null!=t.py)r=t.px,o=t.py;else{const i=Et(t,e,n);if(!i)return null;r=i.x,o=i.y}if(null==r||null==o)return null;if(!At(r,o,n))return null;const i=null!==(G=t.dx)&&void 0!==G?G:0,l=null!==(V=t.dy)&&void 0!==V?V:0,a=null!==(q=t.width)&&void 0!==q?q:32,s=null!==(K=t.height)&&void 0!==K?K:32,c=null!==(U=t.content)&&void 0!==U?U:g.createElement("span",{style:{fontSize:18,cursor:"default"},title:t.label||"Info"},"ℹ️");return g.createElement("foreignObject",{key:"ann-"+e,x:r+i-a/2,y:o+l-s/2,width:a,height:s,style:{overflow:"visible",pointerEvents:"auto"}},g.createElement("div",{style:{width:a,height:s,display:"flex",alignItems:"center",justifyContent:"center"}},c))}case"text":{const r=Et(t,e,n);if(!r)return null;const{x:o,y:i}=r;return g.createElement("text",{key:"ann-text-"+e,x:o+(t.dx||0),y:i+(t.dy||0),fill:t.color||"var(--semiotic-text, #333)",fontSize:t.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},t.label)}case"category-highlight":{const r=t.category;if(null==r)return null;const o=null===(Z=n.scales)||void 0===Z?void 0:Z.o,i=null===(Q=n.scales)||void 0===Q?void 0:Q.x,l=null===(J=n.scales)||void 0===J?void 0:J.y,a=(null==o?void 0:o.bandwidth)?o:(null==i?void 0:i.bandwidth)?i:(null==l?void 0:l.bandwidth)?l:null;if(!a)return null;const s=a(r);if(null==s)return null;const c=a.bandwidth(),u=t.color||"var(--semiotic-primary, #4589ff)",h=null!==(tt=t.opacity)&&void 0!==tt?tt:.15,d=t.label;return(n.projection?"vertical"===n.projection:a===i)?g.createElement("g",{key:"ann-"+e},g.createElement("rect",{x:s,y:0,width:c,height:n.height||0,fill:u,fillOpacity:h}),d&&g.createElement("text",{x:s+c/2,y:12,textAnchor:"middle",fill:u,fontSize:12,fontWeight:"bold"},d)):g.createElement("g",{key:"ann-"+e},g.createElement("rect",{x:0,y:s,width:n.width||0,height:c,fill:u,fillOpacity:h}),d&&g.createElement("text",{x:12,y:s+c/2,dominantBaseline:"middle",fill:u,fontSize:12,fontWeight:"bold"},d))}default:return null}},e={scales:h?{x:h.x,y:h.y,time:h.x,value:h.y}:null,timeAxis:"x",xAccessor:O,yAccessor:W,width:o,height:i,data:I,frameType:"xy",pointNodes:z,curve:R,stickyPositionCache:V.current};return N.map((n,r)=>{if($){const o=$(n,r,e);return null!=o?o:t(n,r,e)}return t(n,r,e)}).filter(Boolean)},[N,$,o,i,O,W,I,h,z,R]),Z=function(e){var n;const r=t.useSyncExternalStore(e?Lt:Nt,e?Dt:$t,e?Dt:$t);return e&&null!==(n=r.positions.get(e))&&void 0!==n?n:null}(j);return d||w||E||C||D||U&&U.length>0||k||Y||Z?g.createElement("svg",{role:"img",width:l,height:c,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"}},g.createElement("title",null,"string"==typeof w?w:"XY Chart"),g.createElement("desc",null,"string"==typeof w?w+" — XY data visualization":"XY data visualization"),g.createElement("g",{transform:`translate(${u.left},${u.top})`},k&&h&&!B&&g.createElement("g",{className:"stream-grid"},H.map((t,e)=>g.createElement("line",{key:"xgrid-"+e,x1:t.pixel,y1:0,x2:t.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),X.map((t,e)=>g.createElement("line",{key:"ygrid-"+e,x1:0,y1:t.pixel,x2:o,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),d&&h&&(()=>{const t=null==f?void 0:f.find(t=>"left"===t.orient),e=null==f?void 0:f.find(t=>"bottom"===t.orient),n=!t||!1!==t.baseline,r=(null==t?void 0:t.jaggedBase)||!1,l=(null==e?void 0:e.jaggedBase)||!1,a=null==e?void 0:e.landmarkTicks,s=null==t?void 0:t.landmarkTicks,c="var(--semiotic-border, #ccc)",h="var(--semiotic-text-secondary, var(--semiotic-text, #666))",d="var(--semiotic-text, #333)";return g.createElement("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},!B&&(!e||!1!==e.baseline)&&!l&&g.createElement("line",{x1:0,y1:i,x2:o,y2:i,stroke:c,strokeWidth:1}),!B&&l&&g.createElement("path",{d:Ot("bottom",o,i),fill:"none",stroke:c,strokeWidth:1}),H.map((t,e)=>{const n=!!a&&("function"==typeof a?a(t.value,e):Rt(t.value,e>0?H[e-1].value:void 0));return g.createElement("g",{key:"xtick-"+e,transform:`translate(${t.pixel},${i})`},g.createElement("line",{y2:5,stroke:c,strokeWidth:1}),g.createElement("text",{y:18,textAnchor:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:h,style:{userSelect:"none"}},t.label))}),y&&g.createElement("text",{x:o/2,y:i+40,textAnchor:"middle",fontSize:12,fill:d,style:{userSelect:"none"}},y),!B&&n&&!r&&g.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:c,strokeWidth:1}),!B&&r&&g.createElement("path",{d:Ot("left",o,i),fill:"none",stroke:c,strokeWidth:1}),X.map((t,e)=>{const n=!!s&&("function"==typeof s?s(t.value,e):Rt(t.value,e>0?X[e-1].value:void 0));return g.createElement("g",{key:"ytick-"+e,transform:`translate(0,${t.pixel})`},g.createElement("line",{x2:-5,stroke:c,strokeWidth:1}),g.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:h,style:{userSelect:"none"}},t.label))}),(()=>{const e=(null==t?void 0:t.label)||m;return e?g.createElement("text",{x:15-u.left,y:i/2,textAnchor:"middle",fontSize:12,fill:d,transform:`rotate(-90, ${15-u.left}, ${i/2})`,style:{userSelect:"none"}},e):null})(),(()=>{const t=null==f?void 0:f.find(t=>"right"===t.orient);if(!t||0===G.length)return null;const e=t.landmarkTicks,n=t.label||v;return g.createElement(g.Fragment,null,!1!==t.baseline&&g.createElement("line",{x1:o,y1:0,x2:o,y2:i,stroke:c,strokeWidth:1}),G.map((t,n)=>{const r=!!e&&("function"==typeof e?e(t.value,n):Rt(t.value,n>0?G[n-1].value:void 0));return g.createElement("g",{key:"ytick-r-"+n,transform:`translate(${o},${t.pixel})`},g.createElement("line",{x2:5,stroke:c,strokeWidth:1}),g.createElement("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:r?11:10,fontWeight:r?600:400,fill:h,style:{userSelect:"none"}},t.label))}),n&&g.createElement("text",{x:o+u.right-15,y:i/2,textAnchor:"middle",fontSize:12,fill:d,transform:`rotate(90, ${o+u.right-15}, ${i/2})`,style:{userSelect:"none"}},n))})())})(),U,D&&h&&L&&T&&g.createElement(g.Fragment,null,D.top&&g.createElement("g",{transform:"translate(0, 0)"},g.createElement(pt,{orient:"top",config:gt(D.top),values:L,scale:h.x,size:u.top,length:o})),D.bottom&&g.createElement("g",{transform:`translate(0, ${i})`},g.createElement(pt,{orient:"bottom",config:gt(D.bottom),values:L,scale:h.x,size:u.bottom,length:o})),D.left&&g.createElement("g",{transform:"translate(0, 0)"},g.createElement(pt,{orient:"left",config:gt(D.left),values:T,scale:h.y,size:u.left,length:i})),D.right&&g.createElement("g",{transform:`translate(${o}, 0)`},g.createElement(pt,{orient:"right",config:gt(D.right),values:T,scale:h.y,size:u.right,length:i}))),C,Z&&Z.sourceId!==F&&(null==h?void 0:h.x)&&(()=>{const t=h.x(Z.xValue);return null==t||0>t||t>o?null:g.createElement("line",{x1:t,y1:0,x2:t,y2:i,stroke:"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:1,strokeDasharray:"4,4",pointerEvents:"none"})})(),Y),w&&g.createElement("text",{x:l/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof w?w:null),yt({legend:E,totalWidth:l,totalHeight:c,margin:u,legendPosition:P,title:w,legendHoverBehavior:A,legendClickBehavior:M,legendHighlightedCategory:S,legendIsolatedCategories:_})):null}function jt(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}const Ft="undefined"==typeof window||"undefined"==typeof document,Yt=g.createContext(null);function Ht(){return g.useContext(Yt)}const Xt={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Gt(t,e){if(!t||0===t.length)return e+", empty";const n={};for(const e of t)n[e.type]=(n[e.type]||0)+1;const r=[],o={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},i=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],l=Object.keys(n).sort((t,e)=>{const n=i.indexOf(t),r=i.indexOf(e);return(-1===n?999:n)-(-1===r?999:r)});for(const t of l)r.push(`${n[t]} ${o[t]||t}`);return`${e}, ${r.join(", ")}`}function Vt(t,e,n){const r=[];return t>0&&r.push(t+" nodes"),e>0&&r.push(e+" edges"),0===r.length?n+", empty":`${n}, ${r.join(", ")}`}const qt=t=>{if(null==t)return"";const e=Math.round(100*t)/100;return Number.isNaN(e)?"":e+""},Kt={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},Ut={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},Zt={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},Qt={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Jt={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},te={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},ee={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function ne({scene:t,chartType:e,tableId:n,chartTitle:r}){var o;const[i,l]=g.useState(!1),a=Ht(),s=null!==(o=null==a?void 0:a.visible)&&void 0!==o&&o,c=i||s,u=g.useRef(null),h=r?"Data summary for "+r:n?`Data summary for ${e} ${n}`:"Data summary for "+e,d=g.useCallback(()=>{i||s||l(!0)},[i,s]),f=g.useCallback(t=>{var e;s||(null===(e=u.current)||void 0===e?void 0:e.contains(t.relatedTarget))||l(!1)},[s]);if(!t||0===t.length)return n?g.createElement("span",{id:n,tabIndex:-1,style:Xt}):null;if(!c)return g.createElement("div",{id:n,tabIndex:-1,onFocus:d,style:Xt,role:"region","aria-label":h},g.createElement("button",{type:"button",onClick:()=>l(!0)},"View data summary (",t.length," elements)"));const y=function(t){var e,n,r,o,i,l,a,s,c,u,h,d,f,y,g,p,m,v,x,b,k,w,E,A,M;const S=[];if(!Array.isArray(t))return S;for(const _ of t)if(_&&"object"==typeof _)try{switch(_.type){case"point":S.push({label:"Point",values:{x:_.x,y:_.y}});break;case"line":{const t=_.path,e=Array.isArray(_.datum)?_.datum:[];if(!Array.isArray(t))break;for(let n=0;t.length>n&&e.length>n;n++){const e=t[n];Array.isArray(e)&&S.push({label:"Line point",values:{x:e[0],y:e[1]}})}break}case"area":{const t=_.topPath,e=Array.isArray(_.datum)?_.datum:[];if(!Array.isArray(t))break;for(let n=0;t.length>n&&e.length>n;n++){const e=t[n];Array.isArray(e)&&S.push({label:"Area point",values:{x:e[0],y:e[1]}})}break}case"rect":{const t=null!=_.datum&&"object"==typeof _.datum?_.datum:{},i=null!==(n=null!==(e=t.category)&&void 0!==e?e:_.group)&&void 0!==n?n:"",l=null!==(o=null!==(r=t.value)&&void 0!==r?r:t.__aggregateValue)&&void 0!==o?o:t.total;S.push({label:"Bar",values:{category:i,value:null!=l?l:""}});break}case"heatcell":S.push({label:"Cell",values:{x:_.x,y:_.y,value:_.value}});break;case"wedge":S.push({label:"Wedge",values:{category:null!==(s=null!==(l=null===(i=_.datum)||void 0===i?void 0:i.category)&&void 0!==l?l:null===(a=_.datum)||void 0===a?void 0:a.label)&&void 0!==s?s:"",value:null!==(u=null===(c=_.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":S.push({label:"Node",values:{id:null!==(d=null===(h=_.datum)||void 0===h?void 0:h.id)&&void 0!==d?d:"",x:null!==(f=_.cx)&&void 0!==f?f:_.x,y:null!==(y=_.cy)&&void 0!==y?y:_.y}});break;case"arc":S.push({label:"Arc",values:{id:null!==(p=null===(g=_.datum)||void 0===g?void 0:g.id)&&void 0!==p?p:"",x:null!==(m=_.cx)&&void 0!==m?m:_.x,y:null!==(v=_.cy)&&void 0!==v?v:_.y}});break;case"candlestick":S.push({label:"Candlestick",values:{x:_.x,open:_.open,high:_.high,low:_.low,close:_.close}});break;case"geoarea":S.push({label:"Region",values:{name:null!==(E=null!==(k=null===(b=null===(x=_.datum)||void 0===x?void 0:x.properties)||void 0===b?void 0:b.name)&&void 0!==k?k:null===(w=_.datum)||void 0===w?void 0:w.name)&&void 0!==E?E:"",value:null!==(M=null===(A=_.datum)||void 0===A?void 0:A.value)&&void 0!==M?M:""}})}}catch(t){}return S}(t),p=function(t){if(!t||0===t.length)return[];const e=new Set;for(const n of t)if(n&&n.values)for(const t of Object.keys(n.values))e.add(t);const n=[];for(const r of e){const e=[],o=new Set;for(const n of t){if(!n||!n.values)continue;const t=n.values[r];null!=t&&""!==t&&("number"==typeof t&&!Number.isNaN(t)&&Number.isFinite(t)?e.push(t):"number"==typeof t||"object"!=typeof t&&"function"!=typeof t&&o.add(t+""))}if(e.length>0){let t=e[0],o=e[0],i=0;for(const n of e)t>n&&(t=n),n>o&&(o=n),i+=n;n.push({name:r,count:e.length,numeric:!0,min:t,max:o,mean:i/e.length})}else if(o.size>0){const t=Array.from(o);n.push({name:r,count:t.length,numeric:!1,uniqueValues:t.slice(0,5)})}}return n}(y),m=function(t,e){const n=[t+" data points."];for(const t of e)if(t.numeric)n.push(`${t.name}: ${qt(t.min)} to ${qt(t.max)}, mean ${qt(t.mean)}.`);else{const e=t.uniqueValues,r=e.length>3?`${e.slice(0,3).join(", ")}… (${t.count} unique)`:e.join(", ");n.push(`${t.name}: ${r}.`)}return n.join(" ")}(y.length,p),v=y.slice(0,5),x=new Set;for(const t of v)for(const e of Object.keys(t.values))x.add(e);const b=Array.from(x);return g.createElement("div",{ref:u,id:n,tabIndex:-1,onBlur:f,style:Kt,role:"region","aria-label":h},g.createElement("button",{type:"button",onClick:()=>{s&&a&&a.setVisible(!1),l(!1)},"aria-label":"Close data summary",style:Zt},"×"),g.createElement("div",{role:"note",style:Ut},m),g.createElement("table",{role:"table","aria-label":"Sample data for "+e,style:Qt},g.createElement("caption",{style:ee},"First ",v.length," of ",y.length," data points"),g.createElement("thead",null,g.createElement("tr",null,g.createElement("th",{style:Jt},"type"),b.map(t=>g.createElement("th",{key:t,style:Jt},t)))),g.createElement("tbody",null,v.map((t,e)=>g.createElement("tr",{key:e},g.createElement("td",{style:te},t.label),b.map(e=>{return g.createElement("td",{key:e,style:te},null==(n=t.values[e])||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":qt(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"");var n}))))))}function re({nodes:t,edges:e,chartType:n,tableId:r,chartTitle:o}){var i,l,a,s,c,u,h,d,f,y,p,m,v,x;const[b,k]=g.useState(!1),w=Ht(),E=null!==(i=null==w?void 0:w.visible)&&void 0!==i&&i,A=b||E,M=o?"Data summary for "+o:r?`Data summary for ${n} ${r}`:"Data summary for "+n,S=g.useRef(null),_=g.useCallback(()=>{b||E||k(!0)},[b,E]),P=g.useCallback(t=>{var e;E||(null===(e=S.current)||void 0===e?void 0:e.contains(t.relatedTarget))||k(!1)},[E]);if(!t||0===t.length)return r?g.createElement("span",{id:r,tabIndex:-1,style:Xt}):null;if(!A)return g.createElement("div",{id:r,tabIndex:-1,onFocus:_,style:Xt,role:"region","aria-label":M},g.createElement("button",{type:"button",onClick:()=>k(!0)},"View data summary (",t.length," nodes, ",e.length," edges)"));const C=Array.isArray(t)?t:[],D=Array.isArray(e)?e:[],L=new Map,T=new Map,N=new Map,$=new Map;for(const t of D){if(!t||"object"!=typeof t)continue;const e=null!==(l=t.datum)&&void 0!==l?l:t,n="object"==typeof e.source?null===(a=e.source)||void 0===a?void 0:a.id:e.source,r="object"==typeof e.target?null===(s=e.target)||void 0===s?void 0:s.id:e.target,o="number"==typeof e.value&&Number.isFinite(e.value)?e.value:0;if(null!=n&&""!==n){const t=n+"";T.set(t,(null!==(c=T.get(t))&&void 0!==c?c:0)+1),$.set(t,(null!==(u=$.get(t))&&void 0!==u?u:0)+o)}if(null!=r&&""!==r){const t=r+"";L.set(t,(null!==(h=L.get(t))&&void 0!==h?h:0)+1),N.set(t,(null!==(d=N.get(t))&&void 0!==d?d:0)+o)}}const O=[];for(let t=0;C.length>t;t++){const e=C[t];if(!e||"object"!=typeof e)continue;const n=null!==(y=null===(f=e.datum)||void 0===f?void 0:f.id)&&void 0!==y?y:e.id,r=null!=n?n+"":"node-"+t,o=null!==(p=L.get(r))&&void 0!==p?p:0,i=null!==(m=T.get(r))&&void 0!==m?m:0,l=null!==(v=N.get(r))&&void 0!==v?v:0,a=null!==(x=$.get(r))&&void 0!==x?x:0;O.push({id:r,degree:o+i,inDeg:o,outDeg:i,wDegree:l+a,wInDeg:l,wOutDeg:a})}O.sort((t,e)=>e.degree-t.degree);let W=0,I=0;if(O.length>0){let t=0;for(const e of O)t+=e.degree,e.degree>I&&(I=e.degree);W=t/O.length}const z=D.some(t=>{var e;const n=null!==(e=null==t?void 0:t.datum)&&void 0!==e?e:t;return"number"==typeof(null==n?void 0:n.value)&&Number.isFinite(n.value)}),R=[`${O.length} nodes, ${D.length} edges.`];O.length>0&&R.push(`Mean degree: ${qt(W)}, max degree: ${I}.`);const B=O.slice(0,5);return g.createElement("div",{ref:S,id:r,tabIndex:-1,onBlur:P,style:Kt,role:"region","aria-label":M},g.createElement("button",{type:"button",onClick:()=>{E&&w&&w.setVisible(!1),k(!1)},"aria-label":"Close data summary",style:Zt},"×"),g.createElement("div",{role:"note",style:Ut},R.join(" ")),g.createElement("table",{role:"table","aria-label":"Node degree summary for "+n,style:Qt},g.createElement("caption",{style:ee},"Top ",B.length," of ",O.length," nodes by degree"),g.createElement("thead",null,g.createElement("tr",null,g.createElement("th",{style:Jt},"id"),g.createElement("th",{style:Jt},"degree"),g.createElement("th",{style:Jt},"in"),g.createElement("th",{style:Jt},"out"),z&&g.createElement("th",{style:Jt},"w. degree"),z&&g.createElement("th",{style:Jt},"w. in"),z&&g.createElement("th",{style:Jt},"w. out"))),g.createElement("tbody",null,B.map((t,e)=>g.createElement("tr",{key:e},g.createElement("td",{style:te},t.id),g.createElement("td",{style:te},t.degree),g.createElement("td",{style:te},t.inDeg),g.createElement("td",{style:te},t.outDeg),z&&g.createElement("td",{style:te},qt(t.wDegree)),z&&g.createElement("td",{style:te},qt(t.wInDeg)),z&&g.createElement("td",{style:te},qt(t.wOutDeg)))))))}function oe({summary:t}){return t?g.createElement("div",{role:"note",style:Xt},t):null}function ie({tableId:t}){return g.createElement("a",{href:"#"+t,style:Xt,onClick:e=>{e.preventDefault();const n=document.getElementById(t);n&&requestAnimationFrame(()=>n.focus())},onFocus:t=>{Object.assign(t.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:t=>{const e=t.currentTarget;e.removeAttribute("style"),Object.assign(e.style,Xt)}},"Skip to data table")}function le({hoverPoint:t}){let e="";if(t){const n=t.data||t;e="object"==typeof n?"Focused on data point: "+Object.entries(n).filter(([,t])=>"object"!=typeof t&&"function"!=typeof t).map(([t,e])=>`${t}: ${e}`).join(", "):"Focused on data point: "+n}return g.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:Xt},e)}const ae="var(--semiotic-focus, #005fcc)";function se({active:t,hoverPoint:e,margin:n,size:r,shape:o="circle",width:i,height:l}){if(!t||!e)return null;const a=e.x+n.left,s=e.y+n.top;let c;if("rect"===o&&null!=i&&null!=l){const t=Math.max(i,4),e=Math.max(l,4);c=g.createElement("rect",{x:a-t/2-3,y:s-e/2-3,width:t+6,height:e+6,rx:3,fill:"none",stroke:ae,strokeWidth:2,strokeDasharray:"4,2"})}else c=g.createElement("circle","wedge"===o?{cx:a,cy:s,r:12,fill:"none",stroke:ae,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:a,cy:s,r:8,fill:"none",stroke:ae,strokeWidth:2,strokeDasharray:"4,2"});return g.createElement("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true"},c)}function ce({x:t,y:e,containerWidth:n,containerHeight:r,margin:o,children:i,className:l="stream-frame-tooltip",zIndex:a=1}){const s=g.useRef(null),[c,u]=g.useState(null);g.useLayoutEffect(()=>{const t=s.current;if(!t)return;const e=t.getBoundingClientRect();u(t=>t&&t.width===e.width&&t.height===e.height?t:{width:e.width,height:e.height})},[i,l,n,r]);let h;return h=c?`translate(${c.width+12>n-t?"calc(-100% - 12px)":"12px"}, ${c.height+12>r-e?"calc(-100% - 4px)":"4px"})`:`translate(${t>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*r>e?"4px":"calc(-100% - 4px)"})`,g.createElement("div",{ref:s,className:l,style:{position:"absolute",left:o.left+t,top:o.top+e,transform:h,pointerEvents:"none",zIndex:a,width:"max-content"}},i)}function ue(){const[e,n]=t.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return t.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const t=window.matchMedia("(prefers-reduced-motion: reduce)");return n(t.matches),function(t,e){return"function"==typeof t.addEventListener?(t.addEventListener("change",e),()=>t.removeEventListener("change",e)):(t.addListener(e),()=>t.removeListener(e))}(t,t=>n(t.matches))},[]),e}function he(e){const n=t.createContext(null),r=de(e);return[function({children:r}){const o=t.useMemo(()=>de(e),[]);return g.createElement(n.Provider,{value:o,children:r})},e=>{var o;const i=null!==(o=t.useContext(n))&&void 0!==o?o:r,l=t.useRef(e);l.current=e;const a=t.useCallback(()=>l.current(i.getState()),[i]),s=t.useCallback(()=>l.current(i.getState()),[i]);return t.useSyncExternalStore(i.subscribe,a,s)}]}function de(t){const e=new EventTarget;let n=t(function(t){n=Object.assign(Object.assign({},n),t(n)),e.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(t){return e.addEventListener("update",t),()=>e.removeEventListener("update",t)}}}const fe={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},ye={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},ge={mode:"light",colors:{primary:"#0000cc",categorical:["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],sequential:"blues",diverging:"RdBu",background:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"},[pe,me]=he(t=>({theme:fe,setTheme(e){t(t=>{if("light"===e)return{theme:fe};if("dark"===e)return{theme:ye};if("high-contrast"===e)return{theme:ge};if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?ye:fe;return{theme:Object.assign(Object.assign(Object.assign({},t),e),{colors:Object.assign(Object.assign({},t.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.typography),e.typography||{})})}}return{theme:Object.assign(Object.assign(Object.assign({},t.theme),e),{colors:Object.assign(Object.assign({},t.theme.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.theme.typography),e.typography||{})})}})}}));function ve(t,e,n,r){const o=t.getContext("2d");if(!o)return null;const i=e[0]*r,l=e[1]*r,a=e[0]+"px",s=e[1]+"px";return t.style.width!==a&&(t.style.width=a),t.style.height!==s&&(t.style.height=s),t.width===i&&t.height===l||(t.width=i,t.height=l),o.setTransform(r,0,0,r,0,0),o.translate(n.left,n.top),o}function xe(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function be(t){switch(t){case"monotoneX":return s.curveMonotoneX;case"monotoneY":return s.curveMonotoneY;case"cardinal":return s.curveCardinal;case"catmullRom":return s.curveCatmullRom;case"step":return s.curveStep;case"stepBefore":return s.curveStepBefore;case"stepAfter":return s.curveStepAfter;case"basis":return s.curveBasis;case"natural":return s.curveNatural;default:return null}}function ke(t,e,n){let r=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(r=n.color):t>n.value&&(r=n.color);return r}function we(t,e,n,r,o,i){if(2>e.length)return;const l=[0];for(let t=1;e.length>t;t++){const n=e[t][0]-e[t-1][0],r=e[t][1]-e[t-1][1];l.push(l[t-1]+Math.sqrt(n*n+r*r))}const a=l[l.length-1];if(0===a)return;const s=Math.min(.2*a,40);t.strokeStyle=n,t.lineWidth=r,t.lineCap=i;for(let n=0;e.length-1>n;n++){const r=(l[n]+l[n+1])/2;let i=o;s>r&&(i*=r/s),s>a-r&&(i*=(a-r)/s),t.globalAlpha=Math.max(0,i),t.beginPath(),t.moveTo(e[n][0],e[n][1]),t.lineTo(e[n+1][0],e[n+1][1]),t.stroke()}}function Ee(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function Ae(t,e,n=.3){Ee(e)&&(t.globalAlpha=e._pulseIntensity*n,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h))}function Me(t,e,n=.6){var r,o,i,l,a;if(!Ee(e))return;const s=null!==(r=e._pulseGlowRadius)&&void 0!==r?r:4,c=e.r+s*e._pulseIntensity,u=null!==(i=null!==(o=e.cx)&&void 0!==o?o:e.x)&&void 0!==i?i:0,h=null!==(a=null!==(l=e.cy)&&void 0!==l?l:e.y)&&void 0!==a?a:0;t.beginPath(),t.arc(u,h,c,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=e._pulseIntensity*n,t.stroke()}function Se(t,e,n,r=.35){Ee(e)&&(t.globalAlpha=e._pulseIntensity*r,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill())}function _e(t){switch(t){case"monotoneX":return s.curveMonotoneX;case"monotoneY":return s.curveMonotoneY;case"cardinal":return s.curveCardinal;case"catmullRom":return s.curveCatmullRom;case"step":return s.curveStep;case"stepBefore":return s.curveStepBefore;case"stepAfter":return s.curveStepAfter;case"basis":return s.curveBasis;case"natural":return s.curveNatural;default:return null}}function Pe(t){if(t.startsWith("#")){const e=4===t.length?t[1]+t[1]+t[2]+t[2]+t[3]+t[3]:t.slice(1,7);return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[78,121,167]}function Ce(t,e){const n=_e(e.curve);if(!n||2>e.topPath.length||2>e.bottomPath.length){t.beginPath(),t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1]);for(let n=e.bottomPath.length-1;n>=0;n--)t.lineTo(e.bottomPath[n][0],e.bottomPath[n][1]);t.closePath()}else{const r=s.area().x(t=>t[0]).y0((t,n)=>e.bottomPath[n][1]).y1(t=>t[1]).curve(n).context(t);t.beginPath(),r(e.topPath)}}const De=(t,e,n,r)=>{var o,i,l;const a=e.filter(t=>"area"===t.type);for(const e of a){if(2>e.topPath.length)continue;const n=e.style.fill||"#4e79a7",r=e._decayOpacities;if(r&&r.length===e.topPath.length){const i=null!==(o=e.style.fillOpacity)&&void 0!==o?o:.7;t.fillStyle=n;for(let n=0;e.topPath.length-1>n;n++)t.globalAlpha=.5*(r[n]+r[n+1])*i,t.beginPath(),t.moveTo(e.topPath[n][0],e.topPath[n][1]),t.lineTo(e.topPath[n+1][0],e.topPath[n+1][1]),t.lineTo(e.bottomPath[n+1][0],e.bottomPath[n+1][1]),t.lineTo(e.bottomPath[n][0],e.bottomPath[n][1]),t.closePath(),t.fill();if(e.style.stroke&&"none"!==e.style.stroke){t.strokeStyle=e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);for(let n=0;e.topPath.length-1>n;n++)t.globalAlpha=.5*(r[n]+r[n+1]),t.beginPath(),t.moveTo(e.topPath[n][0],e.topPath[n][1]),t.lineTo(e.topPath[n+1][0],e.topPath[n+1][1]),t.stroke()}t.globalAlpha=1;continue}const a=null!==(i=e.style.opacity)&&void 0!==i?i:1;if(Ce(t,e),e.fillGradient){let r=1/0;for(const t of e.topPath)r>t[1]&&(r=t[1]);let o=-1/0;for(const t of e.bottomPath)t[1]>o&&(o=t[1]);const i=Pe("string"==typeof n?n:"#4e79a7"),l=e.fillGradient.topOpacity,s=e.fillGradient.bottomOpacity,c=t.createLinearGradient(0,r,0,o);c.addColorStop(0,`rgba(${i[0]},${i[1]},${i[2]},${l})`),c.addColorStop(1,`rgba(${i[0]},${i[1]},${i[2]},${s})`),t.fillStyle=c,t.globalAlpha=a}else{const r=null!==(l=e.style.fillOpacity)&&void 0!==l?l:.7;t.globalAlpha=r*a,t.fillStyle=n}if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(Ce(t,e),Se(t,e)),e.style.stroke&&"none"!==e.style.stroke){t.globalAlpha=a,t.strokeStyle=e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);const n=_e(e.curve);if(t.beginPath(),n)s.line().x(t=>t[0]).y(t=>t[1]).curve(n).context(t)(e.topPath);else{t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1])}t.stroke()}t.globalAlpha=1}},Le=(t,e,n,r)=>{var o;const i=e.filter(t=>"point"===t.type);if(0!==i.length){t.save();try{for(const e of i){t.beginPath(),t.arc(e.x,e.y,e.r,0,2*Math.PI);const n=null!==(o=e.style.opacity)&&void 0!==o?o:e.style.fillOpacity;null!=n&&(t.globalAlpha=n),t.fillStyle=e.style.fill||"#4e79a7",t.fill(),e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke()),Me(t,e),t.globalAlpha=1}}finally{t.restore()}}},Te=(t,e,n,r)=>{const o=e.filter(t=>"rect"===t.type);for(const e of o)null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon?Ne(t,e):(t.fillStyle=e.style.fill||"#007bff",t.fillRect(e.x,e.y,e.w,e.h),e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))),Ae(t,e),t.globalAlpha=1};function Ne(t,e){const n=e.style.icon,r=e.style.iconPadding||2,o=Math.min(e.w,e.h)-r;if(0>=o)return;const i=e.h>e.w;if(t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip(),i){const i=o+r,l=e.x+(e.w-o)/2;for(let r=e.y+e.h-o;r>=e.y-o;r-=i)t.drawImage(n,l,r,o,o)}else{const i=o+r,l=e.y+(e.h-o)/2;for(let r=e.x;e.x+e.w>r;r+=i)t.drawImage(n,r,l,o,o)}t.restore()}function $e(t){const[e,n,r]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*r>128?"#000":"#fff"}function Oe(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}const We=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Ie(t){const e=t[1]-t[0],n=3156e7;return 864e5>e?t=>{const e=new Date(t);return`${(e.getUTCHours()+"").padStart(2,"0")}:${(e.getUTCMinutes()+"").padStart(2,"0")}`}:n>e?t=>{const e=new Date(t);return`${We[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*n>e?t=>{const e=new Date(t);return`${We[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}const ze={line:[De,(t,e,n,r)=>{var o,i;const l=e.filter(t=>"line"===t.type);for(const a of l){if(2>a.path.length)continue;const c=a.style.stroke||"#007bff",u=a.style.strokeWidth||2,h=a.colorThresholds,d=a.rawValues;if(t.setLineDash(a.style.strokeDasharray?a.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=a.style.opacity&&(t.globalAlpha=a.style.opacity),t.lineWidth=u,t.lineCap=a.style.strokeLinecap||"butt",a.style._edgeFade){const p=null!==(o=a.style.opacity)&&void 0!==o?o:1;we(t,a.path,c,u,p,a.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const f=be(a.curve),y=h&&h.length>0&&d&&d.length===a.path.length,g=a._decayOpacities;if(g&&g.length===a.path.length&&!y){t.strokeStyle=c;const m=null!==(i=a.style.opacity)&&void 0!==i?i:1;for(let v=0;a.path.length-1>v;v++)t.globalAlpha=.5*(g[v]+g[v+1])*m,t.beginPath(),t.moveTo(a.path[v][0],a.path[v][1]),t.lineTo(a.path[v+1][0],a.path[v+1][1]),t.stroke()}else if(y){let x=null,b=null,k=null,w=null,E=!1;function A(e,n,r){t.beginPath(),t.strokeStyle=e,t.moveTo(n,r),E=!0}function M(){E&&(t.stroke(),E=!1)}for(let S=0;a.path.length>S;S++){const[_,P]=a.path[S],C=d[S],D=ke(C,h,c);if(null!==x&&null!==w&&null!==k){if(D===w)t.lineTo(_,P);else{const L=[];for(const T of h){const N=T.value;(k>N||N>C)&&(N>k||C>N)||k===N||C===N||L.push({t:(N-k)/(C-k)})}L.sort((t,e)=>t.t-e.t);for(const $ of L){const O=x+(_-x)*$.t,W=b+(P-b)*$.t,I=ke(k+(C-k)*Math.min($.t+1e-4,1),h,c);t.lineTo(O,W),M(),A(I,O,W)}t.lineTo(_,P)}x=_,b=P,k=C,w=D}else A(D,_,P),x=_,b=P,k=C,w=D}M()}else{if(t.beginPath(),t.strokeStyle=c,f)s.line().x(t=>t[0]).y(t=>t[1]).curve(f).context(t)(a.path);else{const[z,R]=a.path[0];t.moveTo(z,R);for(let B=1;a.path.length>B;B++)t.lineTo(a.path[B][0],a.path[B][1])}t.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=a.style.fillOpacity,t.fillStyle=a.style.fill,f&&!y)s.line().x(t=>t[0]).y(t=>t[1]).curve(f).context(t)(a.path);else{const[F,Y]=a.path[0];t.moveTo(F,Y);for(let H=1;a.path.length>H;H++)t.lineTo(a.path[H][0],a.path[H][1])}const j=a.path[0][0];t.lineTo(a.path[a.path.length-1][0],r.height),t.lineTo(j,r.height),t.closePath(),t.fill()}t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}},Le],area:[De,Le],stackedarea:[De,Le],scatter:[Le],bubble:[Le],heatmap:[(t,e,n,r)=>{const o=e.filter(t=>"heatcell"===t.type);t.save();try{for(const e of o){const n=e.style;if(null!=(null==n?void 0:n.opacity)&&(t.globalAlpha=n.opacity),t.fillStyle=e.fill,t.fillRect(e.x,e.y,e.w,e.h),t.strokeStyle="#fff",t.lineWidth=1,t.strokeRect(e.x,e.y,e.w,e.h),Ae(t,e),t.globalAlpha=1,e.showValues&&null!=e.value){if(20>e.w||20>e.h)continue;const n=e.valueFormat?e.valueFormat(e.value):Oe(e.value),r=Math.max(10,Math.min(16,.3*Math.min(e.w,e.h))),o=e.x+e.w/2,i=e.y+e.h/2;t.fillStyle=$e(e.fill),t.font=r+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,o,i)}}}finally{t.restore()}}],bar:[Te],swarm:[Le],waterfall:[(t,e,n,r)=>{var o,i,l;Te(t,e);const a=e.filter(t=>"rect"===t.type);if(2>a.length)return;const s=a[0].datum,c=null==s?void 0:s._connectorStroke;if(c){t.save(),t.strokeStyle=c,t.lineWidth=null!==(o=null==s?void 0:s._connectorWidth)&&void 0!==o?o:1,t.setLineDash([]);for(let e=0;a.length-1>e;e++){const r=a[e],o=a[e+1];if(!(null===(i=r.datum)||void 0===i?void 0:i.cumEnd)||!(null===(l=o.datum)||void 0===l?void 0:l.baseline))continue;const s=n.y(r.datum.cumEnd),c=r.x+r.w,u=o.x;t.beginPath(),t.moveTo(c,s),t.lineTo(u,s),t.stroke()}t.restore()}}],candlestick:[(t,e,n,r)=>{for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.save();const r=e._decayOpacity;null!=r&&1!==r&&(t.globalAlpha=r),t.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=e.wickColor,t.lineWidth=e.wickWidth,t.stroke();const o=Math.min(e.openY,e.closeY),i=Math.abs(e.openY-e.closeY),l=e.isUp?e.upColor:e.downColor;t.fillStyle=l,t.fillRect(e.x-e.bodyWidth/2,o,e.bodyWidth,Math.max(i,1)),t.strokeStyle=l,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,o,e.bodyWidth,Math.max(i,1)),t.restore()}}]},Re={top:20,right:20,bottom:30,left:40},Be={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white"},je={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Fe({hover:t}){const e=t=>Number.isInteger(t)?t+"":t.toFixed(2);return g.createElement("div",{className:"semiotic-tooltip",style:je},g.createElement("div",{style:{fontWeight:600,marginBottom:2}},e(t.value)),g.createElement("div",{style:{opacity:.7,fontSize:11}},e(t.time)))}const Ye=t.forwardRef(function(e,n){var r,o,i,l,a,s,c,u,h,d,f;const{chartType:y,runtimeMode:p,data:m,chunkThreshold:v,chunkSize:k,xAccessor:w,yAccessor:E,colorAccessor:A,sizeAccessor:M,groupAccessor:S,lineDataAccessor:_,curve:P,normalize:C,binSize:D,valueAccessor:L,arrowOfTime:T="right",windowMode:N="sliding",windowSize:$=200,timeAccessor:O,xExtent:W,yExtent:I,extentPadding:z=.1,sizeRange:R,size:B=[500,300],responsiveWidth:j,responsiveHeight:F,margin:Y,className:X,background:G,lineStyle:K,pointStyle:tt,areaStyle:ot,waterfallStyle:st,swarmStyle:ct,barColors:ut,colorScheme:ht,boundsAccessor:dt,boundsStyle:ft,y0Accessor:yt,gradientFill:gt,openAccessor:pt,highAccessor:mt,lowAccessor:vt,closeAccessor:xt,candlestickStyle:bt,showAxes:kt=!0,axes:wt,xLabel:Et,yLabel:At,yLabelRight:Mt,xFormat:St,yFormat:_t,tickFormatTime:Pt,tickFormatValue:Ct,hoverAnnotation:Dt,tooltipContent:Lt,customHoverBehavior:Tt,enableHover:Nt,annotations:$t,svgAnnotationRules:Ot,showGrid:It,legend:zt,legendHoverBehavior:Rt,legendClickBehavior:Yt,legendHighlightedCategory:Ht,legendIsolatedCategories:Xt,legendPosition:Vt,backgroundGraphics:qt,foregroundGraphics:Kt,canvasPreRenderers:Ut,svgPreRenderers:Zt,title:Qt,categoryAccessor:Jt,brush:te,onBrush:ee,decay:re,pulse:ae,transition:he,staleness:de,heatmapAggregation:fe,heatmapXBins:ye,heatmapYBins:ge,showValues:pe,heatmapValueFormat:be,marginalGraphics:ke,pointIdAccessor:we,xScaleType:Ee,yScaleType:Ae,accessibleTable:Me=!0,description:Se,summary:_e,linkedCrosshairName:Pe,linkedCrosshairSourceId:Ce}=e,De=ue(),Le=t.useRef(De);Le.current=De;const[Te,Ne]=lt(B,j,F),$e=Object.assign(Object.assign({},Re),Y);if(ke){const t=60;ke.top&&t>$e.top&&($e.top=t),ke.bottom&&t>$e.bottom&&($e.bottom=t),ke.left&&t>$e.left&&($e.left=t),ke.right&&t>$e.right&&($e.right=t)}const Oe=Ne[0]-$e.left-$e.right,We=Ne[1]-$e.top-$e.bottom,je="function"==typeof Kt?Kt({size:Ne,margin:$e}):Kt,Ye="function"==typeof qt?qt({size:Ne,margin:$e}):qt,He=null!=Dt?Dt:Nt,Xe=t.useRef(null),Ge=t.useRef(null),Ve=t.useRef(0),qe=t.useRef(!1),Ke=me(t=>t.theme),[Ue,Ze]=t.useState(0),[Qe,Je]=t.useState(null),tn=t.useRef(null),en=t.useRef(null),[nn,rn]=t.useState(null),[on,ln]=t.useState(!1),[an,sn]=t.useState([]),[cn,un]=t.useState([]),hn=t.useRef(()=>{}),dn="streaming"===p||["bar","swarm","waterfall"].includes(y),fn=t.useMemo(()=>({chartType:y,runtimeMode:dn?"streaming":"bounded",windowSize:$,windowMode:N,arrowOfTime:dn?T:"right",extentPadding:z,xAccessor:dn?void 0:w,yAccessor:dn?void 0:E,timeAccessor:dn?O:void 0,valueAccessor:L,colorAccessor:A,sizeAccessor:M,groupAccessor:S,categoryAccessor:Jt,lineDataAccessor:_,xScaleType:Ee,yScaleType:Ae,xExtent:W,yExtent:I,sizeRange:R,binSize:D,normalize:C,boundsAccessor:dt,boundsStyle:ft,y0Accessor:yt,gradientFill:"boolean"==typeof gt?gt?{topOpacity:.8,bottomOpacity:.05}:void 0:gt,openAccessor:pt,highAccessor:mt,lowAccessor:vt,closeAccessor:xt,candlestickStyle:bt,lineStyle:K,pointStyle:tt,areaStyle:ot,swarmStyle:ct,waterfallStyle:st,colorScheme:ht,barColors:ut,annotations:$t,decay:re,pulse:ae,transition:he,staleness:de,heatmapAggregation:fe,heatmapXBins:ye,heatmapYBins:ge,showValues:pe,heatmapValueFormat:be,pointIdAccessor:we,curve:P}),[y,$,N,T,z,w,E,O,L,Ee,Ae,A,M,S,Jt,_,W,I,R,D,C,dt,ft,yt,gt,pt,mt,vt,xt,bt,K,tt,ot,ct,st,ht,ut,$t,re,ae,he,de,fe,ye,ge,pe,be,dn,we,P]),yn=t.useRef(null);yn.current||(yn.current=new H(fn));const gn=t.useCallback(()=>{Ve.current||(Ve.current=requestAnimationFrame(()=>hn.current()))},[]);t.useEffect(()=>{var t;null===(t=yn.current)||void 0===t||t.updateConfig(fn),qe.current=!0,gn()},[fn,gn]),t.useEffect(()=>{qe.current=!0,gn()},[Ke,gn]);const pn=t.useRef(null);pn.current||(pn.current=new b(t=>{const e=yn.current;e&&e.ingest(t)&&(qe.current=!0,gn())},{chunkThreshold:v,chunkSize:k})),t.useEffect(()=>{var t;null===(t=pn.current)||void 0===t||t.updateChunkOptions({chunkThreshold:v,chunkSize:k})},[v,k]);const mn=t.useCallback(t=>{var e;null===(e=pn.current)||void 0===e||e.push(t)},[]),vn=t.useCallback(t=>{var e;null===(e=pn.current)||void 0===e||e.pushMany(t)},[]),xn=t.useCallback(()=>{var t,e;null===(t=pn.current)||void 0===t||t.clear(),null===(e=yn.current)||void 0===e||e.clear(),qe.current=!0,gn()},[gn]);t.useImperativeHandle(n,()=>({push:mn,pushMany:vn,clear:xn,getData:()=>{var t,e,n;return null===(t=pn.current)||void 0===t||t.flush(),null!==(n=null===(e=yn.current)||void 0===e?void 0:e.getData())&&void 0!==n?n:[]},getScales:()=>{var t,e;return null!==(e=null===(t=yn.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=yn.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[mn,vn,xn]),t.useEffect(()=>{var t;m&&(null===(t=pn.current)||void 0===t||t.setBoundedData(m))},[m]);const bn=t.useRef(()=>{}),kn=t.useRef(()=>{});bn.current=t=>{if(!He)return;const e=Xe.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-$e.left,o=t.clientY-n.top-$e.top;if(0>r||r>Oe||0>o||o>We)return void(tn.current&&(tn.current=null,en.current=null,rn(null),Tt&&(Tt(null),qe.current=!0),gn()));const i=yn.current;if(!i||0===i.scene.length)return;const l=function(t,e,n,r=30,o){let i=null,l=!1;if(o){const t=o.find(e,n,r);if(t){const o=V(t,e,n);o&&r>o.distance&&(i=o,l=!0)}}for(const a of t){let t=null;switch(a.type){case"point":if(o&&l)break;t=V(a,e,n);break;case"line":t=q(a,e,n);break;case"rect":t=U(a,e,n);break;case"heatcell":t=Z(a,e,n);break;case"area":if(!1===a.interactive)break;t=J(a,e,n);break;case"candlestick":t=Q(a,e,n)}t&&r>t.distance&&(i&&t.distance>=i.distance||(i=t))}return i}(i.scene,r,o,30,i.quadtree);if(!l)return void(tn.current&&(tn.current=null,en.current=null,rn(null),Tt&&Tt(null),gn()));const a=l.datum||{},s=Object.assign(Object.assign({},"object"!=typeof a||null===a||Array.isArray(a)?{}:a),{data:a,time:l.x,value:l.y,x:l.x,y:l.y});tn.current=s,en.current=l.node,rn(s),Tt&&(Tt(s),qe.current=!0),gn()},kn.current=()=>{tn.current&&(tn.current=null,en.current=null,rn(null),Tt&&(Tt(null),qe.current=!0),gn())},t.useCallback(t=>bn.current(t),[]);const wn=t.useCallback(()=>kn.current(),[]),En=t.useRef(-1),An=t.useRef(null),Mn=t.useRef(null),Sn=t.useCallback(t=>{const e=yn.current;if(!e||0===e.scene.length)return;const n=e.version;let r;if(Mn.current&&Mn.current.version===n)r=Mn.current.graph;else{const t=function(t){var e,n,r,o;const i=[];for(const l of t)switch(l.type){case"point":i.push({x:l.x,y:l.y,datum:l.datum,shape:"circle",group:null!==(e=l.group)&&void 0!==e?e:"_default"});break;case"line":{const t=l,e=Array.isArray(t.datum)?t.datum:[],r=null!==(n=t.group)&&void 0!==n?n:"_default";for(let n=0;t.path.length>n&&e.length>n;n++)i.push({x:t.path[n][0],y:t.path[n][1],datum:e[n],shape:"circle",group:r});break}case"area":{const t=l,e=Array.isArray(t.datum)?t.datum:[],n=null!==(r=t.group)&&void 0!==r?r:"_default";for(let r=0;t.topPath.length>r&&e.length>r;r++)i.push({x:t.topPath[r][0],y:t.topPath[r][1],datum:e[r],shape:"circle",group:n});break}case"rect":i.push({x:l.x+l.w/2,y:l.y+l.h/2,datum:l.datum,shape:"rect",w:l.w,h:l.h,group:null!==(o=l.group)&&void 0!==o?o:"_default"});break;case"heatcell":i.push({x:l.x+l.w/2,y:l.y+l.h/2,datum:l.datum,shape:"rect",w:l.w,h:l.h,group:"_default"})}return i.sort((t,e)=>t.x-e.x||t.y-e.y),i}(e.scene);if(0===t.length)return;r=et(t),Mn.current={version:n,graph:r}}const o=En.current;if(0>o){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key))return;t.preventDefault(),En.current=0;const e=r.flat[0];An.current={shape:e.shape,w:e.w,h:e.h};const n=it(e);return tn.current=n,rn(n),Tt&&Tt(n),void gn()}const i=nt(r,o),l=rt(t.key,i,r);if(null===l)return;if(t.preventDefault(),0>l)return En.current=-1,An.current=null,tn.current=null,en.current=null,rn(null),Tt&&Tt(null),void gn();En.current=l;const a=r.flat[l];An.current={shape:a.shape,w:a.w,h:a.h};const s=it(a);tn.current=s,rn(s),Tt&&Tt(s),gn()},[Tt,gn]),_n=t.useCallback(t=>{En.current=-1,An.current=null,bn.current(t)},[]);hn.current=()=>{var t,e;Ve.current=0;const n=Xe.current,r=Ge.current;if(!n||!r)return;const o=yn.current;if(!o)return;const i="undefined"!=typeof performance?performance.now():Date.now(),l=o.advanceTransition(Le.current?i+1e6:i),a=!Le.current&&l,s=qe.current||l;s&&!a&&o.computeScene({width:Oe,height:We});const c=xe(),u=function(t){if(!t)return Be;const e=getComputedStyle(t),n=e.getPropertyValue("--semiotic-border").trim(),r=e.getPropertyValue("--semiotic-text-secondary").trim(),o=e.getPropertyValue("--semiotic-bg").trim(),i=r||e.getPropertyValue("--text-secondary").trim(),l=e.getPropertyValue("--text-primary").trim(),a=n||e.getPropertyValue("--surface-3").trim(),s=o||e.getPropertyValue("--surface-0").trim();return i||l||n?{axisStroke:a||Be.axisStroke,tickText:i||Be.tickText,crosshair:i?i+"66":Be.crosshair,hoverFill:s?s+"4D":Be.hoverFill,hoverStroke:i?i+"99":Be.hoverStroke,pointRing:s||Be.pointRing}:Be}(n),h=null!==(t=null==de?void 0:de.threshold)&&void 0!==t?t:5e3,d=de&&o.lastIngestTime>0&&i-o.lastIngestTime>h;if(s){const t=ve(n,Ne,$e,c);if(t){t.clearRect(-$e.left,-$e.top,Ne[0],Ne[1]),d&&(t.globalAlpha=null!==(e=null==de?void 0:de.dimOpacity)&&void 0!==e?e:.5);const r=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=G||(r&&"transparent"!==r?r:null);if(i&&(t.fillStyle=i,t.fillRect(-$e.left,-$e.top,Ne[0],Ne[1])),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,Oe,We),t.clip()),Ut&&o.scales)for(const e of Ut)t.save(),e(t,o.scene,o.scales,{width:Oe,height:We}),t.restore();const l=ze[y];if(l&&o.scales)for(const e of l)e(t,o.scene,o.scales,{width:Oe,height:We});t.restore(),d&&(t.globalAlpha=1)}}{const t=ve(r,Ne,$e,c);if(t&&(t.clearRect(-$e.left,-$e.top,Ne[0],Ne[1]),He&&tn.current&&o.scales&&function(t,e,n,r,o,i,l){var a;if(!1===o.crosshair)return;t.save();const s="object"==typeof o.crosshair?o.crosshair:{};t.strokeStyle=s.stroke||l.crosshair,t.lineWidth=s.strokeWidth||1,t.setLineDash(s.strokeDasharray?s.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(e.x,0),t.lineTo(e.x,r),t.stroke(),t.beginPath(),t.moveTo(0,e.y),t.lineTo(n,e.y),t.stroke(),t.restore();let c="";try{(null===(a=t.canvas)||void 0===a?void 0:a.parentElement)&&(c=getComputedStyle(t.canvas).getPropertyValue("--semiotic-primary").trim())}catch(t){}const u=o.pointColor||function(t){if(!t)return null;if("heatcell"===t.type)return t.fill||null;if("candlestick"===t.type)return t.isUp?t.upColor:t.downColor;const{style:e}=t;if(!e)return null;const n="string"==typeof e.fill?e.fill:null;return"line"===t.type||"area"===t.type?e.stroke||n||null:n||e.stroke||null}(i)||c||"#007bff";t.beginPath(),t.arc(e.x,e.y,4,0,2*Math.PI),t.fillStyle=u,t.fill(),t.strokeStyle=l.pointRing,t.lineWidth=2,t.stroke()}(t,tn.current,Oe,We,"object"==typeof He?He:{},en.current,u),en.current&&Array.isArray(Dt))){const e=Dt.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,n,r){var o;if(!n)return;const i=n.group;if(void 0!==i)for(const n of e){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const e="function"==typeof r.style?r.style(n.datum):r.style||{};t.save(),t.beginPath(),t.moveTo(n.path[0][0],n.path[0][1]);for(let e=1;n.path.length>e;e++)t.lineTo(n.path[e][0],n.path[e][1]);t.strokeStyle=e.stroke||n.style.stroke||"#007bff",t.lineWidth=e.strokeWidth||(n.style.strokeWidth||2)+2,t.globalAlpha=null!==(o=e.opacity)&&void 0!==o?o:1,t.stroke(),t.restore()}}(t,o.scene,en.current,e)}}s&&n&&n.setAttribute("aria-label",Gt(o.scene,y+" chart"));const f=qe.current;if(qe.current=!1,f&&o.scales&&((!Qe||Qe.x.domain()[0]!==o.scales.x.domain()[0]||Qe.x.domain()[1]!==o.scales.x.domain()[1]||Qe.y.domain()[0]!==o.scales.y.domain()[0]||Qe.y.domain()[1]!==o.scales.y.domain()[1]||Qe.x.range()[0]!==o.scales.x.range()[0]||Qe.x.range()[1]!==o.scales.x.range()[1]||Qe.y.range()[0]!==o.scales.y.range()[0]||Qe.y.range()[1]!==o.scales.y.range()[1])&&Je(o.scales),ke)){const t=o.getData(),e="function"==typeof w?w:t=>t[w||"x"],n="function"==typeof E?E:t=>t[E||"y"];sn(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),un(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}f&&$t&&$t.length>0&&Ze(t=>t+1),(null==de?void 0:de.showBadge)&&ln(!!d),(a||o.hasActivePulses)&&(Ve.current=requestAnimationFrame(()=>hn.current()))},t.useEffect(()=>(gn(),()=>{Ve.current&&(cancelAnimationFrame(Ve.current),Ve.current=0)}),[gn]),t.useEffect(()=>{qe.current=!0,gn()},[y,Oe,We,kt,G,K,Ut,gn]),at(de,yn,qe,gn,on,ln);const Pn=t.useMemo(()=>{if(St||Pt)return;const t=yn.current;return(null==t?void 0:t.xIsDate)&&Qe?Ie(Qe.x.domain()):void 0},[St,Pt,Qe]),Cn=St||Pt||Pn,Dn=He&&nn?Lt?Lt(nn):g.createElement(Fe,{hover:nn}):null,Ln=Dn?g.createElement(ce,{x:nn.x,y:nn.y,containerWidth:Oe,containerHeight:We,margin:$e,className:"stream-frame-tooltip"},Dn):null,Tn=An.current,Nn=g.createElement(se,{active:En.current>=0,hoverPoint:nn,margin:$e,size:Ne,shape:null==Tn?void 0:Tn.shape,width:null==Tn?void 0:Tn.w,height:null==Tn?void 0:Tn.h}),$n=(t,e,n,r)=>"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:n,fn:t}:"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:r,fn:e}:{key:void 0,fn:null},On=$n(w,O,"__semiotic_resolvedX","__semiotic_resolvedTime"),Wn=$n(E,L,"__semiotic_resolvedY","__semiotic_resolvedValue"),In=On.key,zn=Wn.key,Rn=$t&&$t.length>0,Bn=t=>{if(!t||!Rn||!On.fn&&!Wn.fn)return t;let e=!1;const n=t.map(t=>{const n=On.fn&&On.key&&!(On.key in t),r=Wn.fn&&Wn.key&&!(Wn.key in t);if(!n&&!r)return t;e=!0;const o=Object.assign({},t);return n&&(o[On.key]=On.fn(t)),r&&(o[Wn.key]=Wn.fn(t)),o});return e?n:t};if(Ft){const t=yn.current;t&&m&&(t.ingest({inserts:m,bounded:!0}),t.computeScene({width:Oe,height:We}));const e=null!==(r=null==t?void 0:t.scene)&&void 0!==r?r:[],n=null!==(o=null==t?void 0:t.scales)&&void 0!==o?o:null,i=Cn||(()=>{if((null==t?void 0:t.xIsDate)&&n)return Ie(n.x.domain())})();return g.createElement("div",{className:"stream-xy-frame"+(X?" "+X:""),role:"img","aria-label":Se||("string"==typeof Qt?Qt:"XY chart"),style:{position:"relative",width:Ne[0],height:Ne[1]}},g.createElement(oe,{summary:_e}),g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ne[0],height:Ne[1],style:{position:"absolute",left:0,top:0}},g.createElement("g",{transform:`translate(${$e.left},${$e.top})`},Ye),g.createElement("g",{transform:`translate(${$e.left},${$e.top})`},G&&g.createElement("rect",{x:0,y:0,width:Oe,height:We,fill:G}),Zt&&n&&Zt.map((t,r)=>g.createElement(g.Fragment,{key:"svgpre-"+r},t(e,n,{width:Oe,height:We}))),e.map((t,e)=>function(t,e){var n,r,o;switch(t.type){case"line":{const n=t;if(0===n.path.length)return null;const r="M"+n.path.map(([t,e])=>`${t},${e}`).join("L");return g.createElement("path",{key:"line-"+e,d:r,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity})}case"area":{const o=t;if(0===o.topPath.length)return null;const i=o.topPath.map(([t,e])=>`${t},${e}`).join("L"),l=[...o.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return g.createElement("path",{key:"area-"+e,d:`M${i}L${l}Z`,fill:jt(o.style.fill),fillOpacity:null!==(r=null!==(n=o.style.fillOpacity)&&void 0!==n?n:o.style.opacity)&&void 0!==r?r:.7,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})}case"point":{const n=t;return g.createElement("circle",{key:"point-"+e,cx:n.x,cy:n.y,r:n.r,fill:jt(n.style.fill),opacity:null!==(o=n.style.opacity)&&void 0!==o?o:.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})}case"rect":{const n=t;return g.createElement("rect",{key:"rect-"+e,x:n.x,y:n.y,width:n.w,height:n.h,fill:jt(n.style.fill),opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})}case"heatcell":{const n=t;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const t=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[r,o,i]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(n.fill),l=.299*r+.587*o+.114*i>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return g.createElement("g",{key:"heatcell-"+e},g.createElement("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),g.createElement("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:l,fontSize:a+"px"},t))}return g.createElement("rect",{key:"heatcell-"+e,x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill})}case"candlestick":{const n=t,r=Math.min(n.openY,n.closeY),o=Math.max(Math.abs(n.openY-n.closeY),1),i=n.isUp?n.upColor:n.downColor;return g.createElement("g",{key:"candle-"+e},g.createElement("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),g.createElement("rect",{x:n.x-n.bodyWidth/2,y:r,width:n.bodyWidth,height:o,fill:i,stroke:i,strokeWidth:1}))}default:return null}}(t,e)).filter(Boolean))),g.createElement(Bt,{width:Oe,height:We,totalWidth:Ne[0],totalHeight:Ne[1],margin:$e,scales:n,showAxes:kt,axes:wt,xLabel:Et,yLabel:At,yLabelRight:Mt,xFormat:i,yFormat:_t||Ct,showGrid:It,title:Qt,legend:zt,legendHoverBehavior:Rt,legendClickBehavior:Yt,legendHighlightedCategory:Ht,legendIsolatedCategories:Xt,legendPosition:Vt,foregroundGraphics:je,marginalGraphics:ke,xValues:[],yValues:[],annotations:$t,svgAnnotationRules:Ot,annotationFrame:0,xAccessor:In,yAccessor:zn,annotationData:Bn(null==t?void 0:t.getData()),pointNodes:null==t?void 0:t.scene.filter(t=>"point"===t.type),curve:"string"==typeof P?P:void 0,linkedCrosshairName:Pe,linkedCrosshairSourceId:Ce}))}const jn="semiotic-table-"+g.useId();return g.createElement("div",{ref:Te,className:"stream-xy-frame"+(X?" "+X:""),role:"group","aria-label":Se||("string"==typeof Qt?Qt:"XY chart"),tabIndex:0,style:{position:"relative",width:j?"100%":Ne[0],height:F?"100%":Ne[1],overflow:"visible"},onKeyDown:Sn},Me&&g.createElement(ie,{tableId:jn}),Me&&g.createElement(ne,{scene:null!==(l=null===(i=yn.current)||void 0===i?void 0:i.scene)&&void 0!==l?l:[],chartType:y+" chart",tableId:jn,chartTitle:"string"==typeof Qt?Qt:void 0}),g.createElement(oe,{summary:_e}),g.createElement("div",{role:"img","aria-label":Se||("string"==typeof Qt?Qt:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:He?_n:void 0,onMouseLeave:He?wn:void 0},Ye&&g.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Ne[0],height:Ne[1],pointerEvents:"none"}},g.createElement("g",{transform:`translate(${$e.left},${$e.top})`},Ye)),g.createElement(Wt,{width:Oe,height:We,totalWidth:Ne[0],totalHeight:Ne[1],margin:$e,scales:Qe,showAxes:kt,axes:wt,showGrid:It,xFormat:Cn,yFormat:_t||Ct}),g.createElement("canvas",{ref:Xe,"aria-label":Gt(null!==(s=null===(a=yn.current)||void 0===a?void 0:a.scene)&&void 0!==s?s:[],y+" chart"),style:{position:"absolute",left:0,top:0}}),g.createElement("canvas",{ref:Ge,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),g.createElement(le,{hoverPoint:nn}),g.createElement(Bt,{width:Oe,height:We,totalWidth:Ne[0],totalHeight:Ne[1],margin:$e,scales:Qe,showAxes:kt,axes:wt,xLabel:Et,yLabel:At,yLabelRight:Mt,xFormat:Cn,yFormat:_t||Ct,showGrid:It,title:Qt,legend:zt,legendHoverBehavior:Rt,legendClickBehavior:Yt,legendHighlightedCategory:Ht,legendIsolatedCategories:Xt,legendPosition:Vt,foregroundGraphics:je,marginalGraphics:ke,xValues:an,yValues:cn,annotations:$t,svgAnnotationRules:Ot,annotationFrame:Ue,xAccessor:In,yAccessor:zn,annotationData:Bn(null===(c=yn.current)||void 0===c?void 0:c.getData()),pointNodes:null===(u=yn.current)||void 0===u?void 0:u.scene.filter(t=>"point"===t.type),curve:"string"==typeof P?P:void 0,underlayRendered:!0,linkedCrosshairName:Pe,linkedCrosshairSourceId:Ce}),(te||ee)&&g.createElement(x,{width:Oe,height:We,totalWidth:Ne[0],totalHeight:Ne[1],margin:$e,dimension:null!==(h=null==te?void 0:te.dimension)&&void 0!==h?h:"xy",scales:Qe,onBrush:null!=ee?ee:()=>{},binSize:D,snap:null==te?void 0:te.snap,binBoundaries:null!==(d=null==te?void 0:te.binBoundaries)&&void 0!==d?d:"bar"===y?null===(f=yn.current)||void 0===f?void 0:f.getBinBoundaries():void 0,snapDuring:null==te?void 0:te.snapDuring,streaming:"streaming"===p}),(null==de?void 0:de.showBadge)&&g.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===de.badgePosition?{top:4,left:4}:"bottom-left"===de.badgePosition?{bottom:4,left:4}:"bottom-right"===de.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:on?"#dc3545":"#28a745",color:"white"})},on?"STALE":"LIVE"),Nn,Ln))});Ye.displayName="StreamXYFrame";const He={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Xe={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class Ge{constructor(t){this.capacity=t,this.particles=Array(t);for(let e=0;t>e;e++)this.particles[e]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0}}spawn(t){for(let e=0;this.capacity>e;e++){const n=this.particles[e];if(!n.active)return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=t,n.x=0,n.y=0,n}return null}step(t,e,n,r){var o;for(let i=0;this.capacity>i;i++){const l=this.particles[i];if(!l.active)continue;const a=n[l.edgeIndex];if(!a||!a.bezier){l.active=!1;continue}const s=r&&null!==(o=r[l.edgeIndex])&&void 0!==o?o:1;if(l.t+=t*e*s*(a.bezier.circular?.3:1),l.t>=1){l.active=!1;continue}const c=Ve(a.bezier,l.t,l.offset);l.x=c.x,l.y=c.y}}countForEdge(t){let e=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===t&&e++;return e}clear(){for(let t=0;this.capacity>t;t++)this.particles[t].active=!1}resize(t){if(this.capacity>=t)return;const e=this.particles;this.particles=Array(t);for(let n=0;t>n;n++)this.particles[n]=e.length>n?e[n]:{t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0};this.capacity=t}}function Ve(t,e,n){if(t.circular&&t.segments)return function(t,e,n,r){const o=t.length,i=e*o,l=Math.min(Math.floor(i),o-1),a=i-l,[s,c,u,h]=t[l],d=qe(s,c,u,h,a),f=h.x-s.x,y=h.y-s.y,g=Math.sqrt(f*f+y*y);if(g>.001){const t=f/g;d.x+=-y/g*n*r*2,d.y+=t*n*r*2}return d}(t.segments,e,n,t.halfWidth);if(!t.points)return{x:0,y:0};const[r,o,i,l]=t.points,a=qe(r,o,i,l,e),s=l.x-r.x,c=l.y-r.y,u=Math.sqrt(s*s+c*c);if(u>.001){const e=s/u;a.x+=-c/u*n*t.halfWidth*2,a.y+=e*n*t.halfWidth*2}return a}function qe(t,e,n,r,o){const i=1-o,l=i*i,a=l*i,s=o*o,c=s*o;return{x:a*t.x+3*l*o*e.x+3*i*s*n.x+c*r.x,y:a*t.y+3*l*o*e.y+3*i*s*n.y+c*r.y}}function Ke(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function Ue(t,e){var n,r=[],o=[],i=[],l={},a=[];function s(t){i[t]=!1,l.hasOwnProperty(t)&&Object.keys(l[t]).forEach(function(e){delete l[t][e],i[e]&&s(e)})}function c(t){var e,r,h=!1;for(o.push(t),i[t]=!0,e=0;a[t].length>e;e++)(r=a[t][e])===n?(u(n,o),h=!0):i[r]||(h=c(r));if(h)s(t);else for(e=0;a[t].length>e;e++){var d=l[r=a[t][e]];d||(l[r]=d={}),d[r]=!0}return o.pop(),h}function u(t,e){var n=[].concat(e).concat(t);r.push(n)}function h(e){!function(e){for(var n=0;t.length>n;n++)n>=e&&t[n]||(t[n]=[]),t[n]=t[n].filter(function(t){return t>=e})}(e);for(var n,r=function(t){for(var e=t.length,n=Array(e),r=Array(e),o=Array(e),i=Array(e),l=Array(e),a=Array(e),s=0;e>s;++s)n[s]=-1,r[s]=0,o[s]=!1,i[s]=0,l[s]=-1,a[s]=[];var c,u=0,h=[],d=[];function f(e){var s=[e],c=[e];for(n[e]=r[e]=u,o[e]=!0,u+=1;c.length>0;){var f=t[e=c[c.length-1]];if(f.length>i[e]){for(var y=i[e];f.length>y;++y){var g=f[y];if(0>n[g]){n[g]=r[g]=u,o[g]=!0,u+=1,s.push(g),c.push(g);break}o[g]&&(r[e]=0|Math.min(r[e],r[g])),0>l[g]||a[e].push(l[g])}i[e]=y}else{if(r[e]===n[e]){var p=[],m=[],v=0;for(y=s.length-1;y>=0;--y){var x=s[y];if(o[x]=!1,p.push(x),m.push(a[x]),v+=a[x].length,l[x]=h.length,x===e){s.length=y;break}}h.push(p);var b=Array(v);for(y=0;m.length>y;y++)for(var k=0;m[y].length>k;k++)b[--v]=m[y][k];d.push(b)}c.pop()}}}for(s=0;e>s;++s)0>n[s]&&f(s);for(s=0;d.length>s;s++){var y=d[s];if(0!==y.length){y.sort(function(t,e){return t-e}),c=[y[0]];for(var g=1;y.length>g;g++)y[g]!==y[g-1]&&c.push(y[g]);d[s]=c}}return{components:h,adjacencyList:d}}(t),o=r.components.filter(function(t){return t.length>1}),i=1/0,l=0;o.length>l;l++)for(var a=0;o[l].length>a;a++)i>o[l][a]&&(i=o[l][a],n=l);var s=o[n];if(!s)return!1;var c=t.map(function(t,e){return-1===s.indexOf(e)?[]:t.filter(function(t){return-1!==s.indexOf(t)})});return{leastVertex:i,adjList:c}}n=0;for(var d=t.length;d>n;){var f=h(n);if(n=f.leastVertex,a=f.adjList){for(var y=0;a.length>y;y++)for(var g=0;a[y].length>g;g++){var p=a[y][g];i[+p]=!1,l[p]={}}c(n),n+=1}else n=d}return r}function Ze(t){return t.y0-t.y1>0?"up":"down"}function Qe(t,e){return e(t.source)==e(t.target)}function Je(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var n=0;return t.target.targetLinks.forEach(function(t){n=t.circular?n+1:n}),1>=e&&1>=n}function tn(t){return t.target.x0-t.source.x1}function en(t,e){var n=rn(t),r=tn(e)/Math.tan(n);return"up"==Ze(t)?t.y1-r:t.y1+r}function nn(t,e){var n=rn(t),r=tn(e)/Math.tan(n);return"up"==Ze(t)?t.y1+r:t.y1-r}function rn(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function on(t,e){return e(t)}function ln(t){return sn(t.source)}function an(t){return sn(t.target)}function sn(t){return(t.y0+t.y1)/2}function cn(t){return t.virtual?0:t.value}function un(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!Qe(t,e)?n+1:n});var r=0;return t.targetLinks.forEach(function(t){r=t.circular&&!Qe(t,e)?r+1:r}),n+r}function hn(t){return t.target.depth}function dn(t,e){return t.sourceLinks.length?t.depth:e-1}function fn(t,e){return t.y0-e.y0}function yn(t,e){return e.y0-t.y0}function gn(t,e){return t.y1-e.y1}function pn(t,e){return e.y1-t.y1}function mn(t,e){return xn(t.source,e.source)||t.index-e.index}function vn(t,e){return xn(t.target,e.target)||t.index-e.index}function xn(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function bn(t,e){return kn(t)==kn(e)?"bottom"==t.circularLinkType?yn(t,e):fn(t,e):kn(e)-kn(t)}function kn(t){return t.target.column-t.source.column}function wn(t,e){return En(t)==En(e)}function En(t){return t.y0-t.y1>0?"up":"down"}function An(t,e,n,r,o){let i=t;var a=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,a))});var s=l.min(i.links,function(t){return t.source.y0});i.links.forEach(function(t){t.circular&&(t.circularPathData={})});var c=i.links.filter(function(t){return t.circular});return c.sort(function(t,e){return e.value-t.value}),c.forEach(function(t,e){t._circularStub=e>=4}),Mn(i.links.filter(function(t){return"top"==t.circularLinkType}),e,n),Mn(i.links.filter(function(t){return"bottom"==t.circularLinkType}),e,n),i.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+r,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,Qe(t,e)&&Je(t))t.circularPathData.rightSmallArcRadius=r+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=r+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=r+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=r+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var l=t.source.column,a=t.circularLinkType,c=i.links.filter(function(t){return t.source.column==l&&t.circularLinkType==a});c.sort("bottom"==t.circularLinkType?yn:fn);var u=0;c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=r+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=r+t._circularWidth/2+o*n+u),u+=e._circularWidth||e.width}),l=t.target.column,(c=i.links.filter(function(t){return t.target.column==l&&t.circularLinkType==a})).sort("bottom"==t.circularLinkType?pn:gn),u=0,c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=r+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=r+t._circularWidth/2+o*n+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(i.y1,t.source.y1,t.target.y1)+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=s-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,n=t.y0,r=t.target.x0,o=t.y1,i=(e+r)/2;return"M"+e+","+n+"C"+i+","+n+" "+i+","+o+" "+r+","+o}(t)}),i}function Mn(t,e,n){t.sort(bn);var r=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,o){var i=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(Qe(t,e)&&Je(t))t.circularPathData.verticalBuffer=i+t._circularWidth/2;else{for(var l=0;r.length>l;l++){var a=r[l];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&Sn(t,a)){var s=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;i=s>i?s:i}}t.circularPathData.verticalBuffer=i+t._circularWidth/2}}),t}function Sn(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function _n(t){return function(){return t}}function Pn(t){return t.index}function Cn(t){return t.nodes}function Dn(t){return t.links}function Ln(t,e,n){var r=l.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});r.forEach(function(o,i){var l=o.length;if(e)o.sort(e);else if(i>0){var a=new Map;o.forEach(function(t,e){var n,r,o,i=(r=0,o=0,(n=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=sn(t.source)*e,r+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=sn(t.target)*e,r+=e}}),r>0?o/r:NaN);a.set(t,{bc:i,idx:e})}),o.sort(function(t,e){var n=a.get(t),r=a.get(e),o=n.bc,i=r.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(o)||isNaN(i)?isNaN(o)?isNaN(i)?n.idx-r.idx:1:-1:o-i})}else o.sort(function(t,e){return t.circularLinkType==e.circularLinkType?un(e,n)-un(t,n):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});o.forEach(function(e,o){e.depth==r.length-1&&1==l||0==e.depth&&1==l?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==un(e,n)?(e.y0=t.y1/2+o,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+o,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-o,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/l*o,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-l/2+o,e.y1=e.y0+e.value*t.ky)})})}function Tn(t,e,n,r,o,i){var a=l.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});h();for(var s=1,c=i;c>0;--c)u(s*=.99,n),h();function u(e,n){var r=a.length;a.forEach(function(o){var i=o.length,a=o[0].depth;o.forEach(function(o){var s;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&un(o,n)>0){var c=l.mean(o.sourceLinks,an),u=l.mean(o.targetLinks,ln),h=c&&u?(c+u)/2:c||u;if(h){var d=(h-sn(o))*e*.3;o.y0+=d,o.y1+=d}}else if(0==a&&1==i)o.y0=t.y1/2-(s=o.y1-o.y0)/2,o.y1=t.y1/2+s/2;else if(a==r-1&&1==i)o.y0=t.y1/2-(s=o.y1-o.y0)/2,o.y1=t.y1/2+s/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)s=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+s;else{var f=l.mean(o.sourceLinks,an),y=l.mean(o.targetLinks,ln),g=((f&&y?(f+y)/2:f||y)-sn(o))*e;o.y0+=g,o.y1+=g}})})}function h(){a.forEach(function(n){var i,l,a,s=t.y0,c=n.length;for(n.sort(e||xn),a=0;c>a;++a)(l=s-(i=n[a]).y0)>0&&(i.y0+=l,i.y1+=l),s=i.y1+r;if((l=s-r-t.y1)>0)for(s=i.y0-=l,i.y1-=l,a=c-2;a>=0;--a)(l=(i=n[a]).y1+o-s)>0&&(i.y0-=l,i.y1-=l),s=i.y0})}}function Nn(t){t.nodes.forEach(function(t){t.sourceLinks.sort(vn),t.targetLinks.sort(mn)}),t.nodes.forEach(function(t){var e=t.y0,n=e,r=t.y1,o=r;t.sourceLinks.forEach(function(t){t.circular?(t.y0=r-t.width/2,r-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=o-t.width/2,o-=t.width):(t.y1=n+t.width/2,n+=t.width)})})}function $n(){var t=0,e=0,n=1,r=1,o=24,i=8,a=null,s=Pn,c=dn,u=void 0,h=32,d=2,f=Cn,y=Dn;function g(){var g={nodes:f.apply(null,arguments),links:y.apply(null,arguments)};return function(f){f.x0=t,f.y0=e,f.x1=n,f.y1=r,f.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var n=function(t,e){var n=new Map;return l.group(t,e).forEach(function(t,e){n.set(e,t[0])}),n}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var r=t.source,o=t.target;"object"!=typeof r&&(r=t.source=Ke(n,r)),"object"!=typeof o&&(o=t.target=Ke(n,o)),r.sourceLinks.push(t),o.targetLinks.push(t)})}(f,s),function(t,e){var n=0;if(null==e){for(var r=[],o=0;t.links.length>o;o++){var i=t.links[o],l=i.source.index,a=i.target.index;r[l]||(r[l]=[]),r[a]||(r[a]=[]),-1===r[l].indexOf(a)&&r[l].push(a)}var s=Ue(r);s.sort(function(t,e){return t.length-e.length});var c={};for(o=0;s.length>o;o++){var u=s[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,r=t.source.index;e===r||c[r]&&c[r][e]?(t.circular=!0,t.circularLinkID=n++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=n++)})}(f,u),function(t,e){var n=0,r=0;t.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:r>n?"top":"bottom","top"==o.circularLinkType?n++:r++,t.nodes.forEach(function(t){on(t,e)!=on(o.source,e)&&on(t,e)!=on(o.target,e)||(t.circularLinkType=o.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),Qe(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(f,s),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(l.sum(t.sourceLinks,cn),l.sum(t.targetLinks,cn)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(f),function(t,e,n){var r,o,i;if(null!=e){t.nodes.sort(function(t,n){return e(t)<e(n)?-1:1});var l=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){l=e(t)==a?l:l+1,a=e(t)==a?a:e(t),t.column=l})}for(r=t.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(t){t.depth=i,t.sourceLinks.forEach(function(t){0>o.indexOf(t.target)&&!t.circular&&o.push(t.target)})});for(r=t.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(t){t.height=i,t.targetLinks.forEach(function(t){0>o.indexOf(t.source)&&!t.circular&&o.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?n(t,i):t.column})}(f,u,c);var y=i;if(null!==a){var g=l.groups(f.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=l.max(g,function(t){return t.length});p>1&&(y=Math.max(1,(r-e)*a/(p-1)))}(function(t,e,n){var r=l.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var o=l.min(r,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/l.sum(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var i=l.max(t.nodes,function(t){return t.column});t.nodes.forEach(i>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-n)/i),e.x1=e.x0+n}:function(e){e.x0=t.x0,e.x1=e.x0+n})})(f,y,o),Ln(f,u,s),Tn(f,u,s,y,y,h),Nn(f),An(f,s,d,10,8),Ln(f,u,s),Tn(f,u,s,y,y,h),Nn(f),An(f,s,d,10,8),function(t,e){let n=t;n.nodes.forEach(function(t){t.y+(t.y1-t.y0)>n.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-n.y1));var r=n.links.filter(function(n){return on(n.source,e)==on(t,e)}),o=r.length;o>1&&r.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!wn(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=en(e,t);return t.y1-n}if(e.target.column>t.target.column)return en(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var i=t.y0;r.forEach(function(t){t.y0=i+t.width/2,i+=t.width}),r.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var i=n+1,l=0;o>i;i++)l+=r[i].width;e.y0=t.y1-l-e.width/2}})})}(f,s),function(t,e){let n=t;n.nodes.forEach(function(t){var r=n.links.filter(function(n){return on(n.target,e)==on(t,e)}),o=r.length;o>1&&r.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!wn(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=nn(e,t);return t.y0-n}if(e.source.column>t.source.column)return nn(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var i=t.y0;r.forEach(function(t){t.y1=i+t.width/2,i+=t.width}),r.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var i=n+1,l=0;o>i;i++)l+=r[i].width;e.y1=t.y1-l-e.width/2}})})}(f,s),function(t){var e=t.nodes,n=t.links,r=!1,o=!1;if(n.forEach(function(t){"top"==t.circularLinkType?r=!0:"bottom"==t.circularLinkType&&(o=!0)}),0==r||0==o){var i=l.min(e,function(t){return t.y0}),a=l.max(e,function(t){return t.y1}),s=(t.y1-t.y0)/(a-i);function c(e){return(e-i)/(a-i)*(t.y1-t.y0)+t.y0}1>s?(e.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1)}),n.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1),t.width=t.width*s})):e.forEach(function(t){var e=t.y1-t.y0,n=c(t.y0)-t.y0;t.y0=c(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+n}),t.targetLinks.forEach(function(t){t.y1=t.y1+n})})}}(f),An(f,s,d,10,8)}(g),g}return g.update=function(t){return Nn(t),An(t,s,d,10,8),t},g.nodeWidth=function(t){return arguments.length?(o=+t,g):o},g.nodePadding=function(t){return arguments.length?(i=+t,g):i},g.nodePaddingRatio=function(t){return arguments.length?(a=+t,g):a},g.nodes=function(t){return arguments.length?(f="function"==typeof t?t:_n(t),g):f},g.links=function(t){return arguments.length?(y="function"==typeof t?t:_n(t),g):y},g.nodeId=function(t){return arguments.length?(s="function"==typeof t?t:_n(t),g):s},g.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:_n(t),g):c},g.nodeSort=function(t){return arguments.length?(u=t,g):u},g.iterations=function(t){return arguments.length?(h=+t,g):h},g.circularLinkGap=function(t){return arguments.length?(d=+t,g):d},g.extent=function(o){return arguments.length?(t=+o[0][0],e=+o[0][1],n=+o[1][0],r=+o[1][1],g):[[t,e],[n,r]]},g.size=function(o){return arguments.length?(t=e=0,n=+o[0],r=+o[1],g):[n-t,r-e]},g}const On=t=>{let e,n,r,o,i,l,a,s,c;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,r=t.y1+t.sankeyWidth/2,o=t.y0+t.sankeyWidth/2,i=t.source.x1,l=t.target.x0,a=u.interpolateNumber(i,l),s=a(.5),c=a(.5),`M${e},${i}C${e},${s} ${n},${c} ${n},${l}L${r},${l}C${r},${c} ${o},${s} ${o},${i}Z`):(e=t.source.x1,n=t.target.x0,a=u.interpolateNumber(e,n),r=a(.5),o=a(.5),i=t.y0-t.sankeyWidth/2,l=t.y1-t.sankeyWidth/2,s=t.y1+t.sankeyWidth/2,c=t.y0+t.sankeyWidth/2,`M${e},${i}C${r},${i} ${o},${l} ${n},${l}L${n},${s}C${o},${s} ${r},${c} ${e},${c}Z`)};function Wn(t){var e;const n=t.sankeyWidth/2,r=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,o=t.circularPathData;if(!o)return null;if("down"===t.direction)return null;if(t._circularStub){const e=o.sourceX,r=o.sourceY,i=o.targetX,l=o.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(o.rightFullExtent-e))),s=Math.max(15,Math.min(40,.33*(i-o.leftFullExtent)));return`M${e},${r-n}L${e+a},${r-n}L${e+a},${r+n}L${e},${r+n}ZM${i},${l-n}L${i-s},${l-n}L${i-s},${l+n}L${i},${l+n}Z`}const i=o.sourceX,l=o.sourceY,a=o.targetX,s=o.targetY,c=o.rightFullExtent,u=o.leftFullExtent,h=o.verticalFullExtent,d="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(r,15));return`M${i},${l-d*n}L${c},${l-d*n}L${c+r},${l-d*n+d*f}L${c+r},${h+d*r-d*f}L${c+r-f},${h+d*r}L${u-r+f},${h+d*r}L${u-r},${h+d*r-d*f}L${u-r},${s-d*n+d*f}L${u-r+f},${s-d*n}L${a},${s-d*n}L${a},${s+d*n}L${u+r},${s+d*n}L${u+r},${h-d*r}L${c-r},${h-d*r}L${c-r},${l+d*n}L${i},${l+d*n}Z`}const In={left:function(t){return t.depth},right:function(t,e){return e-1-t.height},center:function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Math.min.apply(Math,t.sourceLinks.map(hn))-1:0},justify:dn},zn={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,r){var o,i,l,a,s,c,u;if(0===t.length)return;const h="vertical"===n.orientation?"down":"right",d=n.nodeAlign||"justify",f=null!==(o=n.nodeWidth)&&void 0!==o?o:15,y=null!==(i=n.nodePaddingRatio)&&void 0!==i?i:.05,g=null!==(l=n.iterations)&&void 0!==l?l:100,p=t.map(t=>Object.assign({},t)),m=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let v;v="down"===h?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const x=$n().extent(v).links(m).nodes(p).nodeAlign(In[d]||dn).nodeId(t=>t.id).nodeWidth(f).iterations(g);x.nodePaddingRatio&&x.nodePaddingRatio(y),x();{let t=1/0,e=-1/0,n=1/0,o=-1/0;for(const r of p)t>r.x0&&(t=r.x0),r.x1>e&&(e=r.x1),n>r.y0&&(n=r.y0),r.y1>o&&(o=r.y1);for(const r of m){if(!r.circular||!r.circularPathData)continue;const i=r.circularPathData,l=(null!==(s=null!==(a=r._circularWidth)&&void 0!==a?a:r.width)&&void 0!==s?s:0)/2;t>i.leftFullExtent-l&&(t=i.leftFullExtent-l),i.rightFullExtent+l>e&&(e=i.rightFullExtent+l),n>i.verticalFullExtent-l&&(n=i.verticalFullExtent-l),i.verticalFullExtent+l>o&&(o=i.verticalFullExtent+l)}const i=e-t,l=o-n,u=r[0],h=r[1];if(i>0&&l>0&&(0>t||0>n||e>u||o>h)){const e=Math.min(u/i,h/l),r=-t*e+(u-i*e)/2,o=-n*e+(h-l*e)/2;for(const t of p)t.x0=t.x0*e+r,t.x1=t.x1*e+r,t.y0=t.y0*e+o,t.y1=t.y1*e+o;for(const t of m)if(t.y0=t.y0*e+o,t.y1=t.y1*e+o,t.width=(null!==(c=t.width)&&void 0!==c?c:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const n=t.circularPathData;n.sourceX=n.sourceX*e+r,n.targetX=n.targetX*e+r,n.sourceY=n.sourceY*e+o,n.targetY=n.targetY*e+o,n.rightFullExtent=n.rightFullExtent*e+r,n.leftFullExtent=n.leftFullExtent*e+r,n.verticalFullExtent=n.verticalFullExtent*e+o,n.rightInnerExtent=n.rightInnerExtent*e+r,n.leftInnerExtent=n.leftInnerExtent*e+r,n.verticalRightInnerExtent=n.verticalRightInnerExtent*e+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*e+o,n.rightSmallArcRadius*=e,n.rightLargeArcRadius*=e,n.leftSmallArcRadius*=e,n.leftLargeArcRadius*=e,n.sourceWidth*=e,n.rightNodeBuffer*=e,n.leftNodeBuffer*=e,n.arcRadius*=e}}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of p){const e=b.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const k=new Map;for(const t of e)k.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of m){const e=t.source,n=t.target,r="object"==typeof e&&null!==e?e.id:e+"",o="object"==typeof n&&null!==n?n.id:n+"",i=k.get(t._edgeKey?t._edgeKey:`${r}\0${o}`);if(i){i.y0=t.y0,i.y1=t.y1,i.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,i.circular=!!t.circular,i.circularPathData=t.circularPathData,i._circularWidth=t._circularWidth,i._circularStub=t._circularStub,i.path=t.path,i.circularLinkType=t.circularLinkType,i.direction=h;const e=b.get(r),n=b.get(o);e&&(i.source=e),n&&(i.target=n)}}},buildScene(t,e,n,r){var o,l,a,s;const c="vertical"===n.orientation?"down":"right",u=n.nodeStyle,h=n.edgeStyle,d=null!==(o=n.edgeOpacity)&&void 0!==o?o:.5,f=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:i.schemeCategory10,g=new Map;t.forEach((t,e)=>{g.set(t.id,y[e%y.length])});const p=[],m=[],v=[],x=new Map;for(const e of t){const t=e.x1-e.x0,n=e.y1-e.y0;if(0>=t||0>=n)continue;const r=u?u(e):{},o={fill:r.fill||g.get(e.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};x.set(e.id,("string"==typeof o.fill?o.fill:null)||g.get(e.id)||"#4d430c"),p.push("down"===c?{type:"rect",x:e.y0,y:e.x0,w:n,h:t,style:o,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:o,datum:e,id:e.id,label:e.id})}const b=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of b){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;if(!e||!n)continue;let r="#999";r="function"==typeof f?f(t)||r:"target"===f?x.get(n.id)||g.get(n.id)||r:x.get(e.id)||g.get(e.id)||r;const o=h?h(t):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,i=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),s=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),c=o.fill||r;m.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+i},${e.sourceY-n}L${e.sourceX+i},${e.sourceY+n}L${e.sourceX},${e.sourceY+n}Z`,style:{fill:c,fillOpacity:null!==(l=o.fillOpacity)&&void 0!==l?l:d,stroke:"none",opacity:o.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+i}}),m.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-n}L${e.targetX-s},${e.targetY-n}L${e.targetX-s},${e.targetY+n}L${e.targetX},${e.targetY+n}Z`,style:{fill:c,fillOpacity:null!==(a=o.fillOpacity)&&void 0!==a?a:d,stroke:"none",opacity:o.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-s,x1:e.targetX}});continue}let i;if(i=t.circular&&t.circularPathData?Wn(t):On(t),!i)continue;const c={fill:o.fill||r,fillOpacity:null!==(s=o.fillOpacity)&&void 0!==s?s:d,stroke:o.stroke||"none",strokeWidth:o.strokeWidth,opacity:o.opacity};m.push({type:"bezier",pathD:i,bezierCache:t.bezier,style:c,datum:t})}if(!1!==n.showLabels){const e=(k=n.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null;for(const n of t){const t=n.x1-n.x0,o=n.y1-n.y0;if(0>=t||0>=o)continue;const i=e?e(n):n.id;if(!i)continue;let l,a,s;"down"===c?(l=n.y0+(n.y1-n.y0)/2,a=n.x1+14,s="middle"):(r[0]/2>n.x0+t/2?(l=n.x0-6,s="end"):(l=n.x1+6,s="start"),a=n.y0+o/2),v.push({x:l,y:a,text:i+"",anchor:s,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:p,sceneEdges:m,labels:v}}},Rn={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,r){var o,i;if(0===t.length)return;const l=null!==(o=n.forceStrength)&&void 0!==o?o:.1,a=r[0]/2,s=r[1]/2,c=n.__previousPositions;let u=0;const d=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),n=null==c?void 0:c.get(e.id);t?u++:n?(e.x=n.x,e.y=n.y,u++):d.push(e)}const f=u>0&&.3>=(t.length>0?d.length/t.length:1);if(f){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of d){const r=Bn(t.id,e,n);if(r.length>0){let e=0,n=0;for(const t of r)e+=t.x,n+=t.y;const o=jn(t.id),i=o%360*(Math.PI/180),l=10+o%20;t.x=e/r.length+l*Math.cos(i),t.y=n/r.length+l*Math.sin(i)}else{const e=jn(t.id),n=e%360*(Math.PI/180),r=15+e%30;t.x=a+r*Math.cos(n),t.y=s+r*Math.sin(n)}}}else{const e=2.399963229728653;for(let n=0;t.length>n;n++){const r=t[n];if(null==r.x||null==r.y||0===r.x&&0===r.y){const t=10*Math.sqrt(n+.5),o=n*e;r.x=a+t*Math.cos(o),r.y=s+t*Math.sin(o)}}}const y=null!==(i=n.iterations)&&void 0!==i?i:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),g=f?40:y,p=Fn(n.nodeSize,n.nodeSizeRange,t),m=t=>p(t),v=h.forceLink().strength(t=>Math.min(2.5,t.weight?t.weight*l:l)).id(t=>t.id),x=h.forceSimulation().force("charge",h.forceManyBody().strength(t=>-25*m(t))).force("center",h.forceCenter(a,s).strength(.8)).force("x",h.forceX(a).strength(.15)).force("y",h.forceY(s).strength(.15));if(x.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));x.force("link",v),x.force("link").links(t)}f?x.alpha(.3):.1>x.alpha()&&x.alpha(1),x.stop();for(let t=0;g>t;++t)x.tick();for(const e of t){if(null==e.x||null==e.y)continue;const t=m(e);e.x=Math.max(t,Math.min(r[0]-t,e.x)),e.y=Math.max(t,Math.min(r[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=b.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=b.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,r){var o,l,a;const s=n.nodeStyle,c=n.edgeStyle,u=Fn(n.nodeSize,n.nodeSizeRange,t),h=Array.isArray(n.colorScheme)?n.colorScheme:i.schemeCategory10,d=new Map;t.forEach((t,e)=>{d.set(t.id,h[e%h.length])});const f=[],y=[],g=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=u(e),n=s?s(e):{},r={fill:n.fill||d.get(e.id)||"#007bff",stroke:n.stroke||"#fff",strokeWidth:null!==(o=n.strokeWidth)&&void 0!==o?o:2,opacity:n.opacity};f.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id})}const p=new Map;for(const e of t)p.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:p.get(t.source),n="object"==typeof t.target?t.target:p.get(t.target);if(!e||!n)continue;if(null==e.x||null==e.y)continue;if(null==n.x||null==n.y)continue;const r=c?c(t):{},o={stroke:r.stroke||"#999",strokeWidth:null!==(l=r.strokeWidth)&&void 0!==l?l:1,opacity:null!==(a=r.opacity)&&void 0!==a?a:.6};y.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:o,datum:t})}if(!1!==n.showLabels){const e=(m=n.nodeLabel)?"function"==typeof m?m:t=>t[m]||t.id:null;for(const n of t){if(null==n.x||null==n.y)continue;const t=e?e(n):n.id;if(!t)continue;const r=u(n);g.push({x:n.x,y:n.y-r-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var m;return{sceneNodes:f,sceneEdges:y,labels:g}}};function Bn(t,e,n){const r=[];for(const o of e){const e="string"==typeof o.source?o.source:o.source.id,i="string"==typeof o.target?o.target:o.target.id;let l=null;if(e===t?l=i:i===t&&(l=e),l){const t=n.get(l);!t||0===t.x&&0===t.y||r.push({x:t.x,y:t.y})}}return r}function jn(t){let e=0;for(let n=0;t.length>n;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return Math.abs(e)}function Fn(t,e,n){var o,i;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const a=e||[5,20],s=n.map(e=>{var n;return null===(n=e.data)||void 0===n?void 0:n[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===s.length)return()=>a[0];const c=null!==(o=l.min(s))&&void 0!==o?o:0,u=null!==(i=l.max(s))&&void 0!==i?i:1;if(c===u)return()=>(a[0]+a[1])/2;const h=r.scaleLinear().domain([c,u]).range(a).clamp(!0);return e=>{var n;const r=null===(n=e.data)||void 0===n?void 0:n[t];return null==r||"number"!=typeof r?a[0]:h(r)}}const Yn=i.schemeCategory10,Hn={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,r){if(0===t.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:l}=n,a=Math.min(r[0],r[1])/2,c=a-i,u=r[0]/2,h=r[1]/2,f=(y=n.valueAccessor)?"function"==typeof y?y:t=>{var e;return null!==(e=t[y])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var y;const g=new Map;for(let e=0;t.length>e;e++)g.set(t[e].id,e);const p=t.length,m=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=g.get("string"==typeof t.source?t.source:t.source.id),r=g.get(e);if(void 0===n||void 0===r)continue;const o=f(t);m[n][r]=o}const v=d.chord().padAngle(o);l&&v.sortGroups(l);const x=v(m),b=x.groups,k=s.arc().innerRadius(c).outerRadius(a);for(const e of b){const n=t[e.index],r=k.centroid(e);n.x=r[0]+u,n.y=r[1]+h,n.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const w=new Map;for(const e of t)w.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=w.get("string"==typeof t.source?t.source:t.source.id),r=w.get(e);n&&(t.source=n),r&&(t.target=r)}const E=new Map;for(const t of e)E.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of x){const n=t[e.source.index].id,r=t[e.target.index].id,o=E.get(`${n}\0${r}`)||E.get(`${r}\0${n}`);o&&(o.chordData=e)}},buildScene(t,e,n,r){var o,i;const{groupWidth:l=20,edgeOpacity:a=.5}=n,s=Math.min(r[0],r[1])/2,c=s-l,u=r[0]/2,h=r[1]/2,f=n.nodeStyle,y=n.edgeStyle,g=n.edgeColorBy||"source",p=Array.isArray(n.colorScheme)?n.colorScheme:Yn,m=new Map;t.forEach((t,e)=>{m.set(t.id,p[e%p.length])});const v=d.ribbon().radius(c),x=[],b=[],k=[];for(let e=0;t.length>e;e++){const n=t[e],r=n.arcData;if(!r)continue;let i;i=f?f(n).fill||m.get(n.id)||p[e%p.length]:m.get(n.id)||p[e%p.length];const l=f?f(n):{},a={fill:i,stroke:l.stroke||"black",strokeWidth:null!==(o=l.strokeWidth)&&void 0!==o?o:1,opacity:l.opacity};x.push({type:"arc",cx:u,cy:h,innerR:c,outerR:s,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:a,datum:n,id:n.id,label:n.id})}for(const t of e){const e=t.chordData;if(!e)continue;const n=v(e);if(!n)continue;const r=Xn(n,u,h);let o="#999";if(y)o=y(t).fill||o;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===g&&n?o=m.get(n.id)||o:e&&(o=m.get(e.id)||o)}const l=y?y(t):{},s={fill:o,fillOpacity:null!==(i=l.fillOpacity)&&void 0!==i?i:a,stroke:l.stroke||"none",strokeWidth:l.strokeWidth,opacity:l.opacity};b.push({type:"ribbon",pathD:r,style:s,datum:t})}if(!1!==n.showLabels){const e=(w=n.nodeLabel)?"function"==typeof w?w:t=>t[w]||t.id:null,r=s+12;for(const n of t){const t=n.arcData;if(!t)continue;const o=e?e(n):n.id;if(!o)continue;const i=(t.startAngle+t.endAngle)/2,l=i-Math.PI/2;k.push({x:u+Math.cos(l)*r,y:h+Math.sin(l)*r,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:x,sceneEdges:b,labels:k}}};function Xn(t,e,n){const r=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return t;const o=[];let i=0;for(;r.length>i;){const t=r[i];if("M"===t||"L"===t)for(o.push(t),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(Number(r[i])+e+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("C"===t)for(o.push(t),i++;r.length>i&&!isNaN(Number(r[i]));)for(let t=0;3>t&&r.length>i&&!isNaN(Number(r[i]));t++)o.push(Number(r[i])+e+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("Q"===t)for(o.push(t),i++;r.length>i&&!isNaN(Number(r[i]));)for(let t=0;2>t&&r.length>i&&!isNaN(Number(r[i]));t++)o.push(Number(r[i])+e+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("A"===t)for(o.push(t),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&(o.push(Number(r[i])+e+""),i++),r.length>i&&(o.push(Number(r[i])+n+""),i++);else"Z"===t||"z"===t?(o.push(t),i++):(o.push(r[i]),i++)}return o.join(" ")}const Gn=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Vn(t){const[e,n,r]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*r>150?"#222":"#fff"}function qn(t,e,n){const r=e.nodeIDAccessor;return"function"==typeof r?r(t.data)+"":"string"==typeof r&&void 0!==t.data[r]?t.data[r]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function Kn(t){return t?"function"==typeof t?t:e=>{var n;return(null===(n=e.data)||void 0===n?void 0:n[t])||e[t]||e.id}:null}function Un(t,e,n,r,o){if("horizontal"===o){const o=(t+n)/2;return`M ${t},${e} C ${o},${e} ${o},${r} ${n},${r}`}if("radial"===o){const o=(t+n)/2;return`M ${t},${e} Q ${o},${e} ${o},${(e+r)/2} T ${n},${r}`}{const o=(e+r)/2;return`M ${t},${e} C ${t},${o} ${n},${o} ${n},${r}`}}const Zn={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,r){var o;const i=n.__hierarchyRoot;if(!i)return;const l=n.chartType,s=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(n.childrenAccessor),c=n.hierarchySum||(t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0}),u=a.hierarchy(i,s);u.sum(c),u.sort((t,e)=>{var n,r;return(null!==(n=e.value)&&void 0!==n?n:0)-(null!==(r=t.value)&&void 0!==r?r:0)});const[h,d]=r;switch(l){case"tree":!function(t,e,n,r){const o=e.treeOrientation||"vertical",i=a.tree();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(t)}(u,n,h,d);break;case"cluster":!function(t,e,n,r){const o=e.treeOrientation||"vertical",i=a.cluster();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(t)}(u,n,h,d);break;case"treemap":!function(t,e,n,r){var o,i;const l=null!==(o=e.padding)&&void 0!==o?o:4,s=null!==(i=e.paddingTop)&&void 0!==i?i:0,c=a.treemap().size([n,r]).tile(a.treemapBinary).padding(l);s>0&&c.paddingTop(s),c(t)}(u,n,h,d);break;case"circlepack":!function(t,e,n,r){var o;const i=null!==(o=e.padding)&&void 0!==o?o:4;a.pack().size([n,r]).padding(i)(t)}(u,n,h,d);break;case"partition":!function(t,e,n,r){var o;a.partition().size([n,r]).padding(null!==(o=e.padding)&&void 0!==o?o:1)(t)}(u,n,h,d)}const f=u.descendants();t.length=0,e.length=0;const y=new Map;for(let e=0;f.length>e;e++){const r=f[e],i={id:qn(r,n,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=r.value)&&void 0!==o?o:0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===l||"cluster"===l?Qn(i,r,n):"treemap"===l||"partition"===l?Jn(i,r):"circlepack"===l&&tr(i,r),i.__hierarchyNode=r,t.push(i),y.set(r,i)}if("tree"===l||"cluster"===l)for(const t of f)if(t.parent){const n=y.get(t.parent),r=y.get(t);n&&r&&e.push({source:n,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,r){const o=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,r,o,i){var l,a,s,c,u;const h=[],d=[],f=[],y=n.treeOrientation||"vertical",g="radial"===y,p=r[0]/2,m=r[1]/2,v="number"==typeof(x=n.nodeSize)?x:5;var x;for(const e of t){let t=e.x,r=e.y;g&&(t+=p,r+=m);const i=o(e);let a=i.fill||"#4d430c";n.colorByDepth&&void 0!==e.depth&&(a=Gn[e.depth%Gn.length]);const s={fill:a,stroke:i.stroke||"#fff",strokeWidth:null!==(l=i.strokeWidth)&&void 0!==l?l:1,opacity:i.opacity};h.push({type:"circle",cx:t,cy:r,r:v,style:s,datum:e,id:e.id,label:e.id,depth:e.depth})}const b=null!==(a=n.edgeOpacity)&&void 0!==a?a:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;if(!e||!n)continue;let r=e.x,o=e.y,l=n.x,a=n.y;g&&(r+=p,o+=m,l+=p,a+=m);const u=Un(r,o,l,a,y),h=i(t),f={fill:"none",stroke:h.stroke||"#999",strokeWidth:null!==(s=h.strokeWidth)&&void 0!==s?s:1.5,opacity:null!==(c=h.opacity)&&void 0!==c?c:b};d.push({type:"curved",pathD:u,style:f,datum:t})}if(!1!==n.showLabels){const e=Kn(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let r,o,i,l=n.x,a=n.y;if(g&&(l+=p,a+=m),g){const t=l-p,e=a-m,n=Math.sqrt(t*t+e*e);n>0?(r=l+t/n*10,o=a+e/n*10,i=0>t?"end":"start"):(r=l,o=a-12,i="middle")}else"horizontal"===y?((null===(u=n.data)||void 0===u?void 0:u.children)&&0!==n.data.children.length?(r=l-v-6,i="end"):(r=l+v+6,i="start"),o=a):(r=l,o=a+v+14,i="middle");f.push({x:r,y:o,text:t+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:h,sceneEdges:d,labels:f}}(t,e,n,r,o,i);case"treemap":case"partition":return function(t,e,n,r){var o,i;const l=[],a=[];for(const n of t){const t=n.x1-n.x0,i=n.y1-n.y0;if(0>=t||0>=i)continue;const a=r(n);let s=a.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(s=Gn[n.depth%Gn.length]);const c={fill:s,stroke:a.stroke||"#fff",strokeWidth:null!==(o=a.strokeWidth)&&void 0!==o?o:1,opacity:a.opacity};l.push({type:"rect",x:n.x0,y:n.y0,w:t,h:i,style:c,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=Kn(e.nodeLabel),o=e.labelMode||"leaf",l="partition"===e.chartType;for(const s of t){const t=s.x1-s.x0,c=s.y1-s.y0;if(0>=t||0>=c)continue;const u=!((null===(i=s.data)||void 0===i?void 0:i.children)&&s.data.children.length>0);if(!l){if("leaf"===o&&!u)continue;if("parent"===o&&u)continue}const h=n?n(s):s.id;if(!h)continue;if((u?30:40)>t||(u?16:14)>c)continue;let d=r(s).fill||"#4d430c";e.colorByDepth&&void 0!==s.depth&&(d=Gn[s.depth%Gn.length]);const f=Vn(d);a.push(u?{x:s.x0+t/2,y:s.y0+c/2,text:h+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,c)/6)),fill:f}:{x:s.x0+4,y:s.y0+12,text:h+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:f})}}return{sceneNodes:l,sceneEdges:[],labels:a}}(t,n,0,o);case"circlepack":return function(t,e,n,r){var o,i,l,a,s;const c=[],u=[];for(const n of t){const t=null!==(o=n.__radius)&&void 0!==o?o:5;if(0>=t)continue;const a=r(n);let s=a.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(s=Gn[n.depth%Gn.length]);const u={fill:s,stroke:a.stroke||"#fff",strokeWidth:null!==(i=a.strokeWidth)&&void 0!==i?i:1,opacity:null!==(l=a.opacity)&&void 0!==l?l:.7};c.push({type:"circle",cx:n.x,cy:n.y,r:t,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=Kn(e.nodeLabel);for(const o of t){const t=null!==(a=o.__radius)&&void 0!==a?a:5,i=n?n(o):o.id;if(!i)continue;if(15>t)continue;const l=!((null===(s=o.data)||void 0===s?void 0:s.children)&&o.data.children.length>0);let c=r(o).fill||"#4d430c";if(e.colorByDepth&&void 0!==o.depth&&(c=Gn[o.depth%Gn.length]),l){const e=Vn(c);u.push({x:o.x,y:o.y,text:i+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:e})}else u.push({x:o.x,y:o.y-t+14,text:i+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:"#000",stroke:"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(t,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Qn(t,e,n){const r=n.treeOrientation||"vertical";if("radial"===r){const n=e.x,r=e.y;t.x=r*Math.cos(n-Math.PI/2),t.y=r*Math.sin(n-Math.PI/2)}else"horizontal"===r?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function Jn(t,e){t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.x=(e.x0+e.x1)/2,t.y=(e.y0+e.y1)/2,t.width=e.x1-e.x0,t.height=e.y1-e.y0}function tr(t,e){var n;const r=null!==(n=e.r)&&void 0!==n?n:0;t.x=e.x,t.y=e.y,t.x0=e.x-r,t.x1=e.x+r,t.y0=e.y-r,t.y1=e.y+r,t.width=2*r,t.height=2*r,t.__radius=r}function er(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const nr={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,r){const o=n.__hierarchyRoot;o&&function(t,e,n,r,o){var i,l;const a=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(n.childrenAccessor),c=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>{var n;return(null!==(n=t[e])&&void 0!==n?n:"")+""}}(n.nodeIDAccessor),u=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),h=null!==(i=n.orbitSize)&&void 0!==i?i:2.95,d=null!==(l=n.orbitEccentricity)&&void 0!==l?l:1,f="number"==typeof h?()=>h:h,y="number"==typeof d?()=>d:d,g=er(n);g.metaMap.clear(),r.length=0,o.length=0;const p=new Map;function m(t){var e;const n=null!==(e=p.get(t))&&void 0!==e?e:0;return p.set(t,n+1),0===n?t:`${t}__${n}`}const v=e[0]/2,x=e[1]/2,b=Math.min(e[0],e[1])/2*.85,k=m(c(t));r.push({id:k,x:v,y:x,x0:v,x1:v,y0:x,y1:x,width:0,height:0,value:0,depth:0,data:t}),g.metaMap.set(k,{ring:b,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,n,i,l,h,d,p){const v=a(e);if(!(null==v?void 0:v.length))return;const x=v.length;let b=0,k=0,w=0;for(;x>k;)k+=u[Math.min(w,u.length-1)],w++,b++;let E=0;for(let x=0;b>x;x++){const k=u[Math.min(x,u.length-1)],w=v.slice(E,E+k);if(!w.length)break;const A=(x+1)/b,M={id:n,depth:d,data:e,parentId:n},S=p?h/f(M)*A:h*A,_=s.pie().value(t=>{var e;return(null===(e=a(t))||void 0===e?void 0:e.length)?4:1}).sort(null),P=_(w),C=y(M);for(let e=0;w.length>e;e++){const a=(P[e].startAngle+P[e].endAngle)/2,s=w[e],u=m(c(s)),h=i+S*Math.sin(a),f=l+S*Math.cos(a)*C;r.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:d,data:s}),g.metaMap.set(u,{ring:S,angle:a,depth:d,parentId:n,eccentricity:C}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),t(s,u,h,f,S,d+1,!0)}E+=k}}(t,k,v,x,b,1,!1)}(o,r,n,t,e)},buildScene(t,e,n,r){var o,i,l,a,s;const c=n.nodeStyle,u=n.nodeSize,h="number"==typeof u?()=>u:"function"==typeof u?u:()=>6,d=[],f=[],y=[];if(!1!==n.orbitShowRings){const e=er(n),r=new Map;for(const e of t)r.set(e.id,e);const o=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=r.get(t.parentId);if(!e)continue;const n=`${t.parentId}:${t.ring}`;o.has(n)||o.set(n,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const i=48,l={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:n,ecc:r}]of o)for(let o=0;i>o;o++){const a=o/i*Math.PI*2,s=(o+1)/i*Math.PI*2;f.push({type:"line",x1:t+n*Math.sin(a),y1:e+n*Math.cos(a)*r,x2:t+n*Math.sin(s),y2:e+n*Math.cos(s)*r,style:l,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=h(e),n=c?c(e):{},r={fill:n.fill||"#6366f1",stroke:n.stroke||"#fff",strokeWidth:null!==(o=n.strokeWidth)&&void 0!==o?o:1,opacity:null!==(i=n.opacity)&&void 0!==i?i:0===(null!==(l=e.depth)&&void 0!==l?l:0)?1:.85};d.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id,depth:e.depth})}const g=new Map;for(const e of t)g.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:g.get(t.source),n="object"==typeof t.target?t.target:g.get(t.target);e&&n&&(null!=e.x&&null!=n.x&&f.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(n.showLabels){const e=n.nodeLabel;for(const n of t){const t=h(n);if(4>=t)continue;const r="function"==typeof e?e(n):e&&null!==(s=null===(a=n.data)||void 0===a?void 0:a[e])&&void 0!==s?s:n.id;y.push({x:n.x,y:n.y+t+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:d,sceneEdges:f,labels:y}},tick:(t,e,n,r,o)=>!1!==n.orbitAnimated&&(function(t,e){var n,r;const o=er(e),i=null!==(n=e.orbitSpeed)&&void 0!==n?n:.25,l=null!==(r=e.orbitRevolution)&&void 0!==r?r:function(t){switch(t){case"decay":return t=>{var e;return Math.pow(.6,null!==(e=t.depth)&&void 0!==e?e:0)};case"alternate":return t=>{var e;const n=null!==(e=t.depth)&&void 0!==e?e:0;return(n%2==0?1:-1)/(n+1)};default:return t=>{var e;return 1/((null!==(e=t.depth)&&void 0!==e?e:0)+1)}}}(e.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,s=i*(Math.PI/6),c=new Map;for(const e of t)c.set(e.id,e);for(const e of t){const t=o.metaMap.get(e.id);if(!t||!t.parentId)continue;const n=c.get(t.parentId);if(!n)continue;const r=t.angle+a*s*l({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=n.x+t.ring*Math.sin(r),e.y=n.y+t.ring*Math.cos(r)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,n),!0)},rr={sankey:zn,force:Rn,chord:Hn,tree:Zn,cluster:Zn,treemap:Zn,circlepack:Zn,partition:Zn,orbit:nr};function or(t){return rr[t]}class ir{constructor(t){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.particlePool=null,this.transition=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._lastPositionSnapshot=null,this.config=t,this.tensionConfig=Object.assign(Object.assign({},He),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&(this.particlePool=new Ge(2e3))}updateConfig(t){const e=this.config,n=t;e.__orbitState&&(n.__orbitState=e.__orbitState),e.__hierarchyRoot&&(n.__hierarchyRoot=e.__hierarchyRoot),this.config=t,this.tensionConfig=Object.assign(Object.assign({},He),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&!this.particlePool&&(this.particlePool=new Ge(2e3))}ingestHierarchy(t,e){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.config.__hierarchyRoot=t,this.runLayout(e)}ingestBounded(t,e,n){const{nodeIDAccessor:r="id",sourceAccessor:o="source",targetAccessor:i="target",valueAccessor:l="value"}=this.config,a="function"==typeof r?r:t=>t[r],s="function"==typeof o?o:t=>t[o],c="function"==typeof i?i:t=>t[i],u="function"==typeof l?l:t=>{var e;return null!==(e=t[l])&&void 0!==e?e:1};this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of t){const t=a(e)+"";this.nodes.set(t,Object.assign(Object.assign({},lr(t)),{data:e}))}for(let t=0;e.length>t;t++){const n=e[t],r=s(n)+"",o=c(n)+"",i=Number(u(n))||1;this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},lr(r)),{data:n})),this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},lr(o)),{data:n}));const l=`${r}\0${o}\0${t}`;this.edges.set(l,{source:r,target:o,value:i,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:l})}this.runLayout(n)}edgeKey(t,e){return`${t}\0${e}`}ingestEdge(t){const{source:e,target:n,value:r}=t,o=0===this.nodes.size;let i=!1;const l="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=l,this._decaySortedNodes=null,this.nodes.has(e)||(this.nodes.set(e,lr(e)),this.nodeTimestamps.set(e,l),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,lr(n)),this.nodeTimestamps.set(n,l),this.tension+=this.tensionConfig.newNode,i=!0);const a=this.edgeKey(e,n),s=this.edges.get(a);let c=!1;return s?(s.value+=r,this.edgeTimestamps.set(a,l),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(a,{source:e,target:n,value:r,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(a,l),this.tension+=this.tensionConfig.newEdge,i=!0),o||i||c||this.tension>=this.tensionConfig.threshold}runLayout(t){var e,n,r,o,i,l;const a=or(this.config.chartType);if(!a)return;let s=Array.from(this.nodes.values()),c=Array.from(this.edges.values());if(0===s.length&&!a.hierarchical)return;if(this.prepareForRelayout(),a.supportsStreaming&&!a.hierarchical){const t=new Map;for(const a of s)if(void 0!==a._prevX0){const s=(null!==(e=a._prevX1)&&void 0!==e?e:0)-(null!==(n=a._prevX0)&&void 0!==n?n:0),c=(null!==(r=a._prevY1)&&void 0!==r?r:0)-(null!==(o=a._prevY0)&&void 0!==o?o:0);t.set(a.id,{x:(null!==(i=a._prevX0)&&void 0!==i?i:0)+s/2,y:(null!==(l=a._prevY0)&&void 0!==l?l:0)+c/2})}else 0===a.x&&0===a.y||t.set(a.id,{x:a.x,y:a.y});if(this._lastPositionSnapshot)for(const[e,n]of this._lastPositionSnapshot)t.has(e)||t.set(e,n);this.config.__previousPositions=t.size>0?t:void 0}if(a.computeLayout(s,c,this.config,t),delete this.config.__previousPositions,a.hierarchical&&s.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const t of s)this.nodes.set(t.id,t);for(let t=0;c.length>t;t++){const e=c[t],n=e._edgeKey||`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}\0${t}`;e._edgeKey=n,this.edges.set(n,e)}}this.finalizeLayout();const u=new Map;for(const t of this.nodes.values())0===t.x&&0===t.y||u.set(t.id,{x:t.x,y:t.y});this._lastPositionSnapshot=u,this.saveTargetPositions(),s.some(t=>void 0!==t._prevX0&&(0!==t._prevX0||0!==t._prevX1||0!==t._prevY0||0!==t._prevY1))&&this.tensionConfig.transitionDuration>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:this.tensionConfig.transitionDuration});const h=new Set(this.nodes.keys()),d=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of h)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)h.has(t)||this.removedNodes.add(t);for(const t of d)this.previousEdgeKeys.has(t)||this.addedEdges.add(t);for(const t of this.previousEdgeKeys)d.has(t)||this.removedEdges.add(t);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=h,this.previousEdgeKeys=d,this.layoutVersion++}buildScene(t){const e=or(this.config.chartType);if(!e)return;const n=Array.from(this.nodes.values()),r=Array.from(this.edges.values()),{sceneNodes:o,sceneEdges:i,labels:l}=e.buildScene(n,r,this.config,t);this.sceneNodes=o,this.sceneEdges=i,this.labels=l}get isAnimating(){const t=or(this.config.chartType);return!!(null==t?void 0:t.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(t,e){const n=or(this.config.chartType);if(!(null==n?void 0:n.tick))return!1;const r=Array.from(this.nodes.values()),o=Array.from(this.edges.values());return n.tick(r,o,this.config,t,e)}advanceTransition(t){if(!this.transition)return!1;const e=N(t,this.transition),n=T(e);for(const t of this.nodes.values())void 0===t._targetX0||void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=$(t._prevX0,t._targetX0,n),t.x1=$(t._prevX1,t._targetX1,n),t.y0=$(t._prevY0,t._targetY0,n),t.y1=$(t._prevY1,t._targetY1,n));for(const t of this.edges.values())void 0!==t._targetY0&&void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&t._prevSankeyWidth>0&&(t.y0=$(t._prevY0,t._targetY0,n),t.y1=$(t._prevY1,t._targetY1,n),t.sankeyWidth=$(t._prevSankeyWidth,t._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>e||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){for(const t of this.nodes.values())t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1;for(const t of this.edges.values())t._prevY0=t.y0,t._prevY1=t.y1,t._prevSankeyWidth=t.sankeyWidth}finalizeLayout(){const t="vertical"===this.config.orientation?"down":"right";for(const t of this.nodes.values())if(0!==t.x0||0!==t.x1||0!==t.y0||0!==t.y1)t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;else{const e=5;t.x0=t.x-e,t.x1=t.x+e,t.y0=t.y-e,t.y1=t.y+e,t.width=2*e,t.height=2*e}for(const e of this.edges.values())e.direction=t,this.updateEdgeBezier(e);this.tension=0}saveTargetPositions(){for(const t of this.nodes.values())t._targetX0=t.x0,t._targetX1=t.x1,t._targetY0=t.y0,t._targetY1=t.y1;for(const t of this.edges.values())t._targetY0=t.y0,t._targetY1=t.y1,t._targetSankeyWidth=t.sankeyWidth}restorePreviousPositions(){for(const t of this.nodes.values())void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=t._prevX0,t.x1=t._prevX1,t.y0=t._prevY0,t.y1=t._prevY1);for(const t of this.edges.values())void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&t._prevSankeyWidth>0&&(t.y0=t._prevY0,t.y1=t._prevY1,t.sankeyWidth=t._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const t of this.nodes.values())void 0!==t._targetX0&&(t.x0=t._targetX0,t.x1=t._targetX1,t.y0=t._targetY0,t.y1=t._targetY1);for(const t of this.edges.values())void 0!==t._targetY0&&(t.y0=t._targetY0,t.y1=t._targetY1,t.sankeyWidth=t._targetSankeyWidth);this.rebuildAllBeziers()}updateEdgeBezier(t){const e="string"==typeof t.source?this.nodes.get(t.source):t.source,n="string"==typeof t.target?this.nodes.get(t.target):t.target;e&&n&&(t.bezier=t.circular&&t.circularPathData?this.buildCircularBezier(t):this.buildStandardBezier(t,e,n))}buildStandardBezier(t,e,n){const r=(t.sankeyWidth||1)/2;if("down"===t.direction){const o=e.x1,i=n.x0,l=u.interpolateNumber(o,i);return{circular:!1,points:[{x:t.y0,y:o},{x:t.y0,y:l(.5)},{x:t.y1,y:l(.5)},{x:t.y1,y:i}],halfWidth:r}}const o=e.x1,i=n.x0,l=u.interpolateNumber(o,i);return{circular:!1,points:[{x:o,y:t.y0},{x:l(.5),y:t.y0},{x:l(.5),y:t.y1},{x:i,y:t.y1}],halfWidth:r}}buildCircularBezier(t){const e=(t._circularWidth||t.sankeyWidth||1)/2,n=t.circularPathData;if(t._circularStub){const t=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),r=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*t,y:n.sourceY},{x:n.sourceX+.66*t,y:n.sourceY},{x:n.sourceX+t,y:n.sourceY}],[{x:n.targetX-r,y:n.targetY},{x:n.targetX-.66*r,y:n.targetY},{x:n.targetX-.33*r,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:e}}let r;r="down"===t.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const o=[];for(let t=0;r.length-1>t;t++){const e=r[t],n=r[t+1],i=n.x-e.x,l=n.y-e.y;o.push([e,{x:e.x+i/3,y:e.y+l/3},{x:e.x+2*i/3,y:e.y+2*l/3},n])}return{circular:!0,segments:o,halfWidth:e}}rebuildAllBeziers(){for(const t of this.nodes.values())t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;for(const t of this.edges.values())this.updateEdgeBezier(t)}applyPulse(t){var e,n,r,o,i;const l=this.config.pulse;if(!l)return;const a=null!==(e=l.duration)&&void 0!==e?e:500,s=null!==(n=l.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(r=l.glowRadius)&&void 0!==r?r:4;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const r=this.nodeTimestamps.get(n);if(!r)continue;const o=t-r;a>o&&(e._pulseIntensity=1-o/a,e._pulseColor=s,e._pulseGlowRadius=c)}for(const e of this.sceneEdges){const n=e.datum;if(!n)continue;const r="object"==typeof n.source?null===(o=n.source)||void 0===o?void 0:o.id:n.source,l="object"==typeof n.target?null===(i=n.target)||void 0===i?void 0:i.id:n.target;if(!r||!l)continue;const c=this.edgeTimestamps.get(`${r}\0${l}`);if(!c)continue;const u=t-c;a>u&&(e._pulseIntensity=1-u/a,e._pulseColor=s)}}applyDecay(){var t,e,n,r,o;const i=this.config.decay;if(!i)return;const l=null!==(t=i.minOpacity)&&void 0!==t?t:.1,a=this.nodeTimestamps.size;if(1>=a)return;this._decaySortedNodes||(this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((t,e)=>t[1]-e[1]));const s=this._decaySortedNodes,c=new Map;for(let t=0;s.length>t;t++)c.set(s[t][0],t);for(const t of this.sceneNodes){const s=t.id;if(!s)continue;const u=c.get(s);if(void 0===u)continue;const h=a-1-u;let d;switch(i.type){case"linear":d=l+(1-h/(a-1))*(1-l);break;case"exponential":{const t=null!==(e=i.halfLife)&&void 0!==e?e:a/2;d=l+Math.pow(.5,h/t)*(1-l);break}case"step":d=(null!==(n=i.stepThreshold)&&void 0!==n?n:.5*a)>h?1:l;break;default:d=1}const f=null!==(o=null===(r=t.style)||void 0===r?void 0:r.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:f*d})}}applyTopologyDiff(t){var e;if(0===this.addedNodes.size)return;const n=t-this.lastTopologyChangeTime;if(n>=2e3)return;const r=1-n/2e3;for(const t of this.sceneNodes){const n=t.id;n&&this.addedNodes.has(n)&&(t._pulseIntensity=Math.max(null!==(e=t._pulseIntensity)&&void 0!==e?e:0,r),t._pulseColor="rgba(34, 197, 94, 0.7)",t._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(t){var e,n;const r=this.config.thresholds;if(!r)return;const o=null!==(e=r.warningColor)&&void 0!==e?e:"#f59e0b",i=null!==(n=r.criticalColor)&&void 0!==n?n:"#ef4444",l=!1!==r.pulse;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const a=this.nodes.get(n);if(!a)continue;const s=r.metric(a);let c=null;void 0===r.critical||r.critical>s?void 0===r.warning||r.warning>s||(c=o):c=i,c&&(e.style=Object.assign(Object.assign({},e.style),{fill:c}),l&&(e._pulseIntensity=.6+.4*Math.sin(t/300),e._pulseColor=c,e._pulseGlowRadius=6))}}get hasActiveThresholds(){const t=this.config.thresholds;if(!t)return!1;for(const e of this.nodes.values()){const n=t.metric(e);if(void 0!==t.warning&&n>=t.warning||void 0!==t.critical&&n>=t.critical)return!0}return!1}get hasActivePulses(){var t;const e=this.config.pulse;if(!e||0===this.lastIngestTime)return!1;const n="undefined"!=typeof performance?performance.now():Date.now();return(null!==(t=e.duration)&&void 0!==t?t:500)>n-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function lr(t){return{id:t,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function ar(t,e,n,r,o=30){let i=null,l=o,a=1/0;for(const e of t){const t=sr(e,n,r);if(t)if("rect"===e.type){const n=e.w*e.h;a>n&&(i=t,a=n)}else l>t.distance&&(i=t,l=t.distance)}if(i)return i;for(const t of e){const e=dr(t,n,r);e&&l>e.distance&&(i=e,l=e.distance)}return i}function sr(t,e,n){switch(t.type){case"circle":return function(t,e,n){const r=e-t.cx,o=n-t.cy,i=Math.sqrt(r*r+o*o);return i>Math.max(t.r+5,12)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:i}}(t,e,n);case"rect":return function(t,e,n){const r=X(e,n,t);return r.hit?{type:"node",datum:t.datum,x:r.cx,y:r.cy,distance:0}:null}(t,e,n);case"arc":return function(t,e,n){const r=e-t.cx,o=n-t.cy,i=Math.sqrt(r*r+o*o);if(t.innerR-2>i||i>t.outerR+2)return null;const l=G(Math.atan2(o,r)),a=G(t.startAngle),s=G(t.endAngle);if(a>s?l>=a||s>=l:l>=a&&s>=l){const e=(t.startAngle+t.endAngle)/2,n=(t.innerR+t.outerR)/2;return{type:"node",datum:t.datum,x:t.cx+n*Math.cos(e),y:t.cy+n*Math.sin(e),distance:0}}return null}(t,e,n);default:return null}}let cr=null,ur=null;function hr(){return ur||(cr=document.createElement("canvas"),cr.width=1,cr.height=1,ur=cr.getContext("2d")),ur}function dr(t,e,n){switch(t.type){case"bezier":return function(t,e,n){var r,o;if(!t.pathD)return null;try{const i=new Path2D(t.pathD),l=hr();if(!l)return null;if(l.isPointInPath(i,e,n)){const i="object"==typeof(null===(r=t.datum)||void 0===r?void 0:r.source)?t.datum.source:null,l="object"==typeof(null===(o=t.datum)||void 0===o?void 0:o.target)?t.datum.target:null;return{type:"edge",datum:t.datum,x:i&&l?(i.x1+l.x0)/2:e,y:t.datum?(t.datum.y0+t.datum.y1)/2:n,distance:0}}const a=l.lineWidth;l.lineWidth=10;const s=l.isPointInStroke(i,e,n);if(l.lineWidth=a,s)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch(t){}return null}(t,e,n);case"line":return function(t,e,n){const r=t.x2-t.x1,o=t.y2-t.y1,i=r*r+o*o;if(0===i)return null;let l=((e-t.x1)*r+(n-t.y1)*o)/i;l=Math.max(0,Math.min(1,l));const a=t.x1+l*r,s=t.y1+l*o,c=Math.sqrt(Math.pow(e-a,2)+Math.pow(n-s,2));return c>5?null:{type:"edge",datum:t.datum,x:a,y:s,distance:c}}(t,e,n);case"ribbon":case"curved":return function(t,e,n){if(!t.pathD)return null;try{const r=new Path2D(t.pathD),o=hr();if(!o)return null;if(o.isPointInPath(r,e,n))return{type:"edge",datum:t.datum,x:e,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const l=o.isPointInStroke(r,e,n);if(o.lineWidth=i,l)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch(t){}return null}(t,e,n);default:return null}}function fr(t){const{width:e,height:n,totalWidth:r,totalHeight:o,margin:i,labels:l,title:a,legend:s,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d,legendPosition:f="right",foregroundGraphics:y,sceneNodes:p,annotations:m,svgAnnotationRules:v}=t;return g.createElement(g.Fragment,null,g.createElement("svg",{role:"img",width:r,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},g.createElement("title",null,"string"==typeof a?a:"Network Chart"),g.createElement("desc",null,"string"==typeof a?a+" — network data visualization":"Network data visualization"),g.createElement("g",{transform:`translate(${i.left},${i.top})`},l.map((t,e)=>g.createElement("text",{key:"label-"+e,x:t.x,y:t.y,textAnchor:t.anchor||"start",dominantBaseline:t.baseline||"middle",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"currentColor",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,style:{pointerEvents:"none"}},t.text)),m&&m.filter(t=>"widget"!==t.type).map((t,r)=>{if(v){const o=v(t,r,{width:e,height:n,sceneNodes:p});if(o)return g.createElement(g.Fragment,{key:"annotation-"+r},o)}return null}),y),a&&"string"==typeof a?g.createElement("text",{x:r/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},a):a?g.createElement("foreignObject",{x:0,y:0,width:r,height:i.top},a):null,yt({legend:s,totalWidth:r,totalHeight:o,margin:i,legendPosition:f,title:a,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d})),null==m?void 0:m.filter(t=>"widget"===t.type&&t.nodeId&&p).map((t,e)=>{var n,r,o,l,a,s,c,u,h;const d=p.find(e=>{var n,r,o,i,l;return e.id===t.nodeId||(null===(n=e.datum)||void 0===n?void 0:n.id)===t.nodeId||(null===(o=null===(r=e.datum)||void 0===r?void 0:r.data)||void 0===o?void 0:o.id)===t.nodeId||(null===(l=null===(i=e.datum)||void 0===i?void 0:i.data)||void 0===l?void 0:l.name)===t.nodeId});if(!d)return null;const f=i.left+(null!==(n=d.cx)&&void 0!==n?n:null!=d.x&&null!=d.w?d.x+d.w/2:null!==(r=d.x)&&void 0!==r?r:0),y=i.top+(null!==(o=d.cy)&&void 0!==o?o:null!=d.y&&null!=d.h?d.y+d.h/2:null!==(l=d.y)&&void 0!==l?l:0),m=null!==(a=t.dx)&&void 0!==a?a:0,v=null!==(s=t.dy)&&void 0!==s?s:-16,x=null!==(c=t.width)&&void 0!==c?c:32,b=null!==(u=t.height)&&void 0!==u?u:32,k=null!==(h=t.content)&&void 0!==h?h:g.createElement("span",{style:{fontSize:18,cursor:"default"}},"ℹ️");return g.createElement("div",{key:"widget-"+e,style:{position:"absolute",left:f+m-x/2,top:y+v-b/2,width:x,height:b,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5}},k)}))}function yr(t,e){var n,r,o,i,l,a;if(!e.pathD)return;t.save();const s=new Path2D(e.pathD);if(e.style.fill&&"none"!==e.style.fill){const l=e._gradient;if(l){const o=t.createLinearGradient(l.x0,0,l.x1,0),i=null!==(r=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==r?r:.5,a="string"==typeof e.style.fill?e.style.fill:"#999";o.addColorStop(0,1===l.from?a:"transparent"),o.addColorStop(1,1===l.to?a:"transparent"),t.fillStyle=o,t.globalAlpha=i}else t.fillStyle=e.style.fill,t.globalAlpha=null!==(i=null!==(o=e.style.fillOpacity)&&void 0!==o?o:e.style.opacity)&&void 0!==i?i:.5;t.fill(s)}e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(l=e.style.strokeWidth)&&void 0!==l?l:.5,t.globalAlpha=.5*(null!==(a=e.style.opacity)&&void 0!==a?a:1),t.stroke(s)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.2*e._pulseIntensity,t.fill(s)),t.restore()}function gr(t,e){var n,r;t.save(),t.strokeStyle=e.style.stroke||"#999",t.lineWidth=null!==(n=e.style.strokeWidth)&&void 0!==n?n:1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.strokeDasharray&&t.setLineDash(e.style.strokeDasharray.split(/[\s,]+/).map(Number)),t.beginPath(),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.stroke(),e._pulseIntensity&&e._pulseIntensity>0&&(t.setLineDash([]),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=(null!==(r=e.style.strokeWidth)&&void 0!==r?r:1)+3*e._pulseIntensity,t.globalAlpha=.4*e._pulseIntensity,t.beginPath(),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.stroke()),t.restore()}function pr(t,e){var n,r,o,i;if(!e.pathD)return;t.save();const l=new Path2D(e.pathD);e.style.fill&&"none"!==e.style.fill&&(t.fillStyle=e.style.fill,t.globalAlpha=null!==(r=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==r?r:.5,t.fill(l)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(o=e.style.strokeWidth)&&void 0!==o?o:.5,t.globalAlpha=.3*(null!==(i=e.style.opacity)&&void 0!==i?i:1),t.stroke(l)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.25*e._pulseIntensity,t.fill(l)),t.restore()}function mr(t,e){var n,r;if(!e.pathD)return;t.save();const o=new Path2D(e.pathD);t.strokeStyle=e.style.stroke||"#999",t.lineWidth=null!==(n=e.style.strokeWidth)&&void 0!==n?n:1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.stroke(o),e.style.fill&&"none"!==e.style.fill&&(t.fillStyle=e.style.fill,t.globalAlpha=null!==(r=e.style.fillOpacity)&&void 0!==r?r:.1,t.fill(o)),t.restore()}fr.displayName="NetworkSVGOverlay";const vr={top:20,right:80,bottom:20,left:80},xr={top:40,right:40,bottom:40,left:40},br=new Set(["chord","force","circlepack","orbit"]),kr=[800,600],wr={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Er({data:t}){var e,n,r,o,i,l;if("edge"===t.type){const e=t.data;return g.createElement("div",{className:"semiotic-tooltip",style:wr},g.createElement("div",{style:{fontWeight:600}},"object"==typeof e.source?e.source.id:e.source," → ","object"==typeof e.target?e.target.id:e.target),null!=e.value&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof e.value?e.value.toLocaleString():e.value+""))}const a=t.data,s=null==a?void 0:a.__hierarchyNode;if(s){const t=[];let i=s;for(;i;){const l=null!==(o=null!==(n=null===(e=i.data)||void 0===e?void 0:e.name)&&void 0!==n?n:null===(r=i.data)||void 0===r?void 0:r.id)&&void 0!==o?o:a.id;null!=l&&t.unshift(l+""),i=i.parent}t.length>1&&t.shift();const l=t.length-1;return g.createElement("div",{className:"semiotic-tooltip",style:wr},g.createElement("div",null,t.map((t,e)=>g.createElement("span",{key:e},e>0&&g.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),e===l?g.createElement("strong",null,t):g.createElement("span",{style:{opacity:.7}},t)))),null!=a.value&&a.value>0&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof a.value?a.value.toLocaleString():a.value+""))}const c=((null===(i=a.sourceLinks)||void 0===i?void 0:i.length)||0)+((null===(l=a.targetLinks)||void 0===l?void 0:l.length)||0),u=(a.sourceLinks||[]).reduce((t,e)=>t+(e.value||0),0)+(a.targetLinks||[]).reduce((t,e)=>t+(e.value||0),0);return g.createElement("div",{className:"semiotic-tooltip",style:wr},g.createElement("div",{style:{fontWeight:600}},a.id),null!=a.value&&a.value>0&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof a.value?a.value.toLocaleString():a.value+""),c>0&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",c,u!==c&&` (weighted: ${u.toLocaleString()})`))}const Ar=t.forwardRef(function(e,n){var r,o,i,l,a,c,u,h,d,f,y,p,m,v;const{chartType:x,nodes:b,edges:k,data:w,initialEdges:E,nodeIDAccessor:A="id",sourceAccessor:M="source",targetAccessor:S="target",valueAccessor:_="value",childrenAccessor:C,hierarchySum:D,orientation:L="horizontal",nodeAlign:T="justify",nodePaddingRatio:N=.05,nodeWidth:$=15,iterations:O=300,forceStrength:W=.1,padAngle:I=.01,groupWidth:z=20,sortGroups:R,edgeSort:B,treeOrientation:j="vertical",edgeType:F="curve",padding:Y,paddingTop:H,tensionConfig:X,showParticles:G=!1,particleStyle:V,nodeStyle:q,edgeStyle:K,colorBy:U,colorScheme:Z="category10",edgeColorBy:Q="source",edgeOpacity:J=.5,colorByDepth:tt=!1,nodeSize:ot=8,nodeSizeRange:it=[5,20],nodeLabel:st,showLabels:ct=!0,labelMode:ut,size:ht=kr,responsiveWidth:dt,responsiveHeight:ft,margin:yt,className:gt,background:pt,enableHover:mt=!0,tooltipContent:vt,customHoverBehavior:xt,customClickBehavior:bt,onObservation:kt,chartId:wt,onTopologyChange:Et,annotations:At,svgAnnotationRules:Mt,legend:St,legendPosition:_t,legendHoverBehavior:Pt,legendClickBehavior:Ct,legendHighlightedCategory:Dt,legendIsolatedCategories:Lt,title:Tt,foregroundGraphics:Nt,backgroundGraphics:$t,decay:Ot,pulse:Wt,staleness:It,thresholds:zt,accessibleTable:Rt=!0,description:Bt,summary:Yt,orbitMode:Ht,orbitSize:Xt,orbitSpeed:Gt,orbitRevolution:qt,orbitRevolutionStyle:Kt,orbitEccentricity:Ut,orbitShowRings:Zt,orbitAnimated:Qt}=e,Jt=ue(),te=t.useRef(Jt);te.current=Jt;const ee="semiotic-table-"+g.useId(),ne=br.has(x)?xr:vr,[ae,he]=lt(ht,dt,ft),de=Object.assign(Object.assign({},ne),yt),fe=he[0]-de.left-de.right,ye=he[1]-de.top-de.bottom,ge="function"==typeof Nt?Nt({size:he,margin:de}):Nt,pe=t.useMemo(()=>Object.assign(Object.assign({},He),X),[X]),be=t.useMemo(()=>Object.assign(Object.assign({},Xe),V),[V]),ke=t.useMemo(()=>({chartType:x,nodeIDAccessor:A,sourceAccessor:M,targetAccessor:S,valueAccessor:_,childrenAccessor:C,hierarchySum:D,orientation:L,nodeAlign:T,nodePaddingRatio:N,nodeWidth:$,iterations:O,forceStrength:W,padAngle:I,groupWidth:z,sortGroups:R,edgeSort:B,treeOrientation:j,edgeType:F,padding:Y,paddingTop:H,tensionConfig:pe,showParticles:G,particleStyle:be,nodeStyle:q,edgeStyle:K,nodeLabel:st,showLabels:ct,labelMode:ut,colorBy:U,colorScheme:Z,edgeColorBy:Q,edgeOpacity:J,colorByDepth:tt,nodeSize:ot,nodeSizeRange:it,decay:Ot,pulse:Wt,staleness:It,thresholds:zt,orbitMode:Ht,orbitSize:Xt,orbitSpeed:Gt,orbitRevolution:qt,orbitRevolutionStyle:Kt,orbitEccentricity:Ut,orbitShowRings:Zt,orbitAnimated:Qt}),[x,A,M,S,_,C,D,L,T,N,$,O,W,I,z,R,B,j,F,Y,H,pe,G,be,q,K,st,ct,ut,U,Z,Q,J,tt,ot,it,Ot,Wt,It,zt,Ht,Xt,Gt,qt,Kt,Ut,Zt,Qt]),we=t.useRef(null),Ee=t.useRef(0),Se=t.useRef(0),_e=t.useRef(!0),Pe=me(t=>t.theme),Ce=t.useRef(()=>{}),De=t.useRef(null);De.current||(De.current=new ir(ke));const[Le,Te]=t.useState(null),[Ne,$e]=t.useState(0),[Oe,We]=t.useState(0),[Ie,ze]=t.useState(!1),Re=t.useRef(null),Be=t.useRef(new Map),je=t.useRef(0),Fe=t.useCallback(t=>{if("function"==typeof U)return U(t)+"";if("string"==typeof U&&t.data){const e=t.data[U];if(void 0!==e){if(!Be.current.has(e+"")){const t=Array.isArray(Z)?Z:P;Be.current.set(e+"",t[je.current++%t.length])}return Be.current.get(e+"")}}if(Be.current.has(t.id))return Be.current.get(t.id);const e=Array.isArray(Z)?Z:P,n=U?e[je.current++%e.length]:e[0];return Be.current.set(t.id,n),n},[U,Z]),Ye=t.useCallback(t=>{if("function"==typeof Q)return Q(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===Q&&n?Fe(n):e?Fe(e):"#999"},[Q,Fe]),Ge=t.useCallback(t=>{if(!(null==V?void 0:V.colorBy))return Ye(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===be.colorBy&&n?Fe(n):e?Fe(e):"#999"},[null==V?void 0:V.colorBy,be.colorBy,Fe,Ye]),Ve="sankey"===x&&G||!!Wt||null!==(o=null===(r=De.current)||void 0===r?void 0:r.isAnimating)&&void 0!==o&&o,qe=t.useCallback(()=>{Ee.current&&!Ve||Ee.current||(Ee.current=requestAnimationFrame(()=>Ce.current()))},[Ve]);t.useEffect(()=>{var t;null===(t=De.current)||void 0===t||t.updateConfig(ke),_e.current=!0,qe()},[ke,qe]),t.useEffect(()=>{_e.current=!0,qe()},[Pe,qe]);const Ke=t.useCallback(()=>{var t;const e=De.current;if(!e)return;e.runLayout([fe,ye]),e.buildScene([fe,ye]),_e.current=!0;for(const n of e.sceneNodes)n.id&&"string"==typeof(null===(t=n.style)||void 0===t?void 0:t.fill)&&Be.current.set(n.id,n.style.fill);const n=Array.isArray(Z)?Z:P,r=Array.from(e.nodes.values());for(let t=0;r.length>t;t++){const e=r[t];Be.current.has(e.id)||Be.current.set(e.id,n[t%n.length])}if(je.current=r.length,$e(e.layoutVersion),Et){const{nodes:t,edges:n}=e.getLayoutData();Et(t,n)}},[fe,ye,Et,Z]),Ue=t.useCallback(t=>{const e=De.current;e&&(e.ingestEdge(t)&&Ke(),qe())},[Ke,qe]),Ze=t.useCallback(t=>{const e=De.current;if(!e)return;let n=!1;for(const r of t)e.ingestEdge(r)&&(n=!0);n&&Ke(),qe()},[Ke,qe]),Qe=t.useCallback(()=>{var t;null===(t=De.current)||void 0===t||t.clear(),Be.current.clear(),je.current=0,$e(0),Te(null),Re.current=null,_e.current=!0,qe()},[qe]),Je=t.useCallback(()=>{const t=De.current;t&&(t.tension+=999,Ke(),qe())},[Ke,qe]);t.useImperativeHandle(n,()=>({push:Ue,pushMany:Ze,clear:Qe,getTopology:()=>{var t,e;return null!==(e=null===(t=De.current)||void 0===t?void 0:t.getLayoutData())&&void 0!==e?e:{nodes:[],edges:[]}},getTopologyDiff:()=>{const t=De.current;return t?{addedNodes:Array.from(t.addedNodes),removedNodes:Array.from(t.removedNodes),addedEdges:Array.from(t.addedEdges),removedEdges:Array.from(t.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:Je,getTension:()=>{var t,e;return null!==(e=null===(t=De.current)||void 0===t?void 0:t.tension)&&void 0!==e?e:0}}),[Ue,Ze,Qe,Je]);const tn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(x),en=tn?w||(Array.isArray(k)?void 0:k):void 0;t.useEffect(()=>{var t;const e=De.current;if(e)if(tn&&en)e.ingestHierarchy(en,[fe,ye]),e.buildScene([fe,ye]),_e.current=!0,qe();else{const n=b||[],r=Array.isArray(k)?k:[];if(0===n.length&&0===r.length)return;e.ingestBounded(n,r,[fe,ye]),e.buildScene([fe,ye]);for(const n of e.sceneNodes)n.id&&(null===(t=n.style)||void 0===t?void 0:t.fill)&&Be.current.set(n.id,n.style.fill+"");const o=Array.isArray(Z)?Z:P,i=Array.from(e.nodes.values());for(let t=0;i.length>t;t++){const e=i[t];Be.current.has(e.id)||Be.current.set(e.id,o[t%o.length])}je.current=i.length,_e.current=!0,qe()}},[b,k,w,en,tn,fe,ye,ke,qe,Z]),t.useEffect(()=>{E&&E.length>0&&Ze(E)},[]);const nn=t.useCallback(t=>{if(xt&&xt(t),kt){const e=Date.now();kt(t?{type:"hover",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:wt}:{type:"hover-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:wt})}},[xt,kt,wt]),rn=t.useCallback(t=>{if(bt&&bt(t),kt){const e=Date.now();kt(t?{type:"click",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:wt}:{type:"click-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:wt})}},[bt,kt,wt]),on=t.useRef(()=>{}),ln=t.useRef(()=>{});on.current=t=>{if(!mt)return;const e=we.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-de.left,o=t.clientY-n.top-de.top;if(0>r||r>fe||0>o||o>ye)return void(Re.current&&(Re.current=null,Te(null),nn&&(nn(null),_e.current=!0),qe()));const i=De.current;if(!i)return;const l=ar(i.sceneNodes,i.sceneEdges,r,o);if(!l)return void(Re.current&&(Re.current=null,Te(null),nn&&(nn(null),_e.current=!0),qe()));const a=l.datum||{},s=Object.assign(Object.assign({},"object"!=typeof a||null===a||Array.isArray(a)?{}:a),{type:l.type,data:a,x:l.x,y:l.y});Re.current=s,Te(s),nn&&(nn(s),_e.current=!0),qe()},ln.current=()=>{Re.current&&(Re.current=null,Te(null),nn&&(nn(null),_e.current=!0),qe())};const an=t.useRef(()=>{});an.current=t=>{if(!bt&&!kt)return;const e=we.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-de.left,o=t.clientY-n.top-de.top;if(0>r||r>fe||0>o||o>ye)return;const i=De.current;if(!i)return;const l=ar(i.sceneNodes,i.sceneEdges,r,o);if(l){const t=l.datum||{};rn(Object.assign(Object.assign({},"object"!=typeof t||null===t||Array.isArray(t)?{}:t),{type:l.type,data:t,x:l.x,y:l.y}))}else rn(null)},t.useCallback(t=>on.current(t),[]);const sn=t.useCallback(()=>ln.current(),[]),cn=t.useCallback(t=>an.current(t),[]),un=t.useRef(-1),hn=t.useRef(null),dn=t.useRef(-1),fn=t.useCallback(t=>{var e;const n=De.current;if(!n)return;const r=function(t){var e,n,r,o,i,l;const a=[];for(const s of t)"circle"===s.type&&null!=s.cx?a.push({x:s.cx,y:s.cy,datum:s.datum,shape:"circle",group:null!==(n=null===(e=s.datum)||void 0===e?void 0:e.id)&&void 0!==n?n:"_default"}):"rect"===s.type&&null!=s.x?a.push({x:s.x+s.w/2,y:s.y+s.h/2,datum:s.datum,shape:"rect",w:s.w,h:s.h,group:null!==(o=null===(r=s.datum)||void 0===r?void 0:r.id)&&void 0!==o?o:"_default"}):"arc"===s.type&&null!=s.cx&&a.push({x:s.cx,y:s.cy,datum:s.datum,shape:"circle",group:null!==(l=null===(i=s.datum)||void 0===i?void 0:i.id)&&void 0!==l?l:"_default"});return a.sort((t,e)=>t.x-e.x||t.y-e.y),a}(n.sceneNodes);if(0===r.length)return;const o=et(r),i=un.current;if(0>i){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(t.key))return;t.preventDefault(),un.current=0,dn.current=-1;const e=o.flat[0];hn.current={shape:e.shape,w:e.w,h:e.h};const n=e.datum||{},r=Object.assign(Object.assign({},"object"!=typeof n||null===n||Array.isArray(n)?{}:n),{type:"node",data:n,x:e.x,y:e.y});return Re.current=r,Te(r),nn&&(nn(r),_e.current=!0),void qe()}const l=nt(o,i),a=function(t,e,n,r,o){var i,l,a;const s=n.flat[e.flatIndex];if(!s)return rt(t,e,n);const c=null===(i=s.datum)||void 0===i?void 0:i.id;switch(t){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const r=null!==(l=function(t,e,n){let r=null,o=1/0;for(let i=0;t.flat.length>i;i++){const l=t.flat[i];if(l===e)continue;const a=l.x-e.x,s=l.y-e.y;let c=!1;switch(n){case"right":c=a>0&&Math.abs(a)>=Math.abs(s);break;case"left":c=0>a&&Math.abs(a)>=Math.abs(s);break;case"down":c=s>0&&Math.abs(s)>=Math.abs(a);break;case"up":c=0>s&&Math.abs(s)>=Math.abs(a)}if(!c)continue;const u=a*a+s*s;o>u&&(o=u,r=i)}return r}(n,s,"ArrowRight"===t?"right":"ArrowLeft"===t?"left":"ArrowDown"===t?"down":"up"))&&void 0!==l?l:e.flatIndex;return r!==e.flatIndex&&(o.current=-1),r}case"Enter":{if(null==c)return e.flatIndex;const t=function(t,e){var n,r,o;const i=t+"",l=[];for(const t of e){const e=null!==(n=t.datum)&&void 0!==n?n:t,a="object"==typeof e.source?null===(r=e.source)||void 0===r?void 0:r.id:e.source,s="object"==typeof e.target?null===(o=e.target)||void 0===o?void 0:o.id:e.target,c=null!=a,u=null!=s;c&&a+""===i&&u?l.push(s+""):u&&s+""===i&&c&&l.push(a+"")}return l}(c,r);if(0===t.length)return e.flatIndex;const i=null!==(a=n.idToIdx.get(t[(o.current+1)%t.length]))&&void 0!==a?a:-1;return 0>i?e.flatIndex:(o.current=-1,i)}default:{const r=rt(t,e,n);return null!==r&&r!==e.flatIndex&&(o.current=-1),r}}}(t.key,l,o,null!==(e=n.sceneEdges)&&void 0!==e?e:[],dn);if(null===a)return;if(t.preventDefault(),0>a)return un.current=-1,hn.current=null,dn.current=-1,Re.current=null,Te(null),nn&&(nn(null),_e.current=!0),void qe();un.current=a;const s=o.flat[a];hn.current={shape:s.shape,w:s.w,h:s.h};const c=s.datum||{},u=Object.assign(Object.assign({},"object"!=typeof c||null===c||Array.isArray(c)?{}:c),{type:"node",data:c,x:s.x,y:s.y});Re.current=u,Te(u),nn&&(nn(u),_e.current=!0),qe()},[nn,qe]),yn=t.useCallback(t=>{un.current=-1,hn.current=null,on.current(t)},[]);Ce.current=()=>{var t,e,n,r,o,i,l;Ee.current=0;const a=we.current;if(!a)return;const s=a.getContext("2d");if(!s)return;const c=De.current;if(!c)return;const u=performance.now(),h=Se.current?Math.min((u-Se.current)/1e3,.1):.016;Se.current=u;const d=c.advanceTransition(te.current?u+1e6:u),f=!te.current&&d,y=!te.current&&c.tickAnimation([fe,ye],h);(d||_e.current||y)&&c.buildScene([fe,ye]);const g=xe();if(!ve(a,he,de,g))return;s.clearRect(-de.left,-de.top,he[0],he[1]),pt&&(s.fillStyle=pt,s.fillRect(0,0,fe,ye)),Ot&&c.applyDecay(),Wt&&c.applyPulse(u),zt&&c.applyThresholds(u),c.applyTopologyDiff(u);const p=null!==(t=null==It?void 0:It.threshold)&&void 0!==t?t:5e3,m=It&&c.lastIngestTime>0&&u-c.lastIngestTime>p;if(m&&(s.globalAlpha=null!==(e=null==It?void 0:It.dimOpacity)&&void 0!==e?e:.5),function(t,e){for(const n of e)switch(n.type){case"bezier":yr(t,n);break;case"line":gr(t,n);break;case"ribbon":pr(t,n);break;case"curved":mr(t,n)}}(s,c.sceneEdges),function(t,e){var n,r,o;for(const i of e){if("rect"!==i.type)continue;const e=i;e.w>0&&e.h>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.fill&&(t.fillStyle=e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fillRect(e.x,e.y,e.w,e.h)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(r=e.style.strokeWidth)&&void 0!==r?r:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.strokeRect(e.x,e.y,e.w,e.h)),Ae(t,e),t.restore())}}(s,c.sceneNodes),function(t,e){var n,r,o;for(const i of e){if("circle"!==i.type)continue;const e=i;e.r>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.r,0,2*Math.PI),e.style.fill&&(t.fillStyle=e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(r=e.style.strokeWidth)&&void 0!==r?r:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.stroke()),Me(t,e),t.restore())}}(s,c.sceneNodes),function(t,e){var n,r,o;for(const i of e){if("arc"!==i.type)continue;const e=i;t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.outerR,e.startAngle,e.endAngle),t.arc(e.cx,e.cy,e.innerR,e.endAngle,e.startAngle,!0),t.closePath(),e.style.fill&&(t.fillStyle=e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(r=e.style.strokeWidth)&&void 0!==r?r:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.stroke()),t.restore()}}(s,c.sceneNodes),G&&c.particlePool&&!m){const t=Array.from(c.edges.values());if(t.length>0){!function(t,e,n,r){var o,i;const l=null!==(o=r.spawnRate)&&void 0!==o?o:Xe.spawnRate,a=null!==(i=r.maxPerEdge)&&void 0!==i?i:Xe.maxPerEdge;for(let r=0;e.length>r;r++){const o=e[r];if(!o.bezier)continue;if(t.countForEdge(r)>=a)continue;const i=o.value*l*n*(o.bezier.circular?.3:1),s=Math.floor(i),c=i-s;let u=s;Math.random()<c&&u++;for(let e=0;u>e&&t.countForEdge(r)<a;e++)t.spawn(r)}}(c.particlePool,t,h,be);const e=.5*(null!==(n=be.speedMultiplier)&&void 0!==n?n:1);let r;if(be.proportionalSpeed){const e=t.reduce((t,e)=>Math.max(t,e.value||1),1);r=t.map(t=>.3+(t.value||1)/e*1.7)}c.particlePool.step(h,e,t,r),function(t,e,n,r,o){var i,l;const a=null!==(i=r.radius)&&void 0!==i?i:Xe.radius,s=null!==(l=r.opacity)&&void 0!==l?l:Xe.opacity;t.globalAlpha=s;for(let i=0;e.particles.length>i;i++){const l=e.particles[i];if(!l.active)continue;const s=n[l.edgeIndex];if(s){if("function"==typeof r.color){const e="object"==typeof s.source?s.source:null;t.fillStyle=e?r.color(s,e):"#666"}else t.fillStyle=r.color&&"inherit"!==r.color?r.color:o(s);t.beginPath(),t.arc(l.x,l.y,a,0,2*Math.PI),t.fill()}}t.globalAlpha=1}(s,c.particlePool,t,be,Ge)}}m&&(s.globalAlpha=1);const v=_e.current;if(_e.current=!1,v||f||y){const t=we.current;t&&t.setAttribute("aria-label",Vt(null!==(o=null===(r=c.sceneNodes)||void 0===r?void 0:r.length)&&void 0!==o?o:0,null!==(l=null===(i=c.sceneEdges)||void 0===i?void 0:i.length)&&void 0!==l?l:0,"Network chart"))}(v||f||y)&&We(t=>t+1),(Ve||f||y||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff)&&(Ee.current=requestAnimationFrame(()=>Ce.current()))},t.useEffect(()=>(qe(),()=>{Ee.current&&(cancelAnimationFrame(Ee.current),Ee.current=0)}),[qe]),t.useEffect(()=>{_e.current=!0,qe()},[x,fe,ye,pt,qe]),at(It,De,_e,qe,Ie,ze);const gn=mt&&Le?g.createElement(ce,{x:Le.x,y:Le.y,containerWidth:fe,containerHeight:ye,margin:de,className:"stream-network-tooltip",zIndex:2},vt?vt(Le):g.createElement(Er,{data:Le})):null;if(Ft){const t=De.current;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(x),n=e?w||(Array.isArray(k)?void 0:k):void 0;if(e&&n)t.ingestHierarchy(n,[fe,ye]),t.buildScene([fe,ye]);else{const e=b||[],n=Array.isArray(k)?k:[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[fe,ye]),t.buildScene([fe,ye]))}}const e=null!==(i=null==t?void 0:t.sceneNodes)&&void 0!==i?i:[],n=null!==(l=null==t?void 0:t.sceneEdges)&&void 0!==l?l:[],r=null!==(a=null==t?void 0:t.labels)&&void 0!==a?a:[];return g.createElement("div",{className:"stream-network-frame"+(gt?" "+gt:""),role:"img","aria-label":Bt||("string"==typeof Tt?Tt:"Network chart"),style:{position:"relative",width:he[0],height:he[1]}},g.createElement(oe,{summary:Yt}),g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:he[0],height:he[1],style:{position:"absolute",left:0,top:0}},$t&&g.createElement("g",{transform:`translate(${de.left},${de.top})`},$t),g.createElement("g",{transform:`translate(${de.left},${de.top})`},pt&&g.createElement("rect",{x:0,y:0,width:fe,height:ye,fill:pt}),n.map((t,e)=>function(t,e){switch(t.type){case"line":return g.createElement("line",{key:"net-edge-"+e,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity});case"bezier":{const n=t;return g.createElement("path",{key:"net-edge-"+e,d:n.pathD,fill:jt(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"ribbon":{const n=t;return g.createElement("path",{key:"net-edge-"+e,d:n.pathD,fill:jt(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"curved":{const n=t;return g.createElement("path",{key:"net-edge-"+e,d:n.pathD,fill:jt(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity})}default:return null}}(t,e)).filter(Boolean),e.map((t,e)=>function(t,e){switch(t.type){case"circle":{const n=t;return g.createElement("circle",{key:"net-circle-"+e,cx:n.cx,cy:n.cy,r:n.r,fill:jt(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"rect":{const n=t;return g.createElement("rect",{key:"net-rect-"+e,x:n.x,y:n.y,width:n.w,height:n.h,fill:jt(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"arc":{const n=t,r=s.arc().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle).endAngle(n.endAngle)({})||"";return g.createElement("path",{key:"net-arc-"+e,d:r,transform:`translate(${n.cx},${n.cy})`,fill:jt(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}default:return null}}(t,e)).filter(Boolean),r.map((t,e)=>function(t,e){return g.createElement("text",{key:"net-label-"+e,x:t.x,y:t.y,textAnchor:t.anchor||"middle",dominantBaseline:t.baseline||"auto",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"#333",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder},t.text)}(t,e)).filter(Boolean))),g.createElement(fr,{width:fe,height:ye,totalWidth:he[0],totalHeight:he[1],margin:de,labels:r,sceneNodes:e,title:Tt,legend:St,legendPosition:_t,legendHoverBehavior:Pt,legendClickBehavior:Ct,legendHighlightedCategory:Dt,legendIsolatedCategories:Lt,foregroundGraphics:ge,annotations:At,svgAnnotationRules:Mt,annotationFrame:0}))}const pn=De.current;return g.createElement("div",{ref:ae,className:"stream-network-frame"+(gt?" "+gt:""),role:"group","aria-label":Bt||("string"==typeof Tt?Tt:"Network chart"),tabIndex:0,style:{position:"relative",width:dt?"100%":he[0],height:ft?"100%":he[1],overflow:"visible"},onKeyDown:fn},Rt&&g.createElement(ie,{tableId:ee}),Rt&&g.createElement(re,{nodes:null!==(c=null==pn?void 0:pn.sceneNodes)&&void 0!==c?c:[],edges:null!==(u=null==pn?void 0:pn.sceneEdges)&&void 0!==u?u:[],chartType:"Network chart",tableId:ee,chartTitle:"string"==typeof Tt?Tt:void 0}),g.createElement(oe,{summary:Yt}),g.createElement("div",{role:"img","aria-label":Bt||("string"==typeof Tt?Tt:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:mt?yn:void 0,onMouseLeave:mt?sn:void 0,onClick:bt||kt?cn:void 0},$t&&g.createElement("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:he[0],height:he[1],pointerEvents:"none",overflow:"visible"}},g.createElement("g",{transform:`translate(${de.left},${de.top})`},$t)),g.createElement("canvas",{ref:we,"aria-label":Vt(null!==(d=null===(h=null==pn?void 0:pn.sceneNodes)||void 0===h?void 0:h.length)&&void 0!==d?d:0,null!==(y=null===(f=null==pn?void 0:pn.sceneEdges)||void 0===f?void 0:f.length)&&void 0!==y?y:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),g.createElement(le,{hoverPoint:Le}),g.createElement(fr,{width:fe,height:ye,totalWidth:he[0],totalHeight:he[1],margin:de,labels:(null==pn?void 0:pn.labels)||[],sceneNodes:null==pn?void 0:pn.sceneNodes,title:Tt,legend:St,legendPosition:_t,legendHoverBehavior:Pt,legendClickBehavior:Ct,legendHighlightedCategory:Dt,legendIsolatedCategories:Lt,foregroundGraphics:ge,annotations:At,svgAnnotationRules:Mt,annotationFrame:Oe}),g.createElement(se,{active:un.current>=0,hoverPoint:Le,margin:de,size:he,shape:null===(p=hn.current)||void 0===p?void 0:p.shape,width:null===(m=hn.current)||void 0===m?void 0:m.w,height:null===(v=hn.current)||void 0===v?void 0:v.h}),gn,(null==It?void 0:It.showBadge)&&g.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===It.badgePosition?{top:4,left:4}:"bottom-left"===It.badgePosition?{bottom:4,left:4}:"bottom-right"===It.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Ie?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},Ie?"STALE":"LIVE")))});function Mr(t){const e=[];for(const[n,r]of Object.entries(t.fields))if("point"===r.type)e.push(t=>r.values.has(t[n]));else{const[t,o]=r.range;e.push(e=>{const r=e[n];return r>=t&&o>=r})}return t=>e.every(e=>e(t))}function Sr(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}Ar.displayName="StreamNetworkFrame";const[_r,Pr]=he(t=>({selections:new Map,setClause(e,n){t(t=>{const r=new Map(t.selections),o=Sr(r,e),i=new Map(o.clauses);return i.set(n.clientId,n),r.set(e,Object.assign(Object.assign({},o),{clauses:i})),{selections:r}})},clearClause(e,n){t(t=>{const r=t.selections.get(e);if(!r)return{};const o=new Map(t.selections),i=new Map(r.clauses);return i.delete(n),o.set(e,Object.assign(Object.assign({},r),{clauses:i})),{selections:o}})},setResolution(e,n){t(t=>{const r=new Map(t.selections),o=Sr(r,e);return r.set(e,Object.assign(Object.assign({},o),{resolution:n})),{selections:r}})},clearSelection(e){t(t=>{const n=new Map(t.selections),r=n.get(e);return r&&n.set(e,Object.assign(Object.assign({},r),{clauses:new Map})),{selections:n}})}})),[Cr,Dr]=he(t=>({observations:[],maxObservations:100,version:0,pushObservation(e){t(t=>{const n=t.observations;return n.push(e),n.length>t.maxObservations&&n.shift(),{version:t.version+1}})},clearObservations(){t(()=>({observations:[],version:0}))}}));function Lr(e){const n=t.useId(),r=e.clientId||n,{name:o}=e,i=Pr(t=>t.selections.get(o)),l=Pr(t=>t.setClause),a=Pr(t=>t.clearClause),s=t.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:t.useMemo(()=>i&&0!==i.clauses.size?function(t,e){const n=[];for(const[r,o]of t.clauses)"crossfilter"===t.resolution&&r===e||n.push(Mr(o));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(i,r):()=>!0,[i,r]),isActive:s,selectPoints:t.useCallback(t=>{const e={};for(const[n,r]of Object.entries(t))e[n]={type:"point",values:new Set(r)};l(o,{clientId:r,type:"point",fields:e})},[r,o,l]),selectInterval:t.useCallback(t=>{const e={};for(const[n,r]of Object.entries(t))e[n]={type:"interval",range:r};l(o,{clientId:r,type:"interval",fields:e})},[r,o,l]),clear:t.useCallback(()=>{a(o,r)},[a,o,r]),clientId:r}}function Tr({selection:e,linkedHover:n,fallbackFields:r=[],unwrapData:o=!1,onObservation:i,chartType:l,chartId:a,onClick:s}){const c=t.useId(),u=function(t,e){return t?!0===t?{name:"hover",fields:e||[]}:"string"==typeof t?{name:t,fields:e||[]}:{name:t.name||"hover",fields:t.fields||e||[],mode:t.mode,xField:t.xField}:null}(n,r),h=Lr({name:(null==e?void 0:e.name)||"__unused__"}),d=function(e){const n=e.name||"hover",{fields:r}=e,{predicate:o,isActive:i,selectPoints:l,clear:a}=Lr({name:n});return{onHover:t.useCallback(t=>{if(!t)return void a();const e={};for(const n of r){const r=t[n];void 0!==r&&(e[n]=[r])}Object.keys(e).length>0&&l(e)},[r,l,a,n]),predicate:o,isActive:i}}({name:(null==u?void 0:u.name)||"hover",fields:(null==u?void 0:u.fields)||r||[]}),f=Dr(t=>t.pushObservation),y=e?{isActive:h.isActive,predicate:h.predicate}:null,g=t.useCallback(t=>{var e,r;if(n)if(t){let e=t.data||t.datum||t;if(Array.isArray(e)&&(e=e[0]),"x-position"===(null==u?void 0:u.mode)&&u.xField){const t=null==e?void 0:e[u.xField];null!=t&&Number.isFinite(Number(t))&&function(t,e,n){const r=St.positions.get(t);r&&r.xValue===e&&r.sourceId===n||(St={positions:new Map(St.positions).set(t,{xValue:e,sourceId:n})},Pt())}(u.name||"hover",Number(t),c)}"x-position"!==(null==u?void 0:u.mode)&&d.onHover(e)}else"x-position"===(null==u?void 0:u.mode)&&Ct(u.name||"hover",c),"x-position"!==(null==u?void 0:u.mode)&&d.onHover(null);if(i||f){const n={timestamp:Date.now(),chartType:l||"unknown",chartId:a};if(t){let o=t.data||t.datum||t;Array.isArray(o)&&(o=o[0]);const l=Object.assign(Object.assign({},n),{type:"hover",datum:o||{},x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(r=t.y)&&void 0!==r?r:0});i&&i(l),f&&f(l)}else{const t=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(t),f&&f(t)}}},[n,d,u,c,i,l,a,f]),p=t.useCallback(t=>{var e,n,r,o;if(t&&s){let r=t.data||t.datum||t;Array.isArray(r)&&(r=r[0]),s(r,{x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0})}if(i||f){const e={timestamp:Date.now(),chartType:l||"unknown",chartId:a};if(t){let n=t.data||t.datum||t;Array.isArray(n)&&(n=n[0]);const l=Object.assign(Object.assign({},e),{type:"click",datum:n||{},x:null!==(r=t.x)&&void 0!==r?r:0,y:null!==(o=t.y)&&void 0!==o?o:0});i&&i(l),f&&f(l)}else{const t=Object.assign(Object.assign({},e),{type:"click-end"});i&&i(t),f&&f(t)}}},[s,i,f,l,a]);return t.useEffect(()=>{if("x-position"!==(null==u?void 0:u.mode))return;const t=u.name||"hover";return()=>{Ct(t,c)}},[null==u?void 0:u.mode,null==u?void 0:u.name,c]),{activeSelectionHook:y,customHoverBehavior:g,customClickBehavior:p,crosshairSourceId:c}}const Nr={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 $r(t,e,n){var r,o,i,l,a,s;const c=Nr[t||"primary"],u="context"===t||"sparkline"===t;return{width:null!==(r=e.width)&&void 0!==r?r:c.width,height:null!==(o=e.height)&&void 0!==o?o:c.height,showAxes:c.showAxes,showGrid:null!==(i=e.showGrid)&&void 0!==i?i:c.showGrid,enableHover:null!==(l=e.enableHover)&&void 0!==l?l:!!e.linkedHover||c.enableHover,showLegend:null!==(a=e.showLegend)&&void 0!==a?a:c.showLegend,showLabels:null!==(s=e.showLabels)&&void 0!==s?s:c.showLabels,title:u?void 0:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:u?void 0:e.xLabel,yLabel:u?void 0:e.yLabel,categoryLabel:u?void 0:e.categoryLabel,valueLabel:u?void 0:e.valueLabel,marginDefaults:Or(c.marginDefaults,e.showCategoryTicks,e.orientation)}}function Or(t,e,n){if(!1!==e)return t;const r=Object.assign({},t);return"horizontal"===n?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}"undefined"!=typeof process&&process;const Wr={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Ir={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function zr(t,e,n,r){return!1===r||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?g.createElement("div",{style:Object.assign(Object.assign({},Wr),{width:e,height:n})},r||"No data available"):null}function Rr(t,e,n){if(!t)return null;const r=Math.min(5,Math.floor(n/40)),o=Math.max(8,Math.floor(n/(3*r))),i=Math.max(6,Math.floor(n/(2.5*r))),l=Math.floor((n-(r*(o+i)-i))/2);return g.createElement("div",{style:{width:e,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:r},(t,n)=>g.createElement("div",{key:n,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Ir),{position:"absolute",top:l+n*(o+i),left:Math.floor(.1*e),width:30+(37*n+13)%50+"%",height:o,opacity:.5+n%2*.2})})))}const Br=t.forwardRef(function(e,n){var r,o,i,l;const a=$r(e.mode,{width:null!==(o=null===(r=e.size)||void 0===r?void 0:r[0])&&void 0!==o?o:e.width,height:null!==(l=null===(i=e.size)||void 0===i?void 0:i[1])&&void 0!==l?l:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:d="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:m,timeExtent:v,valueExtent:x,extentPadding:b,stroke:k="#007bff",strokeWidth:w=2,strokeDasharray:E,background:A,tooltipContent:M,tooltip:S,onHover:_,annotations:P,svgAnnotationRules:C,tickFormatTime:D,tickFormatValue:L,decay:T,pulse:N,staleness:$,transition:O,linkedHover:W,selection:I,onObservation:z,chartId:R,loading:B,emptyContent:j,emphasis:F,legendPosition:Y}=e,H=a.showAxes,X=a.enableHover,G=null!=c?c:a.marginDefaults,V=null!=s?s:[a.width,a.height],q=null!=M?M:S,K=t.useRef(null),{customHoverBehavior:U}=Tr({selection:I,linkedHover:W,unwrapData:!0,onObservation:z,chartType:"RealtimeLineChart",chartId:R}),Z=t.useCallback(t=>{_&&_(t),U(t)},[_,U]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=K.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Q=Rr(B,V[0],V[1]),J=Q?null:zr(y,V[0],V[1],j),tt={stroke:k,strokeWidth:w,strokeDasharray:E};return Q||J||g.createElement(Ye,{ref:K,chartType:"line",runtimeMode:"streaming",size:V,margin:G,className:F?`${u||""} semiotic-emphasis-${F}`.trim():u,arrowOfTime:h,windowMode:d,windowSize:f,data:y,timeAccessor:p,valueAccessor:m,xExtent:v,yExtent:x,extentPadding:b,lineStyle:tt,showAxes:H,background:A,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:Z,annotations:P,svgAnnotationRules:C,tickFormatTime:D,tickFormatValue:L,decay:T,pulse:N,staleness:$,transition:O,legendPosition:Y})});Br.displayName="RealtimeLineChart";const jr=t.forwardRef(function(e,n){var r,o,i,l;const a=$r(e.mode,{width:null!==(o=null===(r=e.size)||void 0===r?void 0:r[0])&&void 0!==o?o:e.width,height:null!==(l=null===(i=e.size)||void 0===i?void 0:i[1])&&void 0!==l?l:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{binSize:s,size:c,margin:u,className:h,arrowOfTime:d="right",windowMode:f="sliding",windowSize:y=200,data:p,timeAccessor:m,valueAccessor:v,timeExtent:x,valueExtent:b,extentPadding:k,categoryAccessor:w,colors:E,fill:A,stroke:M,strokeWidth:S,gap:_,background:P,tooltipContent:C,tooltip:D,onHover:L,annotations:T,svgAnnotationRules:N,tickFormatTime:$,tickFormatValue:O,linkedHover:W,selection:I,decay:z,pulse:R,staleness:B,transition:j,onObservation:F,chartId:Y,loading:H,emptyContent:X,emphasis:G,legendPosition:V,brush:q,onBrush:K,linkedBrush:U}=e,Z=a.showAxes,Q=a.enableHover,J=null!=u?u:a.marginDefaults,tt=null!=c?c:[a.width,a.height],et=null!=C?C:D,nt=t.useRef(null),{customHoverBehavior:rt}=Tr({selection:I,linkedHover:W,unwrapData:!0,onObservation:F,chartType:"RealtimeTemporalHistogram",chartId:Y}),ot=t.useCallback(t=>{L&&L(t),rt(t)},[L,rt]),it=!0===q?{dimension:"x",snap:"bin"}:"x"===q?{dimension:"x"}:"object"==typeof q?q:void 0,lt=(at=U)?"string"==typeof at?{name:at}:at:null;var at;const st=function(e){const{name:n,xField:r,yField:o}=e,{predicate:i,isActive:l,selectInterval:a,clear:s}=Lr({name:n}),c=r&&o?"xyBrush":r?"xBrush":"yBrush",u=t.useCallback(t=>{if(!t)return void s();const e={};"xyBrush"===c&&Array.isArray(t)&&2===t.length?(r&&(e[r]=[Math.min(t[0][0],t[1][0]),Math.max(t[0][0],t[1][0])]),o&&(e[o]=[Math.min(t[0][1],t[1][1]),Math.max(t[0][1],t[1][1])])):"xBrush"===c&&Array.isArray(t)?r&&(e[r]=[Math.min(...t),Math.max(...t)]):"yBrush"===c&&Array.isArray(t)&&o&&(e[o]=[Math.min(...t),Math.max(...t)]),Object.keys(e).length>0&&a(e)},[c,r,o,a,s]);return{brushInteraction:t.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:i,isActive:l,clear:s}}(Object.assign({name:(null==lt?void 0:lt.name)||"__unused_hist_brush__",xField:(null==lt?void 0:lt.xField)||("string"==typeof m?m:"time")},(null==lt?void 0:lt.yField)?{yField:lt.yField}:{})),ct=t.useRef(st.brushInteraction);ct.current=st.brushInteraction;const ut=t.useCallback(t=>{if(K&&K(t),F&&F(t?{type:"brush",extent:t,timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:Y}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:Y}),lt){const e=ct.current;e.end(t?"xBrush"===e.brush?t.x:"yBrush"===e.brush?t.y:[[t.x[0],t.y[0]],[t.x[1],t.y[1]]]:null)}},[K,F,Y,lt]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=nt.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=nt.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=nt.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=nt.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const ht=Rr(H,tt[0],tt[1]),dt=ht?null:zr(p,tt[0],tt[1],X),ft={};return null!=A&&(ft.fill=A),null!=M&&(ft.stroke=M),null!=S&&(ft.strokeWidth=S),null!=_&&(ft.gap=_),ht||dt||g.createElement(Ye,{ref:nt,chartType:"bar",runtimeMode:"streaming",size:tt,margin:J,className:G?`${h||""} semiotic-emphasis-${G}`.trim():h,arrowOfTime:d,windowMode:f,windowSize:y,data:p,timeAccessor:m,valueAccessor:v,xExtent:x,yExtent:b,extentPadding:k,binSize:s,categoryAccessor:w,barColors:E,barStyle:ft,showAxes:Z,background:P,hoverAnnotation:Q,tooltipContent:et,customHoverBehavior:ot,annotations:T,svgAnnotationRules:N,tickFormatTime:$,tickFormatValue:O,decay:z,pulse:R,staleness:B,transition:j,legendPosition:V,brush:it||(U?{dimension:"x"}:void 0),onBrush:it||U?ut:void 0})});jr.displayName="RealtimeTemporalHistogram";const Fr=jr,Yr=t.forwardRef(function(e,n){var r,o,i,l;const a=$r(e.mode,{width:null!==(o=null===(r=e.size)||void 0===r?void 0:r[0])&&void 0!==o?o:e.width,height:null!==(l=null===(i=e.size)||void 0===i?void 0:i[1])&&void 0!==l?l:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:d="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:m,timeExtent:v,valueExtent:x,extentPadding:b,categoryAccessor:k,colors:w,radius:E,fill:A,opacity:M,stroke:S,strokeWidth:_,background:P,tooltipContent:C,tooltip:D,onHover:L,annotations:T,svgAnnotationRules:N,tickFormatTime:$,tickFormatValue:O,linkedHover:W,selection:I,onObservation:z,chartId:R,loading:B,emptyContent:j,emphasis:F,legendPosition:Y}=e,H=a.showAxes,X=a.enableHover,G=null!=c?c:a.marginDefaults,V=null!=s?s:[a.width,a.height],q=null!=C?C:D,K=t.useRef(null),{customHoverBehavior:U}=Tr({selection:I,linkedHover:W,unwrapData:!0,onObservation:z,chartType:"RealtimeSwarmChart",chartId:R}),Z=t.useCallback(t=>{L&&L(t),U(t)},[L,U]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=K.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Q=Rr(B,V[0],V[1]),J=Q?null:zr(y,V[0],V[1],j),tt={};return null!=E&&(tt.radius=E),null!=A&&(tt.fill=A),null!=M&&(tt.opacity=M),null!=S&&(tt.stroke=S),null!=_&&(tt.strokeWidth=_),Q||J||g.createElement(Ye,{ref:K,chartType:"swarm",runtimeMode:"streaming",size:V,margin:G,className:F?`${u||""} semiotic-emphasis-${F}`.trim():u,arrowOfTime:h,windowMode:d,windowSize:f,data:y,timeAccessor:p,valueAccessor:m,xExtent:v,yExtent:x,extentPadding:b,categoryAccessor:k,barColors:w,swarmStyle:tt,showAxes:H,background:P,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:Z,annotations:T,svgAnnotationRules:N,tickFormatTime:$,tickFormatValue:O,legendPosition:Y})});Yr.displayName="RealtimeSwarmChart";const Hr=t.forwardRef(function(e,n){var r,o,i,l;const a=$r(e.mode,{width:null!==(o=null===(r=e.size)||void 0===r?void 0:r[0])&&void 0!==o?o:e.width,height:null!==(l=null===(i=e.size)||void 0===i?void 0:i[1])&&void 0!==l?l:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:d="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:m,timeExtent:v,valueExtent:x,extentPadding:b,positiveColor:k,negativeColor:w,connectorStroke:E,connectorWidth:A,gap:M,stroke:S,strokeWidth:_,background:P,tooltipContent:C,tooltip:D,onHover:L,annotations:T,svgAnnotationRules:N,tickFormatTime:$,tickFormatValue:O,linkedHover:W,selection:I,onObservation:z,chartId:R,loading:B,emptyContent:j,emphasis:F,legendPosition:Y}=e,H=a.showAxes,X=a.enableHover,G=null!=c?c:a.marginDefaults,V=null!=s?s:[a.width,a.height],q=null!=C?C:D,K=t.useRef(null),{customHoverBehavior:U}=Tr({selection:I,linkedHover:W,unwrapData:!0,onObservation:z,chartType:"RealtimeWaterfallChart",chartId:R}),Z=t.useCallback(t=>{L&&L(t),U(t)},[L,U]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=K.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Q=Rr(B,V[0],V[1]),J=Q?null:zr(y,V[0],V[1],j),tt={};return null!=k&&(tt.positiveColor=k),null!=w&&(tt.negativeColor=w),null!=E&&(tt.connectorStroke=E),null!=A&&(tt.connectorWidth=A),null!=M&&(tt.gap=M),null!=S&&(tt.stroke=S),null!=_&&(tt.strokeWidth=_),Q||J||g.createElement(Ye,{ref:K,chartType:"waterfall",runtimeMode:"streaming",size:V,margin:G,className:F?`${u||""} semiotic-emphasis-${F}`.trim():u,arrowOfTime:h,windowMode:d,windowSize:f,data:y,timeAccessor:p,valueAccessor:m,xExtent:v,yExtent:x,extentPadding:b,waterfallStyle:tt,showAxes:H,background:P,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:Z,annotations:T,svgAnnotationRules:N,tickFormatTime:$,tickFormatValue:O,legendPosition:Y})});Hr.displayName="RealtimeWaterfallChart";const Xr=t.forwardRef(function(e,n){var r,o,i,l;const a=$r(e.mode,{width:null!==(o=null===(r=e.size)||void 0===r?void 0:r[0])&&void 0!==o?o:e.width,height:null!==(l=null===(i=e.size)||void 0===i?void 0:i[1])&&void 0!==l?l:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:d="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:m,categoryAccessor:v,timeExtent:x,valueExtent:b,extentPadding:k,heatmapXBins:w=20,heatmapYBins:E=20,aggregation:A="count",background:M,tooltipContent:S,tooltip:_,onHover:P,annotations:C,svgAnnotationRules:D,tickFormatTime:L,tickFormatValue:T,decay:N,pulse:$,staleness:O,linkedHover:W,selection:I,onObservation:z,chartId:R,loading:B,emptyContent:j,emphasis:F,legendPosition:Y}=e,H=a.showAxes,X=a.enableHover,G=null!=c?c:a.marginDefaults,V=null!=s?s:[a.width,a.height],q=null!=S?S:_,K=t.useRef(null),{customHoverBehavior:U}=Tr({selection:I,linkedHover:W,unwrapData:!0,onObservation:z,chartType:"RealtimeHeatmap",chartId:R}),Z=t.useCallback(t=>{P&&P(t),U(t)},[P,U]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=K.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Q=Rr(B,V[0],V[1]),J=Q?null:zr(y,V[0],V[1],j);return Q||J||g.createElement(Ye,{ref:K,chartType:"heatmap",runtimeMode:"streaming",size:V,margin:G,className:F?`${u||""} semiotic-emphasis-${F}`.trim():u,arrowOfTime:h,windowMode:d,windowSize:f,data:y,timeAccessor:p,valueAccessor:m,categoryAccessor:v,xExtent:x,yExtent:b,extentPadding:k,heatmapXBins:w,heatmapYBins:E,heatmapAggregation:A,showAxes:H,background:M,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:Z,annotations:C,svgAnnotationRules:D,tickFormatTime:L,tickFormatValue:T,decay:N,pulse:$,staleness:O,legendPosition:Y})});Xr.displayName="RealtimeHeatmap",exports.IncrementalExtent=w,exports.RealtimeHeatmap=Xr,exports.RealtimeHistogram=Fr,exports.RealtimeLineChart=Br,exports.RealtimeSwarmChart=Yr,exports.RealtimeWaterfallChart=Hr,exports.RingBuffer=k,exports.StreamNetworkFrame=Ar,exports.StreamXYFrame=Ye;
1
+ "use strict";const e=require("react"),t=require("d3-selection"),n=require("d3-brush"),r=require("d3-scale"),o=require("d3-quadtree"),i=require("d3-scale-chromatic"),l=require("d3-array"),a=require("d3-hierarchy"),s=require("d3-shape"),c=require("regression"),u=require("d3-interpolate"),d=require("d3-force"),h=require("d3-chord");function f(e){return e&&e.__esModule?e:{default:e}}function y(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}return t.default=e,Object.freeze(t)}const g=y(e),p=f(c);function m(e,t){let n=0,r=t.length-1;for(;r>n;){const o=n+r+1>>1;t[o]>e?r=o-1:n=o}return t[n]}function v(e,t){let n=0,r=t.length-1;for(;r>n;){const o=n+r>>1;e>t[o]?n=o+1:r=o}return t[n]}function x({width:r,height:o,totalWidth:i,totalHeight:l,margin:a,dimension:s,scales:c,onBrush:u,binSize:d,snap:h,binBoundaries:f,snapDuring:y,streaming:p}){const x=e.useRef(null),b=e.useRef(null),k=e.useRef(u);k.current=u;const w=e.useRef(c);w.current=c;const E=e.useMemo(()=>f?[...f].sort((e,t)=>e-t):void 0,[f]),A=e.useRef(E);A.current=E;const M=e.useRef(!1),S=e.useRef(null);return e.useEffect(()=>{if(!x.current)return;const e=t.select(x.current).select(".brush-g"),i="x"===s?n.brushX():"y"===s?n.brushY():n.brush();return i.extent([[0,0],[r,o]]),i.on("brush end",t=>{if(M.current)return;const n=w.current;if(!n)return;if(!t.selection)return S.current=null,void k.current(null);let l,a;if("x"===s){const[e,r]=t.selection;l=[n.x.invert(e),n.x.invert(r)],a=[n.y.invert(o),n.y.invert(0)]}else if("y"===s){const[e,o]=t.selection;l=[n.x.invert(0),n.x.invert(r)],a=[n.y.invert(o),n.y.invert(e)]}else{const[[e,r],[o,i]]=t.selection;l=[n.x.invert(e),n.x.invert(o)],a=[n.y.invert(i),n.y.invert(r)]}if("bin"===h&&"y"!==s&&("end"===t.type||"brush"===t.type&&y)){const r=A.current;r&&r.length>0?l=function(e,t){return 0===t.length?e:[m(e[0],t),v(e[1],t)]}(l,r):d&&d>0&&(l=[Math.floor(l[0]/d)*d,Math.ceil(l[1]/d)*d]);const o=n.x(l[0]),a=n.x(l[1]);if(M.current=!0,"x"===s)e.call(i.move,[o,a]);else if("xy"===s){const n=t.selection;e.call(i.move,[[o,n[0][1]],[a,n[1][1]]])}M.current=!1}const c={x:l,y:a};S.current=c,k.current(c)}),e.call(i),b.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),b.current=null}},[r,o,s,h,d,y]),e.useEffect(()=>{if(!(p&&c&&b.current&&S.current))return;if(!x.current)return;if("y"===s)return;const e=S.current,n=c.x.domain()[0],r=t.select(x.current).select(".brush-g");if(n>=e.x[1])return M.current=!0,r.call(b.current.move,null),M.current=!1,S.current=null,void k.current(null);let o=e.x[0],i=!1;if(n>e.x[0]){if(o=n,"bin"===h){const e=A.current;e&&e.length>0?o=v(n,e):d&&d>0&&(o=Math.ceil(n/d)*d)}if(o>=e.x[1])return M.current=!0,r.call(b.current.move,null),M.current=!1,S.current=null,void k.current(null);i=!0}const l=c.x(o),a=c.x(e.x[1]);if(M.current=!0,"x"===s)r.call(b.current.move,[l,a]);else{const t=c.y(e.y[1]),n=c.y(e.y[0]);r.call(b.current.move,[[l,t],[a,n]])}if(M.current=!1,i){const t={x:[o,e.x[1]],y:e.y};S.current=t,k.current(t)}},[c,p,s,h,d]),g.createElement("svg",{ref:x,width:i,height:l,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},g.createElement("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`}))}class b{constructor(e,t){var n,r;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=null!==(n=null==t?void 0:t.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(r=null==t?void 0:t.chunkSize)&&void 0!==r?r:5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const r=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,r),bounded:!1}),t=r,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){this.pushBuffer.push(e),this.scheduleFlush()}pushMany(e){if(0!==e.length){for(let t=0;e.length>t;t++)this.pushBuffer.push(e[t]);this.scheduleFlush()}}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}class k{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class w{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 E(e,t,n,r,o){const i=new Map;for(const l of e){const e=t(l),a=n(l);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const s=Math.floor(e/r)*r;let c=i.get(s);if(c||(c={start:s,end:s+r,total:0,categories:new Map},i.set(s,c)),c.total+=a,o){const e=o(l);c.categories.set(e,(c.categories.get(e)||0)+a)}}return i}function A(e,t){return e===t||typeof e==typeof t&&"function"==typeof e&&"function"==typeof t&&""+e==""+t}function M(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function S(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function P(e,t){return"function"==typeof e?e:e?t=>t[e]+"":void 0}const _=i.schemeCategory10,C=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function D(e,t,n){var r,o,i;if(1>=n)return 1;const l=null!==(r=e.minOpacity)&&void 0!==r?r:.1,a=n-1-t;switch(e.type){case"linear":return l+(1-a/(n-1))*(1-l);case"exponential":{const t=null!==(o=e.halfLife)&&void 0!==o?o:n/2;return l+Math.pow(.5,a/t)*(1-l)}case"step":return(null!==(i=e.stepThreshold)&&void 0!==i?i:.5*n)>a?1:l;default:return 1}}function L(e,t,n){var r;const o=null!==(r=e.duration)&&void 0!==r?r:500,i=n-t;return o>i?1-i/o:0}function T(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function N(e,t){return Math.min((e-t.startTime)/t.duration,1)}function O(e,t,n){return e+(t-e)*n}function $(e,t,n){var r,o,i,l;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===e.runtimeMode&&t.datum){const n=e.getX(t.datum),r=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${n}:${r}`;if(null!=n&&null!=r)return`p:${n}:${r}`}return"p:"+n;case"rect":return`r:${t.group||""}:${null!==(l=null!==(o=null===(r=t.datum)||void 0===r?void 0:r.binStart)&&void 0!==o?o:null===(i=t.datum)||void 0===i?void 0:i.category)&&void 0!==l?l:n}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+n:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function W(e,t,n,r,o,i){const l=[];for(const o of e){const e=n(o),i=r(o);null==e||null==i||Number.isNaN(e)||Number.isNaN(i)||l.push({px:t.x(e),py:t.y(i),rawY:i,d:o})}l.sort((e,t)=>e.px-t.px);const a=Array(l.length),s=Array(l.length),c=Array(l.length);for(let e=0;l.length>e;e++){const t=l[e];a[e]=[t.px,t.py],s[e]=t.rawY,c[e]=t.d}return{type:"line",path:a,rawValues:s,style:o,datum:c,group:i}}function I(e,t,n,r,o,i,l,a){const s=[];for(const i of e){const e=n(i),l=r(i);if(null==e||null==l||Number.isNaN(e)||Number.isNaN(l))continue;const c=t.x(e),u=a?a(i):o;s.push({px:c,topY:t.y(l),botY:t.y(u)})}s.sort((e,t)=>e.px-t.px);const c=Array(s.length),u=Array(s.length);for(let e=0;s.length>e;e++){const t=s[e];c[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:c,bottomPath:u,style:i,datum:e,group:l}}function z(e,t,n,r,o,i,l){const a=n(e),s=r(e);if(null==a||null==s||Number.isNaN(a)||Number.isNaN(s))return null;const c={type:"point",x:t.x(a),y:t.y(s),r:o,style:i,datum:e};return void 0!==l&&(c.pointId=l),c}function R(e,t,n,r,o,i,l){return{type:"rect",x:e,y:t,w:n,h:r,style:o,datum:i,group:l}}function B(e,t,n,r,o,i,l){const a={type:"heatcell",x:e,y:t,w:n,h:r,fill:o,datum:i};return(null==l?void 0:l.showValues)&&(a.showValues=!0,a.value=l.value,l.valueFormat&&(a.valueFormat=l.valueFormat)),a}function j(e,t,n){if(!e.getBounds||!e.scales)return null;const r=[],o=[];for(const n of t){const t=e.getX(n),i=e.getY(n);if(null==t||null==i||Number.isNaN(t)||Number.isNaN(i))continue;const l=e.getBounds(n),a=e.scales.x(t);if(l&&0!==l)r.push([a,e.scales.y(i+l)]),o.push([a,e.scales.y(i-l)]);else{const t=e.scales.y(i);r.push([a,t]),o.push([a,t])}}return 2>r.length?null:{type:"area",topPath:r,bottomPath:o,style:e.resolveBoundsStyle(n,t[0]),datum:t,group:n,interactive:!1}}function F(e,t,n,r){var o;if(!e.config.pointStyle)return;const i=null!=r?r:e.getY;for(const r of t){const t=e.resolveGroupColor(r.key);for(const l of r.data){let r=e.config.pointStyle(l);!r.fill&&t&&(r=Object.assign(Object.assign({},r),{fill:t}));const a=null!==(o=r.r)&&void 0!==o?o:3,s=e.getPointId?e.getPointId(l)+"":void 0,c=z(l,e.scales,e.getX,i,a,r,s);c&&n.push(c)}}}const Y={blues:i.interpolateBlues,reds:i.interpolateReds,greens:i.interpolateGreens,viridis:i.interpolateViridis},H=new Map;class X{constructor(e){if(this.xExtent=new w,this.yExtent=new w,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.xIsDate=!1,this._quadtree=null,this.config=e,this.buffer=new k(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=M(e.timeAccessor||e.xAccessor,"time"),this.getY=M(e.valueAccessor||e.yAccessor,"value")):(this.getX=M(e.xAccessor,"x"),this.getY=M(e.yAccessor,"y")),this.getGroup=P(e.groupAccessor),this.getCategory=P(e.categoryAccessor),this.getSize=e.sizeAccessor?M(e.sizeAccessor,"size"):void 0,this.getColor=P(e.colorAccessor),this.getBounds=e.boundsAccessor?M(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?M(e.y0Accessor,"y0"):void 0,this.getPointId=P(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,n=null!=e.closeAccessor;this.getOpen=t?M(e.openAccessor,"open"):void 0,this.getHigh=M(e.highAccessor,"high"),this.getLow=M(e.lowAccessor,"low"),this.getClose=n?M(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!n}e.pulse&&(this.timestampBuffer=new k(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){if(this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.getX=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?M(this.config.timeAccessor||this.config.xAccessor,"time"):M(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],n=this.config.xAccessor,r="function"==typeof n?n(t):t[n||"x"],o=r instanceof Date,i="string"==typeof r&&r.length>=10&&!isNaN(new Date(r).getTime())&&isNaN(Number(r));if(this.xIsDate=o||i,i){const e="string"==typeof n?n:void 0;this.getX=e?t=>+new Date(t[e]):e=>+(n(e)instanceof Date?n(e):new Date(n(e)))}}const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n)))}else for(const n of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity||1e6;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n))),null!=e&&(this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):this.yExtent.evict(this.getY(e)))}return!0}computeScene(e){var t,n,o,i,l,a,s;const{config:c,buffer:u}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(t=this.config.scalePadding)&&void 0!==t?t:0)&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);if(this.xExtent.dirty&&this.xExtent.recalculate(u,this.getX),this.yExtent.dirty)if("candlestick"===c.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of u)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(u,this.getY);const d=this.getBufferArray(),h=this.xExtent.extent,f=this.yExtent.extent;let y=c.xExtent?[null!==(n=c.xExtent[0])&&void 0!==n?n:h[0],null!==(o=c.xExtent[1])&&void 0!==o?o:h[1]]:h,g=c.yExtent?[null!==(i=c.yExtent[0])&&void 0!==i?i:f[0],null!==(l=c.yExtent[1])&&void 0!==l?l:f[1]]:f;const p=c.yExtent&&null!=c.yExtent[0]&&null!=c.yExtent[1];if("stackedarea"===c.chartType&&!p&&u.size>0)if(c.normalize)g=[0,1+c.extentPadding];else{const e=`${u.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===e)g=this._stackExtentCache.yDomain;else{const t=this.groupData(d),n=new Map;for(const e of t)for(const t of e.data){const e=this.getX(t),r=this.getY(t);null==e||null==r||Number.isNaN(e)||Number.isNaN(r)||n.set(e,(n.get(e)||0)+r)}let r=0;for(const e of n.values())e>r&&(r=e);g=[0,r+(r>0?r*c.extentPadding:1)],this._stackExtentCache={key:e,yDomain:g}}}else if("bar"===c.chartType&&c.binSize&&!p&&u.size>0){const[,e]=function(e,t,n,r,o){const i=E(e,t,n,r,o);if(0===i.size)return[0,0];let l=0;for(const e of i.values())e.total>l&&(l=e.total);return[0,l]}(u,this.getX,this.getY,c.binSize,this.getCategory);g=[0,e+e*c.extentPadding]}else if("waterfall"===c.chartType&&!p&&u.size>0){const[e,t]=function(e,t){let n=0,r=0,o=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(o+=e,n>o&&(n=o),o>r&&(r=o))}return[n,r]}(u,this.getY),n=t-e,r=n>0?n*c.extentPadding:1;g=[Math.min(0,e-Math.abs(r)),Math.max(0,t+Math.abs(r))]}else if(!p&&g[0]!==1/0){if(this.getBounds)for(const e of d){const t=this.getY(e),n=this.getBounds(e);null!=t&&!Number.isNaN(t)&&n&&(t+n>g[1]&&(g[1]=t+n),g[0]>t-n&&(g[0]=t-n))}const e=g[1]-g[0],t=e>0?e*c.extentPadding:1,n=null===(a=c.yExtent)||void 0===a?void 0:a[0],r=null===(s=c.yExtent)||void 0===s?void 0:s[1];g=[null!=n?g[0]:g[0]-t,null!=r?g[1]:g[1]+t],"log"===c.yScaleType&&0>=g[0]&&f[0]>0&&(g[0]=null!=n?g[0]:f[0]/(1+c.extentPadding))}if(y[0]===1/0||y[1]===-1/0)if("time"===c.xScaleType){const e=Date.now();y=[e-864e5,e]}else y=[0,1];g[0]!==1/0&&g[1]!==-1/0||(g=[0,1]);const m="streaming"===c.runtimeMode,v=Math.max(0,Math.min(c.scalePadding||0,Math.min(e.width,e.height)/2-1));if(m)if("x"==("up"===(x=c.arrowOfTime)||"down"===x?"y":"x")){const t="right"===c.arrowOfTime?[v,e.width-v]:[e.width-v,v];this.scales={x:r.scaleLinear().domain(y).range(t),y:r.scaleLinear().domain(g).range([e.height-v,v])}}else{const t="down"===c.arrowOfTime?[v,e.height-v]:[e.height-v,v];this.scales={x:r.scaleLinear().domain(g).range([v,e.width-v]),y:r.scaleLinear().domain(y).range(t)}}else{const t=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return r.scaleLog().domain(e).range(n).clamp(!0)}return"time"===e?r.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(n):r.scaleLinear().domain(t).range(n)};this.scales={x:t(c.xScaleType,y,[v,e.width-v]),y:t(c.yScaleType,g,[e.height-v,v])}}var x;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(e,d),this.config.decay&&this.applyDecay(this.scene,d),this.config.pulse&&this.applyPulse(this.scene,d),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}rebuildQuadtree(){const e=this.config.chartType;if("scatter"!==e&&"bubble"!==e)return void(this._quadtree=null);const t=this.scene.filter(e=>"point"===e.type);this._quadtree=t.length>X.QUADTREE_THRESHOLD?o.quadtree().x(e=>e.x).y(e=>e.y).addAll(t):null}get quadtree(){return this._quadtree}remapScene(e){const t=e.width/this.lastLayout.width,n=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const r of e.path)r[0]*=t,r[1]*=n;break;case"area":for(const r of e.topPath)r[0]*=t,r[1]*=n;for(const r of e.bottomPath)r[0]*=t,r[1]*=n;break;case"point":e.x*=t,e.y*=n;break;case"rect":case"heatcell":e.x*=t,e.y*=n,e.w*=t,e.h*=n;break;case"candlestick":e.x*=t,e.openY*=n,e.closeY*=n,e.highY*=n,e.lowY*=n}const o=this.scales.x.domain(),i=this.scales.y.domain(),l=this.scales.x.range(),a=this.scales.y.range(),s=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return r.scaleLog().domain(e).range(n).clamp(!0)}return"time"===e?r.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(n):r.scaleLinear().domain(t).range(n)},c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),u=a[1]>a[0];this.scales={x:s(this.config.xScaleType,o,l[0]>l[1]?[e.width-c,c]:[c,e.width-c]),y:s(this.config.yScaleType,i,u?[c,e.height-c]:[e.height-c,c])},this.lastLayout={width:e.width,height:e.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(e,t){var n;const{config:r,scales:o}=this;if(!o||0===t.length)return[];const l={scales:o,config:r,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,getBounds:this.getBounds,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(e,t)=>this.resolveLineStyle(e,t),resolveAreaStyle:(e,t)=>this.resolveAreaStyle(e,t),resolveBoundsStyle:(e,t)=>this.resolveBoundsStyle(e,t),resolveColorMap:e=>this.resolveColorMap(e),resolveGroupColor:e=>this.resolveGroupColor(e),groupData:e=>this.groupData(e),barCategoryCache:this._barCategoryCache};switch(r.chartType){case"line":return function(e,t){var n;const r=e.groupData(t),o=[],i=null===(n=e.config.annotations)||void 0===n?void 0:n.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.getBounds)for(const t of r){const n=j(e,t.data,t.key);n&&o.push(n)}for(const t of r){const n=e.resolveLineStyle(t.key,t.data[0]),r=W(t.data,e.scales,e.getX,e.getY,n,t.key);i&&i.length>0&&(r.colorThresholds=i),e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),o.push(r)}return F(e,r,o),o}(l,t);case"area":return function(e,t){const n=e.groupData(t),r=[],o=e.scales.y.domain()[0],i=e.getY0?t=>{const n=e.getY0(t);return null==n?o:n}:void 0;for(const t of n){const n=e.resolveAreaStyle(t.key,t.data[0]),l=I(t.data,e.scales,e.getX,e.getY,o,n,t.key,i);e.config.gradientFill&&(l.fillGradient=e.config.gradientFill),e.config.curve&&"linear"!==e.config.curve&&(l.curve=e.config.curve),e.config.lineGradient&&(l.strokeGradient=e.config.lineGradient),r.push(l)}return F(e,n,r),r}(l,t);case"mixed":return function(e,t){const n=e.groupData(t),r=[],o=e.config.areaGroups||new Set,i=e.scales.y.domain()[0],l=e.getY0?t=>{const n=e.getY0(t);return null==n?i:n}:void 0;for(const t of n)if(o.has(t.key)){const n=e.resolveAreaStyle(t.key,t.data[0]),o=I(t.data,e.scales,e.getX,e.getY,i,n,t.key,l);e.config.gradientFill&&(o.fillGradient=e.config.gradientFill),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}else{const n=e.resolveLineStyle(t.key,t.data[0]),o=W(t.data,e.scales,e.getX,e.getY,n,t.key);e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}return F(e,n,r),r}(l,t);case"stackedarea":return function(e,t){const n=e.groupData(t);n.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);const r=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,{nodes:o,stackedTops:i}=function(e,t,n,r,o,i,l){var a;const s=new Set;for(const t of e)for(const e of t.data){const t=n(e);null==t||Number.isNaN(t)||s.add(t)}const c=Array.from(s).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const o of t.data){const t=n(o),i=r(o);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||e.set(t,(e.get(t)||0)+i)}u.set(t.key,e)}let d;if(i){d=new Map;for(const t of c){let n=0;for(const r of e)n+=(null===(a=u.get(r.key))||void 0===a?void 0:a.get(t))||0;d.set(t,n||1)}}const h=[],f=new Map,y=new Map;for(const e of c)y.set(e,0);for(const n of e){const e=u.get(n.key),r=[],a=[],s=new Map;for(const n of c){let o=e.get(n)||0;const l=y.get(n);i&&(o/=d.get(n));const c=l+o,u=t.x(n);a.push([u,t.y(l)]),r.push([u,t.y(c)]),y.set(n,c),s.set(n,c)}f.set(n.key,s);const g={type:"area",topPath:r,bottomPath:a,style:o(n.key,n.data[0]),datum:n.data,group:n.key};l&&(g.curve=l),h.push(g)}return{nodes:h,stackedTops:f}}(n,e.scales,e.getX,e.getY,(t,n)=>e.resolveAreaStyle(t,n),e.config.normalize,r),l=o;if(e.config.pointStyle){const t=new WeakMap;for(const r of n){const n=i.get(r.key);if(n)for(const o of r.data){const r=e.getX(o),i=e.getY(o);null==r||Number.isNaN(r)||null==i||Number.isNaN(i)||!n.has(r)||t.set(o,n.get(r))}}const r=n=>{var r;return null!==(r=t.get(n))&&void 0!==r?r:e.getY(n)};F(e,n,l,r)}return l}(l,t);case"scatter":case"bubble":return function(e,t){const n=[],r="bubble"===e.config.chartType?10:5,o=e.config.sizeRange||[3,15];let i=null;if(e.getSize&&!e.config.pointStyle){const n=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(n.length>0){let e=1/0,t=-1/0;for(const r of n)e>r&&(e=r),r>t&&(t=r);i=n=>e===t?(o[0]+o[1])/2:o[0]+(n-e)/(t-e)*(o[1]-o[0])}}const l=e.getColor?e.resolveColorMap(t):null;for(const o of t){let t=e.config.pointStyle?e.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},a=t.r||r;if(i&&e.getSize){const t=e.getSize(o);null==t||Number.isNaN(t)||(a=i(t))}if(l&&e.getColor&&!t.fill){const n=e.getColor(o);n&&l.has(n)&&(t=Object.assign(Object.assign({},t),{fill:l.get(n)}))}const s=e.getPointId?e.getPointId(o)+"":void 0,c=z(o,e.scales,e.getX,e.getY,a,t,s);c&&n.push(c)}return n}(l,t);case"heatmap":return function(e,t,n){if(e.config.heatmapAggregation)return function(e,t,n){var r,o,i;const l=Math.max(1,Math.floor(null!==(r=e.config.heatmapXBins)&&void 0!==r?r:20)),a=Math.max(1,Math.floor(null!==(o=e.config.heatmapYBins)&&void 0!==o?o:20)),s=null!==(i=e.config.heatmapAggregation)&&void 0!==i?i:"count",c=M(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[u,d]=e.scales.x.domain(),[h,f]=e.scales.y.domain(),y=(d-u||1)/l,g=(f-h||1)/a,p=l*a;if(p>1e6)return[];const m=new Int32Array(p),v=new Float64Array(p);for(let n=0;t.length>n;n++){const r=t[n],o=e.getX(r),i=e.getY(r);if(!isFinite(o)||!isFinite(i))continue;const s=Math.min(Math.floor((o-u)/y),l-1),d=Math.min(Math.floor((i-h)/g),a-1);if(0>s||0>d)continue;const f=d*l+s;m[f]++;const p=c(r);v[f]+=isFinite(p)?p:0}let x=1/0,b=-1/0;for(let e=0;p>e;e++){if(0===m[e])continue;let t;switch(s){case"sum":t=v[e];break;case"mean":t=v[e]/m[e];break;default:t=m[e]}x>t&&(x=t),t>b&&(b=t)}if(!isFinite(x))return[];const k=b-x||1,w=n.width/l,E=n.height/a,A=e.config.showValues,S=e.config.heatmapValueFormat,P=[];for(let e=0;a>e;e++){const t=e*l;for(let n=0;l>n;n++){const r=t+n;if(0===m[r])continue;let o;switch(s){case"sum":o=v[r];break;case"mean":o=v[r]/m[r];break;default:o=m[r]}const i=(o-x)/k;P.push(B(n*w,(a-1-e)*E,w,E,`rgb(${220-(180*i+.5)|0},${220-(100*i+.5)|0},${255-(50*i+.5)|0})`,{xi:n,yi:e,value:o,count:m[r],sum:v[r]},A?{value:o,showValues:!0,valueFormat:S}:void 0))}}return P}(e,t,n);if(0===t.length)return[];const r=M(e.config.valueAccessor,"value"),o=S(e.config.xAccessor,"x"),l=S(e.config.yAccessor,"y"),a=new Map,s=new Map,c=Array(t.length),u=Array(t.length);for(let e=0;t.length>e;e++){const n=t[e],r=o(n),i=l(n);c[e]=r,u[e]=i,a.has(r)||a.set(r,a.size),s.has(i)||s.set(i,s.size)}const d=a.size,h=s.size;if(0===d||0===h)return[];const f=Array.from(a.keys()),y=Array.from(s.keys()),g=f.every(e=>"number"==typeof e&&!isNaN(e)),p=y.every(e=>"number"==typeof e&&!isNaN(e));if(g){f.sort((e,t)=>e-t),a.clear();for(let e=0;f.length>e;e++)a.set(f[e],e)}if(p){y.sort((e,t)=>e-t),s.clear();for(let e=0;y.length>e;e++)s.set(y[e],e)}const m=new Float64Array(t.length),v=new Float64Array(t.length),x=Array(t.length),b=new Map;let k=0;for(let e=0;t.length>e;e++){const n=t[e],o=a.get(c[e]),i=s.get(u[e]);if(void 0===o||void 0===i)continue;const l=r(n),h=i*d+o,f=b.get(h);let y;void 0!==f?y=f:(y=k++,b.set(h,y)),m[y]=h,v[y]=l,x[y]=n}let w=1/0,E=-1/0;for(let e=0;k>e;e++){const t=v[e];isFinite(t)&&(w>t&&(w=t),t>E&&(E=t))}if(!isFinite(w)||!isFinite(E))return[];const A=function(e){const t=e in Y?e:"blues";let n=H.get(t);if(n)return n;n=Array(256);const r=Y[t]||i.interpolateBlues;for(let e=0;256>e;e++)n[e]=r(e/255);return H.set(t,n),n}("string"==typeof e.config.colorScheme?e.config.colorScheme:"blues"),P=255/(E-w||1),_=n.width/d,C=n.height/h,D=e.config.showValues,L=e.config.heatmapValueFormat,T=[];for(let e=0;k>e;e++){const t=v[e];if(!isFinite(t))continue;const n=m[e],r=n%d;T.push(B(r*_,(h-1-(n-r)/d)*C,_,C,A[Math.min((t-w)*P+.5|0,255)],x[e],D?{value:t,showValues:!0,valueFormat:L}:void 0))}return T}(l,t,e);case"bar":{const e=function(e,t){var n;if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const r=E(t,e.getX,e.getY,e.config.binSize,e.getCategory);if(0===r.size)return{nodes:[],binBoundaries:[]};let o=null;if(e.getCategory){const t=new Set;for(const e of r.values())for(const n of e.categories.keys())t.add(n);const n=e.config.barColors?Object.keys(e.config.barColors):[],i=new Set(n),l=Array.from(t).filter(e=>!i.has(e)).sort(),a=n.filter(e=>t.has(e)),s=a.join("\0")+""+l.join("\0");e.barCategoryCache&&e.barCategoryCache.key===s?o=e.barCategoryCache.order:(o=[...a,...l],e.barCategoryCache={key:s,order:o})}const i=[],l=e.scales,[a,s]=l.x.domain();for(const t of r.values()){const r=Math.max(t.start,a),c=Math.min(t.end,s);if(r>=c)continue;const u=l.x(r),d=l.x(c),h=Math.abs(d-u),f=h>2?1:0,y=Math.min(u,d)+f/2,g=Math.max(h-f,1);if(g>0)if(o&&t.categories.size>0){let r=0;for(const a of o){const o=t.categories.get(a)||0;if(0===o)continue;const s=l.y(r),c=l.y(r+o);i.push(R(y,Math.min(s,c),g,Math.abs(s-c),{fill:(null===(n=e.config.barColors)||void 0===n?void 0:n[a])||"#4e79a7"},{binStart:t.start,binEnd:t.end,total:t.total,category:a,categoryValue:o},a)),r+=o}}else{const e=l.y(0),n=l.y(t.total);i.push(R(y,Math.min(e,n),g,Math.abs(e-n),{fill:"#007bff"},{binStart:t.start,binEnd:t.end,total:t.total}))}}const c=new Set;for(const e of r.values())c.add(e.start),c.add(e.end);return{nodes:i,binBoundaries:Array.from(c).sort((e,t)=>e-t)}}(l,t);return this._barCategoryCache=null!==(n=l.barCategoryCache)&&void 0!==n?n:null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){var n,r,o,i;const l=[],a=e.config.swarmStyle||{},s=null!==(n=a.radius)&&void 0!==n?n:3,c=null!==(r=a.fill)&&void 0!==r?r:"#007bff",u=null!==(o=a.opacity)&&void 0!==o?o:.7,d=a.stroke,h=a.strokeWidth;for(const n of t){const t=e.getX(n),r=e.getY(n);if(null==r||Number.isNaN(r))continue;const o=e.scales.x(t),a=e.scales.y(r);let f=c;if(e.getCategory){const t=e.getCategory(n);f=(null===(i=e.config.barColors)||void 0===i?void 0:i[t])||f}const y={type:"point",x:o,y:a,r:s,style:{fill:f,opacity:u,stroke:d,strokeWidth:h},datum:n};e.getPointId&&(y.pointId=e.getPointId(n)+""),l.push(y)}return l}(l,t);case"waterfall":return function(e,t,n){var r,o,i;const l=[],a=e.scales,s=e.config.waterfallStyle,c=t.filter(t=>{const n=e.getY(t),r=e.getX(t);return null!=n&&!Number.isNaN(n)&&null!=r&&isFinite(r)});if(0===c.length)return l;const u=null!==(r=null==s?void 0:s.positiveColor)&&void 0!==r?r:"#28a745",d=null!==(o=null==s?void 0:s.negativeColor)&&void 0!==o?o:"#dc3545",h=null!==(i=null==s?void 0:s.gap)&&void 0!==i?i:1,f=null==s?void 0:s.stroke,y=null==s?void 0:s.strokeWidth;let g=0;for(let t=0;c.length>t;t++){const r=c[t],o=e.getX(r),i=e.getY(r),p=g+i;let m;m=c.length-1>t?e.getX(c[t+1])-o:t>0?o-e.getX(c[t-1]):0;const v=a.x(o),x=0!==m?a.x(o+m):v+n.width/10,b=Math.min(v,x)+h/2,k=Math.max(v,x)-h/2-b;if(0>=k){g=p;continue}const w=a.y(g),E=a.y(p);l.push(R(b,Math.min(w,E),k,Math.abs(w-E),{fill:0>i?d:u,stroke:f,strokeWidth:y},Object.assign(Object.assign({},r),{baseline:g,cumEnd:p,delta:i,_connectorStroke:null==s?void 0:s.connectorStroke,_connectorWidth:null==s?void 0:s.connectorWidth}))),g=p}return l}(l,t,e);case"candlestick":return function(e,t){var n,r;if(!e.getHigh||!e.getLow||!e.scales)return[];const o=null!==(n=e.config.candlestickRangeMode)&&void 0!==n&&n;if(!(o||e.getOpen&&e.getClose))return[];const i=[],l=e.config.candlestickStyle||{},a=l.rangeColor||"#6366f1",s=o?a:l.upColor||"#28a745",c=o?a:l.downColor||"#dc3545",u=o?a:l.wickColor||"#333",d=l.wickWidth||(o?2:1),h=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let f=o?0:null!==(r=l.bodyWidth)&&void 0!==r?r:0;if(!o&&null==l.bodyWidth&&h.length>1){let t=1/0;for(let n=1;h.length>n;n++){const r=Math.abs(e.scales.x(h[n])-e.scales.x(h[n-1]));r>0&&t>r&&(t=r)}f=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else o||null!=l.bodyWidth||(f=6);for(const n of t){const t=e.getX(n);if(null==t||Number.isNaN(t))continue;const r=e.getHigh(n),l=e.getLow(n);if(null==r||Number.isNaN(r)||null==l||Number.isNaN(l))continue;const a=o?r:e.getOpen(n),h=o?l:e.getClose(n);if(!o&&[a,h].some(e=>null==e||Number.isNaN(e)))continue;const y=h>=a,g={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(a),closeY:e.scales.y(h),highY:e.scales.y(r),lowY:e.scales.y(l),bodyWidth:f,upColor:s,downColor:c,wickColor:u,wickWidth:d,isUp:y,datum:n};o&&(g.isRange=!0),i.push(g)}return i}(l,t);default:return[]}}resolveBoundsStyle(e,t){const n=this.config.boundsStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(e,t).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?D(n,e,t):1}applyDecay(e,t){this.config.decay&&function(e,t,n){var r,o;const i=n.length;if(1>=i)return;const l=new Map;for(let e=0;n.length>e;e++)l.set(n[e],e);for(const n of t){if("line"===n.type){const t=Array.isArray(n.datum)?n.datum:[];if(2>t.length)continue;const r=Array(t.length);let o=!1;for(let n=0;t.length>n;n++){const a=l.get(t[n]);null!=a?(r[n]=D(e,a,i),1>r[n]&&(o=!0)):r[n]=1}o&&(n._decayOpacities=r);continue}if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[],r=n.topPath?n.topPath.length:t.length;if(2>r)continue;if(t.length===r){const o=Array(r);let a=!1;for(let n=0;t.length>n;n++){const r=l.get(t[n]);null!=r?(o[n]=D(e,r,i),1>o[n]&&(a=!0)):o[n]=1}a&&(n._decayOpacities=o)}else{let o=1;for(const n of t){const t=l.get(n);if(null!=t){const n=D(e,t,i);o>n&&(o=n)}}if(1>o){const e=Array(r);e.fill(o),n._decayOpacities=e}}continue}const t=l.get(n.datum);if(null==t)continue;const a=D(e,t,i);if("heatcell"===n.type)n.style={opacity:a};else if("candlestick"===n.type)n._decayOpacity=a;else{const e=null!==(o=null===(r=n.style)||void 0===r?void 0:r.opacity)&&void 0!==o?o:1;n.style=Object.assign(Object.assign({},n.style),{opacity:e*a})}}}(this.config.decay,e,t)}applyPulse(e,t){this.config.pulse&&this.timestampBuffer&&function(e,t,n,r){var o,i;const l="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(o=e.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",s=null!==(i=e.glowRadius)&&void 0!==i?i:4,c=new Map;for(let e=0;n.length>e;e++)c.set(n[e],e);for(const n of t){if("line"===n.type)continue;if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[n.datum];let o=0;for(const n of t){const t=c.get(n);if(null==t)continue;const i=r.get(t);if(null==i)continue;const a=L(e,i,l);a>o&&(o=a)}o>0&&(n._pulseIntensity=o,n._pulseColor=a);continue}const t=c.get(n.datum);if(null==t)continue;const o=r.get(t);if(null==o)continue;const i=L(e,o,l);i>0&&(n._pulseIntensity=i,n._pulseColor=a,n._pulseGlowRadius=s)}}(this.config.pulse,e,t,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(e,t){var n;if(!t||0===t.size)return!1;const r="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(n=e.duration)&&void 0!==n?n:500,i=t.peek();return null!=i&&o>r-i}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(e,t,n,r){var o,i,l;n.clear(),r.clear();for(let a=0;t.length>a;a++){const s=t[a],c=$(e,s,a);c&&("point"===s.type?n.set(c,{x:s.x,y:s.y,r:s.r,opacity:s.style.opacity}):"rect"===s.type?n.set(c,{x:s.x,y:s.y,w:s.w,h:s.h,opacity:s.style.opacity}):"heatcell"===s.type?n.set(c,{x:s.x,y:s.y,w:s.w,h:s.h,opacity:null===(o=s.style)||void 0===o?void 0:o.opacity}):"candlestick"===s.type?n.set(c,{x:s.x,y:s.openY}):"line"===s.type?r.set(c,{path:s.path.map(e=>[e[0],e[1]]),opacity:null===(i=s.style)||void 0===i?void 0:i.opacity}):"area"===s.type&&r.set(c,{topPath:s.topPath.map(e=>[e[0],e[1]]),bottomPath:s.bottomPath.map(e=>[e[0],e[1]]),opacity:null===(l=s.style)||void 0===l?void 0:l.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}startTransition(){if(!this.config.transition)return;const e=function(e,t,n,r,o){var i,l,a,s,c,u,d,h,f,y,g,p,m,v,x,b,k,w,E,A,M,S,P,_,C,D,L,T;if(0===r.size&&0===o.size)return n;const N=null!==(i=t.duration)&&void 0!==i?i:300;if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}let O=!1;const W=new Set,I=new Set;for(let t=0;n.scene.length>t;t++){const i=n.scene[t],E=$(e,i,t);if(!E)continue;if(i._transitionKey=E,"line"===i.type||"area"===i.type){const e=o.get(E);if(e){if(I.add(E),"line"===i.type&&e.path&&e.path.length===i.path.length){i._targetPath=i.path.map(e=>[e[0],e[1]]),i._prevPath=e.path;for(let t=0;i.path.length>t;t++)i.path[t]=[e.path[t][0],e.path[t][1]];O=!0}else if("area"===i.type&&e.topPath&&e.bottomPath&&e.topPath.length===i.topPath.length&&e.bottomPath.length===i.bottomPath.length){i._targetTopPath=i.topPath.map(e=>[e[0],e[1]]),i._targetBottomPath=i.bottomPath.map(e=>[e[0],e[1]]),i._prevTopPath=e.topPath,i._prevBottomPath=e.bottomPath;for(let t=0;i.topPath.length>t;t++)i.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;i.bottomPath.length>t;t++)i.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];O=!0}i._targetOpacity=null!==(l=i.style.opacity)&&void 0!==l?l:1,i._startOpacity=null!==(s=null!==(a=e.opacity)&&void 0!==a?a:i.style.opacity)&&void 0!==s?s:1}else i._targetOpacity=null!==(c=i.style.opacity)&&void 0!==c?c:1,i._startOpacity=0,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),O=!0;continue}const A=r.get(E);if("point"===i.type)if(A){W.add(E);const e={x:i.x,y:i.y,r:i.r};i._targetOpacity=null!==(u=i.style.opacity)&&void 0!==u?u:1,A.x===e.x&&A.y===e.y&&A.r===e.r||(i._targetX=e.x,i._targetY=e.y,i._targetR=e.r,i.x=A.x,i.y=A.y,i.r=null!==(d=A.r)&&void 0!==d?d:i.r,O=!0)}else i._targetOpacity=null!==(h=i.style.opacity)&&void 0!==h?h:1,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),O=!0;else if("rect"===i.type)if(A){W.add(E);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=null!==(f=i.style.opacity)&&void 0!==f?f:1,A.x===e.x&&A.y===e.y&&A.w===e.w&&A.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=A.x,i.y=A.y,i.w=null!==(y=A.w)&&void 0!==y?y:i.w,i.h=null!==(g=A.h)&&void 0!==g?g:i.h,O=!0)}else i._targetOpacity=null!==(p=i.style.opacity)&&void 0!==p?p:1,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),O=!0;else if("heatcell"===i.type)if(A){W.add(E);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=null!==(v=null===(m=i.style)||void 0===m?void 0:m.opacity)&&void 0!==v?v:1,A.x===e.x&&A.y===e.y&&A.w===e.w&&A.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=A.x,i.y=A.y,i.w=null!==(x=A.w)&&void 0!==x?x:i.w,i.h=null!==(b=A.h)&&void 0!==b?b:i.h,O=!0)}else i._targetOpacity=null!==(w=null===(k=i.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,i.style=Object.assign(Object.assign({},i.style||{}),{opacity:0}),O=!0}for(const[e,t]of o)if(!I.has(e))if(e.startsWith("l:")&&t.path){const r={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(E=t.opacity)&&void 0!==E?E:1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(r),O=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const r={type:"area",topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),group:e.slice(2),style:{fill:"#999",opacity:null!==(A=t.opacity)&&void 0!==A?A:1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(r),O=!0}for(const[e,t]of r)if(!W.has(e)){if(e.startsWith("p:")){const r={type:"point",x:t.x,y:t.y,r:null!==(M=t.r)&&void 0!==M?M:3,style:{opacity:null!==(S=t.opacity)&&void 0!==S?S:1},datum:null,_targetOpacity:0,_transitionKey:e};n.exitNodes.push(r)}else if(e.startsWith("r:")){const r={type:"rect",x:t.x,y:t.y,w:null!==(P=t.w)&&void 0!==P?P:0,h:null!==(_=t.h)&&void 0!==_?_:0,style:{opacity:null!==(C=t.opacity)&&void 0!==C?C:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e};n.exitNodes.push(r)}else if(e.startsWith("h:")){const r={type:"heatcell",x:t.x,y:t.y,w:null!==(D=t.w)&&void 0!==D?D:0,h:null!==(L=t.h)&&void 0!==L?L:0,fill:"#999",datum:null,style:{opacity:null!==(T=t.opacity)&&void 0!==T?T:1},_targetOpacity:0,_transitionKey:e};n.exitNodes.push(r)}O=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),O&&(n.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:N}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition}advanceTransition(e){if(!this.activeTransition||!this.config.transition)return!1;const t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(e,t,n,r){var o,i,l,a,s;if(!n.activeTransition)return!1;const c=N(e,n.activeTransition),u=T(c,"linear"===t.easing?"linear":"ease-out-cubic");for(const e of n.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0,i=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;e.style.opacity=O(i,e._targetOpacity,u)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=O(n.x,e._targetX,u),e.y=O(n.y,e._targetY,u),void 0!==e._targetR&&void 0!==n.r&&(e.r=O(n.r,e._targetR,u))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0,o=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;e.style.opacity=O(o,e._targetOpacity,u)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=O(n.x,e._targetX,u),e.y=O(n.y,e._targetY,u),void 0!==n.w&&(e.w=O(n.w,e._targetW,u)),void 0!==n.h&&(e.h=O(n.h,e._targetH,u))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0,o=n?null!==(l=n.opacity)&&void 0!==l?l:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:O(o,e._targetOpacity,u)})}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=O(n.x,e._targetX,u),e.y=O(n.y,e._targetY,u),void 0!==n.w&&(e.w=O(n.w,e._targetW,u)),void 0!==n.h&&(e.h=O(n.h,e._targetH,u))}else if("line"===e.type){if(void 0!==e._targetOpacity){const t=null!==(a=e._startOpacity)&&void 0!==a?a:0;e.style=Object.assign(Object.assign({},e.style),{opacity:O(t,e._targetOpacity,u)})}const t=e._prevPath,n=e._targetPath;if(t&&n&&t.length===e.path.length)for(let r=0;e.path.length>r;r++)e.path[r][0]=O(t[r][0],n[r][0],u),e.path[r][1]=O(t[r][1],n[r][1],u)}else if("area"===e.type){if(void 0!==e._targetOpacity){const t=null!==(s=e._startOpacity)&&void 0!==s?s:0;e.style=Object.assign(Object.assign({},e.style),{opacity:O(t,e._targetOpacity,u)})}const t=e._prevTopPath,n=e._prevBottomPath,r=e._targetTopPath,o=e._targetBottomPath;if(t&&r&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=O(t[n][0],r[n][0],u),e.topPath[n][1]=O(t[n][1],r[n][1],u);if(n&&o&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=O(n[t][0],o[t][0],u),e.bottomPath[t][1]=O(n[t][1],o[t][1],u)}}if(c>=1){for(const e of n.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style=Object.assign(Object.assign({},"line"===e.type||"area"===e.type?e.style:e.style||{}),{opacity:0===t?0:t}),e._targetOpacity=void 0}if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("line"===e.type){const t=e._targetPath;if(t)for(let n=0;e.path.length>n;n++)e.path[n]=t[n];e._prevPath=void 0,e._targetPath=void 0}else if("area"===e.type){const t=e._targetTopPath,n=e._targetBottomPath;if(t)for(let n=0;e.topPath.length>n;n++)e.topPath[n]=t[n];if(n)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=n[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0}}if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(e,this.config.transition,t,this.prevPositionMap);return this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition,n}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const n of e){const e=this.getGroup(n);t.has(e)||t.set(e,[]),t.get(e).push(n)}return Array.from(t.entries()).map(([e,t])=>({key:e,data:t}))}resolveColorMap(e){const t=new Set;for(const n of e){const e=this.getColor(n);e&&t.add(e)}const n=Array.from(t).sort(),r=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===r)return this._colorMapCache.map;const o=Array.isArray(this.config.colorScheme)?this.config.colorScheme:C,i=new Map;for(let e=0;n.length>e;e++)i.set(n[e],o[e%o.length]);return this._colorMapCache={key:r,map:i},i}resolveLineStyle(e,t){const n=this.config.lineStyle;if("function"==typeof n){const r=n(t||{},e);if(r&&!r.stroke&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},r),{stroke:t})}return r}return n&&"object"==typeof n?{stroke:n.stroke||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var n;if(this.config.areaStyle){const n=this.config.areaStyle(t||{});if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}const r=this.config.lineStyle;if("function"==typeof r){const n=r(t||{},e);if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}return r&&"object"==typeof r?{fill:r.fill||r.stroke||"#4e79a7",fillOpacity:null!==(n=r.fillOpacity)&&void 0!==n?n:.7,stroke:r.stroke||"#4e79a7",strokeWidth:r.strokeWidth||2}:{fill:"#4e79a7",fillOpacity:.7,stroke:"#4e79a7",strokeWidth:2}}resolveGroupColor(e){if(this._colorMapCache){const t=this._colorMapCache.map.get(e);if(t)return t}const t=this._groupColorMap.get(e);if(t)return t;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:C,r=n[this._groupColorMap.size%n.length];return this._groupColorMap.set(e,r),r}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(e){var t,n,r,o;const i=Object.assign({},this.config);void 0!==e.colorScheme&&(this._colorMapCache=null,this._groupColorMap=new Map),void 0===e.barColors&&void 0===e.colorScheme||(this._barCategoryCache=null),void 0===e.normalize&&void 0===e.extentPadding&&void 0===e.xAccessor&&void 0===e.yAccessor&&void 0===e.groupAccessor&&void 0===e.categoryAccessor&&void 0===e.chartType||(this._stackExtentCache=null);let l=!1;Object.assign(this.config,e);const a="chartType"in e&&e.chartType!==i.chartType||"runtimeMode"in e&&e.runtimeMode!==i.runtimeMode;if(a||void 0!==e.xAccessor||void 0!==e.yAccessor||void 0!==e.timeAccessor||void 0!==e.valueAccessor){const s=a||!A(null!==(t=e.xAccessor)&&void 0!==t?t:e.timeAccessor,null!==(n=i.xAccessor)&&void 0!==n?n:i.timeAccessor),c=a||!A(null!==(r=e.yAccessor)&&void 0!==r?r:e.valueAccessor,null!==(o=i.yAccessor)&&void 0!==o?o:i.valueAccessor);(s||c)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=M(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=M(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=M(this.config.xAccessor,"x"),this.getY=M(this.config.yAccessor,"y")),l=!0)}if("groupAccessor"in e&&!A(e.groupAccessor,i.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?P(this.config.groupAccessor):void 0,l=!0),"categoryAccessor"in e&&!A(e.categoryAccessor,i.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?P(this.config.categoryAccessor):void 0,l=!0),"sizeAccessor"in e&&!A(e.sizeAccessor,i.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?M(this.config.sizeAccessor,"size"):void 0,l=!0),"colorAccessor"in e&&!A(e.colorAccessor,i.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?P(this.config.colorAccessor):void 0,l=!0),"y0Accessor"in e&&!A(e.y0Accessor,i.y0Accessor)&&(this.getY0=this.config.y0Accessor?M(this.config.y0Accessor,"y0"):void 0,l=!0),"pointIdAccessor"in e&&!A(e.pointIdAccessor,i.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?P(this.config.pointIdAccessor):void 0,l=!0),"candlestick"===this.config.chartType&&("openAccessor"in e&&!A(e.openAccessor,i.openAccessor)||"closeAccessor"in e&&!A(e.closeAccessor,i.closeAccessor)||"highAccessor"in e&&!A(e.highAccessor,i.highAccessor)||"lowAccessor"in e&&!A(e.lowAccessor,i.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?M(this.config.openAccessor,"open"):void 0,this.getHigh=M(this.config.highAccessor,"high"),this.getLow=M(this.config.lowAccessor,"low"),this.getClose=t?M(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,l=!0}if(!l){const t=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const n of t)if(e[n]!==i[n]){l=!0;break}}l&&(this.needsFullRebuild=!0)}}function G(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function V(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}function q(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function U(e,t){const n=q(e);if(!n)return!1;const r=q(t);return!r||n.getFullYear()!==r.getFullYear()||n.getMonth()!==r.getMonth()}function K(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function Z(e,t,n,r=30,o){let i=null,l=!1;if(o){const e=o.find(t,n,r);if(e){const o=J(e,t,n,r);o&&r>o.distance&&(i=o,l=!0)}}for(const a of e){let e=null;switch(a.type){case"point":if(o&&l)break;e=J(a,t,n,r);break;case"line":e=ee(a,t,n,r);break;case"rect":e=ne(a,t,n);break;case"heatcell":e=re(a,t,n);break;case"area":if(!1===a.interactive)break;e=ie(a,t,n);break;case"candlestick":e=oe(a,t,n)}e&&r>e.distance&&(i&&e.distance>=i.distance||(i=e))}return i}function Q(e,t,n){if(0===e.length)return null;const r=le(e,t);if(0>r)return null;if(Math.abs(e[r][0]-t)>n)return null;let o=r,i=r;r>0&&e[r][0]>=t?(o=r-1,i=r):e.length-1>r&&(o=r,i=r+1);const[l,a]=e[o],[s,c]=e[i];return s===l?a:a+Math.max(0,Math.min(1,(t-l)/(s-l)))*(c-a)}function J(e,t,n,r=30){const o=t-e.x,i=n-e.y,l=Math.sqrt(o*o+i*i);return l>V(e.r,r)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:l}}function ee(e,t,n,r=30){var o,i,l,a;if(0===e.path.length)return null;const s=le(e.path,t);if(0>s)return null;const[c,u]=e.path[s];let d;if(e.path.length>1){let r=1/0;const o=Math.max(0,s-1),i=Math.min(e.path.length-2,s);for(let l=o;i>=l;l++){const[o,i]=e.path[l],[a,s]=e.path[l+1],c=te(t,n,o,i,a,s);r>c&&(r=c)}d=r}else{const e=t-c,r=n-u;d=Math.sqrt(e*e+r*r)}const h=null!==(a=null!==(i=null===(o=e.style)||void 0===o?void 0:o.strokeWidth)&&void 0!==i?i:null===(l=e.style)||void 0===l?void 0:l.lineWidth)&&void 0!==a?a:1;return d>Math.max(5,h/2+2,r)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:c,y:u,distance:d}}function te(e,t,n,r,o,i){const l=o-n,a=i-r,s=l*l+a*a;if(0===s)return Math.sqrt(Math.pow(e-n,2)+Math.pow(t-r,2));let c=((e-n)*l+(t-r)*a)/s;c=Math.max(0,Math.min(1,c));const u=r+c*a;return Math.sqrt(Math.pow(e-(n+c*l),2)+Math.pow(t-u,2))}function ne(e,t,n){const r=G(t,n,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function re(e,t,n){const r=G(t,n,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function oe(e,t,n){const r=e.bodyWidth/2,o=Math.min(e.openY,e.closeY);if(!(e.x-r-3>t||t>e.x+r+3||e.highY-3>n||n>e.lowY+3)){const r=o+Math.max(Math.max(e.openY,e.closeY)-o,1)/2,i=t-e.x,l=n-r;return{node:e,datum:e.datum,x:e.x,y:r,distance:Math.sqrt(i*i+l*l)}}return null}function ie(e,t,n){if(0===e.topPath.length)return null;const r=le(e.topPath,t);if(0>r)return null;const[o,i]=e.topPath[r],l=t-o,a=n-i,s=Math.sqrt(l*l+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[r]?e.datum[r]:e.datum,x:o,y:i,distance:s}}function le(e,t){if(0===e.length)return-1;let n=0,r=e.length-1;for(;r>n;){const o=n+r>>1;t>e[o][0]?n=o+1:r=o}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}function ae(e){var t,n;const r=new Map;for(const n of e){const e=null!==(t=n.group)&&void 0!==t?t:"_default";let o=r.get(e);o||(o=[],r.set(e,o)),o.push(n)}for(const e of r.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const o=Array.from(r.keys()).sort((e,t)=>{const n=r.get(e),o=r.get(t);return(n.length>0?n[0].y:0)-(o.length>0?o[0].y:0)}),i=Array.from(r.values()).flat();i.sort((e,t)=>e.x-t.x||e.y-t.y);const l=new Map;for(let e=0;i.length>e;e++){i[e]._flatIndex=e;const t=null===(n=i[e].datum)||void 0===n?void 0:n.id;null!=t&&l.set(t+"",e)}return{flat:i,groups:o,byGroup:r,idToIdx:l}}function se(e,t){var n,r;if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const o=Math.max(0,Math.min(t,e.flat.length-1)),i=e.flat[o];return{flatIndex:o,group:null!==(n=i.group)&&void 0!==n?n:"_default",indexInGroup:null!==(r=i._groupIndex)&&void 0!==r?r:0}}function ce(e,t,n){const{group:r,indexInGroup:o}=t,i=n.byGroup.get(r);switch(e){case"ArrowRight":return i.length-1>o?i[o+1]._flatIndex:t.flatIndex;case"ArrowLeft":return o>0?i[o-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(r);return n.groups.length-1>e?ue(n,n.groups[e+1],i[o]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(r);return e>0?ue(n,n.groups[e-1],i[o]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function ue(e,t,n){const r=e.byGroup.get(t);let o=0,i=Math.abs(r[0].x-n.x);for(let e=1;r.length>e;e++){const t=Math.abs(r[e].x-n.x);i>t&&(i=t,o=e)}return r[o]._flatIndex}function de(e){const t=e.datum||{};return Object.assign(Object.assign({},"object"!=typeof t||null===t||Array.isArray(t)?{}:t),{data:t,x:e.x,y:e.y,time:e.x,value:e.y})}function he(t,n,r){const o=e.useRef(null),[i,l]=e.useState(null);return e.useEffect(()=>{if(!n&&!r)return;const e=o.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;l(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[n,r]),[o,[n&&i?i.w:t[0],r&&i?i.h:t[1]]]}function fe(t,n,r,o,i,l){e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{var e;const a=n.current;if(!a||0===a.lastIngestTime)return;const s="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(e=t.threshold)&&void 0!==e?e:5e3,u=s-a.lastIngestTime>c;u!==i&&(l(u),r.current=!0,o())},1e3);return()=>clearInterval(e)},[t,i,o])}X.QUADTREE_THRESHOLD=500;const ye={fill:e=>g.createElement("rect",{style:e,width:16,height:16}),line:e=>g.createElement("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function ge(e,t,n,r){let o;return o="function"==typeof n?n(e):(0,ye[n])(r(e,t)),o}function pe(){return g.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function me(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function ve({config:e,orientation:t="vertical",width:n=100}){const{colorFn:r,domain:o,label:i,format:l}=e,a=l||(e=>Math.round(100*e)/100+""),s="grad-legend-"+g.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),l=Math.max(0,(n-t)/2),c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(g.createElement("stop",{key:e,offset:100*t+"%",stopColor:r(o[0]+t*(o[1]-o[0]))}))}return g.createElement("g",{"aria-label":i||"Gradient legend"},g.createElement("defs",null,g.createElement("linearGradient",{id:s,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},c)),i&&g.createElement("text",{x:l+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),g.createElement("rect",{x:l,y:0,width:t,height:e,fill:`url(#${s})`,rx:2}),g.createElement("text",{x:l,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(o[0])),g.createElement("text",{x:l+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(o[1])))}const c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(g.createElement("stop",{key:e,offset:100*t+"%",stopColor:r(o[1]-t*(o[1]-o[0]))}))}return g.createElement("g",{"aria-label":i||"Gradient legend"},i&&g.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),g.createElement("defs",null,g.createElement("linearGradient",{id:s,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},c)),g.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${s})`,rx:2}),g.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(o[1])),g.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(o[0])))}function xe(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,legendInteraction:l,title:a="Legend",width:s=100,height:c=20,orientation:u="vertical"}=e,[d,h]=g.useState(0),[f,y]=g.useState(0),p=g.useCallback((e,t)=>{h(e),y(t)},[]),m="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:l,focusedItemIndex:a,onFocusedIndexChange:s,legendInteraction:c})=>{let u=24;const d=[];return e.forEach((e,h)=>{u+=5,d.push(g.createElement("line",{key:"legend-top-line legend-symbol-"+h,stroke:"gray",x1:0,y1:u,x2:t,y2:u})),u+=8,e.label&&(u+=16,d.push(g.createElement("text",{key:"legend-text-"+h,y:u,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label)),u+=8),d.push(g.createElement("g",{key:"legend-group-"+h,className:"legend-item",transform:`translate(0,${u})`},((e,t,n,r,o,i,l,a,s,c)=>{const{type:u="fill",styleFn:d,items:h}=e,f=[];let y=0;const p=!(!t&&!n),m="isolate"===c||void 0===c&&null!=o;return h.forEach((e,c)=>{const v=ge(e,c,u,d),x=me(e,r,o),b=o&&o.size>0&&o.has(e.label);f.push(g.createElement("g",{key:"legend-item-"+c,transform:`translate(0,${y})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:p?a===i&&c===l?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&m?b||!1:void 0,"aria-current":p&&!m&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:p?n=>{var r;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(c+("ArrowDown"===n.key?1:-1)+h.length)%h.length;s(a,e);const t=null===(r=n.currentTarget.parentElement)||void 0===r?void 0:r.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:p?t=>{s(a,c),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:p?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:p?"pointer":"default",opacity:x,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},p&&g.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,b&&g.createElement(pe,null),g.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),y+=22}),f})(e,n,r,o,i,l,a,h,s,c))),u+=22*e.items.length+8}),d})({legendGroups:t||[],width:s,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:d,focusedItemIndex:f,onFocusedIndexChange:p,legendInteraction:l}):(({legendGroups:e,height:t,width:n,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:l,focusedGroupIndex:a,focusedItemIndex:s,onFocusedIndexChange:c,legendInteraction:u})=>{let d=0;const h=[];e.forEach((e,t)=>{let f=0;e.label&&(f+=16);const y=((e,t,n,r,o,i,l,a,s,c,u)=>{const{type:d="fill",styleFn:h,items:f}=e,y=[];let p=0,m=0;const v=!(!t&&!n),x="isolate"===c||void 0===c&&null!=o;f.forEach((e,c)=>{const b=ge(e,c,d,h),k=me(e,r,o),w=o&&o.size>0&&o.has(e.label),E=26+7*e.label.length;u&&u>0&&p>0&&p+E>u&&(m++,p=0),y.push(g.createElement("g",{key:"legend-item-"+c,transform:`translate(${p},${22*m})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:v?a===i&&c===l?0:-1:void 0,role:v?"option":void 0,"aria-selected":v&&x?w||!1:void 0,"aria-current":v&&!x&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:v?n=>{var r;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(c+("ArrowRight"===n.key?1:-1)+f.length)%f.length;s(a,e);const t=null===(r=n.currentTarget.parentElement)||void 0===r?void 0:r.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:v?t=>{s(a,c),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:v?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:v?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},v&&g.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),b,w&&g.createElement(pe,null),g.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),p+=E});let b=0,k=0;for(const e of f){const t=26+7*e.label.length;u&&u>0&&k>0&&k+t>u?(b=Math.max(b,k),k=t):k+=t}b=Math.max(b,k);const w=m+1;return{items:y,offset:b,totalRows:w,totalHeight:22*w}})(e,r,o,i,l,a,s,t,c,u,n);f+=y.offset+5,h.push(Object.assign(Object.assign({label:e.label},y),{offset:f,totalRows:y.totalRows,totalHeight:y.totalHeight})),d+=f+12});let f=d>n?0:Math.max(0,(n-d)/2);const y=[];return h.forEach((n,r)=>{const o=e[r];o.label&&(y.push(g.createElement("text",{key:"legend-text-"+r,transform:`translate(${f},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},o.label)),f+=16),y.push(g.createElement("g",{key:"legend-group-"+r,className:"legend-item",transform:`translate(${f},0)`},n.items)),f+=n.offset+5,e[r+1]&&y.push(g.createElement("line",{key:"legend-top-line legend-symbol-"+r,stroke:"gray",x1:f,y1:-8,x2:f,y2:(n.totalHeight||t)+0+8})),f+=12}),g.createElement("g",null,y)})({legendGroups:t||[],title:a,height:c,width:s,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:d,focusedItemIndex:f,onFocusedIndexChange:p,legendInteraction:l}),v=!(!n&&!r);return g.createElement("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==l&&(void 0!==l||null==i))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},void 0!==a&&""!==a&&"vertical"===u&&g.createElement("text",{className:"legend-title",y:16,x:s/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},a),m)}function be(e){const{legend:t,totalWidth:n,totalHeight:r,margin:o,legendPosition:i="right",title:l,legendHoverBehavior:a,legendClickBehavior:s,legendHighlightedCategory:c,legendIsolatedCategories:u,legendInteraction:d}=e;if(!t)return null;const h="top"===i||"bottom"===i;let f,y;return"left"===i?(f=4,y=o.top):"top"===i?(f=0,y=l?32:8):"bottom"===i?(f=0,y=r-o.bottom+50):(f=n-o.right+10,y=o.top),g.createElement("g",{transform:`translate(${f}, ${y})`},function(e){return"object"==typeof e&&null!==e&&"gradient"in e}(t)?g.createElement(ve,{config:t.gradient,orientation:h?"horizontal":"vertical",width:h?n:100}):function(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}(t)?g.createElement(xe,{legendGroups:t.legendGroups,title:"",width:h?n:100,orientation:h?"horizontal":"vertical",customHoverBehavior:a,customClickBehavior:s,highlightedCategory:c,isolatedCategories:u,legendInteraction:d}):t)}function ke(e){return"string"==typeof e?{type:e}:e}function we({orient:t,config:n,values:r,scale:o,size:i,length:a}){const s=function(e){var t,n,r,o,i;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(n=e.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(r=e.fillOpacity)&&void 0!==r?r:.5,stroke:null!==(o=e.stroke)&&void 0!==o?o:"none",strokeWidth:null!==(i=e.strokeWidth)&&void 0!==i?i:1}}(n),c="top"===t||"bottom"===t,u=e.useMemo(()=>{if(0===r.length)return null;const e=o.domain(),n=i-8;if("boxplot"===s.type){const e=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const r=t[Math.floor(.25*n)],o=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],l=i-r;return{q1:r,median:o,q3:i,whiskerLow:Math.max(t[0],r-1.5*l),whiskerHigh:Math.min(t[n-1],i+1.5*l)}}(r);if(!e)return null;const{q1:i,median:l,q3:a,whiskerLow:u,whiskerHigh:d}=e,h=Math.min(.5*n,20),f=(n-h)/2+4;if(c){const e=o(i),n=o(a),r=o(l),c=o(u),y=o(d),p="top"===t?-1:1,m=0;return g.createElement("g",{"data-testid":"marginal-boxplot-"+t},g.createElement("line",{x1:c,y1:m+p*(f+h/2),x2:y,y2:m+p*(f+h/2),stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:c,y1:m+p*f,x2:c,y2:m+p*(f+h),stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:y,y1:m+p*f,x2:y,y2:m+p*(f+h),stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("rect",{x:Math.min(e,n),y:"top"===t?m-f-h:m+f,width:Math.abs(n-e),height:h,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:r,y1:"top"===t?m-f-h:m+f,x2:r,y2:"top"===t?m-f:m+f+h,stroke:s.fill,strokeWidth:2}))}{const e=o(i),n=o(a),r=o(l),c=o(u),y=o(d),p="left"===t?-1:1,m=0;return g.createElement("g",{"data-testid":"marginal-boxplot-"+t},g.createElement("line",{x1:m+p*(f+h/2),y1:c,x2:m+p*(f+h/2),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:m+p*f,y1:c,x2:m+p*(f+h),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:m+p*f,y1:y,x2:m+p*(f+h),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("rect",{x:"left"===t?m-f-h:m+f,y:Math.min(e,n),width:h,height:Math.abs(n-e),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:"left"===t?m-f-h:m+f,y1:r,x2:"left"===t?m-f:m+f+h,y2:r,stroke:s.fill,strokeWidth:2}))}}const u=l.bin().domain(e).thresholds(s.bins)(r);if(0===u.length)return null;const d=Math.max(...u.map(e=>e.length));if(0===d)return null;if("histogram"===s.type)return g.createElement("g",{"data-testid":"marginal-histogram-"+t},u.map((e,r)=>{if(null==e.x0||null==e.x1)return null;const i=e.length/d*n;if(c){const n=o(e.x0),l=o(e.x1)-o(e.x0);return g.createElement("rect",{key:r,x:n,y:"top"===t?-4-i:4,width:Math.max(l,.5),height:i,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}{const n=o(e.x0),l=o(e.x1)-o(e.x0);return g.createElement("rect",{key:r,x:"left"===t?-4-i:4,y:Math.min(n,n+l),width:i,height:Math.abs(l),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}}));if("violin"===s.type){const e=n/2+4,r=[];for(const i of u){if(null==i.x0||null==i.x1)continue;const l=i.length/d*(n/2),a=o((i.x0+i.x1)/2);r.push(c?`${a},${"top"===t?-(e-l):e-l}`:`${"left"===t?-(e-l):e-l},${a}`)}for(let i=u.length-1;i>=0;i--){const l=u[i];if(null==l.x0||null==l.x1)continue;const a=l.length/d*(n/2),s=o((l.x0+l.x1)/2);r.push(c?`${s},${"top"===t?-(e+a):e+a}`:`${"left"===t?-(e+a):e+a},${s}`)}return g.createElement("g",{"data-testid":"marginal-violin-"+t},g.createElement("polygon",{points:r.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}if("ridgeline"===s.type){const e=[];if(c){const r=0,i=null!=u[0].x0?o(u[0].x0):0;e.push(`M${i},${r}`);for(const r of u){if(null==r.x0||null==r.x1)continue;const i=r.length/d*n,l=o((r.x0+r.x1)/2);e.push(`L${l},${"top"===t?-i-4:i+4}`)}const l=null!=u[u.length-1].x1?o(u[u.length-1].x1):a;e.push(`L${l},${r}`),e.push("Z")}else{const r=0,i=null!=u[0].x0?o(u[0].x0):0;e.push(`M${r},${i}`);for(const r of u){if(null==r.x0||null==r.x1)continue;const i=r.length/d*n,l=o((r.x0+r.x1)/2);e.push(`L${"left"===t?-i-4:i+4},${l}`)}const l=null!=u[u.length-1].x1?o(u[u.length-1].x1):a;e.push(`L${r},${l}`),e.push("Z")}return g.createElement("g",{"data-testid":"marginal-ridgeline-"+t},g.createElement("path",{d:e.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}return null},[r,o,s,i,a,t,c,4]);return u?g.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},u):null}function Ee(e,t=120,n=8){if(!e)return[];const r=Math.max(1,Math.floor(t/n)),o=e.split(/\s+/),i=[];let l="";for(const e of o)l&&l.length+1+e.length>r?(i.push(l),l=e):l=l?`${l} ${e}`:e;return l&&i.push(l),i}function Ae(e,t,n,r){return"curly"===e?r?`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`:r?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function Me(e){const{x:t=0,y:n=0,dx:r,dy:o,nx:i,ny:l,note:a,connector:s,subject:c,type:u,color:d,className:h,disable:f,events:y={},"data-testid":p}=e,m=new Set(Array.isArray(f)?f:[]);let v=r||0,x=o||0;null!=i&&(v=i-t),null!=l&&(x=l-n);const b="string"==typeof u?u:"label";if("bracket"===b&&c&&0===v&&0===x)if(void 0!==c.width){v=c.width/2;const e=c.depth||30;x=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;v=e+(0>e?-5:5),x=c.height/2}return g.createElement("g",Object.assign({className:("annotation "+(h||"")).trim(),transform:`translate(${t},${n})`,"data-testid":p},y),!m.has("connector")&&function(e,t,n,r,o,i){const l=[];let a=0,s=0;if("callout-circle"!==o&&"label"!==o||!(null==i?void 0:i.radius)){if("callout-rect"===o&&i){const n=i.width||0,r=i.height||0;if(n>0||r>0){const o=n/2,i=r/2,l=e-o,c=t-i;if(0!==l||0!==c){const e=Math.abs(l),t=Math.abs(c),u=n/2,d=r/2,h=e*d>t*u?u/e:d/t;a=o+l*h,s=i+c*h}}}else if("bracket"===o&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(a=e/2,s=n):void 0!==t&&(a=n,s=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const r=Math.atan2(t,e);a=Math.cos(r)*n,s=Math.sin(r)*n}}if(Math.sqrt(Math.pow(e-a,2)+Math.pow(t-s,2))>.5&&(l.push(g.createElement("line",{key:"connector-line",x1:a,y1:s,x2:e,y2:t,stroke:r||"var(--semiotic-text-secondary, currentColor)"})),"arrow"===(null==n?void 0:n.end))){const n=10,o=16/180*Math.PI,i=Math.atan2(t-s,e-a);l.push(g.createElement("path",{key:"connector-arrow",d:`M${a},${s}L${a+n*Math.cos(i+o)},${s+n*Math.sin(i+o)}L${a+n*Math.cos(i-o)},${s+n*Math.sin(i-o)}Z`,fill:r||"var(--semiotic-text-secondary, currentColor)",stroke:"none"}))}return g.createElement("g",{className:"annotation-connector"},l)}(v,x,s,d,b,c),!m.has("subject")&&function(e,t,n,r,o){var i;const l=[];switch(e){case"callout-circle":{const e=((null==t?void 0:t.radius)||0)+((null==t?void 0:t.radiusPadding)||0);e>0&&l.push(g.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"}));break}case"callout-rect":{const e=(null==t?void 0:t.width)||0,r=(null==t?void 0:t.height)||0;(e>0||r>0)&&l.push(g.createElement("rect",{key:"subject-rect",width:e,height:r,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"}));break}case"callout-custom":(null==t?void 0:t.custom)&&l.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=r||0,i=o||0;if(void 0!==(null==t?void 0:t.x)){const r=(t.x||0)-e;l.push(g.createElement("line",{key:"threshold-line",x1:r,y1:(t.y1||0)-i,x2:r,y2:(t.y2||0)-i,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}))}else if(void 0!==(null==t?void 0:t.y)){const r=(t.y||0)-i;l.push(g.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:r,x2:(t.x2||0)-e,y2:r,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}))}else void 0!==(null==t?void 0:t.x1)||void 0!==(null==t?void 0:t.x2)?l.push(g.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"})):void 0===(null==t?void 0:t.y1)&&void 0===(null==t?void 0:t.y2)||l.push(g.createElement("line",{key:"threshold-line",x1:0,y1:(t.y1||0)-i,x2:0,y2:(t.y2||0)-i,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(i=null==t?void 0:t.width)&&void 0!==i?i:null==t?void 0:t.height;void 0!==e&&l.push(g.createElement("path",{key:"bracket-path",d:Ae((null==t?void 0:t.type)||"curly",e,(null==t?void 0:t.depth)||30,void 0===(null==t?void 0:t.width)),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"}));break}}return g.createElement("g",{className:"annotation-subject"},l)}(b,c,d,t,n),!m.has("note")&&function(e,t,n,r){if(!e)return g.createElement("g",{className:"annotation-note"});const{label:o,title:i,orientation:l,align:a,wrap:s=120,noWrap:c}=e;if(!o&&!i)return g.createElement("g",{className:"annotation-note"});let u=l;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=a;d&&"dynamic"!==d||(d="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let h="start";"topBottom"===u?"right"===d?h="end":"middle"===d&&(h="middle"):h=0>t?"end":"start";const f=16,y=i?c?[i]:Ee(i,s):[],p=o?c?[o]:Ee(o,s):[],m="leftRight"===u?"end"===h?-4:4:0;let v=0;const x=[],b=r||"var(--semiotic-text, #333)";y.length>0&&(x.push(g.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:b,textAnchor:h,fontWeight:"bold"},y.map((e,t)=>g.createElement("tspan",{key:t,x:m,dy:0===t?0:f},e)))),v=y.length*f),p.length>0&&x.push(g.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:b,textAnchor:h,y:v},p.map((e,t)=>g.createElement("tspan",{key:t,x:m,dy:0===t?0:f},e))));let k=null;if((i||o)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(s,120);let t=0,n=e;"end"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),k=g.createElement("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(y.length+p.length)*f+(p.length>0?f:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),k=g.createElement("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,y.length+p.length-1)*f;let E=0;return"topBottom"===u?E=0>n?-(w+2):18:"leftRight"===u&&(E="middle"===d?-(w+f+(p.length>0&&y.length>0?2:0))/2+8:"bottom"===d||0>n?-(w+2):18),g.createElement("g",{className:"annotation-note",transform:`translate(${t},${n})`},g.createElement("g",{className:"annotation-note-content",transform:0!==E?`translate(0,${E})`:void 0},x),k)}(a,v,x,d))}function Se(e){var t,n;const{noteData:r}=e,{screenCoordinates:o}=r,i="string"==typeof r.type?r.type:"label",l=r.eventListeners||r.events||{};if(r.coordinates&&o){const e=r.nx||o[0][0]+(null!==(t=r.dx)&&void 0!==t?t:0),l=r.ny||o[0][1]+(null!==(n=r.dy)&&void 0!==n?n:0),a=o.map((t,n)=>{const o=Object.assign({},r,{note:0===n?r.note:{label:""},x:t[0],y:t[1],nx:e,ny:l});return g.createElement(Me,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},o,{type:i}))});return g.createElement("g",null,a)}const a=r.note||{title:"none",label:r.label};return g.createElement(Me,Object.assign({"data-testid":"semiotic-annotation",key:`${a.label}-${a.title}-${r.i}`,events:l},r,{type:i}))}function Pe(e,t){var n,r,o;const i=null!==(r=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==r?r:null===(o=t.scales)||void 0===o?void 0:o.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function _e(e,t){var n,r,o;const i=null!==(r=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==r?r:null===(o=t.scales)||void 0===o?void 0:o.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function Ce(e,t,n){var r,o,i,l;const a=e.anchor||"fixed";if("latest"===a){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const i=n.pointNodes[o];if(i.pointId===e.pointId){const e={x:i.x,y:i.y};return null===(r=n.stickyPositionCache)||void 0===r||r.set(t,e),e}}const i=function(e){var t,n,r,o,i,l;const a=e.data;if(!a||0===a.length)return null;const s=a[a.length-1],c=null!==(n=null===(t=e.scales)||void 0===t?void 0:t.x)&&void 0!==n?n:null===(r=e.scales)||void 0===r?void 0:r.time,u=null!==(i=null===(o=e.scales)||void 0===o?void 0:o.y)&&void 0!==i?i:null===(l=e.scales)||void 0===l?void 0:l.value;if(!c||!u)return null;const d=s[e.xAccessor||"x"],h=s[e.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return i&&(null===(o=n.stickyPositionCache)||void 0===o||o.set(t,i)),i}let s=null,c=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(s=t.x,c=t.y)}if(null!=s&&null!=c||(s=Pe(e,n),c=_e(e,n)),null!=s&&null!=c)return null===(i=n.stickyPositionCache)||void 0===i||i.set(t,{x:s,y:c}),{x:s,y:c};if("sticky"===a){const e=null===(l=n.stickyPositionCache)||void 0===l?void 0:l.get(t);if(e)return e}return null}function De(e,t,n,r=50){return!(-r>e||e>(n.width||0)+r||-r>t||t>(n.height||0)+r)}const Le={linear:s.curveLinear,monotoneX:s.curveMonotoneX,monotoneY:s.curveMonotoneY,step:s.curveStep,stepAfter:s.curveStepAfter,stepBefore:s.curveStepBefore,basis:s.curveBasis,cardinal:s.curveCardinal,catmullRom:s.curveCatmullRom};let Te={positions:new Map};const Ne=new Set;function Oe(){for(const e of Ne)e()}function $e(e,t){const n=Te.positions.get(e);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==t)return;const r=new Map(Te.positions);r.delete(e),Te={positions:r},Oe()}function We(e,t){const n=Te.positions.get(e);if(!(null==n?void 0:n.locked))return;if(t&&n.sourceId!==t)return;const r=new Map(Te.positions);r.delete(e),Te={positions:r},Oe()}function Ie(){return Te}function ze(e){return Ne.add(e),()=>Ne.delete(e)}const Re={positions:new Map};function Be(){return()=>{}}function je(){return Re}function Fe(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Ye(e,t,n){if("left"===e||"right"===e){const r="left"===e?n:0,o="left"===e?-1:1,i=Math.ceil(t/8);let l="M0,"+r;for(let e=0;i>e;e++){const n=8*(e+1);l+=`L${Math.min(8*e+4,t)},${r+4*o}`,l+=`L${Math.min(n,t)},${r}`}return l}{const r="bottom"===e?0:t,o="bottom"===e?1:-1,i=Math.ceil(n/8);let l=`M${r},0`;for(let e=0;i>e;e++){const t=8*(e+1);l+=`L${r+4*o},${Math.min(8*e+4,n)}`,l+=`L${r},${Math.min(t,n)}`}return l}}function He(t){const{width:n,height:r,totalWidth:o,totalHeight:i,margin:l,scales:a,showAxes:s,axes:c,showGrid:u,xFormat:d,yFormat:h}=t,f=e.useMemo(()=>{var e;if(!a)return[];const t=null==c?void 0:c.find(e=>"bottom"===e.orient),r=(null==t?void 0:t.tickFormat)||d||Xe,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,i=a.x.ticks(Math.min(o,Math.max(2,Math.floor(n/70)))),l=i.map(e=>e.valueOf()),s=i.map((e,t)=>({value:e,pixel:a.x(e),label:r(e,t,l)})),u=s.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0);return Ge(s,Math.max(55,u+8))},[a,c,d,n]),y=e.useMemo(()=>{var e;if(!a)return[];const t=null==c?void 0:c.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||h||Xe,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return Ge(a.y.ticks(Math.min(o,Math.max(2,Math.floor(r/30)))).map(e=>({value:e,pixel:a.y(e),label:n(e)})),22)},[a,c,h,r]),p=u&&a,m=s&&a;if(!p&&!m)return null;const v=null==c?void 0:c.find(e=>"bottom"===e.orient),x=null==c?void 0:c.find(e=>"left"===e.orient),b=m&&(!v||!1!==v.baseline),k=m&&(!x||!1!==x.baseline),w=(null==v?void 0:v.jaggedBase)||!1,E=(null==x?void 0:x.jaggedBase)||!1,A="var(--semiotic-border, #ccc)";return g.createElement("svg",{width:o,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},g.createElement("g",{transform:`translate(${l.left},${l.top})`},p&&(()=>{var e,t;const o=Fe(null===(e=null==c?void 0:c.find(e=>"bottom"===e.orient))||void 0===e?void 0:e.gridStyle),i=Fe(null===(t=null==c?void 0:c.find(e=>"left"===e.orient))||void 0===t?void 0:t.gridStyle);return g.createElement("g",{className:"stream-grid"},f.map((e,t)=>g.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:r,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o})),y.map((e,t)=>g.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:n,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i})))})(),b&&!w&&g.createElement("line",{x1:0,y1:r,x2:n,y2:r,stroke:A,strokeWidth:1}),w&&g.createElement("path",{d:Ye("bottom",n,r),fill:"none",stroke:A,strokeWidth:1}),k&&!E&&g.createElement("line",{x1:0,y1:0,x2:0,y2:r,stroke:A,strokeWidth:1}),E&&g.createElement("path",{d:Ye("left",n,r),fill:"none",stroke:A,strokeWidth:1})))}function Xe(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function Ge(e,t){if(2>=e.length)return e;const n=[e[0]];for(let r=1;e.length-1>r;r++)t>Math.abs(e[r].pixel-n[n.length-1].pixel)||n.push(e[r]);const r=e[e.length-1];return t>Math.abs(r.pixel-n[n.length-1].pixel)?n[n.length-1]=r:n.push(r),n}function Ve(t){var n,r;const{width:o,height:i,totalWidth:l,totalHeight:c,margin:u,scales:d,showAxes:h,axes:f,xLabel:y,yLabel:m,yLabelRight:v,xFormat:x,yFormat:b,showGrid:k,title:w,legend:E,legendHoverBehavior:A,legendClickBehavior:M,legendHighlightedCategory:S,legendIsolatedCategories:P,legendPosition:_="right",foregroundGraphics:C,marginalGraphics:D,xValues:L,yValues:T,annotations:N,svgAnnotationRules:O,xAccessor:$,yAccessor:W,annotationData:I,pointNodes:z,curve:R,underlayRendered:B,linkedCrosshairName:j,linkedCrosshairSourceId:F,children:Y}=t,H=e.useMemo(()=>{var e;if(!h||!d)return[];const t=null==f?void 0:f.find(e=>"bottom"===e.orient),n=(null==t?void 0:t.tickFormat)||x||Xe,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,i=d.x.ticks(Math.min(r,Math.max(2,Math.floor(o/70)))),l=i.map(e=>e.valueOf()),a=i.map((e,t)=>({value:e,pixel:d.x(e),label:n(e,t,l)})),s=a.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0),c=(null==t?void 0:t.autoRotate)?Math.max(20,Math.min(s+8,55)):Math.max(55,s+8);let u=Ge(a,c);if(u.length>1&&(u=u.filter((e,t)=>0===t||e.label+""!=u[t-1].label+"")),(null==t?void 0:t.includeMax)&&u.length>0){const e=d.x.domain()[1],t=d.x(e),r=u[u.length-1].pixel;if(Math.abs(t-r)>1){const o=n(e,u.length,l);c>t-r&&u.length>1&&(u=u.slice(0,-1)),u.push({value:e,pixel:t,label:o})}}return u},[h,d,f,x,o]),X=e.useMemo(()=>{var e;if(!h||!d)return[];const t=null==f?void 0:f.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||b||Xe,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;let o=Ge(d.y.ticks(Math.min(r,Math.max(2,Math.floor(i/30)))).map(e=>({value:e,pixel:d.y(e),label:n(e)})),22);if(o.length>1&&(o=o.filter((e,t)=>0===t||e.label+""!=o[t-1].label+"")),(null==t?void 0:t.includeMax)&&o.length>0){const e=d.y.domain()[1],t=d.y(e),r=o[o.length-1].pixel;if(Math.abs(t-r)>1){const i=n(e);22>Math.abs(t-r)&&o.length>1&&(o=o.slice(0,-1)),o.push({value:e,pixel:t,label:i})}}return o},[h,d,f,b,i]),G=e.useMemo(()=>{var e;if(!h||!d)return[];const t=null==f?void 0:f.find(e=>"right"===e.orient);if(!t)return[];const n=t.tickFormat||b||Xe,r=null!==(e=t.ticks)&&void 0!==e?e:5;return Ge(d.y.ticks(Math.min(r,Math.max(2,Math.floor(i/30)))).map(e=>({value:e,pixel:d.y(e),label:n(e)})),22)},[h,d,f,b,i]),V=e.useRef(new Map),q=e.useRef(null!==(n=null==N?void 0:N.length)&&void 0!==n?n:0),K=null!==(r=null==N?void 0:N.length)&&void 0!==r?r:0;q.current!==K&&(q.current=K,V.current=new Map);const Z=e.useMemo(()=>{if(!N||0===N.length)return null;const e=function(e,t,n){var r,o,i,l,c,u,d,h,f,y,m,v,x,b,k,w,E,A,M,S,P,_,C,D,L,T,N,O,$,W,I,z,R,B,j,F,Y,H,X,G,V,q,U,K,Z,Q,J,ee;switch(e.type){case"label":{const r=Ce(e,t,n);if(!r)return null;const{x:o,y:i}=r;return De(o,i,n)?g.createElement(Se,{key:"ann-"+t,noteData:{x:o,y:i,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"label",connector:e.connector||{end:"arrow"},color:e.color}}):null}case"callout":{const r=Ce(e,t,n);if(!r)return null;const{x:o,y:i}=r;return De(o,i,n)?g.createElement(Se,{key:"ann-"+t,noteData:{x:o,y:i,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"callout-circle",subject:{radius:e.radius||12},connector:e.connector||{end:"arrow"},color:e.color}}):null}case"x-threshold":{const r=Pe(e,n);if(null==r)return null;const o=e.color||"#f97316",i=e.labelPosition||"top";let l;return l="bottom"===i?(n.height||0)-4:"center"===i?(n.height||0)/2:12,g.createElement("g",{key:"ann-"+t},g.createElement("line",{x1:r,y1:0,x2:r,y2:n.height||0,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&g.createElement("text",{x:r+4,y:l,fill:o,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const r=_e(e,n);if(null==r)return null;const o=e.color||"#f97316",i=e.labelPosition||"right";let l,a;return"left"===i?(l=4,a="start"):"center"===i?(l=(n.width||0)/2,a="middle"):(l=(n.width||0)-4,a="end"),g.createElement("g",{key:"ann-"+t},g.createElement("line",{x1:0,y1:r,x2:n.width||0,y2:r,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&g.createElement("text",{x:l,y:r-4,textAnchor:a,fill:o,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const r=(e.coordinates||[]).map(e=>({x:Pe(Object.assign(Object.assign({},e),{type:"point"}),n),y:_e(Object.assign(Object.assign({},e),{type:"point"}),n),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;const o=a.packEnclose(r),i=e.padding||10;return g.createElement("g",{key:"ann-"+t},g.createElement("circle",{cx:o.x,cy:o.y,r:o.r+i,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&g.createElement("text",{x:o.x,y:o.y-o.r-i-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12},e.label))}case"rect-enclose":{const r=(e.coordinates||[]).map(e=>({x:Pe(Object.assign(Object.assign({},e),{type:"point"}),n),y:_e(Object.assign(Object.assign({},e),{type:"point"}),n)})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;const o=e.padding||10,i=r.map(e=>e.x),l=r.map(e=>e.y),a=Math.min(...i)-o,s=Math.max(...i)+o,c=Math.min(...l)-o,u=Math.max(...l)+o;return g.createElement("g",{key:"ann-"+t},g.createElement("rect",{x:a,y:c,width:s-a,height:u-c,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&g.createElement("text",{x:(a+s)/2,y:c-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12},e.label))}case"highlight":{const r=n.data||[],o="function"==typeof e.filter?r.filter(e.filter):e.field&&null!=e.value?r.filter(t=>t[e.field]===e.value):[],i={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return g.createElement("g",{key:"ann-"+t},o.map((t,r)=>{const o=Pe(t,n),l=_e(t,n);if(null==o||null==l)return null;const a="function"==typeof e.r?e.r(t):e.r||6,s="function"==typeof e.style?e.style(t):e.style||i;return g.createElement("circle",Object.assign({key:"hl-"+r,cx:o,cy:l,r:a},s))}))}case"bracket":{const r=Pe(e,n),o=_e(e,n);return g.createElement(Se,{key:"ann-"+t,noteData:{x:null!=r?r:0,y:null!=o?o:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}})}case"trend":{const a=n.data||[];if(2>a.length)return null;const s=n.xAccessor||"x",h=n.yAccessor||"y",f=a.map(e=>[e[s],e[h]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>f.length)return null;const y=null!==(o=null===(r=n.scales)||void 0===r?void 0:r.x)&&void 0!==o?o:null===(i=n.scales)||void 0===i?void 0:i.time,m=null!==(c=null===(l=n.scales)||void 0===l?void 0:l.y)&&void 0!==c?c:null===(u=n.scales)||void 0===u?void 0:u.value;if(!y||!m)return null;const v=e.method||"linear";let x;x="loess"===v?function(e,t=.3){const n=e.length;if(2>n)return e.slice();const r=e.slice().sort((e,t)=>e[0]-t[0]),o=r.map(e=>e[0]),i=r.map(e=>e[1]),l=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=o[e],r=o.map(e=>Math.abs(e-t)),s=r.slice().sort((e,t)=>e-t)[Math.min(l-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===s?0:r[e]/s;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,f=0,y=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*o[e],h+=t*i[e],f+=t*o[e]*o[e],y+=t*o[e]*i[e])}if(0===u){a.push([t,i[e]]);continue}const g=u*f-d*d;if(1e-12>Math.abs(g))a.push([t,h/u]);else{const e=(u*y-d*h)/g;a.push([t,(h-e*d)/u+e*t])}}return a}(f,null!==(d=e.bandwidth)&&void 0!==d?d:.3):("polynomial"===v?p.default.polynomial(f,{order:e.order||2}):p.default.linear(f)).points;const b=x.map(([e,t])=>`${y(e)},${m(t)}`).join(" "),k=e.color||"#6366f1";return g.createElement("g",{key:"ann-"+t},g.createElement("polyline",{points:b,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&g.createElement("text",{x:y(x[x.length-1][0])+4,y:m(x[x.length-1][1])-4,fill:k,fontSize:11},e.label))}case"band":{const r=null!==(f=null===(h=n.scales)||void 0===h?void 0:h.y)&&void 0!==f?f:null===(y=n.scales)||void 0===y?void 0:y.value,o=null!==(m=null==r?void 0:r(e.y0))&&void 0!==m?m:0,i=null!==(v=null==r?void 0:r(e.y1))&&void 0!==v?v:n.height||0;return g.createElement("g",{key:"ann-"+t},g.createElement("rect",{x:0,y:Math.min(o,i),width:n.width||0,height:Math.abs(i-o),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&g.createElement("text",{x:(n.width||0)-4,y:Math.min(o,i)-4,textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11},e.label))}case"envelope":{const r=n.data||[];if(2>r.length)return null;const o=n.xAccessor||"x",i=null!==(b=null===(x=n.scales)||void 0===x?void 0:x.x)&&void 0!==b?b:null===(k=n.scales)||void 0===k?void 0:k.time,l=null!==(E=null===(w=n.scales)||void 0===w?void 0:w.y)&&void 0!==E?E:null===(A=n.scales)||void 0===A?void 0:A.value;if(!i||!l)return null;const a=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",u=e.filter,d=r.filter(e=>null!=e[a]&&null!=e[c]&&!(u&&!u(e))).sort((e,t)=>e[o]-t[o]);if(2>d.length)return null;const h=Le[n.curve||"linear"]||s.curveLinear,f=s.area().x(e=>i(e[o])).y0(e=>l(e[c])).y1(e=>l(e[a])).curve(h)(d);if(!f)return null;const y=e.fill||"#6366f1";return g.createElement("g",{key:"ann-"+t},g.createElement("path",{d:f,fill:y,fillOpacity:null!==(M=e.fillOpacity)&&void 0!==M?M:.15,stroke:"none"}),e.label&&d.length>0&&g.createElement("text",{x:i(d[d.length-1][o])+4,y:l(d[d.length-1][a])-4,fill:y,fontSize:11},e.label))}case"anomaly-band":{const r=n.data||[];if(2>r.length)return null;const o=n.yAccessor||"y",i=null!==(P=null===(S=n.scales)||void 0===S?void 0:S.x)&&void 0!==P?P:null===(_=n.scales)||void 0===_?void 0:_.time,l=null!==(D=null===(C=n.scales)||void 0===C?void 0:C.y)&&void 0!==D?D:null===(L=n.scales)||void 0===L?void 0:L.value;if(!i||!l)return null;const a=r.map(e=>e[o]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const s=a.reduce((e,t)=>e+t,0)/a.length,c=a.reduce((e,t)=>e+Math.pow(t-s,2),0)/a.length,u=Math.sqrt(c),d=null!==(T=e.threshold)&&void 0!==T?T:2,h=s-d*u,f=!1!==e.showBand,y=e.fill||"#6366f1",p=null!==(N=e.fillOpacity)&&void 0!==N?N:.1,m=e.anomalyColor||"#ef4444",v=null!==(O=e.anomalyRadius)&&void 0!==O?O:6,x=l(s+d*u),b=l(h),k=r.filter(e=>{const t=e[o];return null!=t&&Math.abs(t-s)>d*u});return g.createElement("g",{key:"ann-"+t},f&&g.createElement("rect",{x:0,y:Math.min(x,b),width:n.width||0,height:Math.abs(b-x),fill:y,fillOpacity:p}),k.map((e,t)=>{const r=Pe(e,n),o=_e(e,n);return null==r||null==o?null:g.createElement("circle",{key:"anomaly-"+t,cx:r,cy:o,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5})}),e.label&&g.createElement("text",{x:(n.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:y,fontSize:11},e.label))}case"forecast":{const r=n.data||[];if(3>r.length)return null;const o=n.xAccessor||"x",i=n.yAccessor||"y",l=null!==(W=null===($=n.scales)||void 0===$?void 0:$.x)&&void 0!==W?W:null===(I=n.scales)||void 0===I?void 0:I.time,a=null!==(R=null===(z=n.scales)||void 0===z?void 0:z.y)&&void 0!==R?R:null===(B=n.scales)||void 0===B?void 0:B.value;if(!l||!a)return null;const s=r.map(e=>[e[o],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>s.length)return null;let c;if("polynomial"===(e.method||"linear")){const t=p.default.polynomial(s,{order:e.order||2}).equation;c=e=>t.reduce((t,n,r)=>t+n*Math.pow(e,r),0)}else{const e=s.length;let t=0,n=0,r=0,o=0;for(const[e,i]of s)t+=e,n+=i,r+=e*e,o+=e*i;const i=e*r-t*t;if(1e-12>Math.abs(i))return null;const l=(e*o-t*n)/i,a=(n-l*t)/e;c=e=>a+l*e}const u=s.length,d=s.map(([e,t])=>t-c(e)).reduce((e,t)=>e+t*t,0),h=Math.sqrt(d/Math.max(u-2,1)),f=s.reduce((e,t)=>e+t[0],0)/u,y=s.reduce((e,t)=>e+Math.pow(t[0]-f,2),0),m=null!==(j=e.confidence)&&void 0!==j?j:.95,v=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,x=null!==(F=e.steps)&&void 0!==F?F:5,b=s[u-1][0],k=(b-s[0][0])/Math.max(u-1,1),w=[];for(let e=1;x>=e;e++)w.push(b+e*k);const E=[];for(const e of w){const t=c(e),n=h*Math.sqrt(1+1/u+(y>0?Math.pow(e-f,2)/y:0))*v;E.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const A=`M${E.map(e=>`${l(e.x)},${a(e.yUpper)}`).join(" L")} L${E.slice().reverse().map(e=>`${l(e.x)},${a(e.yLower)}`).join(" L")} Z`,M=E.map(e=>`${l(e.x)},${a(e.yCenter)}`).join(" "),S=`${l(b)},${a(c(b))}`,P=e.strokeColor||"#6366f1";return g.createElement("g",{key:"ann-"+t},g.createElement("path",{d:A,fill:e.fill||"#6366f1",fillOpacity:null!==(Y=e.fillOpacity)&&void 0!==Y?Y:.15,stroke:"none"}),g.createElement("polyline",{points:`${S} ${M}`,fill:"none",stroke:P,strokeWidth:null!==(H=e.strokeWidth)&&void 0!==H?H:2,strokeDasharray:null!==(X=e.strokeDasharray)&&void 0!==X?X:"6,3"}),e.label&&E.length>0&&g.createElement("text",{x:l(E[E.length-1].x)+4,y:a(E[E.length-1].yCenter)-4,fill:P,fontSize:11},e.label))}case"widget":{let r=null,o=null;if(null!=e.px&&null!=e.py)r=e.px,o=e.py;else{const i=Ce(e,t,n);if(!i)return null;r=i.x,o=i.y}if(null==r||null==o)return null;if(!De(r,o,n))return null;const i=null!==(G=e.dx)&&void 0!==G?G:0,l=null!==(V=e.dy)&&void 0!==V?V:0,a=null!==(q=e.width)&&void 0!==q?q:32,s=null!==(U=e.height)&&void 0!==U?U:32,c=null!==(K=e.content)&&void 0!==K?K:g.createElement("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info"},"ℹ️");return g.createElement("foreignObject",{key:"ann-"+t,x:r+i-a/2,y:o+l-s/2,width:a,height:s,style:{overflow:"visible",pointerEvents:"auto"}},g.createElement("div",{style:{width:a,height:s,display:"flex",alignItems:"center",justifyContent:"center"}},c))}case"text":{const r=Ce(e,t,n);if(!r)return null;const{x:o,y:i}=r;return g.createElement("text",{key:"ann-text-"+t,x:o+(e.dx||0),y:i+(e.dy||0),fill:e.color||"var(--semiotic-text, #333)",fontSize:e.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},e.label)}case"category-highlight":{const r=e.category;if(null==r)return null;const o=null===(Z=n.scales)||void 0===Z?void 0:Z.o,i=null===(Q=n.scales)||void 0===Q?void 0:Q.x,l=null===(J=n.scales)||void 0===J?void 0:J.y,a=(null==o?void 0:o.bandwidth)?o:(null==i?void 0:i.bandwidth)?i:(null==l?void 0:l.bandwidth)?l:null;if(!a)return null;const s=a(r);if(null==s)return null;const c=a.bandwidth(),u=e.color||"var(--semiotic-primary, #4589ff)",d=null!==(ee=e.opacity)&&void 0!==ee?ee:.15,h=e.label;return(n.projection?"vertical"===n.projection:a===i)?g.createElement("g",{key:"ann-"+t},g.createElement("rect",{x:s,y:0,width:c,height:n.height||0,fill:u,fillOpacity:d}),h&&g.createElement("text",{x:s+c/2,y:12,textAnchor:"middle",fill:u,fontSize:12,fontWeight:"bold"},h)):g.createElement("g",{key:"ann-"+t},g.createElement("rect",{x:0,y:s,width:n.width||0,height:c,fill:u,fillOpacity:d}),h&&g.createElement("text",{x:12,y:s+c/2,dominantBaseline:"middle",fill:u,fontSize:12,fontWeight:"bold"},h))}default:return null}},t={scales:d?{x:d.x,y:d.y,time:d.x,value:d.y}:null,timeAxis:"x",xAccessor:$,yAccessor:W,width:o,height:i,data:I,frameType:"xy",pointNodes:z,curve:R,stickyPositionCache:V.current};return N.map((n,r)=>{if(O){const o=O(n,r,t);return null!=o?o:e(n,r,t)}return e(n,r,t)}).filter(Boolean)},[N,O,o,i,$,W,I,d,z,R]),Q=function(t){var n;const r=e.useSyncExternalStore(t?ze:Be,t?Ie:je,t?Ie:je);return t&&null!==(n=r.positions.get(t))&&void 0!==n?n:null}(j);return e.useEffect(()=>{if(!(null==Q?void 0:Q.locked)||!j)return;const e=e=>{"Escape"===e.key&&We(j)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[null==Q?void 0:Q.locked,j]),h||w||E||C||D||Z&&Z.length>0||k||Y||Q?g.createElement("svg",{role:"img",width:l,height:c,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"}},g.createElement("title",null,"string"==typeof w?w:"XY Chart"),g.createElement("desc",null,"string"==typeof w?w+" — XY data visualization":"XY data visualization"),g.createElement("g",{transform:`translate(${u.left},${u.top})`},k&&d&&!B&&(()=>{var e,t;const n=Fe(null===(e=null==f?void 0:f.find(e=>"bottom"===e.orient))||void 0===e?void 0:e.gridStyle),r=Fe(null===(t=null==f?void 0:f.find(e=>"left"===e.orient))||void 0===t?void 0:t.gridStyle);return g.createElement("g",{className:"stream-grid"},H.map((e,t)=>g.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:n})),X.map((e,t)=>g.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:o,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r})))})(),h&&d&&(()=>{const e=null==f?void 0:f.find(e=>"left"===e.orient),t=null==f?void 0:f.find(e=>"bottom"===e.orient),n=!e||!1!==e.baseline,r=!t||!1!==t.baseline,l=(null==e?void 0:e.jaggedBase)||!1,a=(null==t?void 0:t.jaggedBase)||!1,s=null==t?void 0:t.landmarkTicks,c=null==e?void 0:e.landmarkTicks,d="var(--semiotic-border, #ccc)",h="var(--semiotic-text-secondary, var(--semiotic-text, #666))",p="var(--semiotic-text, #333)",x=!!(null==t?void 0:t.autoRotate)&&H.length>1&&(()=>{const e=o/Math.max(H.length-1,1);return H.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})();return g.createElement("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},!B&&r&&!a&&g.createElement("line",{x1:0,y1:i,x2:o,y2:i,stroke:d,strokeWidth:1}),!B&&a&&g.createElement("path",{d:Ye("bottom",o,i),fill:"none",stroke:d,strokeWidth:1}),H.map((e,t)=>{const n=!!s&&("function"==typeof s?s(e.value,t):U(e.value,t>0?H[t-1].value:void 0));return g.createElement("g",{key:"xtick-"+t,transform:`translate(${e.pixel},${i})`},g.createElement("line",{y2:5,stroke:d,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?g.createElement("text",{y:x?10:18,textAnchor:x?"end":"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:h,style:{userSelect:"none"},transform:x?"rotate(-45)":void 0},e.label):g.createElement("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"}},g.createElement("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"}},e.label)))}),y&&g.createElement("text",{x:o/2,y:i+40,textAnchor:"middle",fontSize:12,fill:p,style:{userSelect:"none"}},y),!B&&n&&!l&&g.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:d,strokeWidth:1}),!B&&l&&g.createElement("path",{d:Ye("left",o,i),fill:"none",stroke:d,strokeWidth:1}),X.map((e,t)=>{const n=!!c&&("function"==typeof c?c(e.value,t):U(e.value,t>0?X[t-1].value:void 0));return g.createElement("g",{key:"ytick-"+t,transform:`translate(0,${e.pixel})`},g.createElement("line",{x2:-5,stroke:d,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?g.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:h,style:{userSelect:"none"}},e.label):g.createElement("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"}},g.createElement("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"}},e.label)))}),(()=>{const t=(null==e?void 0:e.label)||m;return t?g.createElement("text",{x:15-u.left,y:i/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(-90, ${15-u.left}, ${i/2})`,style:{userSelect:"none"}},t):null})(),(()=>{const e=null==f?void 0:f.find(e=>"right"===e.orient);if(!e||0===G.length)return null;const t=e.landmarkTicks,n=e.label||v;return g.createElement(g.Fragment,null,!1!==e.baseline&&g.createElement("line",{x1:o,y1:0,x2:o,y2:i,stroke:d,strokeWidth:1}),G.map((e,n)=>{const r=!!t&&("function"==typeof t?t(e.value,n):U(e.value,n>0?G[n-1].value:void 0));return g.createElement("g",{key:"ytick-r-"+n,transform:`translate(${o},${e.pixel})`},g.createElement("line",{x2:5,stroke:d,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?g.createElement("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:r?11:10,fontWeight:r?600:400,fill:h,style:{userSelect:"none"}},e.label):g.createElement("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"}},g.createElement("div",{style:{textAlign:"left",fontSize:10,userSelect:"none"}},e.label)))}),n&&g.createElement("text",{x:o+u.right-15,y:i/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(90, ${o+u.right-15}, ${i/2})`,style:{userSelect:"none"}},n))})())})(),Z,D&&d&&L&&T&&g.createElement(g.Fragment,null,D.top&&g.createElement("g",{transform:"translate(0, 0)"},g.createElement(we,{orient:"top",config:ke(D.top),values:L,scale:d.x,size:u.top,length:o})),D.bottom&&g.createElement("g",{transform:`translate(0, ${i})`},g.createElement(we,{orient:"bottom",config:ke(D.bottom),values:L,scale:d.x,size:u.bottom,length:o})),D.left&&g.createElement("g",{transform:"translate(0, 0)"},g.createElement(we,{orient:"left",config:ke(D.left),values:T,scale:d.y,size:u.left,length:i})),D.right&&g.createElement("g",{transform:`translate(${o}, 0)`},g.createElement(we,{orient:"right",config:ke(D.right),values:T,scale:d.y,size:u.right,length:i}))),C,Q&&Q.sourceId!==F&&(null==d?void 0:d.x)&&(()=>{const e=d.x(Q.xValue);if(null==e||0>e||e>o)return null;const t=Q.locked;return g.createElement("line",{x1:e,y1:0,x2:e,y2:i,stroke:t?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:t?1.5:1,strokeDasharray:t?"6,3":"4,4",pointerEvents:"none"})})(),Y),w&&g.createElement("text",{x:l/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof w?w:null),be({legend:E,totalWidth:l,totalHeight:c,margin:u,legendPosition:_,title:w,legendHoverBehavior:A,legendClickBehavior:M,legendHighlightedCategory:S,legendIsolatedCategories:P})):null}function qe(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}const Ue="undefined"==typeof window||"undefined"==typeof document,Ke=g.createContext(null);function Ze(){return g.useContext(Ke)}const Qe={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Je(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e)n[t.type]=(n[t.type]||0)+1;const r=[],o={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},i=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],l=Object.keys(n).sort((e,t)=>{const n=i.indexOf(e),r=i.indexOf(t);return(-1===n?999:n)-(-1===r?999:r)});for(const e of l)r.push(`${n[e]} ${o[e]||e}`);return`${t}, ${r.join(", ")}`}function et(e,t,n){const r=[];return e>0&&r.push(e+" nodes"),t>0&&r.push(t+" edges"),0===r.length?n+", empty":`${n}, ${r.join(", ")}`}const tt=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},nt={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},rt={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},ot={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},it={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},lt={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},at={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},st={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function ct({scene:e,chartType:t,tableId:n,chartTitle:r}){var o;const[i,l]=g.useState(!1),a=Ze(),s=null!==(o=null==a?void 0:a.visible)&&void 0!==o&&o,c=i||s,u=g.useRef(null),d=r?"Data summary for "+r:n?`Data summary for ${t} ${n}`:"Data summary for "+t,h=g.useCallback(()=>{i||s||l(!0)},[i,s]),f=g.useCallback(e=>{var t;s||(null===(t=u.current)||void 0===t?void 0:t.contains(e.relatedTarget))||l(!1)},[s]);if(!e||0===e.length)return n?g.createElement("span",{id:n,tabIndex:-1,style:Qe}):null;if(!c)return g.createElement("div",{id:n,tabIndex:-1,onFocus:h,style:Qe,role:"region","aria-label":d},g.createElement("button",{type:"button",onClick:()=>l(!0)},"View data summary (",e.length," elements)"));const y=function(e){var t,n,r,o,i,l,a,s,c,u,d,h,f,y,g,p,m,v,x,b,k,w,E,A,M;const S=[];if(!Array.isArray(e))return S;for(const P of e)if(P&&"object"==typeof P)try{switch(P.type){case"point":S.push({label:"Point",values:{x:P.x,y:P.y}});break;case"line":{const e=P.path,t=Array.isArray(P.datum)?P.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&S.push({label:"Line point",values:{x:t[0],y:t[1]}})}break}case"area":{const e=P.topPath,t=Array.isArray(P.datum)?P.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&S.push({label:"Area point",values:{x:t[0],y:t[1]}})}break}case"rect":{const e=null!=P.datum&&"object"==typeof P.datum?P.datum:{},i=null!==(n=null!==(t=e.category)&&void 0!==t?t:P.group)&&void 0!==n?n:"",l=null!==(o=null!==(r=e.value)&&void 0!==r?r:e.__aggregateValue)&&void 0!==o?o:e.total;S.push({label:"Bar",values:{category:i,value:null!=l?l:""}});break}case"heatcell":S.push({label:"Cell",values:{x:P.x,y:P.y,value:P.value}});break;case"wedge":S.push({label:"Wedge",values:{category:null!==(s=null!==(l=null===(i=P.datum)||void 0===i?void 0:i.category)&&void 0!==l?l:null===(a=P.datum)||void 0===a?void 0:a.label)&&void 0!==s?s:"",value:null!==(u=null===(c=P.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":S.push({label:"Node",values:{id:null!==(h=null===(d=P.datum)||void 0===d?void 0:d.id)&&void 0!==h?h:"",x:null!==(f=P.cx)&&void 0!==f?f:P.x,y:null!==(y=P.cy)&&void 0!==y?y:P.y}});break;case"arc":S.push({label:"Arc",values:{id:null!==(p=null===(g=P.datum)||void 0===g?void 0:g.id)&&void 0!==p?p:"",x:null!==(m=P.cx)&&void 0!==m?m:P.x,y:null!==(v=P.cy)&&void 0!==v?v:P.y}});break;case"candlestick":S.push({label:"Candlestick",values:{x:P.x,open:P.open,high:P.high,low:P.low,close:P.close}});break;case"geoarea":S.push({label:"Region",values:{name:null!==(E=null!==(k=null===(b=null===(x=P.datum)||void 0===x?void 0:x.properties)||void 0===b?void 0:b.name)&&void 0!==k?k:null===(w=P.datum)||void 0===w?void 0:w.name)&&void 0!==E?E:"",value:null!==(M=null===(A=P.datum)||void 0===A?void 0:A.value)&&void 0!==M?M:""}})}}catch(e){}return S}(e),p=function(e){if(!e||0===e.length)return[];const t=new Set;for(const n of e)if(n&&n.values)for(const e of Object.keys(n.values))t.add(e);const n=[];for(const r of t){const t=[],o=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[r];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&o.add(e+""))}if(t.length>0){let e=t[0],o=t[0],i=0;for(const n of t)e>n&&(e=n),n>o&&(o=n),i+=n;n.push({name:r,count:t.length,numeric:!0,min:e,max:o,mean:i/t.length})}else if(o.size>0){const e=Array.from(o);n.push({name:r,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(y),m=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${tt(e.min)} to ${tt(e.max)}, mean ${tt(e.mean)}.`);else{const t=e.uniqueValues,r=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${r}.`)}return n.join(" ")}(y.length,p),v=y.slice(0,5),x=new Set;for(const e of v)for(const t of Object.keys(e.values))x.add(t);const b=Array.from(x);return g.createElement("div",{ref:u,id:n,tabIndex:-1,onBlur:f,style:nt,role:"region","aria-label":d},g.createElement("button",{type:"button",onClick:()=>{s&&a&&a.setVisible(!1),l(!1)},"aria-label":"Close data summary",style:ot},"×"),g.createElement("div",{role:"note",style:rt},m),g.createElement("table",{role:"table","aria-label":"Sample data for "+t,style:it},g.createElement("caption",{style:st},"First ",v.length," of ",y.length," data points"),g.createElement("thead",null,g.createElement("tr",null,g.createElement("th",{style:lt},"type"),b.map(e=>g.createElement("th",{key:e,style:lt},e)))),g.createElement("tbody",null,v.map((e,t)=>g.createElement("tr",{key:t},g.createElement("td",{style:at},e.label),b.map(t=>{return g.createElement("td",{key:t,style:at},null==(n=e.values[t])||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":tt(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"");var n}))))))}function ut({nodes:e,edges:t,chartType:n,tableId:r,chartTitle:o}){var i,l,a,s,c,u,d,h,f,y,p,m,v,x;const[b,k]=g.useState(!1),w=Ze(),E=null!==(i=null==w?void 0:w.visible)&&void 0!==i&&i,A=b||E,M=o?"Data summary for "+o:r?`Data summary for ${n} ${r}`:"Data summary for "+n,S=g.useRef(null),P=g.useCallback(()=>{b||E||k(!0)},[b,E]),_=g.useCallback(e=>{var t;E||(null===(t=S.current)||void 0===t?void 0:t.contains(e.relatedTarget))||k(!1)},[E]);if(!e||0===e.length)return r?g.createElement("span",{id:r,tabIndex:-1,style:Qe}):null;if(!A)return g.createElement("div",{id:r,tabIndex:-1,onFocus:P,style:Qe,role:"region","aria-label":M},g.createElement("button",{type:"button",onClick:()=>k(!0)},"View data summary (",e.length," nodes, ",t.length," edges)"));const C=Array.isArray(e)?e:[],D=Array.isArray(t)?t:[],L=new Map,T=new Map,N=new Map,O=new Map;for(const e of D){if(!e||"object"!=typeof e)continue;const t=null!==(l=e.datum)&&void 0!==l?l:e,n="object"==typeof t.source?null===(a=t.source)||void 0===a?void 0:a.id:t.source,r="object"==typeof t.target?null===(s=t.target)||void 0===s?void 0:s.id:t.target,o="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=n&&""!==n){const e=n+"";T.set(e,(null!==(c=T.get(e))&&void 0!==c?c:0)+1),O.set(e,(null!==(u=O.get(e))&&void 0!==u?u:0)+o)}if(null!=r&&""!==r){const e=r+"";L.set(e,(null!==(d=L.get(e))&&void 0!==d?d:0)+1),N.set(e,(null!==(h=N.get(e))&&void 0!==h?h:0)+o)}}const $=[];for(let e=0;C.length>e;e++){const t=C[e];if(!t||"object"!=typeof t)continue;const n=null!==(y=null===(f=t.datum)||void 0===f?void 0:f.id)&&void 0!==y?y:t.id,r=null!=n?n+"":"node-"+e,o=null!==(p=L.get(r))&&void 0!==p?p:0,i=null!==(m=T.get(r))&&void 0!==m?m:0,l=null!==(v=N.get(r))&&void 0!==v?v:0,a=null!==(x=O.get(r))&&void 0!==x?x:0;$.push({id:r,degree:o+i,inDeg:o,outDeg:i,wDegree:l+a,wInDeg:l,wOutDeg:a})}$.sort((e,t)=>t.degree-e.degree);let W=0,I=0;if($.length>0){let e=0;for(const t of $)e+=t.degree,t.degree>I&&(I=t.degree);W=e/$.length}const z=D.some(e=>{var t;const n=null!==(t=null==e?void 0:e.datum)&&void 0!==t?t:e;return"number"==typeof(null==n?void 0:n.value)&&Number.isFinite(n.value)}),R=[`${$.length} nodes, ${D.length} edges.`];$.length>0&&R.push(`Mean degree: ${tt(W)}, max degree: ${I}.`);const B=$.slice(0,5);return g.createElement("div",{ref:S,id:r,tabIndex:-1,onBlur:_,style:nt,role:"region","aria-label":M},g.createElement("button",{type:"button",onClick:()=>{E&&w&&w.setVisible(!1),k(!1)},"aria-label":"Close data summary",style:ot},"×"),g.createElement("div",{role:"note",style:rt},R.join(" ")),g.createElement("table",{role:"table","aria-label":"Node degree summary for "+n,style:it},g.createElement("caption",{style:st},"Top ",B.length," of ",$.length," nodes by degree"),g.createElement("thead",null,g.createElement("tr",null,g.createElement("th",{style:lt},"id"),g.createElement("th",{style:lt},"degree"),g.createElement("th",{style:lt},"in"),g.createElement("th",{style:lt},"out"),z&&g.createElement("th",{style:lt},"w. degree"),z&&g.createElement("th",{style:lt},"w. in"),z&&g.createElement("th",{style:lt},"w. out"))),g.createElement("tbody",null,B.map((e,t)=>g.createElement("tr",{key:t},g.createElement("td",{style:at},e.id),g.createElement("td",{style:at},e.degree),g.createElement("td",{style:at},e.inDeg),g.createElement("td",{style:at},e.outDeg),z&&g.createElement("td",{style:at},tt(e.wDegree)),z&&g.createElement("td",{style:at},tt(e.wInDeg)),z&&g.createElement("td",{style:at},tt(e.wOutDeg)))))))}function dt({summary:e}){return e?g.createElement("div",{role:"note",style:Qe},e):null}function ht({tableId:e}){return g.createElement("a",{href:"#"+e,style:Qe,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,Qe)}},"Skip to data table")}function ft({hoverPoint:e}){let t="";if(e){const n=e.data||e;t="object"==typeof n?"Focused on data point: "+Object.entries(n).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Focused on data point: "+n}return g.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:Qe},t)}const yt="var(--semiotic-focus, #005fcc)";function gt({active:e,hoverPoint:t,margin:n,size:r,shape:o="circle",width:i,height:l}){if(!e||!t)return null;const a=t.x+n.left,s=t.y+n.top;let c;if("rect"===o&&null!=i&&null!=l){const e=Math.max(i,4),t=Math.max(l,4);c=g.createElement("rect",{x:a-e/2-3,y:s-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:yt,strokeWidth:2,strokeDasharray:"4,2"})}else c=g.createElement("circle","wedge"===o?{cx:a,cy:s,r:12,fill:"none",stroke:yt,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:a,cy:s,r:8,fill:"none",stroke:yt,strokeWidth:2,strokeDasharray:"4,2"});return g.createElement("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true"},c)}function pt({x:e,y:t,containerWidth:n,containerHeight:r,margin:o,children:i,className:l="stream-frame-tooltip",zIndex:a=1}){const s=g.useRef(null),[c,u]=g.useState(null);g.useLayoutEffect(()=>{const e=s.current;if(!e)return;const t=e.getBoundingClientRect();u(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[i,l,n,r]);let d;return d=c?`translate(${c.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${c.height+12>r-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*r>t?"4px":"calc(-100% - 4px)"})`,g.createElement("div",{ref:s,className:l,style:{position:"absolute",left:o.left+e,top:o.top+t,transform:d,pointerEvents:"none",zIndex:a,width:"max-content"}},i)}function mt(){const[t,n]=e.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return e.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return n(e.matches),function(e,t){return"function"==typeof e.addEventListener?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))}(e,e=>n(e.matches))},[]),t}function vt(t){const n=e.createContext(null),r=xt(t);return[function({children:r}){const o=e.useMemo(()=>xt(t),[]);return g.createElement(n.Provider,{value:o,children:r})},t=>{var o;const i=null!==(o=e.useContext(n))&&void 0!==o?o:r,l=e.useRef(t);l.current=t;const a=e.useCallback(()=>l.current(i.getState()),[i]),s=e.useCallback(()=>l.current(i.getState()),[i]);return e.useSyncExternalStore(i.subscribe,a,s)}]}function xt(e){const t=new EventTarget;let n=e(function(e){n=Object.assign(Object.assign({},n),e(n)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}const bt={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},kt={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},wt={mode:"light",colors:{primary:"#0000cc",categorical:["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],sequential:"blues",diverging:"RdBu",background:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"},[Et,At]=vt(e=>({theme:bt,setTheme(t){e(e=>{if("light"===t)return{theme:bt};if("dark"===t)return{theme:kt};if("high-contrast"===t)return{theme:wt};if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?kt:bt;return{theme:Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{})})}}return{theme:Object.assign(Object.assign(Object.assign({},e.theme),t),{colors:Object.assign(Object.assign({},e.theme.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.theme.typography),t.typography||{})})}})}}));function Mt(e,t,n,r){const o=e.getContext("2d");if(!o)return null;const i=t[0]*r,l=t[1]*r,a=t[0]+"px",s=t[1]+"px";return e.style.width!==a&&(e.style.width=a),e.style.height!==s&&(e.style.height=s),e.width===i&&e.height===l||(e.width=i,e.height=l),o.setTransform(r,0,0,r,0,0),o.translate(n.left,n.top),o}function St(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function Pt(e){switch(e){case"monotoneX":return s.curveMonotoneX;case"monotoneY":return s.curveMonotoneY;case"cardinal":return s.curveCardinal;case"catmullRom":return s.curveCatmullRom;case"step":return s.curveStep;case"stepBefore":return s.curveStepBefore;case"stepAfter":return s.curveStepAfter;case"basis":return s.curveBasis;case"natural":return s.curveNatural;default:return null}}function _t(e,t,n){let r=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(r=n.color):e>n.value&&(r=n.color);return r}function Ct(e,t,n,r,o,i){if(2>t.length)return;const l=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],r=t[e][1]-t[e-1][1];l.push(l[e-1]+Math.sqrt(n*n+r*r))}const a=l[l.length-1];if(0===a)return;const s=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=r,e.lineCap=i;for(let n=0;t.length-1>n;n++){const r=(l[n]+l[n+1])/2;let i=o;s>r&&(i*=r/s),s>a-r&&(i*=(a-r)/s),e.globalAlpha=Math.max(0,i),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}const Dt=(e,t,n,r)=>{var o,i;const l=t.filter(e=>"line"===e.type);for(const a of l){if(2>a.path.length)continue;const c=a.style.stroke||"#007bff",u=a.style.strokeWidth||2,d=a.colorThresholds,h=a.rawValues;if(e.setLineDash(a.style.strokeDasharray?a.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=a.style.opacity&&(e.globalAlpha=a.style.opacity),e.lineWidth=u,e.lineCap=a.style.strokeLinecap||"butt",a.style._edgeFade){const p=null!==(o=a.style.opacity)&&void 0!==o?o:1;Ct(e,a.path,c,u,p,a.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const f=Pt(a.curve),y=d&&d.length>0&&h&&h.length===a.path.length,g=a._decayOpacities;if(g&&g.length===a.path.length&&!y){e.strokeStyle=c;const m=null!==(i=a.style.opacity)&&void 0!==i?i:1;for(let v=0;a.path.length-1>v;v++)e.globalAlpha=.5*(g[v]+g[v+1])*m,e.beginPath(),e.moveTo(a.path[v][0],a.path[v][1]),e.lineTo(a.path[v+1][0],a.path[v+1][1]),e.stroke()}else if(y){let x=null,b=null,k=null,w=null,E=!1;function A(t,n,r){e.beginPath(),e.strokeStyle=t,e.moveTo(n,r),E=!0}function M(){E&&(e.stroke(),E=!1)}for(let S=0;a.path.length>S;S++){const[P,_]=a.path[S],C=h[S],D=_t(C,d,c);if(null!==x&&null!==w&&null!==k){if(D===w)e.lineTo(P,_);else{const L=[];for(const T of d){const N=T.value;(k>N||N>C)&&(N>k||C>N)||k===N||C===N||L.push({t:(N-k)/(C-k)})}L.sort((e,t)=>e.t-t.t);for(const O of L){const $=x+(P-x)*O.t,W=b+(_-b)*O.t,I=_t(k+(C-k)*Math.min(O.t+1e-4,1),d,c);e.lineTo($,W),M(),A(I,$,W)}e.lineTo(P,_)}x=P,b=_,k=C,w=D}else A(D,P,_),x=P,b=_,k=C,w=D}M()}else{if(e.beginPath(),!a.strokeGradient||2>a.strokeGradient.colorStops.length||2>a.path.length)e.strokeStyle=c;else{const z=e.createLinearGradient(a.path[0][0],0,a.path[a.path.length-1][0],0);for(const R of a.strokeGradient.colorStops)z.addColorStop(Math.max(0,Math.min(1,R.offset)),R.color);e.strokeStyle=z}if(f)s.line().x(e=>e[0]).y(e=>e[1]).curve(f).context(e)(a.path);else{const[B,j]=a.path[0];e.moveTo(B,j);for(let F=1;a.path.length>F;F++)e.lineTo(a.path[F][0],a.path[F][1])}e.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=a.style.fillOpacity,e.fillStyle=a.style.fill,f&&!y)s.line().x(e=>e[0]).y(e=>e[1]).curve(f).context(e)(a.path);else{const[H,X]=a.path[0];e.moveTo(H,X);for(let G=1;a.path.length>G;G++)e.lineTo(a.path[G][0],a.path[G][1])}const Y=a.path[0][0];e.lineTo(a.path[a.path.length-1][0],r.height),e.lineTo(Y,r.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function Lt(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Tt(e,t,n=.3){Lt(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function Nt(e,t,n=.6){var r,o,i,l,a;if(!Lt(t))return;const s=null!==(r=t._pulseGlowRadius)&&void 0!==r?r:4,c=t.r+s*t._pulseIntensity,u=null!==(i=null!==(o=t.cx)&&void 0!==o?o:t.x)&&void 0!==i?i:0,d=null!==(a=null!==(l=t.cy)&&void 0!==l?l:t.y)&&void 0!==a?a:0;e.beginPath(),e.arc(u,d,c,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function Ot(e,t,n,r=.35){Lt(t)&&(e.globalAlpha=t._pulseIntensity*r,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill())}function $t(e){switch(e){case"monotoneX":return s.curveMonotoneX;case"monotoneY":return s.curveMonotoneY;case"cardinal":return s.curveCardinal;case"catmullRom":return s.curveCatmullRom;case"step":return s.curveStep;case"stepBefore":return s.curveStepBefore;case"stepAfter":return s.curveStepAfter;case"basis":return s.curveBasis;case"natural":return s.curveNatural;default:return null}}function Wt(e){if(e.startsWith("#")){const t=4===e.length?e[1]+e[1]+e[2]+e[2]+e[3]+e[3]:e.slice(1,7);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[78,121,167]}function It(e,t){const n=$t(t.curve);if(!n||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath()}else{const r=s.area().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),r(t.topPath)}}const zt=(e,t,n,r)=>{var o,i,l;const a=t.filter(e=>"area"===e.type);for(const t of a){if(2>t.topPath.length)continue;const n=t.style.fill||"#4e79a7",r=t._decayOpacities;if(r&&r.length===t.topPath.length){const i=null!==(o=t.style.fillOpacity)&&void 0!==o?o:.7;e.fillStyle=n;for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(r[n]+r[n+1])*i,e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.lineTo(t.bottomPath[n+1][0],t.bottomPath[n+1][1]),e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(r[n]+r[n+1]),e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.stroke()}e.globalAlpha=1;continue}const a=null!==(i=t.style.opacity)&&void 0!==i?i:1;if(It(e,t),t.fillGradient&&("colorStops"in t.fillGradient&&t.fillGradient.colorStops.length>=2||"topOpacity"in t.fillGradient)&&t.fillGradient){let r=1/0;for(const e of t.topPath)r>e[1]&&(r=e[1]);let o=-1/0;for(const e of t.bottomPath)e[1]>o&&(o=e[1]);const i=e.createLinearGradient(0,r,0,o);if("colorStops"in t.fillGradient)for(const e of t.fillGradient.colorStops){const t=Math.max(0,Math.min(1,e.offset));isNaN(t)||i.addColorStop(t,e.color)}else if("topOpacity"in t.fillGradient){const e=Wt("string"==typeof n?n:"#4e79a7");i.addColorStop(0,`rgba(${e[0]},${e[1]},${e[2]},${t.fillGradient.topOpacity})`),i.addColorStop(1,`rgba(${e[0]},${e[1]},${e[2]},${t.fillGradient.bottomOpacity})`)}e.fillStyle=i,e.globalAlpha=a}else{const r=null!==(l=t.style.fillOpacity)&&void 0!==l?l:.7;e.globalAlpha=r*a,e.fillStyle=n}if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(It(e,t),Ot(e,t)),t.style.stroke&&"none"!==t.style.stroke){if(e.globalAlpha=a,!t.strokeGradient||2>t.strokeGradient.colorStops.length||2>t.topPath.length)e.strokeStyle=t.style.stroke;else{const n=e.createLinearGradient(t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0);for(const e of t.strokeGradient.colorStops)n.addColorStop(Math.max(0,Math.min(1,e.offset)),e.color);e.strokeStyle=n}e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const n=$t(t.curve);if(e.beginPath(),n)s.line().x(e=>e[0]).y(e=>e[1]).curve(n).context(e)(t.topPath);else{e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1])}e.stroke()}e.globalAlpha=1}},Rt=(e,t,n,r)=>{var o;const i=t.filter(e=>"point"===e.type);if(0!==i.length){e.save();try{for(const t of i){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(o=t.style.opacity)&&void 0!==o?o:t.style.fillOpacity;null!=n&&(e.globalAlpha=n),e.fillStyle=t.style.fill||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),Nt(e,t),e.globalAlpha=1}}finally{e.restore()}}},Bt=(e,t,n,r)=>{const o=t.filter(e=>"rect"===e.type);for(const t of o)null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon?jt(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))),Tt(e,t),e.globalAlpha=1};function jt(e,t){const n=t.style.icon,r=t.style.iconPadding||2,o=Math.min(t.w,t.h)-r;if(0>=o)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=o+r,l=t.x+(t.w-o)/2;for(let r=t.y+t.h-o;r>=t.y-o;r-=i)e.drawImage(n,l,r,o,o)}else{const i=o+r,l=t.y+(t.h-o)/2;for(let r=t.x;t.x+t.w>r;r+=i)e.drawImage(n,r,l,o,o)}e.restore()}function Ft(e){const[t,n,r]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*r>128?"#000":"#fff"}function Yt(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}const Ht=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Xt(e){const t=e[1]-e[0],n=3156e7;return 864e5>t?e=>{const t=new Date(e);return`${(t.getUTCHours()+"").padStart(2,"0")}:${(t.getUTCMinutes()+"").padStart(2,"0")}`}:n>t?e=>{const t=new Date(e);return`${Ht[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*n>t?e=>{const t=new Date(e);return`${Ht[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}const Gt={line:[zt,Dt,Rt],area:[zt,Rt],stackedarea:[zt,Rt],scatter:[Rt],bubble:[Rt],heatmap:[(e,t,n,r)=>{const o=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of o){const n=t.style;if(null!=(null==n?void 0:n.opacity)&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle="#fff",e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),Tt(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const n=t.valueFormat?t.valueFormat(t.value):Yt(t.value),r=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),o=t.x+t.w/2,i=t.y+t.h/2;e.fillStyle=Ft(t.fill),e.font=r+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,o,i)}}}finally{e.restore()}}],bar:[Bt],swarm:[Rt],waterfall:[(e,t,n,r)=>{var o,i,l;Bt(e,t);const a=t.filter(e=>"rect"===e.type);if(2>a.length)return;const s=a[0].datum,c=null==s?void 0:s._connectorStroke;if(c){e.save(),e.strokeStyle=c,e.lineWidth=null!==(o=null==s?void 0:s._connectorWidth)&&void 0!==o?o:1,e.setLineDash([]);for(let t=0;a.length-1>t;t++){const r=a[t],o=a[t+1];if(!(null===(i=r.datum)||void 0===i?void 0:i.cumEnd)||!(null===(l=o.datum)||void 0===l?void 0:l.baseline))continue;const s=n.y(r.datum.cumEnd),c=r.x+r.w,u=o.x;e.beginPath(),e.moveTo(c,s),e.lineTo(u,s),e.stroke()}e.restore()}}],candlestick:[(e,t,n,r)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const r=t._decayOpacity;if(null!=r&&1!==r&&(e.globalAlpha=r),e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=t.wickColor,e.lineWidth=t.wickWidth,e.stroke(),t.isRange){const n=Math.max(2*t.wickWidth,4);e.fillStyle=t.wickColor,e.beginPath(),e.arc(t.x,t.highY,n,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,n,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const n=Math.min(t.openY,t.closeY),r=Math.abs(t.openY-t.closeY),o=t.isUp?t.upColor:t.downColor;e.fillStyle=o,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(r,1)),e.strokeStyle=o,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(r,1))}e.restore()}}],mixed:[zt,Dt,Rt]},Vt={top:20,right:20,bottom:30,left:40},qt={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white"},Ut={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Kt({hover:e}){const t=e=>Number.isInteger(e)?e+"":e.toFixed(2);return g.createElement("div",{className:"semiotic-tooltip",style:Ut},g.createElement("div",{style:{fontWeight:600,marginBottom:2}},t(e.value)),g.createElement("div",{style:{opacity:.7,fontSize:11}},t(e.time)))}const Zt=e.forwardRef(function(t,n){var r,o,i,l,a,s,c,u,d,h,f;const{chartType:y,runtimeMode:p,data:m,chunkThreshold:v,chunkSize:k,xAccessor:w,yAccessor:E,colorAccessor:A,sizeAccessor:M,groupAccessor:S,lineDataAccessor:P,curve:_,normalize:C,binSize:D,valueAccessor:L,arrowOfTime:T="right",windowMode:N="sliding",windowSize:O=200,timeAccessor:$,xExtent:W,yExtent:I,extentPadding:z=.1,scalePadding:R,sizeRange:B,size:j=[500,300],responsiveWidth:F,responsiveHeight:Y,margin:H,className:G,background:V,lineStyle:q,pointStyle:U,areaStyle:K,waterfallStyle:J,swarmStyle:ee,barColors:te,colorScheme:ne,boundsAccessor:re,boundsStyle:oe,y0Accessor:ie,gradientFill:ue,lineGradient:ye,areaGroups:ge,openAccessor:pe,highAccessor:me,lowAccessor:ve,closeAccessor:xe,candlestickStyle:be,showAxes:ke=!0,axes:we,xLabel:Ee,yLabel:Ae,yLabelRight:Me,xFormat:Se,yFormat:Pe,tickFormatTime:_e,tickFormatValue:Ce,hoverAnnotation:De,tooltipContent:Le,customHoverBehavior:Te,customClickBehavior:Ne,enableHover:Oe,hoverRadius:$e=30,tooltipMode:We,annotations:Ie,svgAnnotationRules:ze,showGrid:Re,legend:Be,legendHoverBehavior:je,legendClickBehavior:Fe,legendHighlightedCategory:Ye,legendIsolatedCategories:Xe,legendPosition:Ge,backgroundGraphics:Ke,foregroundGraphics:Ze,canvasPreRenderers:Qe,svgPreRenderers:et,title:tt,categoryAccessor:nt,brush:rt,onBrush:ot,decay:it,pulse:lt,transition:at,staleness:st,heatmapAggregation:ut,heatmapXBins:yt,heatmapYBins:vt,showValues:xt,heatmapValueFormat:bt,marginalGraphics:kt,pointIdAccessor:wt,xScaleType:Et,yScaleType:Pt,accessibleTable:_t=!0,description:Ct,summary:Dt,linkedCrosshairName:Lt,linkedCrosshairSourceId:Tt}=t,Nt=mt(),Ot=e.useRef(Nt);Ot.current=Nt;const[$t,Wt]=he(j,F,Y),It=Object.assign(Object.assign({},Vt),H);if(kt){const e=60;kt.top&&e>It.top&&(It.top=e),kt.bottom&&e>It.bottom&&(It.bottom=e),kt.left&&e>It.left&&(It.left=e),kt.right&&e>It.right&&(It.right=e)}const zt=Wt[0]-It.left-It.right,Rt=Wt[1]-It.top-It.bottom,Bt="function"==typeof Ze?Ze({size:Wt,margin:It}):Ze,jt="function"==typeof Ke?Ke({size:Wt,margin:It}):Ke,Ft=null!=De?De:Oe,Yt=e.useRef(null),Ht=e.useRef(null),Ut=e.useRef(0),Zt=e.useRef(!1),Qt=At(e=>e.theme),[Jt,en]=e.useState(0),[tn,nn]=e.useState(null),rn=e.useRef(null),on=e.useRef(null),[ln,an]=e.useState(null),[sn,cn]=e.useState(!1),[un,dn]=e.useState([]),[hn,fn]=e.useState([]),yn=e.useRef(()=>{}),gn="streaming"===p||["bar","swarm","waterfall"].includes(y),pn=e.useMemo(()=>({chartType:y,runtimeMode:gn?"streaming":"bounded",windowSize:O,windowMode:N,arrowOfTime:gn?T:"right",extentPadding:z,scalePadding:R,xAccessor:gn?void 0:w,yAccessor:gn?void 0:E,timeAccessor:gn?$:void 0,valueAccessor:L,colorAccessor:A,sizeAccessor:M,groupAccessor:S||(P?"_lineGroup":void 0),categoryAccessor:nt,lineDataAccessor:P,xScaleType:Et,yScaleType:Pt,xExtent:W,yExtent:I,sizeRange:B,binSize:D,normalize:C,boundsAccessor:re,boundsStyle:oe,y0Accessor:ie,gradientFill:!0===ue?{topOpacity:.8,bottomOpacity:.05}:!1===ue?void 0:ue,areaGroups:ge?new Set(ge):void 0,lineGradient:ye,openAccessor:pe,highAccessor:me,lowAccessor:ve,closeAccessor:xe,candlestickStyle:be,lineStyle:q,pointStyle:U,areaStyle:K,swarmStyle:ee,waterfallStyle:J,colorScheme:ne,barColors:te,annotations:Ie,decay:it,pulse:lt,transition:at,staleness:st,heatmapAggregation:ut,heatmapXBins:yt,heatmapYBins:vt,showValues:xt,heatmapValueFormat:bt,pointIdAccessor:wt,curve:_}),[y,O,N,T,z,R,w,E,$,L,Et,Pt,A,M,S,nt,P,W,I,B,D,C,re,oe,ie,ue,ye,ge,pe,me,ve,xe,be,q,U,K,ee,J,ne,te,Ie,it,lt,at,st,ut,yt,vt,xt,bt,gn,wt,_]),mn=e.useRef(null);mn.current||(mn.current=new X(pn));const vn=e.useCallback(()=>{Ut.current||(Ut.current=requestAnimationFrame(()=>yn.current()))},[]);e.useEffect(()=>{var e;null===(e=mn.current)||void 0===e||e.updateConfig(pn),Zt.current=!0,vn()},[pn,vn]),e.useEffect(()=>{Zt.current=!0,vn()},[Qt,vn]);const xn=e.useRef(null);xn.current||(xn.current=new b(e=>{const t=mn.current;t&&t.ingest(e)&&(Zt.current=!0,vn())},{chunkThreshold:v,chunkSize:k})),e.useEffect(()=>{var e;null===(e=xn.current)||void 0===e||e.updateChunkOptions({chunkThreshold:v,chunkSize:k})},[v,k]);const bn=e.useCallback(e=>{var t;null===(t=xn.current)||void 0===t||t.push(e)},[]),kn=e.useCallback(e=>{var t;null===(t=xn.current)||void 0===t||t.pushMany(e)},[]),wn=e.useCallback(()=>{var e,t;null===(e=xn.current)||void 0===e||e.clear(),null===(t=mn.current)||void 0===t||t.clear(),Zt.current=!0,vn()},[vn]);e.useImperativeHandle(n,()=>({push:bn,pushMany:kn,clear:wn,getData:()=>{var e,t,n;return null===(e=xn.current)||void 0===e||e.flush(),null!==(n=null===(t=mn.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var e,t;return null!==(t=null===(e=mn.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=mn.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[bn,kn,wn]),e.useEffect(()=>{var e,t;if(m){if(P&&m.length>0&&"object"==typeof m[0]&&null!==m[0]){const t="string"==typeof P?P:"coordinates";if(Array.isArray(m[0][t])){const n=[];for(const e of m){const r=e[t];if(Array.isArray(r)){const t=e.label||e.id||e.key;if(null!=t)for(const e of r)n.push(Object.assign(Object.assign({},e),{_lineGroup:t}));else for(const e of r)n.push(e)}}return void(null===(e=xn.current)||void 0===e||e.setBoundedData(n))}}null===(t=xn.current)||void 0===t||t.setBoundedData(m)}},[m,P]);const En=e.useRef(()=>{}),An=e.useRef(()=>{});En.current=e=>{if(!Ft)return;const t=Yt.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-It.left,o=e.clientY-n.top-It.top;if(0>r||r>zt||0>o||o>Rt)return void(rn.current&&(rn.current=null,on.current=null,an(null),Te&&(Te(null),Zt.current=!0),vn()));const i=mn.current;if(!i||0===i.scene.length)return;const l=Z(i.scene,r,o,$e,i.quadtree);if(!l)return void(rn.current&&(rn.current=null,on.current=null,an(null),Te&&Te(null),vn()));const a=l.datum||{},s=Object.assign(Object.assign({},"object"!=typeof a||null===a||Array.isArray(a)?{}:a),{data:a,time:l.x,value:l.y,x:l.x,y:l.y});if("multi"===We&&i.scene.length>0&&i.scales){const e=function(e,t,n=30){const r=[];for(const o of e)if("line"===o.type){const e=o;if(2>e.path.length)continue;const i=Q(e.path,t,n);if(null===i)continue;const l=le(e.path,t);r.push({node:o,datum:Array.isArray(e.datum)&&e.datum[l]?e.datum[l]:e.datum,x:e.path[l][0],y:i,group:e.group,color:e.style.stroke})}else if("area"===o.type){const e=o;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const i=Q(e.topPath,t,n);if(null===i)continue;const l=le(e.topPath,t);r.push({node:o,datum:Array.isArray(e.datum)&&e.datum[l]?e.datum[l]:e.datum,x:e.topPath[l][0],y:i,group:e.group,color:"string"==typeof e.style.stroke?e.style.stroke:"string"==typeof e.style.fill?e.style.fill:void 0})}return r}(i.scene,l.x,$e),t=i.scales.y.invert,n=i.scales.x.invert;if(e.length>0){const r=n?n(l.x):l.x;s.xValue=r,s.xPx=l.x,s.allSeries=e.map(e=>({group:e.group||"",value:t?t(e.y):e.y,valuePx:e.y,color:e.color||"#007bff",datum:e.datum}))}}rn.current=s,on.current=l.node,an(s),Te&&(Te(s),Zt.current=!0),vn()},An.current=()=>{rn.current&&(rn.current=null,on.current=null,an(null),Te&&(Te(null),Zt.current=!0),vn())},e.useCallback(e=>En.current(e),[]);const Mn=e.useCallback(()=>An.current(),[]),Sn=e.useRef(()=>{});Sn.current=e=>{if(!Ne)return;const t=Yt.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-It.left,o=e.clientY-n.top-It.top;if(0>r||r>zt||0>o||o>Rt)return void Ne(null);const i=mn.current;if(!i||0===i.scene.length)return void Ne(null);const l=Z(i.scene,r,o,$e,i.quadtree);if(!l)return void Ne(null);const a=l.datum||{},s=Object.assign(Object.assign({},"object"!=typeof a||null===a||Array.isArray(a)?{}:a),{data:a,time:l.x,value:l.y,x:l.x,y:l.y});Ne(s)};const Pn=e.useCallback(e=>Sn.current(e),[]),_n=e.useRef(-1),Cn=e.useRef(null),Dn=e.useRef(null),Ln=e.useCallback(e=>{const t=mn.current;if(!t||0===t.scene.length)return;const n=t.version;let r;if(Dn.current&&Dn.current.version===n)r=Dn.current.graph;else{const e=function(e){var t,n,r,o;const i=[];for(const l of e)switch(l.type){case"point":i.push({x:l.x,y:l.y,datum:l.datum,shape:"circle",group:null!==(t=l.group)&&void 0!==t?t:"_default"});break;case"line":{const e=l,t=Array.isArray(e.datum)?e.datum:[],r=null!==(n=e.group)&&void 0!==n?n:"_default";for(let n=0;e.path.length>n&&t.length>n;n++)i.push({x:e.path[n][0],y:e.path[n][1],datum:t[n],shape:"circle",group:r});break}case"area":{const e=l,t=Array.isArray(e.datum)?e.datum:[],n=null!==(r=e.group)&&void 0!==r?r:"_default";for(let r=0;e.topPath.length>r&&t.length>r;r++)i.push({x:e.topPath[r][0],y:e.topPath[r][1],datum:t[r],shape:"circle",group:n});break}case"rect":i.push({x:l.x+l.w/2,y:l.y+l.h/2,datum:l.datum,shape:"rect",w:l.w,h:l.h,group:null!==(o=l.group)&&void 0!==o?o:"_default"});break;case"heatcell":i.push({x:l.x+l.w/2,y:l.y+l.h/2,datum:l.datum,shape:"rect",w:l.w,h:l.h,group:"_default"})}return i.sort((e,t)=>e.x-t.x||e.y-t.y),i}(t.scene);if(0===e.length)return;r=ae(e),Dn.current={version:n,graph:r}}const o=_n.current;if(0>o){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),_n.current=0;const t=r.flat[0];Cn.current={shape:t.shape,w:t.w,h:t.h};const n=de(t);return rn.current=n,an(n),Te&&Te(n),void vn()}const i=se(r,o),l=ce(e.key,i,r);if(null===l)return;if(e.preventDefault(),0>l)return _n.current=-1,Cn.current=null,rn.current=null,on.current=null,an(null),Te&&Te(null),void vn();_n.current=l;const a=r.flat[l];Cn.current={shape:a.shape,w:a.w,h:a.h};const s=de(a);rn.current=s,an(s),Te&&Te(s),vn()},[Te,vn]),Tn=e.useCallback(e=>{_n.current=-1,Cn.current=null,En.current(e)},[]);yn.current=()=>{var e,t;Ut.current=0;const n=Yt.current,r=Ht.current;if(!n||!r)return;const o=mn.current;if(!o)return;const i="undefined"!=typeof performance?performance.now():Date.now(),l=o.advanceTransition(Ot.current?i+1e6:i),a=!Ot.current&&l,s=Zt.current||l;s&&!a&&o.computeScene({width:zt,height:Rt});const c=St(),u=function(e){if(!e)return qt;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),r=t.getPropertyValue("--semiotic-text-secondary").trim(),o=t.getPropertyValue("--semiotic-bg").trim(),i=r||t.getPropertyValue("--text-secondary").trim(),l=t.getPropertyValue("--text-primary").trim(),a=n||t.getPropertyValue("--surface-3").trim(),s=o||t.getPropertyValue("--surface-0").trim();return i||l||n?{axisStroke:a||qt.axisStroke,tickText:i||qt.tickText,crosshair:i?i+"66":qt.crosshair,hoverFill:s?s+"4D":qt.hoverFill,hoverStroke:i?i+"99":qt.hoverStroke,pointRing:s||qt.pointRing}:qt}(n),d=null!==(e=null==st?void 0:st.threshold)&&void 0!==e?e:5e3,h=st&&o.lastIngestTime>0&&i-o.lastIngestTime>d;if(s){const e=Mt(n,Wt,It,c);if(e){e.clearRect(-It.left,-It.top,Wt[0],Wt[1]),h&&(e.globalAlpha=null!==(t=null==st?void 0:st.dimOpacity)&&void 0!==t?t:.5);const r=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=V||(r&&"transparent"!==r?r:null);if(i&&(e.fillStyle=i,e.fillRect(-It.left,-It.top,Wt[0],Wt[1])),e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,zt,Rt),e.clip()),Qe&&o.scales)for(const t of Qe)e.save(),t(e,o.scene,o.scales,{width:zt,height:Rt}),e.restore();const l=Gt[y];if(l&&o.scales)for(const t of l)t(e,o.scene,o.scales,{width:zt,height:Rt});e.restore(),h&&(e.globalAlpha=1)}}{const e=Mt(r,Wt,It,c);if(e&&(e.clearRect(-It.left,-It.top,Wt[0],Wt[1]),Ft&&rn.current&&o.scales&&function(e,t,n,r,o,i,l){var a,s;if(!1===o.crosshair)return;const c=t.allSeries,u=c&&c.length>0,d=null!==(a=t.xPx)&&void 0!==a?a:t.x;e.save();const h="object"==typeof o.crosshair?o.crosshair:{};if(e.strokeStyle=h.stroke||l.crosshair,e.lineWidth=h.strokeWidth||1,e.setLineDash(h.strokeDasharray?h.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(u?d:t.x,0),e.lineTo(u?d:t.x,r),e.stroke(),u||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke()),e.restore(),u){e.lineWidth=2,e.strokeStyle=l.pointRing;for(const t of c)null!=t.valuePx&&(e.beginPath(),e.arc(d,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||"#007bff",e.fill(),e.stroke())}else{let n="";try{(null===(s=e.canvas)||void 0===s?void 0:s.parentElement)&&(n=getComputedStyle(e.canvas).getPropertyValue("--semiotic-primary").trim())}catch(e){}const r=o.pointColor||function(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const n="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||n||null:n||t.stroke||null}(i)||n||"#007bff";e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=r,e.fill(),e.strokeStyle=l.pointRing,e.lineWidth=2,e.stroke()}}(e,rn.current,zt,Rt,"object"==typeof Ft?Ft:{},on.current,u),on.current&&Array.isArray(De))){const t=De.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,r){var o;if(!n)return;const i=n.group;if(void 0!==i)for(const n of t){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const t="function"==typeof r.style?r.style(n.datum):r.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||"#007bff",e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=null!==(o=t.opacity)&&void 0!==o?o:1,e.stroke(),e.restore()}}(e,o.scene,on.current,t)}}s&&n&&n.setAttribute("aria-label",Je(o.scene,y+" chart"));const f=Zt.current;if(Zt.current=!1,f&&o.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!tn||e(tn.x.domain()[0])!==e(o.scales.x.domain()[0])||e(tn.x.domain()[1])!==e(o.scales.x.domain()[1])||e(tn.y.domain()[0])!==e(o.scales.y.domain()[0])||e(tn.y.domain()[1])!==e(o.scales.y.domain()[1])||tn.x.range()[0]!==o.scales.x.range()[0]||tn.x.range()[1]!==o.scales.x.range()[1]||tn.y.range()[0]!==o.scales.y.range()[0]||tn.y.range()[1]!==o.scales.y.range()[1])&&nn(o.scales),kt){const e=o.getData(),t="function"==typeof w?w:e=>e[w||"x"],n="function"==typeof E?E:e=>e[E||"y"];dn(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),fn(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}f&&Ie&&Ie.length>0&&en(e=>e+1),(null==st?void 0:st.showBadge)&&cn(!!h),(a||o.hasActivePulses)&&(Ut.current=requestAnimationFrame(()=>yn.current()))},e.useEffect(()=>(vn(),()=>{Ut.current&&(cancelAnimationFrame(Ut.current),Ut.current=0)}),[vn]),e.useEffect(()=>{Zt.current=!0,vn()},[y,zt,Rt,ke,V,q,Qe,vn]),fe(st,mn,Zt,vn,sn,cn);const Nn=e.useMemo(()=>{if(Se||_e)return;const e=mn.current;return(null==e?void 0:e.xIsDate)&&tn?Xt(tn.x.domain()):void 0},[Se,_e,tn]),On=Se||_e||Nn,$n=Ft&&ln?Le?Le(ln):g.createElement(Kt,{hover:ln}):null,Wn=$n?g.createElement(pt,{x:ln.x,y:ln.y,containerWidth:zt,containerHeight:Rt,margin:It,className:"stream-frame-tooltip"},$n):null,In=Cn.current,zn=g.createElement(gt,{active:_n.current>=0,hoverPoint:ln,margin:It,size:Wt,shape:null==In?void 0:In.shape,width:null==In?void 0:In.w,height:null==In?void 0:In.h}),Rn=(e,t,n,r)=>"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:n,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:r,fn:t}:{key:void 0,fn:null},Bn=Rn(w,$,"__semiotic_resolvedX","__semiotic_resolvedTime"),jn=Rn(E,L,"__semiotic_resolvedY","__semiotic_resolvedValue"),Fn=Bn.key,Yn=jn.key,Hn=Ie&&Ie.length>0,Xn=e=>{if(!e||!Hn||!Bn.fn&&!jn.fn)return e;let t=!1;const n=e.map(e=>{const n=Bn.fn&&Bn.key&&!(Bn.key in e),r=jn.fn&&jn.key&&!(jn.key in e);if(!n&&!r)return e;t=!0;const o=Object.assign({},e);return n&&(o[Bn.key]=Bn.fn(e)),r&&(o[jn.key]=jn.fn(e)),o});return t?n:e};if(Ue){const e=mn.current;e&&m&&(e.ingest({inserts:m,bounded:!0}),e.computeScene({width:zt,height:Rt}));const t=null!==(r=null==e?void 0:e.scene)&&void 0!==r?r:[],n=null!==(o=null==e?void 0:e.scales)&&void 0!==o?o:null,i=On||(()=>{if((null==e?void 0:e.xIsDate)&&n)return Xt(n.x.domain())})();return g.createElement("div",{className:"stream-xy-frame"+(G?" "+G:""),role:"img","aria-label":Ct||("string"==typeof tt?tt:"XY chart"),style:{position:"relative",width:Wt[0],height:Wt[1]}},g.createElement(dt,{summary:Dt}),g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Wt[0],height:Wt[1],style:{position:"absolute",left:0,top:0}},g.createElement("g",{transform:`translate(${It.left},${It.top})`},jt),g.createElement("g",{transform:`translate(${It.left},${It.top})`},V&&g.createElement("rect",{x:0,y:0,width:zt,height:Rt,fill:V}),et&&n&&et.map((e,r)=>g.createElement(g.Fragment,{key:"svgpre-"+r},e(t,n,{width:zt,height:Rt}))),t.map((e,t)=>function(e,t){var n,r,o;switch(e.type){case"line":{const n=e;if(0===n.path.length)return null;const r="M"+n.path.map(([e,t])=>`${e},${t}`).join("L");return g.createElement("path",{key:"line-"+t,d:r,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity})}case"area":{const o=e;if(0===o.topPath.length)return null;const i=o.topPath.map(([e,t])=>`${e},${t}`).join("L"),l=[...o.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L");return g.createElement("path",{key:"area-"+t,d:`M${i}L${l}Z`,fill:qe(o.style.fill),fillOpacity:null!==(r=null!==(n=o.style.fillOpacity)&&void 0!==n?n:o.style.opacity)&&void 0!==r?r:.7,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})}case"point":{const n=e;return g.createElement("circle",{key:"point-"+t,cx:n.x,cy:n.y,r:n.r,fill:qe(n.style.fill),opacity:null!==(o=n.style.opacity)&&void 0!==o?o:.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})}case"rect":{const n=e;return g.createElement("rect",{key:"rect-"+t,x:n.x,y:n.y,width:n.w,height:n.h,fill:qe(n.style.fill),opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})}case"heatcell":{const n=e;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const e=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[r,o,i]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(n.fill),l=.299*r+.587*o+.114*i>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return g.createElement("g",{key:"heatcell-"+t},g.createElement("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),g.createElement("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:l,fontSize:a+"px"},e))}return g.createElement("rect",{key:"heatcell-"+t,x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill})}case"candlestick":{const n=e,r=Math.min(n.openY,n.closeY),o=Math.max(Math.abs(n.openY-n.closeY),1),i=n.isUp?n.upColor:n.downColor;return g.createElement("g",{key:"candle-"+t},g.createElement("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),g.createElement("rect",{x:n.x-n.bodyWidth/2,y:r,width:n.bodyWidth,height:o,fill:i,stroke:i,strokeWidth:1}))}default:return null}}(e,t)).filter(Boolean))),g.createElement(Ve,{width:zt,height:Rt,totalWidth:Wt[0],totalHeight:Wt[1],margin:It,scales:n,showAxes:ke,axes:we,xLabel:Ee,yLabel:Ae,yLabelRight:Me,xFormat:i,yFormat:Pe||Ce,showGrid:Re,title:tt,legend:Be,legendHoverBehavior:je,legendClickBehavior:Fe,legendHighlightedCategory:Ye,legendIsolatedCategories:Xe,legendPosition:Ge,foregroundGraphics:Bt,marginalGraphics:kt,xValues:[],yValues:[],annotations:Ie,svgAnnotationRules:ze,annotationFrame:0,xAccessor:Fn,yAccessor:Yn,annotationData:Xn(null==e?void 0:e.getData()),pointNodes:null==e?void 0:e.scene.filter(e=>"point"===e.type),curve:"string"==typeof _?_:void 0,linkedCrosshairName:Lt,linkedCrosshairSourceId:Tt}))}const Gn="semiotic-table-"+g.useId();return g.createElement("div",{ref:$t,className:"stream-xy-frame"+(G?" "+G:""),role:"group","aria-label":Ct||("string"==typeof tt?tt:"XY chart"),tabIndex:0,style:{position:"relative",width:F?"100%":Wt[0],height:Y?"100%":Wt[1],overflow:"visible"},onKeyDown:Ln},_t&&g.createElement(ht,{tableId:Gn}),_t&&g.createElement(ct,{scene:null!==(l=null===(i=mn.current)||void 0===i?void 0:i.scene)&&void 0!==l?l:[],chartType:y+" chart",tableId:Gn,chartTitle:"string"==typeof tt?tt:void 0}),g.createElement(dt,{summary:Dt}),g.createElement("div",{role:"img","aria-label":Ct||("string"==typeof tt?tt:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Ft?Tn:void 0,onMouseLeave:Ft?Mn:void 0,onClick:Ne?Pn:void 0},jt&&g.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Wt[0],height:Wt[1],pointerEvents:"none"}},g.createElement("g",{transform:`translate(${It.left},${It.top})`},jt)),g.createElement(He,{width:zt,height:Rt,totalWidth:Wt[0],totalHeight:Wt[1],margin:It,scales:tn,showAxes:ke,axes:we,showGrid:Re,xFormat:On,yFormat:Pe||Ce}),g.createElement("canvas",{ref:Yt,"aria-label":Je(null!==(s=null===(a=mn.current)||void 0===a?void 0:a.scene)&&void 0!==s?s:[],y+" chart"),style:{position:"absolute",left:0,top:0}}),g.createElement("canvas",{ref:Ht,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),g.createElement(ft,{hoverPoint:ln}),g.createElement(Ve,{width:zt,height:Rt,totalWidth:Wt[0],totalHeight:Wt[1],margin:It,scales:tn,showAxes:ke,axes:we,xLabel:Ee,yLabel:Ae,yLabelRight:Me,xFormat:On,yFormat:Pe||Ce,showGrid:Re,title:tt,legend:Be,legendHoverBehavior:je,legendClickBehavior:Fe,legendHighlightedCategory:Ye,legendIsolatedCategories:Xe,legendPosition:Ge,foregroundGraphics:Bt,marginalGraphics:kt,xValues:un,yValues:hn,annotations:Ie,svgAnnotationRules:ze,annotationFrame:Jt,xAccessor:Fn,yAccessor:Yn,annotationData:Xn(null===(c=mn.current)||void 0===c?void 0:c.getData()),pointNodes:null===(u=mn.current)||void 0===u?void 0:u.scene.filter(e=>"point"===e.type),curve:"string"==typeof _?_:void 0,underlayRendered:!0,linkedCrosshairName:Lt,linkedCrosshairSourceId:Tt}),(rt||ot)&&g.createElement(x,{width:zt,height:Rt,totalWidth:Wt[0],totalHeight:Wt[1],margin:It,dimension:null!==(d=null==rt?void 0:rt.dimension)&&void 0!==d?d:"xy",scales:tn,onBrush:null!=ot?ot:()=>{},binSize:D,snap:null==rt?void 0:rt.snap,binBoundaries:null!==(h=null==rt?void 0:rt.binBoundaries)&&void 0!==h?h:"bar"===y?null===(f=mn.current)||void 0===f?void 0:f.getBinBoundaries():void 0,snapDuring:null==rt?void 0:rt.snapDuring,streaming:"streaming"===p}),(null==st?void 0:st.showBadge)&&g.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===st.badgePosition?{top:4,left:4}:"bottom-left"===st.badgePosition?{bottom:4,left:4}:"bottom-right"===st.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:sn?"#dc3545":"#28a745",color:"white"})},sn?"STALE":"LIVE"),zn,Wn))});Zt.displayName="StreamXYFrame";const Qt={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Jt={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class en{constructor(e){this.capacity=e,this.particles=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0}}spawn(e){for(let t=0;this.capacity>t;t++){const n=this.particles[t];if(!n.active)return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=e,n.x=0,n.y=0,n}return null}step(e,t,n,r){var o;for(let i=0;this.capacity>i;i++){const l=this.particles[i];if(!l.active)continue;const a=n[l.edgeIndex];if(!a||!a.bezier){l.active=!1;continue}const s=r&&null!==(o=r[l.edgeIndex])&&void 0!==o?o:1;if(l.t+=e*t*s*(a.bezier.circular?.3:1),l.t>=1){l.active=!1;continue}const c=tn(a.bezier,l.t,l.offset);l.x=c.x,l.y=c.y}}countForEdge(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let n=0;e>n;n++)this.particles[n]=t.length>n?t[n]:{t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0};this.capacity=e}}function tn(e,t,n){if(e.circular&&e.segments)return function(e,t,n,r){const o=e.length,i=t*o,l=Math.min(Math.floor(i),o-1),a=i-l,[s,c,u,d]=e[l],h=nn(s,c,u,d,a),f=d.x-s.x,y=d.y-s.y,g=Math.sqrt(f*f+y*y);if(g>.001){const e=f/g;h.x+=-y/g*n*r*2,h.y+=e*n*r*2}return h}(e.segments,t,n,e.halfWidth);if(!e.points)return{x:0,y:0};const[r,o,i,l]=e.points,a=nn(r,o,i,l,t),s=l.x-r.x,c=l.y-r.y,u=Math.sqrt(s*s+c*c);if(u>.001){const t=s/u;a.x+=-c/u*n*e.halfWidth*2,a.y+=t*n*e.halfWidth*2}return a}function nn(e,t,n,r,o){const i=1-o,l=i*i,a=l*i,s=o*o,c=s*o;return{x:a*e.x+3*l*o*t.x+3*i*s*n.x+c*r.x,y:a*e.y+3*l*o*t.y+3*i*s*n.y+c*r.y}}function rn(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function on(e,t){var n,r=[],o=[],i=[],l={},a=[];function s(e){i[e]=!1,l.hasOwnProperty(e)&&Object.keys(l[e]).forEach(function(t){delete l[e][t],i[t]&&s(t)})}function c(e){var t,r,d=!1;for(o.push(e),i[e]=!0,t=0;a[e].length>t;t++)(r=a[e][t])===n?(u(n,o),d=!0):i[r]||(d=c(r));if(d)s(e);else for(t=0;a[e].length>t;t++){var h=l[r=a[e][t]];h||(l[r]=h={}),h[r]=!0}return o.pop(),d}function u(e,t){var n=[].concat(t).concat(e);r.push(n)}function d(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,r=function(e){for(var t=e.length,n=Array(t),r=Array(t),o=Array(t),i=Array(t),l=Array(t),a=Array(t),s=0;t>s;++s)n[s]=-1,r[s]=0,o[s]=!1,i[s]=0,l[s]=-1,a[s]=[];var c,u=0,d=[],h=[];function f(t){var s=[t],c=[t];for(n[t]=r[t]=u,o[t]=!0,u+=1;c.length>0;){var f=e[t=c[c.length-1]];if(f.length>i[t]){for(var y=i[t];f.length>y;++y){var g=f[y];if(0>n[g]){n[g]=r[g]=u,o[g]=!0,u+=1,s.push(g),c.push(g);break}o[g]&&(r[t]=0|Math.min(r[t],r[g])),0>l[g]||a[t].push(l[g])}i[t]=y}else{if(r[t]===n[t]){var p=[],m=[],v=0;for(y=s.length-1;y>=0;--y){var x=s[y];if(o[x]=!1,p.push(x),m.push(a[x]),v+=a[x].length,l[x]=d.length,x===t){s.length=y;break}}d.push(p);var b=Array(v);for(y=0;m.length>y;y++)for(var k=0;m[y].length>k;k++)b[--v]=m[y][k];h.push(b)}c.pop()}}}for(s=0;t>s;++s)0>n[s]&&f(s);for(s=0;h.length>s;s++){var y=h[s];if(0!==y.length){y.sort(function(e,t){return e-t}),c=[y[0]];for(var g=1;y.length>g;g++)y[g]!==y[g-1]&&c.push(y[g]);h[s]=c}}return{components:d,adjacencyList:h}}(e),o=r.components.filter(function(e){return e.length>1}),i=1/0,l=0;o.length>l;l++)for(var a=0;o[l].length>a;a++)i>o[l][a]&&(i=o[l][a],n=l);var s=o[n];if(!s)return!1;var c=e.map(function(e,t){return-1===s.indexOf(t)?[]:e.filter(function(e){return-1!==s.indexOf(e)})});return{leastVertex:i,adjList:c}}n=0;for(var h=e.length;h>n;){var f=d(n);if(n=f.leastVertex,a=f.adjList){for(var y=0;a.length>y;y++)for(var g=0;a[y].length>g;g++){var p=a[y][g];i[+p]=!1,l[p]={}}c(n),n+=1}else n=h}return r}function ln(e){return e.y0-e.y1>0?"up":"down"}function an(e,t){return t(e.source)==t(e.target)}function sn(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function cn(e){return e.target.x0-e.source.x1}function un(e,t){var n=hn(e),r=cn(t)/Math.tan(n);return"up"==ln(e)?e.y1-r:e.y1+r}function dn(e,t){var n=hn(e),r=cn(t)/Math.tan(n);return"up"==ln(e)?e.y1+r:e.y1-r}function hn(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function fn(e,t){return t(e)}function yn(e){return pn(e.source)}function gn(e){return pn(e.target)}function pn(e){return(e.y0+e.y1)/2}function mn(e){return e.virtual?0:e.value}function vn(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!an(e,t)?n+1:n});var r=0;return e.targetLinks.forEach(function(e){r=e.circular&&!an(e,t)?r+1:r}),n+r}function xn(e){return e.target.depth}function bn(e,t){return e.sourceLinks.length?e.depth:t-1}function kn(e,t){return e.y0-t.y0}function wn(e,t){return t.y0-e.y0}function En(e,t){return e.y1-t.y1}function An(e,t){return t.y1-e.y1}function Mn(e,t){return Pn(e.source,t.source)||e.index-t.index}function Sn(e,t){return Pn(e.target,t.target)||e.index-t.index}function Pn(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function _n(e,t){return Cn(e)==Cn(t)?"bottom"==e.circularLinkType?wn(e,t):kn(e,t):Cn(t)-Cn(e)}function Cn(e){return e.target.column-e.source.column}function Dn(e,t){return Ln(e)==Ln(t)}function Ln(e){return e.y0-e.y1>0?"up":"down"}function Tn(e,t,n,r,o){let i=e;var a=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,a))});var s=l.min(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=i.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),Nn(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),Nn(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+r,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,an(e,t)&&sn(e))e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var l=e.source.column,a=e.circularLinkType,c=i.links.filter(function(e){return e.source.column==l&&e.circularLinkType==a});c.sort("bottom"==e.circularLinkType?wn:kn);var u=0;c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2+o*n+u),u+=t._circularWidth||t.width}),l=e.target.column,(c=i.links.filter(function(e){return e.target.column==l&&e.circularLinkType==a})).sort("bottom"==e.circularLinkType?An:En),u=0,c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2+o*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=s-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,n=e.y0,r=e.target.x0,o=e.y1,i=(t+r)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+o+" "+r+","+o}(e)}),i}function Nn(e,t,n){e.sort(_n);var r=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,o){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(an(e,t)&&sn(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var l=0;r.length>l;l++){var a=r[l];if(a!==e&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&On(e,a)){var s=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;i=s>i?s:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function On(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function $n(e){return function(){return e}}function Wn(e){return e.index}function In(e){return e.nodes}function zn(e){return e.links}function Rn(e,t,n){var r=l.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});r.forEach(function(o,i){var l=o.length;if(t)o.sort(t);else if(i>0){var a=new Map;o.forEach(function(e,t){var n,r,o,i=(r=0,o=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=pn(e.source)*t,r+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=pn(e.target)*t,r+=t}}),r>0?o/r:NaN);a.set(e,{bc:i,idx:t})}),o.sort(function(e,t){var n=a.get(e),r=a.get(t),o=n.bc,i=r.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(o)||isNaN(i)?isNaN(o)?isNaN(i)?n.idx-r.idx:1:-1:o-i})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?vn(t,n)-vn(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});o.forEach(function(t,o){t.depth==r.length-1&&1==l||0==t.depth&&1==l?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==vn(t,n)?(t.y0=e.y1/2+o,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+o,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-o,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/l*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-l/2+o,t.y1=t.y0+t.value*e.ky)})})}function Bn(e,t,n,r,o,i){var a=l.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});d();for(var s=1,c=i;c>0;--c)u(s*=.99,n),d();function u(t,n){var r=a.length;a.forEach(function(o){var i=o.length,a=o[0].depth;o.forEach(function(o){var s;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&vn(o,n)>0){var c=l.mean(o.sourceLinks,gn),u=l.mean(o.targetLinks,yn),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-pn(o))*t*.3;o.y0+=h,o.y1+=h}}else if(0==a&&1==i)o.y0=e.y1/2-(s=o.y1-o.y0)/2,o.y1=e.y1/2+s/2;else if(a==r-1&&1==i)o.y0=e.y1/2-(s=o.y1-o.y0)/2,o.y1=e.y1/2+s/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)s=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+s;else{var f=l.mean(o.sourceLinks,gn),y=l.mean(o.targetLinks,yn),g=((f&&y?(f+y)/2:f||y)-pn(o))*t;o.y0+=g,o.y1+=g}})})}function d(){a.forEach(function(n){var i,l,a,s=e.y0,c=n.length;for(n.sort(t||Pn),a=0;c>a;++a)(l=s-(i=n[a]).y0)>0&&(i.y0+=l,i.y1+=l),s=i.y1+r;if((l=s-r-e.y1)>0)for(s=i.y0-=l,i.y1-=l,a=c-2;a>=0;--a)(l=(i=n[a]).y1+o-s)>0&&(i.y0-=l,i.y1-=l),s=i.y0})}}function jn(e){e.nodes.forEach(function(e){e.sourceLinks.sort(Sn),e.targetLinks.sort(Mn)}),e.nodes.forEach(function(e){var t=e.y0,n=t,r=e.y1,o=r;e.sourceLinks.forEach(function(e){e.circular?(e.y0=r-e.width/2,r-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=o-e.width/2,o-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function Fn(){var e=0,t=0,n=1,r=1,o=24,i=8,a=null,s=Wn,c=bn,u=void 0,d=32,h=2,f=In,y=zn;function g(){var g={nodes:f.apply(null,arguments),links:y.apply(null,arguments)};return function(f){f.x0=e,f.y0=t,f.x1=n,f.y1=r,f.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return l.group(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var r=e.source,o=e.target;"object"!=typeof r&&(r=e.source=rn(n,r)),"object"!=typeof o&&(o=e.target=rn(n,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}(f,s),function(e,t){var n=0;if(null==t){for(var r=[],o=0;e.links.length>o;o++){var i=e.links[o],l=i.source.index,a=i.target.index;r[l]||(r[l]=[]),r[a]||(r[a]=[]),-1===r[l].indexOf(a)&&r[l].push(a)}var s=on(r);s.sort(function(e,t){return e.length-t.length});var c={};for(o=0;s.length>o;o++){var u=s[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,r=e.source.index;t===r||c[r]&&c[r][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(f,u),function(e,t){var n=0,r=0;e.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:r>n?"top":"bottom","top"==o.circularLinkType?n++:r++,e.nodes.forEach(function(e){fn(e,t)!=fn(o.source,t)&&fn(e,t)!=fn(o.target,t)||(e.circularLinkType=o.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),an(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(f,s),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(l.sum(e.sourceLinks,mn),l.sum(e.targetLinks,mn)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(f),function(e,t,n){var r,o,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var l=0,a=t(e.nodes[0]);e.nodes.forEach(function(e){l=t(e)==a?l:l+1,a=t(e)==a?a:t(e),e.column=l})}for(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>o.indexOf(e.source)&&!e.circular&&o.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,i):e.column})}(f,u,c);var y=i;if(null!==a){var g=l.groups(f.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),p=l.max(g,function(e){return e.length});p>1&&(y=Math.max(1,(r-t)*a/(p-1)))}(function(e,t,n){var r=l.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var o=l.min(r,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/l.sum(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var i=l.max(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/i),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(f,y,o),Rn(f,u,s),Bn(f,u,s,y,y,d),jn(f),Tn(f,s,h,10,8),Rn(f,u,s),Bn(f,u,s,y,y,d),jn(f),Tn(f,s,h,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var r=n.links.filter(function(n){return fn(n.source,t)==fn(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Dn(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=un(t,e);return e.y1-n}if(t.target.column>e.target.column)return un(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;r.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,l=0;o>i;i++)l+=r[i].width;t.y0=e.y1-l-t.width/2}})})}(f,s),function(e,t){let n=e;n.nodes.forEach(function(e){var r=n.links.filter(function(n){return fn(n.target,t)==fn(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Dn(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=dn(t,e);return e.y0-n}if(t.source.column>e.source.column)return dn(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;r.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,l=0;o>i;i++)l+=r[i].width;t.y1=e.y1-l-t.width/2}})})}(f,s),function(e){var t=e.nodes,n=e.links,r=!1,o=!1;if(n.forEach(function(e){"top"==e.circularLinkType?r=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==r||0==o){var i=l.min(t,function(e){return e.y0}),a=l.max(t,function(e){return e.y1}),s=(e.y1-e.y0)/(a-i);function c(t){return(t-i)/(a-i)*(e.y1-e.y0)+e.y0}1>s?(t.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1)}),n.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1),e.width=e.width*s})):t.forEach(function(e){var t=e.y1-e.y0,n=c(e.y0)-e.y0;e.y0=c(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(f),Tn(f,s,h,10,8)}(g),g}return g.update=function(e){return jn(e),Tn(e,s,h,10,8),e},g.nodeWidth=function(e){return arguments.length?(o=+e,g):o},g.nodePadding=function(e){return arguments.length?(i=+e,g):i},g.nodePaddingRatio=function(e){return arguments.length?(a=+e,g):a},g.nodes=function(e){return arguments.length?(f="function"==typeof e?e:$n(e),g):f},g.links=function(e){return arguments.length?(y="function"==typeof e?e:$n(e),g):y},g.nodeId=function(e){return arguments.length?(s="function"==typeof e?e:$n(e),g):s},g.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:$n(e),g):c},g.nodeSort=function(e){return arguments.length?(u=e,g):u},g.iterations=function(e){return arguments.length?(d=+e,g):d},g.circularLinkGap=function(e){return arguments.length?(h=+e,g):h},g.extent=function(o){return arguments.length?(e=+o[0][0],t=+o[0][1],n=+o[1][0],r=+o[1][1],g):[[e,t],[n,r]]},g.size=function(o){return arguments.length?(e=t=0,n=+o[0],r=+o[1],g):[n-e,r-t]},g}const Yn=e=>{let t,n,r,o,i,l,a,s,c;return"down"===e.direction?(t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,r=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,i=e.source.x1,l=e.target.x0,a=u.interpolateNumber(i,l),s=a(.5),c=a(.5),`M${t},${i}C${t},${s} ${n},${c} ${n},${l}L${r},${l}C${r},${c} ${o},${s} ${o},${i}Z`):(t=e.source.x1,n=e.target.x0,a=u.interpolateNumber(t,n),r=a(.5),o=a(.5),i=e.y0-e.sankeyWidth/2,l=e.y1-e.sankeyWidth/2,s=e.y1+e.sankeyWidth/2,c=e.y0+e.sankeyWidth/2,`M${t},${i}C${r},${i} ${o},${l} ${n},${l}L${n},${s}C${o},${s} ${r},${c} ${t},${c}Z`)};function Hn(e){var t;const n=e.sankeyWidth/2,r=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,o=e.circularPathData;if(!o)return null;if("down"===e.direction)return null;if(e._circularStub){const t=o.sourceX,r=o.sourceY,i=o.targetX,l=o.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const a=Math.max(15,Math.min(40,.33*(o.rightFullExtent-t))),s=Math.max(15,Math.min(40,.33*(i-o.leftFullExtent)));return`M${t},${r-n}L${t+a},${r-n}L${t+a},${r+n}L${t},${r+n}ZM${i},${l-n}L${i-s},${l-n}L${i-s},${l+n}L${i},${l+n}Z`}const i=o.sourceX,l=o.sourceY,a=o.targetX,s=o.targetY,c=o.rightFullExtent,u=o.leftFullExtent,d=o.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,f=Math.max(4,Math.min(r,15));return`M${i},${l-h*n}L${c},${l-h*n}L${c+r},${l-h*n+h*f}L${c+r},${d+h*r-h*f}L${c+r-f},${d+h*r}L${u-r+f},${d+h*r}L${u-r},${d+h*r-h*f}L${u-r},${s-h*n+h*f}L${u-r+f},${s-h*n}L${a},${s-h*n}L${a},${s+h*n}L${u+r},${s+h*n}L${u+r},${d-h*r}L${c-r},${d-h*r}L${c-r},${l+h*n}L${i},${l+h*n}Z`}const Xn=new Set,Gn=new WeakMap;function Vn(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=Gn.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,Gn.set(e,n);const r=new Proxy(e,{get(e,n,r){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;Xn.has(e)||(Xn.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,n,r)}});return n.set(t,r),r}const qn={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(xn))-1:0},justify:bn},Un={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){var o,i,l,a,s,c,u;if(0===e.length)return;const d="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",f=null!==(o=n.nodeWidth)&&void 0!==o?o:15,y=null!==(i=n.nodePaddingRatio)&&void 0!==i?i:.05,g=null!==(l=n.iterations)&&void 0!==l?l:100,p=e.map(e=>Object.assign({},e)),m=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let v;v="down"===d?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const x=Fn().extent(v).links(m).nodes(p).nodeAlign(qn[h]||bn).nodeId(e=>e.id).nodeWidth(f).iterations(g);x.nodePaddingRatio&&x.nodePaddingRatio(y),x();{let e=1/0,t=-1/0,n=1/0,o=-1/0;for(const r of p)e>r.x0&&(e=r.x0),r.x1>t&&(t=r.x1),n>r.y0&&(n=r.y0),r.y1>o&&(o=r.y1);for(const r of m){if(!r.circular||!r.circularPathData)continue;const i=r.circularPathData,l=(null!==(s=null!==(a=r._circularWidth)&&void 0!==a?a:r.width)&&void 0!==s?s:0)/2;e>i.leftFullExtent-l&&(e=i.leftFullExtent-l),i.rightFullExtent+l>t&&(t=i.rightFullExtent+l),n>i.verticalFullExtent-l&&(n=i.verticalFullExtent-l),i.verticalFullExtent+l>o&&(o=i.verticalFullExtent+l)}const i=t-e,l=o-n,u=r[0],d=r[1];if(i>0&&l>0&&(0>e||0>n||t>u||o>d)){const t=Math.min(u/i,d/l),r=-e*t+(u-i*t)/2,o=-n*t+(d-l*t)/2;for(const e of p)e.x0=e.x0*t+r,e.x1=e.x1*t+r,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of m)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(null!==(c=e.width)&&void 0!==c?c:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+r,n.targetX=n.targetX*t+r,n.sourceY=n.sourceY*t+o,n.targetY=n.targetY*t+o,n.rightFullExtent=n.rightFullExtent*t+r,n.leftFullExtent=n.leftFullExtent*t+r,n.verticalFullExtent=n.verticalFullExtent*t+o,n.rightInnerExtent=n.rightInnerExtent*t+r,n.leftInnerExtent=n.leftInnerExtent*t+r,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+o,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const b=new Map;for(const t of e)b.set(t.id,t);for(const e of p){const t=b.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const k=new Map;for(const e of t)k.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of m){const t=e.source,n=e.target,r="object"==typeof t&&null!==t?t.id:t+"",o="object"==typeof n&&null!==n?n.id:n+"",i=k.get(e._edgeKey?e._edgeKey:`${r}\0${o}`);if(i){i.y0=e.y0,i.y1=e.y1,i.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,i.circular=!!e.circular,i.circularPathData=e.circularPathData,i._circularWidth=e._circularWidth,i._circularStub=e._circularStub,i.path=e.path,i.circularLinkType=e.circularLinkType,i.direction=d;const t=b.get(r),n=b.get(o);t&&(i.source=t),n&&(i.target=n)}}},buildScene(e,t,n,r){var o,l,a,s;const c="vertical"===n.orientation?"down":"right",u=n.nodeStyle,d=n.edgeStyle,h=null!==(o=n.edgeOpacity)&&void 0!==o?o:.5,f=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:i.schemeCategory10,g=new Map;e.forEach((e,t)=>{g.set(e.id,y[t%y.length])});const p=[],m=[],v=[],x=new Map;for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const r=u?u(Vn(t,"nodeStyle")):{},o={fill:r.fill||g.get(t.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};x.set(t.id,("string"==typeof o.fill?o.fill:null)||g.get(t.id)||"#4d430c"),p.push("down"===c?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:o,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:o,datum:t,id:t.id,label:t.id})}const b=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of b){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let r="#999";r="function"==typeof f?f(e)||r:"target"===f?x.get(n.id)||g.get(n.id)||r:x.get(t.id)||g.get(t.id)||r;const o=d?d(Vn(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,i=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),s=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=o.fill||r;m.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+i},${t.sourceY-n}L${t.sourceX+i},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:c,fillOpacity:null!==(l=o.fillOpacity)&&void 0!==l?l:h,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+i}}),m.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-s},${t.targetY-n}L${t.targetX-s},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:c,fillOpacity:null!==(a=o.fillOpacity)&&void 0!==a?a:h,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-s,x1:t.targetX}});continue}let i;if(i=e.circular&&e.circularPathData?Hn(e):Yn(e),!i)continue;const c={fill:o.fill||r,fillOpacity:null!==(s=o.fillOpacity)&&void 0!==s?s:h,stroke:o.stroke||"none",strokeWidth:o.strokeWidth,opacity:o.opacity};m.push({type:"bezier",pathD:i,bezierCache:e.bezier,style:c,datum:e})}if(!1!==n.showLabels){const t=(k=n.nodeLabel)?"function"==typeof k?k:e=>e[k]||e.id:null;for(const n of e){const e=n.x1-n.x0,o=n.y1-n.y0;if(0>=e||0>=o)continue;const i=t?t(n):n.id;if(!i)continue;let l,a,s;"down"===c?(l=n.y0+(n.y1-n.y0)/2,a=n.x1+14,s="middle"):(r[0]/2>n.x0+e/2?(l=n.x0-6,s="end"):(l=n.x1+6,s="start"),a=n.y0+o/2),v.push({x:l,y:a,text:i+"",anchor:s,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:p,sceneEdges:m,labels:v}}},Kn={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){var o,i;if(0===e.length)return;const l=null!==(o=n.forceStrength)&&void 0!==o?o:.1,a=r[0]/2,s=r[1]/2,c=n.__previousPositions;let u=0;const h=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=null==c?void 0:c.get(t.id);e?u++:n?(t.x=n.x,t.y=n.y,u++):h.push(t)}const f=u>0&&.3>=(e.length>0?h.length/e.length:1);if(f){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of h){const r=Zn(e.id,t,n);if(r.length>0){let t=0,n=0;for(const e of r)t+=e.x,n+=e.y;const o=Qn(e.id),i=o%360*(Math.PI/180),l=10+o%20;e.x=t/r.length+l*Math.cos(i),e.y=n/r.length+l*Math.sin(i)}else{const t=Qn(e.id),n=t%360*(Math.PI/180),r=15+t%30;e.x=a+r*Math.cos(n),e.y=s+r*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const r=e[n];if(null==r.x||null==r.y||0===r.x&&0===r.y){const e=10*Math.sqrt(n+.5),o=n*t;r.x=a+e*Math.cos(o),r.y=s+e*Math.sin(o)}}}const y=null!==(i=n.iterations)&&void 0!==i?i:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),g=f?40:y,p=Jn(n.nodeSize,n.nodeSizeRange,e),m=e=>p(e),v=d.forceLink().strength(e=>Math.min(2.5,e.weight?e.weight*l:l)).id(e=>e.id),x=d.forceSimulation().force("charge",d.forceManyBody().strength(e=>-25*m(e))).force("center",d.forceCenter(a,s).strength(.8)).force("x",d.forceX(a).strength(.15)).force("y",d.forceY(s).strength(.15));if(x.nodes(e),t.length>0){const e=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));x.force("link",v),x.force("link").links(e)}f?x.alpha(.3):.1>x.alpha()&&x.alpha(1),x.stop();for(let e=0;g>e;++e)x.tick();for(const t of e){if(null==t.x||null==t.y)continue;const e=m(t);t.x=Math.max(e,Math.min(r[0]-e,t.x)),t.y=Math.max(e,Math.min(r[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const b=new Map;for(const t of e)b.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=b.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=b.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,r){var o,l,a;const s=n.nodeStyle,c=n.edgeStyle,u=Jn(n.nodeSize,n.nodeSizeRange,e),d=Array.isArray(n.colorScheme)?n.colorScheme:i.schemeCategory10,h=new Map;e.forEach((e,t)=>{h.set(e.id,d[t%d.length])});const f=[],y=[],g=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=u(Vn(t,"nodeSize")),n=s?s(Vn(t,"nodeStyle")):{},r={fill:n.fill||h.get(t.id)||"#007bff",stroke:n.stroke||"#fff",strokeWidth:null!==(o=n.strokeWidth)&&void 0!==o?o:2,opacity:n.opacity};f.push({type:"circle",cx:t.x,cy:t.y,r:e,style:r,datum:t,id:t.id,label:t.id})}const p=new Map;for(const t of e)p.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:p.get(e.source),n="object"==typeof e.target?e.target:p.get(e.target);if(!t||!n)continue;if(null==t.x||null==t.y)continue;if(null==n.x||null==n.y)continue;const r=c?c(Vn(e,"edgeStyle")):{},o={stroke:r.stroke||"#999",strokeWidth:null!==(l=r.strokeWidth)&&void 0!==l?l:1,opacity:null!==(a=r.opacity)&&void 0!==a?a:.6};y.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:o,datum:e})}if(!1!==n.showLabels){const t=(m=n.nodeLabel)?"function"==typeof m?m:e=>e[m]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const r=u(Vn(n,"nodeSize"));g.push({x:n.x,y:n.y-r-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var m;return{sceneNodes:f,sceneEdges:y,labels:g}}};function Zn(e,t,n){const r=[];for(const o of t){const t="string"==typeof o.source?o.source:o.source.id,i="string"==typeof o.target?o.target:o.target.id;let l=null;if(t===e?l=i:i===e&&(l=t),l){const e=n.get(l);!e||0===e.x&&0===e.y||r.push({x:e.x,y:e.y})}}return r}function Qn(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function Jn(e,t,n){var o,i;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const a=t||[5,20],s=n.map(t=>{var n;return null===(n=t.data)||void 0===n?void 0:n[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===s.length)return()=>a[0];const c=null!==(o=l.min(s))&&void 0!==o?o:0,u=null!==(i=l.max(s))&&void 0!==i?i:1;if(c===u)return()=>(a[0]+a[1])/2;const d=r.scaleLinear().domain([c,u]).range(a).clamp(!0);return t=>{var n;const r=null===(n=t.data)||void 0===n?void 0:n[e];return null==r||"number"!=typeof r?a[0]:d(r)}}const er=i.schemeCategory10,tr={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:l}=n,a=Math.min(r[0],r[1])/2,c=a-i,u=r[0]/2,d=r[1]/2,f=(y=n.valueAccessor)?"function"==typeof y?y:e=>{var t;return null!==(t=e[y])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var y;const g=new Map;for(let t=0;e.length>t;t++)g.set(e[t].id,t);const p=e.length,m=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=g.get("string"==typeof e.source?e.source:e.source.id),r=g.get(t);if(void 0===n||void 0===r)continue;const o=f(e);m[n][r]=o}const v=h.chord().padAngle(o);l&&v.sortGroups(l);const x=v(m),b=x.groups,k=s.arc().innerRadius(c).outerRadius(a);for(const t of b){const n=e[t.index],r=k.centroid(t);n.x=r[0]+u,n.y=r[1]+d,n.arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const w=new Map;for(const t of e)w.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=w.get("string"==typeof e.source?e.source:e.source.id),r=w.get(t);n&&(e.source=n),r&&(e.target=r)}const E=new Map;for(const e of t)E.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of x){const n=e[t.source.index].id,r=e[t.target.index].id,o=E.get(`${n}\0${r}`)||E.get(`${r}\0${n}`);o&&(o.chordData=t)}},buildScene(e,t,n,r){var o,i;const{groupWidth:l=20,edgeOpacity:a=.5}=n,s=Math.min(r[0],r[1])/2,c=s-l,u=r[0]/2,d=r[1]/2,f=n.nodeStyle,y=n.edgeStyle,g=n.edgeColorBy||"source",p=Array.isArray(n.colorScheme)?n.colorScheme:er,m=new Map;e.forEach((e,t)=>{m.set(e.id,p[t%p.length])});const v=h.ribbon().radius(c),x=[],b=[],k=[];for(let t=0;e.length>t;t++){const n=e[t],r=n.arcData;if(!r)continue;let i;i=f?f(Vn(n,"nodeStyle")).fill||m.get(n.id)||p[t%p.length]:m.get(n.id)||p[t%p.length];const l=f?f(Vn(n,"nodeStyle")):{},a={fill:i,stroke:l.stroke||"black",strokeWidth:null!==(o=l.strokeWidth)&&void 0!==o?o:1,opacity:l.opacity};x.push({type:"arc",cx:u,cy:d,innerR:c,outerR:s,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:a,datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.chordData;if(!t)continue;const n=v(t);if(!n)continue;const r=nr(n,u,d);let o="#999";if(y)o=y(Vn(e,"edgeStyle")).fill||o;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===g&&n?o=m.get(n.id)||o:t&&(o=m.get(t.id)||o)}const l=y?y(Vn(e,"edgeStyle")):{},s={fill:o,fillOpacity:null!==(i=l.fillOpacity)&&void 0!==i?i:a,stroke:l.stroke||"none",strokeWidth:l.strokeWidth,opacity:l.opacity};b.push({type:"ribbon",pathD:r,style:s,datum:e})}if(!1!==n.showLabels){const t=(w=n.nodeLabel)?"function"==typeof w?w:e=>e[w]||e.id:null,r=s+12;for(const n of e){const e=n.arcData;if(!e)continue;const o=t?t(n):n.id;if(!o)continue;const i=(e.startAngle+e.endAngle)/2,l=i-Math.PI/2;k.push({x:u+Math.cos(l)*r,y:d+Math.sin(l)*r,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:x,sceneEdges:b,labels:k}}};function nr(e,t,n){const r=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return e;const o=[];let i=0;for(;r.length>i;){const e=r[i];if("M"===e||"L"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("C"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;3>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("Q"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;2>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("A"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&(o.push(Number(r[i])+t+""),i++),r.length>i&&(o.push(Number(r[i])+n+""),i++);else"Z"===e||"z"===e?(o.push(e),i++):(o.push(r[i]),i++)}return o.join(" ")}const rr=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function or(e){const[t,n,r]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*r>150?"#222":"#fff"}function ir(e,t,n){const r=t.nodeIDAccessor;return"function"==typeof r?r(e.data)+"":"string"==typeof r&&void 0!==e.data[r]?e.data[r]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function lr(e){return e?"function"==typeof e?e:t=>{var n;return(null===(n=t.data)||void 0===n?void 0:n[e])||t[e]||t.id}:null}function ar(e,t,n,r,o){if("horizontal"===o){const o=(e+n)/2;return`M ${e},${t} C ${o},${t} ${o},${r} ${n},${r}`}if("radial"===o){const o=(e+n)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+r)/2} T ${n},${r}`}{const o=(t+r)/2;return`M ${e},${t} C ${e},${o} ${n},${o} ${n},${r}`}}const sr={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,r){var o;const i=n.__hierarchyRoot;if(!i)return;const l=n.chartType,s=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),c=n.hierarchySum||(e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0}),u=a.hierarchy(i,s);u.sum(c),u.sort((e,t)=>{var n,r;return(null!==(n=t.value)&&void 0!==n?n:0)-(null!==(r=e.value)&&void 0!==r?r:0)});const[d,h]=r;switch(l){case"tree":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=a.tree();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(u,n,d,h);break;case"cluster":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=a.cluster();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(u,n,d,h);break;case"treemap":!function(e,t,n,r){var o,i;const l=null!==(o=t.padding)&&void 0!==o?o:4,s=null!==(i=t.paddingTop)&&void 0!==i?i:0,c=a.treemap().size([n,r]).tile(a.treemapBinary).padding(l);s>0&&c.paddingTop(s),c(e)}(u,n,d,h);break;case"circlepack":!function(e,t,n,r){var o;const i=null!==(o=t.padding)&&void 0!==o?o:4;a.pack().size([n,r]).padding(i)(e)}(u,n,d,h);break;case"partition":!function(e,t,n,r){var o;a.partition().size([n,r]).padding(null!==(o=t.padding)&&void 0!==o?o:1)(e)}(u,n,d,h)}const f=u.descendants();e.length=0,t.length=0;const y=new Map;for(let t=0;f.length>t;t++){const r=f[t],i={id:ir(r,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=r.value)&&void 0!==o?o:0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===l||"cluster"===l?cr(i,r,n):"treemap"===l||"partition"===l?ur(i,r):"circlepack"===l&&dr(i,r),i.__hierarchyNode=r,e.push(i),y.set(r,i)}if("tree"===l||"cluster"===l)for(const e of f)if(e.parent){const n=y.get(e.parent),r=y.get(e);n&&r&&t.push({source:n,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,r){const o=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,r,o,i){var l,a,s,c,u;const d=[],h=[],f=[],y=n.treeOrientation||"vertical",g="radial"===y,p=r[0]/2,m=r[1]/2,v="number"==typeof(x=n.nodeSize)?x:5;var x;for(const t of e){let e=t.x,r=t.y;g&&(e+=p,r+=m);const i=o(Vn(t,"nodeStyle"));let a=i.fill||"#4d430c";n.colorByDepth&&void 0!==t.depth&&(a=rr[t.depth%rr.length]);const s={fill:a,stroke:i.stroke||"#fff",strokeWidth:null!==(l=i.strokeWidth)&&void 0!==l?l:1,opacity:i.opacity};d.push({type:"circle",cx:e,cy:r,r:v,style:s,datum:t,id:t.id,label:t.id,depth:t.depth})}const b=null!==(a=n.edgeOpacity)&&void 0!==a?a:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let r=t.x,o=t.y,l=n.x,a=n.y;g&&(r+=p,o+=m,l+=p,a+=m);const u=ar(r,o,l,a,y),d=i(Vn(e,"edgeStyle")),f={fill:"none",stroke:d.stroke||"#999",strokeWidth:null!==(s=d.strokeWidth)&&void 0!==s?s:1.5,opacity:null!==(c=d.opacity)&&void 0!==c?c:b};h.push({type:"curved",pathD:u,style:f,datum:e})}if(!1!==n.showLabels){const t=lr(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let r,o,i,l=n.x,a=n.y;if(g&&(l+=p,a+=m),g){const e=l-p,t=a-m,n=Math.sqrt(e*e+t*t);n>0?(r=l+e/n*10,o=a+t/n*10,i=0>e?"end":"start"):(r=l,o=a-12,i="middle")}else"horizontal"===y?((null===(u=n.data)||void 0===u?void 0:u.children)&&0!==n.data.children.length?(r=l-v-6,i="end"):(r=l+v+6,i="start"),o=a):(r=l,o=a+v+14,i="middle");f.push({x:r,y:o,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:f}}(e,t,n,r,o,i);case"treemap":case"partition":return function(e,t,n,r){var o,i;const l=[],a=[];for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const a=r(Vn(n,"nodeStyle"));let s=a.fill||"#4d430c";t.colorByDepth&&void 0!==n.depth&&(s=rr[n.depth%rr.length]);const c={fill:s,stroke:a.stroke||"#fff",strokeWidth:null!==(o=a.strokeWidth)&&void 0!==o?o:1,opacity:a.opacity};l.push({type:"rect",x:n.x0,y:n.y0,w:e,h:i,style:c,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=lr(t.nodeLabel),o=t.labelMode||"leaf",l="partition"===t.chartType;for(const s of e){const e=s.x1-s.x0,c=s.y1-s.y0;if(0>=e||0>=c)continue;const u=!((null===(i=s.data)||void 0===i?void 0:i.children)&&s.data.children.length>0);if(!l){if("leaf"===o&&!u)continue;if("parent"===o&&u)continue}const d=n?n(s):s.id;if(!d)continue;if((u?30:40)>e||(u?16:14)>c)continue;let h=r(Vn(s,"nodeStyle")).fill||"#4d430c";t.colorByDepth&&void 0!==s.depth&&(h=rr[s.depth%rr.length]);const f=or(h);a.push(u?{x:s.x0+e/2,y:s.y0+c/2,text:d+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,c)/6)),fill:f}:{x:s.x0+4,y:s.y0+12,text:d+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:f})}}return{sceneNodes:l,sceneEdges:[],labels:a}}(e,n,0,o);case"circlepack":return function(e,t,n,r){var o,i,l,a,s;const c=[],u=[];for(const n of e){const e=null!==(o=n.__radius)&&void 0!==o?o:5;if(0>=e)continue;const a=r(Vn(n,"nodeStyle"));let s=a.fill||"#4d430c";t.colorByDepth&&void 0!==n.depth&&(s=rr[n.depth%rr.length]);const u={fill:s,stroke:a.stroke||"#fff",strokeWidth:null!==(i=a.strokeWidth)&&void 0!==i?i:1,opacity:null!==(l=a.opacity)&&void 0!==l?l:.7};c.push({type:"circle",cx:n.x,cy:n.y,r:e,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=lr(t.nodeLabel);for(const o of e){const e=null!==(a=o.__radius)&&void 0!==a?a:5,i=n?n(o):o.id;if(!i)continue;if(15>e)continue;const l=!((null===(s=o.data)||void 0===s?void 0:s.children)&&o.data.children.length>0);let c=r(Vn(o,"nodeStyle")).fill||"#4d430c";if(t.colorByDepth&&void 0!==o.depth&&(c=rr[o.depth%rr.length]),l){const t=or(c);u.push({x:o.x,y:o.y,text:i+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:t})}else u.push({x:o.x,y:o.y-e+14,text:i+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:"#000",stroke:"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(e,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function cr(e,t,n){const r=n.treeOrientation||"vertical";if("radial"===r){const n=t.x,r=t.y;e.x=r*Math.cos(n-Math.PI/2),e.y=r*Math.sin(n-Math.PI/2)}else"horizontal"===r?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function ur(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function dr(e,t){var n;const r=null!==(n=t.r)&&void 0!==n?n:0;e.x=t.x,e.y=t.y,e.x0=t.x-r,e.x1=t.x+r,e.y0=t.y-r,e.y1=t.y+r,e.width=2*r,e.height=2*r,e.__radius=r}function hr(e){const t=e;return t.__orbitState||(t.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),t.__orbitState}const fr={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,r){const o=n.__hierarchyRoot;o&&function(e,t,n,r,o){var i,l;const a=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),c=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>{var n;return(null!==(n=e[t])&&void 0!==n?n:"")+""}}(n.nodeIDAccessor),u=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),d=null!==(i=n.orbitSize)&&void 0!==i?i:2.95,h=null!==(l=n.orbitEccentricity)&&void 0!==l?l:1,f="number"==typeof d?()=>d:d,y="number"==typeof h?()=>h:h,g=hr(n);g.metaMap.clear(),r.length=0,o.length=0;const p=new Map;function m(e){var t;const n=null!==(t=p.get(e))&&void 0!==t?t:0;return p.set(e,n+1),0===n?e:`${e}__${n}`}const v=t[0]/2,x=t[1]/2,b=Math.min(t[0],t[1])/2*.85,k=m(c(e));r.push({id:k,x:v,y:x,x0:v,x1:v,y0:x,y1:x,width:0,height:0,value:0,depth:0,data:e}),g.metaMap.set(k,{ring:b,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,i,l,d,h,p){const v=a(t);if(!(null==v?void 0:v.length))return;const x=v.length;let b=0,k=0,w=0;for(;x>k;)k+=u[Math.min(w,u.length-1)],w++,b++;let E=0;for(let x=0;b>x;x++){const k=u[Math.min(x,u.length-1)],w=v.slice(E,E+k);if(!w.length)break;const A=(x+1)/b,M={id:n,depth:h,data:t,parentId:n},S=p?d/f(M)*A:d*A,P=s.pie().value(e=>{var t;return(null===(t=a(e))||void 0===t?void 0:t.length)?4:1}).sort(null),_=P(w),C=y(M);for(let t=0;w.length>t;t++){const a=(_[t].startAngle+_[t].endAngle)/2,s=w[t],u=m(c(s)),d=i+S*Math.sin(a),f=l+S*Math.cos(a)*C;r.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:h,data:s}),g.metaMap.set(u,{ring:S,angle:a,depth:h,parentId:n,eccentricity:C}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(s,u,d,f,S,h+1,!0)}E+=k}}(e,k,v,x,b,1,!1)}(o,r,n,e,t)},buildScene(e,t,n,r){var o,i,l,a,s;const c=n.nodeStyle,u=n.nodeSize,d="number"==typeof u?()=>u:"function"==typeof u?u:()=>6,h=[],f=[],y=[];if(!1!==n.orbitShowRings){const t=hr(n),r=new Map;for(const t of e)r.set(t.id,t);const o=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=r.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;o.has(n)||o.set(n,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,l={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:n,ecc:r}]of o)for(let o=0;i>o;o++){const a=o/i*Math.PI*2,s=(o+1)/i*Math.PI*2;f.push({type:"line",x1:e+n*Math.sin(a),y1:t+n*Math.cos(a)*r,x2:e+n*Math.sin(s),y2:t+n*Math.cos(s)*r,style:l,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=d(Vn(t,"nodeSize")),n=c?c(Vn(t,"nodeStyle")):{},r={fill:n.fill||"#6366f1",stroke:n.stroke||"#fff",strokeWidth:null!==(o=n.strokeWidth)&&void 0!==o?o:1,opacity:null!==(i=n.opacity)&&void 0!==i?i:0===(null!==(l=t.depth)&&void 0!==l?l:0)?1:.85};h.push({type:"circle",cx:t.x,cy:t.y,r:e,style:r,datum:t,id:t.id,label:t.id,depth:t.depth})}const g=new Map;for(const t of e)g.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:g.get(e.source),n="object"==typeof e.target?e.target:g.get(e.target);t&&n&&(null!=t.x&&null!=n.x&&f.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=d(Vn(n,"nodeSize"));if(4>=e)continue;const r="function"==typeof t?t(n):t&&null!==(s=null===(a=n.data)||void 0===a?void 0:a[t])&&void 0!==s?s:n.id;y.push({x:n.x,y:n.y+e+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:h,sceneEdges:f,labels:y}},tick:(e,t,n,r,o)=>!1!==n.orbitAnimated&&(function(e,t){var n,r;const o=hr(t),i=null!==(n=t.orbitSpeed)&&void 0!==n?n:.25,l=null!==(r=t.orbitRevolution)&&void 0!==r?r:function(e){switch(e){case"decay":return e=>{var t;return Math.pow(.6,null!==(t=e.depth)&&void 0!==t?t:0)};case"alternate":return e=>{var t;const n=null!==(t=e.depth)&&void 0!==t?t:0;return(n%2==0?1:-1)/(n+1)};default:return e=>{var t;return 1/((null!==(t=e.depth)&&void 0!==t?t:0)+1)}}}(t.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,s=i*(Math.PI/6),c=new Map;for(const t of e)c.set(t.id,t);for(const t of e){const e=o.metaMap.get(t.id);if(!e||!e.parentId)continue;const n=c.get(e.parentId);if(!n)continue;const r=e.angle+a*s*l({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=n.x+e.ring*Math.sin(r),t.y=n.y+e.ring*Math.cos(r)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)},yr={sankey:Un,force:Kn,chord:tr,tree:sr,cluster:sr,treemap:sr,circlepack:sr,partition:sr,orbit:fr};function gr(e){return yr[e]}class pr{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.particlePool=null,this.transition=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._lastPositionSnapshot=null,this.config=e,this.tensionConfig=Object.assign(Object.assign({},Qt),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new en(2e3))}updateConfig(e){const t=this.config,n=e;t.__orbitState&&(n.__orbitState=t.__orbitState),t.__hierarchyRoot&&(n.__hierarchyRoot=t.__hierarchyRoot),this.config=e,this.tensionConfig=Object.assign(Object.assign({},Qt),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&!this.particlePool&&(this.particlePool=new en(2e3))}ingestHierarchy(e,t){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.config.__hierarchyRoot=e,this.runLayout(t)}ingestBounded(e,t,n){const{nodeIDAccessor:r="id",sourceAccessor:o="source",targetAccessor:i="target",valueAccessor:l="value"}=this.config,a="function"==typeof r?r:e=>e[r],s="function"==typeof o?o:e=>e[o],c="function"==typeof i?i:e=>e[i],u="function"==typeof l?l:e=>{var t;return null!==(t=e[l])&&void 0!==t?t:1};this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const t of e){const e=a(t)+"";this.nodes.set(e,Object.assign(Object.assign({},mr(e)),{data:t}))}for(let e=0;t.length>e;e++){const n=t[e],r=s(n)+"",o=c(n)+"",i=Number(u(n))||1;this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},mr(r)),{data:n})),this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},mr(o)),{data:n}));const l=`${r}\0${o}\0${e}`;this.edges.set(l,{source:r,target:o,value:i,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:l})}this.runLayout(n)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:n,value:r}=e,o=0===this.nodes.size;let i=!1;const l="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=l,this._decaySortedNodes=null,this.nodes.has(t)||(this.nodes.set(t,mr(t)),this.nodeTimestamps.set(t,l),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,mr(n)),this.nodeTimestamps.set(n,l),this.tension+=this.tensionConfig.newNode,i=!0);const a=this.edgeKey(t,n),s=this.edges.get(a);let c=!1;return s?(s.value+=r,this.edgeTimestamps.set(a,l),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(a,{source:t,target:n,value:r,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(a,l),this.tension+=this.tensionConfig.newEdge,i=!0),o||i||c||this.tension>=this.tensionConfig.threshold}runLayout(e){var t,n,r,o,i,l;const a=gr(this.config.chartType);if(!a)return;let s=Array.from(this.nodes.values()),c=Array.from(this.edges.values());if(0===s.length&&!a.hierarchical)return;if(this.prepareForRelayout(),a.supportsStreaming&&!a.hierarchical){const e=new Map;for(const a of s)if(void 0!==a._prevX0){const s=(null!==(t=a._prevX1)&&void 0!==t?t:0)-(null!==(n=a._prevX0)&&void 0!==n?n:0),c=(null!==(r=a._prevY1)&&void 0!==r?r:0)-(null!==(o=a._prevY0)&&void 0!==o?o:0);e.set(a.id,{x:(null!==(i=a._prevX0)&&void 0!==i?i:0)+s/2,y:(null!==(l=a._prevY0)&&void 0!==l?l:0)+c/2})}else 0===a.x&&0===a.y||e.set(a.id,{x:a.x,y:a.y});if(this._lastPositionSnapshot)for(const[t,n]of this._lastPositionSnapshot)e.has(t)||e.set(t,n);this.config.__previousPositions=e.size>0?e:void 0}if(a.computeLayout(s,c,this.config,e),delete this.config.__previousPositions,a.hierarchical&&s.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of s)this.nodes.set(e.id,e);for(let e=0;c.length>e;e++){const t=c[e],n=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=n,this.edges.set(n,t)}}this.finalizeLayout();const u=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||u.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=u,this.saveTargetPositions(),s.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1))&&this.tensionConfig.transitionDuration>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:this.tensionConfig.transitionDuration});const d=new Set(this.nodes.keys()),h=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of d)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)d.has(e)||this.removedNodes.add(e);for(const e of h)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)h.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=d,this.previousEdgeKeys=h,this.layoutVersion++}buildScene(e){const t=gr(this.config.chartType);if(!t)return;const n=Array.from(this.nodes.values()),r=Array.from(this.edges.values()),{sceneNodes:o,sceneEdges:i,labels:l}=t.buildScene(n,r,this.config,e);this.sceneNodes=o,this.sceneEdges=i,this.labels=l}get isAnimating(){const e=gr(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=gr(this.config.chartType);if(!(null==n?void 0:n.tick))return!1;const r=Array.from(this.nodes.values()),o=Array.from(this.edges.values());return n.tick(r,o,this.config,e,t)}advanceTransition(e){if(!this.transition)return!1;const t=N(e,this.transition),n=T(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=O(e._prevX0,e._targetX0,n),e.x1=O(e._prevX1,e._targetX1,n),e.y0=O(e._prevY0,e._targetY0,n),e.y1=O(e._prevY1,e._targetY1,n));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=O(e._prevY0,e._targetY0,n),e.y1=O(e._prevY1,e._targetY1,n),e.sankeyWidth=O(e._prevSankeyWidth,e._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){for(const e of this.nodes.values())e._prevX0=e.x0,e._prevX1=e.x1,e._prevY0=e.y0,e._prevY1=e.y1;for(const e of this.edges.values())e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth);this.rebuildAllBeziers()}updateEdgeBezier(e){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,n="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&n&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,n))}buildStandardBezier(e,t,n){const r=(e.sankeyWidth||1)/2;if("down"===e.direction){const o=t.x1,i=n.x0,l=u.interpolateNumber(o,i);return{circular:!1,points:[{x:e.y0,y:o},{x:e.y0,y:l(.5)},{x:e.y1,y:l(.5)},{x:e.y1,y:i}],halfWidth:r}}const o=t.x1,i=n.x0,l=u.interpolateNumber(o,i);return{circular:!1,points:[{x:o,y:e.y0},{x:l(.5),y:e.y0},{x:l(.5),y:e.y1},{x:i,y:e.y1}],halfWidth:r}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),r=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-r,y:n.targetY},{x:n.targetX-.66*r,y:n.targetY},{x:n.targetX-.33*r,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let r;r="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const o=[];for(let e=0;r.length-1>e;e++){const t=r[e],n=r[e+1],i=n.x-t.x,l=n.y-t.y;o.push([t,{x:t.x+i/3,y:t.y+l/3},{x:t.x+2*i/3,y:t.y+2*l/3},n])}return{circular:!0,segments:o,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){var t,n,r,o,i;const l=this.config.pulse;if(!l)return;const a=null!==(t=l.duration)&&void 0!==t?t:500,s=null!==(n=l.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(r=l.glowRadius)&&void 0!==r?r:4;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const r=this.nodeTimestamps.get(n);if(!r)continue;const o=e-r;a>o&&(t._pulseIntensity=1-o/a,t._pulseColor=s,t._pulseGlowRadius=c)}for(const t of this.sceneEdges){const n=t.datum;if(!n)continue;const r="object"==typeof n.source?null===(o=n.source)||void 0===o?void 0:o.id:n.source,l="object"==typeof n.target?null===(i=n.target)||void 0===i?void 0:i.id:n.target;if(!r||!l)continue;const c=this.edgeTimestamps.get(`${r}\0${l}`);if(!c)continue;const u=e-c;a>u&&(t._pulseIntensity=1-u/a,t._pulseColor=s)}}applyDecay(){var e,t,n,r,o;const i=this.config.decay;if(!i)return;const l=null!==(e=i.minOpacity)&&void 0!==e?e:.1,a=this.nodeTimestamps.size;if(1>=a)return;this._decaySortedNodes||(this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]));const s=this._decaySortedNodes,c=new Map;for(let e=0;s.length>e;e++)c.set(s[e][0],e);for(const e of this.sceneNodes){const s=e.id;if(!s)continue;const u=c.get(s);if(void 0===u)continue;const d=a-1-u;let h;switch(i.type){case"linear":h=l+(1-d/(a-1))*(1-l);break;case"exponential":{const e=null!==(t=i.halfLife)&&void 0!==t?t:a/2;h=l+Math.pow(.5,d/e)*(1-l);break}case"step":h=(null!==(n=i.stepThreshold)&&void 0!==n?n:.5*a)>d?1:l;break;default:h=1}const f=null!==(o=null===(r=e.style)||void 0===r?void 0:r.opacity)&&void 0!==o?o:1;e.style=Object.assign(Object.assign({},e.style),{opacity:f*h})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const n=e-this.lastTopologyChangeTime;if(n>=2e3)return;const r=1-n/2e3;for(const e of this.sceneNodes){const n=e.id;n&&this.addedNodes.has(n)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,r),e._pulseColor="rgba(34, 197, 94, 0.7)",e._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(e){var t,n;const r=this.config.thresholds;if(!r)return;const o=null!==(t=r.warningColor)&&void 0!==t?t:"#f59e0b",i=null!==(n=r.criticalColor)&&void 0!==n?n:"#ef4444",l=!1!==r.pulse;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const a=this.nodes.get(n);if(!a)continue;const s=r.metric(a);let c=null;void 0===r.critical||r.critical>s?void 0===r.warning||r.warning>s||(c=o):c=i,c&&(t.style=Object.assign(Object.assign({},t.style),{fill:c}),l&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=c,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const n=e.metric(t);if(void 0!==e.warning&&n>=e.warning||void 0!==e.critical&&n>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const n="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>n-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function mr(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function vr(e,t,n,r,o=30){let i=null,l=o,a=1/0;for(const t of e){const e=xr(t,n,r,o);if(e)if("rect"===t.type){const n=t.w*t.h;a>n&&(i=e,a=n)}else l>e.distance&&(i=e,l=e.distance)}if(i)return i;for(const e of t){const t=Er(e,n,r);t&&l>t.distance&&(i=t,l=t.distance)}return i}function xr(e,t,n,r=30){switch(e.type){case"circle":return function(e,t,n,r=30){const o=t-e.cx,i=n-e.cy,l=Math.sqrt(o*o+i*i);return l>V(e.r,r)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:l}}(e,t,n,r);case"rect":return function(e,t,n){const r=G(t,n,e);return r.hit?{type:"node",datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}(e,t,n);case"arc":return function(e,t,n){const r=t-e.cx,o=n-e.cy,i=Math.sqrt(r*r+o*o);if(e.innerR-2>i||i>e.outerR+2)return null;const l=K(Math.atan2(o,r)),a=K(e.startAngle),s=K(e.endAngle);if(a>s?l>=a||s>=l:l>=a&&s>=l){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(e,t,n);default:return null}}let br=null,kr=null;function wr(){return kr||(br=document.createElement("canvas"),br.width=1,br.height=1,kr=br.getContext("2d")),kr}function Er(e,t,n){switch(e.type){case"bezier":return function(e,t,n){var r,o;if(!e.pathD)return null;try{const i=new Path2D(e.pathD),l=wr();if(!l)return null;if(l.isPointInPath(i,t,n)){const i="object"==typeof(null===(r=e.datum)||void 0===r?void 0:r.source)?e.datum.source:null,l="object"==typeof(null===(o=e.datum)||void 0===o?void 0:o.target)?e.datum.target:null;return{type:"edge",datum:e.datum,x:i&&l?(i.x1+l.x0)/2:t,y:e.datum?(e.datum.y0+e.datum.y1)/2:n,distance:0}}const a=l.lineWidth;l.lineWidth=10;const s=l.isPointInStroke(i,t,n);if(l.lineWidth=a,s)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch(e){}return null}(e,t,n);case"line":return function(e,t,n){const r=e.x2-e.x1,o=e.y2-e.y1,i=r*r+o*o;if(0===i)return null;let l=((t-e.x1)*r+(n-e.y1)*o)/i;l=Math.max(0,Math.min(1,l));const a=e.x1+l*r,s=e.y1+l*o,c=Math.sqrt(Math.pow(t-a,2)+Math.pow(n-s,2));return c>5?null:{type:"edge",datum:e.datum,x:a,y:s,distance:c}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;try{const r=new Path2D(e.pathD),o=wr();if(!o)return null;if(o.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const l=o.isPointInStroke(r,t,n);if(o.lineWidth=i,l)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch(e){}return null}(e,t,n);default:return null}}function Ar(e){const{width:t,height:n,totalWidth:r,totalHeight:o,margin:i,labels:l,title:a,legend:s,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h,legendPosition:f="right",foregroundGraphics:y,sceneNodes:p,annotations:m,svgAnnotationRules:v}=e;return g.createElement(g.Fragment,null,g.createElement("svg",{role:"img",width:r,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},g.createElement("title",null,"string"==typeof a?a:"Network Chart"),g.createElement("desc",null,"string"==typeof a?a+" — network data visualization":"Network data visualization"),g.createElement("g",{transform:`translate(${i.left},${i.top})`},l.map((e,t)=>g.createElement("text",{key:"label-"+t,x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"currentColor",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"}},e.text)),m&&m.filter(e=>"widget"!==e.type).map((e,r)=>{if(v){const o=v(e,r,{width:t,height:n,sceneNodes:p});if(o)return g.createElement(g.Fragment,{key:"annotation-"+r},o)}return null}),y),a&&"string"==typeof a?g.createElement("text",{x:r/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},a):a?g.createElement("foreignObject",{x:0,y:0,width:r,height:i.top},a):null,be({legend:s,totalWidth:r,totalHeight:o,margin:i,legendPosition:f,title:a,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h})),null==m?void 0:m.filter(e=>"widget"===e.type&&e.nodeId&&p).map((e,t)=>{var n,r,o,l,a,s,c,u,d;const h=p.find(t=>{var n,r,o,i,l;return t.id===e.nodeId||(null===(n=t.datum)||void 0===n?void 0:n.id)===e.nodeId||(null===(o=null===(r=t.datum)||void 0===r?void 0:r.data)||void 0===o?void 0:o.id)===e.nodeId||(null===(l=null===(i=t.datum)||void 0===i?void 0:i.data)||void 0===l?void 0:l.name)===e.nodeId});if(!h)return null;const f=i.left+(null!==(n=h.cx)&&void 0!==n?n:null!=h.x&&null!=h.w?h.x+h.w/2:null!==(r=h.x)&&void 0!==r?r:0),y=i.top+(null!==(o=h.cy)&&void 0!==o?o:null!=h.y&&null!=h.h?h.y+h.h/2:null!==(l=h.y)&&void 0!==l?l:0),m=null!==(a=e.dx)&&void 0!==a?a:0,v=null!==(s=e.dy)&&void 0!==s?s:-16,x=null!==(c=e.width)&&void 0!==c?c:32,b=null!==(u=e.height)&&void 0!==u?u:32,k=null!==(d=e.content)&&void 0!==d?d:g.createElement("span",{style:{fontSize:18,cursor:"default"}},"ℹ️");return g.createElement("div",{key:"widget-"+t,style:{position:"absolute",left:f+m-x/2,top:y+v-b/2,width:x,height:b,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5}},k)}))}function Mr(e,t){var n,r,o,i,l,a;if(!t.pathD)return;e.save();const s=new Path2D(t.pathD);if(t.style.fill&&"none"!==t.style.fill){const l=t._gradient;if(l){const o=e.createLinearGradient(l.x0,0,l.x1,0),i=null!==(r=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==r?r:.5,a="string"==typeof t.style.fill?t.style.fill:"#999";o.addColorStop(0,1===l.from?a:"transparent"),o.addColorStop(1,1===l.to?a:"transparent"),e.fillStyle=o,e.globalAlpha=i}else e.fillStyle=t.style.fill,e.globalAlpha=null!==(i=null!==(o=t.style.fillOpacity)&&void 0!==o?o:t.style.opacity)&&void 0!==i?i:.5;e.fill(s)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(l=t.style.strokeWidth)&&void 0!==l?l:.5,e.globalAlpha=.5*(null!==(a=t.style.opacity)&&void 0!==a?a:1),e.stroke(s)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(s)),e.restore()}function Sr(e,t){var n,r;e.save(),e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(r=t.style.strokeWidth)&&void 0!==r?r:1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function Pr(e,t){var n,r,o,i;if(!t.pathD)return;e.save();const l=new Path2D(t.pathD);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(r=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==r?r:.5,e.fill(l)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:.5,e.globalAlpha=.3*(null!==(i=t.style.opacity)&&void 0!==i?i:1),e.stroke(l)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(l)),e.restore()}function _r(e,t){var n,r;if(!t.pathD)return;e.save();const o=new Path2D(t.pathD);e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(o),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(r=t.style.fillOpacity)&&void 0!==r?r:.1,e.fill(o)),e.restore()}Ar.displayName="NetworkSVGOverlay";const Cr={top:20,right:80,bottom:20,left:80},Dr={top:40,right:40,bottom:40,left:40},Lr=new Set(["chord","force","circlepack","orbit"]),Tr=[800,600],Nr={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Or({data:e}){var t,n,r,o,i,l;if("edge"===e.type){const t=e.data;return g.createElement("div",{className:"semiotic-tooltip",style:Nr},g.createElement("div",{style:{fontWeight:600}},"object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target),null!=t.value&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""))}const a=e.data,s=null==a?void 0:a.__hierarchyNode;if(s){const e=[];let i=s;for(;i;){const l=null!==(o=null!==(n=null===(t=i.data)||void 0===t?void 0:t.name)&&void 0!==n?n:null===(r=i.data)||void 0===r?void 0:r.id)&&void 0!==o?o:a.id;null!=l&&e.unshift(l+""),i=i.parent}e.length>1&&e.shift();const l=e.length-1;return g.createElement("div",{className:"semiotic-tooltip",style:Nr},g.createElement("div",null,e.map((e,t)=>g.createElement("span",{key:t},t>0&&g.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),t===l?g.createElement("strong",null,e):g.createElement("span",{style:{opacity:.7}},e)))),null!=a.value&&a.value>0&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof a.value?a.value.toLocaleString():a.value+""))}const c=((null===(i=a.sourceLinks)||void 0===i?void 0:i.length)||0)+((null===(l=a.targetLinks)||void 0===l?void 0:l.length)||0),u=(a.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(a.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return g.createElement("div",{className:"semiotic-tooltip",style:Nr},g.createElement("div",{style:{fontWeight:600}},a.id),null!=a.value&&a.value>0&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof a.value?a.value.toLocaleString():a.value+""),c>0&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",c,u!==c&&` (weighted: ${u.toLocaleString()})`))}const $r=e.forwardRef(function(t,n){var r,o,i,l,a,c,u,d,h,f,y,p,m,v;const{chartType:x,nodes:b,edges:k,data:w,initialEdges:E,nodeIDAccessor:A="id",sourceAccessor:M="source",targetAccessor:S="target",valueAccessor:P="value",childrenAccessor:C,hierarchySum:D,orientation:L="horizontal",nodeAlign:T="justify",nodePaddingRatio:N=.05,nodeWidth:O=15,iterations:$=300,forceStrength:W=.1,padAngle:I=.01,groupWidth:z=20,sortGroups:R,edgeSort:B,treeOrientation:j="vertical",edgeType:F="curve",padding:Y,paddingTop:H,tensionConfig:X,showParticles:G=!1,particleStyle:V,nodeStyle:q,edgeStyle:U,colorBy:K,colorScheme:Z="category10",edgeColorBy:Q="source",edgeOpacity:J=.5,colorByDepth:ee=!1,nodeSize:te=8,nodeSizeRange:ne=[5,20],nodeLabel:re,showLabels:oe=!0,labelMode:ie,size:le=Tr,responsiveWidth:ue,responsiveHeight:de,margin:ye,className:ge,background:pe,enableHover:me=!0,tooltipContent:ve,customHoverBehavior:xe,customClickBehavior:be,onObservation:ke,chartId:we,onTopologyChange:Ee,annotations:Ae,svgAnnotationRules:Me,legend:Se,legendPosition:Pe,legendHoverBehavior:_e,legendClickBehavior:Ce,legendHighlightedCategory:De,legendIsolatedCategories:Le,title:Te,foregroundGraphics:Ne,backgroundGraphics:Oe,decay:$e,pulse:We,staleness:Ie,thresholds:ze,accessibleTable:Re=!0,description:Be,summary:je,orbitMode:Fe,orbitSize:Ye,orbitSpeed:He,orbitRevolution:Xe,orbitRevolutionStyle:Ge,orbitEccentricity:Ve,orbitShowRings:Ke,orbitAnimated:Ze}=t,Qe=mt(),Je=e.useRef(Qe);Je.current=Qe;const tt="semiotic-table-"+g.useId(),nt=Lr.has(x)?Dr:Cr,[rt,ot]=he(le,ue,de),it=Object.assign(Object.assign({},nt),ye),lt=ot[0]-it.left-it.right,at=ot[1]-it.top-it.bottom,st="function"==typeof Ne?Ne({size:ot,margin:it}):Ne,ct=e.useMemo(()=>Object.assign(Object.assign({},Qt),X),[X]),yt=e.useMemo(()=>Object.assign(Object.assign({},Jt),V),[V]),vt=e.useMemo(()=>({chartType:x,nodeIDAccessor:A,sourceAccessor:M,targetAccessor:S,valueAccessor:P,childrenAccessor:C,hierarchySum:D,orientation:L,nodeAlign:T,nodePaddingRatio:N,nodeWidth:O,iterations:$,forceStrength:W,padAngle:I,groupWidth:z,sortGroups:R,edgeSort:B,treeOrientation:j,edgeType:F,padding:Y,paddingTop:H,tensionConfig:ct,showParticles:G,particleStyle:yt,nodeStyle:q,edgeStyle:U,nodeLabel:re,showLabels:oe,labelMode:ie,colorBy:K,colorScheme:Z,edgeColorBy:Q,edgeOpacity:J,colorByDepth:ee,nodeSize:te,nodeSizeRange:ne,decay:$e,pulse:We,staleness:Ie,thresholds:ze,orbitMode:Fe,orbitSize:Ye,orbitSpeed:He,orbitRevolution:Xe,orbitRevolutionStyle:Ge,orbitEccentricity:Ve,orbitShowRings:Ke,orbitAnimated:Ze}),[x,A,M,S,P,C,D,L,T,N,O,$,W,I,z,R,B,j,F,Y,H,ct,G,yt,q,U,re,oe,ie,K,Z,Q,J,ee,te,ne,$e,We,Ie,ze,Fe,Ye,He,Xe,Ge,Ve,Ke,Ze]),xt=e.useRef(null),bt=e.useRef(0),kt=e.useRef(0),wt=e.useRef(!0),Et=At(e=>e.theme),Pt=e.useRef(()=>{}),_t=e.useRef(null);_t.current||(_t.current=new pr(vt));const[Ct,Dt]=e.useState(null),[Lt,Ot]=e.useState(0),[$t,Wt]=e.useState(0),[It,zt]=e.useState(!1),Rt=e.useRef(null),Bt=e.useRef(new Map),jt=e.useRef(0),Ft=e.useCallback(e=>{if("function"==typeof K)return K(e)+"";if("string"==typeof K&&e.data){const t=e.data[K];if(void 0!==t){if(!Bt.current.has(t+"")){const e=Array.isArray(Z)?Z:_;Bt.current.set(t+"",e[jt.current++%e.length])}return Bt.current.get(t+"")}}if(Bt.current.has(e.id))return Bt.current.get(e.id);const t=Array.isArray(Z)?Z:_,n=K?t[jt.current++%t.length]:t[0];return Bt.current.set(e.id,n),n},[K,Z]),Yt=e.useCallback(e=>{if("function"==typeof Q)return Q(e);const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;return"target"===Q&&n?Ft(n):t?Ft(t):"#999"},[Q,Ft]),Ht=e.useCallback(e=>{if(!(null==V?void 0:V.colorBy))return Yt(e);const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;return"target"===yt.colorBy&&n?Ft(n):t?Ft(t):"#999"},[null==V?void 0:V.colorBy,yt.colorBy,Ft,Yt]),Xt="sankey"===x&&G||!!We||null!==(o=null===(r=_t.current)||void 0===r?void 0:r.isAnimating)&&void 0!==o&&o,Gt=e.useCallback(()=>{bt.current&&!Xt||bt.current||(bt.current=requestAnimationFrame(()=>Pt.current()))},[Xt]);e.useEffect(()=>{var e;null===(e=_t.current)||void 0===e||e.updateConfig(vt),wt.current=!0,Gt()},[vt,Gt]),e.useEffect(()=>{wt.current=!0,Gt()},[Et,Gt]);const Vt=e.useCallback(()=>{var e;const t=_t.current;if(!t)return;t.runLayout([lt,at]),t.buildScene([lt,at]),wt.current=!0;for(const n of t.sceneNodes)n.id&&"string"==typeof(null===(e=n.style)||void 0===e?void 0:e.fill)&&Bt.current.set(n.id,n.style.fill);const n=Array.isArray(Z)?Z:_,r=Array.from(t.nodes.values());for(let e=0;r.length>e;e++){const t=r[e];Bt.current.has(t.id)||Bt.current.set(t.id,n[e%n.length])}if(jt.current=r.length,Ot(t.layoutVersion),Ee){const{nodes:e,edges:n}=t.getLayoutData();Ee(e,n)}},[lt,at,Ee,Z]),qt=e.useCallback(e=>{const t=_t.current;t&&(t.ingestEdge(e)&&Vt(),Gt())},[Vt,Gt]),Ut=e.useCallback(e=>{const t=_t.current;if(!t)return;let n=!1;for(const r of e)t.ingestEdge(r)&&(n=!0);n&&Vt(),Gt()},[Vt,Gt]),Kt=e.useCallback(()=>{var e;null===(e=_t.current)||void 0===e||e.clear(),Bt.current.clear(),jt.current=0,Ot(0),Dt(null),Rt.current=null,wt.current=!0,Gt()},[Gt]),Zt=e.useCallback(()=>{const e=_t.current;e&&(e.tension+=999,Vt(),Gt())},[Vt,Gt]);e.useImperativeHandle(n,()=>({push:qt,pushMany:Ut,clear:Kt,getTopology:()=>{var e,t;return null!==(t=null===(e=_t.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=_t.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:Zt,getTension:()=>{var e,t;return null!==(t=null===(e=_t.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[qt,Ut,Kt,Zt]);const en=["tree","cluster","treemap","circlepack","partition","orbit"].includes(x),tn=en?w||(Array.isArray(k)?void 0:k):void 0;e.useEffect(()=>{var e;const t=_t.current;if(t)if(en&&tn)t.ingestHierarchy(tn,[lt,at]),t.buildScene([lt,at]),wt.current=!0,Gt();else{const n=b||[],r=Array.isArray(k)?k:[];if(0===n.length&&0===r.length)return;t.ingestBounded(n,r,[lt,at]),t.buildScene([lt,at]);for(const n of t.sceneNodes)n.id&&(null===(e=n.style)||void 0===e?void 0:e.fill)&&Bt.current.set(n.id,n.style.fill+"");const o=Array.isArray(Z)?Z:_,i=Array.from(t.nodes.values());for(let e=0;i.length>e;e++){const t=i[e];Bt.current.has(t.id)||Bt.current.set(t.id,o[e%o.length])}jt.current=i.length,wt.current=!0,Gt()}},[b,k,w,tn,en,lt,at,vt,Gt,Z]),e.useEffect(()=>{E&&E.length>0&&Ut(E)},[]);const nn=e.useCallback(e=>{if(xe&&xe(e),ke){const t=Date.now();ke(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:we}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:we})}},[xe,ke,we]),rn=e.useCallback(e=>{if(be&&be(e),ke){const t=Date.now();ke(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:we}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:we})}},[be,ke,we]),on=e.useRef(()=>{}),ln=e.useRef(()=>{});on.current=e=>{if(!me)return;const t=xt.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-it.left,o=e.clientY-n.top-it.top;if(0>r||r>lt||0>o||o>at)return void(Rt.current&&(Rt.current=null,Dt(null),nn&&(nn(null),wt.current=!0),Gt()));const i=_t.current;if(!i)return;const l=vr(i.sceneNodes,i.sceneEdges,r,o);if(!l)return void(Rt.current&&(Rt.current=null,Dt(null),nn&&(nn(null),wt.current=!0),Gt()));const a=l.datum||{},s=Object.assign(Object.assign({},"object"!=typeof a||null===a||Array.isArray(a)?{}:a),{type:l.type,data:a,x:l.x,y:l.y});Rt.current=s,Dt(s),nn&&(nn(s),wt.current=!0),Gt()},ln.current=()=>{Rt.current&&(Rt.current=null,Dt(null),nn&&(nn(null),wt.current=!0),Gt())};const an=e.useRef(()=>{});an.current=e=>{if(!be&&!ke)return;const t=xt.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-it.left,o=e.clientY-n.top-it.top;if(0>r||r>lt||0>o||o>at)return;const i=_t.current;if(!i)return;const l=vr(i.sceneNodes,i.sceneEdges,r,o);if(l){const e=l.datum||{};rn(Object.assign(Object.assign({},"object"!=typeof e||null===e||Array.isArray(e)?{}:e),{type:l.type,data:e,x:l.x,y:l.y}))}else rn(null)},e.useCallback(e=>on.current(e),[]);const sn=e.useCallback(()=>ln.current(),[]),cn=e.useCallback(e=>an.current(e),[]),un=e.useRef(-1),dn=e.useRef(null),hn=e.useRef(-1),fn=e.useCallback(e=>{var t;const n=_t.current;if(!n)return;const r=function(e){var t,n,r,o,i,l;const a=[];for(const s of e)"circle"===s.type&&null!=s.cx?a.push({x:s.cx,y:s.cy,datum:s.datum,shape:"circle",group:null!==(n=null===(t=s.datum)||void 0===t?void 0:t.id)&&void 0!==n?n:"_default"}):"rect"===s.type&&null!=s.x?a.push({x:s.x+s.w/2,y:s.y+s.h/2,datum:s.datum,shape:"rect",w:s.w,h:s.h,group:null!==(o=null===(r=s.datum)||void 0===r?void 0:r.id)&&void 0!==o?o:"_default"}):"arc"===s.type&&null!=s.cx&&a.push({x:s.cx,y:s.cy,datum:s.datum,shape:"circle",group:null!==(l=null===(i=s.datum)||void 0===i?void 0:i.id)&&void 0!==l?l:"_default"});return a.sort((e,t)=>e.x-t.x||e.y-t.y),a}(n.sceneNodes);if(0===r.length)return;const o=ae(r),i=un.current;if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),un.current=0,hn.current=-1;const t=o.flat[0];dn.current={shape:t.shape,w:t.w,h:t.h};const n=t.datum||{},r=Object.assign(Object.assign({},"object"!=typeof n||null===n||Array.isArray(n)?{}:n),{type:"node",data:n,x:t.x,y:t.y});return Rt.current=r,Dt(r),nn&&(nn(r),wt.current=!0),void Gt()}const l=se(o,i),a=function(e,t,n,r,o){var i,l,a;const s=n.flat[t.flatIndex];if(!s)return ce(e,t,n);const c=null===(i=s.datum)||void 0===i?void 0:i.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const r=null!==(l=function(e,t,n){let r=null,o=1/0;for(let i=0;e.flat.length>i;i++){const l=e.flat[i];if(l===t)continue;const a=l.x-t.x,s=l.y-t.y;let c=!1;switch(n){case"right":c=a>0&&Math.abs(a)>=Math.abs(s);break;case"left":c=0>a&&Math.abs(a)>=Math.abs(s);break;case"down":c=s>0&&Math.abs(s)>=Math.abs(a);break;case"up":c=0>s&&Math.abs(s)>=Math.abs(a)}if(!c)continue;const u=a*a+s*s;o>u&&(o=u,r=i)}return r}(n,s,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up"))&&void 0!==l?l:t.flatIndex;return r!==t.flatIndex&&(o.current=-1),r}case"Enter":{if(null==c)return t.flatIndex;const e=function(e,t){var n,r,o;const i=e+"",l=[];for(const e of t){const t=null!==(n=e.datum)&&void 0!==n?n:e,a="object"==typeof t.source?null===(r=t.source)||void 0===r?void 0:r.id:t.source,s="object"==typeof t.target?null===(o=t.target)||void 0===o?void 0:o.id:t.target,c=null!=a,u=null!=s;c&&a+""===i&&u?l.push(s+""):u&&s+""===i&&c&&l.push(a+"")}return l}(c,r);if(0===e.length)return t.flatIndex;const i=null!==(a=n.idToIdx.get(e[(o.current+1)%e.length]))&&void 0!==a?a:-1;return 0>i?t.flatIndex:(o.current=-1,i)}default:{const r=ce(e,t,n);return null!==r&&r!==t.flatIndex&&(o.current=-1),r}}}(e.key,l,o,null!==(t=n.sceneEdges)&&void 0!==t?t:[],hn);if(null===a)return;if(e.preventDefault(),0>a)return un.current=-1,dn.current=null,hn.current=-1,Rt.current=null,Dt(null),nn&&(nn(null),wt.current=!0),void Gt();un.current=a;const s=o.flat[a];dn.current={shape:s.shape,w:s.w,h:s.h};const c=s.datum||{},u=Object.assign(Object.assign({},"object"!=typeof c||null===c||Array.isArray(c)?{}:c),{type:"node",data:c,x:s.x,y:s.y});Rt.current=u,Dt(u),nn&&(nn(u),wt.current=!0),Gt()},[nn,Gt]),yn=e.useCallback(e=>{un.current=-1,dn.current=null,on.current(e)},[]);Pt.current=()=>{var e,t,n,r,o,i,l;bt.current=0;const a=xt.current;if(!a)return;const s=a.getContext("2d");if(!s)return;const c=_t.current;if(!c)return;const u=performance.now(),d=kt.current?Math.min((u-kt.current)/1e3,.1):.016;kt.current=u;const h=c.advanceTransition(Je.current?u+1e6:u),f=!Je.current&&h,y=!Je.current&&c.tickAnimation([lt,at],d);(h||wt.current||y)&&c.buildScene([lt,at]);const g=St();if(!Mt(a,ot,it,g))return;s.clearRect(-it.left,-it.top,ot[0],ot[1]),pe&&(s.fillStyle=pe,s.fillRect(0,0,lt,at)),$e&&c.applyDecay(),We&&c.applyPulse(u),ze&&c.applyThresholds(u),c.applyTopologyDiff(u);const p=null!==(e=null==Ie?void 0:Ie.threshold)&&void 0!==e?e:5e3,m=Ie&&c.lastIngestTime>0&&u-c.lastIngestTime>p;if(m&&(s.globalAlpha=null!==(t=null==Ie?void 0:Ie.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const n of t)switch(n.type){case"bezier":Mr(e,n);break;case"line":Sr(e,n);break;case"ribbon":Pr(e,n);break;case"curved":_r(e,n)}}(s,c.sceneEdges),function(e,t){var n,r,o;for(const i of t){if("rect"!==i.type)continue;const t=i;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.strokeRect(t.x,t.y,t.w,t.h)),Tt(e,t),e.restore())}}(s,c.sceneNodes),function(e,t){var n,r,o;for(const i of t){if("circle"!==i.type)continue;const t=i;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.stroke()),Nt(e,t),e.restore())}}(s,c.sceneNodes),function(e,t){var n,r,o;for(const i of t){if("arc"!==i.type)continue;const t=i;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.stroke()),e.restore()}}(s,c.sceneNodes),G&&c.particlePool&&!m){const e=Array.from(c.edges.values());if(e.length>0){!function(e,t,n,r){var o,i;const l=null!==(o=r.spawnRate)&&void 0!==o?o:Jt.spawnRate,a=null!==(i=r.maxPerEdge)&&void 0!==i?i:Jt.maxPerEdge;for(let r=0;t.length>r;r++){const o=t[r];if(!o.bezier)continue;if(e.countForEdge(r)>=a)continue;const i=o.value*l*n*(o.bezier.circular?.3:1),s=Math.floor(i),c=i-s;let u=s;Math.random()<c&&u++;for(let t=0;u>t&&e.countForEdge(r)<a;t++)e.spawn(r)}}(c.particlePool,e,d,yt);const t=.5*(null!==(n=yt.speedMultiplier)&&void 0!==n?n:1);let r;if(yt.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);r=e.map(e=>.3+(e.value||1)/t*1.7)}c.particlePool.step(d,t,e,r),function(e,t,n,r,o){var i,l;const a=null!==(i=r.radius)&&void 0!==i?i:Jt.radius,s=null!==(l=r.opacity)&&void 0!==l?l:Jt.opacity;e.globalAlpha=s;for(let i=0;t.particles.length>i;i++){const l=t.particles[i];if(!l.active)continue;const s=n[l.edgeIndex];if(s){if("function"==typeof r.color){const t="object"==typeof s.source?s.source:null;e.fillStyle=t?r.color(s,t):"#666"}else e.fillStyle=r.color&&"inherit"!==r.color?r.color:o(s);e.beginPath(),e.arc(l.x,l.y,a,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(s,c.particlePool,e,yt,Ht)}}m&&(s.globalAlpha=1);const v=wt.current;if(wt.current=!1,v||f||y){const e=xt.current;e&&e.setAttribute("aria-label",et(null!==(o=null===(r=c.sceneNodes)||void 0===r?void 0:r.length)&&void 0!==o?o:0,null!==(l=null===(i=c.sceneEdges)||void 0===i?void 0:i.length)&&void 0!==l?l:0,"Network chart"))}(v||f||y)&&Wt(e=>e+1),(Xt||f||y||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff)&&(bt.current=requestAnimationFrame(()=>Pt.current()))},e.useEffect(()=>(Gt(),()=>{bt.current&&(cancelAnimationFrame(bt.current),bt.current=0)}),[Gt]),e.useEffect(()=>{wt.current=!0,Gt()},[x,lt,at,pe,Gt]),fe(Ie,_t,wt,Gt,It,zt);const gn=me&&Ct?g.createElement(pt,{x:Ct.x,y:Ct.y,containerWidth:lt,containerHeight:at,margin:it,className:"stream-network-tooltip",zIndex:2},ve?ve(Ct):g.createElement(Or,{data:Ct})):null;if(Ue){const e=_t.current;if(e){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(x),n=t?w||(Array.isArray(k)?void 0:k):void 0;if(t&&n)e.ingestHierarchy(n,[lt,at]),e.buildScene([lt,at]);else{const t=b||[],n=Array.isArray(k)?k:[];(t.length>0||n.length>0)&&(e.ingestBounded(t,n,[lt,at]),e.buildScene([lt,at]))}}const t=null!==(i=null==e?void 0:e.sceneNodes)&&void 0!==i?i:[],n=null!==(l=null==e?void 0:e.sceneEdges)&&void 0!==l?l:[],r=null!==(a=null==e?void 0:e.labels)&&void 0!==a?a:[];return g.createElement("div",{className:"stream-network-frame"+(ge?" "+ge:""),role:"img","aria-label":Be||("string"==typeof Te?Te:"Network chart"),style:{position:"relative",width:ot[0],height:ot[1]}},g.createElement(dt,{summary:je}),g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:ot[0],height:ot[1],style:{position:"absolute",left:0,top:0}},Oe&&g.createElement("g",{transform:`translate(${it.left},${it.top})`},Oe),g.createElement("g",{transform:`translate(${it.left},${it.top})`},pe&&g.createElement("rect",{x:0,y:0,width:lt,height:at,fill:pe}),n.map((e,t)=>function(e,t){switch(e.type){case"line":return g.createElement("line",{key:"net-edge-"+t,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity});case"bezier":{const n=e;return g.createElement("path",{key:"net-edge-"+t,d:n.pathD,fill:qe(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"ribbon":{const n=e;return g.createElement("path",{key:"net-edge-"+t,d:n.pathD,fill:qe(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"curved":{const n=e;return g.createElement("path",{key:"net-edge-"+t,d:n.pathD,fill:qe(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity})}default:return null}}(e,t)).filter(Boolean),t.map((e,t)=>function(e,t){switch(e.type){case"circle":{const n=e;return g.createElement("circle",{key:"net-circle-"+t,cx:n.cx,cy:n.cy,r:n.r,fill:qe(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"rect":{const n=e;return g.createElement("rect",{key:"net-rect-"+t,x:n.x,y:n.y,width:n.w,height:n.h,fill:qe(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"arc":{const n=e,r=s.arc().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle).endAngle(n.endAngle)({})||"";return g.createElement("path",{key:"net-arc-"+t,d:r,transform:`translate(${n.cx},${n.cy})`,fill:qe(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}default:return null}}(e,t)).filter(Boolean),r.map((e,t)=>function(e,t){return g.createElement("text",{key:"net-label-"+t,x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"#333",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder},e.text)}(e,t)).filter(Boolean))),g.createElement(Ar,{width:lt,height:at,totalWidth:ot[0],totalHeight:ot[1],margin:it,labels:r,sceneNodes:t,title:Te,legend:Se,legendPosition:Pe,legendHoverBehavior:_e,legendClickBehavior:Ce,legendHighlightedCategory:De,legendIsolatedCategories:Le,foregroundGraphics:st,annotations:Ae,svgAnnotationRules:Me,annotationFrame:0}))}const pn=_t.current;return g.createElement("div",{ref:rt,className:"stream-network-frame"+(ge?" "+ge:""),role:"group","aria-label":Be||("string"==typeof Te?Te:"Network chart"),tabIndex:0,style:{position:"relative",width:ue?"100%":ot[0],height:de?"100%":ot[1],overflow:"visible"},onKeyDown:fn},Re&&g.createElement(ht,{tableId:tt}),Re&&g.createElement(ut,{nodes:null!==(c=null==pn?void 0:pn.sceneNodes)&&void 0!==c?c:[],edges:null!==(u=null==pn?void 0:pn.sceneEdges)&&void 0!==u?u:[],chartType:"Network chart",tableId:tt,chartTitle:"string"==typeof Te?Te:void 0}),g.createElement(dt,{summary:je}),g.createElement("div",{role:"img","aria-label":Be||("string"==typeof Te?Te:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:me?yn:void 0,onMouseLeave:me?sn:void 0,onClick:be||ke?cn:void 0},Oe&&g.createElement("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:ot[0],height:ot[1],pointerEvents:"none",overflow:"visible"}},g.createElement("g",{transform:`translate(${it.left},${it.top})`},Oe)),g.createElement("canvas",{ref:xt,"aria-label":et(null!==(h=null===(d=null==pn?void 0:pn.sceneNodes)||void 0===d?void 0:d.length)&&void 0!==h?h:0,null!==(y=null===(f=null==pn?void 0:pn.sceneEdges)||void 0===f?void 0:f.length)&&void 0!==y?y:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),g.createElement(ft,{hoverPoint:Ct}),g.createElement(Ar,{width:lt,height:at,totalWidth:ot[0],totalHeight:ot[1],margin:it,labels:(null==pn?void 0:pn.labels)||[],sceneNodes:null==pn?void 0:pn.sceneNodes,title:Te,legend:Se,legendPosition:Pe,legendHoverBehavior:_e,legendClickBehavior:Ce,legendHighlightedCategory:De,legendIsolatedCategories:Le,foregroundGraphics:st,annotations:Ae,svgAnnotationRules:Me,annotationFrame:$t}),g.createElement(gt,{active:un.current>=0,hoverPoint:Ct,margin:it,size:ot,shape:null===(p=dn.current)||void 0===p?void 0:p.shape,width:null===(m=dn.current)||void 0===m?void 0:m.w,height:null===(v=dn.current)||void 0===v?void 0:v.h}),gn,(null==Ie?void 0:Ie.showBadge)&&g.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Ie.badgePosition?{top:4,left:4}:"bottom-left"===Ie.badgePosition?{bottom:4,left:4}:"bottom-right"===Ie.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:It?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},It?"STALE":"LIVE")))});function Wr(e){const t=[];for(const[n,r]of Object.entries(e.fields))if("point"===r.type)t.push(e=>r.values.has(e[n]));else{const[e,o]=r.range;t.push(t=>{const r=t[n];return r>=e&&o>=r})}return e=>t.every(t=>t(e))}function Ir(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}$r.displayName="StreamNetworkFrame";const[zr,Rr]=vt(e=>({selections:new Map,setClause(t,n){e(e=>{const r=new Map(e.selections),o=Ir(r,t),i=new Map(o.clauses);return i.set(n.clientId,n),r.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:r}})},clearClause(t,n){e(e=>{const r=e.selections.get(t);if(!r)return{};const o=new Map(e.selections),i=new Map(r.clauses);return i.delete(n),o.set(t,Object.assign(Object.assign({},r),{clauses:i})),{selections:o}})},setResolution(t,n){e(e=>{const r=new Map(e.selections),o=Ir(r,t);return r.set(t,Object.assign(Object.assign({},o),{resolution:n})),{selections:r}})},clearSelection(t){e(e=>{const n=new Map(e.selections),r=n.get(t);return r&&n.set(t,Object.assign(Object.assign({},r),{clauses:new Map})),{selections:n}})}})),[Br,jr]=vt(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function Fr(t){const n=e.useId(),r=t.clientId||n,{name:o}=t,i=Rr(e=>e.selections.get(o)),l=Rr(e=>e.setClause),a=Rr(e=>e.clearClause),s=e.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:e.useMemo(()=>i&&0!==i.clauses.size?function(e,t){const n=[];for(const[r,o]of e.clauses)"crossfilter"===e.resolution&&r===t||n.push(Wr(o));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(i,r):()=>!0,[i,r]),isActive:s,selectPoints:e.useCallback(e=>{const t={};for(const[n,r]of Object.entries(e))t[n]={type:"point",values:new Set(r)};l(o,{clientId:r,type:"point",fields:t})},[r,o,l]),selectInterval:e.useCallback(e=>{const t={};for(const[n,r]of Object.entries(e))t[n]={type:"interval",range:r};l(o,{clientId:r,type:"interval",fields:t})},[r,o,l]),clear:e.useCallback(()=>{a(o,r)},[a,o,r]),clientId:r}}function Yr({selection:t,linkedHover:n,fallbackFields:r=[],unwrapData:o=!1,onObservation:i,chartType:l,chartId:a,onClick:s,hoverHighlight:c,colorByField:u}){const d=e.useId(),h=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField}:null}(n,r),f=Fr({name:(null==t?void 0:t.name)||"__unused__"}),y=function(t){const n=t.name||"hover",{fields:r}=t,{predicate:o,isActive:i,selectPoints:l,clear:a}=Fr({name:n});return{onHover:e.useCallback(e=>{if(!e)return void a();const t={};for(const n of r){const r=e[n];void 0!==r&&(t[n]=[r])}Object.keys(t).length>0&&l(t)},[r,l,a,n]),predicate:o,isActive:i}}({name:(null==h?void 0:h.name)||"hover",fields:(null==h?void 0:h.fields)||r||[]}),g=jr(e=>e.pushObservation),p=t?{isActive:f.isActive,predicate:f.predicate}:null,[m,v]=e.useState(null),x=u||r[0],b=e.useMemo(()=>{if(!c||null==m||!x)return null;const e=m,t=x;return{isActive:!0,predicate:n=>{var r;return("string"==typeof n[t]?n[t]:(null!==(r=n[t])&&void 0!==r?r:"")+"")===e}}},[c,m,x]),k=e.useCallback(e=>{var t,r;if(n)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===(null==h?void 0:h.mode)&&h.xField){const e=null==t?void 0:t[h.xField];null!=e&&Number.isFinite(Number(e))&&function(e,t,n){const r=Te.positions.get(e);(null==r?void 0:r.locked)||r&&r.xValue===t&&r.sourceId===n||(Te={positions:new Map(Te.positions).set(e,{xValue:t,sourceId:n})},Oe())}(h.name||"hover",Number(e),d)}"x-position"!==(null==h?void 0:h.mode)&&y.onHover(t)}else"x-position"===(null==h?void 0:h.mode)&&$e(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&y.onHover(null);if(c&&x)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[x];v(null!=n?n+"":null)}else v(null);if(i||g){const n={timestamp:Date.now(),chartType:l||"unknown",chartId:a};if(e){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]);const l=Object.assign(Object.assign({},n),{type:"hover",datum:o||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(r=e.y)&&void 0!==r?r:0});i&&i(l),g&&g(l)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(e),g&&g(e)}}},[n,y,h,d,i,l,a,g,c,x]),w=e.useCallback(e=>{var t,n,r,o;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[h.xField];null!=n&&Number.isFinite(Number(n))&&function(e,t,n){const r=Te.positions.get(e);if(null==r?void 0:r.locked){const t=new Map(Te.positions);return t.delete(e),Te={positions:t},Oe(),!1}Te={positions:new Map(Te.positions).set(e,{xValue:t,sourceId:n,locked:!0})},Oe()}(h.name||"hover",Number(n),d)}if(e&&s){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]),s(r,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0})}if(i||g){const t={timestamp:Date.now(),chartType:l||"unknown",chartId:a};if(e){let n=e.data||e.datum||e;Array.isArray(n)&&(n=n[0]);const l=Object.assign(Object.assign({},t),{type:"click",datum:n||{},x:null!==(r=e.x)&&void 0!==r?r:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(l),g&&g(l)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});i&&i(e),g&&g(e)}}},[s,i,g,l,a,h,d]);return e.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const e=h.name||"hover";return()=>{We(e,d),$e(e,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:p,hoverSelectionHook:b,customHoverBehavior:k,customClickBehavior:w,crosshairSourceId:d}}const Hr={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 Xr(e,t,n){var r,o,i,l,a,s;const c=Hr[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(r=t.width)&&void 0!==r?r:c.width,height:null!==(o=t.height)&&void 0!==o?o:c.height,showAxes:c.showAxes,showGrid:null!==(i=t.showGrid)&&void 0!==i?i:c.showGrid,enableHover:null!==(l=t.enableHover)&&void 0!==l?l:!!t.linkedHover||c.enableHover,showLegend:null!==(a=t.showLegend)&&void 0!==a?a:c.showLegend,showLabels:null!==(s=t.showLabels)&&void 0!==s?s:c.showLabels,title:u?void 0:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,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:Gr(c.marginDefaults,t.showCategoryTicks,t.orientation)}}function Gr(e,t,n){if(!1!==t)return e;const r=Object.assign({},e);return"horizontal"===n?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}"undefined"!=typeof process&&process;const Vr={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},qr={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Ur(e,t,n,r){return!1===r||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?g.createElement("div",{style:Object.assign(Object.assign({},Vr),{width:t,height:n})},r||"No data available"):null}function Kr(e,t,n){if(!e)return null;const r=Math.min(5,Math.floor(n/40)),o=Math.max(8,Math.floor(n/(3*r))),i=Math.max(6,Math.floor(n/(2.5*r))),l=Math.floor((n-(r*(o+i)-i))/2);return g.createElement("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:r},(e,n)=>g.createElement("div",{key:n,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},qr),{position:"absolute",top:l+n*(o+i),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:o,opacity:.5+n%2*.2})})))}const Zr=e.forwardRef(function(t,n){var r,o,i,l;const a=Xr(t.mode,{width:null!==(o=null===(r=t.size)||void 0===r?void 0:r[0])&&void 0!==o?o:t.width,height:null!==(l=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==l?l:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:d="right",windowMode:h="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:m,timeExtent:v,valueExtent:x,extentPadding:b,stroke:k="#007bff",strokeWidth:w=2,strokeDasharray:E,background:A,tooltipContent:M,tooltip:S,onHover:P,annotations:_,svgAnnotationRules:C,tickFormatTime:D,tickFormatValue:L,decay:T,pulse:N,staleness:O,transition:$,linkedHover:W,selection:I,onObservation:z,chartId:R,loading:B,emptyContent:j,emphasis:F,legendPosition:Y}=t,H=a.showAxes,X=a.enableHover,G=null!=c?c:a.marginDefaults,V=null!=s?s:[a.width,a.height],q=null!=M?M:S,U=e.useRef(null),{customHoverBehavior:K}=Yr({selection:I,linkedHover:W,unwrapData:!0,onObservation:z,chartType:"RealtimeLineChart",chartId:R}),Z=e.useCallback(e=>{P&&P(e),K(e)},[P,K]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const Q=Kr(B,V[0],V[1]),J=Q?null:Ur(y,V[0],V[1],j),ee={stroke:k,strokeWidth:w,strokeDasharray:E};return Q||J||g.createElement(Zt,{ref:U,chartType:"line",runtimeMode:"streaming",size:V,margin:G,className:F?`${u||""} semiotic-emphasis-${F}`.trim():u,arrowOfTime:d,windowMode:h,windowSize:f,data:y,timeAccessor:p,valueAccessor:m,xExtent:v,yExtent:x,extentPadding:b,lineStyle:ee,showAxes:H,background:A,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:Z,annotations:_,svgAnnotationRules:C,tickFormatTime:D,tickFormatValue:L,decay:T,pulse:N,staleness:O,transition:$,legendPosition:Y})});Zr.displayName="RealtimeLineChart";const Qr=e.forwardRef(function(t,n){var r,o,i,l;const a=Xr(t.mode,{width:null!==(o=null===(r=t.size)||void 0===r?void 0:r[0])&&void 0!==o?o:t.width,height:null!==(l=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==l?l:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{binSize:s,size:c,margin:u,className:d,arrowOfTime:h="right",windowMode:f="sliding",windowSize:y=200,data:p,timeAccessor:m,valueAccessor:v,timeExtent:x,valueExtent:b,extentPadding:k,categoryAccessor:w,colors:E,fill:A,stroke:M,strokeWidth:S,gap:P,background:_,tooltipContent:C,tooltip:D,onHover:L,annotations:T,svgAnnotationRules:N,tickFormatTime:O,tickFormatValue:$,linkedHover:W,selection:I,decay:z,pulse:R,staleness:B,transition:j,onObservation:F,chartId:Y,loading:H,emptyContent:X,emphasis:G,legendPosition:V,brush:q,onBrush:U,linkedBrush:K}=t,Z=a.showAxes,Q=a.enableHover,J=null!=u?u:a.marginDefaults,ee=null!=c?c:[a.width,a.height],te=null!=C?C:D,ne=e.useRef(null),{customHoverBehavior:re}=Yr({selection:I,linkedHover:W,unwrapData:!0,onObservation:F,chartType:"RealtimeTemporalHistogram",chartId:Y}),oe=e.useCallback(e=>{L&&L(e),re(e)},[L,re]),ie=!0===q?{dimension:"x",snap:"bin"}:"x"===q?{dimension:"x"}:"object"==typeof q?q:void 0,le=(ae=K)?"string"==typeof ae?{name:ae}:ae:null;var ae;const se=function(t){const{name:n,xField:r,yField:o}=t,{predicate:i,isActive:l,selectInterval:a,clear:s}=Fr({name:n}),c=r&&o?"xyBrush":r?"xBrush":"yBrush",u=e.useCallback(e=>{if(!e)return void s();const t={};"xyBrush"===c&&Array.isArray(e)&&2===e.length?(r&&(t[r]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),o&&(t[o]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&Array.isArray(e)?r&&(t[r]=[Math.min(...e),Math.max(...e)]):"yBrush"===c&&Array.isArray(e)&&o&&(t[o]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&a(t)},[c,r,o,a,s]);return{brushInteraction:e.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:i,isActive:l,clear:s}}(Object.assign({name:(null==le?void 0:le.name)||"__unused_hist_brush__",xField:(null==le?void 0:le.xField)||("string"==typeof m?m:"time")},(null==le?void 0:le.yField)?{yField:le.yField}:{})),ce=e.useRef(se.brushInteraction);ce.current=se.brushInteraction;const ue=e.useCallback(e=>{if(U&&U(e),F&&F(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:Y}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:Y}),le){const t=ce.current;t.end(e?"xBrush"===t.brush?e.x:"yBrush"===t.brush?e.y:[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:null)}},[U,F,Y,le]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=ne.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=ne.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=ne.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=ne.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const de=Kr(H,ee[0],ee[1]),he=de?null:Ur(p,ee[0],ee[1],X),fe={};return null!=A&&(fe.fill=A),null!=M&&(fe.stroke=M),null!=S&&(fe.strokeWidth=S),null!=P&&(fe.gap=P),de||he||g.createElement(Zt,{ref:ne,chartType:"bar",runtimeMode:"streaming",size:ee,margin:J,className:G?`${d||""} semiotic-emphasis-${G}`.trim():d,arrowOfTime:h,windowMode:f,windowSize:y,data:p,timeAccessor:m,valueAccessor:v,xExtent:x,yExtent:b,extentPadding:k,binSize:s,categoryAccessor:w,barColors:E,barStyle:fe,showAxes:Z,background:_,hoverAnnotation:Q,tooltipContent:te,customHoverBehavior:oe,annotations:T,svgAnnotationRules:N,tickFormatTime:O,tickFormatValue:$,decay:z,pulse:R,staleness:B,transition:j,legendPosition:V,brush:ie||(K?{dimension:"x"}:void 0),onBrush:ie||K?ue:void 0})});Qr.displayName="RealtimeTemporalHistogram";const Jr=Qr,eo=e.forwardRef(function(t,n){var r,o,i,l;const a=Xr(t.mode,{width:null!==(o=null===(r=t.size)||void 0===r?void 0:r[0])&&void 0!==o?o:t.width,height:null!==(l=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==l?l:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:d="right",windowMode:h="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:m,timeExtent:v,valueExtent:x,extentPadding:b,categoryAccessor:k,colors:w,radius:E,fill:A,opacity:M,stroke:S,strokeWidth:P,background:_,tooltipContent:C,tooltip:D,onHover:L,annotations:T,svgAnnotationRules:N,tickFormatTime:O,tickFormatValue:$,linkedHover:W,selection:I,onObservation:z,chartId:R,loading:B,emptyContent:j,emphasis:F,legendPosition:Y}=t,H=a.showAxes,X=a.enableHover,G=null!=c?c:a.marginDefaults,V=null!=s?s:[a.width,a.height],q=null!=C?C:D,U=e.useRef(null),{customHoverBehavior:K}=Yr({selection:I,linkedHover:W,unwrapData:!0,onObservation:z,chartType:"RealtimeSwarmChart",chartId:R}),Z=e.useCallback(e=>{L&&L(e),K(e)},[L,K]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const Q=Kr(B,V[0],V[1]),J=Q?null:Ur(y,V[0],V[1],j),ee={};return null!=E&&(ee.radius=E),null!=A&&(ee.fill=A),null!=M&&(ee.opacity=M),null!=S&&(ee.stroke=S),null!=P&&(ee.strokeWidth=P),Q||J||g.createElement(Zt,{ref:U,chartType:"swarm",runtimeMode:"streaming",size:V,margin:G,className:F?`${u||""} semiotic-emphasis-${F}`.trim():u,arrowOfTime:d,windowMode:h,windowSize:f,data:y,timeAccessor:p,valueAccessor:m,xExtent:v,yExtent:x,extentPadding:b,categoryAccessor:k,barColors:w,swarmStyle:ee,showAxes:H,background:_,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:Z,annotations:T,svgAnnotationRules:N,tickFormatTime:O,tickFormatValue:$,legendPosition:Y})});eo.displayName="RealtimeSwarmChart";const to=e.forwardRef(function(t,n){var r,o,i,l;const a=Xr(t.mode,{width:null!==(o=null===(r=t.size)||void 0===r?void 0:r[0])&&void 0!==o?o:t.width,height:null!==(l=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==l?l:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:d="right",windowMode:h="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:m,timeExtent:v,valueExtent:x,extentPadding:b,positiveColor:k,negativeColor:w,connectorStroke:E,connectorWidth:A,gap:M,stroke:S,strokeWidth:P,background:_,tooltipContent:C,tooltip:D,onHover:L,annotations:T,svgAnnotationRules:N,tickFormatTime:O,tickFormatValue:$,linkedHover:W,selection:I,onObservation:z,chartId:R,loading:B,emptyContent:j,emphasis:F,legendPosition:Y}=t,H=a.showAxes,X=a.enableHover,G=null!=c?c:a.marginDefaults,V=null!=s?s:[a.width,a.height],q=null!=C?C:D,U=e.useRef(null),{customHoverBehavior:K}=Yr({selection:I,linkedHover:W,unwrapData:!0,onObservation:z,chartType:"RealtimeWaterfallChart",chartId:R}),Z=e.useCallback(e=>{L&&L(e),K(e)},[L,K]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const Q=Kr(B,V[0],V[1]),J=Q?null:Ur(y,V[0],V[1],j),ee={};return null!=k&&(ee.positiveColor=k),null!=w&&(ee.negativeColor=w),null!=E&&(ee.connectorStroke=E),null!=A&&(ee.connectorWidth=A),null!=M&&(ee.gap=M),null!=S&&(ee.stroke=S),null!=P&&(ee.strokeWidth=P),Q||J||g.createElement(Zt,{ref:U,chartType:"waterfall",runtimeMode:"streaming",size:V,margin:G,className:F?`${u||""} semiotic-emphasis-${F}`.trim():u,arrowOfTime:d,windowMode:h,windowSize:f,data:y,timeAccessor:p,valueAccessor:m,xExtent:v,yExtent:x,extentPadding:b,waterfallStyle:ee,showAxes:H,background:_,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:Z,annotations:T,svgAnnotationRules:N,tickFormatTime:O,tickFormatValue:$,legendPosition:Y})});to.displayName="RealtimeWaterfallChart";const no=e.forwardRef(function(t,n){var r,o,i,l;const a=Xr(t.mode,{width:null!==(o=null===(r=t.size)||void 0===r?void 0:r[0])&&void 0!==o?o:t.width,height:null!==(l=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==l?l:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:d="right",windowMode:h="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:m,categoryAccessor:v,timeExtent:x,valueExtent:b,extentPadding:k,heatmapXBins:w=20,heatmapYBins:E=20,aggregation:A="count",background:M,tooltipContent:S,tooltip:P,onHover:_,annotations:C,svgAnnotationRules:D,tickFormatTime:L,tickFormatValue:T,decay:N,pulse:O,staleness:$,linkedHover:W,selection:I,onObservation:z,chartId:R,loading:B,emptyContent:j,emphasis:F,legendPosition:Y}=t,H=a.showAxes,X=a.enableHover,G=null!=c?c:a.marginDefaults,V=null!=s?s:[a.width,a.height],q=null!=S?S:P,U=e.useRef(null),{customHoverBehavior:K}=Yr({selection:I,linkedHover:W,unwrapData:!0,onObservation:z,chartType:"RealtimeHeatmap",chartId:R}),Z=e.useCallback(e=>{_&&_(e),K(e)},[_,K]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const Q=Kr(B,V[0],V[1]),J=Q?null:Ur(y,V[0],V[1],j);return Q||J||g.createElement(Zt,{ref:U,chartType:"heatmap",runtimeMode:"streaming",size:V,margin:G,className:F?`${u||""} semiotic-emphasis-${F}`.trim():u,arrowOfTime:d,windowMode:h,windowSize:f,data:y,timeAccessor:p,valueAccessor:m,categoryAccessor:v,xExtent:x,yExtent:b,extentPadding:k,heatmapXBins:w,heatmapYBins:E,heatmapAggregation:A,showAxes:H,background:M,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:Z,annotations:C,svgAnnotationRules:D,tickFormatTime:L,tickFormatValue:T,decay:N,pulse:O,staleness:$,legendPosition:Y})});no.displayName="RealtimeHeatmap",exports.IncrementalExtent=w,exports.RealtimeHeatmap=no,exports.RealtimeHistogram=Jr,exports.RealtimeLineChart=Zr,exports.RealtimeSwarmChart=eo,exports.RealtimeWaterfallChart=to,exports.RingBuffer=k,exports.StreamNetworkFrame=$r,exports.StreamXYFrame=Zt;