semiotic 3.2.2 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CLAUDE.md +118 -222
  2. package/README.md +37 -17
  3. package/ai/schema.json +64 -1
  4. package/ai/system-prompt.md +3 -3
  5. package/dist/components/Tooltip/Tooltip.d.ts +6 -1
  6. package/dist/components/charts/index.d.ts +2 -0
  7. package/dist/components/charts/ordinal/BarChart.d.ts +2 -0
  8. package/dist/components/charts/ordinal/GaugeChart.d.ts +55 -0
  9. package/dist/components/charts/ordinal/GroupedBarChart.d.ts +1 -0
  10. package/dist/components/charts/ordinal/StackedBarChart.d.ts +1 -0
  11. package/dist/components/charts/ordinal/SwimlaneChart.d.ts +4 -0
  12. package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +2 -0
  13. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +2 -0
  14. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +2 -0
  15. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +2 -0
  16. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +2 -0
  17. package/dist/components/charts/shared/hooks.d.ts +5 -1
  18. package/dist/components/charts/shared/types.d.ts +14 -5
  19. package/dist/components/charts/shared/useChartSetup.d.ts +2 -0
  20. package/dist/components/charts/xy/AreaChart.d.ts +17 -2
  21. package/dist/components/charts/xy/LineChart.d.ts +14 -3
  22. package/dist/components/realtime/RingBuffer.d.ts +11 -0
  23. package/dist/components/realtime/types.d.ts +4 -0
  24. package/dist/components/semiotic-ordinal.d.ts +2 -0
  25. package/dist/components/semiotic-server.d.ts +6 -1
  26. package/dist/components/semiotic-utils.d.ts +2 -1
  27. package/dist/components/semiotic.d.ts +3 -3
  28. package/dist/components/server/animatedGif.d.ts +78 -0
  29. package/dist/components/server/renderToStaticSVG.d.ts +85 -5
  30. package/dist/components/server/staticAnnotations.d.ts +40 -0
  31. package/dist/components/server/staticLegend.d.ts +39 -0
  32. package/dist/components/server/svgHatchPattern.d.ts +26 -0
  33. package/dist/components/server/themeResolver.d.ts +35 -0
  34. package/dist/components/store/LinkedCrosshairStore.d.ts +6 -2
  35. package/dist/components/stream/CanvasHitTester.d.ts +13 -0
  36. package/dist/components/stream/GeoPipelineStore.d.ts +6 -1
  37. package/dist/components/stream/NetworkPipelineStore.d.ts +20 -0
  38. package/dist/components/stream/OrdinalPipelineStore.d.ts +11 -0
  39. package/dist/components/stream/OrdinalSVGOverlay.d.ts +6 -1
  40. package/dist/components/stream/PipelineStore.d.ts +28 -1
  41. package/dist/components/stream/SVGOverlay.d.ts +11 -5
  42. package/dist/components/stream/accessorUtils.d.ts +3 -3
  43. package/dist/components/stream/geoTypes.d.ts +2 -0
  44. package/dist/components/stream/hitTestUtils.d.ts +15 -0
  45. package/dist/components/stream/networkTypes.d.ts +33 -0
  46. package/dist/components/stream/ordinalTypes.d.ts +37 -4
  47. package/dist/components/stream/renderers/resolveCSSColor.d.ts +17 -0
  48. package/dist/components/stream/types.d.ts +58 -5
  49. package/dist/components/stream/xySceneBuilders/mixedScene.d.ts +12 -0
  50. package/dist/components/stream/xySceneBuilders/types.d.ts +15 -0
  51. package/dist/geo.min.js +1 -1
  52. package/dist/geo.module.min.js +1 -1
  53. package/dist/network.min.js +1 -1
  54. package/dist/network.module.min.js +1 -1
  55. package/dist/ordinal.min.js +1 -1
  56. package/dist/ordinal.module.min.js +1 -1
  57. package/dist/realtime.min.js +1 -1
  58. package/dist/realtime.module.min.js +1 -1
  59. package/dist/semiotic-ai.min.js +1 -1
  60. package/dist/semiotic-ai.module.min.js +1 -1
  61. package/dist/semiotic-ordinal.d.ts +2 -0
  62. package/dist/semiotic-server.d.ts +6 -1
  63. package/dist/semiotic-utils.d.ts +2 -1
  64. package/dist/semiotic-utils.min.js +1 -1
  65. package/dist/semiotic-utils.module.min.js +1 -1
  66. package/dist/semiotic.d.ts +3 -3
  67. package/dist/semiotic.min.js +1 -1
  68. package/dist/semiotic.module.min.js +1 -1
  69. package/dist/server.min.js +1 -1
  70. package/dist/server.module.min.js +1 -1
  71. package/dist/xy.min.js +1 -1
  72. package/dist/xy.module.min.js +1 -1
  73. package/package.json +21 -7
@@ -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"),a=require("d3-array"),l=require("d3-hierarchy"),s=require("d3-shape"),c=require("regression"),u=require("d3-interpolate"),d=require("d3-force"),h=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:a,margin:l,dimension:s,scales:c,onBrush:u,binSize:d,snap:h,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 a,l;if("x"===s){const[t,r]=e.selection;a=[n.x.invert(t),n.x.invert(r)],l=[n.y.invert(o),n.y.invert(0)]}else if("y"===s){const[t,o]=e.selection;a=[n.x.invert(0),n.x.invert(r)],l=[n.y.invert(o),n.y.invert(t)]}else{const[[t,r],[o,i]]=e.selection;a=[n.x.invert(t),n.x.invert(o)],l=[n.y.invert(i),n.y.invert(r)]}if("bin"===h&&"y"!==s&&("end"===e.type||"brush"===e.type&&y)){const r=A.current;r&&r.length>0?a=function(t,e){return 0===e.length?t:[m(t[0],e),v(t[1],e)]}(a,r):d&&d>0&&(a=[Math.floor(a[0]/d)*d,Math.ceil(a[1]/d)*d]);const o=n.x(a[0]),l=n.x(a[1]);if(M.current=!0,"x"===s)t.call(i.move,[o,l]);else if("xy"===s){const n=e.selection;t.call(i.move,[[o,n[0][1]],[l,n[1][1]]])}M.current=!1}const c={x:a,y:l};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,h,d,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"===h){const t=A.current;t&&t.length>0?o=v(n,t):d&&d>0&&(o=Math.ceil(n/d)*d)}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 a=c.x(o),l=c.x(t.x[1]);if(M.current=!0,"x"===s)r.call(b.current.move,[a,l]);else{const e=c.y(t.y[1]),n=c.y(t.y[0]);r.call(b.current.move,[[a,e],[l,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,h,d]),g.createElement("svg",{ref:x,width:i,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},g.createElement("g",{className:"brush-g",transform:`translate(${l.left},${l.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 a of t){const t=e(a),l=n(a);if(null==t||null==l||Number.isNaN(t)||Number.isNaN(l))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+=l,o){const t=o(a);c.categories.set(t,(c.categories.get(t)||0)+l)}}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 a=null!==(r=t.minOpacity)&&void 0!==r?r:.1,l=n-1-e;switch(t.type){case"linear":return a+(1-l/(n-1))*(1-a);case"exponential":{const e=null!==(o=t.halfLife)&&void 0!==o?o:n/2;return a+Math.pow(.5,l/e)*(1-a)}case"step":return(null!==(i=t.stepThreshold)&&void 0!==i?i:.5*n)>l?1:a;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,a;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!==(a=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!==a?a: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 a=[];for(const o of t){const t=n(o),i=r(o);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||a.push({px:e.x(t),py:e.y(i),rawY:i,d:o})}a.sort((t,e)=>t.px-e.px);const l=Array(a.length),s=Array(a.length),c=Array(a.length);for(let t=0;a.length>t;t++){const e=a[t];l[t]=[e.px,e.py],s[t]=e.rawY,c[t]=e.d}return{type:"line",path:l,rawValues:s,style:o,datum:c,group:i}}function I(t,e,n,r,o,i,a,l){const s=[];for(const i of t){const t=n(i),a=r(i);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const c=e.x(t),u=l?l(i):o;s.push({px:c,topY:e.y(a),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:a}}function z(t,e,n,r,o,i,a){const l=n(t),s=r(t);if(null==l||null==s||Number.isNaN(l)||Number.isNaN(s))return null;const c={type:"point",x:e.x(l),y:e.y(s),r:o,style:i,datum:t};return void 0!==a&&(c.pointId=a),c}function R(t,e,n,r,o,i,a){return{type:"rect",x:t,y:e,w:n,h:r,style:o,datum:i,group:a}}function B(t,e,n,r,o,i,a){const l={type:"heatcell",x:t,y:e,w:n,h:r,fill:o,datum:i};return(null==a?void 0:a.showValues)&&(l.showValues=!0,l.value=a.value,a.valueFormat&&(l.valueFormat=a.valueFormat)),l}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 a=t.getBounds(n),l=t.scales.x(e);if(a&&0!==a)r.push([l,t.scales.y(i+a)]),o.push([l,t.scales.y(i-a)]);else{const e=t.scales.y(i);r.push([l,e]),o.push([l,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 a of r.data){let r=t.config.pointStyle(a);!r.fill&&e&&(r=Object.assign(Object.assign({},r),{fill:e}));const l=null!==(o=r.r)&&void 0!==o?o:3,s=t.getPointId?t.getPointId(a)+"":void 0,c=z(a,t.scales,t.getX,i,l,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,a,l;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(),d=this.xExtent.extent,h=this.yExtent.extent;let f=s.xExtent?[null!==(e=s.xExtent[0])&&void 0!==e?e:d[0],null!==(n=s.xExtent[1])&&void 0!==n?n:d[1]]:d,y=s.yExtent?[null!==(o=s.yExtent[0])&&void 0!==o?o:h[0],null!==(i=s.yExtent[1])&&void 0!==i?i:h[1]]:h;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 a=0;for(const t of i.values())t.total>a&&(a=t.total);return[0,a]}(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===(a=s.yExtent)||void 0===a?void 0:a[0],r=null===(l=s.yExtent)||void 0===l?void 0:l[1];y=[null!=n?y[0]:y[0]-e,null!=r?y[1]:y[1]+e],"log"===s.yScaleType&&0>=y[0]&&h[0]>0&&(y[0]=null!=n?y[0]:h[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(),a=this.scales.x.range(),l=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,[a[0]*e,a[1]*e]),y:s(this.config.yScaleType,i,[l[0]*n,l[1]*n])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){var n;const{config:o,scales:a}=this;if(!a||0===e.length)return[];const l={scales:a,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}(l,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]),a=I(e.data,t.scales,t.getX,t.getY,o,n,e.key,i);t.config.gradientFill&&(a.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(a.curve=t.config.curve),r.push(a)}return F(t,n,r),r}(l,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,a){var l;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 d;if(i){d=new Map;for(const e of c){let n=0;for(const r of t)n+=(null===(l=u.get(r.key))||void 0===l?void 0:l.get(e))||0;d.set(e,n||1)}}const h=[],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=[],l=[],s=new Map;for(const n of c){let o=t.get(n)||0;const a=y.get(n);i&&(o/=d.get(n));const c=a+o,u=e.x(n);l.push([u,e.y(a)]),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:l,style:o(n.key,n.data[0]),datum:n.data,group:n.key};a&&(g.curve=a),h.push(g)}return{nodes:h,stackedTops:f}}(n,t.scales,t.getX,t.getY,(e,n)=>t.resolveAreaStyle(e,n),t.config.normalize,r),a=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,a,r)}return a}(l,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 a=t.getColor?t.resolveColorMap(e):null;for(const o of e){let e=t.config.pointStyle?t.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},l=e.r||r;if(i&&t.getSize){const e=t.getSize(o);null==e||Number.isNaN(e)||(l=i(e))}if(a&&t.getColor&&!e.fill){const n=t.getColor(o);n&&a.has(n)&&(e=Object.assign(Object.assign({},e),{fill:a.get(n)}))}const s=t.getPointId?t.getPointId(o)+"":void 0,c=z(o,t.scales,t.getX,t.getY,l,e,s);c&&n.push(c)}return n}(l,e);case"heatmap":return function(t,e,n){if(t.config.heatmapAggregation)return function(t,e,n){var r,o,i;const a=[],l=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 a;const[d,h]=t.scales.x.domain(),[f,y]=t.scales.y.domain(),g=(h-d||1)/l,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-d)/g),l-1),i=Math.min(Math.floor((r-f)/p),s-1);if(0>o||0>i)continue;const a=u(n),c=`${o}_${i}`;let h=m.get(c);h||(h={sum:0,count:0,data:[]},m.set(c,h)),h.count++,h.sum+=isFinite(a)?a:0,h.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/l,E=n.height/s;for(const[e,n]of b){const[r,o]=e.split("_"),i=+r,l=+o,c=(n-v)/k,u=`rgb(${Math.round(220-180*c)},${Math.round(220-100*c)},${Math.round(255-50*c)})`,d=m.get(e);a.push(B(i*w,(s-1-l)*E,w,E,u,{xi:i,yi:l,value:n,count:d.count,sum:d.sum,data:d.data},t.config.showValues?{value:n,showValues:!0,valueFormat:t.config.heatmapValueFormat}:void 0))}return a}(t,e,n);const o=[],a=M(t.config.valueAccessor,"value"),l=S(t.config.xAccessor,"x"),s=S(t.config.yAccessor,"y"),c=new Set,u=new Set;for(const t of e)c.add(l(t)),u.add(s(t));const d=Array.from(c),h=Array.from(u),f=d.every(t=>"number"==typeof t&&!isNaN(t)),y=h.every(t=>"number"==typeof t&&!isNaN(t)),g=f?d.sort((t,e)=>t-e):d,p=y?h.sort((t,e)=>t-e):h;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=`${l(t)}\0${s(t)}`;x.set(e,{val:a(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}(l,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),a=Array.from(e).filter(t=>!i.has(t)).sort(),l=n.filter(t=>e.has(t)),s=l.join("\0")+""+a.join("\0");t.barCategoryCache&&t.barCategoryCache.key===s?o=t.barCategoryCache.order:(o=[...l,...a],t.barCategoryCache={key:s,order:o})}const i=[],a=t.scales,[l,s]=a.x.domain();for(const e of r.values()){const r=Math.max(e.start,l),c=Math.min(e.end,s);if(r>=c)continue;const u=a.x(r),d=a.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&&e.categories.size>0){let r=0;for(const l of o){const o=e.categories.get(l)||0;if(0===o)continue;const s=a.y(r),c=a.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[l])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:l,categoryValue:o},l)),r+=o}}else{const t=a.y(0),n=a.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)}}(l,e);return this._barCategoryCache=null!==(n=l.barCategoryCache)&&void 0!==n?n:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var n,r,o,i;const a=[],l=t.config.swarmStyle||{},s=null!==(n=l.radius)&&void 0!==n?n:3,c=null!==(r=l.fill)&&void 0!==r?r:"#007bff",u=null!==(o=l.opacity)&&void 0!==o?o:.7,d=l.stroke,h=l.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),l=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:l,r:s,style:{fill:f,opacity:u,stroke:d,strokeWidth:h},datum:n};t.getPointId&&(y.pointId=t.getPointId(n)+""),a.push(y)}return a}(l,e);case"waterfall":return function(t,e,n){var r,o,i;const a=[],l=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 a;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 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=l.x(o),x=0!==m?l.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=l.y(g),E=l.y(p);a.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 a}(l,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",a=r.wickColor||"#333",l=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),d=t.getLow(r),h=t.getClose(r);if([s,u,d,h].some(t=>null==t||Number.isNaN(t)))continue;const f=h>=s;n.push({type:"candlestick",x:t.scales.x(e),openY:t.scales.y(s),closeY:t.scales.y(h),highY:t.scales.y(u),lowY:t.scales.y(d),bodyWidth:c,upColor:o,downColor:i,wickColor:a,wickWidth:l,isUp:f,datum:r})}return n}(l,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 a=new Map;for(let t=0;n.length>t;t++)a.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 l=a.get(e[n]);null!=l?(r[n]=D(t,l,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 l=!1;for(let n=0;e.length>n;n++){const r=a.get(e[n]);null!=r?(o[n]=D(t,r,i),1>o[n]&&(l=!0)):o[n]=1}l&&(n._decayOpacities=o)}else{let o=1;for(const n of e){const e=a.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=a.get(n.datum);if(null==e)continue;const l=D(t,e,i);if("heatcell"===n.type)n.style={opacity:l};else if("candlestick"===n.type)n._decayOpacity=l;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*l})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,n,r){var o,i;const a="undefined"!=typeof performance?performance.now():Date.now(),l=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 l=L(t,i,a);l>o&&(o=l)}o>0&&(n._pulseIntensity=o,n._pulseColor=l);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,a);i>0&&(n._pulseIntensity=i,n._pulseColor=l,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,a;n.clear(),r.clear();for(let l=0;e.length>l;l++){const s=e[l],c=O(t,s,l);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===(a=s.style)||void 0===a?void 0:a.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,a,l,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=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!==(a=i.style.opacity)&&void 0!==a?a:1,i._startOpacity=null!==(s=null!==(l=t.opacity)&&void 0!==l?l: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!==(d=A.r)&&void 0!==d?d:i.r,$=!0)}else i._targetOpacity=null!==(h=i.style.opacity)&&void 0!==h?h: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,a,l,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!==(a=n.opacity)&&void 0!==a?a: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!==(l=t._startOpacity)&&void 0!==l?l: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 a=!1;Object.assign(this.config,t);const l="chartType"in t&&t.chartType!==i.chartType||"runtimeMode"in t&&t.runtimeMode!==i.runtimeMode;if(l||void 0!==t.xAccessor||void 0!==t.yAccessor||void 0!==t.timeAccessor||void 0!==t.valueAccessor){const s=l||!A(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(n=i.xAccessor)&&void 0!==n?n:i.timeAccessor),c=l||!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")),a=!0)}if("groupAccessor"in t&&!A(t.groupAccessor,i.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?_(this.config.groupAccessor):void 0,a=!0),"categoryAccessor"in t&&!A(t.categoryAccessor,i.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?_(this.config.categoryAccessor):void 0,a=!0),"sizeAccessor"in t&&!A(t.sizeAccessor,i.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?M(this.config.sizeAccessor,"size"):void 0,a=!0),"colorAccessor"in t&&!A(t.colorAccessor,i.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?_(this.config.colorAccessor):void 0,a=!0),"y0Accessor"in t&&!A(t.y0Accessor,i.y0Accessor)&&(this.getY0=this.config.y0Accessor?M(this.config.y0Accessor,"y0"):void 0,a=!0),"pointIdAccessor"in t&&!A(t.pointIdAccessor,i.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?_(this.config.pointIdAccessor):void 0,a=!0),!a){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const n of e)if(t[n]!==i[n]){a=!0;break}}a&&(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,a;if(0===t.path.length)return null;const l=tt(t.path,e);if(0>l)return null;const[s,c]=t.path[l];let u;if(t.path.length>1){let r=1/0;const o=Math.max(0,l-1),i=Math.min(t.path.length-2,l);for(let a=o;i>=a;a++){const[o,i]=t.path[a],[l,s]=t.path[a+1],c=U(e,n,o,i,l,s);r>c&&(r=c)}u=r}else{const t=e-s,r=n-c;u=Math.sqrt(t*t+r*r)}const d=null!==(a=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!==a?a:1;return u>Math.max(5,d/2+2)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[l]?t.datum[l]:t.datum,x:s,y:c,distance:u}}function U(t,e,n,r,o,i){const a=o-n,l=i-r,s=a*a+l*l;if(0===s)return Math.sqrt(Math.pow(t-n,2)+Math.pow(e-r,2));let c=((t-n)*a+(e-r)*l)/s;c=Math.max(0,Math.min(1,c));const u=r+c*l;return Math.sqrt(Math.pow(t-(n+c*a),2)+Math.pow(e-u,2))}function K(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,a=n-r;return{node:t,datum:t.datum,x:t.x,y:r,distance:Math.sqrt(i*i+a*a)}}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],a=e-o,l=n-i,s=Math.sqrt(a*a+l*l);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 a=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&&a.set(e+"",t)}return{flat:i,groups:o,byGroup:r,idToIdx:a}}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 at(e,n,r){const o=t.useRef(null),[i,a]=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;a(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 lt(e,n,r,o,i,a){t.useEffect(()=>{if(!e)return;const t=setInterval(()=>{var t;const l=n.current;if(!l||0===l.lastIngestTime)return;const s="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(t=e.threshold)&&void 0!==t?t:5e3,u=s-l.lastIngestTime>c;u!==i&&(a(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 dt(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}function ht({config:t,orientation:e="vertical",width:n=100}){const{colorFn:r,domain:o,label:i,format:a}=t,l=a||(t=>Math.round(100*t)/100+""),s="grad-legend-"+g.useId();if("horizontal"===e){const t=12,e=Math.min(n,200),a=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:a+e/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),g.createElement("rect",{x:a,y:0,width:e,height:t,fill:`url(#${s})`,rx:2}),g.createElement("text",{x:a,y:t+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(o[0])),g.createElement("text",{x:a+e,y:t+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(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)"},l(o[1])),g.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(o[0])))}function ft(t){const{legendGroups:e,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,legendInteraction:a,title:l="Legend",width:s=100,height:c=20,orientation:u="vertical"}=t,[d,h]=g.useState(0),[f,y]=g.useState(0),p=g.useCallback((t,e)=>{h(t),y(e)},[]),m="vertical"===u?(({legendGroups:t,width:e,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:s,legendInteraction:c})=>{let u=24;const d=[];return t.forEach((t,h)=>{u+=5,d.push(g.createElement("line",{key:"legend-top-line legend-symbol-"+h,stroke:"gray",x1:0,y1:u,x2:e,y2:u})),u+=8,t.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)"},t.label)),u+=8),d.push(g.createElement("g",{key:"legend-group-"+h,className:"legend-item",transform:`translate(0,${u})`},((t,e,n,r,o,i,a,l,s,c)=>{const{type:u="fill",styleFn:d,items:h}=t,f=[];let y=0;const p=!(!e&&!n),m="isolate"===c||void 0===c&&null!=o;return h.forEach((t,c)=>{const v=ct(t,c,u,d),x=dt(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?l===i&&c===a?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)+h.length)%h.length;s(l,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(l,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,a,l,h,s,c))),u+=22*t.items.length+8}),d})({legendGroups:e||[],width:s,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:d,focusedItemIndex:f,onFocusedIndexChange:p,legendInteraction:a}):(({legendGroups:t,height:e,width:n,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:l,focusedItemIndex:s,onFocusedIndexChange:c,legendInteraction:u})=>{let d=0;const h=[];t.forEach((t,e)=>{let f=0;t.label&&(f+=16);const y=((t,e,n,r,o,i,a,l,s,c,u)=>{const{type:d="fill",styleFn:h,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,d,h),k=dt(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?l===i&&c===a?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(l,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(l,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,a,l,s,e,c,u,n);f+=y.offset+5,h.push(Object.assign(Object.assign({label:t.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=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:l,height:c,width:s,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:d,focusedItemIndex:f,onFocusedIndexChange:p,legendInteraction:a}),v=!(!n&&!r);return g.createElement("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==a&&(void 0!==a||null==i))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},void 0!==l&&""!==l&&"vertical"===u&&g.createElement("text",{className:"legend-title",y:16,x:s/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},l),m)}function yt(t){const{legend:e,totalWidth:n,totalHeight:r,margin:o,legendPosition:i="right",title:a,legendHoverBehavior:l,legendClickBehavior:s,legendHighlightedCategory:c,legendIsolatedCategories:u,legendInteraction:d}=t;if(!e)return null;const h="top"===i||"bottom"===i;let f,y;return"left"===i?(f=4,y=o.top):"top"===i?(f=0,y=a?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(ht,{config:e.gradient,orientation:h?"horizontal":"vertical",width:h?n:100}):function(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}(e)?g.createElement(ft,{legendGroups:e.legendGroups,title:"",width:h?n:100,orientation:h?"horizontal":"vertical",customHoverBehavior:l,customClickBehavior:s,highlightedCategory:c,isolatedCategories:u,legendInteraction:d}):e)}function gt(t){return"string"==typeof t?{type:t}:t}function pt({orient:e,config:n,values:r,scale:o,size:i,length:l}){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)],a=i-r;return{q1:r,median:o,q3:i,whiskerLow:Math.max(e[0],r-1.5*a),whiskerHigh:Math.min(e[n-1],i+1.5*a)}}(r);if(!t)return null;const{q1:i,median:a,q3:l,whiskerLow:u,whiskerHigh:d}=t,h=Math.min(.5*n,20),f=(n-h)/2+4;if(c){const t=o(i),n=o(l),r=o(a),c=o(u),y=o(d),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+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(t,n),y:"top"===e?m-f-h:m+f,width:Math.abs(n-t),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"===e?m-f-h:m+f,x2:r,y2:"top"===e?m-f:m+f+h,stroke:s.fill,strokeWidth:2}))}{const t=o(i),n=o(l),r=o(a),c=o(u),y=o(d),p="left"===e?-1:1,m=0;return g.createElement("g",{"data-testid":"marginal-boxplot-"+e},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"===e?m-f-h:m+f,y:Math.min(t,n),width:h,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-h:m+f,y1:r,x2:"left"===e?m-f:m+f+h,y2:r,stroke:s.fill,strokeWidth:2}))}}const u=a.bin().domain(t).thresholds(s.bins)(r);if(0===u.length)return null;const d=Math.max(...u.map(t=>t.length));if(0===d)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/d*n;if(c){const n=o(t.x0),a=o(t.x1)-o(t.x0);return g.createElement("rect",{key:r,x:n,y:"top"===e?-4-i:4,width:Math.max(a,.5),height:i,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}{const n=o(t.x0),a=o(t.x1)-o(t.x0);return g.createElement("rect",{key:r,x:"left"===e?-4-i:4,y:Math.min(n,n+a),width:i,height:Math.abs(a),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 a=i.length/d*(n/2),l=o((i.x0+i.x1)/2);r.push(c?`${l},${"top"===e?-(t-a):t-a}`:`${"left"===e?-(t-a):t-a},${l}`)}for(let i=u.length-1;i>=0;i--){const a=u[i];if(null==a.x0||null==a.x1)continue;const l=a.length/d*(n/2),s=o((a.x0+a.x1)/2);r.push(c?`${s},${"top"===e?-(t+l):t+l}`:`${"left"===e?-(t+l):t+l},${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/d*n,a=o((r.x0+r.x1)/2);t.push(`L${a},${"top"===e?-i-4:i+4}`)}const a=null!=u[u.length-1].x1?o(u[u.length-1].x1):l;t.push(`L${a},${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/d*n,a=o((r.x0+r.x1)/2);t.push(`L${"left"===e?-i-4:i+4},${a}`)}const a=null!=u[u.length-1].x1?o(u[u.length-1].x1):l;t.push(`L${r},${a}`),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,l,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 a="";for(const t of o)a&&a.length+1+t.length>r?(i.push(a),a=t):a=a?`${a} ${t}`:t;return a&&i.push(a),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:a,note:l,connector:s,subject:c,type:u,color:d,className:h,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!=a&&(x=a-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 "+(h||"")).trim(),transform:`translate(${e},${n})`,"data-testid":p},y),!m.has("connector")&&function(t,e,n,r,o,i){const a=[];let l=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,a=t-o,c=e-i;if(0!==a||0!==c){const t=Math.abs(a),e=Math.abs(c),u=n/2,d=r/2,h=t*d>e*u?u/t:d/e;l=o+a*h,s=i+c*h}}}else if("bracket"===o&&i){const t=i.width,e=i.height,n=i.depth||30;void 0!==t?(l=t/2,s=n):void 0!==e&&(l=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);l=Math.cos(r)*n,s=Math.sin(r)*n}}if(Math.sqrt(Math.pow(t-l,2)+Math.pow(e-s,2))>.5&&(a.push(g.createElement("line",{key:"connector-line",x1:l,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-l);a.push(g.createElement("path",{key:"connector-arrow",d:`M${l},${s}L${l+n*Math.cos(i+o)},${s+n*Math.sin(i+o)}L${l+n*Math.cos(i-o)},${s+n*Math.sin(i-o)}Z`,fill:r||"currentColor",stroke:"none"}))}return g.createElement("g",{className:"annotation-connector"},a)}(v,x,s,d,b,c),!m.has("subject")&&function(t,e,n,r,o){var i;const a=[];switch(t){case"callout-circle":{const t=((null==e?void 0:e.radius)||0)+((null==e?void 0:e.radiusPadding)||0);t>0&&a.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)&&a.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)&&a.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;a.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;a.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)?a.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)||a.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&&a.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"},a)}(b,c,d,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:a,align:l,wrap:s=120,noWrap:c}=t;if(!o&&!i)return g.createElement("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(e)>Math.abs(n)?"leftRight":"topBottom");let d=l;d&&"dynamic"!==d||(d="topBottom"===u?0>e?"right":"left":0>n?"bottom":"top");let h="start";"topBottom"===u?"right"===d?h="end":"middle"===d&&(h="middle"):h=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"===h?-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:h,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:h,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"===h?(e=-t,n=0):"middle"===h&&(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"===d?(e=-t,n=0):"middle"===d&&(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"===d?-(k+f+(p.length>0&&y.length>0?2:0))/2+8:"bottom"===d||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)}(l,v,x,d))}function bt(t){var e,n;const{noteData:r}=t,{screenCoordinates:o}=r,i="string"==typeof r.type?r.type:"label",a=r.eventListeners||r.events||{};if(r.coordinates&&o){const t=r.nx||o[0][0]+(null!==(e=r.dx)&&void 0!==e?e:0),a=r.ny||o[0][1]+(null!==(n=r.dy)&&void 0!==n?n:0),l=o.map((e,n)=>{const o=Object.assign({},r,{note:0===n?r.note:{label:""},x:e[0],y:e[1],nx:t,ny:a});return g.createElement(xt,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},o,{type:i}))});return g.createElement("g",null,l)}const l=r.note||{title:"none",label:r.label};return g.createElement(xt,Object.assign({"data-testid":"semiotic-annotation",key:`${l.label}-${l.title}-${r.i}`,events:a},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,a;const l=t.anchor||"fixed";if("latest"===l){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,a;const l=t.data;if(!l||0===l.length)return null;const s=l[l.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===(a=t.scales)||void 0===a?void 0:a.value;if(!c||!u)return null;const d=s[t.xAccessor||"x"],h=s[t.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(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"===l){const t=null===(a=n.stickyPositionCache)||void 0===a?void 0:a.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 a="M0,"+r;for(let t=0;i>t;t++){const n=8*(t+1);a+=`L${Math.min(8*t+4,e)},${r+4*o}`,a+=`L${Math.min(n,e)},${r}`}return a}{const r="bottom"===t?0:e,o="bottom"===t?1:-1,i=Math.ceil(n/8);let a=`M${r},0`;for(let t=0;i>t;t++){const e=8*(t+1);a+=`L${r+4*o},${Math.min(8*t+4,n)}`,a+=`L${r},${Math.min(e,n)}`}return a}}function Wt(e){const{width:n,height:r,totalWidth:o,totalHeight:i,margin:a,scales:l,showAxes:s,axes:c,showGrid:u,xFormat:d,yFormat:h}=e,f=t.useMemo(()=>{var t;if(!l)return[];const e=null==c?void 0:c.find(t=>"bottom"===t.orient),r=(null==e?void 0:e.tickFormat)||d||It,o=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,i=l.x.ticks(Math.min(o,Math.max(2,Math.floor(n/70)))),a=i.map(t=>t.valueOf()),s=i.map((t,e)=>({value:t,pixel:l.x(t),label:r(t,e,a)})),u=s.reduce((t,e)=>Math.max(t,6.5*e.label.length),0);return zt(s,Math.max(55,u+8))},[l,c,d,n]),y=t.useMemo(()=>{var t;if(!l)return[];const e=null==c?void 0:c.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||h||It,o=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return zt(l.y.ticks(Math.min(o,Math.max(2,Math.floor(r/30)))).map(t=>({value:t,pixel:l.y(t),label:n(t)})),22)},[l,c,h,r]),p=u&&l,m=s&&l;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(${a.left},${a.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:a,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:_,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(!h||!d)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=d.x.ticks(Math.min(r,Math.max(2,Math.floor(o/70)))),a=i.map(t=>t.valueOf()),l=i.map((t,e)=>({value:t,pixel:d.x(t),label:n(t,e,a)})),s=l.reduce((t,e)=>Math.max(t,6.5*e.label.length),0);return zt(l,Math.max(55,s+8))},[h,d,f,x,o]),X=t.useMemo(()=>{var t;if(!h||!d)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(d.y.ticks(Math.min(r,Math.max(2,Math.floor(i/30)))).map(t=>({value:t,pixel:d.y(t),label:n(t)})),22)},[h,d,f,b,i]),G=t.useMemo(()=>{var t;if(!h||!d)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(d.y.ticks(Math.min(r,Math.max(2,Math.floor(i/30)))).map(t=>({value:t,pixel:d.y(t),label:n(t)})),22)},[h,d,f,b,i]),V=t.useRef(new Map),q=t.useRef(null!==(n=null==N?void 0:N.length)&&void 0!==n?n:0),U=null!==(r=null==N?void 0:N.length)&&void 0!==r?r:0;q.current!==U&&(q.current=U,V.current=new Map);const K=t.useMemo(()=>{if(!N||0===N.length)return null;const t=function(t,e,n){var r,o,i,a,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,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 a;return a="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:a,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 a,l;return"left"===i?(a=4,l="start"):"center"===i?(a=(n.width||0)/2,l="middle"):(a=(n.width||0)-4,l="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:a,y:r-4,textAnchor:l,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=l.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),a=r.map(t=>t.y),l=Math.min(...i)-o,s=Math.max(...i)+o,c=Math.min(...a)-o,u=Math.max(...a)+o;return g.createElement("g",{key:"ann-"+e},g.createElement("rect",{x:l,y:c,width:s-l,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:(l+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),a=wt(e,n);if(null==o||null==a)return null;const l="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:a,r:l},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 l=n.data||[];if(2>l.length)return null;const s=n.xAccessor||"x",h=n.yAccessor||"y",f=l.map(t=>[t[s],t[h]]).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===(a=n.scales)||void 0===a?void 0:a.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]),a=Math.max(2,Math.ceil(e*n)),l=[];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(a-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,d=0,h=0,f=0,y=0;for(let t=0;n>t;t++){const e=c[t];0!==e&&(u+=e,d+=e*o[t],h+=e*i[t],f+=e*o[t]*o[t],y+=e*o[t]*i[t])}if(0===u){l.push([e,i[t]]);continue}const g=u*f-d*d;if(1e-12>Math.abs(g))l.push([e,h/u]);else{const t=(u*y-d*h)/g;l.push([e,(h-t*d)/u+t*e])}}return l}(f,null!==(d=t.bandwidth)&&void 0!==d?d:.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===(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(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,a=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||!a)return null;const l=t.upperAccessor||"upperBounds",c=t.lowerAccessor||"lowerBounds",u=t.filter,d=r.filter(t=>null!=t[l]&&null!=t[c]&&!(u&&!u(t))).sort((t,e)=>t[o]-e[o]);if(2>d.length)return null;const h=Mt[n.curve||"linear"]||s.curveLinear,f=s.area().x(t=>i(t[o])).y0(t=>a(t[c])).y1(t=>a(t[l])).curve(h)(d);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&&d.length>0&&g.createElement("text",{x:i(d[d.length-1][o])+4,y:a(d[d.length-1][l])-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,a=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||!a)return null;const l=r.map(t=>t[o]).filter(t=>null!=t&&isFinite(t));if(2>l.length)return null;const s=l.reduce((t,e)=>t+e,0)/l.length,c=l.reduce((t,e)=>t+Math.pow(e-s,2),0)/l.length,u=Math.sqrt(c),d=null!==(T=t.threshold)&&void 0!==T?T:2,h=s-d*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=a(s+d*u),b=a(h),k=r.filter(t=>{const e=t[o];return null!=e&&Math.abs(e-s)>d*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",a=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,l=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(!a||!l)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 a=(t*o-e*n)/i,l=(n-a*e)/t;c=t=>l+a*t}const u=s.length,d=s.map(([t,e])=>e-c(t)).reduce((t,e)=>t+e*e,0),h=Math.sqrt(d/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=h*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=>`${a(t.x)},${l(t.yUpper)}`).join(" L")} L${E.slice().reverse().map(t=>`${a(t.x)},${l(t.yLower)}`).join(" L")} Z`,M=E.map(t=>`${a(t.x)},${l(t.yCenter)}`).join(" "),S=`${a(b)},${l(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:a(E[E.length-1].x)+4,y:l(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,a=null!==(V=t.dy)&&void 0!==V?V:0,l=null!==(q=t.width)&&void 0!==q?q:32,s=null!==(U=t.height)&&void 0!==U?U:32,c=null!==(K=t.content)&&void 0!==K?K:g.createElement("span",{style:{fontSize:18,cursor:"default"},title:t.label||"Info"},"ℹ️");return g.createElement("foreignObject",{key:"ann-"+e,x:r+i-l/2,y:o+a-s/2,width:l,height:s,style:{overflow:"visible",pointerEvents:"auto"}},g.createElement("div",{style:{width:l,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,a=null===(J=n.scales)||void 0===J?void 0:J.y,l=(null==o?void 0:o.bandwidth)?o:(null==i?void 0:i.bandwidth)?i:(null==a?void 0:a.bandwidth)?a:null;if(!l)return null;const s=l(r);if(null==s)return null;const c=l.bandwidth(),u=t.color||"var(--semiotic-primary, #4589ff)",d=null!==(tt=t.opacity)&&void 0!==tt?tt:.15,h=t.label;return(n.projection?"vertical"===n.projection:l===i)?g.createElement("g",{key:"ann-"+e},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-"+e},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}},e={scales:d?{x:d.x,y:d.y,time:d.x,value:d.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,d,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 h||w||E||C||D||K&&K.length>0||k||Y||Z?g.createElement("svg",{role:"img",width:a,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&&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}))),h&&d&&(()=>{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,a=(null==e?void 0:e.jaggedBase)||!1,l=null==e?void 0:e.landmarkTicks,s=null==t?void 0:t.landmarkTicks,c="var(--semiotic-border, #ccc)",d="var(--semiotic-text-secondary, var(--semiotic-text, #666))",h="var(--semiotic-text, #333)";return g.createElement("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},!B&&(!e||!1!==e.baseline)&&!a&&g.createElement("line",{x1:0,y1:i,x2:o,y2:i,stroke:c,strokeWidth:1}),!B&&a&&g.createElement("path",{d:Ot("bottom",o,i),fill:"none",stroke:c,strokeWidth:1}),H.map((t,e)=>{const n=!!l&&("function"==typeof l?l(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:d,style:{userSelect:"none"}},t.label))}),y&&g.createElement("text",{x:o/2,y:i+40,textAnchor:"middle",fontSize:12,fill:h,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:d,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:h,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:d,style:{userSelect:"none"}},t.label))}),n&&g.createElement("text",{x:o+u.right-15,y:i/2,textAnchor:"middle",fontSize:12,fill:h,transform:`rotate(90, ${o+u.right-15}, ${i/2})`,style:{userSelect:"none"}},n))})())})(),K,D&&d&&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:d.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:d.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:d.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:d.y,size:u.right,length:i}))),C,Z&&Z.sourceId!==F&&(null==d?void 0:d.x)&&(()=>{const t=d.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:a/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:a,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"],a=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 a)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+""},Ut={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"},Kt={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,a]=g.useState(!1),l=Ht(),s=null!==(o=null==l?void 0:l.visible)&&void 0!==o&&o,c=i||s,u=g.useRef(null),d=r?"Data summary for "+r:n?`Data summary for ${e} ${n}`:"Data summary for "+e,h=g.useCallback(()=>{i||s||a(!0)},[i,s]),f=g.useCallback(t=>{var e;s||(null===(e=u.current)||void 0===e?void 0:e.contains(t.relatedTarget))||a(!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:h,style:Xt,role:"region","aria-label":d},g.createElement("button",{type:"button",onClick:()=>a(!0)},"View data summary (",t.length," elements)"));const y=function(t){var e,n,r,o,i,a,l,s,c,u,d,h,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:"",a=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!=a?a:""}});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!==(a=null===(i=_.datum)||void 0===i?void 0:i.category)&&void 0!==a?a:null===(l=_.datum)||void 0===l?void 0:l.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!==(h=null===(d=_.datum)||void 0===d?void 0:d.id)&&void 0!==h?h:"",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:Ut,role:"region","aria-label":d},g.createElement("button",{type:"button",onClick:()=>{s&&l&&l.setVisible(!1),a(!1)},"aria-label":"Close data summary",style:Zt},"×"),g.createElement("div",{role:"note",style:Kt},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,a,l,s,c,u,d,h,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!==(a=t.datum)&&void 0!==a?a:t,n="object"==typeof e.source?null===(l=e.source)||void 0===l?void 0:l.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!==(d=L.get(t))&&void 0!==d?d:0)+1),N.set(t,(null!==(h=N.get(t))&&void 0!==h?h: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,a=null!==(v=N.get(r))&&void 0!==v?v:0,l=null!==(x=$.get(r))&&void 0!==x?x:0;O.push({id:r,degree:o+i,inDeg:o,outDeg:i,wDegree:a+l,wInDeg:a,wOutDeg:l})}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:Ut,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:Kt},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 ae({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 le="var(--semiotic-focus, #005fcc)";function se({active:t,hoverPoint:e,margin:n,size:r,shape:o="circle",width:i,height:a}){if(!t||!e)return null;const l=e.x+n.left,s=e.y+n.top;let c;if("rect"===o&&null!=i&&null!=a){const t=Math.max(i,4),e=Math.max(a,4);c=g.createElement("rect",{x:l-t/2-3,y:s-e/2-3,width:t+6,height:e+6,rx:3,fill:"none",stroke:le,strokeWidth:2,strokeDasharray:"4,2"})}else c=g.createElement("circle","wedge"===o?{cx:l,cy:s,r:12,fill:"none",stroke:le,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:s,r:8,fill:"none",stroke:le,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:a="stream-frame-tooltip",zIndex:l=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,a,n,r]);let d;return d=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:a,style:{position:"absolute",left:o.left+t,top:o.top+e,transform:d,pointerEvents:"none",zIndex:l,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 de(e){const n=t.createContext(null),r=he(e);return[function({children:r}){const o=t.useMemo(()=>he(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,a=t.useRef(e);a.current=e;const l=t.useCallback(()=>a.current(i.getState()),[i]),s=t.useCallback(()=>a.current(i.getState()),[i]);return t.useSyncExternalStore(i.subscribe,l,s)}]}function he(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]=de(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,a=e[1]*r,l=e[0]+"px",s=e[1]+"px";return t.style.width!==l&&(t.style.width=l),t.style.height!==s&&(t.style.height=s),t.width===i&&t.height===a||(t.width=i,t.height=a),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 a=[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];a.push(a[t-1]+Math.sqrt(n*n+r*r))}const l=a[a.length-1];if(0===l)return;const s=Math.min(.2*l,40);t.strokeStyle=n,t.lineWidth=r,t.lineCap=i;for(let n=0;e.length-1>n;n++){const r=(a[n]+a[n+1])/2;let i=o;s>r&&(i*=r/s),s>l-r&&(i*=(l-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,a,l;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,d=null!==(l=null!==(a=e.cy)&&void 0!==a?a:e.y)&&void 0!==l?l:0;t.beginPath(),t.arc(u,d,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,a;const l=e.filter(t=>"area"===t.type);for(const e of l){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 l=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"),a=e.fillGradient.topOpacity,s=e.fillGradient.bottomOpacity,c=t.createLinearGradient(0,r,0,o);c.addColorStop(0,`rgba(${i[0]},${i[1]},${i[2]},${a})`),c.addColorStop(1,`rgba(${i[0]},${i[1]},${i[2]},${s})`),t.fillStyle=c,t.globalAlpha=l}else{const r=null!==(a=e.style.fillOpacity)&&void 0!==a?a:.7;t.globalAlpha=r*l,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=l,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,a=e.x+(e.w-o)/2;for(let r=e.y+e.h-o;r>=e.y-o;r-=i)t.drawImage(n,a,r,o,o)}else{const i=o+r,a=e.y+(e.h-o)/2;for(let r=e.x;e.x+e.w>r;r+=i)t.drawImage(n,r,a,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 a=e.filter(t=>"line"===t.type);for(const l of a){if(2>l.path.length)continue;const c=l.style.stroke||"#007bff",u=l.style.strokeWidth||2,d=l.colorThresholds,h=l.rawValues;if(t.setLineDash(l.style.strokeDasharray?l.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=l.style.opacity&&(t.globalAlpha=l.style.opacity),t.lineWidth=u,t.lineCap=l.style.strokeLinecap||"butt",l.style._edgeFade){const p=null!==(o=l.style.opacity)&&void 0!==o?o:1;we(t,l.path,c,u,p,l.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const f=be(l.curve),y=d&&d.length>0&&h&&h.length===l.path.length,g=l._decayOpacities;if(g&&g.length===l.path.length&&!y){t.strokeStyle=c;const m=null!==(i=l.style.opacity)&&void 0!==i?i:1;for(let v=0;l.path.length-1>v;v++)t.globalAlpha=.5*(g[v]+g[v+1])*m,t.beginPath(),t.moveTo(l.path[v][0],l.path[v][1]),t.lineTo(l.path[v+1][0],l.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;l.path.length>S;S++){const[_,P]=l.path[S],C=h[S],D=ke(C,d,c);if(null!==x&&null!==w&&null!==k){if(D===w)t.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((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),d,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)(l.path);else{const[z,R]=l.path[0];t.moveTo(z,R);for(let B=1;l.path.length>B;B++)t.lineTo(l.path[B][0],l.path[B][1])}t.stroke()}if(l.style.fill&&l.style.fillOpacity&&l.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=l.style.fillOpacity,t.fillStyle=l.style.fill,f&&!y)s.line().x(t=>t[0]).y(t=>t[1]).curve(f).context(t)(l.path);else{const[F,Y]=l.path[0];t.moveTo(F,Y);for(let H=1;l.path.length>H;H++)t.lineTo(l.path[H][0],l.path[H][1])}const j=l.path[0][0];t.lineTo(l.path[l.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,a;Te(t,e);const l=e.filter(t=>"rect"===t.type);if(2>l.length)return;const s=l[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;l.length-1>e;e++){const r=l[e],o=l[e+1];if(!(null===(i=r.datum)||void 0===i?void 0:i.cumEnd)||!(null===(a=o.datum)||void 0===a?void 0:a.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),a=e.isUp?e.upColor:e.downColor;t.fillStyle=a,t.fillRect(e.x-e.bodyWidth/2,o,e.bodyWidth,Math.max(i,1)),t.strokeStyle=a,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,a,l,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:_,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:U,pointStyle:tt,areaStyle:ot,waterfallStyle:st,swarmStyle:ct,barColors:ut,colorScheme:dt,boundsAccessor:ht,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:Ut,canvasPreRenderers:Kt,svgPreRenderers:Zt,title:Qt,categoryAccessor:Jt,brush:te,onBrush:ee,decay:re,pulse:le,transition:de,staleness:he,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]=at(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 Ut?Ut({size:Ne,margin:$e}):Ut,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),Ue=me(t=>t.theme),[Ke,Ze]=t.useState(0),[Qe,Je]=t.useState(null),tn=t.useRef(null),en=t.useRef(null),[nn,rn]=t.useState(null),[on,an]=t.useState(!1),[ln,sn]=t.useState([]),[cn,un]=t.useState([]),dn=t.useRef(()=>{}),hn="streaming"===p||["bar","swarm","waterfall"].includes(y),fn=t.useMemo(()=>({chartType:y,runtimeMode:hn?"streaming":"bounded",windowSize:$,windowMode:N,arrowOfTime:hn?T:"right",extentPadding:z,xAccessor:hn?void 0:w,yAccessor:hn?void 0:E,timeAccessor:hn?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:ht,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:U,pointStyle:tt,areaStyle:ot,swarmStyle:ct,waterfallStyle:st,colorScheme:dt,barColors:ut,annotations:$t,decay:re,pulse:le,transition:de,staleness:he,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,ht,ft,yt,gt,pt,mt,vt,xt,bt,U,tt,ot,ct,st,dt,ut,$t,re,le,de,he,fe,ye,ge,pe,be,hn,we,P]),yn=t.useRef(null);yn.current||(yn.current=new H(fn));const gn=t.useCallback(()=>{Ve.current||(Ve.current=requestAnimationFrame(()=>dn.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()},[Ue,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 a=function(t,e,n,r=30,o){let i=null,a=!1;if(o){const t=o.find(e,n,r);if(t){const o=V(t,e,n);o&&r>o.distance&&(i=o,a=!0)}}for(const l of t){let t=null;switch(l.type){case"point":if(o&&a)break;t=V(l,e,n);break;case"line":t=q(l,e,n);break;case"rect":t=K(l,e,n);break;case"heatcell":t=Z(l,e,n);break;case"area":if(!1===l.interactive)break;t=J(l,e,n);break;case"candlestick":t=Q(l,e,n)}t&&r>t.distance&&(i&&t.distance>=i.distance||(i=t))}return i}(i.scene,r,o,30,i.quadtree);if(!a)return void(tn.current&&(tn.current=null,en.current=null,rn(null),Tt&&Tt(null),gn()));const l=a.datum||{},s=Object.assign(Object.assign({},"object"!=typeof l||null===l||Array.isArray(l)?{}:l),{data:l,time:a.x,value:a.y,x:a.x,y:a.y});tn.current=s,en.current=a.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 a of t)switch(a.type){case"point":i.push({x:a.x,y:a.y,datum:a.datum,shape:"circle",group:null!==(e=a.group)&&void 0!==e?e:"_default"});break;case"line":{const t=a,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=a,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:a.x+a.w/2,y:a.y+a.h/2,datum:a.datum,shape:"rect",w:a.w,h:a.h,group:null!==(o=a.group)&&void 0!==o?o:"_default"});break;case"heatcell":i.push({x:a.x+a.w/2,y:a.y+a.h/2,datum:a.datum,shape:"rect",w:a.w,h:a.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),a=rt(t.key,i,r);if(null===a)return;if(t.preventDefault(),0>a)return En.current=-1,An.current=null,tn.current=null,en.current=null,rn(null),Tt&&Tt(null),void gn();En.current=a;const l=r.flat[a];An.current={shape:l.shape,w:l.w,h:l.h};const s=it(l);tn.current=s,rn(s),Tt&&Tt(s),gn()},[Tt,gn]),_n=t.useCallback(t=>{En.current=-1,An.current=null,bn.current(t)},[]);dn.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(),a=o.advanceTransition(Le.current?i+1e6:i),l=!Le.current&&a,s=qe.current||a;s&&!l&&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(),a=e.getPropertyValue("--text-primary").trim(),l=n||e.getPropertyValue("--surface-3").trim(),s=o||e.getPropertyValue("--surface-0").trim();return i||a||n?{axisStroke:l||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),d=null!==(t=null==he?void 0:he.threshold)&&void 0!==t?t:5e3,h=he&&o.lastIngestTime>0&&i-o.lastIngestTime>d;if(s){const t=ve(n,Ne,$e,c);if(t){t.clearRect(-$e.left,-$e.top,Ne[0],Ne[1]),h&&(t.globalAlpha=null!==(e=null==he?void 0:he.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()),Kt&&o.scales)for(const e of Kt)t.save(),e(t,o.scene,o.scales,{width:Oe,height:We}),t.restore();const a=ze[y];if(a&&o.scales)for(const e of a)e(t,o.scene,o.scales,{width:Oe,height:We});t.restore(),h&&(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,a){var l;if(!1===o.crosshair)return;t.save();const s="object"==typeof o.crosshair?o.crosshair:{};t.strokeStyle=s.stroke||a.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===(l=t.canvas)||void 0===l?void 0:l.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=a.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==he?void 0:he.showBadge)&&an(!!h),(l||o.hasActivePulses)&&(Ve.current=requestAnimationFrame(()=>dn.current()))},t.useEffect(()=>(gn(),()=>{Ve.current&&(cancelAnimationFrame(Ve.current),Ve.current=0)}),[gn]),t.useEffect(()=>{qe.current=!0,gn()},[y,Oe,We,kt,G,U,Kt,gn]),lt(he,yn,qe,gn,on,an);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"),a=[...o.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return g.createElement("path",{key:"area-"+e,d:`M${i}L${a}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),a=.299*r+.587*o+.114*i>128?"#000":"#fff",l=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:a,fontSize:l+"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!==(a=null===(i=yn.current)||void 0===i?void 0:i.scene)&&void 0!==a?a:[],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===(l=yn.current)||void 0===l?void 0:l.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(ae,{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:ln,yValues:cn,annotations:$t,svgAnnotationRules:Ot,annotationFrame:Ke,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!==(d=null==te?void 0:te.dimension)&&void 0!==d?d:"xy",scales:Qe,onBrush:null!=ee?ee:()=>{},binSize:D,snap:null==te?void 0:te.snap,binBoundaries:null!==(h=null==te?void 0:te.binBoundaries)&&void 0!==h?h:"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==he?void 0:he.showBadge)&&g.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===he.badgePosition?{top:4,left:4}:"bottom-left"===he.badgePosition?{bottom:4,left:4}:"bottom-right"===he.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 a=this.particles[i];if(!a.active)continue;const l=n[a.edgeIndex];if(!l||!l.bezier){a.active=!1;continue}const s=r&&null!==(o=r[a.edgeIndex])&&void 0!==o?o:1;if(a.t+=t*e*s*(l.bezier.circular?.3:1),a.t>=1){a.active=!1;continue}const c=Ve(l.bezier,a.t,a.offset);a.x=c.x,a.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,a=Math.min(Math.floor(i),o-1),l=i-a,[s,c,u,d]=t[a],h=qe(s,c,u,d,l),f=d.x-s.x,y=d.y-s.y,g=Math.sqrt(f*f+y*y);if(g>.001){const t=f/g;h.x+=-y/g*n*r*2,h.y+=t*n*r*2}return h}(t.segments,e,n,t.halfWidth);if(!t.points)return{x:0,y:0};const[r,o,i,a]=t.points,l=qe(r,o,i,a,e),s=a.x-r.x,c=a.y-r.y,u=Math.sqrt(s*s+c*c);if(u>.001){const e=s/u;l.x+=-c/u*n*t.halfWidth*2,l.y+=e*n*t.halfWidth*2}return l}function qe(t,e,n,r,o){const i=1-o,a=i*i,l=a*i,s=o*o,c=s*o;return{x:l*t.x+3*a*o*e.x+3*i*s*n.x+c*r.x,y:l*t.y+3*a*o*e.y+3*i*s*n.y+c*r.y}}function Ue(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function Ke(t,e){var n,r=[],o=[],i=[],a={},l=[];function s(t){i[t]=!1,a.hasOwnProperty(t)&&Object.keys(a[t]).forEach(function(e){delete a[t][e],i[e]&&s(e)})}function c(t){var e,r,d=!1;for(o.push(t),i[t]=!0,e=0;l[t].length>e;e++)(r=l[t][e])===n?(u(n,o),d=!0):i[r]||(d=c(r));if(d)s(t);else for(e=0;l[t].length>e;e++){var h=a[r=l[t][e]];h||(a[r]=h={}),h[r]=!0}return o.pop(),d}function u(t,e){var n=[].concat(e).concat(t);r.push(n)}function d(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),a=Array(e),l=Array(e),s=0;e>s;++s)n[s]=-1,r[s]=0,o[s]=!1,i[s]=0,a[s]=-1,l[s]=[];var c,u=0,d=[],h=[];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>a[g]||l[e].push(a[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(l[x]),v+=l[x].length,a[x]=d.length,x===e){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;e>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(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]);h[s]=c}}return{components:d,adjacencyList:h}}(t),o=r.components.filter(function(t){return t.length>1}),i=1/0,a=0;o.length>a;a++)for(var l=0;o[a].length>l;l++)i>o[a][l]&&(i=o[a][l],n=a);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 h=t.length;h>n;){var f=d(n);if(n=f.leastVertex,l=f.adjList){for(var y=0;l.length>y;y++)for(var g=0;l[y].length>g;g++){var p=l[y][g];i[+p]=!1,a[p]={}}c(n),n+=1}else n=h}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 an(t){return sn(t.source)}function ln(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 dn(t){return t.target.depth}function hn(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 l=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,l))});var s=a.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 a=t.source.column,l=t.circularLinkType,c=i.links.filter(function(t){return t.source.column==a&&t.circularLinkType==l});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}),a=t.target.column,(c=i.links.filter(function(t){return t.target.column==a&&t.circularLinkType==l})).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 a=0;r.length>a;a++){var l=r[a];if(l!==t&&l.circularPathData&&void 0!==l.circularPathData.verticalBuffer&&Sn(t,l)){var s=l.circularPathData.verticalBuffer+(l._circularWidth||l.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=a.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 a=o.length;if(e)o.sort(e);else if(i>0){var l=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);l.set(t,{bc:i,idx:e})}),o.sort(function(t,e){var n=l.get(t),r=l.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==a||0==e.depth&&1==a?(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)/a*o,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-a/2+o,e.y1=e.y0+e.value*t.ky)})})}function Tn(t,e,n,r,o,i){var l=a.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});d();for(var s=1,c=i;c>0;--c)u(s*=.99,n),d();function u(e,n){var r=l.length;l.forEach(function(o){var i=o.length,l=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=a.mean(o.sourceLinks,ln),u=a.mean(o.targetLinks,an),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-sn(o))*e*.3;o.y0+=h,o.y1+=h}}else if(0==l&&1==i)o.y0=t.y1/2-(s=o.y1-o.y0)/2,o.y1=t.y1/2+s/2;else if(l==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=a.mean(o.sourceLinks,ln),y=a.mean(o.targetLinks,an),g=((f&&y?(f+y)/2:f||y)-sn(o))*e;o.y0+=g,o.y1+=g}})})}function d(){l.forEach(function(n){var i,a,l,s=t.y0,c=n.length;for(n.sort(e||xn),l=0;c>l;++l)(a=s-(i=n[l]).y0)>0&&(i.y0+=a,i.y1+=a),s=i.y1+r;if((a=s-r-t.y1)>0)for(s=i.y0-=a,i.y1-=a,l=c-2;l>=0;--l)(a=(i=n[l]).y1+o-s)>0&&(i.y0-=a,i.y1-=a),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,l=null,s=Pn,c=hn,u=void 0,d=32,h=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 a.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=Ue(n,r)),"object"!=typeof o&&(o=t.target=Ue(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],a=i.source.index,l=i.target.index;r[a]||(r[a]=[]),r[l]||(r[l]=[]),-1===r[a].indexOf(l)&&r[a].push(l)}var s=Ke(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(a.sum(t.sourceLinks,cn),a.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 a=0,l=e(t.nodes[0]);t.nodes.forEach(function(t){a=e(t)==l?a:a+1,l=e(t)==l?l:e(t),t.column=a})}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!==l){var g=a.groups(f.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=a.max(g,function(t){return t.length});p>1&&(y=Math.max(1,(r-e)*l/(p-1)))}(function(t,e,n){var r=a.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=a.min(r,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/a.sum(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var i=a.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,d),Nn(f),An(f,s,h,10,8),Ln(f,u,s),Tn(f,u,s,y,y,d),Nn(f),An(f,s,h,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,a=0;o>i;i++)a+=r[i].width;e.y0=t.y1-a-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,a=0;o>i;i++)a+=r[i].width;e.y1=t.y1-a-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=a.min(e,function(t){return t.y0}),l=a.max(e,function(t){return t.y1}),s=(t.y1-t.y0)/(l-i);function c(e){return(e-i)/(l-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,h,10,8)}(g),g}return g.update=function(t){return Nn(t),An(t,s,h,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?(l=+t,g):l},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?(d=+t,g):d},g.circularLinkGap=function(t){return arguments.length?(h=+t,g):h},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,a,l,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,a=t.target.x0,l=u.interpolateNumber(i,a),s=l(.5),c=l(.5),`M${e},${i}C${e},${s} ${n},${c} ${n},${a}L${r},${a}C${r},${c} ${o},${s} ${o},${i}Z`):(e=t.source.x1,n=t.target.x0,l=u.interpolateNumber(e,n),r=l(.5),o=l(.5),i=t.y0-t.sankeyWidth/2,a=t.y1-t.sankeyWidth/2,s=t.y1+t.sankeyWidth/2,c=t.y0+t.sankeyWidth/2,`M${e},${i}C${r},${i} ${o},${a} ${n},${a}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,a=o.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const l=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+l},${r-n}L${e+l},${r+n}L${e},${r+n}ZM${i},${a-n}L${i-s},${a-n}L${i-s},${a+n}L${i},${a+n}Z`}const i=o.sourceX,a=o.sourceY,l=o.targetX,s=o.targetY,c=o.rightFullExtent,u=o.leftFullExtent,d=o.verticalFullExtent,h="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(r,15));return`M${i},${a-h*n}L${c},${a-h*n}L${c+r},${a-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${l},${s-h*n}L${l},${s+h*n}L${u+r},${s+h*n}L${u+r},${d-h*r}L${c-r},${d-h*r}L${c-r},${a+h*n}L${i},${a+h*n}Z`}const In=new Set,zn=new WeakMap;function Rn(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let n=zn.get(t);if(n){const t=n.get(e);if(t)return t}else n=new Map,zn.set(t,n);const r=new Proxy(t,{get(t,n,r){if("string"==typeof n&&!(n in t)&&t.data&&n in t.data){const t=`${e}:${n}`;In.has(t)||(In.add(t),console.warn(`[Semiotic] "${e}" 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(t,n,r)}});return n.set(e,r),r}const Bn={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(dn))-1:0},justify:hn},jn={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,r){var o,i,a,l,s,c,u;if(0===t.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!==(a=n.iterations)&&void 0!==a?a: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"===d?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const x=$n().extent(v).links(m).nodes(p).nodeAlign(Bn[h]||hn).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,a=(null!==(s=null!==(l=r._circularWidth)&&void 0!==l?l:r.width)&&void 0!==s?s:0)/2;t>i.leftFullExtent-a&&(t=i.leftFullExtent-a),i.rightFullExtent+a>e&&(e=i.rightFullExtent+a),n>i.verticalFullExtent-a&&(n=i.verticalFullExtent-a),i.verticalFullExtent+a>o&&(o=i.verticalFullExtent+a)}const i=e-t,a=o-n,u=r[0],d=r[1];if(i>0&&a>0&&(0>t||0>n||e>u||o>d)){const e=Math.min(u/i,d/a),r=-t*e+(u-i*e)/2,o=-n*e+(d-a*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=d;const e=b.get(r),n=b.get(o);e&&(i.source=e),n&&(i.target=n)}}},buildScene(t,e,n,r){var o,a,l,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;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(Rn(e,"nodeStyle")):{},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=d?d(Rn(t,"edgeStyle")):{};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!==(a=o.fillOpacity)&&void 0!==a?a:h,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!==(l=o.fillOpacity)&&void 0!==l?l:h,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:h,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 a,l,s;"down"===c?(a=n.y0+(n.y1-n.y0)/2,l=n.x1+14,s="middle"):(r[0]/2>n.x0+t/2?(a=n.x0-6,s="end"):(a=n.x1+6,s="start"),l=n.y0+o/2),v.push({x:a,y:l,text:i+"",anchor:s,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:p,sceneEdges:m,labels:v}}},Fn={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,r){var o,i;if(0===t.length)return;const a=null!==(o=n.forceStrength)&&void 0!==o?o:.1,l=r[0]/2,s=r[1]/2,c=n.__previousPositions;let u=0;const h=[];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++):h.push(e)}const f=u>0&&.3>=(t.length>0?h.length/t.length:1);if(f){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of h){const r=Yn(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=Hn(t.id),i=o%360*(Math.PI/180),a=10+o%20;t.x=e/r.length+a*Math.cos(i),t.y=n/r.length+a*Math.sin(i)}else{const e=Hn(t.id),n=e%360*(Math.PI/180),r=15+e%30;t.x=l+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=l+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=Xn(n.nodeSize,n.nodeSizeRange,t),m=t=>p(t),v=d.forceLink().strength(t=>Math.min(2.5,t.weight?t.weight*a:a)).id(t=>t.id),x=d.forceSimulation().force("charge",d.forceManyBody().strength(t=>-25*m(t))).force("center",d.forceCenter(l,s).strength(.8)).force("x",d.forceX(l).strength(.15)).force("y",d.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,a,l;const s=n.nodeStyle,c=n.edgeStyle,u=Xn(n.nodeSize,n.nodeSizeRange,t),d=Array.isArray(n.colorScheme)?n.colorScheme:i.schemeCategory10,h=new Map;t.forEach((t,e)=>{h.set(t.id,d[e%d.length])});const f=[],y=[],g=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=u(Rn(e,"nodeSize")),n=s?s(Rn(e,"nodeStyle")):{},r={fill:n.fill||h.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(Rn(t,"edgeStyle")):{},o={stroke:r.stroke||"#999",strokeWidth:null!==(a=r.strokeWidth)&&void 0!==a?a:1,opacity:null!==(l=r.opacity)&&void 0!==l?l:.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(Rn(n,"nodeSize"));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 Yn(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 a=null;if(e===t?a=i:i===t&&(a=e),a){const t=n.get(a);!t||0===t.x&&0===t.y||r.push({x:t.x,y:t.y})}}return r}function Hn(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 Xn(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 l=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()=>l[0];const c=null!==(o=a.min(s))&&void 0!==o?o:0,u=null!==(i=a.max(s))&&void 0!==i?i:1;if(c===u)return()=>(l[0]+l[1])/2;const d=r.scaleLinear().domain([c,u]).range(l).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?l[0]:d(r)}}const Gn=i.schemeCategory10,Vn={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,r){if(0===t.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:a}=n,l=Math.min(r[0],r[1])/2,c=l-i,u=r[0]/2,d=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=h.chord().padAngle(o);a&&v.sortGroups(a);const x=v(m),b=x.groups,k=s.arc().innerRadius(c).outerRadius(l);for(const e of b){const n=t[e.index],r=k.centroid(e);n.x=r[0]+u,n.y=r[1]+d,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:a=20,edgeOpacity:l=.5}=n,s=Math.min(r[0],r[1])/2,c=s-a,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:Gn,m=new Map;t.forEach((t,e)=>{m.set(t.id,p[e%p.length])});const v=h.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(Rn(n,"nodeStyle")).fill||m.get(n.id)||p[e%p.length]:m.get(n.id)||p[e%p.length];const a=f?f(Rn(n,"nodeStyle")):{},l={fill:i,stroke:a.stroke||"black",strokeWidth:null!==(o=a.strokeWidth)&&void 0!==o?o:1,opacity:a.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:l,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=qn(n,u,d);let o="#999";if(y)o=y(Rn(t,"edgeStyle")).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 a=y?y(Rn(t,"edgeStyle")):{},s={fill:o,fillOpacity:null!==(i=a.fillOpacity)&&void 0!==i?i:l,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.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,a=i-Math.PI/2;k.push({x:u+Math.cos(a)*r,y:d+Math.sin(a)*r,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:x,sceneEdges:b,labels:k}}};function qn(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 Un=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Kn(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 Zn(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 Qn(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 Jn(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 tr={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,r){var o;const i=n.__hierarchyRoot;if(!i)return;const a=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=l.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[d,h]=r;switch(a){case"tree":!function(t,e,n,r){const o=e.treeOrientation||"vertical",i=l.tree();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(t)}(u,n,d,h);break;case"cluster":!function(t,e,n,r){const o=e.treeOrientation||"vertical",i=l.cluster();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(t)}(u,n,d,h);break;case"treemap":!function(t,e,n,r){var o,i;const a=null!==(o=e.padding)&&void 0!==o?o:4,s=null!==(i=e.paddingTop)&&void 0!==i?i:0,c=l.treemap().size([n,r]).tile(l.treemapBinary).padding(a);s>0&&c.paddingTop(s),c(t)}(u,n,d,h);break;case"circlepack":!function(t,e,n,r){var o;const i=null!==(o=e.padding)&&void 0!==o?o:4;l.pack().size([n,r]).padding(i)(t)}(u,n,d,h);break;case"partition":!function(t,e,n,r){var o;l.partition().size([n,r]).padding(null!==(o=e.padding)&&void 0!==o?o:1)(t)}(u,n,d,h)}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:Zn(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"===a||"cluster"===a?er(i,r,n):"treemap"===a||"partition"===a?nr(i,r):"circlepack"===a&&rr(i,r),i.__hierarchyNode=r,t.push(i),y.set(r,i)}if("tree"===a||"cluster"===a)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 a,l,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 e of t){let t=e.x,r=e.y;g&&(t+=p,r+=m);const i=o(Rn(e,"nodeStyle"));let l=i.fill||"#4d430c";n.colorByDepth&&void 0!==e.depth&&(l=Un[e.depth%Un.length]);const s={fill:l,stroke:i.stroke||"#fff",strokeWidth:null!==(a=i.strokeWidth)&&void 0!==a?a:1,opacity:i.opacity};d.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!==(l=n.edgeOpacity)&&void 0!==l?l:.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,a=n.x,l=n.y;g&&(r+=p,o+=m,a+=p,l+=m);const u=Jn(r,o,a,l,y),d=i(Rn(t,"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:t})}if(!1!==n.showLabels){const e=Qn(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let r,o,i,a=n.x,l=n.y;if(g&&(a+=p,l+=m),g){const t=a-p,e=l-m,n=Math.sqrt(t*t+e*e);n>0?(r=a+t/n*10,o=l+e/n*10,i=0>t?"end":"start"):(r=a,o=l-12,i="middle")}else"horizontal"===y?((null===(u=n.data)||void 0===u?void 0:u.children)&&0!==n.data.children.length?(r=a-v-6,i="end"):(r=a+v+6,i="start"),o=l):(r=a,o=l+v+14,i="middle");f.push({x:r,y:o,text:t+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:f}}(t,e,n,r,o,i);case"treemap":case"partition":return function(t,e,n,r){var o,i;const a=[],l=[];for(const n of t){const t=n.x1-n.x0,i=n.y1-n.y0;if(0>=t||0>=i)continue;const l=r(Rn(n,"nodeStyle"));let s=l.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(s=Un[n.depth%Un.length]);const c={fill:s,stroke:l.stroke||"#fff",strokeWidth:null!==(o=l.strokeWidth)&&void 0!==o?o:1,opacity:l.opacity};a.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=Qn(e.nodeLabel),o=e.labelMode||"leaf",a="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(!a){if("leaf"===o&&!u)continue;if("parent"===o&&u)continue}const d=n?n(s):s.id;if(!d)continue;if((u?30:40)>t||(u?16:14)>c)continue;let h=r(Rn(s,"nodeStyle")).fill||"#4d430c";e.colorByDepth&&void 0!==s.depth&&(h=Un[s.depth%Un.length]);const f=Kn(h);l.push(u?{x:s.x0+t/2,y:s.y0+c/2,text:d+"",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:d+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:f})}}return{sceneNodes:a,sceneEdges:[],labels:l}}(t,n,0,o);case"circlepack":return function(t,e,n,r){var o,i,a,l,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 l=r(Rn(n,"nodeStyle"));let s=l.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(s=Un[n.depth%Un.length]);const u={fill:s,stroke:l.stroke||"#fff",strokeWidth:null!==(i=l.strokeWidth)&&void 0!==i?i:1,opacity:null!==(a=l.opacity)&&void 0!==a?a:.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=Qn(e.nodeLabel);for(const o of t){const t=null!==(l=o.__radius)&&void 0!==l?l:5,i=n?n(o):o.id;if(!i)continue;if(15>t)continue;const a=!((null===(s=o.data)||void 0===s?void 0:s.children)&&o.data.children.length>0);let c=r(Rn(o,"nodeStyle")).fill||"#4d430c";if(e.colorByDepth&&void 0!==o.depth&&(c=Un[o.depth%Un.length]),a){const e=Kn(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 er(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 nr(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 rr(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 or(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const ir={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,r){const o=n.__hierarchyRoot;o&&function(t,e,n,r,o){var i,a;const l=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),d=null!==(i=n.orbitSize)&&void 0!==i?i:2.95,h=null!==(a=n.orbitEccentricity)&&void 0!==a?a:1,f="number"==typeof d?()=>d:d,y="number"==typeof h?()=>h:h,g=or(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,a,d,h,p){const v=l(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:h,data:e,parentId:n},S=p?d/f(M)*A:d*A,_=s.pie().value(t=>{var e;return(null===(e=l(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 l=(P[e].startAngle+P[e].endAngle)/2,s=w[e],u=m(c(s)),d=i+S*Math.sin(l),f=a+S*Math.cos(l)*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:l,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}}),t(s,u,d,f,S,h+1,!0)}E+=k}}(t,k,v,x,b,1,!1)}(o,r,n,t,e)},buildScene(t,e,n,r){var o,i,a,l,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 e=or(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,a={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 l=o/i*Math.PI*2,s=(o+1)/i*Math.PI*2;f.push({type:"line",x1:t+n*Math.sin(l),y1:e+n*Math.cos(l)*r,x2:t+n*Math.sin(s),y2:e+n*Math.cos(s)*r,style:a,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=d(Rn(e,"nodeSize")),n=c?c(Rn(e,"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!==(a=e.depth)&&void 0!==a?a:0)?1:.85};h.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=d(Rn(n,"nodeSize"));if(4>=t)continue;const r="function"==typeof e?e(n):e&&null!==(s=null===(l=n.data)||void 0===l?void 0:l[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:h,sceneEdges:f,labels:y}},tick:(t,e,n,r,o)=>!1!==n.orbitAnimated&&(function(t,e){var n,r;const o=or(e),i=null!==(n=e.orbitSpeed)&&void 0!==n?n:.25,a=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),l=(("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+l*s*a({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)},ar={sankey:jn,force:Fn,chord:Vn,tree:tr,cluster:tr,treemap:tr,circlepack:tr,partition:tr,orbit:ir};function lr(t){return ar[t]}class sr{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:a="value"}=this.config,l="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 a?a:t=>{var e;return null!==(e=t[a])&&void 0!==e?e:1};this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of t){const t=l(e)+"";this.nodes.set(t,Object.assign(Object.assign({},cr(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({},cr(r)),{data:n})),this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},cr(o)),{data:n}));const a=`${r}\0${o}\0${t}`;this.edges.set(a,{source:r,target:o,value:i,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:a})}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 a="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=a,this._decaySortedNodes=null,this.nodes.has(e)||(this.nodes.set(e,cr(e)),this.nodeTimestamps.set(e,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,cr(n)),this.nodeTimestamps.set(n,a),this.tension+=this.tensionConfig.newNode,i=!0);const l=this.edgeKey(e,n),s=this.edges.get(l);let c=!1;return s?(s.value+=r,this.edgeTimestamps.set(l,a),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(l,{source:e,target:n,value:r,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(l,a),this.tension+=this.tensionConfig.newEdge,i=!0),o||i||c||this.tension>=this.tensionConfig.threshold}runLayout(t){var e,n,r,o,i,a;const l=lr(this.config.chartType);if(!l)return;let s=Array.from(this.nodes.values()),c=Array.from(this.edges.values());if(0===s.length&&!l.hierarchical)return;if(this.prepareForRelayout(),l.supportsStreaming&&!l.hierarchical){const t=new Map;for(const l of s)if(void 0!==l._prevX0){const s=(null!==(e=l._prevX1)&&void 0!==e?e:0)-(null!==(n=l._prevX0)&&void 0!==n?n:0),c=(null!==(r=l._prevY1)&&void 0!==r?r:0)-(null!==(o=l._prevY0)&&void 0!==o?o:0);t.set(l.id,{x:(null!==(i=l._prevX0)&&void 0!==i?i:0)+s/2,y:(null!==(a=l._prevY0)&&void 0!==a?a:0)+c/2})}else 0===l.x&&0===l.y||t.set(l.id,{x:l.x,y:l.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(l.computeLayout(s,c,this.config,t),delete this.config.__previousPositions,l.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 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 t of d)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)d.has(t)||this.removedNodes.add(t);for(const t of h)this.previousEdgeKeys.has(t)||this.addedEdges.add(t);for(const t of this.previousEdgeKeys)h.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=d,this.previousEdgeKeys=h,this.layoutVersion++}buildScene(t){const e=lr(this.config.chartType);if(!e)return;const n=Array.from(this.nodes.values()),r=Array.from(this.edges.values()),{sceneNodes:o,sceneEdges:i,labels:a}=e.buildScene(n,r,this.config,t);this.sceneNodes=o,this.sceneEdges=i,this.labels=a}get isAnimating(){const t=lr(this.config.chartType);return!!(null==t?void 0:t.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(t,e){const n=lr(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,a=u.interpolateNumber(o,i);return{circular:!1,points:[{x:t.y0,y:o},{x:t.y0,y:a(.5)},{x:t.y1,y:a(.5)},{x:t.y1,y:i}],halfWidth:r}}const o=e.x1,i=n.x0,a=u.interpolateNumber(o,i);return{circular:!1,points:[{x:o,y:t.y0},{x:a(.5),y:t.y0},{x:a(.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,a=n.y-e.y;o.push([e,{x:e.x+i/3,y:e.y+a/3},{x:e.x+2*i/3,y:e.y+2*a/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 a=this.config.pulse;if(!a)return;const l=null!==(e=a.duration)&&void 0!==e?e:500,s=null!==(n=a.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(r=a.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;l>o&&(e._pulseIntensity=1-o/l,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,a="object"==typeof n.target?null===(i=n.target)||void 0===i?void 0:i.id:n.target;if(!r||!a)continue;const c=this.edgeTimestamps.get(`${r}\0${a}`);if(!c)continue;const u=t-c;l>u&&(e._pulseIntensity=1-u/l,e._pulseColor=s)}}applyDecay(){var t,e,n,r,o;const i=this.config.decay;if(!i)return;const a=null!==(t=i.minOpacity)&&void 0!==t?t:.1,l=this.nodeTimestamps.size;if(1>=l)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 d=l-1-u;let h;switch(i.type){case"linear":h=a+(1-d/(l-1))*(1-a);break;case"exponential":{const t=null!==(e=i.halfLife)&&void 0!==e?e:l/2;h=a+Math.pow(.5,d/t)*(1-a);break}case"step":h=(null!==(n=i.stepThreshold)&&void 0!==n?n:.5*l)>d?1:a;break;default:h=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*h})}}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",a=!1!==r.pulse;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const l=this.nodes.get(n);if(!l)continue;const s=r.metric(l);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}),a&&(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 cr(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 ur(t,e,n,r,o=30){let i=null,a=o,l=1/0;for(const e of t){const t=dr(e,n,r);if(t)if("rect"===e.type){const n=e.w*e.h;l>n&&(i=t,l=n)}else a>t.distance&&(i=t,a=t.distance)}if(i)return i;for(const t of e){const e=gr(t,n,r);e&&a>e.distance&&(i=e,a=e.distance)}return i}function dr(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 a=G(Math.atan2(o,r)),l=G(t.startAngle),s=G(t.endAngle);if(l>s?a>=l||s>=a:a>=l&&s>=a){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 hr=null,fr=null;function yr(){return fr||(hr=document.createElement("canvas"),hr.width=1,hr.height=1,fr=hr.getContext("2d")),fr}function gr(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),a=yr();if(!a)return null;if(a.isPointInPath(i,e,n)){const i="object"==typeof(null===(r=t.datum)||void 0===r?void 0:r.source)?t.datum.source:null,a="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&&a?(i.x1+a.x0)/2:e,y:t.datum?(t.datum.y0+t.datum.y1)/2:n,distance:0}}const l=a.lineWidth;a.lineWidth=10;const s=a.isPointInStroke(i,e,n);if(a.lineWidth=l,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 a=((e-t.x1)*r+(n-t.y1)*o)/i;a=Math.max(0,Math.min(1,a));const l=t.x1+a*r,s=t.y1+a*o,c=Math.sqrt(Math.pow(e-l,2)+Math.pow(n-s,2));return c>5?null:{type:"edge",datum:t.datum,x:l,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=yr();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 a=o.isPointInStroke(r,e,n);if(o.lineWidth=i,a)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch(t){}return null}(t,e,n);default:return null}}function pr(t){const{width:e,height:n,totalWidth:r,totalHeight:o,margin:i,labels:a,title:l,legend:s,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h,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 l?l:"Network Chart"),g.createElement("desc",null,"string"==typeof l?l+" — network data visualization":"Network data visualization"),g.createElement("g",{transform:`translate(${i.left},${i.top})`},a.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),l&&"string"==typeof l?g.createElement("text",{x:r/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},l):l?g.createElement("foreignObject",{x:0,y:0,width:r,height:i.top},l):null,yt({legend:s,totalWidth:r,totalHeight:o,margin:i,legendPosition:f,title:l,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h})),null==m?void 0:m.filter(t=>"widget"===t.type&&t.nodeId&&p).map((t,e)=>{var n,r,o,a,l,s,c,u,d;const h=p.find(e=>{var n,r,o,i,a;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===(a=null===(i=e.datum)||void 0===i?void 0:i.data)||void 0===a?void 0:a.name)===t.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!==(a=h.y)&&void 0!==a?a:0),m=null!==(l=t.dx)&&void 0!==l?l: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!==(d=t.content)&&void 0!==d?d: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 mr(t,e){var n,r,o,i,a,l;if(!e.pathD)return;t.save();const s=new Path2D(e.pathD);if(e.style.fill&&"none"!==e.style.fill){const a=e._gradient;if(a){const o=t.createLinearGradient(a.x0,0,a.x1,0),i=null!==(r=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==r?r:.5,l="string"==typeof e.style.fill?e.style.fill:"#999";o.addColorStop(0,1===a.from?l:"transparent"),o.addColorStop(1,1===a.to?l:"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!==(a=e.style.strokeWidth)&&void 0!==a?a:.5,t.globalAlpha=.5*(null!==(l=e.style.opacity)&&void 0!==l?l: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 vr(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 xr(t,e){var n,r,o,i;if(!e.pathD)return;t.save();const a=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(a)),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(a)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.25*e._pulseIntensity,t.fill(a)),t.restore()}function br(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()}pr.displayName="NetworkSVGOverlay";const kr={top:20,right:80,bottom:20,left:80},wr={top:40,right:40,bottom:40,left:40},Er=new Set(["chord","force","circlepack","orbit"]),Ar=[800,600],Mr={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 Sr({data:t}){var e,n,r,o,i,a;if("edge"===t.type){const e=t.data;return g.createElement("div",{className:"semiotic-tooltip",style:Mr},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 l=t.data,s=null==l?void 0:l.__hierarchyNode;if(s){const t=[];let i=s;for(;i;){const a=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:l.id;null!=a&&t.unshift(a+""),i=i.parent}t.length>1&&t.shift();const a=t.length-1;return g.createElement("div",{className:"semiotic-tooltip",style:Mr},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===a?g.createElement("strong",null,t):g.createElement("span",{style:{opacity:.7}},t)))),null!=l.value&&l.value>0&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof l.value?l.value.toLocaleString():l.value+""))}const c=((null===(i=l.sourceLinks)||void 0===i?void 0:i.length)||0)+((null===(a=l.targetLinks)||void 0===a?void 0:a.length)||0),u=(l.sourceLinks||[]).reduce((t,e)=>t+(e.value||0),0)+(l.targetLinks||[]).reduce((t,e)=>t+(e.value||0),0);return g.createElement("div",{className:"semiotic-tooltip",style:Mr},g.createElement("div",{style:{fontWeight:600}},l.id),null!=l.value&&l.value>0&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof l.value?l.value.toLocaleString():l.value+""),c>0&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",c,u!==c&&` (weighted: ${u.toLocaleString()})`))}const _r=t.forwardRef(function(e,n){var r,o,i,a,l,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:_="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:U,colorBy:K,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:dt=Ar,responsiveWidth:ht,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:Ut,orbitEccentricity:Kt,orbitShowRings:Zt,orbitAnimated:Qt}=e,Jt=ue(),te=t.useRef(Jt);te.current=Jt;const ee="semiotic-table-"+g.useId(),ne=Er.has(x)?wr:kr,[le,de]=at(dt,ht,ft),he=Object.assign(Object.assign({},ne),yt),fe=de[0]-he.left-he.right,ye=de[1]-he.top-he.bottom,ge="function"==typeof Nt?Nt({size:de,margin:he}):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:U,nodeLabel:st,showLabels:ct,labelMode:ut,colorBy:K,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:Ut,orbitEccentricity:Kt,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,U,st,ct,ut,K,Z,Q,J,tt,ot,it,Ot,Wt,It,zt,Ht,Xt,Gt,qt,Ut,Kt,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 sr(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 K)return K(t)+"";if("string"==typeof K&&t.data){const e=t.data[K];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=K?e[je.current++%e.length]:e[0];return Be.current.set(t.id,n),n},[K,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 Ue=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]),Ke=t.useCallback(t=>{const e=De.current;e&&(e.ingestEdge(t)&&Ue(),qe())},[Ue,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&&Ue(),qe()},[Ue,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,Ue(),qe())},[Ue,qe]);t.useImperativeHandle(n,()=>({push:Ke,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}}),[Ke,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(()=>{}),an=t.useRef(()=>{});on.current=t=>{if(!mt)return;const e=we.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-he.left,o=t.clientY-n.top-he.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 a=ur(i.sceneNodes,i.sceneEdges,r,o);if(!a)return void(Re.current&&(Re.current=null,Te(null),nn&&(nn(null),_e.current=!0),qe()));const l=a.datum||{},s=Object.assign(Object.assign({},"object"!=typeof l||null===l||Array.isArray(l)?{}:l),{type:a.type,data:l,x:a.x,y:a.y});Re.current=s,Te(s),nn&&(nn(s),_e.current=!0),qe()},an.current=()=>{Re.current&&(Re.current=null,Te(null),nn&&(nn(null),_e.current=!0),qe())};const ln=t.useRef(()=>{});ln.current=t=>{if(!bt&&!kt)return;const e=we.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-he.left,o=t.clientY-n.top-he.top;if(0>r||r>fe||0>o||o>ye)return;const i=De.current;if(!i)return;const a=ur(i.sceneNodes,i.sceneEdges,r,o);if(a){const t=a.datum||{};rn(Object.assign(Object.assign({},"object"!=typeof t||null===t||Array.isArray(t)?{}:t),{type:a.type,data:t,x:a.x,y:a.y}))}else rn(null)},t.useCallback(t=>on.current(t),[]);const sn=t.useCallback(()=>an.current(),[]),cn=t.useCallback(t=>ln.current(t),[]),un=t.useRef(-1),dn=t.useRef(null),hn=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,a;const l=[];for(const s of t)"circle"===s.type&&null!=s.cx?l.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?l.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&&l.push({x:s.cx,y:s.cy,datum:s.datum,shape:"circle",group:null!==(a=null===(i=s.datum)||void 0===i?void 0:i.id)&&void 0!==a?a:"_default"});return l.sort((t,e)=>t.x-e.x||t.y-e.y),l}(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,hn.current=-1;const e=o.flat[0];dn.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 a=nt(o,i),l=function(t,e,n,r,o){var i,a,l;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!==(a=function(t,e,n){let r=null,o=1/0;for(let i=0;t.flat.length>i;i++){const a=t.flat[i];if(a===e)continue;const l=a.x-e.x,s=a.y-e.y;let c=!1;switch(n){case"right":c=l>0&&Math.abs(l)>=Math.abs(s);break;case"left":c=0>l&&Math.abs(l)>=Math.abs(s);break;case"down":c=s>0&&Math.abs(s)>=Math.abs(l);break;case"up":c=0>s&&Math.abs(s)>=Math.abs(l)}if(!c)continue;const u=l*l+s*s;o>u&&(o=u,r=i)}return r}(n,s,"ArrowRight"===t?"right":"ArrowLeft"===t?"left":"ArrowDown"===t?"down":"up"))&&void 0!==a?a: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+"",a=[];for(const t of e){const e=null!==(n=t.datum)&&void 0!==n?n:t,l="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!=l,u=null!=s;c&&l+""===i&&u?a.push(s+""):u&&s+""===i&&c&&a.push(l+"")}return a}(c,r);if(0===t.length)return e.flatIndex;const i=null!==(l=n.idToIdx.get(t[(o.current+1)%t.length]))&&void 0!==l?l:-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,a,o,null!==(e=n.sceneEdges)&&void 0!==e?e:[],hn);if(null===l)return;if(t.preventDefault(),0>l)return un.current=-1,dn.current=null,hn.current=-1,Re.current=null,Te(null),nn&&(nn(null),_e.current=!0),void qe();un.current=l;const s=o.flat[l];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});Re.current=u,Te(u),nn&&(nn(u),_e.current=!0),qe()},[nn,qe]),yn=t.useCallback(t=>{un.current=-1,dn.current=null,on.current(t)},[]);Ce.current=()=>{var t,e,n,r,o,i,a;Ee.current=0;const l=we.current;if(!l)return;const s=l.getContext("2d");if(!s)return;const c=De.current;if(!c)return;const u=performance.now(),d=Se.current?Math.min((u-Se.current)/1e3,.1):.016;Se.current=u;const h=c.advanceTransition(te.current?u+1e6:u),f=!te.current&&h,y=!te.current&&c.tickAnimation([fe,ye],d);(h||_e.current||y)&&c.buildScene([fe,ye]);const g=xe();if(!ve(l,de,he,g))return;s.clearRect(-he.left,-he.top,de[0],de[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":mr(t,n);break;case"line":vr(t,n);break;case"ribbon":xr(t,n);break;case"curved":br(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 a=null!==(o=r.spawnRate)&&void 0!==o?o:Xe.spawnRate,l=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)>=l)continue;const i=o.value*a*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)<l;e++)t.spawn(r)}}(c.particlePool,t,d,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(d,e,t,r),function(t,e,n,r,o){var i,a;const l=null!==(i=r.radius)&&void 0!==i?i:Xe.radius,s=null!==(a=r.opacity)&&void 0!==a?a:Xe.opacity;t.globalAlpha=s;for(let i=0;e.particles.length>i;i++){const a=e.particles[i];if(!a.active)continue;const s=n[a.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(a.x,a.y,l,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!==(a=null===(i=c.sceneEdges)||void 0===i?void 0:i.length)&&void 0!==a?a: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]),lt(It,De,_e,qe,Ie,ze);const gn=mt&&Le?g.createElement(ce,{x:Le.x,y:Le.y,containerWidth:fe,containerHeight:ye,margin:he,className:"stream-network-tooltip",zIndex:2},vt?vt(Le):g.createElement(Sr,{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!==(a=null==t?void 0:t.sceneEdges)&&void 0!==a?a:[],r=null!==(l=null==t?void 0:t.labels)&&void 0!==l?l:[];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:de[0],height:de[1]}},g.createElement(oe,{summary:Yt}),g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:de[0],height:de[1],style:{position:"absolute",left:0,top:0}},$t&&g.createElement("g",{transform:`translate(${he.left},${he.top})`},$t),g.createElement("g",{transform:`translate(${he.left},${he.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(pr,{width:fe,height:ye,totalWidth:de[0],totalHeight:de[1],margin:he,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:le,className:"stream-network-frame"+(gt?" "+gt:""),role:"group","aria-label":Bt||("string"==typeof Tt?Tt:"Network chart"),tabIndex:0,style:{position:"relative",width:ht?"100%":de[0],height:ft?"100%":de[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:de[0],height:de[1],pointerEvents:"none",overflow:"visible"}},g.createElement("g",{transform:`translate(${he.left},${he.top})`},$t)),g.createElement("canvas",{ref:we,"aria-label":Vt(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(ae,{hoverPoint:Le}),g.createElement(pr,{width:fe,height:ye,totalWidth:de[0],totalHeight:de[1],margin:he,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:he,size:de,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==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 Pr(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 Cr(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}_r.displayName="StreamNetworkFrame";const[Dr,Lr]=de(t=>({selections:new Map,setClause(e,n){t(t=>{const r=new Map(t.selections),o=Cr(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=Cr(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}})}})),[Tr,Nr]=de(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 $r(e){const n=t.useId(),r=e.clientId||n,{name:o}=e,i=Lr(t=>t.selections.get(o)),a=Lr(t=>t.setClause),l=Lr(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(Pr(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)};a(o,{clientId:r,type:"point",fields:e})},[r,o,a]),selectInterval:t.useCallback(t=>{const e={};for(const[n,r]of Object.entries(t))e[n]={type:"interval",range:r};a(o,{clientId:r,type:"interval",fields:e})},[r,o,a]),clear:t.useCallback(()=>{l(o,r)},[l,o,r]),clientId:r}}function Or({selection:e,linkedHover:n,fallbackFields:r=[],unwrapData:o=!1,onObservation:i,chartType:a,chartId:l,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),d=$r({name:(null==e?void 0:e.name)||"__unused__"}),h=function(e){const n=e.name||"hover",{fields:r}=e,{predicate:o,isActive:i,selectPoints:a,clear:l}=$r({name:n});return{onHover:t.useCallback(t=>{if(!t)return void l();const e={};for(const n of r){const r=t[n];void 0!==r&&(e[n]=[r])}Object.keys(e).length>0&&a(e)},[r,a,l,n]),predicate:o,isActive:i}}({name:(null==u?void 0:u.name)||"hover",fields:(null==u?void 0:u.fields)||r||[]}),f=Nr(t=>t.pushObservation),y=e?{isActive:d.isActive,predicate:d.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)&&h.onHover(e)}else"x-position"===(null==u?void 0:u.mode)&&Ct(u.name||"hover",c),"x-position"!==(null==u?void 0:u.mode)&&h.onHover(null);if(i||f){const n={timestamp:Date.now(),chartType:a||"unknown",chartId:l};if(t){let o=t.data||t.datum||t;Array.isArray(o)&&(o=o[0]);const a=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(a),f&&f(a)}else{const t=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(t),f&&f(t)}}},[n,h,u,c,i,a,l,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:a||"unknown",chartId:l};if(t){let n=t.data||t.datum||t;Array.isArray(n)&&(n=n[0]);const a=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(a),f&&f(a)}else{const t=Object.assign(Object.assign({},e),{type:"click-end"});i&&i(t),f&&f(t)}}},[s,i,f,a,l]);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 Wr={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 Ir(t,e,n){var r,o,i,a,l,s;const c=Wr[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!==(a=e.enableHover)&&void 0!==a?a:!!e.linkedHover||c.enableHover,showLegend:null!==(l=e.showLegend)&&void 0!==l?l: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:zr(c.marginDefaults,e.showCategoryTicks,e.orientation)}}function zr(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 Rr={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"},Br={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function jr(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({},Rr),{width:e,height:n})},r||"No data available"):null}function Fr(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))),a=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({},Br),{position:"absolute",top:a+n*(o+i),left:Math.floor(.1*e),width:30+(37*n+13)%50+"%",height:o,opacity:.5+n%2*.2})})))}const Yr=t.forwardRef(function(e,n){var r,o,i,a;const l=Ir(e.mode,{width:null!==(o=null===(r=e.size)||void 0===r?void 0:r[0])&&void 0!==o?o:e.width,height:null!==(a=null===(i=e.size)||void 0===i?void 0:i[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.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:_,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=l.showAxes,X=l.enableHover,G=null!=c?c:l.marginDefaults,V=null!=s?s:[l.width,l.height],q=null!=M?M:S,U=t.useRef(null),{customHoverBehavior:K}=Or({selection:I,linkedHover:W,unwrapData:!0,onObservation:z,chartType:"RealtimeLineChart",chartId:R}),Z=t.useCallback(t=>{_&&_(t),K(t)},[_,K]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=U.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=U.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Q=Fr(B,V[0],V[1]),J=Q?null:jr(y,V[0],V[1],j),tt={stroke:k,strokeWidth:w,strokeDasharray:E};return Q||J||g.createElement(Ye,{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: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})});Yr.displayName="RealtimeLineChart";const Hr=t.forwardRef(function(e,n){var r,o,i,a;const l=Ir(e.mode,{width:null!==(o=null===(r=e.size)||void 0===r?void 0:r[0])&&void 0!==o?o:e.width,height:null!==(a=null===(i=e.size)||void 0===i?void 0:i[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.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:_,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:U,linkedBrush:K}=e,Z=l.showAxes,Q=l.enableHover,J=null!=u?u:l.marginDefaults,tt=null!=c?c:[l.width,l.height],et=null!=C?C:D,nt=t.useRef(null),{customHoverBehavior:rt}=Or({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,at=(lt=K)?"string"==typeof lt?{name:lt}:lt:null;var lt;const st=function(e){const{name:n,xField:r,yField:o}=e,{predicate:i,isActive:a,selectInterval:l,clear:s}=$r({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&&l(e)},[c,r,o,l,s]);return{brushInteraction:t.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:i,isActive:a,clear:s}}(Object.assign({name:(null==at?void 0:at.name)||"__unused_hist_brush__",xField:(null==at?void 0:at.xField)||("string"==typeof m?m:"time")},(null==at?void 0:at.yField)?{yField:at.yField}:{})),ct=t.useRef(st.brushInteraction);ct.current=st.brushInteraction;const ut=t.useCallback(t=>{if(U&&U(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}),at){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)}},[U,F,Y,at]);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 dt=Fr(H,tt[0],tt[1]),ht=dt?null:jr(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=_),dt||ht||g.createElement(Ye,{ref:nt,chartType:"bar",runtimeMode:"streaming",size:tt,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: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||(K?{dimension:"x"}:void 0),onBrush:it||K?ut:void 0})});Hr.displayName="RealtimeTemporalHistogram";const Xr=Hr,Gr=t.forwardRef(function(e,n){var r,o,i,a;const l=Ir(e.mode,{width:null!==(o=null===(r=e.size)||void 0===r?void 0:r[0])&&void 0!==o?o:e.width,height:null!==(a=null===(i=e.size)||void 0===i?void 0:i[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.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:_,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=l.showAxes,X=l.enableHover,G=null!=c?c:l.marginDefaults,V=null!=s?s:[l.width,l.height],q=null!=C?C:D,U=t.useRef(null),{customHoverBehavior:K}=Or({selection:I,linkedHover:W,unwrapData:!0,onObservation:z,chartType:"RealtimeSwarmChart",chartId:R}),Z=t.useCallback(t=>{L&&L(t),K(t)},[L,K]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=U.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=U.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Q=Fr(B,V[0],V[1]),J=Q?null:jr(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: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:tt,showAxes:H,background:P,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:Z,annotations:T,svgAnnotationRules:N,tickFormatTime:$,tickFormatValue:O,legendPosition:Y})});Gr.displayName="RealtimeSwarmChart";const Vr=t.forwardRef(function(e,n){var r,o,i,a;const l=Ir(e.mode,{width:null!==(o=null===(r=e.size)||void 0===r?void 0:r[0])&&void 0!==o?o:e.width,height:null!==(a=null===(i=e.size)||void 0===i?void 0:i[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.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:_,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=l.showAxes,X=l.enableHover,G=null!=c?c:l.marginDefaults,V=null!=s?s:[l.width,l.height],q=null!=C?C:D,U=t.useRef(null),{customHoverBehavior:K}=Or({selection:I,linkedHover:W,unwrapData:!0,onObservation:z,chartType:"RealtimeWaterfallChart",chartId:R}),Z=t.useCallback(t=>{L&&L(t),K(t)},[L,K]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=U.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=U.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Q=Fr(B,V[0],V[1]),J=Q?null:jr(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: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:tt,showAxes:H,background:P,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:Z,annotations:T,svgAnnotationRules:N,tickFormatTime:$,tickFormatValue:O,legendPosition:Y})});Vr.displayName="RealtimeWaterfallChart";const qr=t.forwardRef(function(e,n){var r,o,i,a;const l=Ir(e.mode,{width:null!==(o=null===(r=e.size)||void 0===r?void 0:r[0])&&void 0!==o?o:e.width,height:null!==(a=null===(i=e.size)||void 0===i?void 0:i[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.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:_,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=l.showAxes,X=l.enableHover,G=null!=c?c:l.marginDefaults,V=null!=s?s:[l.width,l.height],q=null!=S?S:_,U=t.useRef(null),{customHoverBehavior:K}=Or({selection:I,linkedHover:W,unwrapData:!0,onObservation:z,chartType:"RealtimeHeatmap",chartId:R}),Z=t.useCallback(t=>{P&&P(t),K(t)},[P,K]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=U.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=U.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Q=Fr(B,V[0],V[1]),J=Q?null:jr(y,V[0],V[1],j);return Q||J||g.createElement(Ye,{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:$,staleness:O,legendPosition:Y})});qr.displayName="RealtimeHeatmap",exports.IncrementalExtent=w,exports.RealtimeHeatmap=qr,exports.RealtimeHistogram=Xr,exports.RealtimeLineChart=Yr,exports.RealtimeSwarmChart=Gr,exports.RealtimeWaterfallChart=Vr,exports.RingBuffer=k,exports.StreamNetworkFrame=_r,exports.StreamXYFrame=Ye;
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"),d=require("d3-force"),h=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 v(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 m(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:d,snap:h,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"===h&&"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:[v(t[0],e),m(t[1],e)]}(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)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,h,d,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"===h){const t=A.current;t&&t.length>0?o=m(n,t):d&&d>0&&(o=Math.ceil(n/d)*d)}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,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(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}update(t,e){const n=[],r=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){const i=(r+o)%this._capacity,l=this.buffer[i];if(t(l)){let t;t="object"!=typeof l||null===l?l:Array.isArray(l)?[...l]:Object.assign({},l),n.push(t),this.buffer[i]=e(l)}}return n}remove(t){const e=[],n=[];if(this.forEach(r=>{t(r)?n.push(r):e.push(r)}),0===n.length)return n;this.buffer=Array(this._capacity),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 P(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}const _=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 O(t,e,n){return t+(e-t)*n}function $(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 I(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 W(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},H=new Map;class X{constructor(t){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=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=P(t.groupAccessor),this.getCategory=P(t.categoryAccessor),this.getSize=t.sizeAccessor?M(t.sizeAccessor,"size"):void 0,this.getColor=P(t.colorAccessor),this.getBounds=t.boundsAccessor?M(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?M(t.y0Accessor,"y0"):void 0,this.getPointId=P(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,n=null!=t.closeAccessor;this.getOpen=e?M(t.openAccessor,"open"):void 0,this.getHigh=M(t.highAccessor,"high"),this.getLow=M(t.lowAccessor,"low"),this.getClose=n?M(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!n}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,s;const{config:c,buffer:u}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(e=this.config.scalePadding)&&void 0!==e?e:0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);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 t of u)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}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 t=`${u.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)g=this._stackExtentCache.yDomain;else{const e=this.groupData(d),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);g=[0,r+(r>0?r*c.extentPadding:1)],this._stackExtentCache={key:t,yDomain:g}}}else if("bar"===c.chartType&&c.binSize&&!p&&u.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]}(u,this.getX,this.getY,c.binSize,this.getCategory);g=[0,t+t*c.extentPadding]}else if("waterfall"===c.chartType&&!p&&u.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]}(u,this.getY),n=e-t,r=n>0?n*c.extentPadding:1;g=[Math.min(0,t-Math.abs(r)),Math.max(0,e+Math.abs(r))]}else if(!p&&g[0]!==1/0){if(this.getBounds)for(const t of d){const e=this.getY(t),n=this.getBounds(t);null!=e&&!Number.isNaN(e)&&n&&(e+n>g[1]&&(g[1]=e+n),g[0]>e-n&&(g[0]=e-n))}const t=g[1]-g[0],e=t>0?t*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]-e,null!=r?g[1]:g[1]+e],"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 t=Date.now();y=[t-864e5,t]}else y=[0,1];g[0]!==1/0&&g[1]!==-1/0||(g=[0,1]);const v="streaming"===c.runtimeMode,m=Math.max(0,Math.min(c.scalePadding||0,Math.min(t.width,t.height)/2-1));if(v)if("x"==("up"===(x=c.arrowOfTime)||"down"===x?"y":"x")){const e="right"===c.arrowOfTime?[m,t.width-m]:[t.width-m,m];this.scales={x:r.scaleLinear().domain(y).range(e),y:r.scaleLinear().domain(g).range([t.height-m,m])}}else{const e="down"===c.arrowOfTime?[m,t.height-m]:[t.height-m,m];this.scales={x:r.scaleLinear().domain(g).range([m,t.width-m]),y:r.scaleLinear().domain(y).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"time"===t?r.scaleTime().domain([new Date(e[0]),new Date(e[1])]).range(n):r.scaleLinear().domain(e).range(n)};this.scales={x:e(c.xScaleType,y,[m,t.width-m]),y:e(c.yScaleType,g,[t.height-m,m])}}var x;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,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: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>X.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"time"===t?r.scaleTime().domain([new Date(e[0]),new Date(e[1])]).range(n):r.scaleLinear().domain(e).range(n)},c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),u=a[1]>a[0];this.scales={x:s(this.config.xScaleType,o,l[0]>l[1]?[t.width-c,c]:[c,t.width-c]),y:s(this.config.yScaleType,i,u?[c,t.height-c]:[t.height-c,c])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){var n;const{config:r,scales:o}=this;if(!o||0===e.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:(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(r.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=I(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),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),o.push(r)}return F(t,r,o),o}(l,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=W(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),t.config.lineGradient&&(l.strokeGradient=t.config.lineGradient),r.push(l)}return F(t,n,r),r}(l,e);case"mixed":return function(t,e){const n=t.groupData(e),r=[],o=t.config.areaGroups||new Set,i=t.scales.y.domain()[0],l=t.getY0?e=>{const n=t.getY0(e);return null==n?i:n}:void 0;for(const e of n)if(o.has(e.key)){const n=t.resolveAreaStyle(e.key,e.data[0]),o=W(e.data,t.scales,t.getX,t.getY,i,n,e.key,l);t.config.gradientFill&&(o.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),r.push(o)}else{const n=t.resolveLineStyle(e.key,e.data[0]),o=I(e.data,t.scales,t.getX,t.getY,n,e.key);t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),r.push(o)}return F(t,n,r),r}(l,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 d;if(i){d=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;d.set(e,n||1)}}const h=[],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/=d.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),h.push(g)}return{nodes:h,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}(l,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}(l,e);case"heatmap":return function(t,e,n){if(t.config.heatmapAggregation)return function(t,e,n){var r,o,i;const l=Math.max(1,Math.floor(null!==(r=t.config.heatmapXBins)&&void 0!==r?r:20)),a=Math.max(1,Math.floor(null!==(o=t.config.heatmapYBins)&&void 0!==o?o:20)),s=null!==(i=t.config.heatmapAggregation)&&void 0!==i?i:"count",c=M(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[u,d]=t.scales.x.domain(),[h,f]=t.scales.y.domain(),y=(d-u||1)/l,g=(f-h||1)/a,p=l*a;if(p>1e6)return[];const v=new Int32Array(p),m=new Float64Array(p);for(let n=0;e.length>n;n++){const r=e[n],o=t.getX(r),i=t.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;v[f]++;const p=c(r);m[f]+=isFinite(p)?p:0}let x=1/0,b=-1/0;for(let t=0;p>t;t++){if(0===v[t])continue;let e;switch(s){case"sum":e=m[t];break;case"mean":e=m[t]/v[t];break;default:e=v[t]}x>e&&(x=e),e>b&&(b=e)}if(!isFinite(x))return[];const k=b-x||1,w=n.width/l,E=n.height/a,A=t.config.showValues,S=t.config.heatmapValueFormat,P=[];for(let t=0;a>t;t++){const e=t*l;for(let n=0;l>n;n++){const r=e+n;if(0===v[r])continue;let o;switch(s){case"sum":o=m[r];break;case"mean":o=m[r]/v[r];break;default:o=v[r]}const i=(o-x)/k;P.push(B(n*w,(a-1-t)*E,w,E,`rgb(${220-(180*i+.5)|0},${220-(100*i+.5)|0},${255-(50*i+.5)|0})`,{xi:n,yi:t,value:o,count:v[r],sum:m[r]},A?{value:o,showValues:!0,valueFormat:S}:void 0))}}return P}(t,e,n);if(0===e.length)return[];const r=M(t.config.valueAccessor,"value"),o=S(t.config.xAccessor,"x"),l=S(t.config.yAccessor,"y"),a=new Map,s=new Map,c=Array(e.length),u=Array(e.length);for(let t=0;e.length>t;t++){const n=e[t],r=o(n),i=l(n);c[t]=r,u[t]=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(t=>"number"==typeof t&&!isNaN(t)),p=y.every(t=>"number"==typeof t&&!isNaN(t));if(g){f.sort((t,e)=>t-e),a.clear();for(let t=0;f.length>t;t++)a.set(f[t],t)}if(p){y.sort((t,e)=>t-e),s.clear();for(let t=0;y.length>t;t++)s.set(y[t],t)}const v=new Float64Array(e.length),m=new Float64Array(e.length),x=Array(e.length),b=new Map;let k=0;for(let t=0;e.length>t;t++){const n=e[t],o=a.get(c[t]),i=s.get(u[t]);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)),v[y]=h,m[y]=l,x[y]=n}let w=1/0,E=-1/0;for(let t=0;k>t;t++){const e=m[t];isFinite(e)&&(w>e&&(w=e),e>E&&(E=e))}if(!isFinite(w)||!isFinite(E))return[];const A=function(t){const e=t in Y?t:"blues";let n=H.get(e);if(n)return n;n=Array(256);const r=Y[e]||i.interpolateBlues;for(let t=0;256>t;t++)n[t]=r(t/255);return H.set(e,n),n}("string"==typeof t.config.colorScheme?t.config.colorScheme:"blues"),P=255/(E-w||1),_=n.width/d,C=n.height/h,D=t.config.showValues,L=t.config.heatmapValueFormat,T=[];for(let t=0;k>t;t++){const e=m[t];if(!isFinite(e))continue;const n=v[t],r=n%d;T.push(B(r*_,(h-1-(n-r)/d)*C,_,C,A[Math.min((e-w)*P+.5|0,255)],x[t],D?{value:e,showValues:!0,valueFormat:L}:void 0))}return T}(l,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),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&&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)}}(l,e);return this._barCategoryCache=null!==(n=l.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,d=a.stroke,h=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:d,strokeWidth:h},datum:n};t.getPointId&&(y.pointId=t.getPointId(n)+""),l.push(y)}return l}(l,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",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 e=0;c.length>e;e++){const r=c[e],o=t.getX(r),i=t.getY(r),p=g+i;let v;v=c.length-1>e?t.getX(c[e+1])-o:e>0?o-t.getX(c[e-1]):0;const m=a.x(o),x=0!==v?a.x(o+v):m+n.width/10,b=Math.min(m,x)+h/2,k=Math.max(m,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,e,t);case"candlestick":return function(t,e){var n,r;if(!t.getHigh||!t.getLow||!t.scales)return[];const o=null!==(n=t.config.candlestickRangeMode)&&void 0!==n&&n;if(!(o||t.getOpen&&t.getClose))return[];const i=[],l=t.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=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let f=o?0:null!==(r=l.bodyWidth)&&void 0!==r?r:0;if(!o&&null==l.bodyWidth&&h.length>1){let e=1/0;for(let n=1;h.length>n;n++){const r=Math.abs(t.scales.x(h[n])-t.scales.x(h[n-1]));r>0&&e>r&&(e=r)}f=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else o||null!=l.bodyWidth||(f=6);for(const n of e){const e=t.getX(n);if(null==e||Number.isNaN(e))continue;const r=t.getHigh(n),l=t.getLow(n);if(null==r||Number.isNaN(r)||null==l||Number.isNaN(l))continue;const a=o?r:t.getOpen(n),h=o?l:t.getClose(n);if(!o&&[a,h].some(t=>null==t||Number.isNaN(t)))continue;const y=h>=a,g={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(a),closeY:t.scales.y(h),highY:t.scales.y(r),lowY:t.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,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=$(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,d,h,f,y,g,p,v,m,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 O=!1;const I=new Set,W=new Set;for(let e=0;n.scene.length>e;e++){const i=n.scene[e],E=$(t,i,e);if(!E)continue;if(i._transitionKey=E,"line"===i.type||"area"===i.type){const t=o.get(E);if(t){if(W.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]];O=!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]];O=!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}),O=!0;continue}const A=r.get(E);if("point"===i.type)if(A){I.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!==(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){I.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,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){I.add(E);const t={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=null!==(m=null===(v=i.style)||void 0===v?void 0:v.opacity)&&void 0!==m?m: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,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[t,e]of o)if(!W.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),O=!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),O=!0}for(const[t,e]of r)if(!I.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!==(P=e.w)&&void 0!==P?P:0,h:null!==(_=e.h)&&void 0!==_?_: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)}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=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=O(i,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const n=r.get(e);if(!n)continue;t.x=O(n.x,t._targetX,u),t.y=O(n.y,t._targetY,u),void 0!==t._targetR&&void 0!==n.r&&(t.r=O(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(o,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const n=r.get(e);if(!n)continue;t.x=O(n.x,t._targetX,u),t.y=O(n.y,t._targetY,u),void 0!==n.w&&(t.w=O(n.w,t._targetW,u)),void 0!==n.h&&(t.h=O(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(o,t._targetOpacity,u)})}if(void 0===t._targetX)continue;if(!e)continue;const n=r.get(e);if(!n)continue;t.x=O(n.x,t._targetX,u),t.y=O(n.y,t._targetY,u),void 0!==n.w&&(t.w=O(n.w,t._targetW,u)),void 0!==n.h&&(t.h=O(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:O(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]=O(e[r][0],n[r][0],u),t.path[r][1]=O(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:O(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]=O(e[n][0],r[n][0],u),t.topPath[n][1]=O(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]=O(n[e][0],o[e][0],u),t.bottomPath[e][1]=O(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:this.resolveGroupColor(t)||"#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}if(r&&"object"==typeof r)return{fill:r.fill||r.stroke||"#4e79a7",fillOpacity:null!==(n=r.fillOpacity)&&void 0!==n?n:.7,stroke:r.stroke||"#4e79a7",strokeWidth:r.strokeWidth||2};const o=this.resolveGroupColor(t)||"#4e79a7";return{fill:o,fillOpacity:.7,stroke:o,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()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");const e=new Set(Array.isArray(t)?t:[t]),n=this.getPointId,r=t=>e.has(n(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,n)=>{r(t)&&e.add(n)}),this.timestampBuffer.clear();for(let n=0;t.length>n;n++)e.has(n)||this.timestampBuffer.push(t[n])}const o=this.buffer.remove(r);if(0===o.length)return o;for(const t of o)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)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,o}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=new Set(Array.isArray(t)?t:[t]),r=this.getPointId,o=new Set;this.buffer.forEach((t,e)=>{n.has(r(t))&&o.add(e)});const i=this.buffer.update(t=>n.has(r(t)),e);if(0===i.length)return i;for(const t of i)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)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.buffer.forEach((t,e)=>{o.has(e)&&(this.xExtent.push(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))):(this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,i}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(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?P(this.config.groupAccessor):void 0,l=!0),"categoryAccessor"in t&&!A(t.categoryAccessor,i.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?P(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?P(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?P(this.config.pointIdAccessor):void 0,l=!0),"candlestick"===this.config.chartType&&("openAccessor"in t&&!A(t.openAccessor,i.openAccessor)||"closeAccessor"in t&&!A(t.closeAccessor,i.closeAccessor)||"highAccessor"in t&&!A(t.highAccessor,i.highAccessor)||"lowAccessor"in t&&!A(t.lowAccessor,i.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?M(this.config.openAccessor,"open"):void 0,this.getHigh=M(this.config.highAccessor,"high"),this.getLow=M(this.config.lowAccessor,"low"),this.getClose=e?M(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,l=!0}if(!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 G(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 V(t,e=30){return Math.max((null!=t?t:4)+5,12,e)}function q(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function U(t,e){const n=q(t);if(!n)return!1;const r=q(e);return!r||n.getFullYear()!==r.getFullYear()||n.getMonth()!==r.getMonth()}function K(t){let e=t%(2*Math.PI);return 0>e&&(e+=2*Math.PI),e}function Z(t,e,n,r=30,o){let i=null,l=!1;if(o){const t=o.find(e,n,r);if(t){const o=J(t,e,n,r);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=J(a,e,n,r);break;case"line":t=tt(a,e,n,r);break;case"rect":t=nt(a,e,n);break;case"heatcell":t=rt(a,e,n);break;case"area":if(!1===a.interactive)break;t=it(a,e,n);break;case"candlestick":t=ot(a,e,n)}t&&r>t.distance&&(i&&t.distance>=i.distance||(i=t))}return i}function Q(t,e,n){if(0===t.length)return null;const r=lt(t,e);if(0>r)return null;if(Math.abs(t[r][0]-e)>n)return null;let o=r,i=r;r>0&&t[r][0]>=e?(o=r-1,i=r):t.length-1>r&&(o=r,i=r+1);const[l,a]=t[o],[s,c]=t[i];return s===l?a:a+Math.max(0,Math.min(1,(e-l)/(s-l)))*(c-a)}function J(t,e,n,r=30){const o=e-t.x,i=n-t.y,l=Math.sqrt(o*o+i*i);return l>V(t.r,r)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:l}}function tt(t,e,n,r=30){var o,i,l,a;if(0===t.path.length)return null;const s=lt(t.path,e);if(0>s)return null;const[c,u]=t.path[s];let d;if(t.path.length>1){let r=1/0;const o=Math.max(0,s-1),i=Math.min(t.path.length-2,s);for(let l=o;i>=l;l++){const[o,i]=t.path[l],[a,s]=t.path[l+1],c=et(e,n,o,i,a,s);r>c&&(r=c)}d=r}else{const t=e-c,r=n-u;d=Math.sqrt(t*t+r*r)}const h=null!==(a=null!==(i=null===(o=t.style)||void 0===o?void 0:o.strokeWidth)&&void 0!==i?i:null===(l=t.style)||void 0===l?void 0:l.lineWidth)&&void 0!==a?a:1;return d>Math.max(5,h/2+2,r)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[s]?t.datum[s]:t.datum,x:c,y:u,distance:d}}function et(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 nt(t,e,n){const r=G(e,n,t);return r.hit?{node:t,datum:t.datum,x:r.cx,y:r.cy,distance:0}:null}function rt(t,e,n){const r=G(e,n,t);return r.hit?{node:t,datum:t.datum,x:r.cx,y:r.cy,distance:0}:null}function ot(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 it(t,e,n){if(0===t.topPath.length)return null;const r=lt(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 lt(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 at(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 st(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 ct(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?ut(n,n.groups[t+1],i[o]):e.flatIndex}case"ArrowUp":{const t=n.groups.indexOf(r);return t>0?ut(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 ut(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 dt(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 ht(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 ft(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])}X.QUADTREE_THRESHOLD=500;const yt={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 gt(t,e,n,r){let o;return o="function"==typeof n?n(t):(0,yt[n])(r(t,e)),o}function pt(){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 vt(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}function mt({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 xt(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,[d,h]=g.useState(0),[f,y]=g.useState(0),p=g.useCallback((t,e)=>{h(t),y(e)},[]),v="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 d=[];return t.forEach((t,h)=>{u+=5,d.push(g.createElement("line",{key:"legend-top-line legend-symbol-"+h,stroke:"gray",x1:0,y1:u,x2:e,y2:u})),u+=8,t.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)"},t.label)),u+=8),d.push(g.createElement("g",{key:"legend-group-"+h,className:"legend-item",transform:`translate(0,${u})`},((t,e,n,r,o,i,l,a,s,c)=>{const{type:u="fill",styleFn:d,items:h}=t,f=[];let y=0;const p=!(!e&&!n),v="isolate"===c||void 0===c&&null!=o;return h.forEach((t,c)=>{const m=gt(t,c,u,d),x=vt(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&&v?b||!1:void 0,"aria-current":p&&!v&&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)+h.length)%h.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"}),m,b&&g.createElement(pt,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,h,s,c))),u+=22*t.items.length+8}),d})({legendGroups:e||[],width:s,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:d,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 d=0;const h=[];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:d="fill",styleFn:h,items:f}=t,y=[];let p=0,v=0;const m=!(!e&&!n),x="isolate"===c||void 0===c&&null!=o;f.forEach((t,c)=>{const b=gt(t,c,d,h),k=vt(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&&(v++,p=0),y.push(g.createElement("g",{key:"legend-item-"+c,transform:`translate(${p},${22*v})`,onClick:e?()=>e(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:m?a===i&&c===l?0:-1:void 0,role:m?"option":void 0,"aria-selected":m&&x?w||!1:void 0,"aria-current":m&&!x&&null!=r&&t.label===r||void 0,"aria-label":t.label,onKeyDown:m?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:m?e=>{s(a,c),n&&n(t);const r=e.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:m?t=>{n&&n(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:m?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},m&&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(pt,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=v+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,h.push(Object.assign(Object.assign({label:t.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=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:d,focusedItemIndex:f,onFocusedIndexChange:p,legendInteraction:l}),m=!(!n&&!r);return g.createElement("g",{role:m?"listbox":void 0,"aria-multiselectable":!(!m||"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),v)}function bt(t){const{legend:e,totalWidth:n,totalHeight:r,margin:o,legendPosition:i="right",title:l,legendHoverBehavior:a,legendClickBehavior:s,legendHighlightedCategory:c,legendIsolatedCategories:u,legendInteraction:d}=t;if(!e)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(t){return"object"==typeof t&&null!==t&&"gradient"in t}(e)?g.createElement(mt,{config:e.gradient,orientation:h?"horizontal":"vertical",width:h?n:100}):function(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}(e)?g.createElement(xt,{legendGroups:e.legendGroups,title:"",width:h?n:100,orientation:h?"horizontal":"vertical",customHoverBehavior:a,customClickBehavior:s,highlightedCategory:c,isolatedCategories:u,legendInteraction:d}):e)}function kt(t){return"string"==typeof t?{type:t}:t}function wt({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:d}=t,h=Math.min(.5*n,20),f=(n-h)/2+4;if(c){const t=o(i),n=o(a),r=o(l),c=o(u),y=o(d),p="top"===e?-1:1,v=0;return g.createElement("g",{"data-testid":"marginal-boxplot-"+e},g.createElement("line",{x1:c,y1:v+p*(f+h/2),x2:y,y2:v+p*(f+h/2),stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:c,y1:v+p*f,x2:c,y2:v+p*(f+h),stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:y,y1:v+p*f,x2:y,y2:v+p*(f+h),stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("rect",{x:Math.min(t,n),y:"top"===e?v-f-h:v+f,width:Math.abs(n-t),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"===e?v-f-h:v+f,x2:r,y2:"top"===e?v-f:v+f+h,stroke:s.fill,strokeWidth:2}))}{const t=o(i),n=o(a),r=o(l),c=o(u),y=o(d),p="left"===e?-1:1,v=0;return g.createElement("g",{"data-testid":"marginal-boxplot-"+e},g.createElement("line",{x1:v+p*(f+h/2),y1:c,x2:v+p*(f+h/2),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:v+p*f,y1:c,x2:v+p*(f+h),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:v+p*f,y1:y,x2:v+p*(f+h),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("rect",{x:"left"===e?v-f-h:v+f,y:Math.min(t,n),width:h,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?v-f-h:v+f,y1:r,x2:"left"===e?v-f:v+f+h,y2:r,stroke:s.fill,strokeWidth:2}))}}const u=l.bin().domain(t).thresholds(s.bins)(r);if(0===u.length)return null;const d=Math.max(...u.map(t=>t.length));if(0===d)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/d*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/d*(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/d*(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/d*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/d*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 Et(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 At(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 Mt(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:d,className:h,disable:f,events:y={},"data-testid":p}=t,v=new Set(Array.isArray(f)?f:[]);let m=r||0,x=o||0;null!=i&&(m=i-e),null!=l&&(x=l-n);const b="string"==typeof u?u:"label";if("bracket"===b&&c&&0===m&&0===x)if(void 0!==c.width){m=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;m=t+(0>t?-5:5),x=c.height/2}return g.createElement("g",Object.assign({className:("annotation "+(h||"")).trim(),transform:`translate(${e},${n})`,"data-testid":p},y),!v.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,d=r/2,h=t*d>e*u?u/t:d/e;a=o+l*h,s=i+c*h}}}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||"var(--semiotic-text-secondary, 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||"var(--semiotic-text-secondary, currentColor)",stroke:"none"}))}return g.createElement("g",{className:"annotation-connector"},l)}(m,x,s,d,b,c),!v.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||"var(--semiotic-text-secondary, 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||"var(--semiotic-text-secondary, 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||"var(--semiotic-text-secondary, 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||"var(--semiotic-text-secondary, 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||"var(--semiotic-text-secondary, 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||"var(--semiotic-text-secondary, 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:At((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||"var(--semiotic-text-secondary, currentColor)"}));break}}return g.createElement("g",{className:"annotation-subject"},l)}(b,c,d,e,n),!v.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 d=a;d&&"dynamic"!==d||(d="topBottom"===u?0>e?"right":"left":0>n?"bottom":"top");let h="start";"topBottom"===u?"right"===d?h="end":"middle"===d&&(h="middle"):h=0>e?"end":"start";const f=16,y=i?c?[i]:Et(i,s):[],p=o?c?[o]:Et(o,s):[],v="leftRight"===u?"end"===h?-4:4:0;let m=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((t,e)=>g.createElement("tspan",{key:e,x:v,dy:0===e?0:f},t)))),m=y.length*f),p.length>0&&x.push(g.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:b,textAnchor:h,y:m},p.map((t,e)=>g.createElement("tspan",{key:e,x:v,dy:0===e?0:f},t))));let k=null;if((i||o)&&(0!==e||0!==n))if("topBottom"===u){const t=Math.min(s,120);let e=0,n=t;"end"===h?(e=-t,n=0):"middle"===h&&(e=-t/2,n=t/2),k=g.createElement("line",{className:"note-line",x1:e,x2:n,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const t=(y.length+p.length)*f+(p.length>0?f:0);let e=0,n=t;"bottom"===d?(e=-t,n=0):"middle"===d&&(e=-t/2,n=t/2),k=g.createElement("line",{className:"note-line",x1:0,x2:0,y1:e,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(${e},${n})`},g.createElement("g",{className:"annotation-note-content",transform:0!==E?`translate(0,${E})`:void 0},x),k)}(a,m,x,d))}function St(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(Mt,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(Mt,Object.assign({"data-testid":"semiotic-annotation",key:`${a.label}-${a.title}-${r.i}`,events:l},r,{type:i}))}function Pt(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 _t(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 Ct(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 d=s[t.xAccessor||"x"],h=s[t.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(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=Pt(t,n),c=_t(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 Dt(t,e,n,r=50){return!(-r>t||t>(n.width||0)+r||-r>e||e>(n.height||0)+r)}const Lt={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 Tt={positions:new Map};const Nt=new Set;function Ot(){for(const t of Nt)t()}function $t(t,e){const n=Tt.positions.get(t);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==e)return;const r=new Map(Tt.positions);r.delete(t),Tt={positions:r},Ot()}function It(t,e){const n=Tt.positions.get(t);if(!(null==n?void 0:n.locked))return;if(e&&n.sourceId!==e)return;const r=new Map(Tt.positions);r.delete(t),Tt={positions:r},Ot()}function Wt(){return Tt}function zt(t){return Nt.add(t),()=>Nt.delete(t)}const Rt={positions:new Map};function Bt(){return()=>{}}function jt(){return Rt}function Ft(t){if(t)return"dashed"===t?"6,4":"dotted"===t?"2,4":t}function Yt(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 Ht(e){const{width:n,height:r,totalWidth:o,totalHeight:i,margin:l,scales:a,showAxes:s,axes:c,showGrid:u,xFormat:d,yFormat:h}=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)||d||Xt,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,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0);return Gt(s,Math.max(55,u+8))},[a,c,d,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)||h||Xt,o=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return Gt(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,h,r]),p=u&&a,v=s&&a;if(!p&&!v)return null;const m=null==c?void 0:c.find(t=>"bottom"===t.orient),x=null==c?void 0:c.find(t=>"left"===t.orient),b=v&&(!m||!1!==m.baseline),k=v&&(!x||!1!==x.baseline),w=(null==m?void 0:m.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 t,e;const o=Ft(null===(t=null==c?void 0:c.find(t=>"bottom"===t.orient))||void 0===t?void 0:t.gridStyle),i=Ft(null===(e=null==c?void 0:c.find(t=>"left"===t.orient))||void 0===e?void 0:e.gridStyle);return 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,strokeDasharray:o})),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,strokeDasharray:i})))})(),b&&!w&&g.createElement("line",{x1:0,y1:r,x2:n,y2:r,stroke:A,strokeWidth:1}),w&&g.createElement("path",{d:Yt("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:Yt("left",n,r),fill:"none",stroke:A,strokeWidth:1})))}function Xt(t,e,n){return t instanceof Date?`${t.toLocaleString("en",{month:"short"})} ${t.getDate()}`:"number"==typeof t?Math.round(100*t)/100+"":t+""}function Gt(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 Vt(e){var n,r;const{width:o,height:i,totalWidth:l,totalHeight:c,margin:u,scales:d,showAxes:h,axes:f,xLabel:y,yLabel:v,yLabelRight:m,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:I,annotationData:W,pointNodes:z,curve:R,underlayRendered:B,linkedCrosshairName:j,linkedCrosshairSourceId:F,children:Y}=e,H=t.useMemo(()=>{var t;if(!h||!d)return[];const e=null==f?void 0:f.find(t=>"bottom"===t.orient),n=(null==e?void 0:e.tickFormat)||x||Xt,r=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,i=d.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:d.x(t),label:n(t,e,l)})),s=a.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0),c=(null==e?void 0:e.autoRotate)?Math.max(20,Math.min(s+8,55)):Math.max(55,s+8);let u=Gt(a,c);if(u.length>1&&(u=u.filter((t,e)=>0===e||t.label+""!=u[e-1].label+"")),(null==e?void 0:e.includeMax)&&u.length>0){const t=d.x.domain()[1],e=d.x(t),r=u[u.length-1].pixel;if(Math.abs(e-r)>1){const o=n(t,u.length,l);c>e-r&&u.length>1&&(u=u.slice(0,-1)),u.push({value:t,pixel:e,label:o})}}return u},[h,d,f,x,o]),X=t.useMemo(()=>{var t;if(!h||!d)return[];const e=null==f?void 0:f.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||b||Xt,r=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;let o=Gt(d.y.ticks(Math.min(r,Math.max(2,Math.floor(i/30)))).map(t=>({value:t,pixel:d.y(t),label:n(t)})),22);if(o.length>1&&(o=o.filter((t,e)=>0===e||t.label+""!=o[e-1].label+"")),(null==e?void 0:e.includeMax)&&o.length>0){const t=d.y.domain()[1],e=d.y(t),r=o[o.length-1].pixel;if(Math.abs(e-r)>1){const i=n(t);22>Math.abs(e-r)&&o.length>1&&(o=o.slice(0,-1)),o.push({value:t,pixel:e,label:i})}}return o},[h,d,f,b,i]),G=t.useMemo(()=>{var t;if(!h||!d)return[];const e=null==f?void 0:f.find(t=>"right"===t.orient);if(!e)return[];const n=e.tickFormat||b||Xt,r=null!==(t=e.ticks)&&void 0!==t?t:5;return Gt(d.y.ticks(Math.min(r,Math.max(2,Math.floor(i/30)))).map(t=>({value:t,pixel:d.y(t),label:n(t)})),22)},[h,d,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 Z=t.useMemo(()=>{if(!N||0===N.length)return null;const t=function(t,e,n){var r,o,i,l,c,u,d,h,f,y,v,m,x,b,k,w,E,A,M,S,P,_,C,D,L,T,N,O,$,I,W,z,R,B,j,F,Y,H,X,G,V,q,U,K,Z,Q,J,tt;switch(t.type){case"label":{const r=Ct(t,e,n);if(!r)return null;const{x:o,y:i}=r;return Dt(o,i,n)?g.createElement(St,{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=Ct(t,e,n);if(!r)return null;const{x:o,y:i}=r;return Dt(o,i,n)?g.createElement(St,{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=Pt(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=_t(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:Pt(Object.assign(Object.assign({},t),{type:"point"}),n),y:_t(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:Pt(Object.assign(Object.assign({},t),{type:"point"}),n),y:_t(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=Pt(e,n),l=_t(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=Pt(t,n),o=_t(t,n);return g.createElement(St,{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",h=n.yAccessor||"y",f=a.map(t=>[t[s],t[h]]).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,v=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||!v)return null;const m=t.method||"linear";let x;x="loess"===m?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,d=0,h=0,f=0,y=0;for(let t=0;n>t;t++){const e=c[t];0!==e&&(u+=e,d+=e*o[t],h+=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-d*d;if(1e-12>Math.abs(g))a.push([e,h/u]);else{const t=(u*y-d*h)/g;a.push([e,(h-t*d)/u+t*e])}}return a}(f,null!==(d=t.bandwidth)&&void 0!==d?d:.3):("polynomial"===m?p.default.polynomial(f,{order:t.order||2}):p.default.linear(f)).points;const b=x.map(([t,e])=>`${y(t)},${v(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:v(x[x.length-1][1])-4,fill:k,fontSize:11},t.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!==(v=null==r?void 0:r(t.y0))&&void 0!==v?v:0,i=null!==(m=null==r?void 0:r(t.y1))&&void 0!==m?m: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,d=r.filter(t=>null!=t[a]&&null!=t[c]&&!(u&&!u(t))).sort((t,e)=>t[o]-e[o]);if(2>d.length)return null;const h=Lt[n.curve||"linear"]||s.curveLinear,f=s.area().x(t=>i(t[o])).y0(t=>l(t[c])).y1(t=>l(t[a])).curve(h)(d);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&&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},t.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(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),d=null!==(T=t.threshold)&&void 0!==T?T:2,h=s-d*u,f=!1!==t.showBand,y=t.fill||"#6366f1",p=null!==(N=t.fillOpacity)&&void 0!==N?N:.1,v=t.anomalyColor||"#ef4444",m=null!==(O=t.anomalyRadius)&&void 0!==O?O:6,x=l(s+d*u),b=l(h),k=r.filter(t=>{const e=t[o];return null!=e&&Math.abs(e-s)>d*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=Pt(t,n),o=_t(t,n);return null==r||null==o?null:g.createElement("circle",{key:"anomaly-"+e,cx:r,cy:o,r:m,fill:v,fillOpacity:.7,stroke:v,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!==(I=null===($=n.scales)||void 0===$?void 0:$.x)&&void 0!==I?I:null===(W=n.scales)||void 0===W?void 0:W.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,d=s.map(([t,e])=>e-c(t)).reduce((t,e)=>t+e*e,0),h=Math.sqrt(d/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),v=null!==(j=t.confidence)&&void 0!==j?j:.95,m=.99>v?.95>v?.9>v?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=h*Math.sqrt(1+1/u+(y>0?Math.pow(t-f,2)/y:0))*m;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))}`,P=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:P,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:P,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=Ct(t,e,n);if(!i)return null;r=i.x,o=i.y}if(null==r||null==o)return null;if(!Dt(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!==(U=t.height)&&void 0!==U?U:32,c=null!==(K=t.content)&&void 0!==K?K: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=Ct(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)",d=null!==(tt=t.opacity)&&void 0!==tt?tt:.15,h=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: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-"+e},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}},e={scales:d?{x:d.x,y:d.y,time:d.x,value:d.y}:null,timeAxis:"x",xAccessor:$,yAccessor:I,width:o,height:i,data:W,frameType:"xy",pointNodes:z,curve:R,stickyPositionCache:V.current};return N.map((n,r)=>{if(O){const o=O(n,r,e);return null!=o?o:t(n,r,e)}return t(n,r,e)}).filter(Boolean)},[N,O,o,i,$,I,W,d,z,R]),Q=function(e){var n;const r=t.useSyncExternalStore(e?zt:Bt,e?Wt:jt,e?Wt:jt);return e&&null!==(n=r.positions.get(e))&&void 0!==n?n:null}(j);return t.useEffect(()=>{if(!(null==Q?void 0:Q.locked)||!j)return;const t=t=>{"Escape"===t.key&&It(j)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[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 t,e;const n=Ft(null===(t=null==f?void 0:f.find(t=>"bottom"===t.orient))||void 0===t?void 0:t.gridStyle),r=Ft(null===(e=null==f?void 0:f.find(t=>"left"===t.orient))||void 0===e?void 0:e.gridStyle);return 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,strokeDasharray:n})),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,strokeDasharray:r})))})(),h&&d&&(()=>{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=!e||!1!==e.baseline,l=(null==t?void 0:t.jaggedBase)||!1,a=(null==e?void 0:e.jaggedBase)||!1,s=null==e?void 0:e.landmarkTicks,c=null==t?void 0:t.landmarkTicks,d="var(--semiotic-border, #ccc)",h="var(--semiotic-text-secondary, var(--semiotic-text, #666))",p="var(--semiotic-text, #333)",x=!!(null==e?void 0:e.autoRotate)&&H.length>1&&(()=>{const t=o/Math.max(H.length-1,1);return H.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:60),0)+8>t})();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:Yt("bottom",o,i),fill:"none",stroke:d,strokeWidth:1}),H.map((t,e)=>{const n=!!s&&("function"==typeof s?s(t.value,e):U(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:d,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.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},t.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"}},t.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:Yt("left",o,i),fill:"none",stroke:d,strokeWidth:1}),X.map((t,e)=>{const n=!!c&&("function"==typeof c?c(t.value,e):U(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:d,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?g.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:h,style:{userSelect:"none"}},t.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"}},t.label)))}),(()=>{const e=(null==t?void 0:t.label)||v;return e?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"}},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||m;return g.createElement(g.Fragment,null,!1!==t.baseline&&g.createElement("line",{x1:o,y1:0,x2:o,y2:i,stroke:d,strokeWidth:1}),G.map((t,n)=>{const r=!!e&&("function"==typeof e?e(t.value,n):U(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:d,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?g.createElement("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:r?11:10,fontWeight:r?600:400,fill:h,style:{userSelect:"none"}},t.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"}},t.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(wt,{orient:"top",config:kt(D.top),values:L,scale:d.x,size:u.top,length:o})),D.bottom&&g.createElement("g",{transform:`translate(0, ${i})`},g.createElement(wt,{orient:"bottom",config:kt(D.bottom),values:L,scale:d.x,size:u.bottom,length:o})),D.left&&g.createElement("g",{transform:"translate(0, 0)"},g.createElement(wt,{orient:"left",config:kt(D.left),values:T,scale:d.y,size:u.left,length:i})),D.right&&g.createElement("g",{transform:`translate(${o}, 0)`},g.createElement(wt,{orient:"right",config:kt(D.right),values:T,scale:d.y,size:u.right,length:i}))),C,Q&&Q.sourceId!==F&&(null==d?void 0:d.x)&&(()=>{const t=d.x(Q.xValue);if(null==t||0>t||t>o)return null;const e=Q.locked;return g.createElement("line",{x1:t,y1:0,x2:t,y2:i,stroke:e?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:e?1.5:1,strokeDasharray:e?"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),bt({legend:E,totalWidth:l,totalHeight:c,margin:u,legendPosition:_,title:w,legendHoverBehavior:A,legendClickBehavior:M,legendHighlightedCategory:S,legendIsolatedCategories:P})):null}function qt(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}const Ut="undefined"==typeof window||"undefined"==typeof document,Kt=g.createContext(null);function Zt(){return g.useContext(Kt)}const Qt={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Jt(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 te(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 ee=t=>{if(null==t)return"";const e=Math.round(100*t)/100;return Number.isNaN(e)?"":e+""},ne={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"},re={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},oe={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)"},ie={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},le={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)"},ae={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},se={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function ce({scene:t,chartType:e,tableId:n,chartTitle:r}){var o;const[i,l]=g.useState(!1),a=Zt(),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 ${e} ${n}`:"Data summary for "+e,h=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:Qt}):null;if(!c)return g.createElement("div",{id:n,tabIndex:-1,onFocus:h,style:Qt,role:"region","aria-label":d},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,d,h,f,y,g,p,v,m,x,b,k,w,E,A,M;const S=[];if(!Array.isArray(t))return S;for(const P of t)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 t=P.path,e=Array.isArray(P.datum)?P.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=P.topPath,e=Array.isArray(P.datum)?P.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!=P.datum&&"object"==typeof P.datum?P.datum:{},i=null!==(n=null!==(e=t.category)&&void 0!==e?e:P.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: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!==(v=P.cx)&&void 0!==v?v:P.x,y:null!==(m=P.cy)&&void 0!==m?m: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(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),v=function(t,e){const n=[t+" data points."];for(const t of e)if(t.numeric)n.push(`${t.name}: ${ee(t.min)} to ${ee(t.max)}, mean ${ee(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),m=y.slice(0,5),x=new Set;for(const t of m)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:ne,role:"region","aria-label":d},g.createElement("button",{type:"button",onClick:()=>{s&&a&&a.setVisible(!1),l(!1)},"aria-label":"Close data summary",style:oe},"×"),g.createElement("div",{role:"note",style:re},v),g.createElement("table",{role:"table","aria-label":"Sample data for "+e,style:ie},g.createElement("caption",{style:se},"First ",m.length," of ",y.length," data points"),g.createElement("thead",null,g.createElement("tr",null,g.createElement("th",{style:le},"type"),b.map(t=>g.createElement("th",{key:t,style:le},t)))),g.createElement("tbody",null,m.map((t,e)=>g.createElement("tr",{key:e},g.createElement("td",{style:ae},t.label),b.map(e=>{return g.createElement("td",{key:e,style:ae},null==(n=t.values[e])||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":ee(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"");var n}))))))}function ue({nodes:t,edges:e,chartType:n,tableId:r,chartTitle:o}){var i,l,a,s,c,u,d,h,f,y,p,v,m,x;const[b,k]=g.useState(!1),w=Zt(),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(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:Qt}):null;if(!A)return g.createElement("div",{id:r,tabIndex:-1,onFocus:P,style:Qt,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,O=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),O.set(t,(null!==(u=O.get(t))&&void 0!==u?u:0)+o)}if(null!=r&&""!==r){const t=r+"";L.set(t,(null!==(d=L.get(t))&&void 0!==d?d:0)+1),N.set(t,(null!==(h=N.get(t))&&void 0!==h?h:0)+o)}}const $=[];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!==(v=T.get(r))&&void 0!==v?v:0,l=null!==(m=N.get(r))&&void 0!==m?m: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((t,e)=>e.degree-t.degree);let I=0,W=0;if($.length>0){let t=0;for(const e of $)t+=e.degree,e.degree>W&&(W=e.degree);I=t/$.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=[`${$.length} nodes, ${D.length} edges.`];$.length>0&&R.push(`Mean degree: ${ee(I)}, max degree: ${W}.`);const B=$.slice(0,5);return g.createElement("div",{ref:S,id:r,tabIndex:-1,onBlur:_,style:ne,role:"region","aria-label":M},g.createElement("button",{type:"button",onClick:()=>{E&&w&&w.setVisible(!1),k(!1)},"aria-label":"Close data summary",style:oe},"×"),g.createElement("div",{role:"note",style:re},R.join(" ")),g.createElement("table",{role:"table","aria-label":"Node degree summary for "+n,style:ie},g.createElement("caption",{style:se},"Top ",B.length," of ",$.length," nodes by degree"),g.createElement("thead",null,g.createElement("tr",null,g.createElement("th",{style:le},"id"),g.createElement("th",{style:le},"degree"),g.createElement("th",{style:le},"in"),g.createElement("th",{style:le},"out"),z&&g.createElement("th",{style:le},"w. degree"),z&&g.createElement("th",{style:le},"w. in"),z&&g.createElement("th",{style:le},"w. out"))),g.createElement("tbody",null,B.map((t,e)=>g.createElement("tr",{key:e},g.createElement("td",{style:ae},t.id),g.createElement("td",{style:ae},t.degree),g.createElement("td",{style:ae},t.inDeg),g.createElement("td",{style:ae},t.outDeg),z&&g.createElement("td",{style:ae},ee(t.wDegree)),z&&g.createElement("td",{style:ae},ee(t.wInDeg)),z&&g.createElement("td",{style:ae},ee(t.wOutDeg)))))))}function de({summary:t}){return t?g.createElement("div",{role:"note",style:Qt},t):null}function he({tableId:t}){return g.createElement("a",{href:"#"+t,style:Qt,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,Qt)}},"Skip to data table")}function fe({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:Qt},e)}const ye="var(--semiotic-focus, #005fcc)";function ge({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:ye,strokeWidth:2,strokeDasharray:"4,2"})}else c=g.createElement("circle","wedge"===o?{cx:a,cy:s,r:12,fill:"none",stroke:ye,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:a,cy:s,r:8,fill:"none",stroke:ye,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 pe({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 d;return d=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:d,pointerEvents:"none",zIndex:a,width:"max-content"}},i)}function ve(){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 me(e){const n=t.createContext(null),r=xe(e);return[function({children:r}){const o=t.useMemo(()=>xe(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 xe(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 be={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},ke={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}},we={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"},[Ee,Ae]=me(t=>({theme:be,setTheme(e){t(t=>{if("light"===e)return{theme:be};if("dark"===e)return{theme:ke};if("high-contrast"===e)return{theme:we};if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?ke:be;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 Me(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 Se(){return"undefined"!=typeof window&&window.devicePixelRatio||1}const Pe=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,_e=new WeakMap;function Ce(t,e){var n,r;if(!e)return e;const o=Pe.exec(e);if(!o)return e;const i=t.canvas;if(!i)return(null===(n=o[2])||void 0===n?void 0:n.trim())||e;let l=_e.get(i);if(l||(l=new Map,_e.set(i,l)),l.has(e))return l.get(e);const a=getComputedStyle(i).getPropertyValue(o[1]).trim()||(null===(r=o[2])||void 0===r?void 0:r.trim())||e;return l.set(e,a),a}function De(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 Le(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 Te(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()}}const Ne=(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,d=a.colorThresholds,h=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;Te(t,a.path,c,u,p,a.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const f=De(a.curve),y=d&&d.length>0&&h&&h.length===a.path.length,g=a._decayOpacities;if(g&&g.length===a.path.length&&!y){t.strokeStyle=c;const v=null!==(i=a.style.opacity)&&void 0!==i?i:1;for(let m=0;a.path.length-1>m;m++)t.globalAlpha=.5*(g[m]+g[m+1])*v,t.beginPath(),t.moveTo(a.path[m][0],a.path[m][1]),t.lineTo(a.path[m+1][0],a.path[m+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=h[S],D=Le(C,d,c);if(null!==x&&null!==w&&null!==k){if(D===w)t.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((t,e)=>t.t-e.t);for(const O of L){const $=x+(P-x)*O.t,I=b+(_-b)*O.t,W=Le(k+(C-k)*Math.min(O.t+1e-4,1),d,c);t.lineTo($,I),M(),A(W,$,I)}t.lineTo(P,_)}x=P,b=_,k=C,w=D}else A(D,P,_),x=P,b=_,k=C,w=D}M()}else{if(t.beginPath(),!a.strokeGradient||2>a.strokeGradient.colorStops.length||2>a.path.length)t.strokeStyle=c;else{const z=t.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);t.strokeStyle=z}if(f)s.line().x(t=>t[0]).y(t=>t[1]).curve(f).context(t)(a.path);else{const[B,j]=a.path[0];t.moveTo(B,j);for(let F=1;a.path.length>F;F++)t.lineTo(a.path[F][0],a.path[F][1])}t.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=a.style.fillOpacity,t.fillStyle=("string"==typeof a.style.fill?Ce(t,a.style.fill):a.style.fill)||a.style.fill,f&&!y)s.line().x(t=>t[0]).y(t=>t[1]).curve(f).context(t)(a.path);else{const[H,X]=a.path[0];t.moveTo(H,X);for(let G=1;a.path.length>G;G++)t.lineTo(a.path[G][0],a.path[G][1])}const Y=a.path[0][0];t.lineTo(a.path[a.path.length-1][0],r.height),t.lineTo(Y,r.height),t.closePath(),t.fill()}t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}};function Oe(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function $e(t,e,n=.3){Oe(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 Ie(t,e,n=.6){var r,o,i,l,a;if(!Oe(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,d=null!==(a=null!==(l=e.cy)&&void 0!==l?l:e.y)&&void 0!==a?a:0;t.beginPath(),t.arc(u,d,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 We(t,e,n,r=.35){Oe(e)&&(t.globalAlpha=e._pulseIntensity*r,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill())}function ze(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 Re(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 Be(t,e){const n=ze(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 je=(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=Ce(t,e.style.stroke)||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(Be(t,e),e.fillGradient&&("colorStops"in e.fillGradient&&e.fillGradient.colorStops.length>=2||"topOpacity"in e.fillGradient)&&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=t.createLinearGradient(0,r,0,o);if("colorStops"in e.fillGradient)for(const t of e.fillGradient.colorStops){const e=Math.max(0,Math.min(1,t.offset));isNaN(e)||i.addColorStop(e,t.color)}else if("topOpacity"in e.fillGradient){const t=Re("string"==typeof n?n:"#4e79a7");i.addColorStop(0,`rgba(${t[0]},${t[1]},${t[2]},${e.fillGradient.topOpacity})`),i.addColorStop(1,`rgba(${t[0]},${t[1]},${t[2]},${e.fillGradient.bottomOpacity})`)}t.fillStyle=i,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&&(Be(t,e),We(t,e)),e.style.stroke&&"none"!==e.style.stroke){if(t.globalAlpha=a,!e.strokeGradient||2>e.strokeGradient.colorStops.length||2>e.topPath.length)t.strokeStyle=Ce(t,e.style.stroke)||e.style.stroke;else{const n=t.createLinearGradient(e.topPath[0][0],0,e.topPath[e.topPath.length-1][0],0);for(const t of e.strokeGradient.colorStops)n.addColorStop(Math.max(0,Math.min(1,t.offset)),t.color);t.strokeStyle=n}t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);const n=ze(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}},Fe=(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=("string"==typeof e.style.fill?Ce(t,e.style.fill):e.style.fill)||"#4e79a7",t.fill(),e.style.stroke&&(t.strokeStyle=("string"==typeof e.style.stroke?Ce(t,e.style.stroke):e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke()),Ie(t,e),t.globalAlpha=1}}finally{t.restore()}}},Ye=(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?He(t,e):(t.fillStyle=("string"==typeof e.style.fill?Ce(t,e.style.fill):e.style.fill)||"#007bff",t.fillRect(e.x,e.y,e.w,e.h),e.style.stroke&&(t.strokeStyle=Ce(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))),$e(t,e),t.globalAlpha=1};function He(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 Xe(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 Ge(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}const Ve=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function qe(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`${Ve[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*n>e?t=>{const e=new Date(t);return`${Ve[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}const Ue={line:[je,Ne,Fe],area:[je,Fe],stackedarea:[je,Fe],scatter:[Fe],bubble:[Fe],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),$e(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):Ge(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=Xe(e.fill),t.font=r+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,o,i)}}}finally{t.restore()}}],bar:[Ye],swarm:[Fe],waterfall:[(t,e,n,r)=>{var o,i,l;Ye(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;if(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(),e.isRange){const n=Math.max(2*e.wickWidth,4);t.fillStyle=e.wickColor,t.beginPath(),t.arc(e.x,e.highY,n,0,2*Math.PI),t.fill(),t.beginPath(),t.arc(e.x,e.lowY,n,0,2*Math.PI),t.fill()}else if(e.bodyWidth>0){const n=Math.min(e.openY,e.closeY),r=Math.abs(e.openY-e.closeY),o=e.isUp?e.upColor:e.downColor;t.fillStyle=o,t.fillRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(r,1)),t.strokeStyle=o,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(r,1))}t.restore()}}],mixed:[je,Ne,Fe]},Ke={top:20,right:20,bottom:30,left:40},Ze={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"},Qe={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 Je({hover:t}){const e=t=>Number.isInteger(t)?t+"":t.toFixed(2);return g.createElement("div",{className:"semiotic-tooltip",style:Qe},g.createElement("div",{style:{fontWeight:600,marginBottom:2}},e(t.value)),g.createElement("div",{style:{opacity:.7,fontSize:11}},e(t.time)))}const tn=t.forwardRef(function(e,n){var r,o,i,l,a,s,c,u,d,h,f;const{chartType:y,runtimeMode:p,data:v,chunkThreshold:m,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:I,yExtent:W,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:tt,barColors:et,colorScheme:nt,boundsAccessor:rt,boundsStyle:ot,y0Accessor:it,gradientFill:ut,lineGradient:yt,areaGroups:gt,openAccessor:pt,highAccessor:vt,lowAccessor:mt,closeAccessor:xt,candlestickStyle:bt,showAxes:kt=!0,axes:wt,xLabel:Et,yLabel:At,yLabelRight:Mt,xFormat:St,yFormat:Pt,tickFormatTime:_t,tickFormatValue:Ct,hoverAnnotation:Dt,tooltipContent:Lt,customHoverBehavior:Tt,customClickBehavior:Nt,enableHover:Ot,hoverRadius:$t=30,tooltipMode:It,annotations:Wt,svgAnnotationRules:zt,showGrid:Rt,legend:Bt,legendHoverBehavior:jt,legendClickBehavior:Ft,legendHighlightedCategory:Yt,legendIsolatedCategories:Xt,legendPosition:Gt,backgroundGraphics:Kt,foregroundGraphics:Zt,canvasPreRenderers:Qt,svgPreRenderers:te,title:ee,categoryAccessor:ne,brush:re,onBrush:oe,decay:ie,pulse:le,transition:ae,staleness:se,heatmapAggregation:ue,heatmapXBins:ye,heatmapYBins:me,showValues:xe,heatmapValueFormat:be,marginalGraphics:ke,pointIdAccessor:we,xScaleType:Ee,yScaleType:Pe,accessibleTable:Ce=!0,description:De,summary:Le,linkedCrosshairName:Te,linkedCrosshairSourceId:Ne}=e,Oe=ve(),$e=t.useRef(Oe);$e.current=Oe;const[Ie,We]=ht(j,F,Y),ze=Object.assign(Object.assign({},Ke),H);if(ke){const t=60;ke.top&&t>ze.top&&(ze.top=t),ke.bottom&&t>ze.bottom&&(ze.bottom=t),ke.left&&t>ze.left&&(ze.left=t),ke.right&&t>ze.right&&(ze.right=t)}const Re=We[0]-ze.left-ze.right,Be=We[1]-ze.top-ze.bottom,je="function"==typeof Zt?Zt({size:We,margin:ze}):Zt,Fe="function"==typeof Kt?Kt({size:We,margin:ze}):Kt,Ye=null!=Dt?Dt:Ot,He=t.useRef(null),Xe=t.useRef(null),Ge=t.useRef(0),Ve=t.useRef(!1),Qe=Ae(t=>t.theme),[tn,en]=t.useState(0),[nn,rn]=t.useState(null),on=t.useRef(null),ln=t.useRef(null),[an,sn]=t.useState(null),[cn,un]=t.useState(!1),[dn,hn]=t.useState([]),[fn,yn]=t.useState([]),gn=t.useRef(()=>{}),pn="streaming"===p||["bar","swarm","waterfall"].includes(y),vn=t.useMemo(()=>({chartType:y,runtimeMode:pn?"streaming":"bounded",windowSize:O,windowMode:N,arrowOfTime:pn?T:"right",extentPadding:z,scalePadding:R,xAccessor:pn?void 0:w,yAccessor:pn?void 0:E,timeAccessor:pn?$:void 0,valueAccessor:L,colorAccessor:A,sizeAccessor:M,groupAccessor:S||(P?"_lineGroup":void 0),categoryAccessor:ne,lineDataAccessor:P,xScaleType:Ee,yScaleType:Pe,xExtent:I,yExtent:W,sizeRange:B,binSize:D,normalize:C,boundsAccessor:rt,boundsStyle:ot,y0Accessor:it,gradientFill:!0===ut?{topOpacity:.8,bottomOpacity:.05}:!1===ut?void 0:ut,areaGroups:gt?new Set(gt):void 0,lineGradient:yt,openAccessor:pt,highAccessor:vt,lowAccessor:mt,closeAccessor:xt,candlestickStyle:bt,lineStyle:q,pointStyle:U,areaStyle:K,swarmStyle:tt,waterfallStyle:J,colorScheme:nt,barColors:et,annotations:Wt,decay:ie,pulse:le,transition:ae,staleness:se,heatmapAggregation:ue,heatmapXBins:ye,heatmapYBins:me,showValues:xe,heatmapValueFormat:be,pointIdAccessor:we,curve:_}),[y,O,N,T,z,R,w,E,$,L,Ee,Pe,A,M,S,ne,P,I,W,B,D,C,rt,ot,it,ut,yt,gt,pt,vt,mt,xt,bt,q,U,K,tt,J,nt,et,Wt,ie,le,ae,se,ue,ye,me,xe,be,pn,we,_]),mn=t.useRef(null);mn.current||(mn.current=new X(vn));const xn=t.useCallback(()=>{Ge.current||(Ge.current=requestAnimationFrame(()=>gn.current()))},[]);t.useEffect(()=>{var t;null===(t=mn.current)||void 0===t||t.updateConfig(vn),Ve.current=!0,xn()},[vn,xn]),t.useEffect(()=>{He.current&&_e.delete(He.current),Ve.current=!0,xn()},[Qe,xn]);const bn=t.useRef(null);bn.current||(bn.current=new b(t=>{const e=mn.current;e&&e.ingest(t)&&(Ve.current=!0,xn())},{chunkThreshold:m,chunkSize:k})),t.useEffect(()=>{var t;null===(t=bn.current)||void 0===t||t.updateChunkOptions({chunkThreshold:m,chunkSize:k})},[m,k]);const kn=t.useCallback(t=>{var e;null===(e=bn.current)||void 0===e||e.push(t)},[]),wn=t.useCallback(t=>{var e;null===(e=bn.current)||void 0===e||e.pushMany(t)},[]),En=t.useCallback(()=>{var t,e;null===(t=bn.current)||void 0===t||t.clear(),null===(e=mn.current)||void 0===e||e.clear(),Ve.current=!0,xn()},[xn]);t.useImperativeHandle(n,()=>({push:kn,pushMany:wn,remove:t=>{var e,n,r;null===(e=bn.current)||void 0===e||e.flush();const o=null!==(r=null===(n=mn.current)||void 0===n?void 0:n.remove(t))&&void 0!==r?r:[];return o.length>0&&(Ve.current=!0,xn()),o},update:(t,e)=>{var n,r,o;null===(n=bn.current)||void 0===n||n.flush();const i=null!==(o=null===(r=mn.current)||void 0===r?void 0:r.update(t,e))&&void 0!==o?o:[];return i.length>0&&(Ve.current=!0,xn()),i},clear:En,getData:()=>{var t,e,n;return null===(t=bn.current)||void 0===t||t.flush(),null!==(n=null===(e=mn.current)||void 0===e?void 0:e.getData())&&void 0!==n?n:[]},getScales:()=>{var t,e;return null!==(e=null===(t=mn.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=mn.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[kn,wn,En,xn]),t.useEffect(()=>{var t,e;if(v){if(P&&v.length>0&&"object"==typeof v[0]&&null!==v[0]){const e="string"==typeof P?P:"coordinates";if(Array.isArray(v[0][e])){const n=[];for(const t of v){const r=t[e];if(Array.isArray(r)){const e=t.label||t.id||t.key;if(null!=e)for(const t of r)n.push(Object.assign(Object.assign({},t),{_lineGroup:e}));else for(const t of r)n.push(t)}}return void(null===(t=bn.current)||void 0===t||t.setBoundedData(n))}}null===(e=bn.current)||void 0===e||e.setBoundedData(v)}},[v,P]);const An=t.useRef(()=>{}),Mn=t.useRef(()=>{});An.current=t=>{if(!Ye)return;const e=He.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-ze.left,o=t.clientY-n.top-ze.top;if(0>r||r>Re||0>o||o>Be)return void(on.current&&(on.current=null,ln.current=null,sn(null),Tt&&(Tt(null),Ve.current=!0),xn()));const i=mn.current;if(!i||0===i.scene.length)return;const l=Z(i.scene,r,o,$t,i.quadtree);if(!l)return void(on.current&&(on.current=null,ln.current=null,sn(null),Tt&&Tt(null),xn()));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"===It&&i.scene.length>0&&i.scales){const t=function(t,e,n=30){const r=[];for(const o of t)if("line"===o.type){const t=o;if(2>t.path.length)continue;const i=Q(t.path,e,n);if(null===i)continue;const l=lt(t.path,e);r.push({node:o,datum:Array.isArray(t.datum)&&t.datum[l]?t.datum[l]:t.datum,x:t.path[l][0],y:i,group:t.group,color:t.style.stroke})}else if("area"===o.type){const t=o;if(!1===t.interactive)continue;if(2>t.topPath.length)continue;const i=Q(t.topPath,e,n);if(null===i)continue;const l=lt(t.topPath,e);r.push({node:o,datum:Array.isArray(t.datum)&&t.datum[l]?t.datum[l]:t.datum,x:t.topPath[l][0],y:i,group:t.group,color:"string"==typeof t.style.stroke?t.style.stroke:"string"==typeof t.style.fill?t.style.fill:void 0})}return r}(i.scene,l.x,$t),e=i.scales.y.invert,n=i.scales.x.invert;if(t.length>0){const r=n?n(l.x):l.x;s.xValue=r,s.xPx=l.x,s.allSeries=t.map(t=>({group:t.group||"",value:e?e(t.y):t.y,valuePx:t.y,color:t.color||"#007bff",datum:t.datum}))}}on.current=s,ln.current=l.node,sn(s),Tt&&(Tt(s),Ve.current=!0),xn()},Mn.current=()=>{on.current&&(on.current=null,ln.current=null,sn(null),Tt&&(Tt(null),Ve.current=!0),xn())},t.useCallback(t=>An.current(t),[]);const Sn=t.useCallback(()=>Mn.current(),[]),Pn=t.useRef(()=>{});Pn.current=t=>{if(!Nt)return;const e=He.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-ze.left,o=t.clientY-n.top-ze.top;if(0>r||r>Re||0>o||o>Be)return void Nt(null);const i=mn.current;if(!i||0===i.scene.length)return void Nt(null);const l=Z(i.scene,r,o,$t,i.quadtree);if(!l)return void Nt(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});Nt(s)};const _n=t.useCallback(t=>Pn.current(t),[]),Cn=t.useRef(-1),Dn=t.useRef(null),Ln=t.useRef(null),Tn=t.useCallback(t=>{const e=mn.current;if(!e||0===e.scene.length)return;const n=e.version;let r;if(Ln.current&&Ln.current.version===n)r=Ln.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=at(t),Ln.current={version:n,graph:r}}const o=Cn.current;if(0>o){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key))return;t.preventDefault(),Cn.current=0;const e=r.flat[0];Dn.current={shape:e.shape,w:e.w,h:e.h};const n=dt(e);return on.current=n,sn(n),Tt&&Tt(n),void xn()}const i=st(r,o),l=ct(t.key,i,r);if(null===l)return;if(t.preventDefault(),0>l)return Cn.current=-1,Dn.current=null,on.current=null,ln.current=null,sn(null),Tt&&Tt(null),void xn();Cn.current=l;const a=r.flat[l];Dn.current={shape:a.shape,w:a.w,h:a.h};const s=dt(a);on.current=s,sn(s),Tt&&Tt(s),xn()},[Tt,xn]),Nn=t.useCallback(t=>{Cn.current=-1,Dn.current=null,An.current(t)},[]);gn.current=()=>{var t,e;Ge.current=0;const n=He.current,r=Xe.current;if(!n||!r)return;const o=mn.current;if(!o)return;const i="undefined"!=typeof performance?performance.now():Date.now(),l=o.advanceTransition($e.current?i+1e6:i),a=!$e.current&&l,s=Ve.current||l;s&&!a&&o.computeScene({width:Re,height:Be});const c=Se(),u=function(t){if(!t)return Ze;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||Ze.axisStroke,tickText:i||Ze.tickText,crosshair:i?i+"66":Ze.crosshair,hoverFill:s?s+"4D":Ze.hoverFill,hoverStroke:i?i+"99":Ze.hoverStroke,pointRing:s||Ze.pointRing}:Ze}(n),d=null!==(t=null==se?void 0:se.threshold)&&void 0!==t?t:5e3,h=se&&o.lastIngestTime>0&&i-o.lastIngestTime>d;if(s){const t=Me(n,We,ze,c);if(t){t.clearRect(-ze.left,-ze.top,We[0],We[1]),h&&(t.globalAlpha=null!==(e=null==se?void 0:se.dimOpacity)&&void 0!==e?e:.5);const r=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=V||(r&&"transparent"!==r?r:null);if(i&&(t.fillStyle=i,t.fillRect(-ze.left,-ze.top,We[0],We[1])),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,Re,Be),t.clip()),Qt&&o.scales)for(const e of Qt)t.save(),e(t,o.scene,o.scales,{width:Re,height:Be}),t.restore();const l=Ue[y];if(l&&o.scales)for(const e of l)e(t,o.scene,o.scales,{width:Re,height:Be});t.restore(),h&&(t.globalAlpha=1)}}{const t=Me(r,We,ze,c);if(t&&(t.clearRect(-ze.left,-ze.top,We[0],We[1]),Ye&&on.current&&o.scales&&function(t,e,n,r,o,i,l){var a,s;if(!1===o.crosshair)return;const c=e.allSeries,u=c&&c.length>0,d=null!==(a=e.xPx)&&void 0!==a?a:e.x;t.save();const h="object"==typeof o.crosshair?o.crosshair:{};if(t.strokeStyle=h.stroke||l.crosshair,t.lineWidth=h.strokeWidth||1,t.setLineDash(h.strokeDasharray?h.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(u?d:e.x,0),t.lineTo(u?d:e.x,r),t.stroke(),u||(t.beginPath(),t.moveTo(0,e.y),t.lineTo(n,e.y),t.stroke()),t.restore(),u){t.lineWidth=2,t.strokeStyle=l.pointRing;for(const e of c)null!=e.valuePx&&(t.beginPath(),t.arc(d,e.valuePx,4,0,2*Math.PI),t.fillStyle=e.color||"#007bff",t.fill(),t.stroke())}else{let n="";try{(null===(s=t.canvas)||void 0===s?void 0:s.parentElement)&&(n=getComputedStyle(t.canvas).getPropertyValue("--semiotic-primary").trim())}catch(t){}const r=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)||n||"#007bff";t.beginPath(),t.arc(e.x,e.y,4,0,2*Math.PI),t.fillStyle=r,t.fill(),t.strokeStyle=l.pointRing,t.lineWidth=2,t.stroke()}}(t,on.current,Re,Be,"object"==typeof Ye?Ye:{},ln.current,u),ln.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,ln.current,e)}}s&&n&&n.setAttribute("aria-label",Jt(o.scene,y+" chart"));const f=Ve.current;if(Ve.current=!1,f&&o.scales){const t=t=>"object"==typeof t&&null!==t&&"function"==typeof t.valueOf?t.valueOf():t;if((!nn||t(nn.x.domain()[0])!==t(o.scales.x.domain()[0])||t(nn.x.domain()[1])!==t(o.scales.x.domain()[1])||t(nn.y.domain()[0])!==t(o.scales.y.domain()[0])||t(nn.y.domain()[1])!==t(o.scales.y.domain()[1])||nn.x.range()[0]!==o.scales.x.range()[0]||nn.x.range()[1]!==o.scales.x.range()[1]||nn.y.range()[0]!==o.scales.y.range()[0]||nn.y.range()[1]!==o.scales.y.range()[1])&&rn(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"];hn(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),yn(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}}f&&Wt&&Wt.length>0&&en(t=>t+1),(null==se?void 0:se.showBadge)&&un(!!h),(a||o.hasActivePulses)&&(Ge.current=requestAnimationFrame(()=>gn.current()))},t.useEffect(()=>(xn(),()=>{Ge.current&&(cancelAnimationFrame(Ge.current),Ge.current=0)}),[xn]),t.useEffect(()=>{Ve.current=!0,xn()},[y,Re,Be,kt,V,q,Qt,xn]),ft(se,mn,Ve,xn,cn,un);const On=t.useMemo(()=>{if(St||_t)return;const t=mn.current;return(null==t?void 0:t.xIsDate)&&nn?qe(nn.x.domain()):void 0},[St,_t,nn]),$n=St||_t||On,In=Ye&&an?Lt?Lt(an):g.createElement(Je,{hover:an}):null,Wn=In?g.createElement(pe,{x:an.x,y:an.y,containerWidth:Re,containerHeight:Be,margin:ze,className:"stream-frame-tooltip"},In):null,zn=Dn.current,Rn=g.createElement(ge,{active:Cn.current>=0,hoverPoint:an,margin:ze,size:We,shape:null==zn?void 0:zn.shape,width:null==zn?void 0:zn.w,height:null==zn?void 0:zn.h}),Bn=(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},jn=Bn(w,$,"__semiotic_resolvedX","__semiotic_resolvedTime"),Fn=Bn(E,L,"__semiotic_resolvedY","__semiotic_resolvedValue"),Yn=jn.key,Hn=Fn.key,Xn=Wt&&Wt.length>0,Gn=t=>{if(!t||!Xn||!jn.fn&&!Fn.fn)return t;let e=!1;const n=t.map(t=>{const n=jn.fn&&jn.key&&!(jn.key in t),r=Fn.fn&&Fn.key&&!(Fn.key in t);if(!n&&!r)return t;e=!0;const o=Object.assign({},t);return n&&(o[jn.key]=jn.fn(t)),r&&(o[Fn.key]=Fn.fn(t)),o});return e?n:t};if(Ut){const t=mn.current;t&&v&&(t.ingest({inserts:v,bounded:!0}),t.computeScene({width:Re,height:Be}));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=$n||(()=>{if((null==t?void 0:t.xIsDate)&&n)return qe(n.x.domain())})();return g.createElement("div",{className:"stream-xy-frame"+(G?" "+G:""),role:"img","aria-label":De||("string"==typeof ee?ee:"XY chart"),style:{position:"relative",width:We[0],height:We[1]}},g.createElement(de,{summary:Le}),g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:We[0],height:We[1],style:{position:"absolute",left:0,top:0}},g.createElement("g",{transform:`translate(${ze.left},${ze.top})`},Fe),g.createElement("g",{transform:`translate(${ze.left},${ze.top})`},V&&g.createElement("rect",{x:0,y:0,width:Re,height:Be,fill:V}),te&&n&&te.map((t,r)=>g.createElement(g.Fragment,{key:"svgpre-"+r},t(e,n,{width:Re,height:Be}))),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:qt(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:qt(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:qt(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(Vt,{width:Re,height:Be,totalWidth:We[0],totalHeight:We[1],margin:ze,scales:n,showAxes:kt,axes:wt,xLabel:Et,yLabel:At,yLabelRight:Mt,xFormat:i,yFormat:Pt||Ct,showGrid:Rt,title:ee,legend:Bt,legendHoverBehavior:jt,legendClickBehavior:Ft,legendHighlightedCategory:Yt,legendIsolatedCategories:Xt,legendPosition:Gt,foregroundGraphics:je,marginalGraphics:ke,xValues:[],yValues:[],annotations:Wt,svgAnnotationRules:zt,annotationFrame:0,xAccessor:Yn,yAccessor:Hn,annotationData:Gn(null==t?void 0:t.getData()),pointNodes:null==t?void 0:t.scene.filter(t=>"point"===t.type),curve:"string"==typeof _?_:void 0,linkedCrosshairName:Te,linkedCrosshairSourceId:Ne}))}const Vn="semiotic-table-"+g.useId();return g.createElement("div",{ref:Ie,className:"stream-xy-frame"+(G?" "+G:""),role:"group","aria-label":De||("string"==typeof ee?ee:"XY chart"),tabIndex:0,style:{position:"relative",width:F?"100%":We[0],height:Y?"100%":We[1],overflow:"visible"},onKeyDown:Tn},Ce&&g.createElement(he,{tableId:Vn}),Ce&&g.createElement(ce,{scene:null!==(l=null===(i=mn.current)||void 0===i?void 0:i.scene)&&void 0!==l?l:[],chartType:y+" chart",tableId:Vn,chartTitle:"string"==typeof ee?ee:void 0}),g.createElement(de,{summary:Le}),g.createElement("div",{role:"img","aria-label":De||("string"==typeof ee?ee:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Ye?Nn:void 0,onMouseLeave:Ye?Sn:void 0,onClick:Nt?_n:void 0},Fe&&g.createElement("svg",{style:{position:"absolute",left:0,top:0,width:We[0],height:We[1],pointerEvents:"none"}},g.createElement("g",{transform:`translate(${ze.left},${ze.top})`},Fe)),g.createElement(Ht,{width:Re,height:Be,totalWidth:We[0],totalHeight:We[1],margin:ze,scales:nn,showAxes:kt,axes:wt,showGrid:Rt,xFormat:$n,yFormat:Pt||Ct}),g.createElement("canvas",{ref:He,"aria-label":Jt(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:Xe,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),g.createElement(fe,{hoverPoint:an}),g.createElement(Vt,{width:Re,height:Be,totalWidth:We[0],totalHeight:We[1],margin:ze,scales:nn,showAxes:kt,axes:wt,xLabel:Et,yLabel:At,yLabelRight:Mt,xFormat:$n,yFormat:Pt||Ct,showGrid:Rt,title:ee,legend:Bt,legendHoverBehavior:jt,legendClickBehavior:Ft,legendHighlightedCategory:Yt,legendIsolatedCategories:Xt,legendPosition:Gt,foregroundGraphics:je,marginalGraphics:ke,xValues:dn,yValues:fn,annotations:Wt,svgAnnotationRules:zt,annotationFrame:tn,xAccessor:Yn,yAccessor:Hn,annotationData:Gn(null===(c=mn.current)||void 0===c?void 0:c.getData()),pointNodes:null===(u=mn.current)||void 0===u?void 0:u.scene.filter(t=>"point"===t.type),curve:"string"==typeof _?_:void 0,underlayRendered:!0,linkedCrosshairName:Te,linkedCrosshairSourceId:Ne}),(re||oe)&&g.createElement(x,{width:Re,height:Be,totalWidth:We[0],totalHeight:We[1],margin:ze,dimension:null!==(d=null==re?void 0:re.dimension)&&void 0!==d?d:"xy",scales:nn,onBrush:null!=oe?oe:()=>{},binSize:D,snap:null==re?void 0:re.snap,binBoundaries:null!==(h=null==re?void 0:re.binBoundaries)&&void 0!==h?h:"bar"===y?null===(f=mn.current)||void 0===f?void 0:f.getBinBoundaries():void 0,snapDuring:null==re?void 0:re.snapDuring,streaming:"streaming"===p}),(null==se?void 0:se.showBadge)&&g.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===se.badgePosition?{top:4,left:4}:"bottom-left"===se.badgePosition?{bottom:4,left:4}:"bottom-right"===se.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:cn?"#dc3545":"#28a745",color:"white"})},cn?"STALE":"LIVE"),Rn,Wn))});tn.displayName="StreamXYFrame";const en={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},nn={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class rn{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=on(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 on(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,d]=t[l],h=ln(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 t=f/g;h.x+=-y/g*n*r*2,h.y+=t*n*r*2}return h}(t.segments,e,n,t.halfWidth);if(!t.points)return{x:0,y:0};const[r,o,i,l]=t.points,a=ln(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 ln(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 an(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function sn(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,d=!1;for(o.push(t),i[t]=!0,e=0;a[t].length>e;e++)(r=a[t][e])===n?(u(n,o),d=!0):i[r]||(d=c(r));if(d)s(t);else for(e=0;a[t].length>e;e++){var h=l[r=a[t][e]];h||(l[r]=h={}),h[r]=!0}return o.pop(),d}function u(t,e){var n=[].concat(e).concat(t);r.push(n)}function d(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,d=[],h=[];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=[],v=[],m=0;for(y=s.length-1;y>=0;--y){var x=s[y];if(o[x]=!1,p.push(x),v.push(a[x]),m+=a[x].length,l[x]=d.length,x===e){s.length=y;break}}d.push(p);var b=Array(m);for(y=0;v.length>y;y++)for(var k=0;v[y].length>k;k++)b[--m]=v[y][k];h.push(b)}c.pop()}}}for(s=0;e>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(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]);h[s]=c}}return{components:d,adjacencyList:h}}(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 h=t.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 cn(t){return t.y0-t.y1>0?"up":"down"}function un(t,e){return e(t.source)==e(t.target)}function dn(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 hn(t){return t.target.x0-t.source.x1}function fn(t,e){var n=gn(t),r=hn(e)/Math.tan(n);return"up"==cn(t)?t.y1-r:t.y1+r}function yn(t,e){var n=gn(t),r=hn(e)/Math.tan(n);return"up"==cn(t)?t.y1+r:t.y1-r}function gn(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function pn(t,e){return e(t)}function vn(t){return xn(t.source)}function mn(t){return xn(t.target)}function xn(t){return(t.y0+t.y1)/2}function bn(t){return t.virtual?0:t.value}function kn(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!un(t,e)?n+1:n});var r=0;return t.targetLinks.forEach(function(t){r=t.circular&&!un(t,e)?r+1:r}),n+r}function wn(t){return t.target.depth}function En(t,e){return t.sourceLinks.length?t.depth:e-1}function An(t,e){return t.y0-e.y0}function Mn(t,e){return e.y0-t.y0}function Sn(t,e){return t.y1-e.y1}function Pn(t,e){return e.y1-t.y1}function _n(t,e){return Dn(t.source,e.source)||t.index-e.index}function Cn(t,e){return Dn(t.target,e.target)||t.index-e.index}function Dn(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Ln(t,e){return Tn(t)==Tn(e)?"bottom"==t.circularLinkType?Mn(t,e):An(t,e):Tn(e)-Tn(t)}function Tn(t){return t.target.column-t.source.column}function Nn(t,e){return On(t)==On(e)}function On(t){return t.y0-t.y1>0?"up":"down"}function $n(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}),In(i.links.filter(function(t){return"top"==t.circularLinkType}),e,n),In(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,un(t,e)&&dn(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?Mn:An);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:Sn),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 In(t,e,n){t.sort(Ln);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(un(t,e)&&dn(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&&Wn(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 Wn(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function zn(t){return function(){return t}}function Rn(t){return t.index}function Bn(t){return t.nodes}function jn(t){return t.links}function Fn(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+=xn(t.source)*e,r+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=xn(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?kn(e,n)-kn(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==kn(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 Yn(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]});d();for(var s=1,c=i;c>0;--c)u(s*=.99,n),d();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&&kn(o,n)>0){var c=l.mean(o.sourceLinks,mn),u=l.mean(o.targetLinks,vn),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-xn(o))*e*.3;o.y0+=h,o.y1+=h}}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,mn),y=l.mean(o.targetLinks,vn),g=((f&&y?(f+y)/2:f||y)-xn(o))*e;o.y0+=g,o.y1+=g}})})}function d(){a.forEach(function(n){var i,l,a,s=t.y0,c=n.length;for(n.sort(e||Dn),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 Hn(t){t.nodes.forEach(function(t){t.sourceLinks.sort(Cn),t.targetLinks.sort(_n)}),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 Xn(){var t=0,e=0,n=1,r=1,o=24,i=8,a=null,s=Rn,c=En,u=void 0,d=32,h=2,f=Bn,y=jn;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=an(n,r)),"object"!=typeof o&&(o=t.target=an(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=sn(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){pn(t,e)!=pn(o.source,e)&&pn(t,e)!=pn(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),un(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,bn),l.sum(t.targetLinks,bn)),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),Fn(f,u,s),Yn(f,u,s,y,y,d),Hn(f),$n(f,s,h,10,8),Fn(f,u,s),Yn(f,u,s,y,y,d),Hn(f),$n(f,s,h,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 pn(n.source,e)==pn(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(!Nn(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=fn(e,t);return t.y1-n}if(e.target.column>t.target.column)return fn(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 pn(n.target,e)==pn(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(!Nn(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=yn(e,t);return t.y0-n}if(e.source.column>t.source.column)return yn(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),$n(f,s,h,10,8)}(g),g}return g.update=function(t){return Hn(t),$n(t,s,h,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:zn(t),g):f},g.links=function(t){return arguments.length?(y="function"==typeof t?t:zn(t),g):y},g.nodeId=function(t){return arguments.length?(s="function"==typeof t?t:zn(t),g):s},g.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:zn(t),g):c},g.nodeSort=function(t){return arguments.length?(u=t,g):u},g.iterations=function(t){return arguments.length?(d=+t,g):d},g.circularLinkGap=function(t){return arguments.length?(h=+t,g):h},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 Gn=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 Vn(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,d=o.verticalFullExtent,h="bottom"===t.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 qn=new Set,Un=new WeakMap;function Kn(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let n=Un.get(t);if(n){const t=n.get(e);if(t)return t}else n=new Map,Un.set(t,n);const r=new Proxy(t,{get(t,n,r){if("string"==typeof n&&!(n in t)&&t.data&&n in t.data){const t=`${e}:${n}`;qn.has(t)||(qn.add(t),console.warn(`[Semiotic] "${e}" 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(t,n,r)}});return n.set(e,r),r}const Zn={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(wn))-1:0},justify:En},Qn={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,r){var o,i,l,a,s,c,u;if(0===t.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=t.map(t=>Object.assign({},t)),v=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 m;m="down"===d?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const x=Xn().extent(m).links(v).nodes(p).nodeAlign(Zn[h]||En).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 v){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],d=r[1];if(i>0&&l>0&&(0>t||0>n||e>u||o>d)){const e=Math.min(u/i,d/l),r=-t*e+(u-i*e)/2,o=-n*e+(d-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 v)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 v){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=d;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,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;t.forEach((t,e)=>{g.set(t.id,y[e%y.length])});const p=[],v=[],m=[],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(Kn(e,"nodeStyle")):{},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=d?d(Kn(t,"edgeStyle")):{};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;v.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:h,stroke:"none",opacity:o.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+i}}),v.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:h,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?Vn(t):Gn(t),!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};v.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),m.push({x:l,y:a,text:i+"",anchor:s,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:p,sceneEdges:v,labels:m}}},Jn={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 h=[];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++):h.push(e)}const f=u>0&&.3>=(t.length>0?h.length/t.length:1);if(f){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of h){const r=tr(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=er(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=er(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=0===n.iterations?0:f?40:y,p=nr(n.nodeSize,n.nodeSizeRange,t),v=t=>p(t);if(g>0){const n=d.forceLink().strength(t=>Math.min(2.5,t.weight?t.weight*l:l)).id(t=>t.id),r=d.forceSimulation().force("charge",d.forceManyBody().strength(t=>-25*v(t))).force("center",d.forceCenter(a,s).strength(.8)).force("x",d.forceX(a).strength(.15)).force("y",d.forceY(s).strength(.15));if(r.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}));r.force("link",n),r.force("link").links(t)}f?r.alpha(.3):.1>r.alpha()&&r.alpha(1),r.stop();for(let t=0;g>t;++t)r.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=v(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 m=new Map;for(const e of t)m.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=m.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=m.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,r){var o,l,a;const s=n.nodeStyle,c=n.edgeStyle,u=nr(n.nodeSize,n.nodeSizeRange,t),d=Array.isArray(n.colorScheme)?n.colorScheme:i.schemeCategory10,h=new Map;t.forEach((t,e)=>{h.set(t.id,d[e%d.length])});const f=[],y=[],g=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=u(Kn(e,"nodeSize")),n=s?s(Kn(e,"nodeStyle")):{},r={fill:n.fill||h.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(Kn(t,"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:e.x,y1:e.y,x2:n.x,y2:n.y,style:o,datum:t})}if(!1!==n.showLabels){const e=(v=n.nodeLabel)?"function"==typeof v?v:t=>t[v]||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(Kn(n,"nodeSize"));g.push({x:n.x,y:n.y-r-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var v;return{sceneNodes:f,sceneEdges:y,labels:g}}};function tr(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 er(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 nr(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 d=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]:d(r)}}const rr=i.schemeCategory10,or={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,d=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,v=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);v[n][r]=o}const m=h.chord().padAngle(o);l&&m.sortGroups(l);const x=m(v),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]+d,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,d=r[1]/2,f=n.nodeStyle,y=n.edgeStyle,g=n.edgeColorBy||"source",p=Array.isArray(n.colorScheme)?n.colorScheme:rr,v=new Map;t.forEach((t,e)=>{v.set(t.id,p[e%p.length])});const m=h.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(Kn(n,"nodeStyle")).fill||v.get(n.id)||p[e%p.length]:v.get(n.id)||p[e%p.length];const l=f?f(Kn(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 t of e){const e=t.chordData;if(!e)continue;const n=m(e);if(!n)continue;const r=ir(n,u,d);let o="#999";if(y)o=y(Kn(t,"edgeStyle")).fill||o;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===g&&n?o=v.get(n.id)||o:e&&(o=v.get(e.id)||o)}const l=y?y(Kn(t,"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: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: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 ir(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 lr=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function ar(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 sr(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 cr(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 ur(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 dr={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[d,h]=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,d,h);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,d,h);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,d,h);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,d,h);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,d,h)}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:sr(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?hr(i,r,n):"treemap"===l||"partition"===l?fr(i,r):"circlepack"===l&&yr(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 d=[],h=[],f=[],y=n.treeOrientation||"vertical",g="radial"===y,p=r[0]/2,v=r[1]/2,m="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+=v);const i=o(Kn(e,"nodeStyle"));let a=i.fill||"#4d430c";n.colorByDepth&&void 0!==e.depth&&(a=lr[e.depth%lr.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:t,cy:r,r:m,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+=v,l+=p,a+=v);const u=ur(r,o,l,a,y),d=i(Kn(t,"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:t})}if(!1!==n.showLabels){const e=cr(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+=v),g){const t=l-p,e=a-v,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-m-6,i="end"):(r=l+m+6,i="start"),o=a):(r=l,o=a+m+14,i="middle");f.push({x:r,y:o,text:t+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,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(Kn(n,"nodeStyle"));let s=a.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(s=lr[n.depth%lr.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=cr(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 d=n?n(s):s.id;if(!d)continue;if((u?30:40)>t||(u?16:14)>c)continue;let h=r(Kn(s,"nodeStyle")).fill||"#4d430c";e.colorByDepth&&void 0!==s.depth&&(h=lr[s.depth%lr.length]);const f=ar(h);a.push(u?{x:s.x0+t/2,y:s.y0+c/2,text:d+"",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:d+"",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(Kn(n,"nodeStyle"));let s=a.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(s=lr[n.depth%lr.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=cr(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(Kn(o,"nodeStyle")).fill||"#4d430c";if(e.colorByDepth&&void 0!==o.depth&&(c=lr[o.depth%lr.length]),l){const e=ar(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 hr(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 fr(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 yr(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 gr(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const pr={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),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=gr(n);g.metaMap.clear(),r.length=0,o.length=0;const p=new Map;function v(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 m=e[0]/2,x=e[1]/2,b=Math.min(e[0],e[1])/2*.85,k=v(c(t));r.push({id:k,x:m,y:x,x0:m,x1:m,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,d,h,p){const m=a(e);if(!(null==m?void 0:m.length))return;const x=m.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=m.slice(E,E+k);if(!w.length)break;const A=(x+1)/b,M={id:n,depth:h,data:e,parentId:n},S=p?d/f(M)*A:d*A,P=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=(_[e].startAngle+_[e].endAngle)/2,s=w[e],u=v(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}}),t(s,u,d,f,S,h+1,!0)}E+=k}}(t,k,m,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,d="number"==typeof u?()=>u:"function"==typeof u?u:()=>6,h=[],f=[],y=[];if(!1!==n.orbitShowRings){const e=gr(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=d(Kn(e,"nodeSize")),n=c?c(Kn(e,"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=e.depth)&&void 0!==l?l:0)?1:.85};h.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=d(Kn(n,"nodeSize"));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:h,sceneEdges:f,labels:y}},tick:(t,e,n,r,o)=>!1!==n.orbitAnimated&&(function(t,e){var n,r;const o=gr(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)},vr={sankey:Qn,force:Jn,chord:or,tree:dr,cluster:dr,treemap:dr,circlepack:dr,partition:dr,orbit:pr};function mr(t){return vr[t]}class xr{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({},en),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&(this.particlePool=new rn(2e3))}updateConfig(t){const e=this.config;e.__orbitState&&(t.__orbitState=e.__orbitState),e.__hierarchyRoot&&(t.__hierarchyRoot=e.__hierarchyRoot),this.config=t,this.tensionConfig=Object.assign(Object.assign({},en),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&!this.particlePool&&(this.particlePool=new rn(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({},br(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({},br(r)),{data:n})),this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},br(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,br(e)),this.nodeTimestamps.set(e,l),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,br(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=mr(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),this.config.__previousPositions=void 0,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 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 t of d)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)d.has(t)||this.removedNodes.add(t);for(const t of h)this.previousEdgeKeys.has(t)||this.addedEdges.add(t);for(const t of this.previousEdgeKeys)h.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=d,this.previousEdgeKeys=h,this.layoutVersion++}buildScene(t){const e=mr(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=mr(this.config.chartType);return!!(null==t?void 0:t.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(t,e){const n=mr(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=O(t._prevX0,t._targetX0,n),t.x1=O(t._prevX1,t._targetX1,n),t.y0=O(t._prevY0,t._targetY0,n),t.y1=O(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=O(t._prevY0,t._targetY0,n),t.y1=O(t._prevY1,t._targetY1,n),t.sankeyWidth=O(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 d=a-1-u;let h;switch(i.type){case"linear":h=l+(1-d/(a-1))*(1-l);break;case"exponential":{const t=null!==(e=i.halfLife)&&void 0!==e?e:a/2;h=l+Math.pow(.5,d/t)*(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=t.style)||void 0===r?void 0:r.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:f*h})}}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())}}updateNode(t,e){var n;const r=this.nodes.get(t);if(!r)return null;const o=r.data?Object.assign({},r.data):{};return r.data=e(null!==(n=r.data)&&void 0!==n?n:{}),this.layoutVersion++,o}updateEdge(t,e,n){var r;const o=this.config.valueAccessor,i="function"==typeof o?o:o?t=>t[o]:t=>t.value,l=[];for(const[,o]of this.edges)if(("string"==typeof o.source?o.source:o.source.id)===t&&("string"==typeof o.target?o.target:o.target.id)===e){l.push(o.data?Object.assign({},o.data):{}),o.data=n(null!==(r=o.data)&&void 0!==r?r:{});const t=i(o.data);null!=t&&(o.value=Number(t))}return l.length>0&&this.layoutVersion++,l}removeNode(t){if(!this.nodes.has(t))return!1;this.nodes.delete(t),this.nodeTimestamps.delete(t);for(const[e,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==t&&("string"==typeof n.target?n.target:n.target.id)!==t||(this.edges.delete(e),this.edgeTimestamps.delete(e));return this.layoutVersion++,!0}removeEdge(t,e){const n=[];for(const[r,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===t&&("string"==typeof o.target?o.target:o.target.id)===e&&n.push(r);for(const t of n)this.edges.delete(t),this.edgeTimestamps.delete(t);return n.length>0&&this.layoutVersion++,n.length>0}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 br(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 kr(t,e,n,r,o=30){let i=null,l=o,a=1/0;for(const e of t){const t=wr(e,n,r,o);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=Sr(t,n,r);e&&l>e.distance&&(i=e,l=e.distance)}return i}function wr(t,e,n,r=30){switch(t.type){case"circle":return function(t,e,n,r=30){const o=e-t.cx,i=n-t.cy,l=Math.sqrt(o*o+i*i);return l>V(t.r,r)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:l}}(t,e,n,r);case"rect":return function(t,e,n){const r=G(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=K(Math.atan2(o,r)),a=K(t.startAngle),s=K(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 Er=null,Ar=null;function Mr(){return Ar||(Er=document.createElement("canvas"),Er.width=1,Er.height=1,Ar=Er.getContext("2d")),Ar}function Sr(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=Mr();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=Mr();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 Pr(t){const{width:e,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:v,svgAnnotationRules:m}=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)),v&&v.filter(t=>"widget"!==t.type).map((t,r)=>{if(m){const o=m(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,bt({legend:s,totalWidth:r,totalHeight:o,margin:i,legendPosition:f,title:a,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h})),null==v?void 0:v.filter(t=>"widget"===t.type&&t.nodeId&&p).map((t,e)=>{var n,r,o,l,a,s,c,u,d;const h=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(!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),v=null!==(a=t.dx)&&void 0!==a?a:0,m=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!==(d=t.content)&&void 0!==d?d:g.createElement("span",{style:{fontSize:18,cursor:"default"}},"ℹ️");return g.createElement("div",{key:"widget-"+e,style:{position:"absolute",left:f+v-x/2,top:y+m-b/2,width:x,height:b,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5}},k)}))}function _r(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 Cr(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 Dr(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 Lr(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()}Pr.displayName="NetworkSVGOverlay";const Tr={top:20,right:80,bottom:20,left:80},Nr={top:40,right:40,bottom:40,left:40},Or=new Set(["chord","force","circlepack","orbit"]),$r=[800,600],Ir={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 Wr({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:Ir},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:Ir},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:Ir},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 zr=t.forwardRef(function(e,n){var r,o,i,l,a,c,u,d,h,f,y,p,v,m;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:I=.1,padAngle:W=.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:tt=!1,nodeSize:et=8,nodeSizeRange:nt=[5,20],nodeLabel:rt,showLabels:ot=!0,labelMode:it,size:lt=$r,responsiveWidth:ut,responsiveHeight:dt,margin:yt,className:gt,background:pt,enableHover:vt=!0,tooltipContent:mt,customHoverBehavior:xt,customClickBehavior:bt,onObservation:kt,chartId:wt,onTopologyChange:Et,annotations:At,svgAnnotationRules:Mt,legend:St,legendPosition:Pt,legendHoverBehavior:_t,legendClickBehavior:Ct,legendHighlightedCategory:Dt,legendIsolatedCategories:Lt,title:Tt,foregroundGraphics:Nt,backgroundGraphics:Ot,decay:$t,pulse:It,staleness:Wt,thresholds:zt,accessibleTable:Rt=!0,description:Bt,summary:jt,orbitMode:Ft,orbitSize:Yt,orbitSpeed:Ht,orbitRevolution:Xt,orbitRevolutionStyle:Gt,orbitEccentricity:Vt,orbitShowRings:Kt,orbitAnimated:Zt}=e,Qt=ve(),Jt=t.useRef(Qt);Jt.current=Qt;const ee="semiotic-table-"+g.useId(),ne=Or.has(x)?Nr:Tr,[re,oe]=ht(lt,ut,dt),ie=Object.assign(Object.assign({},ne),yt),le=oe[0]-ie.left-ie.right,ae=oe[1]-ie.top-ie.bottom,se="function"==typeof Nt?Nt({size:oe,margin:ie}):Nt,ce=t.useMemo(()=>Object.assign(Object.assign({},en),X),[X]),ye=t.useMemo(()=>Object.assign(Object.assign({},nn),V),[V]),me=t.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:I,padAngle:W,groupWidth:z,sortGroups:R,edgeSort:B,treeOrientation:j,edgeType:F,padding:Y,paddingTop:H,tensionConfig:ce,showParticles:G,particleStyle:ye,nodeStyle:q,edgeStyle:U,nodeLabel:rt,showLabels:ot,labelMode:it,colorBy:K,colorScheme:Z,edgeColorBy:Q,edgeOpacity:J,colorByDepth:tt,nodeSize:et,nodeSizeRange:nt,decay:$t,pulse:It,staleness:Wt,thresholds:zt,orbitMode:Ft,orbitSize:Yt,orbitSpeed:Ht,orbitRevolution:Xt,orbitRevolutionStyle:Gt,orbitEccentricity:Vt,orbitShowRings:Kt,orbitAnimated:Zt}),[x,A,M,S,P,C,D,L,T,N,O,$,I,W,z,R,B,j,F,Y,H,ce,G,ye,q,U,rt,ot,it,K,Z,Q,J,tt,et,nt,$t,It,Wt,zt,Ft,Yt,Ht,Xt,Gt,Vt,Kt,Zt]),xe=t.useRef(null),be=t.useRef(0),ke=t.useRef(0),we=t.useRef(!0),Ee=Ae(t=>t.theme),Pe=t.useRef(()=>{}),_e=t.useRef(null);_e.current||(_e.current=new xr(me));const[Ce,De]=t.useState(null),[Le,Te]=t.useState(0),[Ne,Oe]=t.useState(0),[We,ze]=t.useState(!1),Re=t.useRef(null),Be=t.useRef(new Map),je=t.useRef(0),Fe=t.useCallback(t=>{if("function"==typeof K)return K(t)+"";if("string"==typeof K&&t.data){const e=t.data[K];if(void 0!==e){if(!Be.current.has(e+"")){const t=Array.isArray(Z)?Z:_;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:_,n=K?e[je.current++%e.length]:e[0];return Be.current.set(t.id,n),n},[K,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]),He=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"===ye.colorBy&&n?Fe(n):e?Fe(e):"#999"},[null==V?void 0:V.colorBy,ye.colorBy,Fe,Ye]),Xe="sankey"===x&&G||!!It||null!==(o=null===(r=_e.current)||void 0===r?void 0:r.isAnimating)&&void 0!==o&&o,Ge=t.useCallback(()=>{be.current&&!Xe||be.current||(be.current=requestAnimationFrame(()=>Pe.current()))},[Xe]);t.useEffect(()=>{var t;null===(t=_e.current)||void 0===t||t.updateConfig(me),we.current=!0,Ge()},[me,Ge]),t.useEffect(()=>{we.current=!0,Ge()},[Ee,Ge]);const Ve=t.useCallback(()=>{var t;const e=_e.current;if(!e)return;e.runLayout([le,ae]),e.buildScene([le,ae]),we.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:_,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,Te(e.layoutVersion),Et){const{nodes:t,edges:n}=e.getLayoutData();Et(t,n)}},[le,ae,Et,Z]),qe=t.useCallback(t=>{const e=_e.current;e&&(e.ingestEdge(t)&&Ve(),Ge())},[Ve,Ge]),Ue=t.useCallback(t=>{const e=_e.current;if(!e)return;let n=!1;for(const r of t)e.ingestEdge(r)&&(n=!0);n&&Ve(),Ge()},[Ve,Ge]),Ke=t.useCallback(()=>{var t;null===(t=_e.current)||void 0===t||t.clear(),Be.current.clear(),je.current=0,Te(0),De(null),Re.current=null,we.current=!0,Ge()},[Ge]),Ze=t.useCallback(()=>{const t=_e.current;t&&(t.tension+=999,Ve(),Ge())},[Ve,Ge]);t.useImperativeHandle(n,()=>({push:qe,pushMany:Ue,removeNode:t=>{var e,n;const r=null!==(n=null===(e=_e.current)||void 0===e?void 0:e.removeNode(t))&&void 0!==n&&n;return r&&(Be.current.delete(t),Ve(),we.current=!0,Ge()),r},removeEdge:(t,e)=>{var n,r;const o=null!==(r=null===(n=_e.current)||void 0===n?void 0:n.removeEdge(t,e))&&void 0!==r&&r;return o&&(Ve(),we.current=!0,Ge()),o},updateNode:(t,e)=>{var n,r;const o=null!==(r=null===(n=_e.current)||void 0===n?void 0:n.updateNode(t,e))&&void 0!==r?r:null;return o&&(we.current=!0,Ge()),o},updateEdge:(t,e,n)=>{var r,o;const i=null!==(o=null===(r=_e.current)||void 0===r?void 0:r.updateEdge(t,e,n))&&void 0!==o?o:[];return i.length>0&&(Ve(),we.current=!0,Ge()),i},clear:Ke,getTopology:()=>{var t,e;return null!==(e=null===(t=_e.current)||void 0===t?void 0:t.getLayoutData())&&void 0!==e?e:{nodes:[],edges:[]}},getTopologyDiff:()=>{const t=_e.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:Ze,getTension:()=>{var t,e;return null!==(e=null===(t=_e.current)||void 0===t?void 0:t.tension)&&void 0!==e?e:0}}),[qe,Ue,Ke,Ze,Ve,Ge]);const Qe=["tree","cluster","treemap","circlepack","partition","orbit"].includes(x),Je=Qe?w||(Array.isArray(k)?void 0:k):void 0;t.useEffect(()=>{var t;const e=_e.current;if(e)if(Qe&&Je)e.ingestHierarchy(Je,[le,ae]),e.buildScene([le,ae]),we.current=!0,Ge();else{const n=b||[],r=Array.isArray(k)?k:[];if(0===n.length&&0===r.length)return;e.ingestBounded(n,r,[le,ae]),e.buildScene([le,ae]);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:_,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,we.current=!0,Ge()}},[b,k,w,Je,Qe,le,ae,me,Ge,Z]),t.useEffect(()=>{E&&E.length>0&&Ue(E)},[]);const tn=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(!vt)return;const e=xe.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-ie.left,o=t.clientY-n.top-ie.top;if(0>r||r>le||0>o||o>ae)return void(Re.current&&(Re.current=null,De(null),tn&&(tn(null),we.current=!0),Ge()));const i=_e.current;if(!i)return;const l=kr(i.sceneNodes,i.sceneEdges,r,o);if(!l)return void(Re.current&&(Re.current=null,De(null),tn&&(tn(null),we.current=!0),Ge()));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,De(s),tn&&(tn(s),we.current=!0),Ge()},ln.current=()=>{Re.current&&(Re.current=null,De(null),tn&&(tn(null),we.current=!0),Ge())};const an=t.useRef(()=>{});an.current=t=>{if(!bt&&!kt)return;const e=xe.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-ie.left,o=t.clientY-n.top-ie.top;if(0>r||r>le||0>o||o>ae)return;const i=_e.current;if(!i)return;const l=kr(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),dn=t.useRef(null),hn=t.useRef(-1),fn=t.useCallback(t=>{var e;const n=_e.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=at(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,hn.current=-1;const e=o.flat[0];dn.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,De(r),tn&&(tn(r),we.current=!0),void Ge()}const l=st(o,i),a=function(t,e,n,r,o){var i,l,a;const s=n.flat[e.flatIndex];if(!s)return ct(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=ct(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:[],hn);if(null===a)return;if(t.preventDefault(),0>a)return un.current=-1,dn.current=null,hn.current=-1,Re.current=null,De(null),tn&&(tn(null),we.current=!0),void Ge();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});Re.current=u,De(u),tn&&(tn(u),we.current=!0),Ge()},[tn,Ge]),yn=t.useCallback(t=>{un.current=-1,dn.current=null,on.current(t)},[]);Pe.current=()=>{var t,e,n,r,o,i,l;be.current=0;const a=xe.current;if(!a)return;const s=a.getContext("2d");if(!s)return;const c=_e.current;if(!c)return;const u=performance.now(),d=ke.current?Math.min((u-ke.current)/1e3,.1):.016;ke.current=u;const h=c.advanceTransition(Jt.current?u+1e6:u),f=!Jt.current&&h,y=!Jt.current&&c.tickAnimation([le,ae],d);(h||we.current||y)&&c.buildScene([le,ae]);const g=Se();if(!Me(a,oe,ie,g))return;s.clearRect(-ie.left,-ie.top,oe[0],oe[1]),pt&&(s.fillStyle=pt,s.fillRect(0,0,le,ae)),$t&&c.applyDecay(),It&&c.applyPulse(u),zt&&c.applyThresholds(u),c.applyTopologyDiff(u);const p=null!==(t=null==Wt?void 0:Wt.threshold)&&void 0!==t?t:5e3,v=Wt&&c.lastIngestTime>0&&u-c.lastIngestTime>p;if(v&&(s.globalAlpha=null!==(e=null==Wt?void 0:Wt.dimOpacity)&&void 0!==e?e:.5),function(t,e){for(const n of e)switch(n.type){case"bezier":_r(t,n);break;case"line":Cr(t,n);break;case"ribbon":Dr(t,n);break;case"curved":Lr(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)),$e(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()),Ie(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&&!v){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:nn.spawnRate,a=null!==(i=r.maxPerEdge)&&void 0!==i?i:nn.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,d,ye);const e=.5*(null!==(n=ye.speedMultiplier)&&void 0!==n?n:1);let r;if(ye.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(d,e,t,r),function(t,e,n,r,o){var i,l;const a=null!==(i=r.radius)&&void 0!==i?i:nn.radius,s=null!==(l=r.opacity)&&void 0!==l?l:nn.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,ye,He)}}v&&(s.globalAlpha=1);const m=we.current;if(we.current=!1,m||f||y){const t=xe.current;t&&t.setAttribute("aria-label",te(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"))}(m||f||y)&&Oe(t=>t+1),(Xe||f||y||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff)&&(be.current=requestAnimationFrame(()=>Pe.current()))},t.useEffect(()=>(Ge(),()=>{be.current&&(cancelAnimationFrame(be.current),be.current=0)}),[Ge]),t.useEffect(()=>{we.current=!0,Ge()},[x,le,ae,pt,Ge]),ft(Wt,_e,we,Ge,We,ze);const gn=vt&&Ce?g.createElement(pe,{x:Ce.x,y:Ce.y,containerWidth:le,containerHeight:ae,margin:ie,className:"stream-network-tooltip",zIndex:2},mt?mt(Ce):g.createElement(Wr,{data:Ce})):null;if(Ut){const t=_e.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,[le,ae]),t.buildScene([le,ae]);else{const e=b||[],n=Array.isArray(k)?k:[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[le,ae]),t.buildScene([le,ae]))}}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:oe[0],height:oe[1]}},g.createElement(de,{summary:jt}),g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:oe[0],height:oe[1],style:{position:"absolute",left:0,top:0}},Ot&&g.createElement("g",{transform:`translate(${ie.left},${ie.top})`},Ot),g.createElement("g",{transform:`translate(${ie.left},${ie.top})`},pt&&g.createElement("rect",{x:0,y:0,width:le,height:ae,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:qt(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:qt(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:qt(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:qt(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:qt(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:qt(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(Pr,{width:le,height:ae,totalWidth:oe[0],totalHeight:oe[1],margin:ie,labels:r,sceneNodes:e,title:Tt,legend:St,legendPosition:Pt,legendHoverBehavior:_t,legendClickBehavior:Ct,legendHighlightedCategory:Dt,legendIsolatedCategories:Lt,foregroundGraphics:se,annotations:At,svgAnnotationRules:Mt,annotationFrame:0}))}const pn=_e.current;return g.createElement("div",{ref:re,className:"stream-network-frame"+(gt?" "+gt:""),role:"group","aria-label":Bt||("string"==typeof Tt?Tt:"Network chart"),tabIndex:0,style:{position:"relative",width:ut?"100%":oe[0],height:dt?"100%":oe[1],overflow:"visible"},onKeyDown:fn},Rt&&g.createElement(he,{tableId:ee}),Rt&&g.createElement(ue,{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(de,{summary:jt}),g.createElement("div",{role:"img","aria-label":Bt||("string"==typeof Tt?Tt:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:vt?yn:void 0,onMouseLeave:vt?sn:void 0,onClick:bt||kt?cn:void 0},Ot&&g.createElement("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:oe[0],height:oe[1],pointerEvents:"none",overflow:"visible"}},g.createElement("g",{transform:`translate(${ie.left},${ie.top})`},Ot)),g.createElement("canvas",{ref:xe,"aria-label":te(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(fe,{hoverPoint:Ce}),g.createElement(Pr,{width:le,height:ae,totalWidth:oe[0],totalHeight:oe[1],margin:ie,labels:(null==pn?void 0:pn.labels)||[],sceneNodes:null==pn?void 0:pn.sceneNodes,title:Tt,legend:St,legendPosition:Pt,legendHoverBehavior:_t,legendClickBehavior:Ct,legendHighlightedCategory:Dt,legendIsolatedCategories:Lt,foregroundGraphics:se,annotations:At,svgAnnotationRules:Mt,annotationFrame:Ne}),g.createElement(ge,{active:un.current>=0,hoverPoint:Ce,margin:ie,size:oe,shape:null===(p=dn.current)||void 0===p?void 0:p.shape,width:null===(v=dn.current)||void 0===v?void 0:v.w,height:null===(m=dn.current)||void 0===m?void 0:m.h}),gn,(null==Wt?void 0:Wt.showBadge)&&g.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Wt.badgePosition?{top:4,left:4}:"bottom-left"===Wt.badgePosition?{bottom:4,left:4}:"bottom-right"===Wt.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:We?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},We?"STALE":"LIVE")))});function Rr(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 Br(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}zr.displayName="StreamNetworkFrame";const[jr,Fr]=me(t=>({selections:new Map,setClause(e,n){t(t=>{const r=new Map(t.selections),o=Br(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=Br(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}})}})),[Yr,Hr]=me(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 Xr(e){const n=t.useId(),r=e.clientId||n,{name:o}=e,i=Fr(t=>t.selections.get(o)),l=Fr(t=>t.setClause),a=Fr(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(Rr(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 Gr({selection:e,linkedHover:n,fallbackFields:r=[],unwrapData:o=!1,onObservation:i,chartType:l,chartId:a,onClick:s,hoverHighlight:c,colorByField:u}){const d=t.useId(),h=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),f=Xr({name:(null==e?void 0:e.name)||"__unused__"}),y=function(e){const n=e.name||"hover",{fields:r}=e,{predicate:o,isActive:i,selectPoints:l,clear:a}=Xr({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==h?void 0:h.name)||"hover",fields:(null==h?void 0:h.fields)||r||[]}),g=Hr(t=>t.pushObservation),p=e?{isActive:f.isActive,predicate:f.predicate}:null,[v,m]=t.useState(null),x=u||r[0],b=t.useMemo(()=>{if(!c||null==v||!x)return null;const t=v,e=x;return{isActive:!0,predicate:n=>{var r;return("string"==typeof n[e]?n[e]:(null!==(r=n[e])&&void 0!==r?r:"")+"")===t}}},[c,v,x]),k=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==h?void 0:h.mode)&&h.xField){const t=null==e?void 0:e[h.xField];null!=t&&Number.isFinite(Number(t))&&function(t,e,n){const r=Tt.positions.get(t);(null==r?void 0:r.locked)||r&&r.xValue===e&&r.sourceId===n||(Tt={positions:new Map(Tt.positions).set(t,{xValue:e,sourceId:n})},Ot())}(h.name||"hover",Number(t),d)}"x-position"!==(null==h?void 0:h.mode)&&y.onHover(e)}else"x-position"===(null==h?void 0:h.mode)&&$t(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&y.onHover(null);if(c&&x)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=null==e?void 0:e[x];m(null!=n?n+"":null)}else m(null);if(i||g){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),g&&g(l)}else{const t=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(t),g&&g(t)}}},[n,y,h,d,i,l,a,g,c,x]),w=t.useCallback(t=>{var e,n,r,o;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=null==e?void 0:e[h.xField];null!=n&&Number.isFinite(Number(n))&&function(t,e,n){const r=Tt.positions.get(t);if(null==r?void 0:r.locked){const e=new Map(Tt.positions);return e.delete(t),Tt={positions:e},Ot(),!1}Tt={positions:new Map(Tt.positions).set(t,{xValue:e,sourceId:n,locked:!0})},Ot()}(h.name||"hover",Number(n),d)}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||g){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),g&&g(l)}else{const t=Object.assign(Object.assign({},e),{type:"click-end"});i&&i(t),g&&g(t)}}},[s,i,g,l,a,h,d]);return t.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const t=h.name||"hover";return()=>{It(t,d),$t(t,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 Vr={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 qr(t,e,n){var r,o,i,l,a,s,c;const u=Vr[t||"primary"],d="context"===t||"sparkline"===t;return{width:null!==(r=e.width)&&void 0!==r?r:u.width,height:null!==(o=e.height)&&void 0!==o?o:u.height,showAxes:null!==(i=e.showAxes)&&void 0!==i?i:u.showAxes,showGrid:null!==(l=e.showGrid)&&void 0!==l?l:u.showGrid,enableHover:null!==(a=e.enableHover)&&void 0!==a?a:!!e.linkedHover||u.enableHover,showLegend:null!==(s=e.showLegend)&&void 0!==s?s:u.showLegend,showLabels:null!==(c=e.showLabels)&&void 0!==c?c:u.showLabels,title:d?void 0:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:d?void 0:e.xLabel,yLabel:d?void 0:e.yLabel,categoryLabel:d?void 0:e.categoryLabel,valueLabel:d?void 0:e.valueLabel,marginDefaults:Ur(u.marginDefaults,e.showCategoryTicks,e.orientation)}}function Ur(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 Kr={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"},Zr={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Qr(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({},Kr),{width:e,height:n})},r||"No data available"):null}function Jr(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({},Zr),{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 to=t.forwardRef(function(e,n){var r,o,i,l;const a=qr(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:d="right",windowMode:h="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:v,timeExtent:m,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:I,selection:W,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,U=t.useRef(null),{customHoverBehavior:K}=Gr({selection:W,linkedHover:I,unwrapData:!0,onObservation:z,chartType:"RealtimeLineChart",chartId:R}),Z=t.useCallback(t=>{P&&P(t),K(t)},[P,K]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=U.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,r;return null!==(r=null===(n=U.current)||void 0===n?void 0:n.update(t,e))&&void 0!==r?r:[]},clear:()=>{var t;return null===(t=U.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=U.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Q=Jr(B,V[0],V[1]),J=Q?null:Qr(y,V[0],V[1],j),tt={stroke:k,strokeWidth:w,strokeDasharray:E};return Q||J||g.createElement(tn,{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:v,xExtent:m,yExtent:x,extentPadding:b,lineStyle:tt,showAxes:H,background:A,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:Z,annotations:_,svgAnnotationRules:C,tickFormatTime:D,tickFormatValue:L,decay:T,pulse:N,staleness:O,transition:$,pointIdAccessor:e.pointIdAccessor,legendPosition:Y})});to.displayName="RealtimeLineChart";const eo=t.forwardRef(function(e,n){var r,o,i,l;const a=qr(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:d,arrowOfTime:h="right",windowMode:f="sliding",windowSize:y=200,data:p,timeAccessor:v,valueAccessor:m,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:I,selection:W,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}=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}=Gr({selection:W,linkedHover:I,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=K)?"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}=Xr({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 v?v:"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(U&&U(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)}},[U,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)},remove:t=>{var e,n;return null!==(n=null===(e=nt.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,r;return null!==(r=null===(n=nt.current)||void 0===n?void 0:n.update(t,e))&&void 0!==r?r:[]},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 dt=Jr(H,tt[0],tt[1]),ht=dt?null:Qr(p,tt[0],tt[1],X),ft={};return null!=A&&(ft.fill=A),null!=M&&(ft.stroke=M),null!=S&&(ft.strokeWidth=S),null!=P&&(ft.gap=P),dt||ht||g.createElement(tn,{ref:nt,chartType:"bar",runtimeMode:"streaming",size:tt,margin:J,className:G?`${d||""} semiotic-emphasis-${G}`.trim():d,arrowOfTime:h,windowMode:f,windowSize:y,data:p,timeAccessor:v,valueAccessor:m,xExtent:x,yExtent:b,extentPadding:k,binSize:s,categoryAccessor:w,barColors:E,barStyle:ft,showAxes:Z,background:_,hoverAnnotation:Q,tooltipContent:et,customHoverBehavior:ot,annotations:T,svgAnnotationRules:N,tickFormatTime:O,tickFormatValue:$,decay:z,pulse:R,staleness:B,transition:j,pointIdAccessor:e.pointIdAccessor,legendPosition:V,brush:it||(K?{dimension:"x"}:void 0),onBrush:it||K?ut:void 0})});eo.displayName="RealtimeTemporalHistogram";const no=eo,ro=t.forwardRef(function(e,n){var r,o,i,l;const a=qr(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:d="right",windowMode:h="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:v,timeExtent:m,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:I,selection:W,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,U=t.useRef(null),{customHoverBehavior:K}=Gr({selection:W,linkedHover:I,unwrapData:!0,onObservation:z,chartType:"RealtimeSwarmChart",chartId:R}),Z=t.useCallback(t=>{L&&L(t),K(t)},[L,K]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=U.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,r;return null!==(r=null===(n=U.current)||void 0===n?void 0:n.update(t,e))&&void 0!==r?r:[]},clear:()=>{var t;return null===(t=U.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=U.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Q=Jr(B,V[0],V[1]),J=Q?null:Qr(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!=P&&(tt.strokeWidth=P),Q||J||g.createElement(tn,{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:v,xExtent:m,yExtent:x,extentPadding:b,categoryAccessor:k,barColors:w,swarmStyle:tt,showAxes:H,background:_,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:Z,annotations:T,svgAnnotationRules:N,tickFormatTime:O,tickFormatValue:$,legendPosition:Y,pointIdAccessor:e.pointIdAccessor})});ro.displayName="RealtimeSwarmChart";const oo=t.forwardRef(function(e,n){var r,o,i,l;const a=qr(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:d="right",windowMode:h="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:v,timeExtent:m,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:I,selection:W,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,U=t.useRef(null),{customHoverBehavior:K}=Gr({selection:W,linkedHover:I,unwrapData:!0,onObservation:z,chartType:"RealtimeWaterfallChart",chartId:R}),Z=t.useCallback(t=>{L&&L(t),K(t)},[L,K]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=U.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,r;return null!==(r=null===(n=U.current)||void 0===n?void 0:n.update(t,e))&&void 0!==r?r:[]},clear:()=>{var t;return null===(t=U.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=U.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Q=Jr(B,V[0],V[1]),J=Q?null:Qr(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!=P&&(tt.strokeWidth=P),Q||J||g.createElement(tn,{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:v,xExtent:m,yExtent:x,extentPadding:b,waterfallStyle:tt,showAxes:H,background:_,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:Z,annotations:T,svgAnnotationRules:N,tickFormatTime:O,tickFormatValue:$,legendPosition:Y,pointIdAccessor:e.pointIdAccessor})});oo.displayName="RealtimeWaterfallChart";const io=t.forwardRef(function(e,n){var r,o,i,l;const a=qr(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:d="right",windowMode:h="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:v,categoryAccessor:m,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:I,selection:W,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:P,U=t.useRef(null),{customHoverBehavior:K}=Gr({selection:W,linkedHover:I,unwrapData:!0,onObservation:z,chartType:"RealtimeHeatmap",chartId:R}),Z=t.useCallback(t=>{_&&_(t),K(t)},[_,K]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=U.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,r;return null!==(r=null===(n=U.current)||void 0===n?void 0:n.update(t,e))&&void 0!==r?r:[]},clear:()=>{var t;return null===(t=U.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=U.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Q=Jr(B,V[0],V[1]),J=Q?null:Qr(y,V[0],V[1],j);return Q||J||g.createElement(tn,{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:v,categoryAccessor:m,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,pointIdAccessor:e.pointIdAccessor})});io.displayName="RealtimeHeatmap",exports.IncrementalExtent=w,exports.RealtimeHeatmap=io,exports.RealtimeHistogram=no,exports.RealtimeLineChart=to,exports.RealtimeSwarmChart=ro,exports.RealtimeWaterfallChart=oo,exports.RingBuffer=k,exports.StreamNetworkFrame=zr,exports.StreamXYFrame=tn;