semiotic 3.2.0 → 3.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +50 -8
- package/README.md +11 -11
- package/ai/dist/mcp-server.js +31925 -528
- package/ai/examples.md +91 -0
- package/ai/schema.json +235 -9
- package/ai/system-prompt.md +12 -4
- package/dist/components/ChartContainer.d.ts +2 -0
- package/dist/components/DataSummaryContext.d.ts +12 -0
- package/dist/components/Tooltip/FlippingTooltip.d.ts +34 -0
- package/dist/components/charts/index.d.ts +4 -0
- package/dist/components/charts/ordinal/BarChart.d.ts +3 -1
- package/dist/components/charts/ordinal/BoxPlot.d.ts +3 -1
- package/dist/components/charts/ordinal/DonutChart.d.ts +0 -1
- package/dist/components/charts/ordinal/DotPlot.d.ts +3 -1
- package/dist/components/charts/ordinal/FunnelChart.d.ts +3 -1
- package/dist/components/charts/ordinal/GroupedBarChart.d.ts +3 -1
- package/dist/components/charts/ordinal/Histogram.d.ts +16 -2
- package/dist/components/charts/ordinal/LikertChart.d.ts +94 -0
- package/dist/components/charts/ordinal/PieChart.d.ts +0 -1
- package/dist/components/charts/ordinal/RidgelinePlot.d.ts +11 -7
- package/dist/components/charts/ordinal/StackedBarChart.d.ts +3 -1
- package/dist/components/charts/ordinal/SwarmPlot.d.ts +14 -1
- package/dist/components/charts/ordinal/SwimlaneChart.d.ts +65 -0
- package/dist/components/charts/ordinal/ViolinPlot.d.ts +16 -2
- package/dist/components/charts/realtime/RealtimeHistogram.d.ts +20 -0
- package/dist/components/charts/shared/annotationResolvers.d.ts +28 -0
- package/dist/components/charts/shared/hooks.d.ts +23 -2
- package/dist/components/charts/shared/selectionUtils.d.ts +5 -1
- package/dist/components/charts/shared/statsTooltip.d.ts +11 -0
- package/dist/components/charts/shared/types.d.ts +22 -1
- package/dist/components/charts/shared/useChartSetup.d.ts +12 -2
- package/dist/components/charts/shared/useLikertAggregation.d.ts +51 -0
- package/dist/components/charts/shared/useOrdinalBrush.d.ts +28 -0
- package/dist/components/charts/shared/useOrdinalStreaming.d.ts +54 -0
- package/dist/components/charts/shared/useStreamingLegend.d.ts +2 -2
- package/dist/components/charts/shared/validateProps.d.ts +2 -2
- package/dist/components/charts/shared/validationMap.d.ts +12 -0
- package/dist/components/charts/xy/AreaChart.d.ts +11 -0
- package/dist/components/charts/xy/MinimapChart.d.ts +1 -1
- package/dist/components/charts/xy/StackedAreaChart.d.ts +11 -0
- package/dist/components/realtime/types.d.ts +4 -0
- package/dist/components/semiotic-ai.d.ts +1 -0
- package/dist/components/semiotic-ordinal.d.ts +2 -0
- package/dist/components/semiotic-themes.d.ts +16 -0
- package/dist/components/semiotic-utils.d.ts +30 -0
- package/dist/components/semiotic.d.ts +4 -4
- package/dist/components/store/LinkedCrosshairStore.d.ts +11 -0
- package/dist/components/store/useSelection.d.ts +1 -0
- package/dist/components/stream/AccessibleDataTable.d.ts +28 -6
- package/dist/components/stream/FocusRing.d.ts +33 -0
- package/dist/components/stream/OrdinalBrushOverlay.d.ts +43 -0
- package/dist/components/stream/OrdinalPipelineStore.d.ts +16 -0
- package/dist/components/stream/OrdinalSVGOverlay.d.ts +1 -1
- package/dist/components/stream/PipelineStore.d.ts +5 -47
- package/dist/components/stream/SVGOverlay.d.ts +4 -0
- package/dist/components/stream/SceneGraph.d.ts +6 -1
- package/dist/components/stream/XYBrushOverlay.d.ts +47 -0
- package/dist/components/stream/devDataAccessWarning.d.ts +13 -0
- package/dist/components/stream/geoTypes.d.ts +5 -1
- package/dist/components/stream/keyboardNav.d.ts +85 -9
- package/dist/components/stream/layouts/hierarchySceneBuilders.d.ts +35 -0
- package/dist/components/stream/layouts/hierarchyUtils.d.ts +25 -0
- package/dist/components/stream/networkTypes.d.ts +5 -1
- package/dist/components/stream/ordinalSceneBuilders/swimlaneScene.d.ts +12 -0
- package/dist/components/stream/ordinalTypes.d.ts +15 -3
- package/dist/components/stream/pipelineDecay.d.ts +20 -0
- package/dist/components/stream/pipelinePulse.d.ts +24 -0
- package/dist/components/stream/pipelineTransitions.d.ts +59 -0
- package/dist/components/stream/renderers/pointCanvasRenderer.d.ts +2 -1
- package/dist/components/stream/types.d.ts +19 -1
- package/dist/components/stream/useMediaPreferences.d.ts +11 -0
- package/dist/components/stream/xySceneBuilders/areaScene.d.ts +13 -0
- package/dist/components/stream/xySceneBuilders/barScene.d.ts +18 -0
- package/dist/components/stream/xySceneBuilders/boundsScene.d.ts +8 -0
- package/dist/components/stream/xySceneBuilders/candlestickScene.d.ts +10 -0
- package/dist/components/stream/xySceneBuilders/emitPointNodes.d.ts +13 -0
- package/dist/components/stream/xySceneBuilders/heatmapScene.d.ts +3 -0
- package/dist/components/stream/xySceneBuilders/lineScene.d.ts +12 -0
- package/dist/components/stream/xySceneBuilders/pointScene.d.ts +12 -0
- package/dist/components/stream/xySceneBuilders/swarmScene.d.ts +10 -0
- package/dist/components/stream/xySceneBuilders/types.d.ts +93 -0
- package/dist/components/stream/xySceneBuilders/waterfallScene.d.ts +12 -0
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai.d.ts +1 -0
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-ordinal.d.ts +2 -0
- package/dist/{semiotic-statisticalOverlays-D8LhSbQt.js → semiotic-statisticalOverlays-DGX_WWc5.js} +1 -1
- package/dist/semiotic-themes.d.ts +16 -0
- package/dist/semiotic-themes.min.js +1 -1
- package/dist/semiotic-themes.module.min.js +1 -1
- package/dist/semiotic-utils.d.ts +30 -0
- package/dist/semiotic-utils.min.js +1 -0
- package/dist/semiotic-utils.module.min.js +1 -0
- package/dist/semiotic.d.ts +4 -4
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +19 -11
package/dist/realtime.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const t=require("react"),e=require("d3-brush"),n=require("d3-selection"),i=require("d3-scale"),r=require("d3-scale-chromatic"),o=require("d3-quadtree"),a=require("d3-array"),l=require("d3-hierarchy"),s=require("d3-shape"),c=require("regression"),u=require("d3-interpolate"),h=require("d3-force"),d=require("d3-chord");function f(t){return t&&t.__esModule?t:{default:t}}function y(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const n in t)if("default"!==n){const i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}return e.default=t,Object.freeze(e)}const g=y(t),p=f(c);class m{constructor(t,e){var n,i;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!==(i=null==e?void 0:e.chunkSize)&&void 0!==i?i: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 i=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,i),bounded:!1}),e=i,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 v{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 x{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 b(t,e,n,i,r){const o=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/i)*i;let c=o.get(s);if(c||(c={start:s,end:s+i,total:0,categories:new Map},o.set(s,c)),c.total+=l,r){const t=r(a);c.categories.set(t,(c.categories.get(t)||0)+l)}}return o}function k(t,e,n,i,r,o){const a=[];for(const r of t){const t=n(r),o=i(r);null==t||null==o||Number.isNaN(t)||Number.isNaN(o)||a.push({px:e.x(t),py:e.y(o),rawY:o,d:r})}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:r,datum:c,group:o}}function w(t,e,n,i,r,o,a,l){const s=[];for(const o of t){const t=n(o),a=i(o);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const c=e.x(t),u=l?l(o):r;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:o,datum:t,group:a}}function E(t,e,n,i,r,o,a){const l=n(t),s=i(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:r,style:o,datum:t};return void 0!==a&&(c.pointId=a),c}function A(t,e,n,i,r,o,a){return{type:"rect",x:t,y:e,w:n,h:i,style:r,datum:o,group:a}}function M(t,e,n,i,r,o,a){const l={type:"heatcell",x:t,y:e,w:n,h:i,fill:r,datum:o};return(null==a?void 0:a.showValues)&&(l.showValues=!0,l.value=a.value,a.valueFormat&&(l.valueFormat=a.valueFormat)),l}function S(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function P(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function _(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function C(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}const L=r.schemeCategory10,D=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function T(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function $(t,e){return Math.min((t-e.startTime)/e.duration,1)}function W(t,e,n){return t+(e-t)*n}class O{constructor(t){this.xExtent=new x,this.yExtent=new x,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.xIsDate=!1,this._quadtree=null,this.config=t,this.buffer=new v(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=P(t.timeAccessor||t.xAccessor,"time"),this.getY=P(t.valueAccessor||t.yAccessor,"value")):(this.getX=P(t.xAccessor,"x"),this.getY=P(t.yAccessor,"y")),this.getGroup=C(t.groupAccessor),this.getCategory=C(t.categoryAccessor),this.getSize=t.sizeAccessor?P(t.sizeAccessor,"size"):void 0,this.getColor=C(t.colorAccessor),this.getBounds=t.boundsAccessor?P(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?P(t.y0Accessor,"y0"):void 0,this.getPointId=C(t.pointIdAccessor),"candlestick"===t.chartType&&(this.getOpen=P(t.openAccessor,"open"),this.getHigh=P(t.highAccessor,"high"),this.getLow=P(t.lowAccessor,"low"),this.getClose=P(t.closeAccessor,"close")),t.pulse&&(this.timestampBuffer=new v(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?P(this.config.timeAccessor||this.config.xAccessor,"time"):P(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],n=this.config.xAccessor,i="function"==typeof n?n(e):e[n||"x"],r=i instanceof Date,o="string"==typeof i&&i.length>=10&&!isNaN(new Date(i).getTime())&&isNaN(Number(i));if(this.xIsDate=r||o,o){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,r,o,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(),h=this.xExtent.extent,d=this.yExtent.extent;let f=s.xExtent?[null!==(e=s.xExtent[0])&&void 0!==e?e:h[0],null!==(n=s.xExtent[1])&&void 0!==n?n:h[1]]:h,y=s.yExtent?[null!==(r=s.yExtent[0])&&void 0!==r?r:d[0],null!==(o=s.yExtent[1])&&void 0!==o?o:d[1]]:d;const g=s.yExtent&&null!=s.yExtent[0]&&null!=s.yExtent[1];if("stackedarea"===s.chartType&&!g&&c.size>0)if(s.normalize)y=[0,1+s.extentPadding];else{const t=`${c.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)y=this._stackExtentCache.yDomain;else{const e=this.groupData(u),n=new Map;for(const t of e)for(const e of t.data){const t=this.getX(e),i=this.getY(e);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||n.set(t,(n.get(t)||0)+i)}let i=0;for(const t of n.values())t>i&&(i=t);y=[0,i+(i>0?i*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,i,r){const o=b(t,e,n,i,r);if(0===o.size)return[0,0];let a=0;for(const t of o.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,i=0,r=0;for(const o of t){const t=e(o);null==t||Number.isNaN(t)||(r+=t,n>r&&(n=r),r>i&&(i=r))}return[n,i]}(c,this.getY),n=e-t,i=n>0?n*s.extentPadding:1;y=[Math.min(0,t-Math.abs(i)),Math.max(0,e+Math.abs(i))]}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],i=null===(l=s.yExtent)||void 0===l?void 0:l[1];y=[null!=n?y[0]:y[0]-e,null!=i?y[1]:y[1]+e],"log"===s.yScaleType&&0>=y[0]&&d[0]>0&&(y[0]=null!=n?y[0]:d[0]/(1+s.extentPadding))}if(f[0]!==1/0&&f[1]!==-1/0||(f=[0,1]),y[0]!==1/0&&y[1]!==-1/0||(y=[0,1]),"streaming"===s.runtimeMode)if("x"==("up"===(p=s.arrowOfTime)||"down"===p?"y":"x")){const e="right"===s.arrowOfTime?[0,t.width]:[t.width,0];this.scales={x:i.scaleLinear().domain(f).range(e),y:i.scaleLinear().domain(y).range([t.height,0])}}else{const e="down"===s.arrowOfTime?[0,t.height]:[t.height,0];this.scales={x:i.scaleLinear().domain(y).range([0,t.width]),y:i.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 i.scaleLog().domain(t).range(n).clamp(!0)}return i.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>O.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 i of t.path)i[0]*=e,i[1]*=n;break;case"area":for(const i of t.topPath)i[0]*=e,i[1]*=n;for(const i of t.bottomPath)i[0]*=e,i[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 r=this.scales.x.domain(),o=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 i.scaleLog().domain(t).range(n).clamp(!0)}return i.scaleLinear().domain(e).range(n)};this.scales={x:s(this.config.xScaleType,r,[a[0]*e,a[1]*e]),y:s(this.config.yScaleType,o,[l[0]*n,l[1]*n])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){const{config:n,scales:i}=this;if(!i||0===e.length)return[];switch(n.chartType){case"line":return this.buildLineScene(e);case"area":return this.buildAreaScene(e);case"stackedarea":return this.buildStackedAreaScene(e);case"scatter":case"bubble":return this.buildPointScene(e);case"heatmap":return this.buildHeatmapScene(e,t);case"bar":return this.buildBarScene(e);case"swarm":return this.buildSwarmScene(e);case"waterfall":return this.buildWaterfallScene(e,t);case"candlestick":return this.buildCandlestickScene(e,t);default:return[]}}buildLineScene(t){var e;const n=this.groupData(t),i=[],r=null===(e=this.config.annotations)||void 0===e?void 0:e.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(this.getBounds)for(const t of n){const e=this.buildBoundsForGroup(t.data,t.key);e&&i.push(e)}for(const t of n){const e=this.resolveLineStyle(t.key,t.data[0]),n=k(t.data,this.scales,this.getX,this.getY,e,t.key);r&&r.length>0&&(n.colorThresholds=r),this.config.curve&&"linear"!==this.config.curve&&(n.curve=this.config.curve),i.push(n)}return i}buildAreaScene(t){const e=this.groupData(t),n=[],i=this.scales.y.domain()[0];for(const t of e){const e=this.resolveAreaStyle(t.key,t.data[0]),r=w(t.data,this.scales,this.getX,this.getY,i,e,t.key,this.getY0);this.config.gradientFill&&(r.fillGradient=this.config.gradientFill),this.config.curve&&"linear"!==this.config.curve&&(r.curve=this.config.curve),n.push(r)}return n}buildStackedAreaScene(t){const e=this.groupData(t);return e.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0),function(t,e,n,i,r,o,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 r of e.data){const e=n(r),o=i(r);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||t.set(e,(t.get(e)||0)+o)}u.set(e.key,t)}let h;if(o){h=new Map;for(const e of c){let n=0;for(const i of t)n+=(null===(l=u.get(i.key))||void 0===l?void 0:l.get(e))||0;h.set(e,n||1)}}const d=[],f=new Map;for(const t of c)f.set(t,0);for(const n of t){const t=u.get(n.key),i=[],l=[];for(const n of c){let r=t.get(n)||0;const a=f.get(n);o&&(r/=h.get(n));const s=e.x(n);l.push([s,e.y(a)]),i.push([s,e.y(a+r)]),f.set(n,a+r)}const s={type:"area",topPath:i,bottomPath:l,style:r(n.key,n.data[0]),datum:n.data,group:n.key};a&&(s.curve=a),d.push(s)}return d}(e,this.scales,this.getX,this.getY,(t,e)=>this.resolveAreaStyle(t,e),this.config.normalize,this.config.curve&&"linear"!==this.config.curve?this.config.curve:void 0)}buildPointScene(t){const e=[],n="bubble"===this.config.chartType?10:5,i=this.config.sizeRange||[3,15];let r=null;if(this.getSize&&!this.config.pointStyle){const e=t.map(t=>this.getSize(t)).filter(t=>null!=t&&!Number.isNaN(t));if(e.length>0){let t=1/0,n=-1/0;for(const i of e)t>i&&(t=i),i>n&&(n=i);r=e=>t===n?(i[0]+i[1])/2:i[0]+(e-t)/(n-t)*(i[1]-i[0])}}const o=this.getColor?this.resolveColorMap(t):null;for(const i of t){let t=this.config.pointStyle?this.config.pointStyle(i):{fill:"#4e79a7",opacity:.8},a=t.r||n;if(r&&this.getSize){const t=this.getSize(i);null==t||Number.isNaN(t)||(a=r(t))}if(o&&this.getColor&&!t.fill){const e=this.getColor(i);e&&o.has(e)&&(t=Object.assign(Object.assign({},t),{fill:o.get(e)}))}const l=this.getPointId?this.getPointId(i)+"":void 0,s=E(i,this.scales,this.getX,this.getY,a,t,l);s&&e.push(s)}return e}buildHeatmapScene(t,e){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(t,e);const o=P(this.config.valueAccessor,"value"),a=_(this.config.xAccessor,"x"),l=_(this.config.yAccessor,"y"),s=new Set,c=new Set;for(const e of t)s.add(a(e)),c.add(l(e));const u=Array.from(s),h=Array.from(c),d=u.every(t=>"number"==typeof t&&!isNaN(t)),f=h.every(t=>"number"==typeof t&&!isNaN(t)),y=d?u.sort((t,e)=>t-e):u,g=f?h.sort((t,e)=>t-e):h;if(0===y.length||0===g.length)return n;const p=e.width/y.length,m=e.height/g.length,v=new Map;for(const e of t){const t=`${a(e)}\0${l(e)}`;v.set(t,{val:o(e),datum:e})}let x=1/0,b=-1/0;for(const{val:t}of v.values())x>t&&(x=t),t>b&&(b=t);const k=i.scaleSequential({blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,viridis:r.interpolateViridis}["string"==typeof this.config.colorScheme?this.config.colorScheme:"blues"]||r.interpolateBlues).domain([x,b]);for(let t=0;y.length>t;t++)for(let e=0;g.length>e;e++){const i=v.get(`${y[t]}\0${g[e]}`);if(!i)continue;const r=k(i.val);n.push(M(t*p,(g.length-1-e)*m,p,m,r,i.datum,this.config.showValues?{value:i.val,showValues:!0,valueFormat:this.config.heatmapValueFormat}:void 0))}return n}buildStreamingHeatmapScene(t,e){var n,i,r;const o=[],a=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,l=null!==(i=this.config.heatmapYBins)&&void 0!==i?i:20,s=null!==(r=this.config.heatmapAggregation)&&void 0!==r?r:"count",c=P(this.config.valueAccessor,"value");if(!this.scales||0===t.length)return o;const[u,h]=this.scales.x.domain(),[d,f]=this.scales.y.domain(),y=(h-u||1)/a,g=(f-d||1)/l,p=new Map;for(const e of t){const t=this.getX(e),n=this.getY(e),i=Math.min(Math.floor((t-u)/y),a-1),r=Math.min(Math.floor((n-d)/g),l-1);if(0>i||0>r)continue;const o=`${i}_${r}`;let s=p.get(o);s||(s={sum:0,count:0,data:[]},p.set(o,s)),s.count++,s.sum+=c(e),s.data.push(e)}let m=1/0,v=-1/0;const x=new Map;for(const[t,e]of p){let n;switch(s){case"sum":n=e.sum;break;case"mean":n=e.count>0?e.sum/e.count:0;break;default:n=e.count}x.set(t,n),m>n&&(m=n),n>v&&(v=n)}const b=v-m||1,k=e.width/a,w=e.height/l;for(const[t,e]of x){const[n,i]=t.split("_"),r=+n,a=+i,s=(e-m)/b,c=`rgb(${Math.round(220-180*s)},${Math.round(220-100*s)},${Math.round(255-50*s)})`,u=p.get(t);o.push(M(r*k,(l-1-a)*w,k,w,c,{xi:r,yi:a,value:e,count:u.count,sum:u.sum,data:u.data},this.config.showValues?{value:e,showValues:!0,valueFormat:this.config.heatmapValueFormat}:void 0))}return o}buildBarScene(t){var e;if(!this.config.binSize)return[];const n=b(t,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===n.size)return[];let i=null;if(this.getCategory){const t=new Set;for(const e of n.values())for(const n of e.categories.keys())t.add(n);const e=this.config.barColors?Object.keys(this.config.barColors):[],r=new Set(e),o=Array.from(t).filter(t=>!r.has(t)).sort(),a=e.filter(e=>t.has(e)),l=a.join("\0")+""+o.join("\0");this._barCategoryCache&&this._barCategoryCache.key===l?i=this._barCategoryCache.order:(i=[...a,...o],this._barCategoryCache={key:l,order:i})}const r=[],o=this.scales,[a,l]=o.x.domain();for(const t of n.values()){const n=Math.max(t.start,a),s=Math.min(t.end,l);if(n>=s)continue;const c=o.x(n),u=o.x(s),h=Math.abs(u-c),d=h>2?1:0,f=Math.min(c,u)+d/2,y=Math.max(h-d,1);if(y>0)if(i&&t.categories.size>0){let n=0;for(const a of i){const i=t.categories.get(a)||0;if(0===i)continue;const l=o.y(n),s=o.y(n+i);r.push(A(f,Math.min(l,s),y,Math.abs(l-s),{fill:(null===(e=this.config.barColors)||void 0===e?void 0:e[a])||"#4e79a7"},{binStart:t.start,binEnd:t.end,total:t.total,category:a,categoryValue:i},a)),n+=i}}else{const e=o.y(0),n=o.y(t.total);r.push(A(f,Math.min(e,n),y,Math.abs(e-n),{fill:"#007bff"},{binStart:t.start,binEnd:t.end,total:t.total}))}}return r}buildSwarmScene(t){var e,n,i,r;const o=[],a=this.config.swarmStyle||{},l=null!==(e=a.radius)&&void 0!==e?e:3,s=null!==(n=a.fill)&&void 0!==n?n:"#007bff",c=null!==(i=a.opacity)&&void 0!==i?i:.7,u=a.stroke,h=a.strokeWidth;for(const e of t){const t=this.getX(e),n=this.getY(e);if(null==n||Number.isNaN(n))continue;const i=this.scales.x(t),a=this.scales.y(n);let d=s;if(this.getCategory){const t=this.getCategory(e);d=(null===(r=this.config.barColors)||void 0===r?void 0:r[t])||d}const f={type:"point",x:i,y:a,r:l,style:{fill:d,opacity:c,stroke:u,strokeWidth:h},datum:e};this.getPointId&&(f.pointId=this.getPointId(e)+""),o.push(f)}return o}buildWaterfallScene(t,e){var n,i,r;const o=[],a=this.scales,l=this.config.waterfallStyle,s=t.filter(t=>{const e=this.getY(t);return null!=e&&!Number.isNaN(e)});if(0===s.length)return o;const c=null!==(n=null==l?void 0:l.positiveColor)&&void 0!==n?n:"#28a745",u=null!==(i=null==l?void 0:l.negativeColor)&&void 0!==i?i:"#dc3545",h=null!==(r=null==l?void 0:l.gap)&&void 0!==r?r:1,d=null==l?void 0:l.stroke,f=null==l?void 0:l.strokeWidth;let y=0;for(let t=0;s.length>t;t++){const n=s[t],i=this.getX(n),r=this.getY(n),g=y+r;let p;p=s.length-1>t?this.getX(s[t+1])-i:t>0?i-this.getX(s[t-1]):0;const m=a.x(i),v=0!==p?a.x(i+p):m+e.width/10,x=Math.min(m,v)+h/2,b=Math.max(m,v)-h/2-x;if(0>=b){y=g;continue}const k=a.y(y),w=a.y(g);o.push(A(x,Math.min(k,w),b,Math.abs(k-w),{fill:0>r?u:c,stroke:d,strokeWidth:f},Object.assign(Object.assign({},n),{baseline:y,cumEnd:g,delta:r,_connectorStroke:null==l?void 0:l.connectorStroke,_connectorWidth:null==l?void 0:l.connectorWidth}))),y=g}return o}buildCandlestickScene(t,e){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],i=this.config.candlestickStyle||{},r=i.upColor||"#28a745",o=i.downColor||"#dc3545",a=i.wickColor||"#333",l=i.wickWidth||1,s=t.map(t=>this.getX(t)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let c=i.bodyWidth||6;if(!i.bodyWidth&&s.length>1){let t=1/0;for(let e=1;s.length>e;e++){const n=Math.abs(this.scales.x(s[e])-this.scales.x(s[e-1]));n>0&&t>n&&(t=n)}t!==1/0&&(c=Math.max(2,Math.min(.6*t,20)))}for(const e of t){const t=this.getX(e);if(null==t||Number.isNaN(t))continue;const i=this.getOpen(e),s=this.getHigh(e),u=this.getLow(e),h=this.getClose(e);if([i,s,u,h].some(t=>null==t||Number.isNaN(t)))continue;const d=h>=i;n.push({type:"candlestick",x:this.scales.x(t),openY:this.scales.y(i),closeY:this.scales.y(h),highY:this.scales.y(s),lowY:this.scales.y(u),bodyWidth:c,upColor:r,downColor:o,wickColor:a,wickWidth:l,isUp:d,datum:e})}return n}buildBoundsForGroup(t,e){if(!this.getBounds||!this.scales)return null;const n=[],i=[];for(const e of t){const t=this.getX(e),r=this.getY(e);if(null==t||null==r||Number.isNaN(t)||Number.isNaN(r))continue;const o=this.getBounds(e),a=this.scales.x(t);if(o&&0!==o)n.push([a,this.scales.y(r+o)]),i.push([a,this.scales.y(r-o)]);else{const t=this.scales.y(r);n.push([a,t]),i.push([a,t])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:i,style:this.resolveBoundsStyle(e,t[0]),datum:t,group:e,interactive:!1}}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){var n,i,r;const o=this.config.decay;if(!o||1>=e)return 1;const a=null!==(n=o.minOpacity)&&void 0!==n?n:.1,l=e-1-t;switch(o.type){case"linear":return a+(1-l/(e-1))*(1-a);case"exponential":{const t=null!==(i=o.halfLife)&&void 0!==i?i:e/2;return a+Math.pow(.5,l/t)*(1-a)}case"step":return(null!==(r=o.stepThreshold)&&void 0!==r?r:.5*e)>l?1:a;default:return 1}}applyDecay(t,e){var n,i;if(!this.config.decay)return;const r=e.length;if(1>=r)return;const o=new Map;for(let t=0;e.length>t;t++)o.set(e[t],t);for(const e of t){if("line"===e.type){const t=Array.isArray(e.datum)?e.datum:[];if(2>t.length)continue;const n=Array(t.length);let i=!1;for(let e=0;t.length>e;e++){const a=o.get(t[e]);null!=a?(n[e]=this.computeDecayOpacity(a,r),1>n[e]&&(i=!0)):n[e]=1}i&&(e._decayOpacities=n);continue}if("area"===e.type){const t=Array.isArray(e.datum)?e.datum:[],n=e.topPath?e.topPath.length:t.length;if(2>n)continue;if(t.length===n){const i=Array(n);let a=!1;for(let e=0;t.length>e;e++){const n=o.get(t[e]);null!=n?(i[e]=this.computeDecayOpacity(n,r),1>i[e]&&(a=!0)):i[e]=1}a&&(e._decayOpacities=i)}else{let i=1;for(const e of t){const t=o.get(e);if(null!=t){const e=this.computeDecayOpacity(t,r);i>e&&(i=e)}}if(1>i){const t=Array(n);t.fill(i),e._decayOpacities=t}}continue}const t=o.get(e.datum);if(null==t)continue;const a=this.computeDecayOpacity(t,r);if("heatcell"===e.type)e.style={opacity:a};else if("candlestick"===e.type)e._decayOpacity=a;else{const t=null!==(i=null===(n=e.style)||void 0===n?void 0:n.opacity)&&void 0!==i?i:1;e.style=Object.assign(Object.assign({},e.style),{opacity:t*a})}}}computePulseIntensity(t,e){var n;const i=this.config.pulse;if(!i)return 0;const r=null!==(n=i.duration)&&void 0!==n?n:500,o=e-t;return r>o?1-o/r:0}applyPulse(t,e){var n,i;if(!this.config.pulse||!this.timestampBuffer)return;const r="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",a=null!==(i=this.config.pulse.glowRadius)&&void 0!==i?i:4,l=new Map;for(let t=0;e.length>t;t++)l.set(e[t],t);for(const e of t){if("line"===e.type)continue;if("area"===e.type){const t=Array.isArray(e.datum)?e.datum:[e.datum];let n=0;for(const e of t){const t=l.get(e);if(null==t)continue;const i=this.timestampBuffer.get(t);if(null==i)continue;const o=this.computePulseIntensity(i,r);o>n&&(n=o)}n>0&&(e._pulseIntensity=n,e._pulseColor=o);continue}const t=l.get(e.datum);if(null==t)continue;const n=this.timestampBuffer.get(t);if(null==n)continue;const i=this.computePulseIntensity(n,r);i>0&&(e._pulseIntensity=i,e._pulseColor=o,e._pulseGlowRadius=a)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,i=this.timestampBuffer.peek();return null!=i&&n>e-i}snapshotPositions(){var t,e,n;this.prevPositionMap.clear(),this.prevPathMap.clear();for(let i=0;this.scene.length>i;i++){const r=this.scene[i],o=this.getNodeIdentity(r,i);o&&("point"===r.type?this.prevPositionMap.set(o,{x:r.x,y:r.y,r:r.r,opacity:r.style.opacity}):"rect"===r.type?this.prevPositionMap.set(o,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:r.style.opacity}):"heatcell"===r.type?this.prevPositionMap.set(o,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:null===(t=r.style)||void 0===t?void 0:t.opacity}):"candlestick"===r.type?this.prevPositionMap.set(o,{x:r.x,y:r.openY}):"line"===r.type?this.prevPathMap.set(o,{path:r.path.map(t=>[t[0],t[1]]),opacity:null===(e=r.style)||void 0===e?void 0:e.opacity}):"area"===r.type&&this.prevPathMap.set(o,{topPath:r.topPath.map(t=>[t[0],t[1]]),bottomPath:r.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(n=r.style)||void 0===n?void 0:n.opacity}))}}getNodeIdentity(t,e){var n,i,r,o;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===this.config.runtimeMode&&t.datum){if(this.getCategory)return`p:${this.getCategory(t.datum)}:${this.getY(t.datum)}`;const e=this.getX(t.datum),n=this.getY(t.datum);if(null!=e&&null!=n)return`p:${e}:${n}`}return"p:"+e;case"rect":return`r:${t.group||""}:${null!==(o=null!==(i=null===(n=t.datum)||void 0===n?void 0:n.binStart)&&void 0!==i?i:null===(r=t.datum)||void 0===r?void 0:r.category)&&void 0!==o?o:e}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+e:"c:"+this.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}startTransition(){var t,e,n,i,r,o,a,l,s,c,u,h,d,f,y,g,p,m,v,x,b,k,w,E,A,M;if(!this.config.transition||0===this.prevPositionMap.size&&0===this.prevPathMap.size)return;const S=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}let P=!1;const _=new Set,C=new Set;for(let t=0;this.scene.length>t;t++){const p=this.scene[t],m=this.getNodeIdentity(p,t);if(!m)continue;if(p._transitionKey=m,"line"===p.type||"area"===p.type){const t=this.prevPathMap.get(m);if(t){if(C.add(m),"line"===p.type&&t.path&&t.path.length===p.path.length){p._targetPath=p.path.map(t=>[t[0],t[1]]),p._prevPath=t.path;for(let e=0;p.path.length>e;e++)p.path[e]=[t.path[e][0],t.path[e][1]];P=!0}else if("area"===p.type&&t.topPath&&t.bottomPath&&t.topPath.length===p.topPath.length&&t.bottomPath.length===p.bottomPath.length){p._targetTopPath=p.topPath.map(t=>[t[0],t[1]]),p._targetBottomPath=p.bottomPath.map(t=>[t[0],t[1]]),p._prevTopPath=t.topPath,p._prevBottomPath=t.bottomPath;for(let e=0;p.topPath.length>e;e++)p.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;p.bottomPath.length>e;e++)p.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];P=!0}p._targetOpacity=null!==(e=p.style.opacity)&&void 0!==e?e:1}else p._targetOpacity=null!==(n=p.style.opacity)&&void 0!==n?n:1,p.style=Object.assign(Object.assign({},p.style),{opacity:0}),P=!0;continue}const v=this.prevPositionMap.get(m);if("point"===p.type)if(v){_.add(m);const t={x:p.x,y:p.y,r:p.r};p._targetOpacity=null!==(i=p.style.opacity)&&void 0!==i?i:1,v.x===t.x&&v.y===t.y||(p._targetX=t.x,p._targetY=t.y,p._targetR=t.r,p.x=v.x,p.y=v.y,p.r=null!==(r=v.r)&&void 0!==r?r:p.r,P=!0)}else p._targetOpacity=null!==(o=p.style.opacity)&&void 0!==o?o:1,p.style=Object.assign(Object.assign({},p.style),{opacity:0}),P=!0;else if("rect"===p.type)if(v){_.add(m);const t={x:p.x,y:p.y,w:p.w,h:p.h};p._targetOpacity=null!==(a=p.style.opacity)&&void 0!==a?a:1,v.x===t.x&&v.y===t.y&&v.w===t.w&&v.h===t.h||(p._targetX=t.x,p._targetY=t.y,p._targetW=t.w,p._targetH=t.h,p.x=v.x,p.y=v.y,p.w=null!==(l=v.w)&&void 0!==l?l:p.w,p.h=null!==(s=v.h)&&void 0!==s?s:p.h,P=!0)}else p._targetOpacity=null!==(c=p.style.opacity)&&void 0!==c?c:1,p.style=Object.assign(Object.assign({},p.style),{opacity:0}),P=!0;else if("heatcell"===p.type)if(v){_.add(m);const t={x:p.x,y:p.y,w:p.w,h:p.h};p._targetOpacity=null!==(h=null===(u=p.style)||void 0===u?void 0:u.opacity)&&void 0!==h?h:1,v.x===t.x&&v.y===t.y||(p._targetX=t.x,p._targetY=t.y,p._targetW=t.w,p._targetH=t.h,p.x=v.x,p.y=v.y,p.w=null!==(d=v.w)&&void 0!==d?d:p.w,p.h=null!==(f=v.h)&&void 0!==f?f:p.h,P=!0)}else p._targetOpacity=null!==(g=null===(y=p.style)||void 0===y?void 0:y.opacity)&&void 0!==g?g:1,p.style=Object.assign(Object.assign({},p.style||{}),{opacity:0}),P=!0}for(const[t,e]of this.prevPathMap)if(!C.has(t))if(t.startsWith("l:")&&e.path){const n={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(p=e.opacity)&&void 0!==p?p:1},_targetOpacity:0,_transitionKey:t,datum:null};this.exitNodes.push(n),P=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const n={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!==(m=e.opacity)&&void 0!==m?m:1},_targetOpacity:0,_transitionKey:t,datum:null};this.exitNodes.push(n),P=!0}for(const[t,e]of this.prevPositionMap)if(!_.has(t)){if(t.startsWith("p:")){const n={type:"point",x:e.x,y:e.y,r:null!==(v=e.r)&&void 0!==v?v:3,style:{opacity:null!==(x=e.opacity)&&void 0!==x?x:1},datum:null,_targetOpacity:0,_transitionKey:t};this.exitNodes.push(n)}else if(t.startsWith("r:")){const n={type:"rect",x:e.x,y:e.y,w:null!==(b=e.w)&&void 0!==b?b:0,h:null!==(k=e.h)&&void 0!==k?k:0,style:{opacity:null!==(w=e.opacity)&&void 0!==w?w:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};this.exitNodes.push(n)}else if(t.startsWith("h:")){const n={type:"heatcell",x:e.x,y:e.y,w:null!==(E=e.w)&&void 0!==E?E:0,h:null!==(A=e.h)&&void 0!==A?A:0,fill:"#999",datum:null,style:{opacity:null!==(M=e.opacity)&&void 0!==M?M:1},_targetOpacity:0,_transitionKey:t};this.exitNodes.push(n)}P=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),P&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:S})}advanceTransition(t){var e,n,i,r,o,a;if(!this.activeTransition)return!1;const l=$(t,this.activeTransition),s=T(l,"linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?"linear":"ease-out-cubic");for(const t of this.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const i=e?this.prevPositionMap.get(e):void 0,r=i?null!==(n=i.opacity)&&void 0!==n?n:1:0;t.style.opacity=W(r,t._targetOpacity,s)}if(void 0===t._targetX)continue;if(!e)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=W(i.x,t._targetX,s),t.y=W(i.y,t._targetY,s),void 0!==t._targetR&&void 0!==i.r&&(t.r=W(i.r,t._targetR,s))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=e?this.prevPositionMap.get(e):void 0,r=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;t.style.opacity=W(r,t._targetOpacity,s)}if(void 0===t._targetX)continue;if(!e)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=W(n.x,t._targetX,s),t.y=W(n.y,t._targetY,s),void 0!==n.w&&(t.w=W(n.w,t._targetW,s)),void 0!==n.h&&(t.h=W(n.h,t._targetH,s))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const n=e?this.prevPositionMap.get(e):void 0,i=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:W(i,t._targetOpacity,s)})}if(void 0===t._targetX)continue;if(!e)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=W(n.x,t._targetX,s),t.y=W(n.y,t._targetY,s),void 0!==n.w&&(t.w=W(n.w,t._targetW,s)),void 0!==n.h&&(t.h=W(n.h,t._targetH,s))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=void 0===t._prevPath&&t._targetOpacity>0?0:null!==(o=t.style.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:W(e,t._targetOpacity,s)})}const e=t._prevPath,n=t._targetPath;if(e&&n&&e.length===t.path.length)for(let i=0;t.path.length>i;i++)t.path[i][0]=W(e[i][0],n[i][0],s),t.path[i][1]=W(e[i][1],n[i][1],s)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=void 0===t._prevTopPath&&t._targetOpacity>0?0:null!==(a=t.style.opacity)&&void 0!==a?a:1;t.style=Object.assign(Object.assign({},t.style),{opacity:W(e,t._targetOpacity,s)})}const e=t._prevTopPath,n=t._prevBottomPath,i=t._targetTopPath,r=t._targetBottomPath;if(e&&i&&e.length===t.topPath.length)for(let n=0;t.topPath.length>n;n++)t.topPath[n][0]=W(e[n][0],i[n][0],s),t.topPath[n][1]=W(e[n][1],i[n][1],s);if(n&&r&&n.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=W(n[e][0],r[e][0],s),t.bottomPath[e][1]=W(n[e][1],r[e][1],s)}}if(l>=1){for(const t of this.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(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}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(),i=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===i)return this._colorMapCache.map;const r=Array.isArray(this.config.colorScheme)?this.config.colorScheme:D,o=new Map;for(let t=0;n.length>t;t++)o.set(n[t],r[t%r.length]);return this._colorMapCache={key:i,map:o},o}resolveLineStyle(t,e){const n=this.config.lineStyle;if("function"==typeof n){const i=n(e||{},t);if(i&&!i.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{stroke:e})}return i}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 i=this.config.lineStyle;if("function"==typeof i){const n=i(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 i&&"object"==typeof i?{fill:i.fill||i.stroke||"#4e79a7",fillOpacity:null!==(n=i.fillOpacity)&&void 0!==n?n:.7,stroke:i.stroke||"#4e79a7",strokeWidth:i.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:D,i=n[this._groupColorMap.size%n.length];return this._groupColorMap.set(t,i),i}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(t){var e,n,i,r;const o=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!==o.chartType||"runtimeMode"in t&&t.runtimeMode!==o.runtimeMode;if(l||void 0!==t.xAccessor||void 0!==t.yAccessor||void 0!==t.timeAccessor||void 0!==t.valueAccessor){const s=l||!S(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(n=o.xAccessor)&&void 0!==n?n:o.timeAccessor),c=l||!S(null!==(i=t.yAccessor)&&void 0!==i?i:t.valueAccessor,null!==(r=o.yAccessor)&&void 0!==r?r:o.valueAccessor);(s||c)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=P(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=P(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=P(this.config.xAccessor,"x"),this.getY=P(this.config.yAccessor,"y")),a=!0)}if("groupAccessor"in t&&!S(t.groupAccessor,o.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?C(this.config.groupAccessor):void 0,a=!0),"categoryAccessor"in t&&!S(t.categoryAccessor,o.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?C(this.config.categoryAccessor):void 0,a=!0),"sizeAccessor"in t&&!S(t.sizeAccessor,o.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?P(this.config.sizeAccessor,"size"):void 0,a=!0),"colorAccessor"in t&&!S(t.colorAccessor,o.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?C(this.config.colorAccessor):void 0,a=!0),"y0Accessor"in t&&!S(t.y0Accessor,o.y0Accessor)&&(this.getY0=this.config.y0Accessor?P(this.config.y0Accessor,"y0"):void 0,a=!0),"pointIdAccessor"in t&&!S(t.pointIdAccessor,o.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?C(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]!==o[n]){a=!0;break}}a&&(this.needsFullRebuild=!0)}}function N(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 z(t){let e=t%(2*Math.PI);return 0>e&&(e+=2*Math.PI),e}function I(t,e,n){const i=e-t.x,r=n-t.y,o=Math.sqrt(i*i+r*r);return o>t.r+5?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:o}}function R(t,e,n){var i,r,o,a;if(0===t.path.length)return null;const l=X(t.path,e);if(0>l)return null;const[s,c]=t.path[l];let u;if(t.path.length>1){let i=1/0;const r=Math.max(0,l-1),o=Math.min(t.path.length-2,l);for(let a=r;o>=a;a++){const[r,o]=t.path[a],[l,s]=t.path[a+1],c=B(e,n,r,o,l,s);i>c&&(i=c)}u=i}else{const t=e-s,i=n-c;u=Math.sqrt(t*t+i*i)}const h=null!==(a=null!==(r=null===(i=t.style)||void 0===i?void 0:i.strokeWidth)&&void 0!==r?r:null===(o=t.style)||void 0===o?void 0:o.lineWidth)&&void 0!==a?a:1;return u>Math.max(5,h/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 B(t,e,n,i,r,o){const a=r-n,l=o-i,s=a*a+l*l;if(0===s)return Math.sqrt(Math.pow(t-n,2)+Math.pow(e-i,2));let c=((t-n)*a+(e-i)*l)/s;c=Math.max(0,Math.min(1,c));const u=i+c*l;return Math.sqrt(Math.pow(t-(n+c*a),2)+Math.pow(e-u,2))}function j(t,e,n){const i=N(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function F(t,e,n){const i=N(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function Y(t,e,n){const i=t.bodyWidth/2,r=Math.min(t.openY,t.closeY);if(!(t.x-i-3>e||e>t.x+i+3||t.highY-3>n||n>t.lowY+3)){const i=r+Math.max(Math.max(t.openY,t.closeY)-r,1)/2,o=e-t.x,a=n-i;return{node:t,datum:t.datum,x:t.x,y:i,distance:Math.sqrt(o*o+a*a)}}return null}function H(t,e,n){if(0===t.topPath.length)return null;const i=X(t.topPath,e);if(0>i)return null;const[r,o]=t.topPath[i],a=e-r,l=n-o,s=Math.sqrt(a*a+l*l);return{node:t,datum:Array.isArray(t.datum)&&t.datum[i]?t.datum[i]:t.datum,x:r,y:o,distance:s}}function X(t,e){if(0===t.length)return-1;let n=0,i=t.length-1;for(;i>n;){const r=n+i>>1;e>t[r][0]?n=r+1:i=r}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}function G(t,e,n){switch(t){case"ArrowRight":case"ArrowDown":return n-1>e?e+1:e;case"ArrowLeft":case"ArrowUp":return e>0?e-1:e;case"Home":return 0;case"End":return n-1;case"Escape":return-1;default:return null}}function q(e,n,i){const r=t.useRef(null),[o,a]=t.useState(null);return t.useEffect(()=>{if(!n&&!i)return;const t=r.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,i]),[r,[n&&o?o.w:e[0],i&&o?o.h:e[1]]]}function V(e,n,i,r,o,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!==o&&(a(u),i.current=!0,r())},1e3);return()=>clearInterval(t)},[e,o,r])}O.QUADTREE_THRESHOLD=500;const K={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 U(t,e,n,i){let r;return r="function"==typeof n?n(t):(0,K[n])(i(t,e)),r}function Z(){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 Q(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}function J({config:t,orientation:e="vertical",width:n=100}){const{colorFn:i,domain:r,label:o,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:i(r[0]+e*(r[1]-r[0]))}))}return g.createElement("g",{"aria-label":o||"Gradient legend"},g.createElement("defs",null,g.createElement("linearGradient",{id:s,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},c)),o&&g.createElement("text",{x:a+e/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},o),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(r[0])),g.createElement("text",{x:a+e,y:t+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(r[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:i(r[1]-e*(r[1]-r[0]))}))}return g.createElement("g",{"aria-label":o||"Gradient legend"},o&&g.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},o),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(r[1])),g.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(r[0])))}function tt(t){const{legendGroups:e,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:o,legendInteraction:a,title:l="Legend",width:s=100,height:c=20,orientation:u="vertical"}=t,[h,d]=g.useState(0),[f,y]=g.useState(0),p=g.useCallback((t,e)=>{d(t),y(e)},[]),m="vertical"===u?(({legendGroups:t,width:e,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:o,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:s,legendInteraction:c})=>{let u=24;const h=[];return t.forEach((t,d)=>{u+=5,h.push(g.createElement("line",{key:"legend-top-line legend-symbol-"+d,stroke:"gray",x1:0,y1:u,x2:e,y2:u})),u+=8,t.label&&(u+=16,h.push(g.createElement("text",{key:"legend-text-"+d,y:u,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label)),u+=8),h.push(g.createElement("g",{key:"legend-group-"+d,className:"legend-item",transform:`translate(0,${u})`},((t,e,n,i,r,o,a,l,s,c)=>{const{type:u="fill",styleFn:h,items:d}=t,f=[];let y=0;const p=!(!e&&!n),m="isolate"===c||void 0===c&&null!=r;return d.forEach((t,c)=>{const v=U(t,c,u,h),x=Q(t,i,r),b=r&&r.size>0&&r.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===o&&c===a?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&m?b||!1:void 0,"aria-current":p&&!m&&null!=i&&t.label===i||void 0,"aria-label":t.label,onKeyDown:p?n=>{var i;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),e&&e(t)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const t=(c+("ArrowDown"===n.key?1:-1)+d.length)%d.length;s(l,t);const e=null===(i=n.currentTarget.parentElement)||void 0===i?void 0:i.children[t];e instanceof SVGElement&&e.focus()}}:void 0,onFocus:p?e=>{s(l,c),n&&n(t);const i=e.currentTarget.querySelector(".semiotic-legend-focus-ring");i&&i.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(Z,null),g.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label))),y+=22}),f})(t,n,i,r,o,a,l,d,s,c))),u+=22*t.items.length+8}),h})({legendGroups:e||[],width:s,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:o,focusedGroupIndex:h,focusedItemIndex:f,onFocusedIndexChange:p,legendInteraction:a}):(({legendGroups:t,height:e,width:n,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:a,focusedGroupIndex:l,focusedItemIndex:s,onFocusedIndexChange:c,legendInteraction:u})=>{let h=0;const d=[];t.forEach((t,e)=>{let n=0;t.label&&(n+=16);const f=((t,e,n,i,r,o,a,l,s,c)=>{const{type:u="fill",styleFn:h,items:d}=t,f=[];let y=0;const p=!(!e&&!n),m="isolate"===c||void 0===c&&null!=r;return d.forEach((t,c)=>{const v=U(t,c,u,h),x=Q(t,i,r),b=r&&r.size>0&&r.has(t.label);f.push(g.createElement("g",{key:"legend-item-"+c,transform:`translate(${y},0)`,onClick:e?()=>e(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:p?l===o&&c===a?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&m?b||!1:void 0,"aria-current":p&&!m&&null!=i&&t.label===i||void 0,"aria-label":t.label,onKeyDown:p?n=>{var i;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)+d.length)%d.length;s(l,t);const e=null===(i=n.currentTarget.parentElement)||void 0===i?void 0:i.children[t];e instanceof SVGElement&&e.focus()}}:void 0,onFocus:p?e=>{s(l,c),n&&n(t);const i=e.currentTarget.querySelector(".semiotic-legend-focus-ring");i&&i.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(Z,null),g.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label))),y+=26+7*t.label.length}),{items:f,offset:y}})(t,i,r,o,a,l,s,e,c,u);n+=f.offset+5,d.push(Object.assign(Object.assign({label:t.label},f),{offset:n})),h+=n+12});let f=Math.max(0,(n-h)/2);const y=[];return d.forEach((n,i)=>{const r=t[i];r.label&&(y.push(g.createElement("text",{key:"legend-text-"+i,transform:`translate(${f},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},r.label)),f+=16),y.push(g.createElement("g",{key:"legend-group-"+i,className:"legend-item",transform:`translate(${f},0)`},n.items)),f+=n.offset+5,t[i+1]&&y.push(g.createElement("line",{key:"legend-top-line legend-symbol-"+i,stroke:"gray",x1:f,y1:-8,x2:f,y2:e+0+8})),f+=12}),g.createElement("g",null,y)})({legendGroups:e||[],title:l,height:c,width:s,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:o,focusedGroupIndex:h,focusedItemIndex:f,onFocusedIndexChange:p,legendInteraction:a}),v=!(!n&&!i);return g.createElement("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==a&&(void 0!==a||null==o))||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 et(t){const{legend:e,totalWidth:n,totalHeight:i,margin:r,legendPosition:o="right",title:a,legendHoverBehavior:l,legendClickBehavior:s,legendHighlightedCategory:c,legendIsolatedCategories:u,legendInteraction:h}=t;if(!e)return null;const d="top"===o||"bottom"===o;let f,y;return"left"===o?(f=4,y=r.top):"top"===o?(f=0,y=a?32:8):"bottom"===o?(f=0,y=i-r.bottom+50):(f=n-r.right+10,y=r.top),g.createElement("g",{transform:`translate(${f}, ${y})`},function(t){return"object"==typeof t&&null!==t&&"gradient"in t}(e)?g.createElement(J,{config:e.gradient,orientation:d?"horizontal":"vertical",width:d?n:100}):function(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}(e)?g.createElement(tt,{legendGroups:e.legendGroups,title:"",width:d?n:100,orientation:d?"horizontal":"vertical",customHoverBehavior:l,customClickBehavior:s,highlightedCategory:c,isolatedCategories:u,legendInteraction:h}):e)}function nt(t){return"string"==typeof t?{type:t}:t}function it({orient:e,config:n,values:i,scale:r,size:o,length:l}){const s=function(t){var e,n,i,r,o;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!==(i=t.fillOpacity)&&void 0!==i?i:.5,stroke:null!==(r=t.stroke)&&void 0!==r?r:"none",strokeWidth:null!==(o=t.strokeWidth)&&void 0!==o?o:1}}(n),c="top"===e||"bottom"===e,u=t.useMemo(()=>{if(0===i.length)return null;const t=r.domain(),n=o-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 i=e[Math.floor(.25*n)],r=e[Math.floor(.5*n)],o=e[Math.floor(.75*n)],a=o-i;return{q1:i,median:r,q3:o,whiskerLow:Math.max(e[0],i-1.5*a),whiskerHigh:Math.min(e[n-1],o+1.5*a)}}(i);if(!t)return null;const{q1:o,median:a,q3:l,whiskerLow:u,whiskerHigh:h}=t,d=Math.min(.5*n,20),f=(n-d)/2+4;if(c){const t=r(o),n=r(l),i=r(a),c=r(u),y=r(h),p="top"===e?-1:1,m=0;return g.createElement("g",{"data-testid":"marginal-boxplot-"+e},g.createElement("line",{x1:c,y1:m+p*(f+d/2),x2:y,y2:m+p*(f+d/2),stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:c,y1:m+p*f,x2:c,y2:m+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:y,y1:m+p*f,x2:y,y2:m+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("rect",{x:Math.min(t,n),y:"top"===e?m-f-d:m+f,width:Math.abs(n-t),height:d,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:i,y1:"top"===e?m-f-d:m+f,x2:i,y2:"top"===e?m-f:m+f+d,stroke:s.fill,strokeWidth:2}))}{const t=r(o),n=r(l),i=r(a),c=r(u),y=r(h),p="left"===e?-1:1,m=0;return g.createElement("g",{"data-testid":"marginal-boxplot-"+e},g.createElement("line",{x1:m+p*(f+d/2),y1:c,x2:m+p*(f+d/2),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:m+p*f,y1:c,x2:m+p*(f+d),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:m+p*f,y1:y,x2:m+p*(f+d),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("rect",{x:"left"===e?m-f-d:m+f,y:Math.min(t,n),width:d,height:Math.abs(n-t),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:"left"===e?m-f-d:m+f,y1:i,x2:"left"===e?m-f:m+f+d,y2:i,stroke:s.fill,strokeWidth:2}))}}const u=a.bin().domain(t).thresholds(s.bins)(i);if(0===u.length)return null;const h=Math.max(...u.map(t=>t.length));if(0===h)return null;if("histogram"===s.type)return g.createElement("g",{"data-testid":"marginal-histogram-"+e},u.map((t,i)=>{if(null==t.x0||null==t.x1)return null;const o=t.length/h*n;if(c){const n=r(t.x0),a=r(t.x1)-r(t.x0);return g.createElement("rect",{key:i,x:n,y:"top"===e?-4-o:4,width:Math.max(a,.5),height:o,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}{const n=r(t.x0),a=r(t.x1)-r(t.x0);return g.createElement("rect",{key:i,x:"left"===e?-4-o:4,y:Math.min(n,n+a),width:o,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,i=[];for(const o of u){if(null==o.x0||null==o.x1)continue;const a=o.length/h*(n/2),l=r((o.x0+o.x1)/2);i.push(c?`${l},${"top"===e?-(t-a):t-a}`:`${"left"===e?-(t-a):t-a},${l}`)}for(let o=u.length-1;o>=0;o--){const a=u[o];if(null==a.x0||null==a.x1)continue;const l=a.length/h*(n/2),s=r((a.x0+a.x1)/2);i.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:i.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 i=0,o=null!=u[0].x0?r(u[0].x0):0;t.push(`M${o},${i}`);for(const i of u){if(null==i.x0||null==i.x1)continue;const o=i.length/h*n,a=r((i.x0+i.x1)/2);t.push(`L${a},${"top"===e?-o-4:o+4}`)}const a=null!=u[u.length-1].x1?r(u[u.length-1].x1):l;t.push(`L${a},${i}`),t.push("Z")}else{const i=0,o=null!=u[0].x0?r(u[0].x0):0;t.push(`M${i},${o}`);for(const i of u){if(null==i.x0||null==i.x1)continue;const o=i.length/h*n,a=r((i.x0+i.x1)/2);t.push(`L${"left"===e?-o-4:o+4},${a}`)}const a=null!=u[u.length-1].x1?r(u[u.length-1].x1):l;t.push(`L${i},${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},[i,r,s,o,l,e,c,4]);return u?g.createElement("g",{className:"marginal-"+e,"data-testid":"marginal-"+e},u):null}function rt(t,e=120,n=8){if(!t)return[];const i=Math.max(1,Math.floor(e/n)),r=t.split(/\s+/),o=[];let a="";for(const t of r)a&&a.length+1+t.length>i?(o.push(a),a=t):a=a?`${a} ${t}`:t;return a&&o.push(a),o}function ot(t,e,n,i){return"curly"===t?i?`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`:i?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function at(t){const{x:e=0,y:n=0,dx:i,dy:r,nx:o,ny:a,note:l,connector:s,subject:c,type:u,color:h,className:d,disable:f,events:y={},"data-testid":p}=t,m=new Set(Array.isArray(f)?f:[]);let v=i||0,x=r||0;null!=o&&(v=o-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 "+(d||"")).trim(),transform:`translate(${e},${n})`,"data-testid":p},y),!m.has("connector")&&function(t,e,n,i,r,o){const a=[];let l=0,s=0;if("callout-circle"!==r&&"label"!==r||!(null==o?void 0:o.radius)){if("callout-rect"===r&&o){const n=o.width||0,i=o.height||0;if(n>0||i>0){const r=n/2,o=i/2,a=t-r,c=e-o;if(0!==a||0!==c){const t=Math.abs(a),e=Math.abs(c),u=n/2,h=i/2,d=t*h>e*u?u/t:h/e;l=r+a*d,s=o+c*d}}}else if("bracket"===r&&o){const t=o.width,e=o.height,n=o.depth||30;void 0!==t?(l=t/2,s=n):void 0!==e&&(l=n,s=e/2)}}else{const n=(o.radius||0)+(o.radiusPadding||0);if(n>0&&(0!==t||0!==e)){const i=Math.atan2(e,t);l=Math.cos(i)*n,s=Math.sin(i)*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:i||"currentColor"})),"arrow"===(null==n?void 0:n.end))){const n=10,r=16/180*Math.PI,o=Math.atan2(e-s,t-l);a.push(g.createElement("path",{key:"connector-arrow",d:`M${l},${s}L${l+n*Math.cos(o+r)},${s+n*Math.sin(o+r)}L${l+n*Math.cos(o-r)},${s+n*Math.sin(o-r)}Z`,fill:i||"currentColor",stroke:"none"}))}return g.createElement("g",{className:"annotation-connector"},a)}(v,x,s,h,b,c),!m.has("subject")&&function(t,e,n,i,r){var o;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,i=(null==e?void 0:e.height)||0;(t>0||i>0)&&a.push(g.createElement("rect",{key:"subject-rect",width:t,height:i,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=i||0,o=r||0;if(void 0!==(null==e?void 0:e.x)){const i=(e.x||0)-t;a.push(g.createElement("line",{key:"threshold-line",x1:i,y1:(e.y1||0)-o,x2:i,y2:(e.y2||0)-o,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==e?void 0:e.y)){const i=(e.y||0)-o;a.push(g.createElement("line",{key:"threshold-line",x1:(e.x1||0)-t,y1:i,x2:(e.x2||0)-t,y2:i,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)-o,x2:0,y2:(e.y2||0)-o,stroke:n||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const t=null!==(o=null==e?void 0:e.width)&&void 0!==o?o:null==e?void 0:e.height;void 0!==t&&a.push(g.createElement("path",{key:"bracket-path",d:ot((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,h,e,n),!m.has("note")&&function(t,e,n,i){if(!t)return g.createElement("g",{className:"annotation-note"});const{label:r,title:o,orientation:a,align:l,wrap:s=120,noWrap:c}=t;if(!r&&!o)return g.createElement("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(e)>Math.abs(n)?"leftRight":"topBottom");let h=l;h&&"dynamic"!==h||(h="topBottom"===u?0>e?"right":"left":0>n?"bottom":"top");let d="start";"topBottom"===u?"right"===h?d="end":"middle"===h&&(d="middle"):d=0>e?"end":"start";const f=16,y=o?c?[o]:rt(o,s):[],p=r?c?[r]:rt(r,s):[],m="leftRight"===u?"end"===d?-4:4:0;let v=0;const x=[];y.length>0&&(x.push(g.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:i||void 0,textAnchor:d,fontWeight:"bold"},y.map((t,e)=>g.createElement("tspan",{key:e,x:m,dy:0===e?0:f},t)))),v=y.length*f),p.length>0&&x.push(g.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:i||void 0,textAnchor:d,y:v},p.map((t,e)=>g.createElement("tspan",{key:e,x:m,dy:0===e?0:f},t))));let b=null;if((o||r)&&(0!==e||0!==n))if("topBottom"===u){const t=Math.min(s,120);let e=0,n=t;"end"===d?(e=-t,n=0):"middle"===d&&(e=-t/2,n=t/2),b=g.createElement("line",{className:"note-line",x1:e,x2:n,y1:0,y2:0,stroke:i||"currentColor"})}else{const t=(y.length+p.length)*f+(p.length>0?f:0);let e=0,n=t;"bottom"===h?(e=-t,n=0):"middle"===h&&(e=-t/2,n=t/2),b=g.createElement("line",{className:"note-line",x1:0,x2:0,y1:e,y2:n,stroke:i||"currentColor"})}const k=Math.max(0,y.length+p.length-1)*f;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===h?-(k+f+(p.length>0&&y.length>0?2:0))/2+8:"bottom"===h||0>n?-(k+2):18),g.createElement("g",{className:"annotation-note",transform:`translate(${e},${n})`},g.createElement("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0},x),b)}(l,v,x,h))}function lt(t){var e,n;const{noteData:i}=t,{screenCoordinates:r}=i,o="string"==typeof i.type?i.type:"label",a=i.eventListeners||i.events||{};if(i.coordinates&&r){const t=i.nx||r[0][0]+(null!==(e=i.dx)&&void 0!==e?e:0),a=i.ny||r[0][1]+(null!==(n=i.dy)&&void 0!==n?n:0),l=r.map((e,n)=>{const r=Object.assign({},i,{note:0===n?i.note:{label:""},x:e[0],y:e[1],nx:t,ny:a});return g.createElement(at,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},r,{type:o}))});return g.createElement("g",null,l)}const l=i.note||{title:"none",label:i.label};return g.createElement(at,Object.assign({"data-testid":"semiotic-annotation",key:`${l.label}-${l.title}-${i.i}`,events:a},i,{type:o}))}const st={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};function ct(t,e){var n,i,r;const o=null!==(i=null===(n=e.scales)||void 0===n?void 0:n.x)&&void 0!==i?i:null===(r=e.scales)||void 0===r?void 0:r.time;return o?null!=t.x?o(t.x):e.xAccessor&&null!=t[e.xAccessor]?o(t[e.xAccessor]):null:null}function ut(t,e){var n,i,r;const o=null!==(i=null===(n=e.scales)||void 0===n?void 0:n.y)&&void 0!==i?i:null===(r=e.scales)||void 0===r?void 0:r.value;return o?null!=t.y?o(t.y):e.yAccessor&&null!=t[e.yAccessor]?o(t[e.yAccessor]):null:null}function ht(t,e,n){var i,r,o,a;const l=t.anchor||"fixed";if("latest"===l){if(null!=t.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const o=n.pointNodes[r];if(o.pointId===t.pointId){const t={x:o.x,y:o.y};return null===(i=n.stickyPositionCache)||void 0===i||i.set(e,t),t}}const o=function(t){var e,n,i,r,o,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===(i=t.scales)||void 0===i?void 0:i.time,u=null!==(o=null===(r=t.scales)||void 0===r?void 0:r.y)&&void 0!==o?o:null===(a=t.scales)||void 0===a?void 0:a.value;if(!c||!u)return null;const h=s[t.xAccessor||"x"],d=s[t.yAccessor||"y"];return null==h||null==d?null:{x:c(h),y:u(d)}}(n);return o&&(null===(r=n.stickyPositionCache)||void 0===r||r.set(e,o)),o}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=ct(t,n),c=ut(t,n)),null!=s&&null!=c)return null===(o=n.stickyPositionCache)||void 0===o||o.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 dt(t,e,n,i=50){return!(-i>t||t>(n.width||0)+i||-i>e||e>(n.height||0)+i)}function ft(t,e,n){if("left"===t||"right"===t){const i="left"===t?n:0,r="left"===t?-1:1,o=Math.ceil(e/8);let a="M0,"+i;for(let t=0;o>t;t++){const n=8*(t+1);a+=`L${Math.min(8*t+4,e)},${i+4*r}`,a+=`L${Math.min(n,e)},${i}`}return a}{const i="bottom"===t?0:e,r="bottom"===t?1:-1,o=Math.ceil(n/8);let a=`M${i},0`;for(let t=0;o>t;t++){const e=8*(t+1);a+=`L${i+4*r},${Math.min(8*t+4,n)}`,a+=`L${i},${Math.min(e,n)}`}return a}}function yt(e){const{width:n,height:i,totalWidth:r,totalHeight:o,margin:a,scales:l,showAxes:s,axes:c,showGrid:u,xFormat:h,yFormat:d}=e,f=t.useMemo(()=>{var t;if(!l)return[];const e=null==c?void 0:c.find(t=>"bottom"===t.orient),i=(null==e?void 0:e.tickFormat)||h||gt,r=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,o=l.x.ticks(Math.min(r,Math.max(2,Math.floor(n/70)))),a=o.map(t=>t.valueOf()),s=o.map((t,e)=>({value:t,pixel:l.x(t),label:i(t,e,a)})),u=s.reduce((t,e)=>Math.max(t,6.5*e.label.length),0);return pt(s,Math.max(55,u+8))},[l,c,h,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)||d||gt,r=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return pt(l.y.ticks(Math.min(r,Math.max(2,Math.floor(i/30)))).map(t=>({value:t,pixel:l.y(t),label:n(t)})),22)},[l,c,d,i]),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:r,height:o,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:i,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:i,x2:n,y2:i,stroke:A,strokeWidth:1}),w&&g.createElement("path",{d:ft("bottom",n,i),fill:"none",stroke:A,strokeWidth:1}),k&&!E&&g.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:A,strokeWidth:1}),E&&g.createElement("path",{d:ft("left",n,i),fill:"none",stroke:A,strokeWidth:1})))}function gt(t,e,n){return Math.round(100*t)/100+""}function pt(t,e){if(2>=t.length)return t;const n=[t[0]];for(let i=1;t.length-1>i;i++)e>Math.abs(t[i].pixel-n[n.length-1].pixel)||n.push(t[i]);const i=t[t.length-1];return e>Math.abs(i.pixel-n[n.length-1].pixel)?n[n.length-1]=i:n.push(i),n}function mt(t,e){return t instanceof Date&&(!(e&&e instanceof Date)||t.getFullYear()!==e.getFullYear()||t.getMonth()!==e.getMonth()||t.getDate()!==e.getDate())}function vt(e){var n,i;const{width:r,height:o,totalWidth:a,totalHeight:c,margin:u,scales:h,showAxes:d,axes:f,xLabel:y,yLabel:m,yLabelRight:v,xFormat:x,yFormat:b,showGrid:k,title:w,legend:E,legendHoverBehavior:A,legendClickBehavior:M,legendHighlightedCategory:S,legendIsolatedCategories:P,legendPosition:_="right",foregroundGraphics:C,marginalGraphics:L,xValues:D,yValues:T,annotations:$,svgAnnotationRules:W,xAccessor:O,yAccessor:N,annotationData:z,pointNodes:I,curve:R,underlayRendered:B,children:j}=e,F=t.useMemo(()=>{var t;if(!d||!h)return[];const e=null==f?void 0:f.find(t=>"bottom"===t.orient),n=(null==e?void 0:e.tickFormat)||x||gt,i=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,o=h.x.ticks(Math.min(i,Math.max(2,Math.floor(r/70)))),a=o.map(t=>t.valueOf()),l=o.map((t,e)=>({value:t,pixel:h.x(t),label:n(t,e,a)})),s=l.reduce((t,e)=>Math.max(t,6.5*e.label.length),0);return pt(l,Math.max(55,s+8))},[d,h,f,x,r]),Y=t.useMemo(()=>{var t;if(!d||!h)return[];const e=null==f?void 0:f.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||b||gt,i=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return pt(h.y.ticks(Math.min(i,Math.max(2,Math.floor(o/30)))).map(t=>({value:t,pixel:h.y(t),label:n(t)})),22)},[d,h,f,b,o]),H=t.useMemo(()=>{var t;if(!d||!h)return[];const e=null==f?void 0:f.find(t=>"right"===t.orient);if(!e)return[];const n=e.tickFormat||b||gt,i=null!==(t=e.ticks)&&void 0!==t?t:5;return pt(h.y.ticks(Math.min(i,Math.max(2,Math.floor(o/30)))).map(t=>({value:t,pixel:h.y(t),label:n(t)})),22)},[d,h,f,b,o]),X=t.useRef(new Map),G=t.useRef(null!==(n=null==$?void 0:$.length)&&void 0!==n?n:0),q=null!==(i=null==$?void 0:$.length)&&void 0!==i?i:0;G.current!==q&&(G.current=q,X.current=new Map);const V=t.useMemo(()=>{if(!$||0===$.length)return null;const t=function(t,e,n){var i,r,o,a,c,u,h,d,f,y,m,v,x,b,k,w,E,A,M,S,P,_,C,L,D,T,$,W,O,N,z,I,R,B,j,F,Y,H,X,G,q,V,K,U;switch(t.type){case"label":{const i=ht(t,e,n);if(!i)return null;const{x:r,y:o}=i;return dt(r,o,n)?g.createElement(lt,{key:"ann-"+e,noteData:{x:r,y:o,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 i=ht(t,e,n);if(!i)return null;const{x:r,y:o}=i;return dt(r,o,n)?g.createElement(lt,{key:"ann-"+e,noteData:{x:r,y:o,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 i=ct(t,n);if(null==i)return null;const r=t.color||"#f97316";return g.createElement("g",{key:"ann-"+e},g.createElement("line",{x1:i,y1:0,x2:i,y2:n.height||0,stroke:r,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&g.createElement("text",{x:i+4,y:12,fill:r,fontSize:12,fontWeight:"bold"},t.label))}case"y-threshold":{const i=ut(t,n);if(null==i)return null;const r=t.color||"#f97316";return g.createElement("g",{key:"ann-"+e},g.createElement("line",{x1:0,y1:i,x2:n.width||0,y2:i,stroke:r,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&g.createElement("text",{x:(n.width||0)-4,y:i-4,textAnchor:"end",fill:r,fontSize:12,fontWeight:"bold"},t.label))}case"enclose":{const i=(t.coordinates||[]).map(t=>({x:ct(Object.assign(Object.assign({},t),{type:"point"}),n),y:ut(Object.assign(Object.assign({},t),{type:"point"}),n),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const r=l.packEnclose(i),o=t.padding||10;return g.createElement("g",{key:"ann-"+e},g.createElement("circle",{cx:r.x,cy:r.y,r:r.r+o,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:r.x,y:r.y-r.r-o-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12},t.label))}case"rect-enclose":{const i=(t.coordinates||[]).map(t=>({x:ct(Object.assign(Object.assign({},t),{type:"point"}),n),y:ut(Object.assign(Object.assign({},t),{type:"point"}),n)})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const r=t.padding||10,o=i.map(t=>t.x),a=i.map(t=>t.y),l=Math.min(...o)-r,s=Math.max(...o)+r,c=Math.min(...a)-r,u=Math.max(...a)+r;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 i=n.data||[],r="function"==typeof t.filter?i.filter(t.filter):t.field&&null!=t.value?i.filter(e=>e[t.field]===t.value):[],o={stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return g.createElement("g",{key:"ann-"+e},r.map((e,i)=>{const r=ct(e,n),a=ut(e,n);if(null==r||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||o;return g.createElement("circle",Object.assign({key:"hl-"+i,cx:r,cy:a,r:l},s))}))}case"bracket":{const i=ct(t,n),r=ut(t,n);return g.createElement(lt,{key:"ann-"+e,noteData:{x:null!=i?i:0,y:null!=r?r: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",d=n.yAccessor||"y",f=l.map(t=>[t[s],t[d]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>f.length)return null;const y=null!==(r=null===(i=n.scales)||void 0===i?void 0:i.x)&&void 0!==r?r:null===(o=n.scales)||void 0===o?void 0:o.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 i=t.slice().sort((t,e)=>t[0]-e[0]),r=i.map(t=>t[0]),o=i.map(t=>t[1]),a=Math.max(2,Math.ceil(e*n)),l=[];for(let t=0;n>t;t++){const e=r[t],i=r.map(t=>Math.abs(t-e)),s=i.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:i[t]/s;c[t]=1>e?Math.pow(1-Math.pow(e,3),3):0}let u=0,h=0,d=0,f=0,y=0;for(let t=0;n>t;t++){const e=c[t];0!==e&&(u+=e,h+=e*r[t],d+=e*o[t],f+=e*r[t]*r[t],y+=e*r[t]*o[t])}if(0===u){l.push([e,o[t]]);continue}const g=u*f-h*h;if(1e-12>Math.abs(g))l.push([e,d/u]);else{const t=(u*y-h*d)/g;l.push([e,(d-t*h)/u+t*e])}}return l}(f,null!==(h=t.bandwidth)&&void 0!==h?h:.3):("polynomial"===v?p.default.polynomial(f,{order:t.order||2}):p.default.linear(f)).points;const b=x.map(([t,e])=>`${y(t)},${m(e)}`).join(" "),k=t.color||"#6366f1";return g.createElement("g",{key:"ann-"+e},g.createElement("polyline",{points:b,fill:"none",stroke:k,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&g.createElement("text",{x:y(x[x.length-1][0])+4,y:m(x[x.length-1][1])-4,fill:k,fontSize:11},t.label))}case"band":{const i=null!==(f=null===(d=n.scales)||void 0===d?void 0:d.y)&&void 0!==f?f:null===(y=n.scales)||void 0===y?void 0:y.value,r=null!==(m=null==i?void 0:i(t.y0))&&void 0!==m?m:0,o=null!==(v=null==i?void 0:i(t.y1))&&void 0!==v?v:n.height||0;return g.createElement("g",{key:"ann-"+e},g.createElement("rect",{x:0,y:Math.min(r,o),width:n.width||0,height:Math.abs(o-r),fill:t.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:t.fillOpacity||.1}),t.label&&g.createElement("text",{x:(n.width||0)-4,y:Math.min(r,o)-4,textAnchor:"end",fill:t.color||"var(--semiotic-primary, #6366f1)",fontSize:11},t.label))}case"envelope":{const i=n.data||[];if(2>i.length)return null;const r=n.xAccessor||"x",o=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(!o||!a)return null;const l=t.upperAccessor||"upperBounds",c=t.lowerAccessor||"lowerBounds",u=t.filter,h=i.filter(t=>null!=t[l]&&null!=t[c]&&!(u&&!u(t))).sort((t,e)=>t[r]-e[r]);if(2>h.length)return null;const d=st[n.curve||"linear"]||s.curveLinear,f=s.area().x(t=>o(t[r])).y0(t=>a(t[c])).y1(t=>a(t[l])).curve(d)(h);if(!f)return null;const y=t.fill||"#6366f1";return g.createElement("g",{key:"ann-"+e},g.createElement("path",{d:f,fill:y,fillOpacity:null!==(M=t.fillOpacity)&&void 0!==M?M:.15,stroke:"none"}),t.label&&h.length>0&&g.createElement("text",{x:o(h[h.length-1][r])+4,y:a(h[h.length-1][l])-4,fill:y,fontSize:11},t.label))}case"anomaly-band":{const i=n.data||[];if(2>i.length)return null;const r=n.yAccessor||"y",o=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,a=null!==(L=null===(C=n.scales)||void 0===C?void 0:C.y)&&void 0!==L?L:null===(D=n.scales)||void 0===D?void 0:D.value;if(!o||!a)return null;const l=i.map(t=>t[r]).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),h=null!==(T=t.threshold)&&void 0!==T?T:2,d=s-h*u,f=!1!==t.showBand,y=t.fill||"#6366f1",p=null!==($=t.fillOpacity)&&void 0!==$?$:.1,m=t.anomalyColor||"#ef4444",v=null!==(W=t.anomalyRadius)&&void 0!==W?W:6,x=a(s+h*u),b=a(d),k=i.filter(t=>{const e=t[r];return null!=e&&Math.abs(e-s)>h*u});return g.createElement("g",{key:"ann-"+e},f&&g.createElement("rect",{x:0,y:Math.min(x,b),width:n.width||0,height:Math.abs(b-x),fill:y,fillOpacity:p}),k.map((t,e)=>{const i=ct(t,n),r=ut(t,n);return null==i||null==r?null:g.createElement("circle",{key:"anomaly-"+e,cx:i,cy:r,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 i=n.data||[];if(3>i.length)return null;const r=n.xAccessor||"x",o=n.yAccessor||"y",a=null!==(N=null===(O=n.scales)||void 0===O?void 0:O.x)&&void 0!==N?N:null===(z=n.scales)||void 0===z?void 0:z.time,l=null!==(R=null===(I=n.scales)||void 0===I?void 0:I.y)&&void 0!==R?R:null===(B=n.scales)||void 0===B?void 0:B.value;if(!a||!l)return null;const s=i.map(t=>[t[r],t[o]]).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,i)=>e+n*Math.pow(t,i),0)}else{const t=s.length;let e=0,n=0,i=0,r=0;for(const[t,o]of s)e+=t,n+=o,i+=t*t,r+=t*o;const o=t*i-e*e;if(1e-12>Math.abs(o))return null;const a=(t*r-e*n)/o,l=(n-a*e)/t;c=t=>l+a*t}const u=s.length,h=s.map(([t,e])=>e-c(t)).reduce((t,e)=>t+e*e,0),d=Math.sqrt(h/Math.max(u-2,1)),f=s.reduce((t,e)=>t+e[0],0)/u,y=s.reduce((t,e)=>t+Math.pow(e[0]-f,2),0),m=null!==(j=t.confidence)&&void 0!==j?j:.95,v=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,x=null!==(F=t.steps)&&void 0!==F?F:5,b=s[u-1][0],k=(b-s[0][0])/Math.max(u-1,1),w=[];for(let t=1;x>=t;t++)w.push(b+t*k);const E=[];for(const t of w){const e=c(t),n=d*Math.sqrt(1+1/u+(y>0?Math.pow(t-f,2)/y:0))*v;E.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const A=`M${E.map(t=>`${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))}`,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:a(E[E.length-1].x)+4,y:l(E[E.length-1].yCenter)-4,fill:P,fontSize:11},t.label))}case"widget":{let i=null,r=null;if(null!=t.px&&null!=t.py)i=t.px,r=t.py;else{const o=ht(t,e,n);if(!o)return null;i=o.x,r=o.y}if(null==i||null==r)return null;if(!dt(i,r,n))return null;const o=null!==(G=t.dx)&&void 0!==G?G:0,a=null!==(q=t.dy)&&void 0!==q?q:0,l=null!==(V=t.width)&&void 0!==V?V:32,s=null!==(K=t.height)&&void 0!==K?K:32,c=null!==(U=t.content)&&void 0!==U?U:g.createElement("span",{style:{fontSize:18,cursor:"default"},title:t.label||"Info"},"ℹ️");return g.createElement("foreignObject",{key:"ann-"+e,x:i+o-l/2,y:r+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 i=ht(t,e,n);if(!i)return null;const{x:r,y:o}=i;return g.createElement("text",{key:"ann-text-"+e,x:r+(t.dx||0),y:o+(t.dy||0),fill:t.color||"var(--semiotic-text, #333)",fontSize:t.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},t.label)}default:return null}},e={scales:h?{x:h.x,y:h.y,time:h.x,value:h.y}:null,timeAxis:"x",xAccessor:O,yAccessor:N,width:r,height:o,data:z,frameType:"xy",pointNodes:I,curve:R,stickyPositionCache:X.current};return $.map((n,i)=>{if(W){const r=W(n,i,e);return null!=r?r:t(n,i,e)}return t(n,i,e)}).filter(Boolean)},[$,W,r,o,O,N,z,h,I,R]);return d||w||E||C||L||V&&V.length>0||k||j?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&&h&&!B&&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:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),Y.map((t,e)=>g.createElement("line",{key:"ygrid-"+e,x1:0,y1:t.pixel,x2:r,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),d&&h&&(()=>{const t=null==f?void 0:f.find(t=>"left"===t.orient),e=null==f?void 0:f.find(t=>"bottom"===t.orient),n=!t||!1!==t.baseline,i=(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)",h="var(--semiotic-text-secondary, var(--semiotic-text, #666))",d="var(--semiotic-text, #333)";return g.createElement("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},!B&&(!e||!1!==e.baseline)&&!a&&g.createElement("line",{x1:0,y1:o,x2:r,y2:o,stroke:c,strokeWidth:1}),!B&&a&&g.createElement("path",{d:ft("bottom",r,o),fill:"none",stroke:c,strokeWidth:1}),F.map((t,e)=>{const n=!!l&&("function"==typeof l?l(t.value,e):mt(t.value,e>0?F[e-1].value:void 0));return g.createElement("g",{key:"xtick-"+e,transform:`translate(${t.pixel},${o})`},g.createElement("line",{y2:5,stroke:c,strokeWidth:1}),g.createElement("text",{y:18,textAnchor:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:h,style:{userSelect:"none"}},t.label))}),y&&g.createElement("text",{x:r/2,y:o+40,textAnchor:"middle",fontSize:12,fill:d,style:{userSelect:"none"}},y),!B&&n&&!i&&g.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:c,strokeWidth:1}),!B&&i&&g.createElement("path",{d:ft("left",r,o),fill:"none",stroke:c,strokeWidth:1}),Y.map((t,e)=>{const n=!!s&&("function"==typeof s?s(t.value,e):mt(t.value,e>0?Y[e-1].value:void 0));return g.createElement("g",{key:"ytick-"+e,transform:`translate(0,${t.pixel})`},g.createElement("line",{x2:-5,stroke:c,strokeWidth:1}),g.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:h,style:{userSelect:"none"}},t.label))}),(()=>{const e=(null==t?void 0:t.label)||m;return e?g.createElement("text",{x:15-u.left,y:o/2,textAnchor:"middle",fontSize:12,fill:d,transform:`rotate(-90, ${15-u.left}, ${o/2})`,style:{userSelect:"none"}},e):null})(),(()=>{const t=null==f?void 0:f.find(t=>"right"===t.orient);if(!t||0===H.length)return null;const e=t.landmarkTicks,n=t.label||v;return g.createElement(g.Fragment,null,!1!==t.baseline&&g.createElement("line",{x1:r,y1:0,x2:r,y2:o,stroke:c,strokeWidth:1}),H.map((t,n)=>{const i=!!e&&("function"==typeof e?e(t.value,n):mt(t.value,n>0?H[n-1].value:void 0));return g.createElement("g",{key:"ytick-r-"+n,transform:`translate(${r},${t.pixel})`},g.createElement("line",{x2:5,stroke:c,strokeWidth:1}),g.createElement("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:i?11:10,fontWeight:i?600:400,fill:h,style:{userSelect:"none"}},t.label))}),n&&g.createElement("text",{x:r+u.right-15,y:o/2,textAnchor:"middle",fontSize:12,fill:d,transform:`rotate(90, ${r+u.right-15}, ${o/2})`,style:{userSelect:"none"}},n))})())})(),V,L&&h&&D&&T&&g.createElement(g.Fragment,null,L.top&&g.createElement("g",{transform:"translate(0, 0)"},g.createElement(it,{orient:"top",config:nt(L.top),values:D,scale:h.x,size:u.top,length:r})),L.bottom&&g.createElement("g",{transform:`translate(0, ${o})`},g.createElement(it,{orient:"bottom",config:nt(L.bottom),values:D,scale:h.x,size:u.bottom,length:r})),L.left&&g.createElement("g",{transform:"translate(0, 0)"},g.createElement(it,{orient:"left",config:nt(L.left),values:T,scale:h.y,size:u.left,length:o})),L.right&&g.createElement("g",{transform:`translate(${r}, 0)`},g.createElement(it,{orient:"right",config:nt(L.right),values:T,scale:h.y,size:u.right,length:o}))),C,j),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),et({legend:E,totalWidth:a,totalHeight:c,margin:u,legendPosition:_,title:w,legendHoverBehavior:A,legendClickBehavior:M,legendHighlightedCategory:S,legendIsolatedCategories:P})):null}function xt(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}const bt="undefined"==typeof window||"undefined"==typeof document,kt={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function wt(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 i=[],r={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks"},o=["point","line","area","rect","heatcell","circle","candlestick"],a=Object.keys(n).sort((t,e)=>{const n=o.indexOf(t),i=o.indexOf(e);return(-1===n?999:n)-(-1===i?999:i)});for(const t of a)i.push(`${n[t]} ${r[t]||t}`);return`${e}, ${i.join(", ")}`}function Et(t,e,n){const i=[];return t>0&&i.push(t+" nodes"),e>0&&i.push(e+" edges"),0===i.length?n+", empty":`${n}, ${i.join(", ")}`}function At({scene:t,chartType:e}){var n,i,r,o;const a=[];for(const e of t){if(a.length>=50)break;"point"===e.type?a.push({label:"Point",values:{x:Math.round(100*e.x)/100+"",y:Math.round(100*e.y)/100+""}}):"rect"===e.type?a.push({label:"Bar",values:{category:(null===(n=e.datum)||void 0===n?void 0:n.category)||"",value:Math.round(100*(null!==(r=null===(i=e.datum)||void 0===i?void 0:i.value)&&void 0!==r?r:0))/100+""}}):"heatcell"===e.type&&a.push({label:"Cell",values:{x:Math.round(100*e.x)/100+"",y:Math.round(100*e.y)/100+"",value:Math.round(100*(null!==(o=e.value)&&void 0!==o?o:0))/100+""}})}if(0===a.length)return null;const l=new Set;for(const t of a)for(const e of Object.keys(t.values))l.add(e);const s=Array.from(l);return g.createElement("table",{style:kt,role:"table","aria-label":"Data table for "+e},g.createElement("thead",null,g.createElement("tr",null,s.map(t=>g.createElement("th",{key:t},t)))),g.createElement("tbody",null,a.map((t,e)=>g.createElement("tr",{key:e},s.map(e=>{var n;return g.createElement("td",{key:e},null!==(n=t.values[e])&&void 0!==n?n:"")}))),t.length>50&&g.createElement("tr",null,g.createElement("td",{colSpan:s.length},"...and ",t.length-50," more items"))))}function Mt({nodes:t,chartType:e}){var n,i,r,o,a;const l=[];for(const e of t){if(l.length>=50)break;l.push({values:{id:(null===(n=e.datum)||void 0===n?void 0:n.id)||e.id||"",x:Math.round(100*(null!==(r=null!==(i=e.cx)&&void 0!==i?i:e.x)&&void 0!==r?r:0))/100+"",y:Math.round(100*(null!==(a=null!==(o=e.cy)&&void 0!==o?o:e.y)&&void 0!==a?a:0))/100+""}})}if(0===l.length)return null;const s=new Set;for(const t of l)for(const e of Object.keys(t.values))s.add(e);const c=Array.from(s);return g.createElement("table",{style:kt,role:"table","aria-label":"Data table for "+e},g.createElement("thead",null,g.createElement("tr",null,c.map(t=>g.createElement("th",{key:t},t)))),g.createElement("tbody",null,l.map((t,e)=>g.createElement("tr",{key:e},c.map(e=>{var n;return g.createElement("td",{key:e},null!==(n=t.values[e])&&void 0!==n?n:"")}))),t.length>50&&g.createElement("tr",null,g.createElement("td",{colSpan:c.length},"...and ",t.length-50," more items"))))}function St({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:kt},e)}function Pt(e){const n=t.createContext(null),i=_t(e);return[function({children:i}){const r=t.useMemo(()=>_t(e),[]);return g.createElement(n.Provider,{value:r,children:i})},e=>{var r;const o=null!==(r=t.useContext(n))&&void 0!==r?r:i,a=t.useRef(e);a.current=e;const l=t.useCallback(()=>a.current(o.getState()),[o]),s=t.useCallback(()=>a.current(o.getState()),[o]);return t.useSyncExternalStore(o.subscribe,l,s)}]}function _t(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 Ct={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}},Lt={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}},Dt={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"},[Tt,$t]=Pt(t=>({theme:Ct,setTheme(e){t(t=>{if("light"===e)return{theme:Ct};if("dark"===e)return{theme:Lt};if("high-contrast"===e)return{theme:Dt};if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?Lt:Ct;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 Wt(t,e,n,i){const r=t.getContext("2d");if(!r)return null;const o=e[0]*i,a=e[1]*i,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===o&&t.height===a||(t.width=o,t.height=a),r.setTransform(i,0,0,i,0,0),r.translate(n.left,n.top),r}function Ot(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function Nt(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 zt(t,e,n){let i=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(i=n.color):t>n.value&&(i=n.color);return i}function It(t,e,n,i,r,o){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],i=e[t][1]-e[t-1][1];a.push(a[t-1]+Math.sqrt(n*n+i*i))}const l=a[a.length-1];if(0===l)return;const s=Math.min(.2*l,40);t.strokeStyle=n,t.lineWidth=i,t.lineCap=o;for(let n=0;e.length-1>n;n++){const i=(a[n]+a[n+1])/2;let o=r;s>i&&(o*=i/s),s>l-i&&(o*=(l-i)/s),t.globalAlpha=Math.max(0,o),t.beginPath(),t.moveTo(e[n][0],e[n][1]),t.lineTo(e[n+1][0],e[n+1][1]),t.stroke()}}function Rt(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function Bt(t,e,n=.3){Rt(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 jt(t,e,n=.6){var i,r,o,a,l;if(!Rt(e))return;const s=null!==(i=e._pulseGlowRadius)&&void 0!==i?i:4,c=e.r+s*e._pulseIntensity,u=null!==(o=null!==(r=e.cx)&&void 0!==r?r:e.x)&&void 0!==o?o:0,h=null!==(l=null!==(a=e.cy)&&void 0!==a?a:e.y)&&void 0!==l?l:0;t.beginPath(),t.arc(u,h,c,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=e._pulseIntensity*n,t.stroke()}function Ft(t,e,n,i=.35){Rt(e)&&(t.globalAlpha=e._pulseIntensity*i,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill())}function Yt(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 Ht(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 Xt(t,e){const n=Yt(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 i=s.area().x(t=>t[0]).y0((t,n)=>e.bottomPath[n][1]).y1(t=>t[1]).curve(n).context(t);t.beginPath(),i(e.topPath)}}const Gt=(t,e,n,i)=>{var r,o,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",i=e._decayOpacities;if(i&&i.length===e.topPath.length){const o=null!==(r=e.style.fillOpacity)&&void 0!==r?r:.7;t.fillStyle=n;for(let n=0;e.topPath.length-1>n;n++)t.globalAlpha=.5*(i[n]+i[n+1])*o,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*(i[n]+i[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!==(o=e.style.opacity)&&void 0!==o?o:1;if(Xt(t,e),e.fillGradient){let i=1/0;for(const t of e.topPath)i>t[1]&&(i=t[1]);let r=-1/0;for(const t of e.bottomPath)t[1]>r&&(r=t[1]);const o=Ht("string"==typeof n?n:"#4e79a7"),a=e.fillGradient.topOpacity,s=e.fillGradient.bottomOpacity,c=t.createLinearGradient(0,i,0,r);c.addColorStop(0,`rgba(${o[0]},${o[1]},${o[2]},${a})`),c.addColorStop(1,`rgba(${o[0]},${o[1]},${o[2]},${s})`),t.fillStyle=c,t.globalAlpha=l}else{const i=null!==(a=e.style.fillOpacity)&&void 0!==a?a:.7;t.globalAlpha=i*l,t.fillStyle=n}if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(Xt(t,e),Ft(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=Yt(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}},qt=(t,e,n,i)=>{var r;const o=e.filter(t=>"point"===t.type);t.save();try{for(const e of o){t.beginPath(),t.arc(e.x,e.y,e.r,0,2*Math.PI);const n=null!==(r=e.style.opacity)&&void 0!==r?r: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()),jt(t,e),t.globalAlpha=1}}finally{t.restore()}},Vt=(t,e,n,i)=>{const r=e.filter(t=>"rect"===t.type);for(const e of r)null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon?Kt(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))),Bt(t,e),t.globalAlpha=1};function Kt(t,e){const n=e.style.icon,i=e.style.iconPadding||2,r=Math.min(e.w,e.h)-i;if(0>=r)return;const o=e.h>e.w;if(t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip(),o){const o=r+i,a=e.x+(e.w-r)/2;for(let i=e.y+e.h-r;i>=e.y-r;i-=o)t.drawImage(n,a,i,r,r)}else{const o=r+i,a=e.y+(e.h-r)/2;for(let i=e.x;e.x+e.w>i;i+=o)t.drawImage(n,i,a,r,r)}t.restore()}function Ut(t){const[e,n,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]}(t);return.299*e+.587*n+.114*i>128?"#000":"#fff"}function Zt(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}const Qt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Jt(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`${Qt[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*n>e?t=>{const e=new Date(t);return`${Qt[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}const te={line:[Gt,(t,e,n,i)=>{var r,o;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,h=l.colorThresholds,d=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!==(r=l.style.opacity)&&void 0!==r?r:1;It(t,l.path,c,u,p,l.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const f=Nt(l.curve),y=h&&h.length>0&&d&&d.length===l.path.length,g=l._decayOpacities;if(g&&g.length===l.path.length&&!y){t.strokeStyle=c;const m=null!==(o=l.style.opacity)&&void 0!==o?o: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,i){t.beginPath(),t.strokeStyle=e,t.moveTo(n,i),E=!0}function M(){E&&(t.stroke(),E=!1)}for(let S=0;l.path.length>S;S++){const[P,_]=l.path[S],C=d[S],L=zt(C,h,c);if(null!==x&&null!==w&&null!==k){if(L===w)t.lineTo(P,_);else{const D=[];for(const T of h){const $=T.value;(k>$||$>C)&&($>k||C>$)||k===$||C===$||D.push({t:($-k)/(C-k)})}D.sort((t,e)=>t.t-e.t);for(const W of D){const O=x+(P-x)*W.t,N=b+(_-b)*W.t,z=zt(k+(C-k)*Math.min(W.t+1e-4,1),h,c);t.lineTo(O,N),M(),A(z,O,N)}t.lineTo(P,_)}x=P,b=_,k=C,w=L}else A(L,P,_),x=P,b=_,k=C,w=L}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[I,R]=l.path[0];t.moveTo(I,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],i.height),t.lineTo(j,i.height),t.closePath(),t.fill()}t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}}],area:[Gt],stackedarea:[Gt],scatter:[qt],bubble:[qt],heatmap:[(t,e,n,i)=>{const r=e.filter(t=>"heatcell"===t.type);t.save();try{for(const e of r){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),Bt(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):Zt(e.value),i=Math.max(10,Math.min(16,.3*Math.min(e.w,e.h))),r=e.x+e.w/2,o=e.y+e.h/2;t.fillStyle=Ut(e.fill),t.font=i+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,r,o)}}}finally{t.restore()}}],bar:[Vt],swarm:[qt],waterfall:[(t,e,n,i)=>{var r,o,a;Vt(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!==(r=null==s?void 0:s._connectorWidth)&&void 0!==r?r:1,t.setLineDash([]);for(let e=0;l.length-1>e;e++){const i=l[e],r=l[e+1];if(!(null===(o=i.datum)||void 0===o?void 0:o.cumEnd)||!(null===(a=r.datum)||void 0===a?void 0:a.baseline))continue;const s=n.y(i.datum.cumEnd),c=i.x+i.w,u=r.x;t.beginPath(),t.moveTo(c,s),t.lineTo(u,s),t.stroke()}t.restore()}}],candlestick:[(t,e,n,i)=>{for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.save();const i=e._decayOpacity;null!=i&&1!==i&&(t.globalAlpha=i),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 r=Math.min(e.openY,e.closeY),o=Math.abs(e.openY-e.closeY),a=e.isUp?e.upColor:e.downColor;t.fillStyle=a,t.fillRect(e.x-e.bodyWidth/2,r,e.bodyWidth,Math.max(o,1)),t.strokeStyle=a,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,r,e.bodyWidth,Math.max(o,1)),t.restore()}}]},ee={top:20,right:20,bottom:30,left:40},ne={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"},ie={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 re({hover:t}){const e=t=>Number.isInteger(t)?t+"":t.toFixed(2);return g.createElement("div",{className:"semiotic-tooltip",style:ie},g.createElement("div",{style:{fontWeight:600,marginBottom:2}},e(t.value)),g.createElement("div",{style:{opacity:.7,fontSize:11}},e(t.time)))}function oe({width:i,height:r,totalWidth:o,totalHeight:a,margin:l,dimension:s,scales:c,onBrush:u}){const h=t.useRef(null),d=t.useRef(null),f=t.useRef(u);f.current=u;const y=t.useRef(c);return y.current=c,t.useEffect(()=>{if(!h.current)return;const t=n.select(h.current).select(".brush-g"),o="x"===s?e.brushX():"y"===s?e.brushY():e.brush();return o.extent([[0,0],[i,r]]),o.on("brush end",t=>{const e=y.current;if(!e)return;if(!t.selection)return void f.current(null);let n,o;if("x"===s){const[i,a]=t.selection;n=[e.x.invert(i),e.x.invert(a)],o=[e.y.invert(r),e.y.invert(0)]}else if("y"===s){const[r,a]=t.selection;n=[e.x.invert(0),e.x.invert(i)],o=[e.y.invert(a),e.y.invert(r)]}else{const[[i,r],[a,l]]=t.selection;n=[e.x.invert(i),e.x.invert(a)],o=[e.y.invert(l),e.y.invert(r)]}f.current({x:n,y:o})}),t.call(o),d.current=o,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{o.on("brush end",null),d.current=null}},[i,r,s]),g.createElement("svg",{ref:h,width:o,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},g.createElement("g",{className:"brush-g",transform:`translate(${l.left},${l.top})`}))}const ae=t.forwardRef(function(e,n){var i,r,o,a,l,s,c,u,h;const{chartType:d,runtimeMode:f,data:y,chunkThreshold:p,chunkSize:v,xAccessor:x,yAccessor:b,colorAccessor:k,sizeAccessor:w,groupAccessor:E,lineDataAccessor:A,curve:M,normalize:S,binSize:P,valueAccessor:_,arrowOfTime:C="right",windowMode:L="sliding",windowSize:D=200,timeAccessor:T,xExtent:$,yExtent:W,extentPadding:N=.1,sizeRange:z,size:B=[500,300],responsiveWidth:X,responsiveHeight:K,margin:U,className:Z,background:Q,lineStyle:J,pointStyle:tt,areaStyle:et,waterfallStyle:nt,swarmStyle:it,barColors:rt,colorScheme:ot,boundsAccessor:at,boundsStyle:lt,y0Accessor:st,gradientFill:ct,openAccessor:ut,highAccessor:ht,lowAccessor:dt,closeAccessor:ft,candlestickStyle:gt,showAxes:pt=!0,axes:mt,xLabel:kt,yLabel:Et,yLabelRight:Mt,xFormat:Pt,yFormat:_t,tickFormatTime:Ct,tickFormatValue:Lt,hoverAnnotation:Dt,tooltipContent:Tt,customHoverBehavior:Nt,enableHover:zt,annotations:It,svgAnnotationRules:Rt,showGrid:Bt,legend:jt,legendHoverBehavior:Ft,legendClickBehavior:Yt,legendHighlightedCategory:Ht,legendIsolatedCategories:Xt,legendPosition:Gt,backgroundGraphics:qt,foregroundGraphics:Vt,canvasPreRenderers:Kt,svgPreRenderers:Ut,title:Zt,categoryAccessor:Qt,brush:ie,onBrush:ae,decay:le,pulse:se,transition:ce,staleness:ue,heatmapAggregation:he,heatmapXBins:de,heatmapYBins:fe,showValues:ye,heatmapValueFormat:ge,marginalGraphics:pe,pointIdAccessor:me,xScaleType:ve,yScaleType:xe,accessibleTable:be}=e,[ke,we]=q(B,X,K),Ee=Object.assign(Object.assign({},ee),U);if(pe){const t=60;pe.top&&t>Ee.top&&(Ee.top=t),pe.bottom&&t>Ee.bottom&&(Ee.bottom=t),pe.left&&t>Ee.left&&(Ee.left=t),pe.right&&t>Ee.right&&(Ee.right=t)}const Ae=we[0]-Ee.left-Ee.right,Me=we[1]-Ee.top-Ee.bottom,Se="function"==typeof Vt?Vt({size:we,margin:Ee}):Vt,Pe="function"==typeof qt?qt({size:we,margin:Ee}):qt,_e=null!=Dt?Dt:zt,Ce=t.useRef(null),Le=t.useRef(null),De=t.useRef(0),Te=t.useRef(!1),$e=$t(t=>t.theme),[We,Oe]=t.useState(0),[Ne,ze]=t.useState(null),Ie=t.useRef(null),Re=t.useRef(null),[Be,je]=t.useState(null),[Fe,Ye]=t.useState(!1),[He,Xe]=t.useState([]),[Ge,qe]=t.useState([]),Ve=t.useRef(()=>{}),Ke="streaming"===f||["bar","swarm","waterfall"].includes(d),Ue=t.useMemo(()=>({chartType:d,runtimeMode:Ke?"streaming":"bounded",windowSize:D,windowMode:L,arrowOfTime:Ke?C:"right",extentPadding:N,xAccessor:Ke?void 0:x,yAccessor:Ke?void 0:b,timeAccessor:Ke?T:void 0,valueAccessor:_,colorAccessor:k,sizeAccessor:w,groupAccessor:E,categoryAccessor:Qt,lineDataAccessor:A,xScaleType:ve,yScaleType:xe,xExtent:$,yExtent:W,sizeRange:z,binSize:P,normalize:S,boundsAccessor:at,boundsStyle:lt,y0Accessor:st,gradientFill:"boolean"==typeof ct?ct?{topOpacity:.8,bottomOpacity:.05}:void 0:ct,openAccessor:ut,highAccessor:ht,lowAccessor:dt,closeAccessor:ft,candlestickStyle:gt,lineStyle:J,pointStyle:tt,areaStyle:et,swarmStyle:it,waterfallStyle:nt,colorScheme:ot,barColors:rt,annotations:It,decay:le,pulse:se,transition:ce,staleness:ue,heatmapAggregation:he,heatmapXBins:de,heatmapYBins:fe,showValues:ye,heatmapValueFormat:ge,pointIdAccessor:me,curve:M}),[d,D,L,C,N,x,b,T,_,ve,xe,k,w,E,Qt,A,$,W,z,P,S,at,lt,st,ct,ut,ht,dt,ft,gt,J,tt,et,it,nt,ot,rt,It,le,se,ce,ue,he,de,fe,ye,ge,Ke,me,M]),Ze=t.useRef(null);Ze.current||(Ze.current=new O(Ue));const Qe=t.useCallback(()=>{De.current||(De.current=requestAnimationFrame(()=>Ve.current()))},[]);t.useEffect(()=>{var t;null===(t=Ze.current)||void 0===t||t.updateConfig(Ue),Te.current=!0,Qe()},[Ue,Qe]),t.useEffect(()=>{Te.current=!0,Qe()},[$e,Qe]);const Je=t.useRef(null);Je.current||(Je.current=new m(t=>{const e=Ze.current;e&&e.ingest(t)&&(Te.current=!0,Qe())},{chunkThreshold:p,chunkSize:v})),t.useEffect(()=>{var t;null===(t=Je.current)||void 0===t||t.updateChunkOptions({chunkThreshold:p,chunkSize:v})},[p,v]);const tn=t.useCallback(t=>{var e;null===(e=Je.current)||void 0===e||e.push(t)},[]),en=t.useCallback(t=>{var e;null===(e=Je.current)||void 0===e||e.pushMany(t)},[]),nn=t.useCallback(()=>{var t,e;null===(t=Je.current)||void 0===t||t.clear(),null===(e=Ze.current)||void 0===e||e.clear(),Te.current=!0,Qe()},[Qe]);t.useImperativeHandle(n,()=>({push:tn,pushMany:en,clear:nn,getData:()=>{var t,e,n;return null===(t=Je.current)||void 0===t||t.flush(),null!==(n=null===(e=Ze.current)||void 0===e?void 0:e.getData())&&void 0!==n?n:[]},getScales:()=>{var t,e;return null!==(e=null===(t=Ze.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=Ze.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[tn,en,nn]),t.useEffect(()=>{var t;y&&(null===(t=Je.current)||void 0===t||t.setBoundedData(y))},[y]);const rn=t.useRef(()=>{}),on=t.useRef(()=>{});rn.current=t=>{if(!_e)return;const e=Ce.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-Ee.left,r=t.clientY-n.top-Ee.top;if(0>i||i>Ae||0>r||r>Me)return void(Ie.current&&(Ie.current=null,Re.current=null,je(null),Nt&&(Nt(null),Te.current=!0),Qe()));const o=Ze.current;if(!o||0===o.scene.length)return;const a=function(t,e,n,i=30,r){let o=null,a=!1;if(r){const t=r.find(e,n,i);if(t){const r=I(t,e,n);r&&i>r.distance&&(o=r,a=!0)}}for(const l of t){let t=null;switch(l.type){case"point":if(r&&a)break;t=I(l,e,n);break;case"line":t=R(l,e,n);break;case"rect":t=j(l,e,n);break;case"heatcell":t=F(l,e,n);break;case"area":if(!1===l.interactive)break;t=H(l,e,n);break;case"candlestick":t=Y(l,e,n)}t&&i>t.distance&&(o&&t.distance>=o.distance||(o=t))}return o}(o.scene,i,r,30,o.quadtree);if(!a)return void(Ie.current&&(Ie.current=null,Re.current=null,je(null),Nt&&Nt(null),Qe()));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});Ie.current=s,Re.current=a.node,je(s),Nt&&(Nt(s),Te.current=!0),Qe()},on.current=()=>{Ie.current&&(Ie.current=null,Re.current=null,je(null),Nt&&(Nt(null),Te.current=!0),Qe())},t.useCallback(t=>rn.current(t),[]);const an=t.useCallback(()=>on.current(),[]),ln=t.useRef(-1),sn=t.useCallback(t=>{const e=Ze.current;if(!e||0===e.scene.length)return;const n=function(t){const e=[];for(const n of t)switch(n.type){case"point":e.push({x:n.x,y:n.y,datum:n.datum});break;case"line":{const t=n,i=Array.isArray(t.datum)?t.datum:[];for(let n=0;t.path.length>n&&i.length>n;n++)e.push({x:t.path[n][0],y:t.path[n][1],datum:i[n]});break}case"area":{const t=n,i=Array.isArray(t.datum)?t.datum:[];for(let n=0;t.topPath.length>n&&i.length>n;n++)e.push({x:t.topPath[n][0],y:t.topPath[n][1],datum:i[n]});break}case"rect":case"heatcell":e.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum})}return e.sort((t,e)=>t.x-e.x||t.y-e.y),e}(e.scene);if(0===n.length)return;const i=0>ln.current?-1:ln.current,r=G(t.key,0>i?-1:i,n.length);if(null===r)return;if(t.preventDefault(),0>r)return ln.current=-1,Ie.current=null,Re.current=null,je(null),Nt&&Nt(null),void Qe();const o=0>i?0:r;ln.current=o;const a=function(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})}(n[o]);Ie.current=a,je(a),Nt&&Nt(a),Qe()},[Nt,Qe]),cn=t.useCallback(t=>{ln.current=-1,rn.current(t)},[]);Ve.current=()=>{var t,e;De.current=0;const n=Ce.current,i=Le.current;if(!n||!i)return;const r=Ze.current;if(!r)return;const o="undefined"!=typeof performance?performance.now():Date.now(),a=r.advanceTransition(o),l=Te.current||a;l&&!a&&r.computeScene({width:Ae,height:Me});const s=Ot(),c=function(t){if(!t)return ne;const e=getComputedStyle(t),n=e.getPropertyValue("--semiotic-border").trim(),i=e.getPropertyValue("--semiotic-text-secondary").trim(),r=e.getPropertyValue("--semiotic-bg").trim(),o=i||e.getPropertyValue("--text-secondary").trim(),a=e.getPropertyValue("--text-primary").trim(),l=n||e.getPropertyValue("--surface-3").trim(),s=r||e.getPropertyValue("--surface-0").trim();return o||a||n?{axisStroke:l||ne.axisStroke,tickText:o||ne.tickText,crosshair:o?o+"66":ne.crosshair,hoverFill:s?s+"4D":ne.hoverFill,hoverStroke:o?o+"99":ne.hoverStroke,pointRing:s||ne.pointRing}:ne}(n),u=null!==(t=null==ue?void 0:ue.threshold)&&void 0!==t?t:5e3,h=ue&&r.lastIngestTime>0&&o-r.lastIngestTime>u;if(l){const t=Wt(n,we,Ee,s);if(t){t.clearRect(-Ee.left,-Ee.top,we[0],we[1]),h&&(t.globalAlpha=null!==(e=null==ue?void 0:ue.dimOpacity)&&void 0!==e?e:.5);const i=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),o=Q||(i&&"transparent"!==i?i:null);if(o&&(t.fillStyle=o,t.fillRect(-Ee.left,-Ee.top,we[0],we[1])),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,Ae,Me),t.clip()),Kt&&r.scales)for(const e of Kt)t.save(),e(t,r.scene,r.scales,{width:Ae,height:Me}),t.restore();const a=te[d];if(a&&r.scales)for(const e of a)e(t,r.scene,r.scales,{width:Ae,height:Me});t.restore(),h&&(t.globalAlpha=1)}}{const t=Wt(i,we,Ee,s);if(t&&(t.clearRect(-Ee.left,-Ee.top,we[0],we[1]),_e&&Ie.current&&r.scales&&function(t,e,n,i,r,o,a){var l;if(!1===r.crosshair)return;t.save();const s="object"==typeof r.crosshair?r.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,i),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=r.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}(o)||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,Ie.current,Ae,Me,"object"==typeof _e?_e:{},Re.current,c),Re.current&&Array.isArray(Dt))){const e=Dt.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,n,i){var r;if(!n)return;const o=n.group;if(void 0!==o)for(const n of e){if("line"!==n.type)continue;if(n.group!==o)continue;if(2>n.path.length)continue;const e="function"==typeof i.style?i.style(n.datum):i.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!==(r=e.opacity)&&void 0!==r?r:1,t.stroke(),t.restore()}}(t,r.scene,Re.current,e)}}l&&n&&n.setAttribute("aria-label",wt(r.scene,d+" chart"));const f=Te.current;if(Te.current=!1,f&&r.scales&&((!Ne||Ne.x.domain()[0]!==r.scales.x.domain()[0]||Ne.x.domain()[1]!==r.scales.x.domain()[1]||Ne.y.domain()[0]!==r.scales.y.domain()[0]||Ne.y.domain()[1]!==r.scales.y.domain()[1]||Ne.x.range()[0]!==r.scales.x.range()[0]||Ne.x.range()[1]!==r.scales.x.range()[1]||Ne.y.range()[0]!==r.scales.y.range()[0]||Ne.y.range()[1]!==r.scales.y.range()[1])&&ze(r.scales),pe)){const t=r.getData(),e="function"==typeof x?x:t=>t[x||"x"],n="function"==typeof b?b:t=>t[b||"y"];Xe(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),qe(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}f&&It&&It.length>0&&Oe(t=>t+1),(null==ue?void 0:ue.showBadge)&&Ye(!!h),(a||r.hasActivePulses)&&(De.current=requestAnimationFrame(()=>Ve.current()))},t.useEffect(()=>(Qe(),()=>{De.current&&(cancelAnimationFrame(De.current),De.current=0)}),[Qe]),t.useEffect(()=>{Te.current=!0,Qe()},[d,Ae,Me,pt,Q,J,Kt,Qe]),V(ue,Ze,Te,Qe,Fe,Ye);const un=t.useMemo(()=>{if(Pt||Ct)return;const t=Ze.current;return(null==t?void 0:t.xIsDate)&&Ne?Jt(Ne.x.domain()):void 0},[Pt,Ct,Ne]),hn=Pt||Ct||un,dn=_e&&Be?Tt?Tt(Be):g.createElement(re,{hover:Be}):null,fn=dn?g.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:Ee.left+Be.x,top:Ee.top+Be.y,transform:`translate(${Be.x>.7*Ae?"calc(-100% - 12px)":"12px"}, ${.3*Me>Be.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1,width:"max-content"}},dn):null,yn=ln.current>=0&&Be?g.createElement("svg",{style:{position:"absolute",left:0,top:0,width:we[0],height:we[1],pointerEvents:"none",zIndex:2}},g.createElement("circle",{cx:Be.x+Ee.left,cy:Be.y+Ee.top,r:8,fill:"none",stroke:"var(--accent, #6366f1)",strokeWidth:2,strokeDasharray:"4,2"})):null;if(bt){const t=Ze.current;t&&y&&(t.ingest({inserts:y,bounded:!0}),t.computeScene({width:Ae,height:Me}));const e=null!==(i=null==t?void 0:t.scene)&&void 0!==i?i:[],n=null!==(r=null==t?void 0:t.scales)&&void 0!==r?r:null,o=hn||(()=>{if((null==t?void 0:t.xIsDate)&&n)return Jt(n.x.domain())})();return g.createElement("div",{className:"stream-xy-frame"+(Z?" "+Z:""),role:"img","aria-label":"string"==typeof Zt?Zt:"XY chart",style:{position:"relative",width:we[0],height:we[1]}},g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:we[0],height:we[1],style:{position:"absolute",left:0,top:0}},Pe,g.createElement("g",{transform:`translate(${Ee.left},${Ee.top})`},Q&&g.createElement("rect",{x:0,y:0,width:Ae,height:Me,fill:Q}),Ut&&n&&Ut.map((t,i)=>g.createElement(g.Fragment,{key:"svgpre-"+i},t(e,n,{width:Ae,height:Me}))),e.map((t,e)=>function(t,e){var n,i,r;switch(t.type){case"line":{const n=t;if(0===n.path.length)return null;const i="M"+n.path.map(([t,e])=>`${t},${e}`).join("L");return g.createElement("path",{key:"line-"+e,d:i,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity})}case"area":{const r=t;if(0===r.topPath.length)return null;const o=r.topPath.map(([t,e])=>`${t},${e}`).join("L"),a=[...r.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return g.createElement("path",{key:"area-"+e,d:`M${o}L${a}Z`,fill:xt(r.style.fill),fillOpacity:null!==(i=null!==(n=r.style.fillOpacity)&&void 0!==n?n:r.style.opacity)&&void 0!==i?i:.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})}case"point":{const n=t;return g.createElement("circle",{key:"point-"+e,cx:n.x,cy:n.y,r:n.r,fill:xt(n.style.fill),opacity:null!==(r=n.style.opacity)&&void 0!==r?r:.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})}case"rect":{const n=t;return g.createElement("rect",{key:"rect-"+e,x:n.x,y:n.y,width:n.w,height:n.h,fill:xt(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),[i,r,o]=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*i+.587*r+.114*o>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,i=Math.min(n.openY,n.closeY),r=Math.max(Math.abs(n.openY-n.closeY),1),o=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:i,width:n.bodyWidth,height:r,fill:o,stroke:o,strokeWidth:1}))}default:return null}}(t,e)).filter(Boolean))),g.createElement(vt,{width:Ae,height:Me,totalWidth:we[0],totalHeight:we[1],margin:Ee,scales:n,showAxes:pt,axes:mt,xLabel:kt,yLabel:Et,yLabelRight:Mt,xFormat:o,yFormat:_t||Lt,showGrid:Bt,title:Zt,legend:jt,legendHoverBehavior:Ft,legendClickBehavior:Yt,legendHighlightedCategory:Ht,legendIsolatedCategories:Xt,legendPosition:Gt,foregroundGraphics:Se,marginalGraphics:pe,xValues:[],yValues:[],annotations:It,svgAnnotationRules:Rt,annotationFrame:0,xAccessor:"string"==typeof x?x:"string"==typeof T?T:void 0,yAccessor:"string"==typeof b?b:"string"==typeof _?_:void 0,annotationData:null==t?void 0:t.getData(),pointNodes:null==t?void 0:t.scene.filter(t=>"point"===t.type),curve:"string"==typeof M?M:void 0}))}return g.createElement("div",{ref:ke,className:"stream-xy-frame"+(Z?" "+Z:""),role:"img","aria-label":"string"==typeof Zt?Zt:"XY chart",tabIndex:0,style:{position:"relative",width:X?"100%":we[0],height:K?"100%":we[1],overflow:"visible"},onMouseMove:_e?cn:void 0,onMouseLeave:_e?an:void 0,onKeyDown:sn},Pe&&g.createElement("svg",{style:{position:"absolute",left:0,top:0,width:we[0],height:we[1],pointerEvents:"none"}},Pe),g.createElement(yt,{width:Ae,height:Me,totalWidth:we[0],totalHeight:we[1],margin:Ee,scales:Ne,showAxes:pt,axes:mt,showGrid:Bt,xFormat:hn,yFormat:_t||Lt}),g.createElement("canvas",{ref:Ce,"aria-label":wt(null!==(a=null===(o=Ze.current)||void 0===o?void 0:o.scene)&&void 0!==a?a:[],d+" chart"),style:{position:"absolute",left:0,top:0}}),g.createElement("canvas",{ref:Le,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),g.createElement(St,{hoverPoint:Be}),be&&g.createElement(At,{scene:null!==(s=null===(l=Ze.current)||void 0===l?void 0:l.scene)&&void 0!==s?s:[],chartType:d+" chart"}),g.createElement(vt,{width:Ae,height:Me,totalWidth:we[0],totalHeight:we[1],margin:Ee,scales:Ne,showAxes:pt,axes:mt,xLabel:kt,yLabel:Et,yLabelRight:Mt,xFormat:hn,yFormat:_t||Lt,showGrid:Bt,title:Zt,legend:jt,legendHoverBehavior:Ft,legendClickBehavior:Yt,legendHighlightedCategory:Ht,legendIsolatedCategories:Xt,legendPosition:Gt,foregroundGraphics:Se,marginalGraphics:pe,xValues:He,yValues:Ge,annotations:It,svgAnnotationRules:Rt,annotationFrame:We,xAccessor:"string"==typeof x?x:"string"==typeof T?T:void 0,yAccessor:"string"==typeof b?b:"string"==typeof _?_:void 0,annotationData:null===(c=Ze.current)||void 0===c?void 0:c.getData(),pointNodes:null===(u=Ze.current)||void 0===u?void 0:u.scene.filter(t=>"point"===t.type),curve:"string"==typeof M?M:void 0,underlayRendered:!0}),(ie||ae)&&g.createElement(oe,{width:Ae,height:Me,totalWidth:we[0],totalHeight:we[1],margin:Ee,dimension:null!==(h=null==ie?void 0:ie.dimension)&&void 0!==h?h:"xy",scales:Ne,onBrush:null!=ae?ae:()=>{}}),(null==ue?void 0:ue.showBadge)&&g.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ue.badgePosition?{top:4,left:4}:"bottom-left"===ue.badgePosition?{bottom:4,left:4}:"bottom-right"===ue.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Fe?"#dc3545":"#28a745",color:"white"})},Fe?"STALE":"LIVE"),yn,fn)});ae.displayName="StreamXYFrame";const le={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},se={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class ce{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,i){var r;for(let o=0;this.capacity>o;o++){const a=this.particles[o];if(!a.active)continue;const l=n[a.edgeIndex];if(!l||!l.bezier){a.active=!1;continue}const s=i&&null!==(r=i[a.edgeIndex])&&void 0!==r?r:1;if(a.t+=t*e*s*(l.bezier.circular?.3:1),a.t>=1){a.active=!1;continue}const c=ue(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 ue(t,e,n){if(t.circular&&t.segments)return function(t,e,n,i){const r=t.length,o=e*r,a=Math.min(Math.floor(o),r-1),l=o-a,[s,c,u,h]=t[a],d=he(s,c,u,h,l),f=h.x-s.x,y=h.y-s.y,g=Math.sqrt(f*f+y*y);if(g>.001){const t=f/g;d.x+=-y/g*n*i*2,d.y+=t*n*i*2}return d}(t.segments,e,n,t.halfWidth);if(!t.points)return{x:0,y:0};const[i,r,o,a]=t.points,l=he(i,r,o,a,e),s=a.x-i.x,c=a.y-i.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 he(t,e,n,i,r){const o=1-r,a=o*o,l=a*o,s=r*r,c=s*r;return{x:l*t.x+3*a*r*e.x+3*o*s*n.x+c*i.x,y:l*t.y+3*a*r*e.y+3*o*s*n.y+c*i.y}}function de(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function fe(t,e){var n,i=[],r=[],o=[],a={},l=[];function s(t){o[t]=!1,a.hasOwnProperty(t)&&Object.keys(a[t]).forEach(function(e){delete a[t][e],o[e]&&s(e)})}function c(t){var e,i,h=!1;for(r.push(t),o[t]=!0,e=0;l[t].length>e;e++)(i=l[t][e])===n?(u(n,r),h=!0):o[i]||(h=c(i));if(h)s(t);else for(e=0;l[t].length>e;e++){var d=a[i=l[t][e]];d||(a[i]=d={}),d[i]=!0}return r.pop(),h}function u(t,e){var n=[].concat(e).concat(t);i.push(n)}function h(e){!function(e){for(var n=0;t.length>n;n++)n>=e&&t[n]||(t[n]=[]),t[n]=t[n].filter(function(t){return t>=e})}(e);for(var n,i=function(t){for(var e=t.length,n=Array(e),i=Array(e),r=Array(e),o=Array(e),a=Array(e),l=Array(e),s=0;e>s;++s)n[s]=-1,i[s]=0,r[s]=!1,o[s]=0,a[s]=-1,l[s]=[];var c,u=0,h=[],d=[];function f(e){var s=[e],c=[e];for(n[e]=i[e]=u,r[e]=!0,u+=1;c.length>0;){var f=t[e=c[c.length-1]];if(f.length>o[e]){for(var y=o[e];f.length>y;++y){var g=f[y];if(0>n[g]){n[g]=i[g]=u,r[g]=!0,u+=1,s.push(g),c.push(g);break}r[g]&&(i[e]=0|Math.min(i[e],i[g])),0>a[g]||l[e].push(a[g])}o[e]=y}else{if(i[e]===n[e]){var p=[],m=[],v=0;for(y=s.length-1;y>=0;--y){var x=s[y];if(r[x]=!1,p.push(x),m.push(l[x]),v+=l[x].length,a[x]=h.length,x===e){s.length=y;break}}h.push(p);var b=Array(v);for(y=0;m.length>y;y++)for(var k=0;m[y].length>k;k++)b[--v]=m[y][k];d.push(b)}c.pop()}}}for(s=0;e>s;++s)0>n[s]&&f(s);for(s=0;d.length>s;s++){var y=d[s];if(0!==y.length){y.sort(function(t,e){return t-e}),c=[y[0]];for(var g=1;y.length>g;g++)y[g]!==y[g-1]&&c.push(y[g]);d[s]=c}}return{components:h,adjacencyList:d}}(t),r=i.components.filter(function(t){return t.length>1}),o=1/0,a=0;r.length>a;a++)for(var l=0;r[a].length>l;l++)o>r[a][l]&&(o=r[a][l],n=a);var s=r[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:o,adjList:c}}n=0;for(var d=t.length;d>n;){var f=h(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];o[+p]=!1,a[p]={}}c(n),n+=1}else n=d}return i}function ye(t){return t.y0-t.y1>0?"up":"down"}function ge(t,e){return e(t.source)==e(t.target)}function pe(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 me(t){return t.target.x0-t.source.x1}function ve(t,e){var n=be(t),i=me(e)/Math.tan(n);return"up"==ye(t)?t.y1-i:t.y1+i}function xe(t,e){var n=be(t),i=me(e)/Math.tan(n);return"up"==ye(t)?t.y1+i:t.y1-i}function be(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function ke(t,e){return e(t)}function we(t){return Ae(t.source)}function Ee(t){return Ae(t.target)}function Ae(t){return(t.y0+t.y1)/2}function Me(t){return t.virtual?0:t.value}function Se(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!ge(t,e)?n+1:n});var i=0;return t.targetLinks.forEach(function(t){i=t.circular&&!ge(t,e)?i+1:i}),n+i}function Pe(t){return t.target.depth}function _e(t,e){return t.sourceLinks.length?t.depth:e-1}function Ce(t,e){return t.y0-e.y0}function Le(t,e){return e.y0-t.y0}function De(t,e){return t.y1-e.y1}function Te(t,e){return e.y1-t.y1}function $e(t,e){return Oe(t.source,e.source)||t.index-e.index}function We(t,e){return Oe(t.target,e.target)||t.index-e.index}function Oe(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Ne(t,e){return ze(t)==ze(e)?"bottom"==t.circularLinkType?Le(t,e):Ce(t,e):ze(e)-ze(t)}function ze(t){return t.target.column-t.source.column}function Ie(t,e){return Re(t)==Re(e)}function Re(t){return t.y0-t.y1>0?"up":"down"}function Be(t,e,n,i,r){let o=t;var l=Math.max(8,.15*(o.y1-o.y0));o.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,l))});var s=a.min(o.links,function(t){return t.source.y0});o.links.forEach(function(t){t.circular&&(t.circularPathData={})});var c=o.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}),je(o.links.filter(function(t){return"top"==t.circularLinkType}),e,n),je(o.links.filter(function(t){return"bottom"==t.circularLinkType}),e,n),o.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+i,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,ge(t,e)&&pe(t))t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+r+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-r-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=o.links.filter(function(t){return t.source.column==a&&t.circularLinkType==l});c.sort("bottom"==t.circularLinkType?Le:Ce);var u=0;c.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2+r*n+u),u+=e._circularWidth||e.width}),a=t.target.column,(c=o.links.filter(function(t){return t.target.column==a&&t.circularLinkType==l})).sort("bottom"==t.circularLinkType?Te:De),u=0,c.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2+r*n+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(o.y1,t.source.y1,t.target.y1)+r+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-r-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,i=t.target.x0,r=t.y1,o=(e+i)/2;return"M"+e+","+n+"C"+o+","+n+" "+o+","+r+" "+i+","+r}(t)}),o}function je(t,e,n){t.sort(Ne);var i=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,r){var o=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(ge(t,e)&&pe(t))t.circularPathData.verticalBuffer=o+t._circularWidth/2;else{for(var a=0;i.length>a;a++){var l=i[a];if(l!==t&&l.circularPathData&&void 0!==l.circularPathData.verticalBuffer&&Fe(t,l)){var s=l.circularPathData.verticalBuffer+(l._circularWidth||l.width)/2+n;o=s>o?s:o}}t.circularPathData.verticalBuffer=o+t._circularWidth/2}}),t}function Fe(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function Ye(t){return function(){return t}}function He(t){return t.index}function Xe(t){return t.nodes}function Ge(t){return t.links}function qe(t,e,n){var i=a.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});i.forEach(function(r,o){var a=r.length;if(e)r.sort(e);else if(o>0){var l=new Map;r.forEach(function(t,e){var n,i,r,o=(i=0,r=0,(n=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=Ae(t.source)*e,i+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=Ae(t.target)*e,i+=e}}),i>0?r/i:NaN);l.set(t,{bc:o,idx:e})}),r.sort(function(t,e){var n=l.get(t),i=l.get(e),r=n.bc,o=i.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(r)||isNaN(o)?isNaN(r)?isNaN(o)?n.idx-i.idx:1:-1:r-o})}else r.sort(function(t,e){return t.circularLinkType==e.circularLinkType?Se(e,n)-Se(t,n):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});r.forEach(function(e,r){e.depth==i.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==Se(e,n)?(e.y0=t.y1/2+r,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+r,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-r,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/a*r,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-a/2+r,e.y1=e.y0+e.value*t.ky)})})}function Ve(t,e,n,i,r,o){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]});h();for(var s=1,c=o;c>0;--c)u(s*=.99,n),h();function u(e,n){var i=l.length;l.forEach(function(r){var o=r.length,l=r[0].depth;r.forEach(function(r){var s;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&Se(r,n)>0){var c=a.mean(r.sourceLinks,Ee),u=a.mean(r.targetLinks,we),h=c&&u?(c+u)/2:c||u;if(h){var d=(h-Ae(r))*e*.3;r.y0+=d,r.y1+=d}}else if(0==l&&1==o)r.y0=t.y1/2-(s=r.y1-r.y0)/2,r.y1=t.y1/2+s/2;else if(l==i-1&&1==o)r.y0=t.y1/2-(s=r.y1-r.y0)/2,r.y1=t.y1/2+s/2;else if(1==r.targetLinks.length&&1==r.targetLinks[0].source.sourceLinks.length)s=r.y1-r.y0,r.y0=r.targetLinks[0].source.y0,r.y1=r.y0+s;else{var f=a.mean(r.sourceLinks,Ee),y=a.mean(r.targetLinks,we),g=((f&&y?(f+y)/2:f||y)-Ae(r))*e;r.y0+=g,r.y1+=g}})})}function h(){l.forEach(function(n){var o,a,l,s=t.y0,c=n.length;for(n.sort(e||Oe),l=0;c>l;++l)(a=s-(o=n[l]).y0)>0&&(o.y0+=a,o.y1+=a),s=o.y1+i;if((a=s-i-t.y1)>0)for(s=o.y0-=a,o.y1-=a,l=c-2;l>=0;--l)(a=(o=n[l]).y1+r-s)>0&&(o.y0-=a,o.y1-=a),s=o.y0})}}function Ke(t){t.nodes.forEach(function(t){t.sourceLinks.sort(We),t.targetLinks.sort($e)}),t.nodes.forEach(function(t){var e=t.y0,n=e,i=t.y1,r=i;t.sourceLinks.forEach(function(t){t.circular?(t.y0=i-t.width/2,i-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=r-t.width/2,r-=t.width):(t.y1=n+t.width/2,n+=t.width)})})}function Ue(){var t=0,e=0,n=1,i=1,r=24,o=8,l=null,s=He,c=_e,u=void 0,h=32,d=2,f=Xe,y=Ge;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=i,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 i=t.source,r=t.target;"object"!=typeof i&&(i=t.source=de(n,i)),"object"!=typeof r&&(r=t.target=de(n,r)),i.sourceLinks.push(t),r.targetLinks.push(t)})}(f,s),function(t,e){var n=0;if(null==e){for(var i=[],r=0;t.links.length>r;r++){var o=t.links[r],a=o.source.index,l=o.target.index;i[a]||(i[a]=[]),i[l]||(i[l]=[]),-1===i[a].indexOf(l)&&i[a].push(l)}var s=fe(i);s.sort(function(t,e){return t.length-e.length});var c={};for(r=0;s.length>r;r++){var u=s[r].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,i=t.source.index;e===i||c[i]&&c[i][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,i=0;t.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:i>n?"top":"bottom","top"==r.circularLinkType?n++:i++,t.nodes.forEach(function(t){ke(t,e)!=ke(r.source,e)&&ke(t,e)!=ke(r.target,e)||(t.circularLinkType=r.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),ge(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,Me),a.sum(t.targetLinks,Me)),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 i,r,o;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(i=t.nodes,r=[],o=0;i.length;++o,i=r,r=[])i.forEach(function(t){t.depth=o,t.sourceLinks.forEach(function(t){0>r.indexOf(t.target)&&!t.circular&&r.push(t.target)})});for(i=t.nodes,r=[],o=0;i.length;++o,i=r,r=[])i.forEach(function(t){t.height=o,t.targetLinks.forEach(function(t){0>r.indexOf(t.source)&&!t.circular&&r.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?n(t,o):t.column})}(f,u,c);var y=o;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,(i-e)*l/(p-1)))}(function(t,e,n){var i=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 r=a.min(i,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/a.sum(e,function(t){return t.value})});t.ky=r,t.links.forEach(function(e){e.width=e.value*t.ky});var o=a.max(t.nodes,function(t){return t.column});t.nodes.forEach(o>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-n)/o),e.x1=e.x0+n}:function(e){e.x0=t.x0,e.x1=e.x0+n})})(f,y,r),qe(f,u,s),Ve(f,u,s,y,y,h),Ke(f),Be(f,s,d,10,8),qe(f,u,s),Ve(f,u,s,y,y,h),Ke(f),Be(f,s,d,10,8),function(t,e){let n=t;n.nodes.forEach(function(t){t.y+(t.y1-t.y0)>n.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-n.y1));var i=n.links.filter(function(n){return ke(n.source,e)==ke(t,e)}),r=i.length;r>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!Ie(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=ve(e,t);return t.y1-n}if(e.target.column>t.target.column)return ve(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 o=t.y0;i.forEach(function(t){t.y0=o+t.width/2,o+=t.width}),i.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var o=n+1,a=0;r>o;o++)a+=i[o].width;e.y0=t.y1-a-e.width/2}})})}(f,s),function(t,e){let n=t;n.nodes.forEach(function(t){var i=n.links.filter(function(n){return ke(n.target,e)==ke(t,e)}),r=i.length;r>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!Ie(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=xe(e,t);return t.y0-n}if(e.source.column>t.source.column)return xe(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 o=t.y0;i.forEach(function(t){t.y1=o+t.width/2,o+=t.width}),i.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var o=n+1,a=0;r>o;o++)a+=i[o].width;e.y1=t.y1-a-e.width/2}})})}(f,s),function(t){var e=t.nodes,n=t.links,i=!1,r=!1;if(n.forEach(function(t){"top"==t.circularLinkType?i=!0:"bottom"==t.circularLinkType&&(r=!0)}),0==i||0==r){var o=a.min(e,function(t){return t.y0}),l=a.max(e,function(t){return t.y1}),s=(t.y1-t.y0)/(l-o);function c(e){return(e-o)/(l-o)*(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),Be(f,s,d,10,8)}(g),g}return g.update=function(t){return Ke(t),Be(t,s,d,10,8),t},g.nodeWidth=function(t){return arguments.length?(r=+t,g):r},g.nodePadding=function(t){return arguments.length?(o=+t,g):o},g.nodePaddingRatio=function(t){return arguments.length?(l=+t,g):l},g.nodes=function(t){return arguments.length?(f="function"==typeof t?t:Ye(t),g):f},g.links=function(t){return arguments.length?(y="function"==typeof t?t:Ye(t),g):y},g.nodeId=function(t){return arguments.length?(s="function"==typeof t?t:Ye(t),g):s},g.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:Ye(t),g):c},g.nodeSort=function(t){return arguments.length?(u=t,g):u},g.iterations=function(t){return arguments.length?(h=+t,g):h},g.circularLinkGap=function(t){return arguments.length?(d=+t,g):d},g.extent=function(r){return arguments.length?(t=+r[0][0],e=+r[0][1],n=+r[1][0],i=+r[1][1],g):[[t,e],[n,i]]},g.size=function(r){return arguments.length?(t=e=0,n=+r[0],i=+r[1],g):[n-t,i-e]},g}const Ze=t=>{let e,n,i,r,o,a,l,s,c;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,i=t.y1+t.sankeyWidth/2,r=t.y0+t.sankeyWidth/2,o=t.source.x1,a=t.target.x0,l=u.interpolateNumber(o,a),s=l(.5),c=l(.5),`M${e},${o}C${e},${s} ${n},${c} ${n},${a}L${i},${a}C${i},${c} ${r},${s} ${r},${o}Z`):(e=t.source.x1,n=t.target.x0,l=u.interpolateNumber(e,n),i=l(.5),r=l(.5),o=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},${o}C${i},${o} ${r},${a} ${n},${a}L${n},${s}C${r},${s} ${i},${c} ${e},${c}Z`)};function Qe(t){var e;const n=t.sankeyWidth/2,i=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,r=t.circularPathData;if(!r)return null;if("down"===t.direction)return null;if(t._circularStub){const e=r.sourceX,i=r.sourceY,o=r.targetX,a=r.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*(r.rightFullExtent-e))),s=Math.max(15,Math.min(40,.33*(o-r.leftFullExtent)));return`M${e},${i-n}L${e+l},${i-n}L${e+l},${i+n}L${e},${i+n}ZM${o},${a-n}L${o-s},${a-n}L${o-s},${a+n}L${o},${a+n}Z`}const o=r.sourceX,a=r.sourceY,l=r.targetX,s=r.targetY,c=r.rightFullExtent,u=r.leftFullExtent,h=r.verticalFullExtent,d="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(i,15));return`M${o},${a-d*n}L${c},${a-d*n}L${c+i},${a-d*n+d*f}L${c+i},${h+d*i-d*f}L${c+i-f},${h+d*i}L${u-i+f},${h+d*i}L${u-i},${h+d*i-d*f}L${u-i},${s-d*n+d*f}L${u-i+f},${s-d*n}L${l},${s-d*n}L${l},${s+d*n}L${u+i},${s+d*n}L${u+i},${h-d*i}L${c-i},${h-d*i}L${c-i},${a+d*n}L${o},${a+d*n}Z`}const Je={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(Pe))-1:0},justify:_e},tn={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var r,o,a,l,s,c,u;if(0===t.length)return;const h="vertical"===n.orientation?"down":"right",d=n.nodeAlign||"justify",f=null!==(r=n.nodeWidth)&&void 0!==r?r:15,y=null!==(o=n.nodePaddingRatio)&&void 0!==o?o:.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"===h?[[0,0],[i[1],i[0]]]:[[0,0],[i[0],i[1]]];const x=Ue().extent(v).links(m).nodes(p).nodeAlign(Je[d]||_e).nodeId(t=>t.id).nodeWidth(f).iterations(g);x.nodePaddingRatio&&x.nodePaddingRatio(y),x();{let t=1/0,e=-1/0,n=1/0,r=-1/0;for(const i of p)t>i.x0&&(t=i.x0),i.x1>e&&(e=i.x1),n>i.y0&&(n=i.y0),i.y1>r&&(r=i.y1);for(const i of m){if(!i.circular||!i.circularPathData)continue;const o=i.circularPathData,a=(null!==(s=null!==(l=i._circularWidth)&&void 0!==l?l:i.width)&&void 0!==s?s:0)/2;t>o.leftFullExtent-a&&(t=o.leftFullExtent-a),o.rightFullExtent+a>e&&(e=o.rightFullExtent+a),n>o.verticalFullExtent-a&&(n=o.verticalFullExtent-a),o.verticalFullExtent+a>r&&(r=o.verticalFullExtent+a)}const o=e-t,a=r-n,u=i[0],h=i[1];if(o>0&&a>0&&(0>t||0>n||e>u||r>h)){const e=Math.min(u/o,h/a),i=-t*e+(u-o*e)/2,r=-n*e+(h-a*e)/2;for(const t of p)t.x0=t.x0*e+i,t.x1=t.x1*e+i,t.y0=t.y0*e+r,t.y1=t.y1*e+r;for(const t of m)if(t.y0=t.y0*e+r,t.y1=t.y1*e+r,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+i,n.targetX=n.targetX*e+i,n.sourceY=n.sourceY*e+r,n.targetY=n.targetY*e+r,n.rightFullExtent=n.rightFullExtent*e+i,n.leftFullExtent=n.leftFullExtent*e+i,n.verticalFullExtent=n.verticalFullExtent*e+r,n.rightInnerExtent=n.rightInnerExtent*e+i,n.leftInnerExtent=n.leftInnerExtent*e+i,n.verticalRightInnerExtent=n.verticalRightInnerExtent*e+r,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*e+r,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,i="object"==typeof e&&null!==e?e.id:e+"",r="object"==typeof n&&null!==n?n.id:n+"",o=k.get(t._edgeKey?t._edgeKey:`${i}\0${r}`);if(o){o.y0=t.y0,o.y1=t.y1,o.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,o.circular=!!t.circular,o.circularPathData=t.circularPathData,o._circularWidth=t._circularWidth,o._circularStub=t._circularStub,o.path=t.path,o.circularLinkType=t.circularLinkType,o.direction=h;const e=b.get(i),n=b.get(r);e&&(o.source=e),n&&(o.target=n)}}},buildScene(t,e,n,i){var o,a,l,s;const c="vertical"===n.orientation?"down":"right",u=n.nodeStyle,h=n.edgeStyle,d=null!==(o=n.edgeOpacity)&&void 0!==o?o:.5,f=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:r.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 i=u?u(e):{},r={fill:i.fill||g.get(e.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity};x.set(e.id,("string"==typeof r.fill?r.fill:null)||g.get(e.id)||"#4d430c"),p.push("down"===c?{type:"rect",x:e.y0,y:e.x0,w:n,h:t,style:r,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:r,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 i="#999";i="function"==typeof f?f(t)||i:"target"===f?x.get(n.id)||g.get(n.id)||i:x.get(e.id)||g.get(e.id)||i;const r=h?h(t):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),s=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),c=r.fill||i;m.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+o},${e.sourceY-n}L${e.sourceX+o},${e.sourceY+n}L${e.sourceX},${e.sourceY+n}Z`,style:{fill:c,fillOpacity:null!==(a=r.fillOpacity)&&void 0!==a?a:d,stroke:"none",opacity:r.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+o}}),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=r.fillOpacity)&&void 0!==l?l:d,stroke:"none",opacity:r.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-s,x1:e.targetX}});continue}let o;if(o=t.circular&&t.circularPathData?Qe(t):Ze(t),!o)continue;const c={fill:r.fill||i,fillOpacity:null!==(s=r.fillOpacity)&&void 0!==s?s:d,stroke:r.stroke||"none",strokeWidth:r.strokeWidth,opacity:r.opacity};m.push({type:"bezier",pathD:o,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,r=n.y1-n.y0;if(0>=t||0>=r)continue;const o=e?e(n):n.id;if(!o)continue;let a,l,s;"down"===c?(a=n.y0+(n.y1-n.y0)/2,l=n.x1+14,s="middle"):(i[0]/2>n.x0+t/2?(a=n.x0-6,s="end"):(a=n.x1+6,s="start"),l=n.y0+r/2),v.push({x:a,y:l,text:o+"",anchor:s,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:p,sceneEdges:m,labels:v}}},en={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var r,o;if(0===t.length)return;const a=null!==(r=n.forceStrength)&&void 0!==r?r:.1,l=i[0]/2,s=i[1]/2,c=n.__previousPositions;let u=0;const d=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),n=null==c?void 0:c.get(e.id);t?u++:n?(e.x=n.x,e.y=n.y,u++):d.push(e)}const f=u>0&&.3>=(t.length>0?d.length/t.length:1);if(f){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of d){const i=nn(t.id,e,n);if(i.length>0){let e=0,n=0;for(const t of i)e+=t.x,n+=t.y;const r=rn(t.id),o=r%360*(Math.PI/180),a=10+r%20;t.x=e/i.length+a*Math.cos(o),t.y=n/i.length+a*Math.sin(o)}else{const e=rn(t.id),n=e%360*(Math.PI/180),i=15+e%30;t.x=l+i*Math.cos(n),t.y=s+i*Math.sin(n)}}}else{const e=2.399963229728653;for(let n=0;t.length>n;n++){const i=t[n];if(null==i.x||null==i.y||0===i.x&&0===i.y){const t=10*Math.sqrt(n+.5),r=n*e;i.x=l+t*Math.cos(r),i.y=s+t*Math.sin(r)}}}const y=null!==(o=n.iterations)&&void 0!==o?o:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),g=f?40:y,p=on(n.nodeSize,n.nodeSizeRange,t),m=t=>p(t),v=h.forceLink().strength(t=>Math.min(2.5,t.weight?t.weight*a:a)).id(t=>t.id),x=h.forceSimulation().force("charge",h.forceManyBody().strength(t=>-25*m(t))).force("center",h.forceCenter(l,s).strength(.8)).force("x",h.forceX(l).strength(.15)).force("y",h.forceY(s).strength(.15));if(x.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));x.force("link",v),x.force("link").links(t)}f?x.alpha(.3):.1>x.alpha()&&x.alpha(1),x.stop();for(let t=0;g>t;++t)x.tick();for(const e of t){if(null==e.x||null==e.y)continue;const t=m(e);e.x=Math.max(t,Math.min(i[0]-t,e.x)),e.y=Math.max(t,Math.min(i[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,i){var o,a,l;const s=n.nodeStyle,c=n.edgeStyle,u=on(n.nodeSize,n.nodeSizeRange,t),h=Array.isArray(n.colorScheme)?n.colorScheme:r.schemeCategory10,d=new Map;t.forEach((t,e)=>{d.set(t.id,h[e%h.length])});const f=[],y=[],g=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=u(e),n=s?s(e):{},i={fill:n.fill||d.get(e.id)||"#007bff",stroke:n.stroke||"#fff",strokeWidth:null!==(o=n.strokeWidth)&&void 0!==o?o:2,opacity:n.opacity};f.push({type:"circle",cx:e.x,cy:e.y,r:t,style:i,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 i=c?c(t):{},r={stroke:i.stroke||"#999",strokeWidth:null!==(a=i.strokeWidth)&&void 0!==a?a:1,opacity:null!==(l=i.opacity)&&void 0!==l?l:.6};y.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:r,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 i=u(n);g.push({x:n.x,y:n.y-i-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var m;return{sceneNodes:f,sceneEdges:y,labels:g}}};function nn(t,e,n){const i=[];for(const r of e){const e="string"==typeof r.source?r.source:r.source.id,o="string"==typeof r.target?r.target:r.target.id;let a=null;if(e===t?a=o:o===t&&(a=e),a){const t=n.get(a);!t||0===t.x&&0===t.y||i.push({x:t.x,y:t.y})}}return i}function rn(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 on(t,e,n){var r,o;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!==(r=a.min(s))&&void 0!==r?r:0,u=null!==(o=a.max(s))&&void 0!==o?o:1;if(c===u)return()=>(l[0]+l[1])/2;const h=i.scaleLinear().domain([c,u]).range(l).clamp(!0);return e=>{var n;const i=null===(n=e.data)||void 0===n?void 0:n[t];return null==i||"number"!=typeof i?l[0]:h(i)}}const an=r.schemeCategory10,ln={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,i){if(0===t.length)return;const{padAngle:r=.01,groupWidth:o=20,sortGroups:a}=n,l=Math.min(i[0],i[1])/2,c=l-o,u=i[0]/2,h=i[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),i=g.get(e);if(void 0===n||void 0===i)continue;const r=f(t);m[n][i]=r}const v=d.chord().padAngle(r);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],i=k.centroid(e);n.x=i[0]+u,n.y=i[1]+h,n.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const w=new Map;for(const e of t)w.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=w.get("string"==typeof t.source?t.source:t.source.id),i=w.get(e);n&&(t.source=n),i&&(t.target=i)}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,i=t[e.target.index].id,r=E.get(`${n}\0${i}`)||E.get(`${i}\0${n}`);r&&(r.chordData=e)}},buildScene(t,e,n,i){var r,o;const{groupWidth:a=20,edgeOpacity:l=.5}=n,s=Math.min(i[0],i[1])/2,c=s-a,u=i[0]/2,h=i[1]/2,f=n.nodeStyle,y=n.edgeStyle,g=n.edgeColorBy||"source",p=Array.isArray(n.colorScheme)?n.colorScheme:an,m=new Map;t.forEach((t,e)=>{m.set(t.id,p[e%p.length])});const v=d.ribbon().radius(c),x=[],b=[],k=[];for(let e=0;t.length>e;e++){const n=t[e],i=n.arcData;if(!i)continue;let o;o=f?f(n).fill||m.get(n.id)||p[e%p.length]:m.get(n.id)||p[e%p.length];const a=f?f(n):{},l={fill:o,stroke:a.stroke||"black",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.opacity};x.push({type:"arc",cx:u,cy:h,innerR:c,outerR:s,startAngle:i.startAngle-Math.PI/2,endAngle:i.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 i=sn(n,u,h);let r="#999";if(y)r=y(t).fill||r;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===g&&n?r=m.get(n.id)||r:e&&(r=m.get(e.id)||r)}const a=y?y(t):{},s={fill:r,fillOpacity:null!==(o=a.fillOpacity)&&void 0!==o?o:l,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};b.push({type:"ribbon",pathD:i,style:s,datum:t})}if(!1!==n.showLabels){const e=(w=n.nodeLabel)?"function"==typeof w?w:t=>t[w]||t.id:null,i=s+12;for(const n of t){const t=n.arcData;if(!t)continue;const r=e?e(n):n.id;if(!r)continue;const o=(t.startAngle+t.endAngle)/2,a=o-Math.PI/2;k.push({x:u+Math.cos(a)*i,y:h+Math.sin(a)*i,text:r+"",anchor:o>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:x,sceneEdges:b,labels:k}}};function sn(t,e,n){const i=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!i)return t;const r=[];let o=0;for(;i.length>o;){const t=i[o];if("M"===t||"L"===t)for(r.push(t),o++;i.length>o&&!isNaN(Number(i[o]));)r.push(Number(i[o])+e+""),o++,i.length>o&&!isNaN(Number(i[o]))&&(r.push(Number(i[o])+n+""),o++);else if("C"===t)for(r.push(t),o++;i.length>o&&!isNaN(Number(i[o]));)for(let t=0;3>t&&i.length>o&&!isNaN(Number(i[o]));t++)r.push(Number(i[o])+e+""),o++,i.length>o&&!isNaN(Number(i[o]))&&(r.push(Number(i[o])+n+""),o++);else if("Q"===t)for(r.push(t),o++;i.length>o&&!isNaN(Number(i[o]));)for(let t=0;2>t&&i.length>o&&!isNaN(Number(i[o]));t++)r.push(Number(i[o])+e+""),o++,i.length>o&&!isNaN(Number(i[o]))&&(r.push(Number(i[o])+n+""),o++);else if("A"===t)for(r.push(t),o++;i.length>o&&!isNaN(Number(i[o]));)r.push(i[o++]),i.length>o&&r.push(i[o++]),i.length>o&&r.push(i[o++]),i.length>o&&r.push(i[o++]),i.length>o&&r.push(i[o++]),i.length>o&&(r.push(Number(i[o])+e+""),o++),i.length>o&&(r.push(Number(i[o])+n+""),o++);else"Z"===t||"z"===t?(r.push(t),o++):(r.push(i[o]),o++)}return r.join(" ")}function cn(t){const[e,n,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]}(t);return.299*e+.587*n+.114*i>150?"#222":"#fff"}const un={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,i){var r;const o=n.__hierarchyRoot;if(!o)return;const a=n.chartType,s=(c=n.childrenAccessor)?"function"==typeof c?c:t=>t[c]:void 0;var c;const u=n.hierarchySum||(t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0}),h=l.hierarchy(o,s);h.sum(u),h.sort((t,e)=>{var n,i;return(null!==(n=e.value)&&void 0!==n?n:0)-(null!==(i=t.value)&&void 0!==i?i:0)});const[d,f]=i;switch(a){case"tree":!function(t,e,n,i){const r=e.treeOrientation||"vertical",o=l.tree();o.size("horizontal"===r?[i,n]:"radial"===r?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),o(t)}(h,n,d,f);break;case"cluster":!function(t,e,n,i){const r=e.treeOrientation||"vertical",o=l.cluster();o.size("horizontal"===r?[i,n]:"radial"===r?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),o(t)}(h,n,d,f);break;case"treemap":!function(t,e,n,i){var r,o;const a=null!==(r=e.padding)&&void 0!==r?r:4,s=null!==(o=e.paddingTop)&&void 0!==o?o:0,c=l.treemap().size([n,i]).tile(l.treemapBinary).padding(a);s>0&&c.paddingTop(s),c(t)}(h,n,d,f);break;case"circlepack":!function(t,e,n,i){var r;const o=null!==(r=e.padding)&&void 0!==r?r:4;l.pack().size([n,i]).padding(o)(t)}(h,n,d,f);break;case"partition":!function(t,e,n,i){var r;l.partition().size([n,i]).padding(null!==(r=e.padding)&&void 0!==r?r:1)(t)}(h,n,d,f)}const y=h.descendants();t.length=0,e.length=0;const g=new Map;for(let e=0;y.length>e;e++){const i=y[e],o={id:gn(i,n,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(r=i.value)&&void 0!==r?r:0,depth:i.depth,data:i.data,createdByFrame:!0};"tree"===a||"cluster"===a?hn(o,i,n):"treemap"===a||"partition"===a?dn(o,i):"circlepack"===a&&fn(o,i),o.__hierarchyNode=i,t.push(o),g.set(i,o)}if("tree"===a||"cluster"===a)for(const t of y)if(t.parent){const n=g.get(t.parent),i=g.get(t);n&&i&&e.push({source:n,target:i,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,i){const r=n.nodeStyle||(()=>({})),o=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,i,r,o){var a,l,s,c,u;const h=[],d=[],f=[],y=n.treeOrientation||"vertical",g="radial"===y,p=i[0]/2,m=i[1]/2,v="number"==typeof(b=n.nodeSize)?b:5,x=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];var b;for(const e of t){let t=e.x,i=e.y;g&&(t+=p,i+=m);const o=r(e);let l=o.fill||"#4d430c";n.colorByDepth&&void 0!==e.depth&&(l=x[e.depth%x.length]);const s={fill:l,stroke:o.stroke||"#fff",strokeWidth:null!==(a=o.strokeWidth)&&void 0!==a?a:1,opacity:o.opacity};h.push({type:"circle",cx:t,cy:i,r:v,style:s,datum:e,id:e.id,label:e.id,depth:e.depth})}const k=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 i=e.x,r=e.y,a=n.x,l=n.y;g&&(i+=p,r+=m,a+=p,l+=m);const u=yn(i,r,a,l,y),h=o(t),f={fill:"none",stroke:h.stroke||"#999",strokeWidth:null!==(s=h.strokeWidth)&&void 0!==s?s:1.5,opacity:null!==(c=h.opacity)&&void 0!==c?c:k};d.push({type:"curved",pathD:u,style:f,datum:t})}if(!1!==n.showLabels){const e=pn(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let i,r,o,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?(i=a+t/n*10,r=l+e/n*10,o=0>t?"end":"start"):(i=a,r=l-12,o="middle")}else"horizontal"===y?((null===(u=n.data)||void 0===u?void 0:u.children)&&0!==n.data.children.length?(i=a-v-6,o="end"):(i=a+v+6,o="start"),r=l):(i=a,r=l+v+14,o="middle");f.push({x:i,y:r,text:t+"",anchor:o,baseline:"middle",fontSize:11})}}return{sceneNodes:h,sceneEdges:d,labels:f}}(t,e,n,i,r,o);case"treemap":case"partition":return function(t,e,n,i){var r,o;const a=[],l=[],s=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of t){const t=n.x1-n.x0,o=n.y1-n.y0;if(0>=t||0>=o)continue;const l=i(n);let c=l.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(c=s[n.depth%s.length]);const u={fill:c,stroke:l.stroke||"#fff",strokeWidth:null!==(r=l.strokeWidth)&&void 0!==r?r:1,opacity:l.opacity};a.push({type:"rect",x:n.x0,y:n.y0,w:t,h:o,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=pn(e.nodeLabel),r=e.labelMode||"leaf",a="partition"===e.chartType;for(const c of t){const t=c.x1-c.x0,u=c.y1-c.y0;if(0>=t||0>=u)continue;const h=!((null===(o=c.data)||void 0===o?void 0:o.children)&&c.data.children.length>0);if(!a){if("leaf"===r&&!h)continue;if("parent"===r&&h)continue}const d=n?n(c):c.id;if(!d)continue;if((h?30:40)>t||(h?16:14)>u)continue;let f=i(c).fill||"#4d430c";e.colorByDepth&&void 0!==c.depth&&(f=s[c.depth%s.length]);const y=cn(f);l.push(h?{x:c.x0+t/2,y:c.y0+u/2,text:d+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,u)/6)),fill:y}:{x:c.x0+4,y:c.y0+12,text:d+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:y})}}return{sceneNodes:a,sceneEdges:[],labels:l}}(t,n,0,r);case"circlepack":return function(t,e,n,i){var r,o,a,l,s;const c=[],u=[],h=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of t){const t=null!==(r=n.__radius)&&void 0!==r?r:5;if(0>=t)continue;const l=i(n);let s=l.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(s=h[n.depth%h.length]);const u={fill:s,stroke:l.stroke||"#fff",strokeWidth:null!==(o=l.strokeWidth)&&void 0!==o?o: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=pn(e.nodeLabel);for(const r of t){const t=null!==(l=r.__radius)&&void 0!==l?l:5,o=n?n(r):r.id;if(!o)continue;if(15>t)continue;const a=!((null===(s=r.data)||void 0===s?void 0:s.children)&&r.data.children.length>0);let c=i(r).fill||"#4d430c";if(e.colorByDepth&&void 0!==r.depth&&(c=h[r.depth%h.length]),a){const e=cn(c);u.push({x:r.x,y:r.y,text:o+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:e})}else u.push({x:r.x,y:r.y-t+14,text:o+"",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,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function hn(t,e,n){const i=n.treeOrientation||"vertical";if("radial"===i){const n=e.x,i=e.y;t.x=i*Math.cos(n-Math.PI/2),t.y=i*Math.sin(n-Math.PI/2)}else"horizontal"===i?(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 dn(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 fn(t,e){var n;const i=null!==(n=e.r)&&void 0!==n?n:0;t.x=e.x,t.y=e.y,t.x0=e.x-i,t.x1=e.x+i,t.y0=e.y-i,t.y1=e.y+i,t.width=2*i,t.height=2*i,t.__radius=i}function yn(t,e,n,i,r){if("horizontal"===r){const r=(t+n)/2;return`M ${t},${e} C ${r},${e} ${r},${i} ${n},${i}`}if("radial"===r){const r=(t+n)/2;return`M ${t},${e} Q ${r},${e} ${r},${(e+i)/2} T ${n},${i}`}{const r=(e+i)/2;return`M ${t},${e} C ${t},${r} ${n},${r} ${n},${i}`}}function gn(t,e,n){const i=e.nodeIDAccessor;return"function"==typeof i?i(t.data)+"":"string"==typeof i&&void 0!==t.data[i]?t.data[i]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function pn(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 mn(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const vn={sankey:tn,force:en,chord:ln,tree:un,cluster:un,treemap:un,circlepack:un,partition:un,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,i){const r=n.__hierarchyRoot;r&&function(t,e,n,i,r){var o,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),h=null!==(o=n.orbitSize)&&void 0!==o?o:2.95,d=null!==(a=n.orbitEccentricity)&&void 0!==a?a:1,f="number"==typeof h?()=>h:h,y="number"==typeof d?()=>d:d,g=mn(n);g.metaMap.clear(),i.length=0,r.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));i.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,o,a,h,d,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:d,data:e,parentId:n},S=p?h/f(M)*A:h*A,P=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=(_[e].startAngle+_[e].endAngle)/2,s=w[e],u=m(c(s)),h=o+S*Math.sin(l),f=a+S*Math.cos(l)*C;i.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:d,data:s}),g.metaMap.set(u,{ring:S,angle:l,depth:d,parentId:n,eccentricity:C}),r.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),t(s,u,h,f,S,d+1,!0)}E+=k}}(t,k,v,x,b,1,!1)}(r,i,n,t,e)},buildScene(t,e,n,i){var r,o,a,l,s;const c=n.nodeStyle,u=n.nodeSize,h="number"==typeof u?()=>u:"function"==typeof u?u:()=>6,d=[],f=[],y=[];if(!1!==n.orbitShowRings){const e=mn(n),i=new Map;for(const e of t)i.set(e.id,e);const r=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=i.get(t.parentId);if(!e)continue;const n=`${t.parentId}:${t.ring}`;r.has(n)||r.set(n,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const o=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:n,ecc:i}]of r)for(let r=0;o>r;r++){const l=r/o*Math.PI*2,s=(r+1)/o*Math.PI*2;f.push({type:"line",x1:t+n*Math.sin(l),y1:e+n*Math.cos(l)*i,x2:t+n*Math.sin(s),y2:e+n*Math.cos(s)*i,style:a,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=h(e),n=c?c(e):{},i={fill:n.fill||"#6366f1",stroke:n.stroke||"#fff",strokeWidth:null!==(r=n.strokeWidth)&&void 0!==r?r:1,opacity:null!==(o=n.opacity)&&void 0!==o?o:0===(null!==(a=e.depth)&&void 0!==a?a:0)?1:.85};d.push({type:"circle",cx:e.x,cy:e.y,r:t,style:i,datum:e,id:e.id,label:e.id,depth:e.depth})}const g=new Map;for(const e of t)g.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:g.get(t.source),n="object"==typeof t.target?t.target:g.get(t.target);e&&n&&(null!=e.x&&null!=n.x&&f.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(n.showLabels){const e=n.nodeLabel;for(const n of t){const t=h(n);if(4>=t)continue;const i="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:i+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:d,sceneEdges:f,labels:y}},tick:(t,e,n,i,r)=>!1!==n.orbitAnimated&&(function(t,e){var n,i;const r=mn(e),o=null!==(n=e.orbitSpeed)&&void 0!==n?n:.25,a=null!==(i=e.orbitRevolution)&&void 0!==i?i: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())-r.startTime)/1e3,s=o*(Math.PI/6),c=new Map;for(const e of t)c.set(e.id,e);for(const e of t){const t=r.metaMap.get(e.id);if(!t||!t.parentId)continue;const n=c.get(t.parentId);if(!n)continue;const i=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(i),e.y=n.y+t.ring*Math.cos(i)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,n),!0)}};function xn(t){return vn[t]}class bn{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({},le),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&(this.particlePool=new ce(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({},le),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&!this.particlePool&&(this.particlePool=new ce(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:i="id",sourceAccessor:r="source",targetAccessor:o="target",valueAccessor:a="value"}=this.config,l="function"==typeof i?i:t=>t[i],s="function"==typeof r?r:t=>t[r],c="function"==typeof o?o:t=>t[o],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({},kn(t)),{data:e}))}for(let t=0;e.length>t;t++){const n=e[t],i=s(n)+"",r=c(n)+"",o=Number(u(n))||1;this.nodes.has(i)||this.nodes.set(i,Object.assign(Object.assign({},kn(i)),{data:n})),this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},kn(r)),{data:n}));const a=`${i}\0${r}\0${t}`;this.edges.set(a,{source:i,target:r,value:o,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:i}=t,r=0===this.nodes.size;let o=!1;const a="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=a,this._decaySortedNodes=null,this.nodes.has(e)||(this.nodes.set(e,kn(e)),this.nodeTimestamps.set(e,a),this.tension+=this.tensionConfig.newNode,o=!0),this.nodes.has(n)||(this.nodes.set(n,kn(n)),this.nodeTimestamps.set(n,a),this.tension+=this.tensionConfig.newNode,o=!0);const l=this.edgeKey(e,n),s=this.edges.get(l);let c=!1;return s?(s.value+=i,this.edgeTimestamps.set(l,a),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(l,{source:e,target:n,value:i,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(l,a),this.tension+=this.tensionConfig.newEdge,o=!0),r||o||c||this.tension>=this.tensionConfig.threshold}runLayout(t){var e,n,i,r,o,a;const l=xn(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!==(i=l._prevY1)&&void 0!==i?i:0)-(null!==(r=l._prevY0)&&void 0!==r?r:0);t.set(l.id,{x:(null!==(o=l._prevX0)&&void 0!==o?o: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 h=new Set(this.nodes.keys()),d=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of h)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)h.has(t)||this.removedNodes.add(t);for(const t of d)this.previousEdgeKeys.has(t)||this.addedEdges.add(t);for(const t of this.previousEdgeKeys)d.has(t)||this.removedEdges.add(t);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=h,this.previousEdgeKeys=d,this.layoutVersion++}buildScene(t){const e=xn(this.config.chartType);if(!e)return;const n=Array.from(this.nodes.values()),i=Array.from(this.edges.values()),{sceneNodes:r,sceneEdges:o,labels:a}=e.buildScene(n,i,this.config,t);this.sceneNodes=r,this.sceneEdges=o,this.labels=a}get isAnimating(){const t=xn(this.config.chartType);return!!(null==t?void 0:t.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(t,e){const n=xn(this.config.chartType);if(!(null==n?void 0:n.tick))return!1;const i=Array.from(this.nodes.values()),r=Array.from(this.edges.values());return n.tick(i,r,this.config,t,e)}advanceTransition(t){if(!this.transition)return!1;const e=$(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=W(t._prevX0,t._targetX0,n),t.x1=W(t._prevX1,t._targetX1,n),t.y0=W(t._prevY0,t._targetY0,n),t.y1=W(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=W(t._prevY0,t._targetY0,n),t.y1=W(t._prevY1,t._targetY1,n),t.sankeyWidth=W(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 i=(t.sankeyWidth||1)/2;if("down"===t.direction){const r=e.x1,o=n.x0,a=u.interpolateNumber(r,o);return{circular:!1,points:[{x:t.y0,y:r},{x:t.y0,y:a(.5)},{x:t.y1,y:a(.5)},{x:t.y1,y:o}],halfWidth:i}}const r=e.x1,o=n.x0,a=u.interpolateNumber(r,o);return{circular:!1,points:[{x:r,y:t.y0},{x:a(.5),y:t.y0},{x:a(.5),y:t.y1},{x:o,y:t.y1}],halfWidth:i}}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))),i=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-i,y:n.targetY},{x:n.targetX-.66*i,y:n.targetY},{x:n.targetX-.33*i,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:e}}let i;i="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 r=[];for(let t=0;i.length-1>t;t++){const e=i[t],n=i[t+1],o=n.x-e.x,a=n.y-e.y;r.push([e,{x:e.x+o/3,y:e.y+a/3},{x:e.x+2*o/3,y:e.y+2*a/3},n])}return{circular:!0,segments:r,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,i,r,o;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!==(i=a.glowRadius)&&void 0!==i?i:4;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const i=this.nodeTimestamps.get(n);if(!i)continue;const r=t-i;l>r&&(e._pulseIntensity=1-r/l,e._pulseColor=s,e._pulseGlowRadius=c)}for(const e of this.sceneEdges){const n=e.datum;if(!n)continue;const i="object"==typeof n.source?null===(r=n.source)||void 0===r?void 0:r.id:n.source,a="object"==typeof n.target?null===(o=n.target)||void 0===o?void 0:o.id:n.target;if(!i||!a)continue;const c=this.edgeTimestamps.get(`${i}\0${a}`);if(!c)continue;const u=t-c;l>u&&(e._pulseIntensity=1-u/l,e._pulseColor=s)}}applyDecay(){var t,e,n,i,r;const o=this.config.decay;if(!o)return;const a=null!==(t=o.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 h=l-1-u;let d;switch(o.type){case"linear":d=a+(1-h/(l-1))*(1-a);break;case"exponential":{const t=null!==(e=o.halfLife)&&void 0!==e?e:l/2;d=a+Math.pow(.5,h/t)*(1-a);break}case"step":d=(null!==(n=o.stepThreshold)&&void 0!==n?n:.5*l)>h?1:a;break;default:d=1}const f=null!==(r=null===(i=t.style)||void 0===i?void 0:i.opacity)&&void 0!==r?r:1;t.style=Object.assign(Object.assign({},t.style),{opacity:f*d})}}applyTopologyDiff(t){var e;if(0===this.addedNodes.size)return;const n=t-this.lastTopologyChangeTime;if(n>=2e3)return;const i=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,i),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 i=this.config.thresholds;if(!i)return;const r=null!==(e=i.warningColor)&&void 0!==e?e:"#f59e0b",o=null!==(n=i.criticalColor)&&void 0!==n?n:"#ef4444",a=!1!==i.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=i.metric(l);let c=null;void 0===i.critical||i.critical>s?void 0===i.warning||i.warning>s||(c=r):c=o,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 kn(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 wn(t,e,n,i,r=30){let o=null,a=r,l=1/0;for(const e of t){const t=En(e,n,i);if(t)if("rect"===e.type){const n=e.w*e.h;l>n&&(o=t,l=n)}else a>t.distance&&(o=t,a=t.distance)}if(o)return o;for(const t of e){const e=Pn(t,n,i);e&&a>e.distance&&(o=e,a=e.distance)}return o}function En(t,e,n){switch(t.type){case"circle":return function(t,e,n){const i=e-t.cx,r=n-t.cy,o=Math.sqrt(i*i+r*r);return o>Math.max(t.r,5)+5?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:o}}(t,e,n);case"rect":return function(t,e,n){const i=N(e,n,t);return i.hit?{type:"node",datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}(t,e,n);case"arc":return function(t,e,n){const i=e-t.cx,r=n-t.cy,o=Math.sqrt(i*i+r*r);if(t.innerR-2>o||o>t.outerR+2)return null;const a=z(Math.atan2(r,i)),l=z(t.startAngle),s=z(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 An=null,Mn=null;function Sn(){return Mn||(An=document.createElement("canvas"),An.width=1,An.height=1,Mn=An.getContext("2d")),Mn}function Pn(t,e,n){switch(t.type){case"bezier":return function(t,e,n){var i,r;if(!t.pathD)return null;try{const o=new Path2D(t.pathD),a=Sn();if(!a)return null;if(a.isPointInPath(o,e,n)){const o="object"==typeof(null===(i=t.datum)||void 0===i?void 0:i.source)?t.datum.source:null,a="object"==typeof(null===(r=t.datum)||void 0===r?void 0:r.target)?t.datum.target:null;return{type:"edge",datum:t.datum,x:o&&a?(o.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(o,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 i=t.x2-t.x1,r=t.y2-t.y1,o=i*i+r*r;if(0===o)return null;let a=((e-t.x1)*i+(n-t.y1)*r)/o;a=Math.max(0,Math.min(1,a));const l=t.x1+a*i,s=t.y1+a*r,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 i=new Path2D(t.pathD),r=Sn();if(!r)return null;if(r.isPointInPath(i,e,n))return{type:"edge",datum:t.datum,x:e,y:n,distance:0};const o=r.lineWidth;r.lineWidth=10;const a=r.isPointInStroke(i,e,n);if(r.lineWidth=o,a)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch(t){}return null}(t,e,n);default:return null}}function _n(t){const{width:e,height:n,totalWidth:i,totalHeight:r,margin:o,labels:a,title:l,legend:s,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d,legendPosition:f="right",foregroundGraphics:y,sceneNodes:p,annotations:m,svgAnnotationRules:v}=t;return g.createElement(g.Fragment,null,g.createElement("svg",{role:"img",width:i,height:r,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(${o.left},${o.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,i)=>{if(v){const r=v(t,i,{width:e,height:n,sceneNodes:p});if(r)return g.createElement(g.Fragment,{key:"annotation-"+i},r)}return null}),y),l&&"string"==typeof l?g.createElement("text",{x:i/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},l):l?g.createElement("foreignObject",{x:0,y:0,width:i,height:o.top},l):null,et({legend:s,totalWidth:i,totalHeight:r,margin:o,legendPosition:f,title:l,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d})),null==m?void 0:m.filter(t=>"widget"===t.type&&t.nodeId&&p).map((t,e)=>{var n,i,r,a,l,s,c,u,h;const d=p.find(e=>{var n,i,r,o,a;return e.id===t.nodeId||(null===(n=e.datum)||void 0===n?void 0:n.id)===t.nodeId||(null===(r=null===(i=e.datum)||void 0===i?void 0:i.data)||void 0===r?void 0:r.id)===t.nodeId||(null===(a=null===(o=e.datum)||void 0===o?void 0:o.data)||void 0===a?void 0:a.name)===t.nodeId});if(!d)return null;const f=o.left+(null!==(n=d.cx)&&void 0!==n?n:null!=d.x&&null!=d.w?d.x+d.w/2:null!==(i=d.x)&&void 0!==i?i:0),y=o.top+(null!==(r=d.cy)&&void 0!==r?r:null!=d.y&&null!=d.h?d.y+d.h/2:null!==(a=d.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!==(h=t.content)&&void 0!==h?h:g.createElement("span",{style:{fontSize:18,cursor:"default"}},"ℹ️");return g.createElement("div",{key:"widget-"+e,style:{position:"absolute",left:f+m-x/2,top:y+v-b/2,width:x,height:b,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5}},k)}))}function Cn(t,e){var n,i,r,o,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 r=t.createLinearGradient(a.x0,0,a.x1,0),o=null!==(i=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==i?i:.5,l="string"==typeof e.style.fill?e.style.fill:"#999";r.addColorStop(0,1===a.from?l:"transparent"),r.addColorStop(1,1===a.to?l:"transparent"),t.fillStyle=r,t.globalAlpha=o}else t.fillStyle=e.style.fill,t.globalAlpha=null!==(o=null!==(r=e.style.fillOpacity)&&void 0!==r?r:e.style.opacity)&&void 0!==o?o:.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 Ln(t,e){var n,i;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!==(i=e.style.strokeWidth)&&void 0!==i?i: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 Dn(t,e){var n,i,r,o;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!==(i=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==i?i:.5,t.fill(a)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(r=e.style.strokeWidth)&&void 0!==r?r:.5,t.globalAlpha=.3*(null!==(o=e.style.opacity)&&void 0!==o?o: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 Tn(t,e){var n,i;if(!e.pathD)return;t.save();const r=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(r),e.style.fill&&"none"!==e.style.fill&&(t.fillStyle=e.style.fill,t.globalAlpha=null!==(i=e.style.fillOpacity)&&void 0!==i?i:.1,t.fill(r)),t.restore()}_n.displayName="NetworkSVGOverlay";const $n={top:20,right:80,bottom:20,left:80},Wn={top:40,right:40,bottom:40,left:40},On=new Set(["chord","force","circlepack","orbit"]),Nn=[800,600],zn={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 In({data:t}){var e,n,i,r,o,a;if("edge"===t.type){const e=t.data;return g.createElement("div",{className:"semiotic-tooltip",style:zn},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 o=s;for(;o;){const a=null!==(r=null!==(n=null===(e=o.data)||void 0===e?void 0:e.name)&&void 0!==n?n:null===(i=o.data)||void 0===i?void 0:i.id)&&void 0!==r?r:l.id;null!=a&&t.unshift(a+""),o=o.parent}t.length>1&&t.shift();const a=t.length-1;return g.createElement("div",{className:"semiotic-tooltip",style:zn},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===(o=l.sourceLinks)||void 0===o?void 0:o.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:zn},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 Rn=t.forwardRef(function(e,n){var i,r,o,a,l,c,u,h,d,f,y;const{chartType:p,nodes:m,edges:v,data:x,initialEdges:b,nodeIDAccessor:k="id",sourceAccessor:w="source",targetAccessor:E="target",valueAccessor:A="value",childrenAccessor:M,hierarchySum:S,orientation:P="horizontal",nodeAlign:_="justify",nodePaddingRatio:C=.05,nodeWidth:D=15,iterations:T=300,forceStrength:$=.1,padAngle:W=.01,groupWidth:O=20,sortGroups:N,edgeSort:z,treeOrientation:I="vertical",edgeType:R="curve",padding:B,paddingTop:j,tensionConfig:F,showParticles:Y=!1,particleStyle:H,nodeStyle:X,edgeStyle:K,colorBy:U,colorScheme:Z="category10",edgeColorBy:Q="source",edgeOpacity:J=.5,colorByDepth:tt=!1,nodeSize:et=8,nodeSizeRange:nt=[5,20],nodeLabel:it,showLabels:rt=!0,labelMode:ot,size:at=Nn,responsiveWidth:lt,responsiveHeight:st,margin:ct,className:ut,background:ht,enableHover:dt=!0,tooltipContent:ft,customHoverBehavior:yt,customClickBehavior:gt,onObservation:pt,chartId:mt,onTopologyChange:vt,annotations:kt,svgAnnotationRules:wt,legend:At,legendPosition:Pt,legendHoverBehavior:_t,legendClickBehavior:Ct,legendHighlightedCategory:Lt,legendIsolatedCategories:Dt,title:Tt,foregroundGraphics:Nt,backgroundGraphics:zt,decay:It,pulse:Rt,staleness:Ft,thresholds:Yt,accessibleTable:Ht,orbitMode:Xt,orbitSize:Gt,orbitSpeed:qt,orbitRevolution:Vt,orbitRevolutionStyle:Kt,orbitEccentricity:Ut,orbitShowRings:Zt,orbitAnimated:Qt}=e,Jt=On.has(p)?Wn:$n,[te,ee]=q(at,lt,st),ne=Object.assign(Object.assign({},Jt),ct),ie=ee[0]-ne.left-ne.right,re=ee[1]-ne.top-ne.bottom,oe="function"==typeof Nt?Nt({size:ee,margin:ne}):Nt,ae=t.useMemo(()=>Object.assign(Object.assign({},le),F),[F]),ce=t.useMemo(()=>Object.assign(Object.assign({},se),H),[H]),ue=t.useMemo(()=>({chartType:p,nodeIDAccessor:k,sourceAccessor:w,targetAccessor:E,valueAccessor:A,childrenAccessor:M,hierarchySum:S,orientation:P,nodeAlign:_,nodePaddingRatio:C,nodeWidth:D,iterations:T,forceStrength:$,padAngle:W,groupWidth:O,sortGroups:N,edgeSort:z,treeOrientation:I,edgeType:R,padding:B,paddingTop:j,tensionConfig:ae,showParticles:Y,particleStyle:ce,nodeStyle:X,edgeStyle:K,nodeLabel:it,showLabels:rt,labelMode:ot,colorBy:U,colorScheme:Z,edgeColorBy:Q,edgeOpacity:J,colorByDepth:tt,nodeSize:et,nodeSizeRange:nt,decay:It,pulse:Rt,staleness:Ft,thresholds:Yt,orbitMode:Xt,orbitSize:Gt,orbitSpeed:qt,orbitRevolution:Vt,orbitRevolutionStyle:Kt,orbitEccentricity:Ut,orbitShowRings:Zt,orbitAnimated:Qt}),[p,k,w,E,A,M,S,P,_,C,D,T,$,W,O,N,z,I,R,B,j,ae,Y,ce,X,K,it,rt,ot,U,Z,Q,J,tt,et,nt,It,Rt,Ft,Yt,Xt,Gt,qt,Vt,Kt,Ut,Zt,Qt]),he=t.useRef(null),de=t.useRef(0),fe=t.useRef(0),ye=t.useRef(!0),ge=$t(t=>t.theme),pe=t.useRef(()=>{}),me=t.useRef(null);me.current||(me.current=new bn(ue));const[ve,xe]=t.useState(null),[be,ke]=t.useState(0),[we,Ee]=t.useState(0),[Ae,Me]=t.useState(!1),Se=t.useRef(null),Pe=t.useRef(new Map),_e=t.useRef(0),Ce=t.useCallback(t=>{if("function"==typeof U)return U(t)+"";if("string"==typeof U&&t.data){const e=t.data[U];if(void 0!==e){if(!Pe.current.has(e+"")){const t=Array.isArray(Z)?Z:L;Pe.current.set(e+"",t[_e.current++%t.length])}return Pe.current.get(e+"")}}if(Pe.current.has(t.id))return Pe.current.get(t.id);const e=Array.isArray(Z)?Z:L,n=U?e[_e.current++%e.length]:e[0];return Pe.current.set(t.id,n),n},[U,Z]),Le=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?Ce(n):e?Ce(e):"#999"},[Q,Ce]),De=t.useCallback(t=>{if(!(null==H?void 0:H.colorBy))return Le(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===ce.colorBy&&n?Ce(n):e?Ce(e):"#999"},[null==H?void 0:H.colorBy,ce.colorBy,Ce,Le]),Te="sankey"===p&&Y||!!Rt||null!==(r=null===(i=me.current)||void 0===i?void 0:i.isAnimating)&&void 0!==r&&r,$e=t.useCallback(()=>{de.current&&!Te||de.current||(de.current=requestAnimationFrame(()=>pe.current()))},[Te]);t.useEffect(()=>{var t;null===(t=me.current)||void 0===t||t.updateConfig(ue),ye.current=!0,$e()},[ue,$e]),t.useEffect(()=>{ye.current=!0,$e()},[ge,$e]);const We=t.useCallback(()=>{var t;const e=me.current;if(!e)return;e.runLayout([ie,re]),e.buildScene([ie,re]),ye.current=!0;for(const n of e.sceneNodes)n.id&&"string"==typeof(null===(t=n.style)||void 0===t?void 0:t.fill)&&Pe.current.set(n.id,n.style.fill);const n=Array.isArray(Z)?Z:L,i=Array.from(e.nodes.values());for(let t=0;i.length>t;t++){const e=i[t];Pe.current.has(e.id)||Pe.current.set(e.id,n[t%n.length])}if(_e.current=i.length,ke(e.layoutVersion),vt){const{nodes:t,edges:n}=e.getLayoutData();vt(t,n)}},[ie,re,vt,Z]),Oe=t.useCallback(t=>{const e=me.current;e&&(e.ingestEdge(t)&&We(),$e())},[We,$e]),Ne=t.useCallback(t=>{const e=me.current;if(!e)return;let n=!1;for(const i of t)e.ingestEdge(i)&&(n=!0);n&&We(),$e()},[We,$e]),ze=t.useCallback(()=>{var t;null===(t=me.current)||void 0===t||t.clear(),Pe.current.clear(),_e.current=0,ke(0),xe(null),Se.current=null,ye.current=!0,$e()},[$e]),Ie=t.useCallback(()=>{const t=me.current;t&&(t.tension+=999,We(),$e())},[We,$e]);t.useImperativeHandle(n,()=>({push:Oe,pushMany:Ne,clear:ze,getTopology:()=>{var t,e;return null!==(e=null===(t=me.current)||void 0===t?void 0:t.getLayoutData())&&void 0!==e?e:{nodes:[],edges:[]}},getTopologyDiff:()=>{const t=me.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:Ie,getTension:()=>{var t,e;return null!==(e=null===(t=me.current)||void 0===t?void 0:t.tension)&&void 0!==e?e:0}}),[Oe,Ne,ze,Ie]);const Re=["tree","cluster","treemap","circlepack","partition","orbit"].includes(p),Be=Re?x||(Array.isArray(v)?void 0:v):void 0;t.useEffect(()=>{var t;const e=me.current;if(e)if(Re&&Be)e.ingestHierarchy(Be,[ie,re]),e.buildScene([ie,re]),ye.current=!0,$e();else{const n=m||[],i=Array.isArray(v)?v:[];if(0===n.length&&0===i.length)return;e.ingestBounded(n,i,[ie,re]),e.buildScene([ie,re]);for(const n of e.sceneNodes)n.id&&(null===(t=n.style)||void 0===t?void 0:t.fill)&&Pe.current.set(n.id,n.style.fill+"");const r=Array.isArray(Z)?Z:L,o=Array.from(e.nodes.values());for(let t=0;o.length>t;t++){const e=o[t];Pe.current.has(e.id)||Pe.current.set(e.id,r[t%r.length])}_e.current=o.length,ye.current=!0,$e()}},[m,v,x,Be,Re,ie,re,ue,$e,Z]),t.useEffect(()=>{b&&b.length>0&&Ne(b)},[]);const je=t.useCallback(t=>{if(yt&&yt(t),pt){const e=Date.now();pt(t?{type:"hover",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:mt}:{type:"hover-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:mt})}},[yt,pt,mt]),Fe=t.useCallback(t=>{if(gt&>(t),pt){const e=Date.now();pt(t?{type:"click",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:mt}:{type:"click-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:mt})}},[gt,pt,mt]),Ye=t.useRef(()=>{}),He=t.useRef(()=>{});Ye.current=t=>{if(!dt)return;const e=he.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-ne.left,r=t.clientY-n.top-ne.top;if(0>i||i>ie||0>r||r>re)return void(Se.current&&(Se.current=null,xe(null),je&&(je(null),ye.current=!0),$e()));const o=me.current;if(!o)return;const a=wn(o.sceneNodes,o.sceneEdges,i,r);if(!a)return void(Se.current&&(Se.current=null,xe(null),je&&(je(null),ye.current=!0),$e()));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});Se.current=s,xe(s),je&&(je(s),ye.current=!0),$e()},He.current=()=>{Se.current&&(Se.current=null,xe(null),je&&(je(null),ye.current=!0),$e())};const Xe=t.useRef(()=>{});Xe.current=t=>{if(!gt&&!pt)return;const e=he.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-ne.left,r=t.clientY-n.top-ne.top;if(0>i||i>ie||0>r||r>re)return;const o=me.current;if(!o)return;const a=wn(o.sceneNodes,o.sceneEdges,i,r);if(a){const t=a.datum||{};Fe(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 Fe(null)},t.useCallback(t=>Ye.current(t),[]);const Ge=t.useCallback(()=>He.current(),[]),qe=t.useCallback(t=>Xe.current(t),[]),Ve=t.useRef(-1),Ke=t.useCallback(t=>{const e=me.current;if(!e)return;const n=function(t){const e=[];for(const n of t)"circle"===n.type&&null!=n.cx?e.push({x:n.cx,y:n.cy,datum:n.datum}):"rect"===n.type&&null!=n.x?e.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum}):"arc"===n.type&&null!=n.cx&&e.push({x:n.cx,y:n.cy,datum:n.datum});return e.sort((t,e)=>t.x-e.x||t.y-e.y),e}(e.sceneNodes);if(0===n.length)return;const i=Ve.current,r=G(t.key,0>i?-1:i,n.length);if(null===r)return;if(t.preventDefault(),0>r)return Ve.current=-1,Se.current=null,xe(null),je&&(je(null),ye.current=!0),void $e();const o=0>i?0:r;Ve.current=o;const a=n[o],l=a.datum||{},s=Object.assign(Object.assign({},"object"!=typeof l||null===l||Array.isArray(l)?{}:l),{type:"node",data:l,x:a.x,y:a.y});Se.current=s,xe(s),je&&(je(s),ye.current=!0),$e()},[je,$e]),Ue=t.useCallback(t=>{Ve.current=-1,Ye.current(t)},[]);pe.current=()=>{var t,e,n,i,r,o,a;de.current=0;const l=he.current;if(!l)return;const s=l.getContext("2d");if(!s)return;const c=me.current;if(!c)return;const u=performance.now(),h=fe.current?Math.min((u-fe.current)/1e3,.1):.016;fe.current=u;const d=c.advanceTransition(u),f=c.tickAnimation([ie,re],h);(d||ye.current||f)&&c.buildScene([ie,re]);const y=Ot();if(!Wt(l,ee,ne,y))return;s.clearRect(-ne.left,-ne.top,ee[0],ee[1]),ht&&(s.fillStyle=ht,s.fillRect(0,0,ie,re)),It&&c.applyDecay(),Rt&&c.applyPulse(u),Yt&&c.applyThresholds(u),c.applyTopologyDiff(u);const g=null!==(t=null==Ft?void 0:Ft.threshold)&&void 0!==t?t:5e3,p=Ft&&c.lastIngestTime>0&&u-c.lastIngestTime>g;if(p&&(s.globalAlpha=null!==(e=null==Ft?void 0:Ft.dimOpacity)&&void 0!==e?e:.5),function(t,e){for(const n of e)switch(n.type){case"bezier":Cn(t,n);break;case"line":Ln(t,n);break;case"ribbon":Dn(t,n);break;case"curved":Tn(t,n)}}(s,c.sceneEdges),function(t,e){var n,i,r;for(const o of e){if("rect"!==o.type)continue;const e=o;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!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(r=e.style.opacity)&&void 0!==r?r:1,t.strokeRect(e.x,e.y,e.w,e.h)),Bt(t,e),t.restore())}}(s,c.sceneNodes),function(t,e){var n,i,r;for(const o of e){if("circle"!==o.type)continue;const e=o;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!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(r=e.style.opacity)&&void 0!==r?r:1,t.stroke()),jt(t,e),t.restore())}}(s,c.sceneNodes),function(t,e){var n,i,r;for(const o of e){if("arc"!==o.type)continue;const e=o;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!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(r=e.style.opacity)&&void 0!==r?r:1,t.stroke()),t.restore()}}(s,c.sceneNodes),Y&&c.particlePool&&!p){const t=Array.from(c.edges.values());if(t.length>0){!function(t,e,n,i){var r,o;const a=null!==(r=i.spawnRate)&&void 0!==r?r:se.spawnRate,l=null!==(o=i.maxPerEdge)&&void 0!==o?o:se.maxPerEdge;for(let i=0;e.length>i;i++){const r=e[i];if(!r.bezier)continue;if(t.countForEdge(i)>=l)continue;const o=r.value*a*n*(r.bezier.circular?.3:1),s=Math.floor(o),c=o-s;let u=s;Math.random()<c&&u++;for(let e=0;u>e&&t.countForEdge(i)<l;e++)t.spawn(i)}}(c.particlePool,t,h,ce);const e=.5*(null!==(n=ce.speedMultiplier)&&void 0!==n?n:1);let i;if(ce.proportionalSpeed){const e=t.reduce((t,e)=>Math.max(t,e.value||1),1);i=t.map(t=>.3+(t.value||1)/e*1.7)}c.particlePool.step(h,e,t,i),function(t,e,n,i,r){var o,a;const l=null!==(o=i.radius)&&void 0!==o?o:se.radius,s=null!==(a=i.opacity)&&void 0!==a?a:se.opacity;t.globalAlpha=s;for(let o=0;e.particles.length>o;o++){const a=e.particles[o];if(!a.active)continue;const s=n[a.edgeIndex];if(s){if("function"==typeof i.color){const e="object"==typeof s.source?s.source:null;t.fillStyle=e?i.color(s,e):"#666"}else t.fillStyle=i.color&&"inherit"!==i.color?i.color:r(s);t.beginPath(),t.arc(a.x,a.y,l,0,2*Math.PI),t.fill()}}t.globalAlpha=1}(s,c.particlePool,t,ce,De)}}p&&(s.globalAlpha=1);const m=ye.current;if(ye.current=!1,m||d||f){const t=he.current;t&&t.setAttribute("aria-label",Et(null!==(r=null===(i=c.sceneNodes)||void 0===i?void 0:i.length)&&void 0!==r?r:0,null!==(a=null===(o=c.sceneEdges)||void 0===o?void 0:o.length)&&void 0!==a?a:0,"Network chart"))}(m||d||f)&&Ee(t=>t+1),(Te||d||f||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff)&&(de.current=requestAnimationFrame(()=>pe.current()))},t.useEffect(()=>($e(),()=>{de.current&&(cancelAnimationFrame(de.current),de.current=0)}),[$e]),t.useEffect(()=>{ye.current=!0,$e()},[p,ie,re,ht,$e]),V(Ft,me,ye,$e,Ae,Me);const Ze=dt&&ve?g.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:ne.left+ve.x,top:ne.top+ve.y,transform:`translate(${ve.x>.6*ie?"calc(-100% - 12px)":"12px"}, ${.3*re>ve.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2,width:"max-content"}},ft?ft(ve):g.createElement(In,{data:ve})):null;if(bt){const t=me.current;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(p),n=e?x||(Array.isArray(v)?void 0:v):void 0;if(e&&n)t.ingestHierarchy(n,[ie,re]),t.buildScene([ie,re]);else{const e=m||[],n=Array.isArray(v)?v:[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[ie,re]),t.buildScene([ie,re]))}}const e=null!==(o=null==t?void 0:t.sceneNodes)&&void 0!==o?o:[],n=null!==(a=null==t?void 0:t.sceneEdges)&&void 0!==a?a:[],i=null!==(l=null==t?void 0:t.labels)&&void 0!==l?l:[];return g.createElement("div",{className:"stream-network-frame"+(ut?" "+ut:""),role:"img","aria-label":"string"==typeof Tt?Tt:"Network chart",style:{position:"relative",width:ee[0],height:ee[1]}},g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:ee[0],height:ee[1],style:{position:"absolute",left:0,top:0}},zt&&g.createElement("g",{transform:`translate(${ne.left},${ne.top})`},zt),g.createElement("g",{transform:`translate(${ne.left},${ne.top})`},ht&&g.createElement("rect",{x:0,y:0,width:ie,height:re,fill:ht}),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:xt(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:xt(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:xt(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:xt(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:xt(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"arc":{const n=t,i=s.arc().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle).endAngle(n.endAngle)({})||"";return g.createElement("path",{key:"net-arc-"+e,d:i,transform:`translate(${n.cx},${n.cy})`,fill:xt(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}default:return null}}(t,e)).filter(Boolean),i.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(_n,{width:ie,height:re,totalWidth:ee[0],totalHeight:ee[1],margin:ne,labels:i,sceneNodes:e,title:Tt,legend:At,legendPosition:Pt,legendHoverBehavior:_t,legendClickBehavior:Ct,legendHighlightedCategory:Lt,legendIsolatedCategories:Dt,foregroundGraphics:oe,annotations:kt,svgAnnotationRules:wt,annotationFrame:0}))}const Qe=me.current;return g.createElement("div",{ref:te,className:"stream-network-frame"+(ut?" "+ut:""),role:"img","aria-label":"string"==typeof Tt?Tt:"Network chart",tabIndex:0,style:{position:"relative",width:lt?"100%":ee[0],height:st?"100%":ee[1],overflow:"visible"},onMouseMove:dt?Ue:void 0,onMouseLeave:dt?Ge:void 0,onClick:gt||pt?qe:void 0,onKeyDown:Ke},zt&&g.createElement("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:ee[0],height:ee[1],pointerEvents:"none",overflow:"visible"}},g.createElement("g",{transform:`translate(${ne.left},${ne.top})`},zt)),g.createElement("canvas",{ref:he,"aria-label":Et(null!==(u=null===(c=null==Qe?void 0:Qe.sceneNodes)||void 0===c?void 0:c.length)&&void 0!==u?u:0,null!==(d=null===(h=null==Qe?void 0:Qe.sceneEdges)||void 0===h?void 0:h.length)&&void 0!==d?d:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),g.createElement(St,{hoverPoint:ve}),Ht&&g.createElement(Mt,{nodes:null!==(f=null==Qe?void 0:Qe.sceneNodes)&&void 0!==f?f:[],edges:null!==(y=null==Qe?void 0:Qe.sceneEdges)&&void 0!==y?y:[],chartType:"Network chart"}),g.createElement(_n,{width:ie,height:re,totalWidth:ee[0],totalHeight:ee[1],margin:ne,labels:(null==Qe?void 0:Qe.labels)||[],sceneNodes:null==Qe?void 0:Qe.sceneNodes,title:Tt,legend:At,legendPosition:Pt,legendHoverBehavior:_t,legendClickBehavior:Ct,legendHighlightedCategory:Lt,legendIsolatedCategories:Dt,foregroundGraphics:oe,annotations:kt,svgAnnotationRules:wt,annotationFrame:we}),Ze,(null==Ft?void 0:Ft.showBadge)&&g.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Ft.badgePosition?{top:4,left:4}:"bottom-left"===Ft.badgePosition?{bottom:4,left:4}:"bottom-right"===Ft.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Ae?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},Ae?"STALE":"LIVE"))});function Bn(t){const e=[];for(const[n,i]of Object.entries(t.fields))if("point"===i.type)e.push(t=>i.values.has(t[n]));else{const[t,r]=i.range;e.push(e=>{const i=e[n];return i>=t&&r>=i})}return t=>e.every(e=>e(t))}function jn(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}Rn.displayName="StreamNetworkFrame";const[Fn,Yn]=Pt(t=>({selections:new Map,setClause(e,n){t(t=>{const i=new Map(t.selections),r=jn(i,e),o=new Map(r.clauses);return o.set(n.clientId,n),i.set(e,Object.assign(Object.assign({},r),{clauses:o})),{selections:i}})},clearClause(e,n){t(t=>{const i=t.selections.get(e);if(!i)return{};const r=new Map(t.selections),o=new Map(i.clauses);return o.delete(n),r.set(e,Object.assign(Object.assign({},i),{clauses:o})),{selections:r}})},setResolution(e,n){t(t=>{const i=new Map(t.selections),r=jn(i,e);return i.set(e,Object.assign(Object.assign({},r),{resolution:n})),{selections:i}})},clearSelection(e){t(t=>{const n=new Map(t.selections),i=n.get(e);return i&&n.set(e,Object.assign(Object.assign({},i),{clauses:new Map})),{selections:n}})}})),[Hn,Xn]=Pt(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 Gn(e){const n=t.useId(),i=e.clientId||n,{name:r}=e,o=Yn(t=>t.selections.get(r)),a=Yn(t=>t.setClause),l=Yn(t=>t.clearClause),s=t.useMemo(()=>!!o&&o.clauses.size>0,[o]);return{predicate:t.useMemo(()=>o&&0!==o.clauses.size?function(t,e){const n=[];for(const[i,r]of t.clauses)"crossfilter"===t.resolution&&i===e||n.push(Bn(r));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(o,i):()=>!0,[o,i]),isActive:s,selectPoints:t.useCallback(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"point",values:new Set(i)};a(r,{clientId:i,type:"point",fields:e})},[i,r,a]),selectInterval:t.useCallback(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"interval",range:i};a(r,{clientId:i,type:"interval",fields:e})},[i,r,a]),clear:t.useCallback(()=>{l(r,i)},[l,r,i]),clientId:i}}function qn({selection:e,linkedHover:n,fallbackFields:i=[],unwrapData:r=!1,onObservation:o,chartType:a,chartId:l}){const s=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}:null}(n,i),c=Gn({name:(null==e?void 0:e.name)||"__unused__"}),u=function(e){const n=e.name||"hover",{fields:i}=e,{predicate:r,isActive:o,selectPoints:a,clear:l}=Gn({name:n});return{onHover:t.useCallback(t=>{if(!t)return void l();const e={};for(const n of i){const i=t[n];void 0!==i&&(e[n]=[i])}Object.keys(e).length>0&&a(e)},[i,a,l,n]),predicate:r,isActive:o}}({name:(null==s?void 0:s.name)||"hover",fields:(null==s?void 0:s.fields)||i||[]}),h=Xn(t=>t.pushObservation);return{activeSelectionHook:e?{isActive:c.isActive,predicate:c.predicate}:null,customHoverBehavior:t.useCallback(t=>{var e,i;if(n)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]),u.onHover(e)}else u.onHover(null);if(o||h){const n={timestamp:Date.now(),chartType:a||"unknown",chartId:l};if(t){let r=t.data||t.datum||t;Array.isArray(r)&&(r=r[0]);const a=Object.assign(Object.assign({},n),{type:"hover",datum:r||{},x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(i=t.y)&&void 0!==i?i:0});o&&o(a),h&&h(a)}else{const t=Object.assign(Object.assign({},n),{type:"hover-end"});o&&o(t),h&&h(t)}}},[n,u,o,a,l,h]),customClickBehavior:t.useCallback(t=>{var e,n;if(o||h){const i={timestamp:Date.now(),chartType:a||"unknown",chartId:l};if(t){let r=t.data||t.datum||t;Array.isArray(r)&&(r=r[0]);const a=Object.assign(Object.assign({},i),{type:"click",datum:r||{},x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0});o&&o(a),h&&h(a)}else{const t=Object.assign(Object.assign({},i),{type:"click-end"});o&&o(t),h&&h(t)}}},[o,h,a,l])}}const Vn={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 Kn(t,e,n){var i,r,o,a,l,s;const c=Vn[t||"primary"],u="context"===t||"sparkline"===t;return{width:null!==(i=e.width)&&void 0!==i?i:c.width,height:null!==(r=e.height)&&void 0!==r?r:c.height,showAxes:c.showAxes,showGrid:null!==(o=e.showGrid)&&void 0!==o?o: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,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:Un(c.marginDefaults,e.showCategoryTicks,e.orientation)}}function Un(t,e,n){if(!1!==e)return t;const i=Object.assign({},t);return"horizontal"===n?i.left=Math.min(i.left,15):i.bottom=Math.min(i.bottom,15),i}"undefined"!=typeof process&&process;const Zn={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Qn={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Jn(t,e,n,i){return!1===i||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?g.createElement("div",{style:Object.assign(Object.assign({},Zn),{width:e,height:n})},i||"No data available"):null}function ti(t,e,n){if(!t)return null;const i=Math.min(5,Math.floor(n/40)),r=Math.max(8,Math.floor(n/(3*i))),o=Math.max(6,Math.floor(n/(2.5*i))),a=Math.floor((n-(i*(r+o)-o))/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:i},(t,n)=>g.createElement("div",{key:n,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Qn),{position:"absolute",top:a+n*(r+o),left:Math.floor(.1*e),width:30+(37*n+13)%50+"%",height:r,opacity:.5+n%2*.2})})))}const ei=t.forwardRef(function(e,n){var i,r,o,a;const l=Kn(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:d="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:m,timeExtent:v,valueExtent:x,extentPadding:b,stroke:k="#007bff",strokeWidth:w=2,strokeDasharray:E,background:A,tooltipContent:M,tooltip:S,onHover:P,annotations:_,svgAnnotationRules:C,tickFormatTime:L,tickFormatValue:D,decay:T,pulse:$,staleness:W,transition:O,linkedHover:N,selection:z,onObservation:I,chartId:R,loading:B,emptyContent:j,emphasis:F,legendPosition:Y}=e,H=l.showAxes,X=l.enableHover,G=null!=c?c:l.marginDefaults,q=null!=s?s:[l.width,l.height],V=null!=M?M:S,K=t.useRef(null),{customHoverBehavior:U}=qn({selection:z,linkedHover:N,unwrapData:!0,onObservation:I,chartType:"RealtimeLineChart",chartId:R}),Z=t.useCallback(t=>{P&&P(t),U(t)},[P,U]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=K.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Q=ti(B,q[0],q[1]),J=Q?null:Jn(y,q[0],q[1],j),tt={stroke:k,strokeWidth:w,strokeDasharray:E};return Q||J||g.createElement(ae,{ref:K,chartType:"line",runtimeMode:"streaming",size:q,margin:G,className:F?`${u||""} semiotic-emphasis-${F}`.trim():u,arrowOfTime:h,windowMode:d,windowSize:f,data:y,timeAccessor:p,valueAccessor:m,xExtent:v,yExtent:x,extentPadding:b,lineStyle:tt,showAxes:H,background:A,hoverAnnotation:X,tooltipContent:V,customHoverBehavior:Z,annotations:_,svgAnnotationRules:C,tickFormatTime:L,tickFormatValue:D,decay:T,pulse:$,staleness:W,transition:O,legendPosition:Y})});ei.displayName="RealtimeLineChart";const ni=t.forwardRef(function(e,n){var i,r,o,a;const l=Kn(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{binSize:s,size:c,margin:u,className:h,arrowOfTime:d="right",windowMode:f="sliding",windowSize:y=200,data:p,timeAccessor:m,valueAccessor:v,timeExtent:x,valueExtent:b,extentPadding:k,categoryAccessor:w,colors:E,fill:A,stroke:M,strokeWidth:S,gap:P,background:_,tooltipContent:C,tooltip:L,onHover:D,annotations:T,svgAnnotationRules:$,tickFormatTime:W,tickFormatValue:O,linkedHover:N,selection:z,decay:I,pulse:R,staleness:B,transition:j,onObservation:F,chartId:Y,loading:H,emptyContent:X,emphasis:G,legendPosition:q}=e,V=l.showAxes,K=l.enableHover,U=null!=u?u:l.marginDefaults,Z=null!=c?c:[l.width,l.height],Q=null!=C?C:L,J=t.useRef(null),{customHoverBehavior:tt}=qn({selection:z,linkedHover:N,unwrapData:!0,onObservation:F,chartType:"RealtimeTemporalHistogram",chartId:Y}),et=t.useCallback(t=>{D&&D(t),tt(t)},[D,tt]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=J.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=J.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=J.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=J.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const nt=ti(H,Z[0],Z[1]),it=nt?null:Jn(p,Z[0],Z[1],X),rt={};return null!=A&&(rt.fill=A),null!=M&&(rt.stroke=M),null!=S&&(rt.strokeWidth=S),null!=P&&(rt.gap=P),nt||it||g.createElement(ae,{ref:J,chartType:"bar",runtimeMode:"streaming",size:Z,margin:U,className:G?`${h||""} semiotic-emphasis-${G}`.trim():h,arrowOfTime:d,windowMode:f,windowSize:y,data:p,timeAccessor:m,valueAccessor:v,xExtent:x,yExtent:b,extentPadding:k,binSize:s,categoryAccessor:w,barColors:E,barStyle:rt,showAxes:V,background:_,hoverAnnotation:K,tooltipContent:Q,customHoverBehavior:et,annotations:T,svgAnnotationRules:$,tickFormatTime:W,tickFormatValue:O,decay:I,pulse:R,staleness:B,transition:j,legendPosition:q})});ni.displayName="RealtimeTemporalHistogram";const ii=ni,ri=t.forwardRef(function(e,n){var i,r,o,a;const l=Kn(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:d="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:m,timeExtent:v,valueExtent:x,extentPadding:b,categoryAccessor:k,colors:w,radius:E,fill:A,opacity:M,stroke:S,strokeWidth:P,background:_,tooltipContent:C,tooltip:L,onHover:D,annotations:T,svgAnnotationRules:$,tickFormatTime:W,tickFormatValue:O,linkedHover:N,selection:z,onObservation:I,chartId:R,loading:B,emptyContent:j,emphasis:F,legendPosition:Y}=e,H=l.showAxes,X=l.enableHover,G=null!=c?c:l.marginDefaults,q=null!=s?s:[l.width,l.height],V=null!=C?C:L,K=t.useRef(null),{customHoverBehavior:U}=qn({selection:z,linkedHover:N,unwrapData:!0,onObservation:I,chartType:"RealtimeSwarmChart",chartId:R}),Z=t.useCallback(t=>{D&&D(t),U(t)},[D,U]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=K.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Q=ti(B,q[0],q[1]),J=Q?null:Jn(y,q[0],q[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(ae,{ref:K,chartType:"swarm",runtimeMode:"streaming",size:q,margin:G,className:F?`${u||""} semiotic-emphasis-${F}`.trim():u,arrowOfTime:h,windowMode:d,windowSize:f,data:y,timeAccessor:p,valueAccessor:m,xExtent:v,yExtent:x,extentPadding:b,categoryAccessor:k,barColors:w,swarmStyle:tt,showAxes:H,background:_,hoverAnnotation:X,tooltipContent:V,customHoverBehavior:Z,annotations:T,svgAnnotationRules:$,tickFormatTime:W,tickFormatValue:O,legendPosition:Y})});ri.displayName="RealtimeSwarmChart";const oi=t.forwardRef(function(e,n){var i,r,o,a;const l=Kn(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:d="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:m,timeExtent:v,valueExtent:x,extentPadding:b,positiveColor:k,negativeColor:w,connectorStroke:E,connectorWidth:A,gap:M,stroke:S,strokeWidth:P,background:_,tooltipContent:C,tooltip:L,onHover:D,annotations:T,svgAnnotationRules:$,tickFormatTime:W,tickFormatValue:O,linkedHover:N,selection:z,onObservation:I,chartId:R,loading:B,emptyContent:j,emphasis:F,legendPosition:Y}=e,H=l.showAxes,X=l.enableHover,G=null!=c?c:l.marginDefaults,q=null!=s?s:[l.width,l.height],V=null!=C?C:L,K=t.useRef(null),{customHoverBehavior:U}=qn({selection:z,linkedHover:N,unwrapData:!0,onObservation:I,chartType:"RealtimeWaterfallChart",chartId:R}),Z=t.useCallback(t=>{D&&D(t),U(t)},[D,U]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=K.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Q=ti(B,q[0],q[1]),J=Q?null:Jn(y,q[0],q[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(ae,{ref:K,chartType:"waterfall",runtimeMode:"streaming",size:q,margin:G,className:F?`${u||""} semiotic-emphasis-${F}`.trim():u,arrowOfTime:h,windowMode:d,windowSize:f,data:y,timeAccessor:p,valueAccessor:m,xExtent:v,yExtent:x,extentPadding:b,waterfallStyle:tt,showAxes:H,background:_,hoverAnnotation:X,tooltipContent:V,customHoverBehavior:Z,annotations:T,svgAnnotationRules:$,tickFormatTime:W,tickFormatValue:O,legendPosition:Y})});oi.displayName="RealtimeWaterfallChart";const ai=t.forwardRef(function(e,n){var i,r,o,a;const l=Kn(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:d="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:m,categoryAccessor:v,timeExtent:x,valueExtent:b,extentPadding:k,heatmapXBins:w=20,heatmapYBins:E=20,aggregation:A="count",background:M,tooltipContent:S,tooltip:P,onHover:_,annotations:C,svgAnnotationRules:L,tickFormatTime:D,tickFormatValue:T,decay:$,pulse:W,staleness:O,linkedHover:N,selection:z,onObservation:I,chartId:R,loading:B,emptyContent:j,emphasis:F,legendPosition:Y}=e,H=l.showAxes,X=l.enableHover,G=null!=c?c:l.marginDefaults,q=null!=s?s:[l.width,l.height],V=null!=S?S:P,K=t.useRef(null),{customHoverBehavior:U}=qn({selection:z,linkedHover:N,unwrapData:!0,onObservation:I,chartType:"RealtimeHeatmap",chartId:R}),Z=t.useCallback(t=>{_&&_(t),U(t)},[_,U]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=K.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Q=ti(B,q[0],q[1]),J=Q?null:Jn(y,q[0],q[1],j);return Q||J||g.createElement(ae,{ref:K,chartType:"heatmap",runtimeMode:"streaming",size:q,margin:G,className:F?`${u||""} semiotic-emphasis-${F}`.trim():u,arrowOfTime:h,windowMode:d,windowSize:f,data:y,timeAccessor:p,valueAccessor:m,categoryAccessor:v,xExtent:x,yExtent:b,extentPadding:k,heatmapXBins:w,heatmapYBins:E,heatmapAggregation:A,showAxes:H,background:M,hoverAnnotation:X,tooltipContent:V,customHoverBehavior:Z,annotations:C,svgAnnotationRules:L,tickFormatTime:D,tickFormatValue:T,decay:$,pulse:W,staleness:O,legendPosition:Y})});ai.displayName="RealtimeHeatmap",exports.IncrementalExtent=x,exports.RealtimeHeatmap=ai,exports.RealtimeHistogram=ii,exports.RealtimeLineChart=ei,exports.RealtimeSwarmChart=ri,exports.RealtimeWaterfallChart=oi,exports.RingBuffer=v,exports.StreamNetworkFrame=Rn,exports.StreamXYFrame=ae;
|
|
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;
|