semiotic 3.3.0 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +7 -4
- package/ai/schema.json +97 -1
- package/dist/components/charts/ordinal/BarChart.d.ts +2 -0
- package/dist/components/charts/ordinal/DonutChart.d.ts +2 -0
- package/dist/components/charts/ordinal/GroupedBarChart.d.ts +4 -0
- package/dist/components/charts/ordinal/PieChart.d.ts +2 -0
- package/dist/components/charts/ordinal/StackedBarChart.d.ts +4 -0
- package/dist/components/realtime/types.d.ts +42 -3
- package/dist/components/server/renderToStaticSVG.d.ts +1 -0
- package/dist/components/server/serverChartConfigs.d.ts +17 -0
- package/dist/components/server/themeResolver.d.ts +4 -0
- package/dist/components/store/ThemeStore.d.ts +14 -0
- package/dist/components/stream/NetworkPipelineStore.d.ts +7 -1
- package/dist/components/stream/geoTypes.d.ts +4 -4
- package/dist/components/stream/hoverUtils.d.ts +22 -0
- package/dist/components/stream/networkTypes.d.ts +14 -22
- package/dist/components/stream/ordinalTypes.d.ts +10 -0
- package/dist/components/stream/pipelineDecay.d.ts +6 -5
- package/dist/components/stream/types.d.ts +4 -0
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-themes.min.js +1 -1
- package/dist/semiotic-themes.module.min.js +1 -1
- package/dist/semiotic-utils.min.js +1 -1
- package/dist/semiotic-utils.module.min.js +1 -1
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as t from"react";import{createContext as e,useMemo as i,useContext as r,useRef as o,useCallback as n,useSyncExternalStore as s}from"react";import{scaleLinear as a,scaleLog as c,scaleTime as l,scaleBand as u,scaleOrdinal as h}from"d3-scale";import{quadtree as f}from"d3-quadtree";import{interpolateViridis as d,interpolateGreens as g,interpolateReds as y,interpolateBlues as p,schemeCategory10 as m}from"d3-scale-chromatic";import{min as x,groups as v,max as b,sum as k,mean as w,group as A,quantile as S}from"d3-array";import{interpolateNumber as _}from"d3-interpolate";import{forceLink as P,forceSimulation as E,forceManyBody as M,forceCenter as O,forceX as L,forceY as D}from"d3-force";import{ribbon as z,chord as j}from"d3-chord";import{arc as T,pie as N}from"d3-shape";import{hierarchy as $,partition as B,pack as W,treemap as R,treemapBinary as F,cluster as C,tree as I}from"d3-hierarchy";import{geoPath as Y,geoGraticule as X,geoDistance as q,geoInterpolate as G,geoEqualEarth as V,geoEquirectangular as H,geoNaturalEarth1 as Z,geoOrthographic as K,geoAlbersUsa as U,geoMercator as Q}from"d3-geo";function J(t,e,i,r){return new(i||(i=Promise))(function(o,n){function s(t){try{c(r.next(t))}catch(t){n(t)}}function a(t){try{c(r.throw(t))}catch(t){n(t)}}function c(t){t.done?o(t.value):function(t){return t instanceof i?t:new i(function(e){e(t)})}(t.value).then(s,a)}c((r=r.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class tt{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 i of t){const t=this.push(i);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 i=0;this._size>i;i++)t(this.buffer[(e+i)%this._capacity],i)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)t[i]=this.buffer[(e+i)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),i=[];for(;e.length>t;)i.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 i}update(t,e){const i=[],r=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){const n=(r+o)%this._capacity,s=this.buffer[n];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:Object.assign({},s),i.push(t),this.buffer[n]=e(s)}}return i}remove(t){const e=[],i=[];if(this.forEach(r=>{t(r)?i.push(r):e.push(r)}),0===i.length)return i;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return i}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 et{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 i of t){const t=e?e(i):i;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 it(t,e,i,r,o){const n=new Map;for(const s of t){const t=e(s),a=i(s);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const c=Math.floor(t/r)*r;let l=n.get(c);if(l||(l={start:c,end:c+r,total:0,categories:new Map},n.set(c,l)),l.total+=a,o){const t=o(s);l.categories.set(t,(l.categories.get(t)||0)+a)}}return n}function rt(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function ot(t,e){if("function"==typeof t)return e=>+t(e);const i=t||e;return t=>+t[i]}function nt(t,e){if("function"==typeof t)return t;const i=t||e;return t=>t[i]}function st(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}const at=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function ct(t,e,i){var r,o,n;if(1>=i)return 1;const s=null!==(r=t.minOpacity)&&void 0!==r?r:.1,a=i-1-e;switch(t.type){case"linear":return s+(1-a/(i-1))*(1-s);case"exponential":{const e=null!==(o=t.halfLife)&&void 0!==o?o:i/2;return s+Math.pow(.5,a/e)*(1-s)}case"step":return(null!==(n=t.stepThreshold)&&void 0!==n?n:.5*i)>a?1:s;default:return 1}}function lt(t,e,i){var r;const o=null!==(r=t.duration)&&void 0!==r?r:500,n=i-e;return o>n?1-n/o:0}function ut(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function ht(t,e){return Math.min((t-e.startTime)/e.duration,1)}function ft(t,e,i){return t+(e-t)*i}function dt(){return"undefined"!=typeof performance?performance.now():Date.now()}function gt(t,e,i){var r,o,n,s;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const i=t.getX(e.datum),r=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${i}:${r}`;if(null!=i&&null!=r)return`p:${i}:${r}`}return"p:"+i;case"rect":return`r:${e.group||""}:${null!==(s=null!==(o=null===(r=e.datum)||void 0===r?void 0:r.binStart)&&void 0!==o?o:null===(n=e.datum)||void 0===n?void 0:n.category)&&void 0!==s?s:i}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+i:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function yt(t,e,i,r,o,n){const s=[];for(const o of t){const t=i(o),n=r(o);null==t||null==n||Number.isNaN(t)||Number.isNaN(n)||s.push({px:e.x(t),py:e.y(n),rawY:n,d:o})}s.sort((t,e)=>t.px-e.px);const a=Array(s.length),c=Array(s.length),l=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];a[t]=[e.px,e.py],c[t]=e.rawY,l[t]=e.d}return{type:"line",path:a,rawValues:c,style:o,datum:l,group:n}}function pt(t,e,i,r,o,n,s,a){const c=[];for(const n of t){const t=i(n),s=r(n);if(null==t||null==s||Number.isNaN(t)||Number.isNaN(s))continue;const l=e.x(t),u=a?a(n):o;c.push({px:l,topY:e.y(s),botY:e.y(u)})}c.sort((t,e)=>t.px-e.px);const l=Array(c.length),u=Array(c.length);for(let t=0;c.length>t;t++){const e=c[t];l[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:l,bottomPath:u,style:n,datum:t,group:s}}function mt(t,e,i,r,o,n,s){const a=i(t),c=r(t);if(null==a||null==c||Number.isNaN(a)||Number.isNaN(c))return null;const l={type:"point",x:e.x(a),y:e.y(c),r:o,style:n,datum:t};return void 0!==s&&(l.pointId=s),l}function xt(t,e,i,r,o,n,s){return{type:"rect",x:t,y:e,w:i,h:r,style:o,datum:n,group:s}}function vt(t,e,i,r,o,n,s){const a={type:"heatcell",x:t,y:e,w:i,h:r,fill:o,datum:n};return(null==s?void 0:s.showValues)&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function bt(t,e,i){if(!t.getBounds||!t.scales)return null;const r=[],o=[];for(const i of e){const e=t.getX(i),n=t.getY(i);if(null==e||null==n||Number.isNaN(e)||Number.isNaN(n))continue;const s=t.getBounds(i),a=t.scales.x(e);if(s&&0!==s)r.push([a,t.scales.y(n+s)]),o.push([a,t.scales.y(n-s)]);else{const e=t.scales.y(n);r.push([a,e]),o.push([a,e])}}return 2>r.length?null:{type:"area",topPath:r,bottomPath:o,style:t.resolveBoundsStyle(i,e[0]),datum:e,group:i,interactive:!1}}function kt(t,e,i,r){var o;if(!t.config.pointStyle)return;const n=null!=r?r:t.getY;for(const r of e){const e=t.resolveGroupColor(r.key);for(const s of r.data){let r=t.config.pointStyle(s);!r.fill&&e&&(r=Object.assign(Object.assign({},r),{fill:e}));const a=null!==(o=r.r)&&void 0!==o?o:3,c=t.getPointId?t.getPointId(s)+"":void 0,l=mt(s,t.scales,t.getX,n,a,r,c);l&&i.push(l)}}}const wt={blues:p,reds:y,greens:g,viridis:d},At=new Map;class St{constructor(t){if(this.xExtent=new et,this.yExtent=new et,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 tt(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=ot(t.timeAccessor||t.xAccessor,"time"),this.getY=ot(t.valueAccessor||t.yAccessor,"value")):(this.getX=ot(t.xAccessor,"x"),this.getY=ot(t.yAccessor,"y")),this.getGroup=st(t.groupAccessor),this.getCategory=st(t.categoryAccessor),this.getSize=t.sizeAccessor?ot(t.sizeAccessor,"size"):void 0,this.getColor=st(t.colorAccessor),this.getBounds=t.boundsAccessor?ot(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?ot(t.y0Accessor,"y0"):void 0,this.getPointId=st(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,i=null!=t.closeAccessor;this.getOpen=e?ot(t.openAccessor,"open"):void 0,this.getHigh=ot(t.highAccessor,"high"),this.getLow=ot(t.lowAccessor,"low"),this.getClose=i?ot(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!i}t.pulse&&(this.timestampBuffer=new tt(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?ot(this.config.timeAccessor||this.config.xAccessor,"time"):ot(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],i=this.config.xAccessor,r="function"==typeof i?i(e):e[i||"x"],o=r instanceof Date,n="string"==typeof r&&r.length>=10&&!isNaN(new Date(r).getTime())&&isNaN(Number(r));if(this.xIsDate=o||n,n){const t="string"==typeof i?i:void 0;this.getX=t?e=>+new Date(e[t]):t=>+(i(t)instanceof Date?i(t):new Date(i(t)))}}const i=t.totalSize||t.inserts.length;i>this.buffer.capacity&&(this.buffer.resize(i),this.timestampBuffer&&i>this.timestampBuffer.capacity&&this.timestampBuffer.resize(i));for(const i of t.inserts)this.buffer.push(i),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(i)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(i)),this.yExtent.push(this.getLow(i))):(this.yExtent.push(this.getY(i)),this.getY0&&this.yExtent.push(this.getY0(i)))}else for(const i 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(i);this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(i)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(i)),this.yExtent.push(this.getLow(i))):(this.yExtent.push(this.getY(i)),this.getY0&&this.yExtent.push(this.getY0(i))),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,i,r,o,n,s,u;const{config:h,buffer:f}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(e=this.config.scalePadding)&&void 0!==e?e:0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);if(this.xExtent.dirty&&this.xExtent.recalculate(f,this.getX),this.yExtent.dirty)if("candlestick"===h.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of f)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(f,this.getY);const d=this.getBufferArray(),g=this.xExtent.extent,y=this.yExtent.extent;let p=h.xExtent?[null!==(i=h.xExtent[0])&&void 0!==i?i:g[0],null!==(r=h.xExtent[1])&&void 0!==r?r:g[1]]:g,m=h.yExtent?[null!==(o=h.yExtent[0])&&void 0!==o?o:y[0],null!==(n=h.yExtent[1])&&void 0!==n?n:y[1]]:y;const x=h.yExtent&&null!=h.yExtent[0]&&null!=h.yExtent[1];if("stackedarea"===h.chartType&&!x&&f.size>0)if(h.normalize)m=[0,1+h.extentPadding];else{const t=`${f.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)m=this._stackExtentCache.yDomain;else{const e=this.groupData(d),i=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)||i.set(t,(i.get(t)||0)+r)}let r=0;for(const t of i.values())t>r&&(r=t);m=[0,r+(r>0?r*h.extentPadding:1)],this._stackExtentCache={key:t,yDomain:m}}}else if("bar"===h.chartType&&h.binSize&&!x&&f.size>0){const[,t]=function(t,e,i,r,o){const n=it(t,e,i,r,o);if(0===n.size)return[0,0];let s=0;for(const t of n.values())t.total>s&&(s=t.total);return[0,s]}(f,this.getX,this.getY,h.binSize,this.getCategory);m=[0,t+t*h.extentPadding]}else if("waterfall"===h.chartType&&!x&&f.size>0){const[t,e]=function(t,e){let i=0,r=0,o=0;for(const n of t){const t=e(n);null==t||Number.isNaN(t)||(o+=t,i>o&&(i=o),o>r&&(r=o))}return[i,r]}(f,this.getY),i=e-t,r=i>0?i*h.extentPadding:1;m=[Math.min(0,t-Math.abs(r)),Math.max(0,e+Math.abs(r))]}else if(!x&&m[0]!==1/0){if(this.getBounds)for(const t of d){const e=this.getY(t),i=this.getBounds(t);null!=e&&!Number.isNaN(e)&&i&&(e+i>m[1]&&(m[1]=e+i),m[0]>e-i&&(m[0]=e-i))}const t=m[1]-m[0],e=t>0?t*h.extentPadding:1,i=null===(s=h.yExtent)||void 0===s?void 0:s[0],r=null===(u=h.yExtent)||void 0===u?void 0:u[1];m=[null!=i?m[0]:m[0]-e,null!=r?m[1]:m[1]+e],"log"===h.yScaleType&&0>=m[0]&&y[0]>0&&(m[0]=null!=i?m[0]:y[0]/(1+h.extentPadding))}if(p[0]===1/0||p[1]===-1/0)if("time"===h.xScaleType){const t=Date.now();p=[t-864e5,t]}else p=[0,1];m[0]!==1/0&&m[1]!==-1/0||(m=[0,1]);const v="streaming"===h.runtimeMode,b=Math.max(0,Math.min(h.scalePadding||0,Math.min(t.width,t.height)/2-1));if(v)if("x"==("up"===(k=h.arrowOfTime)||"down"===k?"y":"x")){const e="right"===h.arrowOfTime?[b,t.width-b]:[t.width-b,b];this.scales={x:a().domain(p).range(e),y:a().domain(m).range([t.height-b,b])}}else{const e="down"===h.arrowOfTime?[b,t.height-b]:[t.height-b,b];this.scales={x:a().domain(m).range([b,t.width-b]),y:a().domain(p).range(e)}}else{const e=(t,e,i)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return c().domain(t).range(i).clamp(!0)}return"time"===t?l().domain([new Date(e[0]),new Date(e[1])]).range(i):a().domain(e).range(i)};this.scales={x:e(h.xScaleType,p,[b,t.width-b]),y:e(h.yScaleType,m,[t.height-b,b])}}var k;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,d),this.config.decay&&this.applyDecay(this.scene,d),this.config.pulse&&this.applyPulse(this.scene,d),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}rebuildQuadtree(){const t=this.config.chartType;if("scatter"!==t&&"bubble"!==t)return void(this._quadtree=null);const e=this.scene.filter(t=>"point"===t.type);this._quadtree=e.length>St.QUADTREE_THRESHOLD?f().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,i=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]*=i;break;case"area":for(const r of t.topPath)r[0]*=e,r[1]*=i;for(const r of t.bottomPath)r[0]*=e,r[1]*=i;break;case"point":t.x*=e,t.y*=i;break;case"rect":case"heatcell":t.x*=e,t.y*=i,t.w*=e,t.h*=i;break;case"candlestick":t.x*=e,t.openY*=i,t.closeY*=i,t.highY*=i,t.lowY*=i}const r=this.scales.x.domain(),o=this.scales.y.domain(),n=this.scales.x.range(),s=this.scales.y.range(),u=(t,e,i)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return c().domain(t).range(i).clamp(!0)}return"time"===t?l().domain([new Date(e[0]),new Date(e[1])]).range(i):a().domain(e).range(i)},h=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),f=s[1]>s[0];this.scales={x:u(this.config.xScaleType,r,n[0]>n[1]?[t.width-h,h]:[h,t.width-h]),y:u(this.config.yScaleType,o,f?[h,t.height-h]:[t.height-h,h])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){var i;const{config:r,scales:o}=this;if(!o||0===e.length)return[];const n={scales:o,config:r,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,getBounds:this.getBounds,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(t,e)=>this.resolveLineStyle(t,e),resolveAreaStyle:(t,e)=>this.resolveAreaStyle(t,e),resolveBoundsStyle:(t,e)=>this.resolveBoundsStyle(t,e),resolveColorMap:t=>this.resolveColorMap(t),resolveGroupColor:t=>this.resolveGroupColor(t),groupData:t=>this.groupData(t),barCategoryCache:this._barCategoryCache};switch(r.chartType){case"line":return function(t,e){var i;const r=t.groupData(e),o=[],n=null===(i=t.config.annotations)||void 0===i?void 0:i.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 i=bt(t,e.data,e.key);i&&o.push(i)}for(const e of r){const i=t.resolveLineStyle(e.key,e.data[0]),r=yt(e.data,t.scales,t.getX,t.getY,i,e.key);n&&n.length>0&&(r.colorThresholds=n),t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),o.push(r)}return kt(t,r,o),o}(n,e);case"area":return function(t,e){const i=t.groupData(e),r=[],o=t.scales.y.domain()[0],n=t.getY0?e=>{const i=t.getY0(e);return null==i?o:i}:void 0;for(const e of i){const i=t.resolveAreaStyle(e.key,e.data[0]),s=pt(e.data,t.scales,t.getX,t.getY,o,i,e.key,n);t.config.gradientFill&&(s.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),r.push(s)}return kt(t,i,r),r}(n,e);case"mixed":return function(t,e){const i=t.groupData(e),r=[],o=t.config.areaGroups||new Set,n=t.scales.y.domain()[0],s=t.getY0?e=>{const i=t.getY0(e);return null==i?n:i}:void 0;for(const e of i)if(o.has(e.key)){const i=t.resolveAreaStyle(e.key,e.data[0]),o=pt(e.data,t.scales,t.getX,t.getY,n,i,e.key,s);t.config.gradientFill&&(o.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),r.push(o)}else{const i=t.resolveLineStyle(e.key,e.data[0]),o=yt(e.data,t.scales,t.getX,t.getY,i,e.key);t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),r.push(o)}return kt(t,i,r),r}(n,e);case"stackedarea":return function(t,e){const i=t.groupData(e);i.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:n}=function(t,e,i,r,o,n,s){var a;const c=new Set;for(const e of t)for(const t of e.data){const e=i(t);null==e||Number.isNaN(e)||c.add(e)}const l=Array.from(c).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=i(o),n=r(o);null==e||null==n||Number.isNaN(e)||Number.isNaN(n)||t.set(e,(t.get(e)||0)+n)}u.set(e.key,t)}let h;if(n){h=new Map;for(const e of l){let i=0;for(const r of t)i+=(null===(a=u.get(r.key))||void 0===a?void 0:a.get(e))||0;h.set(e,i||1)}}const f=[],d=new Map,g=new Map;for(const t of l)g.set(t,0);for(const i of t){const t=u.get(i.key),r=[],a=[],c=new Map;for(const i of l){let o=t.get(i)||0;const s=g.get(i);n&&(o/=h.get(i));const l=s+o,u=e.x(i);a.push([u,e.y(s)]),r.push([u,e.y(l)]),g.set(i,l),c.set(i,l)}d.set(i.key,c);const y={type:"area",topPath:r,bottomPath:a,style:o(i.key,i.data[0]),datum:i.data,group:i.key};s&&(y.curve=s),f.push(y)}return{nodes:f,stackedTops:d}}(i,t.scales,t.getX,t.getY,(e,i)=>t.resolveAreaStyle(e,i),t.config.normalize,r),s=o;if(t.config.pointStyle){const e=new WeakMap;for(const r of i){const i=n.get(r.key);if(i)for(const o of r.data){const r=t.getX(o),n=t.getY(o);null==r||Number.isNaN(r)||null==n||Number.isNaN(n)||!i.has(r)||e.set(o,i.get(r))}}const r=i=>{var r;return null!==(r=e.get(i))&&void 0!==r?r:t.getY(i)};kt(t,i,s,r)}return s}(n,e);case"scatter":case"bubble":return function(t,e){const i=[],r="bubble"===t.config.chartType?10:5,o=t.config.sizeRange||[3,15];let n=null;if(t.getSize&&!t.config.pointStyle){const i=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(i.length>0){let t=1/0,e=-1/0;for(const r of i)t>r&&(t=r),r>e&&(e=r);n=i=>t===e?(o[0]+o[1])/2:o[0]+(i-t)/(e-t)*(o[1]-o[0])}}const s=t.getColor?t.resolveColorMap(e):null;for(const o of e){let e=t.config.pointStyle?t.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},a=e.r||r;if(n&&t.getSize){const e=t.getSize(o);null==e||Number.isNaN(e)||(a=n(e))}if(s&&t.getColor&&!e.fill){const i=t.getColor(o);i&&s.has(i)&&(e=Object.assign(Object.assign({},e),{fill:s.get(i)}))}const c=t.getPointId?t.getPointId(o)+"":void 0,l=mt(o,t.scales,t.getX,t.getY,a,e,c);l&&i.push(l)}return i}(n,e);case"heatmap":return function(t,e,i){if(t.config.heatmapAggregation)return function(t,e,i){var r,o,n;const s=Math.max(1,Math.floor(null!==(r=t.config.heatmapXBins)&&void 0!==r?r:20)),a=Math.max(1,Math.floor(null!==(o=t.config.heatmapYBins)&&void 0!==o?o:20)),c=null!==(n=t.config.heatmapAggregation)&&void 0!==n?n:"count",l=ot(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[u,h]=t.scales.x.domain(),[f,d]=t.scales.y.domain(),g=(h-u||1)/s,y=(d-f||1)/a,p=s*a;if(p>1e6)return[];const m=new Int32Array(p),x=new Float64Array(p);for(let i=0;e.length>i;i++){const r=e[i],o=t.getX(r),n=t.getY(r);if(!isFinite(o)||!isFinite(n))continue;const c=Math.min(Math.floor((o-u)/g),s-1),h=Math.min(Math.floor((n-f)/y),a-1);if(0>c||0>h)continue;const d=h*s+c;m[d]++;const p=l(r);x[d]+=isFinite(p)?p:0}let v=1/0,b=-1/0;for(let t=0;p>t;t++){if(0===m[t])continue;let e;switch(c){case"sum":e=x[t];break;case"mean":e=x[t]/m[t];break;default:e=m[t]}v>e&&(v=e),e>b&&(b=e)}if(!isFinite(v))return[];const k=b-v||1,w=i.width/s,A=i.height/a,S=t.config.showValues,_=t.config.heatmapValueFormat,P=[];for(let t=0;a>t;t++){const e=t*s;for(let i=0;s>i;i++){const r=e+i;if(0===m[r])continue;let o;switch(c){case"sum":o=x[r];break;case"mean":o=x[r]/m[r];break;default:o=m[r]}const n=(o-v)/k;P.push(vt(i*w,(a-1-t)*A,w,A,`rgb(${220-(180*n+.5)|0},${220-(100*n+.5)|0},${255-(50*n+.5)|0})`,{xi:i,yi:t,value:o,count:m[r],sum:x[r]},S?{value:o,showValues:!0,valueFormat:_}:void 0))}}return P}(t,e,i);if(0===e.length)return[];const r=ot(t.config.valueAccessor,"value"),o=nt(t.config.xAccessor,"x"),n=nt(t.config.yAccessor,"y"),s=new Map,a=new Map,c=Array(e.length),l=Array(e.length);for(let t=0;e.length>t;t++){const i=e[t],r=o(i),u=n(i);c[t]=r,l[t]=u,s.has(r)||s.set(r,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,h=a.size;if(0===u||0===h)return[];const f=Array.from(s.keys()),d=Array.from(a.keys()),g=f.every(t=>"number"==typeof t&&!isNaN(t)),y=d.every(t=>"number"==typeof t&&!isNaN(t));if(g){f.sort((t,e)=>t-e),s.clear();for(let t=0;f.length>t;t++)s.set(f[t],t)}if(y){d.sort((t,e)=>t-e),a.clear();for(let t=0;d.length>t;t++)a.set(d[t],t)}const m=new Float64Array(e.length),x=new Float64Array(e.length),v=Array(e.length),b=new Map;let k=0;for(let t=0;e.length>t;t++){const i=e[t],o=s.get(c[t]),n=a.get(l[t]);if(void 0===o||void 0===n)continue;const h=r(i),f=n*u+o,d=b.get(f);let g;void 0!==d?g=d:(g=k++,b.set(f,g)),m[g]=f,x[g]=h,v[g]=i}let w=1/0,A=-1/0;for(let t=0;k>t;t++){const e=x[t];isFinite(e)&&(w>e&&(w=e),e>A&&(A=e))}if(!isFinite(w)||!isFinite(A))return[];const S=function(t){const e=t in wt?t:"blues";let i=At.get(e);if(i)return i;i=Array(256);const r=wt[e]||p;for(let t=0;256>t;t++)i[t]=r(t/255);return At.set(e,i),i}("string"==typeof t.config.colorScheme?t.config.colorScheme:"blues"),_=255/(A-w||1),P=i.width/u,E=i.height/h,M=t.config.showValues,O=t.config.heatmapValueFormat,L=[];for(let t=0;k>t;t++){const e=x[t];if(!isFinite(e))continue;const i=m[t],r=i%u;L.push(vt(r*P,(h-1-(i-r)/u)*E,P,E,S[Math.min((e-w)*_+.5|0,255)],v[t],M?{value:e,showValues:!0,valueFormat:O}:void 0))}return L}(n,e,t);case"bar":{const t=function(t,e){var i;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const r=it(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 i of t.categories.keys())e.add(i);const i=t.config.barColors?Object.keys(t.config.barColors):[],n=new Set(i),s=Array.from(e).filter(t=>!n.has(t)).sort(),a=i.filter(t=>e.has(t)),c=a.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===c?o=t.barCategoryCache.order:(o=[...a,...s],t.barCategoryCache={key:c,order:o})}const n=[],s=t.scales,[a,c]=s.x.domain();for(const e of r.values()){const r=Math.max(e.start,a),l=Math.min(e.end,c);if(r>=l)continue;const u=s.x(r),h=s.x(l),f=Math.abs(h-u),d=f>2?1:0,g=Math.min(u,h)+d/2,y=Math.max(f-d,1);if(y>0)if(o&&e.categories.size>0){let r=0;for(const a of o){const o=e.categories.get(a)||0;if(0===o)continue;const c=s.y(r),l=s.y(r+o);n.push(xt(g,Math.min(c,l),y,Math.abs(c-l),{fill:(null===(i=t.config.barColors)||void 0===i?void 0:i[a])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:a,categoryValue:o},a)),r+=o}}else{const t=s.y(0),i=s.y(e.total);n.push(xt(g,Math.min(t,i),y,Math.abs(t-i),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}const l=new Set;for(const t of r.values())l.add(t.start),l.add(t.end);return{nodes:n,binBoundaries:Array.from(l).sort((t,e)=>t-e)}}(n,e);return this._barCategoryCache=null!==(i=n.barCategoryCache)&&void 0!==i?i:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var i,r,o,n;const s=[],a=t.config.swarmStyle||{},c=null!==(i=a.radius)&&void 0!==i?i:3,l=null!==(r=a.fill)&&void 0!==r?r:"#007bff",u=null!==(o=a.opacity)&&void 0!==o?o:.7,h=a.stroke,f=a.strokeWidth;for(const i of e){const e=t.getX(i),r=t.getY(i);if(null==r||Number.isNaN(r))continue;const o=t.scales.x(e),a=t.scales.y(r);let d=l;if(t.getCategory){const e=t.getCategory(i);d=(null===(n=t.config.barColors)||void 0===n?void 0:n[e])||d}const g={type:"point",x:o,y:a,r:c,style:{fill:d,opacity:u,stroke:h,strokeWidth:f},datum:i};t.getPointId&&(g.pointId=t.getPointId(i)+""),s.push(g)}return s}(n,e);case"waterfall":return function(t,e,i){var r,o,n;const s=[],a=t.scales,c=t.config.waterfallStyle,l=e.filter(e=>{const i=t.getY(e),r=t.getX(e);return null!=i&&!Number.isNaN(i)&&null!=r&&isFinite(r)});if(0===l.length)return s;const u=null!==(r=null==c?void 0:c.positiveColor)&&void 0!==r?r:"#28a745",h=null!==(o=null==c?void 0:c.negativeColor)&&void 0!==o?o:"#dc3545",f=null!==(n=null==c?void 0:c.gap)&&void 0!==n?n:1,d=null==c?void 0:c.stroke,g=null==c?void 0:c.strokeWidth;let y=0;for(let e=0;l.length>e;e++){const r=l[e],o=t.getX(r),n=t.getY(r),p=y+n;let m;m=l.length-1>e?t.getX(l[e+1])-o:e>0?o-t.getX(l[e-1]):0;const x=a.x(o),v=0!==m?a.x(o+m):x+i.width/10,b=Math.min(x,v)+f/2,k=Math.max(x,v)-f/2-b;if(0>=k){y=p;continue}const w=a.y(y),A=a.y(p);s.push(xt(b,Math.min(w,A),k,Math.abs(w-A),{fill:0>n?h:u,stroke:d,strokeWidth:g},Object.assign(Object.assign({},r),{baseline:y,cumEnd:p,delta:n,_connectorStroke:null==c?void 0:c.connectorStroke,_connectorWidth:null==c?void 0:c.connectorWidth}))),y=p}return s}(n,e,t);case"candlestick":return function(t,e){var i,r;if(!t.getHigh||!t.getLow||!t.scales)return[];const o=null!==(i=t.config.candlestickRangeMode)&&void 0!==i&&i;if(!(o||t.getOpen&&t.getClose))return[];const n=[],s=t.config.candlestickStyle||{},a=s.rangeColor||"#6366f1",c=o?a:s.upColor||"#28a745",l=o?a:s.downColor||"#dc3545",u=o?a:s.wickColor||"#333",h=s.wickWidth||(o?2:1),f=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let d=o?0:null!==(r=s.bodyWidth)&&void 0!==r?r:0;if(!o&&null==s.bodyWidth&&f.length>1){let e=1/0;for(let i=1;f.length>i;i++){const r=Math.abs(t.scales.x(f[i])-t.scales.x(f[i-1]));r>0&&e>r&&(e=r)}d=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else o||null!=s.bodyWidth||(d=6);for(const i of e){const e=t.getX(i);if(null==e||Number.isNaN(e))continue;const r=t.getHigh(i),s=t.getLow(i);if(null==r||Number.isNaN(r)||null==s||Number.isNaN(s))continue;const a=o?r:t.getOpen(i),f=o?s:t.getClose(i);if(!o&&[a,f].some(t=>null==t||Number.isNaN(t)))continue;const g=f>=a,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(a),closeY:t.scales.y(f),highY:t.scales.y(r),lowY:t.scales.y(s),bodyWidth:d,upColor:c,downColor:l,wickColor:u,wickWidth:h,isUp:g,datum:i};o&&(y.isRange=!0),n.push(y)}return n}(n,e);default:return[]}}resolveBoundsStyle(t,e){const i=this.config.boundsStyle;return"function"==typeof i?i(e||{},t):i&&"object"==typeof i?i:{fill:this.resolveLineStyle(t,e).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?ct(i,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,i){var r,o;const n=i.length;if(1>=n)return;const s=new Map;for(let t=0;i.length>t;t++)s.set(i[t],t);for(const i of e){if("line"===i.type){const e=Array.isArray(i.datum)?i.datum:[];if(2>e.length)continue;const r=Array(e.length);let o=!1;for(let i=0;e.length>i;i++){const a=s.get(e[i]);null!=a?(r[i]=ct(t,a,n),1>r[i]&&(o=!0)):r[i]=1}o&&(i._decayOpacities=r);continue}if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[],r=i.topPath?i.topPath.length:e.length;if(2>r)continue;if(e.length===r){const o=Array(r);let a=!1;for(let i=0;e.length>i;i++){const r=s.get(e[i]);null!=r?(o[i]=ct(t,r,n),1>o[i]&&(a=!0)):o[i]=1}a&&(i._decayOpacities=o)}else{let o=1;for(const i of e){const e=s.get(i);if(null!=e){const i=ct(t,e,n);o>i&&(o=i)}}if(1>o){const t=Array(r);t.fill(o),i._decayOpacities=t}}continue}const e=s.get(i.datum);if(null==e)continue;const a=ct(t,e,n);if("heatcell"===i.type)i.style={opacity:a};else if("candlestick"===i.type)i._decayOpacity=a;else{const t=null!==(o=null===(r=i.style)||void 0===r?void 0:r.opacity)&&void 0!==o?o:1;i.style=Object.assign(Object.assign({},i.style),{opacity:t*a})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,i,r){var o,n;const s="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(o=t.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",c=null!==(n=t.glowRadius)&&void 0!==n?n:4,l=new Map;for(let t=0;i.length>t;t++)l.set(i[t],t);for(const i of e){if("line"===i.type)continue;if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[i.datum];let o=0;for(const i of e){const e=l.get(i);if(null==e)continue;const n=r.get(e);if(null==n)continue;const a=lt(t,n,s);a>o&&(o=a)}o>0&&(i._pulseIntensity=o,i._pulseColor=a);continue}const e=l.get(i.datum);if(null==e)continue;const o=r.get(e);if(null==o)continue;const n=lt(t,o,s);n>0&&(i._pulseIntensity=n,i._pulseColor=a,i._pulseGlowRadius=c)}}(this.config.pulse,t,e,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(t,e){var i;if(!e||0===e.size)return!1;const r="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(i=t.duration)&&void 0!==i?i:500,n=e.peek();return null!=n&&o>r-n}(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,i,r){var o,n,s;i.clear(),r.clear();for(let a=0;e.length>a;a++){const c=e[a],l=gt(t,c,a);l&&("point"===c.type?i.set(l,{x:c.x,y:c.y,r:c.r,opacity:c.style.opacity}):"rect"===c.type?i.set(l,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:c.style.opacity}):"heatcell"===c.type?i.set(l,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:null===(o=c.style)||void 0===o?void 0:o.opacity}):"candlestick"===c.type?i.set(l,{x:c.x,y:c.openY}):"line"===c.type?r.set(l,{path:c.path.map(t=>[t[0],t[1]]),opacity:null===(n=c.style)||void 0===n?void 0:n.opacity}):"area"===c.type&&r.set(l,{topPath:c.topPath.map(t=>[t[0],t[1]]),bottomPath:c.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(s=c.style)||void 0===s?void 0:s.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}startTransition(){if(!this.config.transition)return;const t=function(t,e,i,r,o){var n,s,a,c,l,u,h,f,d,g,y,p,m,x,v,b,k,w,A,S,_,P,E,M,O,L,D,z;if(0===r.size&&0===o.size)return i;const j=null!==(n=e.duration)&&void 0!==n?n:300;if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}let T=!1;const N=new Set,$=new Set;for(let e=0;i.scene.length>e;e++){const n=i.scene[e],A=gt(t,n,e);if(!A)continue;if(n._transitionKey=A,"line"===n.type||"area"===n.type){const t=o.get(A);if(t){if($.add(A),"line"===n.type&&t.path&&t.path.length===n.path.length){n._targetPath=n.path.map(t=>[t[0],t[1]]),n._prevPath=t.path;for(let e=0;n.path.length>e;e++)n.path[e]=[t.path[e][0],t.path[e][1]];T=!0}else if("area"===n.type&&t.topPath&&t.bottomPath&&t.topPath.length===n.topPath.length&&t.bottomPath.length===n.bottomPath.length){n._targetTopPath=n.topPath.map(t=>[t[0],t[1]]),n._targetBottomPath=n.bottomPath.map(t=>[t[0],t[1]]),n._prevTopPath=t.topPath,n._prevBottomPath=t.bottomPath;for(let e=0;n.topPath.length>e;e++)n.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;n.bottomPath.length>e;e++)n.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];T=!0}n._targetOpacity=null!==(s=n.style.opacity)&&void 0!==s?s:1,n._startOpacity=null!==(c=null!==(a=t.opacity)&&void 0!==a?a:n.style.opacity)&&void 0!==c?c:1}else n._targetOpacity=null!==(l=n.style.opacity)&&void 0!==l?l:1,n._startOpacity=0,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),T=!0;continue}const S=r.get(A);if("point"===n.type)if(S){N.add(A);const t={x:n.x,y:n.y,r:n.r};n._targetOpacity=null!==(u=n.style.opacity)&&void 0!==u?u:1,S.x===t.x&&S.y===t.y&&S.r===t.r||(n._targetX=t.x,n._targetY=t.y,n._targetR=t.r,n.x=S.x,n.y=S.y,n.r=null!==(h=S.r)&&void 0!==h?h:n.r,T=!0)}else n._targetOpacity=null!==(f=n.style.opacity)&&void 0!==f?f:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),T=!0;else if("rect"===n.type)if(S){N.add(A);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=null!==(d=n.style.opacity)&&void 0!==d?d:1,S.x===t.x&&S.y===t.y&&S.w===t.w&&S.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=S.x,n.y=S.y,n.w=null!==(g=S.w)&&void 0!==g?g:n.w,n.h=null!==(y=S.h)&&void 0!==y?y:n.h,T=!0)}else n._targetOpacity=null!==(p=n.style.opacity)&&void 0!==p?p:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),T=!0;else if("heatcell"===n.type)if(S){N.add(A);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=null!==(x=null===(m=n.style)||void 0===m?void 0:m.opacity)&&void 0!==x?x:1,S.x===t.x&&S.y===t.y&&S.w===t.w&&S.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=S.x,n.y=S.y,n.w=null!==(v=S.w)&&void 0!==v?v:n.w,n.h=null!==(b=S.h)&&void 0!==b?b:n.h,T=!0)}else n._targetOpacity=null!==(w=null===(k=n.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,n.style=Object.assign(Object.assign({},n.style||{}),{opacity:0}),T=!0}for(const[t,e]of o)if(!$.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!==(A=e.opacity)&&void 0!==A?A:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(r),T=!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!==(S=e.opacity)&&void 0!==S?S:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(r),T=!0}for(const[t,e]of r)if(!N.has(t)){if(t.startsWith("p:")){const r={type:"point",x:e.x,y:e.y,r:null!==(_=e.r)&&void 0!==_?_:3,style:{opacity:null!==(P=e.opacity)&&void 0!==P?P:1},datum:null,_targetOpacity:0,_transitionKey:t};i.exitNodes.push(r)}else if(t.startsWith("r:")){const r={type:"rect",x:e.x,y:e.y,w:null!==(E=e.w)&&void 0!==E?E:0,h:null!==(M=e.h)&&void 0!==M?M:0,style:{opacity:null!==(O=e.opacity)&&void 0!==O?O:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};i.exitNodes.push(r)}else if(t.startsWith("h:")){const r={type:"heatcell",x:e.x,y:e.y,w:null!==(L=e.w)&&void 0!==L?L:0,h:null!==(D=e.h)&&void 0!==D?D:0,fill:"#999",datum:null,style:{opacity:null!==(z=e.opacity)&&void 0!==z?z:1},_targetOpacity:0,_transitionKey:t};i.exitNodes.push(r)}T=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),T&&(i.activeTransition={startTime:dt(),duration:j}),i}(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},i=function(t,e,i,r){var o,n,s,a,c;if(!i.activeTransition)return!1;const l=ht(t,i.activeTransition),u=ut(l,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of i.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const i=e?r.get(e):void 0,n=i?null!==(o=i.opacity)&&void 0!==o?o:1:0;t.style.opacity=ft(n,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const i=r.get(e);if(!i)continue;t.x=ft(i.x,t._targetX,u),t.y=ft(i.y,t._targetY,u),void 0!==t._targetR&&void 0!==i.r&&(t.r=ft(i.r,t._targetR,u))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=e?r.get(e):void 0,o=i?null!==(n=i.opacity)&&void 0!==n?n:1:0;t.style.opacity=ft(o,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const i=r.get(e);if(!i)continue;t.x=ft(i.x,t._targetX,u),t.y=ft(i.y,t._targetY,u),void 0!==i.w&&(t.w=ft(i.w,t._targetW,u)),void 0!==i.h&&(t.h=ft(i.h,t._targetH,u))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const i=e?r.get(e):void 0,o=i?null!==(s=i.opacity)&&void 0!==s?s:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:ft(o,t._targetOpacity,u)})}if(void 0===t._targetX)continue;if(!e)continue;const i=r.get(e);if(!i)continue;t.x=ft(i.x,t._targetX,u),t.y=ft(i.y,t._targetY,u),void 0!==i.w&&(t.w=ft(i.w,t._targetW,u)),void 0!==i.h&&(t.h=ft(i.h,t._targetH,u))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=null!==(a=t._startOpacity)&&void 0!==a?a:0;t.style=Object.assign(Object.assign({},t.style),{opacity:ft(e,t._targetOpacity,u)})}const e=t._prevPath,i=t._targetPath;if(e&&i&&e.length===t.path.length)for(let r=0;t.path.length>r;r++)t.path[r][0]=ft(e[r][0],i[r][0],u),t.path[r][1]=ft(e[r][1],i[r][1],u)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(c=t._startOpacity)&&void 0!==c?c:0;t.style=Object.assign(Object.assign({},t.style),{opacity:ft(e,t._targetOpacity,u)})}const e=t._prevTopPath,i=t._prevBottomPath,r=t._targetTopPath,o=t._targetBottomPath;if(e&&r&&e.length===t.topPath.length)for(let i=0;t.topPath.length>i;i++)t.topPath[i][0]=ft(e[i][0],r[i][0],u),t.topPath[i][1]=ft(e[i][1],r[i][1],u);if(i&&o&&i.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=ft(i[e][0],o[e][0],u),t.bottomPath[e][1]=ft(i[e][1],o[e][1],u)}}if(l>=1){for(const t of i.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 i=0;t.path.length>i;i++)t.path[i]=e[i];t._prevPath=void 0,t._targetPath=void 0}else if("area"===t.type){const e=t._targetTopPath,i=t._targetBottomPath;if(e)for(let i=0;t.topPath.length>i;i++)t.topPath[i]=e[i];if(i)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=i[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0}}if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}return i.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,i}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const i of t){const t=this.getGroup(i);e.has(t)||e.set(t,[]),e.get(t).push(i)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveColorMap(t){const e=new Set;for(const i of t){const t=this.getColor(i);t&&e.add(t)}const i=Array.from(e).sort(),r=i.join("\0");if(this._colorMapCache&&this._colorMapCache.key===r)return this._colorMapCache.map;const o=Array.isArray(this.config.colorScheme)?this.config.colorScheme:at,n=new Map;for(let t=0;i.length>t;t++)n.set(i[t],o[t%o.length]);return this._colorMapCache={key:r,map:n},n}resolveLineStyle(t,e){const i=this.config.lineStyle;if("function"==typeof i){const r=i(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 i&&"object"==typeof i?{stroke:i.stroke||"#007bff",strokeWidth:i.strokeWidth||2,strokeDasharray:i.strokeDasharray,fill:i.fill,fillOpacity:i.fillOpacity,opacity:i.opacity}:{stroke:this.resolveGroupColor(t)||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var i;if(this.config.areaStyle){const i=this.config.areaStyle(e||{});if(i&&!i.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{fill:e,stroke:i.stroke||e})}return i}const r=this.config.lineStyle;if("function"==typeof r){const i=r(e||{},t);if(i&&!i.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{fill:e,stroke:i.stroke||e})}return i}if(r&&"object"==typeof r)return{fill:r.fill||r.stroke||"#4e79a7",fillOpacity:null!==(i=r.fillOpacity)&&void 0!==i?i:.7,stroke:r.stroke||"#4e79a7",strokeWidth:r.strokeWidth||2};const o=this.resolveGroupColor(t)||"#4e79a7";return{fill:o,fillOpacity:.7,stroke:o,strokeWidth:2}}resolveGroupColor(t){if(this._colorMapCache){const e=this._colorMapCache.map.get(t);if(e)return e}const e=this._groupColorMap.get(t);if(e)return e;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:at,r=i[this._groupColorMap.size%i.length];return this._groupColorMap.set(t,r),r}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");const e=new Set(Array.isArray(t)?t:[t]),i=this.getPointId,r=t=>e.has(i(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,i)=>{r(t)&&e.add(i)}),this.timestampBuffer.clear();for(let i=0;t.length>i;i++)e.has(i)||this.timestampBuffer.push(t[i])}const o=this.buffer.remove(r);if(0===o.length)return o;for(const t of o)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,o}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const i=new Set(Array.isArray(t)?t:[t]),r=this.getPointId,o=new Set;this.buffer.forEach((t,e)=>{i.has(r(t))&&o.add(e)});const n=this.buffer.update(t=>i.has(r(t)),e);if(0===n.length)return n;for(const t of n)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.buffer.forEach((t,e)=>{o.has(e)&&(this.xExtent.push(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))):(this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,n}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,i,r,o;const n=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 s=!1;Object.assign(this.config,t);const a="chartType"in t&&t.chartType!==n.chartType||"runtimeMode"in t&&t.runtimeMode!==n.runtimeMode;if(a||void 0!==t.xAccessor||void 0!==t.yAccessor||void 0!==t.timeAccessor||void 0!==t.valueAccessor){const c=a||!rt(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(i=n.xAccessor)&&void 0!==i?i:n.timeAccessor),l=a||!rt(null!==(r=t.yAccessor)&&void 0!==r?r:t.valueAccessor,null!==(o=n.yAccessor)&&void 0!==o?o:n.valueAccessor);(c||l)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=ot(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=ot(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=ot(this.config.xAccessor,"x"),this.getY=ot(this.config.yAccessor,"y")),s=!0)}if("groupAccessor"in t&&!rt(t.groupAccessor,n.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?st(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in t&&!rt(t.categoryAccessor,n.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?st(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in t&&!rt(t.sizeAccessor,n.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?ot(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in t&&!rt(t.colorAccessor,n.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?st(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in t&&!rt(t.y0Accessor,n.y0Accessor)&&(this.getY0=this.config.y0Accessor?ot(this.config.y0Accessor,"y0"):void 0,s=!0),"pointIdAccessor"in t&&!rt(t.pointIdAccessor,n.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?st(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&("openAccessor"in t&&!rt(t.openAccessor,n.openAccessor)||"closeAccessor"in t&&!rt(t.closeAccessor,n.closeAccessor)||"highAccessor"in t&&!rt(t.highAccessor,n.highAccessor)||"lowAccessor"in t&&!rt(t.lowAccessor,n.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?ot(this.config.openAccessor,"open"):void 0,this.getHigh=ot(this.config.highAccessor,"high"),this.getLow=ot(this.config.lowAccessor,"low"),this.getClose=e?ot(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,s=!0}if(!s){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const i of e)if(t[i]!==n[i]){s=!0;break}}s&&(this.needsFullRebuild=!0)}}function _t(t,e){var i=t.get(e);if(!i)throw Error("missing: "+e);return i}function Pt(t,e){var i,r=[],o=[],n=[],s={},a=[];function c(t){n[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],n[e]&&c(e)})}function l(t){var e,r,h=!1;for(o.push(t),n[t]=!0,e=0;a[t].length>e;e++)(r=a[t][e])===i?(u(i,o),h=!0):n[r]||(h=l(r));if(h)c(t);else for(e=0;a[t].length>e;e++){var f=s[r=a[t][e]];f||(s[r]=f={}),f[r]=!0}return o.pop(),h}function u(t,e){var i=[].concat(e).concat(t);r.push(i)}function h(e){!function(e){for(var i=0;t.length>i;i++)i>=e&&t[i]||(t[i]=[]),t[i]=t[i].filter(function(t){return t>=e})}(e);for(var i,r=function(t){for(var e=t.length,i=Array(e),r=Array(e),o=Array(e),n=Array(e),s=Array(e),a=Array(e),c=0;e>c;++c)i[c]=-1,r[c]=0,o[c]=!1,n[c]=0,s[c]=-1,a[c]=[];var l,u=0,h=[],f=[];function d(e){var c=[e],l=[e];for(i[e]=r[e]=u,o[e]=!0,u+=1;l.length>0;){var d=t[e=l[l.length-1]];if(d.length>n[e]){for(var g=n[e];d.length>g;++g){var y=d[g];if(0>i[y]){i[y]=r[y]=u,o[y]=!0,u+=1,c.push(y),l.push(y);break}o[y]&&(r[e]=0|Math.min(r[e],r[y])),0>s[y]||a[e].push(s[y])}n[e]=g}else{if(r[e]===i[e]){var p=[],m=[],x=0;for(g=c.length-1;g>=0;--g){var v=c[g];if(o[v]=!1,p.push(v),m.push(a[v]),x+=a[v].length,s[v]=h.length,v===e){c.length=g;break}}h.push(p);var b=Array(x);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)b[--x]=m[g][k];f.push(b)}l.pop()}}}for(c=0;e>c;++c)0>i[c]&&d(c);for(c=0;f.length>c;c++){var g=f[c];if(0!==g.length){g.sort(function(t,e){return t-e}),l=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&l.push(g[y]);f[c]=l}}return{components:h,adjacencyList:f}}(t),o=r.components.filter(function(t){return t.length>1}),n=1/0,s=0;o.length>s;s++)for(var a=0;o[s].length>a;a++)n>o[s][a]&&(n=o[s][a],i=s);var c=o[i];if(!c)return!1;var l=t.map(function(t,e){return-1===c.indexOf(e)?[]:t.filter(function(t){return-1!==c.indexOf(t)})});return{leastVertex:n,adjList:l}}i=0;for(var f=t.length;f>i;){var d=h(i);if(i=d.leastVertex,a=d.adjList){for(var g=0;a.length>g;g++)for(var y=0;a[g].length>y;y++){var p=a[g][y];n[+p]=!1,s[p]={}}l(i),i+=1}else i=f}return r}function Et(t){return t.y0-t.y1>0?"up":"down"}function Mt(t,e){return e(t.source)==e(t.target)}function Ot(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var i=0;return t.target.targetLinks.forEach(function(t){i=t.circular?i+1:i}),1>=e&&1>=i}function Lt(t){return t.target.x0-t.source.x1}function Dt(t,e){var i=jt(t),r=Lt(e)/Math.tan(i);return"up"==Et(t)?t.y1-r:t.y1+r}function zt(t,e){var i=jt(t),r=Lt(e)/Math.tan(i);return"up"==Et(t)?t.y1+r:t.y1-r}function jt(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function Tt(t,e){return e(t)}function Nt(t){return Bt(t.source)}function $t(t){return Bt(t.target)}function Bt(t){return(t.y0+t.y1)/2}function Wt(t){return t.virtual?0:t.value}function Rt(t,e){var i=0;t.sourceLinks.forEach(function(t){i=t.circular&&!Mt(t,e)?i+1:i});var r=0;return t.targetLinks.forEach(function(t){r=t.circular&&!Mt(t,e)?r+1:r}),i+r}function Ft(t){return t.target.depth}function Ct(t,e){return t.sourceLinks.length?t.depth:e-1}function It(t,e){return t.y0-e.y0}function Yt(t,e){return e.y0-t.y0}function Xt(t,e){return t.y1-e.y1}function qt(t,e){return e.y1-t.y1}function Gt(t,e){return Ht(t.source,e.source)||t.index-e.index}function Vt(t,e){return Ht(t.target,e.target)||t.index-e.index}function Ht(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Zt(t,e){return Kt(t)==Kt(e)?"bottom"==t.circularLinkType?Yt(t,e):It(t,e):Kt(e)-Kt(t)}function Kt(t){return t.target.column-t.source.column}function Ut(t,e){return Qt(t)==Qt(e)}function Qt(t){return t.y0-t.y1>0?"up":"down"}function Jt(t,e,i,r,o){let n=t;var s=Math.max(8,.15*(n.y1-n.y0));n.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,s))});var a=x(n.links,function(t){return t.source.y0});n.links.forEach(function(t){t.circular&&(t.circularPathData={})});var c=n.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}),te(n.links.filter(function(t){return"top"==t.circularLinkType}),e,i),te(n.links.filter(function(t){return"bottom"==t.circularLinkType}),e,i),n.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,Mt(t,e)&&Ot(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 s=t.source.column,c=t.circularLinkType,l=n.links.filter(function(t){return t.source.column==s&&t.circularLinkType==c});l.sort("bottom"==t.circularLinkType?Yt:It);var u=0;l.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=r+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=r+t._circularWidth/2+o*i+u),u+=e._circularWidth||e.width}),s=t.target.column,(l=n.links.filter(function(t){return t.target.column==s&&t.circularLinkType==c})).sort("bottom"==t.circularLinkType?qt:Xt),u=0,l.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=r+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=r+t._circularWidth/2+o*i+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(n.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=a-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,i=t.y0,r=t.target.x0,o=t.y1,n=(e+r)/2;return"M"+e+","+i+"C"+n+","+i+" "+n+","+o+" "+r+","+o}(t)}),n}function te(t,e,i){t.sort(Zt);var r=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,o){var n=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(Mt(t,e)&&Ot(t))t.circularPathData.verticalBuffer=n+t._circularWidth/2;else{for(var s=0;r.length>s;s++){var a=r[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&ee(t,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+i;n=c>n?c:n}}t.circularPathData.verticalBuffer=n+t._circularWidth/2}}),t}function ee(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function ie(t){return function(){return t}}function re(t){return t.index}function oe(t){return t.nodes}function ne(t){return t.links}function se(t,e,i){var r=v(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,n){var s=o.length;if(e)o.sort(e);else if(n>0){var a=new Map;o.forEach(function(t,e){var i,r,o,n=(r=0,o=0,(i=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=Bt(t.source)*e,r+=e}}),i.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=Bt(t.target)*e,r+=e}}),r>0?o/r:NaN);a.set(t,{bc:n,idx:e})}),o.sort(function(t,e){var i=a.get(t),r=a.get(e),o=i.bc,n=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(n)?isNaN(o)?isNaN(n)?i.idx-r.idx:1:-1:o-n})}else o.sort(function(t,e){return t.circularLinkType==e.circularLinkType?Rt(e,i)-Rt(t,i):"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==s||0==e.depth&&1==s?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==Rt(e,i)?(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)/s*o,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-s/2+o,e.y1=e.y0+e.value*t.ky)})})}function ae(t,e,i,r,o,n){var s=v(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});u();for(var a=1,c=n;c>0;--c)l(a*=.99,i),u();function l(e,i){var r=s.length;s.forEach(function(o){var n=o.length,s=o[0].depth;o.forEach(function(o){var a;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&Rt(o,i)>0){var c=w(o.sourceLinks,$t),l=w(o.targetLinks,Nt),u=c&&l?(c+l)/2:c||l;if(u){var h=(u-Bt(o))*e*.3;o.y0+=h,o.y1+=h}}else if(0==s&&1==n)o.y0=t.y1/2-(a=o.y1-o.y0)/2,o.y1=t.y1/2+a/2;else if(s==r-1&&1==n)o.y0=t.y1/2-(a=o.y1-o.y0)/2,o.y1=t.y1/2+a/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)a=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+a;else{var f=w(o.sourceLinks,$t),d=w(o.targetLinks,Nt),g=((f&&d?(f+d)/2:f||d)-Bt(o))*e;o.y0+=g,o.y1+=g}})})}function u(){s.forEach(function(i){var n,s,a,c=t.y0,l=i.length;for(i.sort(e||Ht),a=0;l>a;++a)(s=c-(n=i[a]).y0)>0&&(n.y0+=s,n.y1+=s),c=n.y1+r;if((s=c-r-t.y1)>0)for(c=n.y0-=s,n.y1-=s,a=l-2;a>=0;--a)(s=(n=i[a]).y1+o-c)>0&&(n.y0-=s,n.y1-=s),c=n.y0})}}function ce(t){t.nodes.forEach(function(t){t.sourceLinks.sort(Vt),t.targetLinks.sort(Gt)}),t.nodes.forEach(function(t){var e=t.y0,i=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=i+t.width/2,i+=t.width)})})}function le(){var t=0,e=0,i=1,r=1,o=24,n=8,s=null,a=re,c=Ct,l=void 0,u=32,h=2,f=oe,d=ne;function g(){var g={nodes:f.apply(null,arguments),links:d.apply(null,arguments)};return function(f){f.x0=t,f.y0=e,f.x1=i,f.y1=r,f.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var i=function(t,e){var i=new Map;return A(t,e).forEach(function(t,e){i.set(e,t[0])}),i}(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=_t(i,r)),"object"!=typeof o&&(o=t.target=_t(i,o)),r.sourceLinks.push(t),o.targetLinks.push(t)})}(f,a),function(t,e){var i=0;if(null==e){for(var r=[],o=0;t.links.length>o;o++){var n=t.links[o],s=n.source.index,a=n.target.index;r[s]||(r[s]=[]),r[a]||(r[a]=[]),-1===r[s].indexOf(a)&&r[s].push(a)}var c=Pt(r);c.sort(function(t,e){return t.length-e.length});var l={};for(o=0;c.length>o;o++){var u=c[o].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,r=t.source.index;e===r||l[r]&&l[r][e]?(t.circular=!0,t.circularLinkID=i++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=i++)})}(f,l),function(t,e){var i=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>i?"top":"bottom","top"==o.circularLinkType?i++:r++,t.nodes.forEach(function(t){Tt(t,e)!=Tt(o.source,e)&&Tt(t,e)!=Tt(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),Mt(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(f,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(k(t.sourceLinks,Wt),k(t.targetLinks,Wt)),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,i){var r,o,n;if(null!=e){t.nodes.sort(function(t,i){return e(t)<e(i)?-1:1});var s=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==a?s:s+1,a=e(t)==a?a:e(t),t.column=s})}for(r=t.nodes,o=[],n=0;r.length;++n,r=o,o=[])r.forEach(function(t){t.depth=n,t.sourceLinks.forEach(function(t){0>o.indexOf(t.target)&&!t.circular&&o.push(t.target)})});for(r=t.nodes,o=[],n=0;r.length;++n,r=o,o=[])r.forEach(function(t){t.height=n,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?i(t,n):t.column})}(f,l,c);var d=n;if(null!==s){var g=v(f.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),y=b(g,function(t){return t.length});y>1&&(d=Math.max(1,(r-e)*s/(y-1)))}(function(t,e,i){var r=v(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=x(r,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/k(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var n=b(t.nodes,function(t){return t.column});t.nodes.forEach(n>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-i)/n),e.x1=e.x0+i}:function(e){e.x0=t.x0,e.x1=e.x0+i})})(f,d,o),se(f,l,a),ae(f,l,a,d,d,u),ce(f),Jt(f,a,h,10,8),se(f,l,a),ae(f,l,a,d,d,u),ce(f),Jt(f,a,h,10,8),function(t,e){let i=t;i.nodes.forEach(function(t){t.y+(t.y1-t.y0)>i.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-i.y1));var r=i.links.filter(function(i){return Tt(i.source,e)==Tt(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(!Ut(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var i=Dt(e,t);return t.y1-i}if(e.target.column>t.target.column)return Dt(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 n=t.y0;r.forEach(function(t){t.y0=n+t.width/2,n+=t.width}),r.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var n=i+1,s=0;o>n;n++)s+=r[n].width;e.y0=t.y1-s-e.width/2}})})}(f,a),function(t,e){let i=t;i.nodes.forEach(function(t){var r=i.links.filter(function(i){return Tt(i.target,e)==Tt(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(!Ut(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var i=zt(e,t);return t.y0-i}if(e.source.column>t.source.column)return zt(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 n=t.y0;r.forEach(function(t){t.y1=n+t.width/2,n+=t.width}),r.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var n=i+1,s=0;o>n;n++)s+=r[n].width;e.y1=t.y1-s-e.width/2}})})}(f,a),function(t){var e=t.nodes,i=t.links,r=!1,o=!1;if(i.forEach(function(t){"top"==t.circularLinkType?r=!0:"bottom"==t.circularLinkType&&(o=!0)}),0==r||0==o){var n=x(e,function(t){return t.y0}),s=b(e,function(t){return t.y1}),a=(t.y1-t.y0)/(s-n);function c(e){return(e-n)/(s-n)*(t.y1-t.y0)+t.y0}1>a?(e.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1)}),i.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1),t.width=t.width*a})):e.forEach(function(t){var e=t.y1-t.y0,i=c(t.y0)-t.y0;t.y0=c(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+i}),t.targetLinks.forEach(function(t){t.y1=t.y1+i})})}}(f),Jt(f,a,h,10,8)}(g),g}return g.update=function(t){return ce(t),Jt(t,a,h,10,8),t},g.nodeWidth=function(t){return arguments.length?(o=+t,g):o},g.nodePadding=function(t){return arguments.length?(n=+t,g):n},g.nodePaddingRatio=function(t){return arguments.length?(s=+t,g):s},g.nodes=function(t){return arguments.length?(f="function"==typeof t?t:ie(t),g):f},g.links=function(t){return arguments.length?(d="function"==typeof t?t:ie(t),g):d},g.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:ie(t),g):a},g.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:ie(t),g):c},g.nodeSort=function(t){return arguments.length?(l=t,g):l},g.iterations=function(t){return arguments.length?(u=+t,g):u},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],i=+o[1][0],r=+o[1][1],g):[[t,e],[i,r]]},g.size=function(o){return arguments.length?(t=e=0,i=+o[0],r=+o[1],g):[i-t,r-e]},g}St.QUADTREE_THRESHOLD=500;const ue=t=>{let e,i,r,o,n,s,a,c,l;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,i=t.y1-t.sankeyWidth/2,r=t.y1+t.sankeyWidth/2,o=t.y0+t.sankeyWidth/2,n=t.source.x1,s=t.target.x0,a=_(n,s),c=a(.5),l=a(.5),`M${e},${n}C${e},${c} ${i},${l} ${i},${s}L${r},${s}C${r},${l} ${o},${c} ${o},${n}Z`):(e=t.source.x1,i=t.target.x0,a=_(e,i),r=a(.5),o=a(.5),n=t.y0-t.sankeyWidth/2,s=t.y1-t.sankeyWidth/2,c=t.y1+t.sankeyWidth/2,l=t.y0+t.sankeyWidth/2,`M${e},${n}C${r},${n} ${o},${s} ${i},${s}L${i},${c}C${o},${c} ${r},${l} ${e},${l}Z`)};function he(t){var e;const i=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,n=o.targetX,s=o.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(o.rightFullExtent-e))),c=Math.max(15,Math.min(40,.33*(n-o.leftFullExtent)));return`M${e},${r-i}L${e+a},${r-i}L${e+a},${r+i}L${e},${r+i}ZM${n},${s-i}L${n-c},${s-i}L${n-c},${s+i}L${n},${s+i}Z`}const n=o.sourceX,s=o.sourceY,a=o.targetX,c=o.targetY,l=o.rightFullExtent,u=o.leftFullExtent,h=o.verticalFullExtent,f="bottom"===t.circularLinkType?1:-1,d=Math.max(4,Math.min(r,15));return`M${n},${s-f*i}L${l},${s-f*i}L${l+r},${s-f*i+f*d}L${l+r},${h+f*r-f*d}L${l+r-d},${h+f*r}L${u-r+d},${h+f*r}L${u-r},${h+f*r-f*d}L${u-r},${c-f*i+f*d}L${u-r+d},${c-f*i}L${a},${c-f*i}L${a},${c+f*i}L${u+r},${c+f*i}L${u+r},${h-f*r}L${l-r},${h-f*r}L${l-r},${s+f*i}L${n},${s+f*i}Z`}const fe=new Set,de=new WeakMap;function ge(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let i=de.get(t);if(i){const t=i.get(e);if(t)return t}else i=new Map,de.set(t,i);const r=new Proxy(t,{get(t,i,r){if("string"==typeof i&&!(i in t)&&t.data&&i in t.data){const t=`${e}:${i}`;fe.has(t)||(fe.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${i}" on the wrapper object, but it only exists on ".data". Use d.data.${i} (or d.data?.${i}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,i,r)}});return i.set(e,r),r}const ye={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(Ft))-1:0},justify:Ct},pe={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,r){var o,n,s,a,c,l,u;if(0===t.length)return;const h="vertical"===i.orientation?"down":"right",f=i.nodeAlign||"justify",d=null!==(o=i.nodeWidth)&&void 0!==o?o:15,g=null!==(n=i.nodePaddingRatio)&&void 0!==n?n:.05,y=null!==(s=i.iterations)&&void 0!==s?s: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 x;x="down"===h?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const v=le().extent(x).links(m).nodes(p).nodeAlign(ye[f]||Ct).nodeId(t=>t.id).nodeWidth(d).iterations(y);v.nodePaddingRatio&&v.nodePaddingRatio(g),v();{let t=1/0,e=-1/0,i=1/0,o=-1/0;for(const r of p)t>r.x0&&(t=r.x0),r.x1>e&&(e=r.x1),i>r.y0&&(i=r.y0),r.y1>o&&(o=r.y1);for(const r of m){if(!r.circular||!r.circularPathData)continue;const n=r.circularPathData,s=(null!==(c=null!==(a=r._circularWidth)&&void 0!==a?a:r.width)&&void 0!==c?c:0)/2;t>n.leftFullExtent-s&&(t=n.leftFullExtent-s),n.rightFullExtent+s>e&&(e=n.rightFullExtent+s),i>n.verticalFullExtent-s&&(i=n.verticalFullExtent-s),n.verticalFullExtent+s>o&&(o=n.verticalFullExtent+s)}const n=e-t,s=o-i,u=r[0],h=r[1];if(n>0&&s>0&&(0>t||0>i||e>u||o>h)){const e=Math.min(u/n,h/s),r=-t*e+(u-n*e)/2,o=-i*e+(h-s*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!==(l=t.width)&&void 0!==l?l:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const i=t.circularPathData;i.sourceX=i.sourceX*e+r,i.targetX=i.targetX*e+r,i.sourceY=i.sourceY*e+o,i.targetY=i.targetY*e+o,i.rightFullExtent=i.rightFullExtent*e+r,i.leftFullExtent=i.leftFullExtent*e+r,i.verticalFullExtent=i.verticalFullExtent*e+o,i.rightInnerExtent=i.rightInnerExtent*e+r,i.leftInnerExtent=i.leftInnerExtent*e+r,i.verticalRightInnerExtent=i.verticalRightInnerExtent*e+o,i.verticalLeftInnerExtent=i.verticalLeftInnerExtent*e+o,i.rightSmallArcRadius*=e,i.rightLargeArcRadius*=e,i.leftSmallArcRadius*=e,i.leftLargeArcRadius*=e,i.sourceWidth*=e,i.rightNodeBuffer*=e,i.leftNodeBuffer*=e,i.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,i=t.target,r="object"==typeof e&&null!==e?e.id:e+"",o="object"==typeof i&&null!==i?i.id:i+"",n=k.get(t._edgeKey?t._edgeKey:`${r}\0${o}`);if(n){n.y0=t.y0,n.y1=t.y1,n.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,n.circular=!!t.circular,n.circularPathData=t.circularPathData,n._circularWidth=t._circularWidth,n._circularStub=t._circularStub,n.path=t.path,n.circularLinkType=t.circularLinkType,n.direction=h;const e=b.get(r),i=b.get(o);e&&(n.source=e),i&&(n.target=i)}}},buildScene(t,e,i,r){var o,n,s,a;const c="vertical"===i.orientation?"down":"right",l=i.nodeStyle,u=i.edgeStyle,h=null!==(o=i.edgeOpacity)&&void 0!==o?o:.5,f=i.edgeColorBy||"source",d=Array.isArray(i.colorScheme)?i.colorScheme:m,g=new Map;t.forEach((t,e)=>{g.set(t.id,d[e%d.length])});const y=[],p=[],x=[],v=new Map;for(const e of t){const t=e.x1-e.x0,i=e.y1-e.y0;if(0>=t||0>=i)continue;const r=l?l(ge(e,"nodeStyle")):{},o={fill:r.fill||g.get(e.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};v.set(e.id,("string"==typeof o.fill?o.fill:null)||g.get(e.id)||"#4d430c"),y.push("down"===c?{type:"rect",x:e.y0,y:e.x0,w:i,h:t,style:o,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:i,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,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let r="#999";r="function"==typeof f?f(t)||r:"target"===f?v.get(i.id)||g.get(i.id)||r:v.get(e.id)||g.get(e.id)||r;const o=u?u(ge(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,i=t.sankeyWidth/2,a=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),c=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),l=o.fill||r;p.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-i}L${e.sourceX+a},${e.sourceY-i}L${e.sourceX+a},${e.sourceY+i}L${e.sourceX},${e.sourceY+i}Z`,style:{fill:l,fillOpacity:null!==(n=o.fillOpacity)&&void 0!==n?n:h,stroke:"none",opacity:o.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+a}}),p.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-i}L${e.targetX-c},${e.targetY-i}L${e.targetX-c},${e.targetY+i}L${e.targetX},${e.targetY+i}Z`,style:{fill:l,fillOpacity:null!==(s=o.fillOpacity)&&void 0!==s?s:h,stroke:"none",opacity:o.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-c,x1:e.targetX}});continue}let c;if(c=t.circular&&t.circularPathData?he(t):ue(t),!c)continue;const l={fill:o.fill||r,fillOpacity:null!==(a=o.fillOpacity)&&void 0!==a?a:h,stroke:o.stroke||"none",strokeWidth:o.strokeWidth,opacity:o.opacity};p.push({type:"bezier",pathD:c,bezierCache:t.bezier,style:l,datum:t})}if(!1!==i.showLabels){const e=(k=i.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null;for(const i of t){const t=i.x1-i.x0,o=i.y1-i.y0;if(0>=t||0>=o)continue;const n=e?e(i):i.id;if(!n)continue;let s,a,l;"down"===c?(s=i.y0+(i.y1-i.y0)/2,a=i.x1+14,l="middle"):(r[0]/2>i.x0+t/2?(s=i.x0-6,l="end"):(s=i.x1+6,l="start"),a=i.y0+o/2),x.push({x:s,y:a,text:n+"",anchor:l,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:y,sceneEdges:p,labels:x}}},me={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,r){var o,n;if(0===t.length)return;const s=null!==(o=i.forceStrength)&&void 0!==o?o:.1,a=r[0]/2,c=r[1]/2,l=i.__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),i=null==l?void 0:l.get(e.id);t?u++:i?(e.x=i.x,e.y=i.y,u++):h.push(e)}const f=u>0&&.3>=(t.length>0?h.length/t.length:1);if(f){const i=new Map;for(const e of t)i.set(e.id,e);for(const t of h){const r=xe(t.id,e,i);if(r.length>0){let e=0,i=0;for(const t of r)e+=t.x,i+=t.y;const o=ve(t.id),n=o%360*(Math.PI/180),s=10+o%20;t.x=e/r.length+s*Math.cos(n),t.y=i/r.length+s*Math.sin(n)}else{const e=ve(t.id),i=e%360*(Math.PI/180),r=15+e%30;t.x=a+r*Math.cos(i),t.y=c+r*Math.sin(i)}}}else{const e=2.399963229728653;for(let i=0;t.length>i;i++){const r=t[i];if(null==r.x||null==r.y||0===r.x&&0===r.y){const t=10*Math.sqrt(i+.5),o=i*e;r.x=a+t*Math.cos(o),r.y=c+t*Math.sin(o)}}}const d=null!==(n=i.iterations)&&void 0!==n?n:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),g=0===i.iterations?0:f?40:d,y=be(i.nodeSize,i.nodeSizeRange,t),p=t=>y(t);if(g>0){const i=P().strength(t=>Math.min(2.5,t.weight?t.weight*s:s)).id(t=>t.id),r=E().force("charge",M().strength(t=>-25*p(t))).force("center",O(a,c).strength(.8)).force("x",L(a).strength(.15)).force("y",D(c).strength(.15));if(r.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));r.force("link",i),r.force("link").links(t)}f?r.alpha(.3):.1>r.alpha()&&r.alpha(1),r.stop();for(let t=0;g>t;++t)r.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=p(e);e.x=Math.max(t,Math.min(r[0]-t,e.x)),e.y=Math.max(t,Math.min(r[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const m=new Map;for(const e of t)m.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=m.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=m.get(t.target);e&&(t.target=e)}}},buildScene(t,e,i,r){var o,n,s;const a=i.nodeStyle,c=i.edgeStyle,l=be(i.nodeSize,i.nodeSizeRange,t),u=Array.isArray(i.colorScheme)?i.colorScheme:m,h=new Map;t.forEach((t,e)=>{h.set(t.id,u[e%u.length])});const f=[],d=[],g=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=l(ge(e,"nodeSize")),i=a?a(ge(e,"nodeStyle")):{},r={fill:i.fill||h.get(e.id)||"#007bff",stroke:i.stroke||"#fff",strokeWidth:null!==(o=i.strokeWidth)&&void 0!==o?o:2,opacity:i.opacity};f.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id})}const y=new Map;for(const e of t)y.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:y.get(t.source),i="object"==typeof t.target?t.target:y.get(t.target);if(!e||!i)continue;if(null==e.x||null==e.y)continue;if(null==i.x||null==i.y)continue;const r=c?c(ge(t,"edgeStyle")):{},o={stroke:r.stroke||"#999",strokeWidth:null!==(n=r.strokeWidth)&&void 0!==n?n:1,opacity:null!==(s=r.opacity)&&void 0!==s?s:.6};d.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:o,datum:t})}if(!1!==i.showLabels){const e=(p=i.nodeLabel)?"function"==typeof p?p:t=>t[p]||t.id:null;for(const i of t){if(null==i.x||null==i.y)continue;const t=e?e(i):i.id;if(!t)continue;const r=l(ge(i,"nodeSize"));g.push({x:i.x,y:i.y-r-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var p;return{sceneNodes:f,sceneEdges:d,labels:g}}};function xe(t,e,i){const r=[];for(const o of e){const e="string"==typeof o.source?o.source:o.source.id,n="string"==typeof o.target?o.target:o.target.id;let s=null;if(e===t?s=n:n===t&&(s=e),s){const t=i.get(s);!t||0===t.x&&0===t.y||r.push({x:t.x,y:t.y})}}return r}function ve(t){let e=0;for(let i=0;t.length>i;i++)e=(e<<5)-e+t.charCodeAt(i)|0;return Math.abs(e)}function be(t,e,i){var r,o;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const n=e||[5,20],s=i.map(e=>{var i;return null===(i=e.data)||void 0===i?void 0:i[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===s.length)return()=>n[0];const c=null!==(r=x(s))&&void 0!==r?r:0,l=null!==(o=b(s))&&void 0!==o?o:1;if(c===l)return()=>(n[0]+n[1])/2;const u=a().domain([c,l]).range(n).clamp(!0);return e=>{var i;const r=null===(i=e.data)||void 0===i?void 0:i[t];return null==r||"number"!=typeof r?n[0]:u(r)}}const ke=m,we={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,i,r){if(0===t.length)return;const{padAngle:o=.01,groupWidth:n=20,sortGroups:s}=i,a=Math.min(r[0],r[1])/2,c=a-n,l=r[0]/2,u=r[1]/2,h=(f=i.valueAccessor)?"function"==typeof f?f:t=>{var e;return null!==(e=t[f])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var f;const d=new Map;for(let e=0;t.length>e;e++)d.set(t[e].id,e);const g=t.length,y=Array.from({length:g},()=>Array.from({length:g},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,i=d.get("string"==typeof t.source?t.source:t.source.id),r=d.get(e);if(void 0===i||void 0===r)continue;const o=h(t);y[i][r]=o}const p=j().padAngle(o);s&&p.sortGroups(s);const m=p(y),x=m.groups,v=T().innerRadius(c).outerRadius(a);for(const e of x){const i=t[e.index],r=v.centroid(e);i.x=r[0]+l,i.y=r[1]+u,i.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,i=b.get("string"==typeof t.source?t.source:t.source.id),r=b.get(e);i&&(t.source=i),r&&(t.target=r)}const k=new Map;for(const t of e)k.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 m){const i=t[e.source.index].id,r=t[e.target.index].id,o=k.get(`${i}\0${r}`)||k.get(`${r}\0${i}`);o&&(o.chordData=e)}},buildScene(t,e,i,r){var o,n;const{groupWidth:s=20,edgeOpacity:a=.5}=i,c=Math.min(r[0],r[1])/2,l=c-s,u=r[0]/2,h=r[1]/2,f=i.nodeStyle,d=i.edgeStyle,g=i.edgeColorBy||"source",y=Array.isArray(i.colorScheme)?i.colorScheme:ke,p=new Map;t.forEach((t,e)=>{p.set(t.id,y[e%y.length])});const m=z().radius(l),x=[],v=[],b=[];for(let e=0;t.length>e;e++){const i=t[e],r=i.arcData;if(!r)continue;let n;n=f?f(ge(i,"nodeStyle")).fill||p.get(i.id)||y[e%y.length]:p.get(i.id)||y[e%y.length];const s=f?f(ge(i,"nodeStyle")):{},a={fill:n,stroke:s.stroke||"black",strokeWidth:null!==(o=s.strokeWidth)&&void 0!==o?o:1,opacity:s.opacity};x.push({type:"arc",cx:u,cy:h,innerR:l,outerR:c,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:a,datum:i,id:i.id,label:i.id})}for(const t of e){const e=t.chordData;if(!e)continue;const i=m(e);if(!i)continue;const r=Ae(i,u,h);let o="#999";if(d)o=d(ge(t,"edgeStyle")).fill||o;else{const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;"target"===g&&i?o=p.get(i.id)||o:e&&(o=p.get(e.id)||o)}const s=d?d(ge(t,"edgeStyle")):{},c={fill:o,fillOpacity:null!==(n=s.fillOpacity)&&void 0!==n?n:a,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity};v.push({type:"ribbon",pathD:r,style:c,datum:t})}if(!1!==i.showLabels){const e=(k=i.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null,r=c+12;for(const i of t){const t=i.arcData;if(!t)continue;const o=e?e(i):i.id;if(!o)continue;const n=(t.startAngle+t.endAngle)/2,s=n-Math.PI/2;b.push({x:u+Math.cos(s)*r,y:h+Math.sin(s)*r,text:o+"",anchor:n>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var k;return{sceneNodes:x,sceneEdges:v,labels:b}}};function Ae(t,e,i){const r=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return t;const o=[];let n=0;for(;r.length>n;){const t=r[n];if("M"===t||"L"===t)for(o.push(t),n++;r.length>n&&!isNaN(Number(r[n]));)o.push(Number(r[n])+e+""),n++,r.length>n&&!isNaN(Number(r[n]))&&(o.push(Number(r[n])+i+""),n++);else if("C"===t)for(o.push(t),n++;r.length>n&&!isNaN(Number(r[n]));)for(let t=0;3>t&&r.length>n&&!isNaN(Number(r[n]));t++)o.push(Number(r[n])+e+""),n++,r.length>n&&!isNaN(Number(r[n]))&&(o.push(Number(r[n])+i+""),n++);else if("Q"===t)for(o.push(t),n++;r.length>n&&!isNaN(Number(r[n]));)for(let t=0;2>t&&r.length>n&&!isNaN(Number(r[n]));t++)o.push(Number(r[n])+e+""),n++,r.length>n&&!isNaN(Number(r[n]))&&(o.push(Number(r[n])+i+""),n++);else if("A"===t)for(o.push(t),n++;r.length>n&&!isNaN(Number(r[n]));)o.push(r[n++]),r.length>n&&o.push(r[n++]),r.length>n&&o.push(r[n++]),r.length>n&&o.push(r[n++]),r.length>n&&o.push(r[n++]),r.length>n&&(o.push(Number(r[n])+e+""),n++),r.length>n&&(o.push(Number(r[n])+i+""),n++);else"Z"===t||"z"===t?(o.push(t),n++):(o.push(r[n]),n++)}return o.join(" ")}const Se=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function _e(t){const[e,i,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*i+.114*r>150?"#222":"#fff"}function Pe(t,e,i){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-"+i}function Ee(t){return t?"function"==typeof t?t:e=>{var i;return(null===(i=e.data)||void 0===i?void 0:i[t])||e[t]||e.id}:null}function Me(t,e,i,r,o){if("horizontal"===o){const o=(t+i)/2;return`M ${t},${e} C ${o},${e} ${o},${r} ${i},${r}`}if("radial"===o){const o=(t+i)/2;return`M ${t},${e} Q ${o},${e} ${o},${(e+r)/2} T ${i},${r}`}{const o=(e+r)/2;return`M ${t},${e} C ${t},${o} ${i},${o} ${i},${r}`}}const Oe={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,i,r){var o;const n=i.__hierarchyRoot;if(!n)return;const s=i.chartType,a=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(i.childrenAccessor),c=i.hierarchySum||(t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0}),l=$(n,a);l.sum(c),l.sort((t,e)=>{var i,r;return(null!==(i=e.value)&&void 0!==i?i:0)-(null!==(r=t.value)&&void 0!==r?r:0)});const[u,h]=r;switch(s){case"tree":!function(t,e,i,r){const o=e.treeOrientation||"vertical",n=I();n.size("horizontal"===o?[r,i]:"radial"===o?[2*Math.PI,Math.min(i,r)/2*.8]:[i,r]),n(t)}(l,i,u,h);break;case"cluster":!function(t,e,i,r){const o=e.treeOrientation||"vertical",n=C();n.size("horizontal"===o?[r,i]:"radial"===o?[2*Math.PI,Math.min(i,r)/2*.8]:[i,r]),n(t)}(l,i,u,h);break;case"treemap":!function(t,e,i,r){var o,n;const s=null!==(o=e.padding)&&void 0!==o?o:4,a=null!==(n=e.paddingTop)&&void 0!==n?n:0,c=R().size([i,r]).tile(F).padding(s);a>0&&c.paddingTop(a),c(t)}(l,i,u,h);break;case"circlepack":!function(t,e,i,r){var o;const n=null!==(o=e.padding)&&void 0!==o?o:4;W().size([i,r]).padding(n)(t)}(l,i,u,h);break;case"partition":!function(t,e,i,r){var o;B().size([i,r]).padding(null!==(o=e.padding)&&void 0!==o?o:1)(t)}(l,i,u,h)}const f=l.descendants();t.length=0,e.length=0;const d=new Map;for(let e=0;f.length>e;e++){const r=f[e],n={id:Pe(r,i,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"===s||"cluster"===s?Le(n,r,i):"treemap"===s||"partition"===s?De(n,r):"circlepack"===s&&ze(n,r),n.__hierarchyNode=r,t.push(n),d.set(r,n)}if("tree"===s||"cluster"===s)for(const t of f)if(t.parent){const i=d.get(t.parent),r=d.get(t);i&&r&&e.push({source:i,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,i,r){const o=i.nodeStyle||(()=>({})),n=i.edgeStyle||(()=>({}));switch(i.chartType){case"tree":case"cluster":return function(t,e,i,r,o,n){var s,a,c,l,u;const h=[],f=[],d=[],g=i.treeOrientation||"vertical",y="radial"===g,p=r[0]/2,m=r[1]/2,x="number"==typeof(v=i.nodeSize)?v:5;var v;for(const e of t){let t=e.x,r=e.y;y&&(t+=p,r+=m);const n=o(ge(e,"nodeStyle"));let a=n.fill||"#4d430c";i.colorByDepth&&void 0!==e.depth&&(a=Se[e.depth%Se.length]);const c={fill:a,stroke:n.stroke||"#fff",strokeWidth:null!==(s=n.strokeWidth)&&void 0!==s?s:1,opacity:n.opacity};h.push({type:"circle",cx:t,cy:r,r:x,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const b=null!==(a=i.edgeOpacity)&&void 0!==a?a:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let r=e.x,o=e.y,s=i.x,a=i.y;y&&(r+=p,o+=m,s+=p,a+=m);const u=Me(r,o,s,a,g),h=n(ge(t,"edgeStyle")),d={fill:"none",stroke:h.stroke||"#999",strokeWidth:null!==(c=h.strokeWidth)&&void 0!==c?c:1.5,opacity:null!==(l=h.opacity)&&void 0!==l?l:b};f.push({type:"curved",pathD:u,style:d,datum:t})}if(!1!==i.showLabels){const e=Ee(i.nodeLabel);for(const i of t){const t=e?e(i):i.id;if(!t)continue;let r,o,n,s=i.x,a=i.y;if(y&&(s+=p,a+=m),y){const t=s-p,e=a-m,i=Math.sqrt(t*t+e*e);i>0?(r=s+t/i*10,o=a+e/i*10,n=0>t?"end":"start"):(r=s,o=a-12,n="middle")}else"horizontal"===g?((null===(u=i.data)||void 0===u?void 0:u.children)&&0!==i.data.children.length?(r=s-x-6,n="end"):(r=s+x+6,n="start"),o=a):(r=s,o=a+x+14,n="middle");d.push({x:r,y:o,text:t+"",anchor:n,baseline:"middle",fontSize:11})}}return{sceneNodes:h,sceneEdges:f,labels:d}}(t,e,i,r,o,n);case"treemap":case"partition":return function(t,e,i,r){var o,n;const s=[],a=[];for(const i of t){const t=i.x1-i.x0,n=i.y1-i.y0;if(0>=t||0>=n)continue;const a=r(ge(i,"nodeStyle"));let c=a.fill||"#4d430c";e.colorByDepth&&void 0!==i.depth&&(c=Se[i.depth%Se.length]);const l={fill:c,stroke:a.stroke||"#fff",strokeWidth:null!==(o=a.strokeWidth)&&void 0!==o?o:1,opacity:a.opacity};s.push({type:"rect",x:i.x0,y:i.y0,w:t,h:n,style:l,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Ee(e.nodeLabel),o=e.labelMode||"leaf",s="partition"===e.chartType;for(const c of t){const t=c.x1-c.x0,l=c.y1-c.y0;if(0>=t||0>=l)continue;const u=!((null===(n=c.data)||void 0===n?void 0:n.children)&&c.data.children.length>0);if(!s){if("leaf"===o&&!u)continue;if("parent"===o&&u)continue}const h=i?i(c):c.id;if(!h)continue;if((u?30:40)>t||(u?16:14)>l)continue;let f=r(ge(c,"nodeStyle")).fill||"#4d430c";e.colorByDepth&&void 0!==c.depth&&(f=Se[c.depth%Se.length]);const d=_e(f);a.push(u?{x:c.x0+t/2,y:c.y0+l/2,text:h+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,l)/6)),fill:d}:{x:c.x0+4,y:c.y0+12,text:h+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:d})}}return{sceneNodes:s,sceneEdges:[],labels:a}}(t,i,0,o);case"circlepack":return function(t,e,i,r){var o,n,s,a,c;const l=[],u=[];for(const i of t){const t=null!==(o=i.__radius)&&void 0!==o?o:5;if(0>=t)continue;const a=r(ge(i,"nodeStyle"));let c=a.fill||"#4d430c";e.colorByDepth&&void 0!==i.depth&&(c=Se[i.depth%Se.length]);const u={fill:c,stroke:a.stroke||"#fff",strokeWidth:null!==(n=a.strokeWidth)&&void 0!==n?n:1,opacity:null!==(s=a.opacity)&&void 0!==s?s:.7};l.push({type:"circle",cx:i.x,cy:i.y,r:t,style:u,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Ee(e.nodeLabel);for(const o of t){const t=null!==(a=o.__radius)&&void 0!==a?a:5,n=i?i(o):o.id;if(!n)continue;if(15>t)continue;const s=!((null===(c=o.data)||void 0===c?void 0:c.children)&&o.data.children.length>0);let l=r(ge(o,"nodeStyle")).fill||"#4d430c";if(e.colorByDepth&&void 0!==o.depth&&(l=Se[o.depth%Se.length]),s){const e=_e(l);u.push({x:o.x,y:o.y,text:n+"",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:n+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:"#000",stroke:"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:l,sceneEdges:[],labels:u}}(t,i,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Le(t,e,i){const r=i.treeOrientation||"vertical";if("radial"===r){const i=e.x,r=e.y;t.x=r*Math.cos(i-Math.PI/2),t.y=r*Math.sin(i-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 De(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 ze(t,e){var i;const r=null!==(i=e.r)&&void 0!==i?i: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 je(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const Te={sankey:pe,force:me,chord:we,tree:Oe,cluster:Oe,treemap:Oe,circlepack:Oe,partition:Oe,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,i,r){const o=i.__hierarchyRoot;o&&function(t,e,i,r,o){var n,s;const a=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(i.childrenAccessor),c=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>{var i;return(null!==(i=t[e])&&void 0!==i?i:"")+""}}(i.nodeIDAccessor),l=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(i.orbitMode),u=null!==(n=i.orbitSize)&&void 0!==n?n:2.95,h=null!==(s=i.orbitEccentricity)&&void 0!==s?s:1,f="number"==typeof u?()=>u:u,d="number"==typeof h?()=>h:h,g=je(i);g.metaMap.clear(),r.length=0,o.length=0;const y=new Map;function p(t){var e;const i=null!==(e=y.get(t))&&void 0!==e?e:0;return y.set(t,i+1),0===i?t:`${t}__${i}`}const m=e[0]/2,x=e[1]/2,v=Math.min(e[0],e[1])/2*.85,b=p(c(t));r.push({id:b,x:m,y:x,x0:m,x1:m,y0:x,y1:x,width:0,height:0,value:0,depth:0,data:t}),g.metaMap.set(b,{ring:v,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,i,n,s,u,h,y){const m=a(e);if(!(null==m?void 0:m.length))return;const x=m.length;let v=0,b=0,k=0;for(;x>b;)b+=l[Math.min(k,l.length-1)],k++,v++;let w=0;for(let x=0;v>x;x++){const b=l[Math.min(x,l.length-1)],k=m.slice(w,w+b);if(!k.length)break;const A=(x+1)/v,S={id:i,depth:h,data:e,parentId:i},_=y?u/f(S)*A:u*A,P=N().value(t=>{var e;return(null===(e=a(t))||void 0===e?void 0:e.length)?4:1}).sort(null),E=P(k),M=d(S);for(let e=0;k.length>e;e++){const a=(E[e].startAngle+E[e].endAngle)/2,l=k[e],u=p(c(l)),f=n+_*Math.sin(a),d=s+_*Math.cos(a)*M;r.push({id:u,x:f,y:d,x0:f,x1:f,y0:d,y1:d,width:0,height:0,value:0,depth:h,data:l}),g.metaMap.set(u,{ring:_,angle:a,depth:h,parentId:i,eccentricity:M}),o.push({source:i,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:u}}),t(l,u,f,d,_,h+1,!0)}w+=b}}(t,b,m,x,v,1,!1)}(o,r,i,t,e)},buildScene(t,e,i,r){var o,n,s,a,c;const l=i.nodeStyle,u=i.nodeSize,h="number"==typeof u?()=>u:"function"==typeof u?u:()=>6,f=[],d=[],g=[];if(!1!==i.orbitShowRings){const e=je(i),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 i=`${t.parentId}:${t.ring}`;o.has(i)||o.set(i,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const n=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:i,ecc:r}]of o)for(let o=0;n>o;o++){const a=o/n*Math.PI*2,c=(o+1)/n*Math.PI*2;d.push({type:"line",x1:t+i*Math.sin(a),y1:e+i*Math.cos(a)*r,x2:t+i*Math.sin(c),y2:e+i*Math.cos(c)*r,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=h(ge(e,"nodeSize")),i=l?l(ge(e,"nodeStyle")):{},r={fill:i.fill||"#6366f1",stroke:i.stroke||"#fff",strokeWidth:null!==(o=i.strokeWidth)&&void 0!==o?o:1,opacity:null!==(n=i.opacity)&&void 0!==n?n:0===(null!==(s=e.depth)&&void 0!==s?s:0)?1:.85};f.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 y=new Map;for(const e of t)y.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:y.get(t.source),i="object"==typeof t.target?t.target:y.get(t.target);e&&i&&(null!=e.x&&null!=i.x&&d.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(i.showLabels){const e=i.nodeLabel;for(const i of t){const t=h(ge(i,"nodeSize"));if(4>=t)continue;const r="function"==typeof e?e(i):e&&null!==(c=null===(a=i.data)||void 0===a?void 0:a[e])&&void 0!==c?c:i.id;g.push({x:i.x,y:i.y+t+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:f,sceneEdges:d,labels:g}},tick:(t,e,i,r,o)=>!1!==i.orbitAnimated&&(function(t,e){var i,r;const o=je(e),n=null!==(i=e.orbitSpeed)&&void 0!==i?i:.25,s=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 i=null!==(e=t.depth)&&void 0!==e?e:0;return(i%2==0?1:-1)/(i+1)};default:return t=>{var e;return 1/((null!==(e=t.depth)&&void 0!==e?e:0)+1)}}}(e.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,c=n*(Math.PI/6),l=new Map;for(const e of t)l.set(e.id,e);for(const e of t){const t=o.metaMap.get(e.id);if(!t||!t.parentId)continue;const i=l.get(t.parentId);if(!i)continue;const r=t.angle+a*c*s({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=i.x+t.ring*Math.sin(r),e.y=i.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,i),!0)}};function Ne(t,e){const{columns:i,config:r,resolvePieceStyle:o}=t,n=[],s=Math.min(e.width,e.height)/2-4,a="donut"===r.chartType?r.innerRadius||60:0,c=-Math.PI/2+(r.startAngle||0)*Math.PI/180,l=null!=r.sweepAngle?r.sweepAngle*Math.PI/180:2*Math.PI;for(const t of Object.values(i)){const e=c+t.pctStart*l,i=c+(t.pctStart+t.pct)*l,r=o(t.pieceData[0],t.name);n.push({type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:e,endAngle:i,style:r,datum:t.pieceData,category:t.name})}return n}function $e(t){var e,i,r;const o=t.length,n=t[0],s=t[o-1];return{n:o,min:n,q1:null!==(e=S(t,.25))&&void 0!==e?e:n,median:null!==(i=S(t,.5))&&void 0!==i?i:(n+s)/2,q3:null!==(r=S(t,.75))&&void 0!==r?r:s,max:s,mean:t.reduce((t,e)=>t+e,0)/o}}const Be={bar:function(t,e){const{scales:i,columns:r,config:o,getR:n,getStack:s,resolvePieceStyle:a}=t,{r:c,projection:l}=i,u=[],h="vertical"===l,f="horizontal"===l,d=o.normalize,g=[];if(s){const t=new Set;for(const e of Object.values(r))for(const i of e.pieceData){const e=s(i);t.has(e)||(t.add(e),g.push(e))}}else g.push("_default");for(const t of Object.values(r)){const e=new Map;for(const i of t.pieceData){const t=s?s(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const r=e.get(t);r.total+=n(i),r.pieces.push(i)}let i=0;if(d)for(const t of e.values())i+=Math.abs(t.total);let r=0,o=0;for(const n of g){const l=e.get(n);if(!l)continue;let g=l.total;d&&i>0&&(g/=i);const y=a(l.pieces[0],s?n:t.name),p=Object.assign(Object.assign({},l.pieces[0]),{__aggregateValue:l.total,__pieceCount:l.pieces.length,category:t.name});if(h){const e=c(0>g?o:r+g),i=0>g?c(o+g)-c(o):c(r)-c(r+g);u.push(xt(t.x,e,t.width,Math.abs(i),y,p,n)),0>g?o+=g:r+=g}else if(f){const e=c(0>g?o+g:r),i=0>g?c(o)-c(o+g):c(r+g)-c(r);u.push(xt(e,t.x,Math.abs(i),t.width,y,p,n)),0>g?o+=g:r+=g}}}return u},clusterbar:function(t,e){const{scales:i,columns:r,getR:o,getGroup:n,resolvePieceStyle:s}=t,{r:a,projection:c}=i,l=[],u="vertical"===c,h=[],f=new Set;for(const t of Object.values(r))for(const e of t.pieceData){const t=n?n(e):"_default";f.has(t)||(f.add(t),h.push(t))}const d=h.length||1;for(const t of Object.values(r)){const e=t.width/d,i=.2*e,r=e-i,c=new Map;for(const e of t.pieceData){const t=n?n(e):"_default";c.has(t)||c.set(t,[]),c.get(t).push(e)}for(let n=0;h.length>n;n++){const f=c.get(h[n])||[];for(const c of f){const f=o(c),d=s(c,h[n]);if(u){const o=t.x+n*e+i/2,s=a(0),u=a(f);l.push(xt(o,Math.min(s,u),r,Math.abs(s-u),d,c,h[n]))}else{const o=t.x+n*e+i/2,s=a(0),u=a(f);l.push(xt(Math.min(s,u),o,Math.abs(u-s),r,d,c,h[n]))}}}}return l},point:function(t,e){var i,r;const{scales:o,columns:n,getR:s,multiScales:a,resolvePieceStyle:c}=t,{r:l,projection:u}=o,h=[],f="vertical"===u,d="radial"===u,g=a.length>0,y=2*Math.PI,p=-Math.PI/2;for(const t of Object.values(n))for(const e of t.pieceData){const o=null!==(i=e.__rIndex)&&void 0!==i?i:0,n=null!==(r=e.__rValue)&&void 0!==r?r:s(e),u=g&&a[o]||l,m=c(e,t.name),x=m.r||5;let v,b;if(d){const e=p+(t.pctStart+t.pct/2)*y,i=u(n);v=Math.cos(e)*i,b=Math.sin(e)*i}else f?(v=t.middle,b=u(n)):(v=u(n),b=t.middle);h.push({type:"point",x:v,y:b,r:x,style:m,datum:e})}return h},swarm:function(t,e){const{scales:i,columns:r,getR:o,resolvePieceStyle:n}=t,{r:s,projection:a}=i,c=[],l="vertical"===a;for(const t of Object.values(r)){const e=t.width/2;for(let i=0;t.pieceData.length>i;i++){const r=t.pieceData[i],a=o(r),u=n(r,t.name),h=u.r||4,f=(7919*i%100/100-.5)*e*.8,d=l?t.middle+f:s(a),g=l?s(a):t.middle+f;c.push({type:"point",x:d,y:g,r:h,style:u,datum:r})}}return c},pie:Ne,donut:Ne,boxplot:function(t,e){var i,r,o,n,s;const{scales:a,columns:c,config:l,getR:u,resolveSummaryStyle:h}=t,{r:f,projection:d}=a,g=[],y="vertical"===d,p=!1!==l.showOutliers;for(const t of Object.values(c)){const e=t.pieceData.map(t=>u(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===e.length)continue;const a=e[0],c=e[e.length-1],l=null!==(i=S(e,.25))&&void 0!==i?i:a,d=null!==(r=S(e,.5))&&void 0!==r?r:(a+c)/2,m=null!==(o=S(e,.75))&&void 0!==o?o:c,x=m-l,v=l-1.5*x,b=m+1.5*x,k=null!==(n=e.find(t=>t>=v))&&void 0!==n?n:a,w=null!==(s=[...e].reverse().find(t=>b>=t))&&void 0!==s?s:c,A=h(t.pieceData[0],t.name),_=[];if(p)for(const e of t.pieceData){const i=u(e);if(v>i||i>b){const r=y?t.middle:f(i),o=y?f(i):t.middle;_.push({px:r,py:o,value:i,datum:e})}}if(g.push({type:"boxplot",x:y?t.middle:0,y:y?0:t.middle,projection:y?"vertical":"horizontal",columnWidth:.6*t.width,minPos:f(k),q1Pos:f(l),medianPos:f(d),q3Pos:f(m),maxPos:f(w),stats:{n:e.length,min:k,q1:l,median:d,q3:m,max:w,mean:e.reduce((t,e)=>t+e,0)/e.length},style:A,datum:t.pieceData,category:t.name,outliers:_}),p)for(const t of _)g.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:A.fill||"#999",opacity:.6},datum:t.datum})}return g},violin:function(t,e){var i,r,o;const{scales:n,columns:s,config:a,getR:c,resolveSummaryStyle:l}=t,{r:u,projection:h}=n,f=[],d="vertical"===h,g=a.bins||20,y=!1!==a.showIQR;for(const t of Object.values(s)){const e=t.pieceData.map(t=>c(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const n=e[0],s=e[e.length-1],a=(s-n)/g||1,h=Array(g).fill(0);for(const t of e)h[Math.min(Math.floor((t-n)/a),g-1)]++;const p=Math.max(...h,1),m=t.width/2*.9;let x="";if(d){x=`M ${t.middle} ${u(n)}`;for(let e=0;g>e;e++){const i=u(n+(e+.5)*a);x+=` L ${t.middle+h[e]/p*m} ${i}`}x+=` L ${t.middle} ${u(s)}`;for(let e=g-1;e>=0;e--){const i=u(n+(e+.5)*a);x+=` L ${t.middle-h[e]/p*m} ${i}`}x+=" Z"}else{x=`M ${u(n)} ${t.middle}`;for(let e=0;g>e;e++)x+=` L ${u(n+(e+.5)*a)} ${t.middle-h[e]/p*m}`;x+=` L ${u(s)} ${t.middle}`;for(let e=g-1;e>=0;e--)x+=` L ${u(n+(e+.5)*a)} ${t.middle+h[e]/p*m}`;x+=" Z"}const v=l(t.pieceData[0],t.name);let b;if(y&&e.length>=4){const a=null!==(i=S(e,.25))&&void 0!==i?i:n,c=null!==(r=S(e,.5))&&void 0!==r?r:(n+s)/2,l=null!==(o=S(e,.75))&&void 0!==o?o:s;b={q1Pos:u(a),medianPos:u(c),q3Pos:u(l),centerPos:t.middle,isVertical:d}}const k=d?{x:t.x,y:Math.min(u(s),u(n)),width:t.width,height:Math.abs(u(s)-u(n))}:{x:Math.min(u(n),u(s)),y:t.x,width:Math.abs(u(s)-u(n)),height:t.width};f.push({type:"violin",pathString:x,translateX:0,translateY:0,bounds:k,iqrLine:b,stats:$e(e),style:v,datum:t.pieceData,category:t.name})}return f},histogram:function(t,e){var i;const{scales:r,columns:o,config:n,getR:s,resolveSummaryStyle:a}=t,{r:c}=r,l=[],u=n.bins||25,h=n.normalize,f=null===(i=c.domain)||void 0===i?void 0:i.call(c),d=f?+f[0]:void 0,g=f?+f[1]:void 0;for(const t of Object.values(o)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const i=null!=d&&isFinite(d)?d:Math.min(...e),r=null!=g&&isFinite(g)?g:Math.max(...e),o=(r-i)/u||1,n=Array(u).fill(0);for(const t of e)i>t||t>r||n[Math.min(Math.floor((t-i)/o),u-1)]++;const f=e.length,y=Math.max(...n,1),p=a(t.pieceData[0],t.name);for(let e=0;u>e;e++){if(0===n[e])continue;const r=(h?n[e]/f:n[e]/y)*t.width*.9,s=c(i+e*o),a=c(i+(e+1)*o);l.push(xt(Math.min(s,a),t.x+t.width-r,Math.abs(a-s),r,p,{bin:e,count:n[e],range:[i+e*o,i+(e+1)*o],category:t.name},t.name))}}return l},ridgeline:function(t,e){var i;const{scales:r,columns:o,config:n,getR:s,resolveSummaryStyle:a}=t,{r:c,projection:l}=r,u=[],h=n.bins||20,f="horizontal"===l,d=n.amplitude||1.5;for(const t of Object.values(o)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const r=e[0],o=e[e.length-1],n=(o-r)/h||1,l=Array(h).fill(0);for(const t of e)r>t||t>o||l[Math.min(Math.floor((t-r)/n),h-1)]++;const g=Math.max(...l,1),y=a(t.pieceData[0],t.name),p=t.width*d;let m="";if(f){const e=t.x+t.width;m=`M ${c(r)} ${e}`;for(let t=0;h>t;t++)m+=` L ${c(r+(t+.5)*n)} ${e-l[t]/g*p}`;m+=` L ${c(o)} ${e} Z`}else{const e=t.x;m=`M ${e} ${c(r)}`;for(let t=0;h>t;t++){const i=c(r+(t+.5)*n);m+=` L ${e+l[t]/g*p} ${i}`}m+=` L ${e} ${c(o)} Z`}const x=f?{x:Math.min(c(r),c(o)),y:t.x,width:Math.abs(c(o)-c(r)),height:t.width}:{x:t.x,y:Math.min(c(o),c(r)),width:t.width,height:Math.abs(c(o)-c(r))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:x,stats:$e(e),style:Object.assign(Object.assign({},y),{fillOpacity:null!==(i=y.fillOpacity)&&void 0!==i?i:.5}),datum:t.pieceData,category:t.name})}return u},timeline:function(t,e){const{scales:i,columns:r,getRawRange:o,resolvePieceStyle:n}=t,{r:s,projection:a}=i,c=[],l="horizontal"===a;for(const t of Object.values(r))for(const e of t.pieceData){const i=o(e);if(!i)continue;const[r,a]=i,u=n(e,t.name);if(l){const i=s(Math.min(r,a)),o=s(Math.max(r,a));c.push(xt(i,t.x,o-i,t.width,u,e,t.name))}else{const i=s(Math.max(r,a)),o=s(Math.min(r,a));c.push(xt(t.x,i,t.width,o-i,u,e,t.name))}}return c},funnel:function(t,e){var i,r,o,n,s,c,l;const{columns:u,getR:h,getStack:f,resolvePieceStyle:d}=t,g=[],y=e.width/2,p=!1!==t.config.showLabels,m=t.scales.o.domain().map(t=>u[t]).filter(Boolean);if(0===m.length)return g;const x=[],v=new Set;for(const t of m)for(const e of t.pieceData){const t=f?f(e):"_default";v.has(t)||(v.add(t),x.push(t))}const b=x.length>1&&"_default"!==x[0],k=[];let w=0;for(const t of m){const e=new Map;let i=0;for(const r of t.pieceData){const t=f?f(r):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t),n=h(r);o.total+=n,o.pieces.push(r),i+=n}k.push({col:t,groups:e,stepTotal:i}),b||i>w&&(w=i)}if(b)for(const t of k){let e=0,i=0;for(let r=0;x.length>r;r++){const o=t.groups.get(x[r]);o&&(r%2==0?e+=o.total:i+=o.total)}const r=Math.max(e,i);r>w&&(w=r)}if(0===w)return g;const A=new Map;for(const t of x){const e=k[0].groups.get(t);A.set(t,null!==(i=null==e?void 0:e.total)&&void 0!==i?i:0)}const S=k[0].stepTotal,_=b?.95*y:.9*e.width,P=a().domain([0,w]).range([0,_]),E=null!==(r=t.config.connectorOpacity)&&void 0!==r?r:.3;let M=new Map;for(let t=0;k.length>t;t++){const e=k[t],i=e.col,r=0===t,a=i.width,u=.55*a,h=i.x+(a-u)/2,f=new Map;if(b){let t=0;for(const i of x){const r=e.groups.get(i);r&&(t+=P(r.total))}let o=y,n=y;for(let a=0;x.length>a;a++){const c=x[a],l=e.groups.get(c);if(!l)continue;const m=P(l.total),v=a%2==0,b=v?o:n-m;v?o+=m:n-=m;const k=d(l.pieces[0],c),w=null!==(s=A.get(c))&&void 0!==s?s:l.total,S=w>0?l.total/w*100:0,_=Object.assign(Object.assign({},l.pieces[0]),{__funnelValue:l.total,__funnelPercent:S,__funnelStep:i.name,__funnelIsFirstStep:r,__aggregateValue:l.total,__pieceCount:l.pieces.length,category:c});p&&(0===a&&(_.__funnelStepLabel=i.name,_.__funnelStepLabelX=y,_.__funnelStepLabelY=h,_.__funnelRowWidth=t),_.__funnelValueLabelX=b+m/2,_.__funnelValueLabelY=h,_.__funnelBarW=m),g.push(xt(b,h,m,u,k,_,c)),f.set(c,{x:b,y:h,w:m,h:u})}}else{const t=e.stepTotal,s=P(t),a=y-s/2,c=x[0],l="_default"!==c,m=null!==(n=null===(o=e.groups.get(c))||void 0===o?void 0:o.pieces[0])&&void 0!==n?n:i.pieceData[0],v=l?c:i.name,b=d(m,v),k=S>0?t/S*100:0,w=Object.assign(Object.assign({},m),{__funnelValue:t,__funnelPercent:k,__funnelStep:i.name,__funnelIsFirstStep:r,category:l?c:i.name});p&&(w.__funnelStepLabel=i.name,w.__funnelStepLabelX=y,w.__funnelStepLabelY=h,w.__funnelRowWidth=s,w.__funnelValueLabelX=y,w.__funnelValueLabelY=h,w.__funnelBarW=s),g.push(xt(a,h,s,u,b,w,v)),f.set(c,{x:a,y:h,w:s,h:u})}if(t>0&&M.size>0){const t=b?x:[x[0]];for(const r of t){const t=M.get(r),o=f.get(r);if(!t||!o)continue;const n=(()=>{const t=e.groups.get(r);return d(t?t.pieces[0]:i.pieceData[0],"_default"===r?i.name:r)})(),s={type:"trapezoid",points:[[t.x,t.y+t.h],[t.x+t.w,t.y+t.h],[o.x+o.w,o.y],[o.x,o.y]],style:{fill:n.fill||"#999",opacity:E},datum:null!==(l=null===(c=e.groups.get(r))||void 0===c?void 0:c.pieces[0])&&void 0!==l?l:i.pieceData[0],category:"_default"===r?i.name:r};g.push(s)}}M=f}return g},"bar-funnel":function(t,e){var i,r,o,n;const{columns:s,getR:a,getStack:c,resolvePieceStyle:l,scales:u}=t,h=[],f=u.o.domain().map(t=>s[t]).filter(Boolean);if(0===f.length)return h;const d=[],g=new Set;for(const t of f)for(const e of t.pieceData){const t=c?c(e):"_default";g.has(t)||(g.add(t),d.push(t))}const y=d.length>1&&"_default"!==d[0],p=[];for(const t of f){const e=new Map;let i=0;for(const r of t.pieceData){const t=c?c(r):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t),n=a(r);o.total+=n,o.pieces.push(r),i+=n}p.push({col:t,groups:e,stepTotal:i})}const m=new Map;for(const t of d){const e=null===(i=p[0])||void 0===i?void 0:i.groups.get(t);m.set(t,null!==(r=null==e?void 0:e.total)&&void 0!==r?r:0)}const x=u.r,v=y?d.length:1,b=y?.15:0;for(let t=0;p.length>t;t++){const e=p[t],i=e.col,r=0===t,s=t>0?p[t-1]:null,a=i.width/v,c=a*b,u=a-c;for(let t=0;d.length>t;t++){const f=d[t],g=e.groups.get(f);if(!g)continue;const p=g.total,v=null!==(o=m.get(f))&&void 0!==o?o:p,b=v>0?p/v*100:0,k=null==s?void 0:s.groups.get(f),w=null!==(n=null==k?void 0:k.total)&&void 0!==n?n:p,A=r?0:Math.max(0,w-p),S=i.x+t*a+c/2,_=x(p),P=x(0)-_,E=l(g.pieces[0],y?f:i.name),M=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:p,__barFunnelPercent:b,__barFunnelIsFirstStep:r,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:A,__barFunnelCategory:"_default"===f?void 0:f,category:y?f:i.name,__barFunnelLabelX:S+u/2,__barFunnelLabelY:x(p+A)});if(h.push(xt(S,_,u,P,E,M,y?f:i.name)),A>0){const t=x(p+A),e=_-t,r=Object.assign({},E),o=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:A,__barFunnelPercent:v>0?A/v*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===f?void 0:f,category:y?f:i.name});h.push(xt(S,t,u,e,r,o,y?f:i.name))}}}return h},swimlane:function(t,e){const{scales:i,columns:r,getR:o,getStack:n,resolvePieceStyle:s}=t,{r:a,projection:c}=i,l=[],u="horizontal"===c;for(const t of Object.values(r)){let e=0;for(const i of t.pieceData){const r=Math.abs(o(i));if(0===r)continue;const c=n?n(i):t.name,h=s(i,c);if(u){const o=a(e),n=a(e+r);l.push(xt(o,t.x,n-o,t.width,h,i,c))}else{const o=a(e+r),n=a(e);l.push(xt(t.x,o,t.width,n-o,h,i,c))}e+=r}}return l}};class We{constructor(t){this.rExtent=new et,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.version=0,this.config=t,this.buffer=new tt(t.windowSize),this.getO=st(t.oAccessor||t.categoryAccessor,"category");const e="streaming"===t.runtimeMode,i=t.rAccessor;Array.isArray(i)?(this.rAccessors=i.map(t=>ot(t,"value")),this.getR=this.rAccessors[0],this.rExtents=i.map(()=>new et)):(this.getR=ot(e&&(t.timeAccessor||t.valueAccessor)&&t.valueAccessor||i,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=st(t.stackBy),this.getGroup=st(t.groupBy),this.getColor=st(t.colorAccessor),this.getConnector=st(t.connectorAccessor),this.getDataId=st(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new tt(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,t.bounded){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=t.totalSize||t.inserts.length;i>this.buffer.capacity&&(this.buffer.resize(i),this.timestampBuffer&&i>this.timestampBuffer.capacity&&this.timestampBuffer.resize(i));for(const i of t.inserts)this.buffer.push(i),this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i)}else{this._hasStreamingData=!0;for(const i of t.inserts){const t=this.buffer.push(i);this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i),null!=t&&this.evictValueExtent(t)}}return!0}pushValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.push(e[0]),this.rExtent.push(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].push(this.rAccessors[e](t));this.rExtent.push(this.getR(t))}else this.rExtent.push(this.getR(t))}evictValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.evict(e[0]),this.rExtent.evict(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].evict(this.rAccessors[e](t));this.rExtent.evict(this.getR(t))}else this.rExtent.evict(this.getR(t))}getRawRange(t){const e=this.config.rAccessor;if(!e)return null;const i="function"==typeof e?e(t):t[e];return Array.isArray(i)&&i.length>=2?[+i[0],+i[1]]:null}computeScene(t){const{config:e,buffer:i}=this;if(0===i.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(i,this.getR);const r=i.toArray(),o=e.projection||"vertical",n=e.oExtent||this.resolveCategories(r),s=this.computeValueDomain(r,n),c="horizontal"===o,l=null!=e.barPadding?e.barPadding/("vertical"===o?t.width:t.height):.1;let h,f;if("radial"===o){h=u().domain(n).range([0,1]).padding(0);const i=Math.min(t.width,t.height)/2,r=e.innerRadius||0;f=a().domain(s).range([r,i])}else c?(h=u().domain(n).range([0,t.height]).padding(l),f=a().domain(s).range([0,t.width])):(h=u().domain(n).range([0,t.width]).padding(l),f=a().domain(s).range([t.height,0]));this.scales={o:h,r:f,projection:o},this.multiScales=this.rAccessors.length>1&&e.multiAxis?this.rAccessors.map((r,o)=>{var n;const s=this.rExtents[o];s.dirty&&s.recalculate(i,r);let[l,u]=s.extent;l===1/0&&(l=0,u=1);const h=null!==(n=e.extentPadding)&&void 0!==n?n:.05,f=u-l,d=f>0?f*h:1;return l-=d,u+=d,l>0&&(l=0),c?a().domain([l,u]).range([0,t.width]):a().domain([l,u]).range([t.height,0])}):[];let d=r;this.rAccessors.length>1&&(d=r.flatMap(t=>this.rAccessors.map((e,i)=>Object.assign(Object.assign({},t),{__rIndex:i,__rValue:e(t),__rName:this.resolveRAccessorName(i)})))),this.columns=this.buildColumns(d,n,h,o,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(d,t),this.config.decay&&this.applyDecay(this.scene,r),this.config.pulse&&this.applyPulse(this.scene,r),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(t){const e=Array.isArray(this.config.rAccessor)?this.config.rAccessor[t]:this.config.rAccessor;return"string"==typeof e?e:"value"+t}resolveCategories(t){const e=Array.from(this.categories),i=this.config.oSort;if(("streaming"===this.config.runtimeMode||this._hasStreamingData)&&void 0===i){const i=new Set;for(const e of t)i.add(this.getO(e));const r=Math.max(50,3*i.size);if(this.categories.size>r){let t=this.categories.size-r;for(const e of this.categories){if(0>=t)break;i.has(e)||(this.categories.delete(e),t--)}}return e.filter(t=>i.has(t))}if(!1===i)return e;if("function"==typeof i)return e.sort(i);const r=new Map;for(const e of t){const t=this.getO(e);r.set(t,(r.get(t)||0)+Math.abs(this.getR(e)))}return e.sort("asc"===i?(t,e)=>(r.get(t)||0)-(r.get(e)||0):(t,e)=>(r.get(e)||0)-(r.get(t)||0))}computeValueDomain(t,e){var i,r,o,n,s;const a=this.config.chartType,c=null!==(i=this.config.extentPadding)&&void 0!==i?i:.05;if("radial"===this.config.projection&&("pie"===a||"donut"===a))return[0,1];let l=0,u=0;if("bar"===a&&this.getStack&&this.config.normalize)l=0,u=1;else if("bar"===a&&this.getStack){const e=new Map,i=new Map;for(const r of t){const t=this.getO(r),o=this.getR(r);0>o?i.set(t,(i.get(t)||0)+o):e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>u&&(u=t);for(const t of i.values())l>t&&(l=t)}else if("bar"===a){const e=new Map;for(const i of t){const t=this.getO(i),r=this.getR(i);e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>u&&(u=t),l>t&&(l=t)}else if("swimlane"===a){const e=new Map;for(const i of t){const t=this.getO(i),r=Math.abs(this.getR(i));e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>u&&(u=t)}else if("clusterbar"===a||"bar-funnel"===a)for(const e of t){const t=this.getR(e);t>u&&(u=t),l>t&&(l=t)}else{const t=this.rExtent.extent[0],e=this.rExtent.extent[1];t!==1/0&&(l=t),e!==-1/0&&(u=e)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(l=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(u=this.config.rExtent[1]));const h="bar"===a||"clusterbar"===a||"bar-funnel"===a||"swimlane"===a;if(h&&null==(null===(r=this.config.rExtent)||void 0===r?void 0:r[0])&&null==(null===(o=this.config.rExtent)||void 0===o?void 0:o[1])&&(l>0&&(l=0),0>u&&(u=0)),"bar-funnel"!==a){const t=u-l,e=t>0?t*c:1;null!=(null===(n=this.config.rExtent)||void 0===n?void 0:n[0])||h&&!this.config.baselinePadding&&0===l||(l-=e),null!=(null===(s=this.config.rExtent)||void 0===s?void 0:s[1])||h&&!this.config.baselinePadding&&0===u||"swimlane"===a||(u+=e)}return[l,u]}buildColumns(t,e,i,r,o){var n;const s={},a=new Map;for(const e of t){const t=this.getO(e);a.has(t)||a.set(t,[]),a.get(t).push(e)}let c=0;if("radial"===r)for(const e of t)c+=Math.abs(this.getR(e));const l=this.config.dynamicColumnWidth;let u=null;if(l&&"radial"!==r){u=new Map;let t=0;for(const i of e){const e=a.get(i)||[];let r;r="string"==typeof l?e.reduce((t,e)=>t+(Number(e[l])||0),0):l(e),u.set(i,r),t+=r}const n=("horizontal"===r?o.height:o.width)-i.padding()*i.step()*e.length;if(t>0)for(const[e,i]of u)u.set(e,i/t*n)}let h=0,f=0;for(const t of e){const e=a.get(t)||[],r=e.reduce((t,e)=>t+Math.abs(this.getR(e)),0),o=c>0?r/c:0;let l,d;u?(l=f,d=u.get(t)||i.bandwidth(),f+=d+i.padding()*i.step()):(l=null!==(n=i(t))&&void 0!==n?n:0,d=i.bandwidth()),s[t]={name:t,x:l,y:0,width:d,middle:l+d/2,padding:i.padding()*i.step(),pieceData:e,pct:o,pctStart:h},h+=o}return s}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(t,e)=>this.resolvePieceStyle(t,e),resolveSummaryStyle:(t,e)=>this.resolveSummaryStyle(t,e),getRawRange:t=>this.getRawRange(t)}}buildSceneNodes(t,e){if(!this.scales)return[];const i=this.getSceneContext(),r=Be[this.config.chartType];let o=r?r(i,e):[];if(this.getConnector&&this.scales){const t=function(t,e){const{scales:i,config:r,getConnector:o,getO:n}=t;if(!o||!i)return[];const s=[],{projection:a}=i,c=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const i=o(e);if(!i)continue;let r,s;"point"===t.type?(r=t.x,s=t.y):(r=t.x+t.w/2,s=t.y+("vertical"===a?0:t.h/2)),c.has(i)||c.set(i,[]),c.get(i).push({x:r,y:s,datum:e,category:n(e)})}const l=i.o.domain(),u=r.connectorStyle;for(const[t,e]of c)if(e.length>=2){e.sort((t,e)=>l.indexOf(t.category)-l.indexOf(e.category));for(let i=0;e.length-1>i;i++){const r=e[i],o=e[i+1],n="function"==typeof u?u(r.datum):u||{stroke:"#999",strokeWidth:1,opacity:.5};s.push({type:"connector",x1:r.x,y1:r.y,x2:o.x,y2:o.y,style:n,datum:r.datum,group:t})}}return s}(i,o);o=[...t,...o]}return o}resolvePieceStyle(t,e){if("function"==typeof this.config.pieceStyle){const i=this.config.pieceStyle(t,e);return i&&!i.fill&&e?Object.assign(Object.assign({},i),{fill:this.getColorFromScheme(e)}):i}return this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&e?{fill:this.config.barColors[e]||"#007bff"}:e?{fill:this.getColorFromScheme(e)}:{fill:"#007bff"}}getColorFromScheme(t){this._colorSchemeMap||(this._colorSchemeMap=new Map);const e=this._colorSchemeMap.get(t);if(e)return e;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:at,r=i[this._colorSchemeIndex%i.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(t,r),r}resolveSummaryStyle(t,e){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(t,e):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(t,e){var i,r,o;const n=this.config.decay;if(!n||1>=e)return 1;const s=null!==(i=n.minOpacity)&&void 0!==i?i:.1,a=e-1-t;switch(n.type){case"linear":return s+(1-a/(e-1))*(1-s);case"exponential":{const t=null!==(r=n.halfLife)&&void 0!==r?r:e/2;return s+Math.pow(.5,a/t)*(1-s)}case"step":return(null!==(o=n.stepThreshold)&&void 0!==o?o:.5*e)>a?1:s;default:return 1}}applyDecay(t,e){var i,r;if(!this.config.decay)return;const o=e.length;if(1>=o)return;const n=new Map;for(let t=0;e.length>t;t++)n.set(e[t],t);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;const t=n.get(e.datum);if(null==t)continue;const s=this.computeDecayOpacity(t,o),a=null!==(r=null===(i=e.style)||void 0===i?void 0:i.opacity)&&void 0!==r?r:1;e.style=Object.assign(Object.assign({},e.style),{opacity:a*s})}}applyPulse(t,e){var i,r,o;if(!this.config.pulse||!this.timestampBuffer)return;const n="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(i=this.config.pulse.duration)&&void 0!==i?i:500,a=null!==(r=this.config.pulse.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",c=null!==(o=this.config.pulse.glowRadius)&&void 0!==o?o:4,l=new Map;for(let t=0;e.length>t;t++)l.set(e[t],t);for(const i of t){if("connector"===i.type||"violin"===i.type||"boxplot"===i.type)continue;if("wedge"===i.type){const t=i.category;if(!t)continue;let r=0;for(let i=0;e.length>i;i++){const o=e[i],a=this.config.oAccessor;if(("function"==typeof a?a(o):o[a||"category"])!==t)continue;const c=this.timestampBuffer.get(i);if(null==c)continue;const l=n-c;if(s>l){const t=1-l/s;t>r&&(r=t)}}r>0&&(i._pulseIntensity=r,i._pulseColor=a);continue}const t=l.get(i.datum);if(null==t)continue;const r=this.timestampBuffer.get(t);if(null==r)continue;const o=n-r;s>o&&(i._pulseIntensity=1-o/s,i._pulseColor=a,i._pulseGlowRadius=c)}}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(),i=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,r=this.timestampBuffer.peek();return null!=r&&i>e-r}getNodeKey(t,e){var i,r;if("point"===t.type){const i=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,r=e.get(i)||0;return e.set(i,r+1),`${i}:${r}`}return"rect"===t.type?`r:${t.group||""}:${null!==(r=null===(i=t.datum)||void 0===i?void 0:i.category)&&void 0!==r?r:""}`:null}snapshotPositions(){this.prevPositionMap.clear();const t=new Map;for(let e=0;this.scene.length>e;e++){const i=this.scene[e],r=this.getNodeKey(i,t);r&&("point"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity}):"rect"===i.type&&this.prevPositionMap.set(r,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity}))}}startTransition(){var t,e,i,r,o,n,s,a,c,l,u,h;if(!this.config.transition||0===this.prevPositionMap.size)return;const f=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 d=!1;const g=new Set,y=new Map;for(let t=0;this.scene.length>t;t++){const a=this.scene[t],c=this.getNodeKey(a,y);if(!c)continue;a._transitionKey=c;const l=this.prevPositionMap.get(c);"point"===a.type?l?(g.add(c),a._targetOpacity=null!==(e=a.style.opacity)&&void 0!==e?e:1,l.x===a.x&&l.y===a.y||(a._targetX=a.x,a._targetY=a.y,a.x=l.x,a.y=l.y,d=!0)):(a._targetOpacity=null!==(i=a.style.opacity)&&void 0!==i?i:1,a.style=Object.assign(Object.assign({},a.style),{opacity:0}),d=!0):"rect"===a.type&&(l?(g.add(c),a._targetOpacity=null!==(r=a.style.opacity)&&void 0!==r?r:1,l.x===a.x&&l.y===a.y&&l.w===a.w&&l.h===a.h||(a._targetX=a.x,a._targetY=a.y,a._targetW=a.w,a._targetH=a.h,a.x=l.x,a.y=l.y,a.w=null!==(o=l.w)&&void 0!==o?o:a.w,a.h=null!==(n=l.h)&&void 0!==n?n:a.h,d=!0)):(a._targetOpacity=null!==(s=a.style.opacity)&&void 0!==s?s:1,a.style=Object.assign(Object.assign({},a.style),{opacity:0}),d=!0))}this.exitNodes=[];for(const[t,e]of this.prevPositionMap)g.has(t)||(t.startsWith("p:")?this.exitNodes.push({type:"point",x:e.x,y:e.y,r:null!==(a=e.r)&&void 0!==a?a:3,style:{opacity:null!==(c=e.opacity)&&void 0!==c?c:1},datum:null,_targetOpacity:0,_transitionKey:t}):t.startsWith("r:")&&this.exitNodes.push({type:"rect",x:e.x,y:e.y,w:null!==(l=e.w)&&void 0!==l?l:0,h:null!==(u=e.h)&&void 0!==u?u:0,style:{opacity:null!==(h=e.opacity)&&void 0!==h?h:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t}),d=!0);this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),d&&(this.activeTransition={startTime:dt(),duration:f})}advanceTransition(t){var e,i,r;if(!this.activeTransition)return!1;const o=ht(t,this.activeTransition),n=ut(o,"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(e)if("point"===t.type){if(void 0!==t._targetOpacity){const r=this.prevPositionMap.get(e),o=r?null!==(i=r.opacity)&&void 0!==i?i:1:0;t.style.opacity=ft(o,t._targetOpacity,n)}if(void 0===t._targetX)continue;const r=this.prevPositionMap.get(e);if(!r)continue;t.x=ft(r.x,t._targetX,n),t.y=ft(r.y,t._targetY,n)}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e),o=i?null!==(r=i.opacity)&&void 0!==r?r:1:0;t.style.opacity=ft(o,t._targetOpacity,n)}if(void 0===t._targetX)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=ft(i.x,t._targetX,n),t.y=ft(i.y,t._targetY,n),void 0!==i.w&&(t.w=ft(i.w,t._targetW,n),t.h=ft(i.h,t._targetH,n))}}if(o>=1){for(const t of this.scene)if(void 0!==t._targetOpacity&&(t.style=Object.assign(Object.assign({},t.style||{}),{opacity:0===t._targetOpacity?0:t._targetOpacity}),t._targetOpacity=void 0),"point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=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}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}getData(){return this.buffer.toArray()}remove(t){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");const e=new Set(Array.isArray(t)?t:[t]),i=this.getDataId,r=t=>e.has(i(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,i)=>{r(t)&&e.add(i)}),this.timestampBuffer.clear();for(let i=0;t.length>i;i++)e.has(i)||this.timestampBuffer.push(t[i])}const o=this.buffer.remove(r);if(0===o.length)return o;for(const t of o)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach(t=>this.categories.add(this.getO(t))),this.version++,o}update(t,e){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const i=new Set(Array.isArray(t)?t:[t]),r=this.getDataId,o=new Set;this.buffer.forEach((t,e)=>{i.has(r(t))&&o.add(e)});const n=this.buffer.update(t=>i.has(r(t)),e);if(0===n.length)return n;for(const t of n)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach((t,e)=>{this.categories.add(this.getO(t)),o.has(e)&&this.pushValueExtent(t)}),this.version++,n}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}updateConfig(t){const e=Object.assign({},this.config);if(t.colorScheme!==this.config.colorScheme&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),Object.assign(this.config,t),(void 0!==t.oAccessor||void 0!==t.categoryAccessor)&&(rt(t.oAccessor||t.categoryAccessor,e.oAccessor||e.categoryAccessor)||(this.getO=st(this.config.oAccessor||this.config.categoryAccessor,"category"),this.categories.clear())),void 0!==t.rAccessor){const i=Array.isArray(t.rAccessor)?t.rAccessor:[t.rAccessor],r=Array.isArray(e.rAccessor)?e.rAccessor:[e.rAccessor];if(i.length!==r.length||i.some((t,e)=>!rt(t,r[e]))){const t=this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>ot(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new et)):(this.getR=ot(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!rt(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?st(this.config.stackBy):void 0),"groupBy"in t&&!rt(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?st(this.config.groupBy):void 0),"colorAccessor"in t&&!rt(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?st(this.config.colorAccessor):void 0),"connectorAccessor"in t&&!rt(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?st(this.config.connectorAccessor):void 0)}}const Re={mercator:Q,equalEarth:V,albersUsa:U,orthographic:K,naturalEarth:Z,equirectangular:H};function Fe(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function Ce(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function Ie(t,e,i){return t?Object.assign(Object.assign({},i),"function"==typeof t?t(e):t):i}const Ye={fill:"#e0e0e0",stroke:"#999",strokeWidth:.5,fillOpacity:1},Xe={fill:"#4e79a7",r:4,fillOpacity:.8},qe={stroke:"#4e79a7",strokeWidth:1.5,fill:"none"};function Ge(t,e){if(2>t.length)return[t];const i=.4*e,r=[];let o=[t[0]];for(let e=1;t.length>e;e++){const n=t[e];Math.abs(n[0]-t[e-1][0])>i?(2>o.length||r.push(o),o=[n]):o.push(n)}return 2>o.length||r.push(o),r}function Ve(t,e,i=24){const r=e[0]-t[0],o=e[1]-t[1],n=Math.sqrt(r*r+o*o);if(0===n)return[t,e];const s=-o/n,a=r/n,c=Math.min(.3*n,80),l=(t[0]+e[0])/2+s*c,u=(t[1]+e[1])/2+a*c,h=[];for(let r=0;i>=r;r++){const o=r/i,n=1-o;h.push([n*n*t[0]+2*n*o*l+o*o*e[0],n*n*t[1]+2*n*o*u+o*o*e[1]])}return h}function He(t,e){if(2>t.length)return t;const i=e/2+1,r=[];for(let e=0;t.length>e;e++){const o=t[e];let n,s;0===e?(n=t[1][0]-o[0],s=t[1][1]-o[1]):e===t.length-1?(n=o[0]-t[e-1][0],s=o[1]-t[e-1][1]):(n=t[e+1][0]-t[e-1][0],s=t[e+1][1]-t[e-1][1]);const a=Math.sqrt(n*n+s*s)||1;r.push([o[0]+s/a*i,o[1]+-n/a*i])}return r}function Ze(t,e,i,r,o){const n=e[0]-t[0],s=e[1]-t[1],a=Math.sqrt(n*n+s*s);if(0===a)return[t,e];const c=s/a,l=-n/a,u=o/2+1;return[[t[0]+c*u,t[1]+l*u],[e[0]+c*u,e[1]+l*u]]}class Ke{constructor(t){this.scene=[],this.scales=null,this.version=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this.config=t}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}setAreas(t){this.areas=t}setPoints(t){this.pointData=t,this.streaming=!1}setLines(t){this.lineData=t}initStreaming(t=500){this.pointBuffer=new tt(t),this.timestampBuffer=new tt(t),this.streaming=!0}pushPoint(t){this.pointBuffer||this.initStreaming(),this.pointBuffer.push(t),this.timestampBuffer.push(performance.now()),this.lastIngestTime=performance.now()}pushMany(t){this.pointBuffer||this.initStreaming();const e=performance.now();for(const i of t)this.pointBuffer.push(i),this.timestampBuffer.push(e);this.lastIngestTime=e}removePoint(t){const{pointIdAccessor:e}=this.config;if(!e)throw Error("removePoint() requires pointIdAccessor to be configured");const i="function"==typeof e?e:t=>t[e],r=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>r.has(i(t)+"");if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),i=new Set;this.pointBuffer.forEach((e,r)=>{t(e)&&i.add(r)}),this.timestampBuffer.clear();for(let t=0;e.length>t;t++)i.has(t)||this.timestampBuffer.push(e[t])}const e=this.pointBuffer.remove(t);return e.length>0&&this.version++,e}{const t=[];return this.pointData=this.pointData.filter(e=>!r.has(i(e)+"")||(t.push(e),!1)),t.length>0&&this.version++,t}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.scene=[],this.scales=null,this.version++}computeScene(t){const{config:e}=this;this.projection=function(t){if(!t)return V();if("string"==typeof t){const e=Re[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),V())}if("object"==typeof t&&"type"in t){const e=Re[t.type],i=e?e():V();return t.rotate&&"rotate"in i&&i.rotate(t.rotate),t.center&&"center"in i&&i.center(t.center),i}return t}(e.projection),this.geoPath=Y(this.projection),this.fitProjection(t),this.geoPath=Y(this.projection);const i=this.projection;this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null};const r=this.scene;this.scene=this.buildSceneNodes(t),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&r.length>0&&this.startTransition(r),this.version++}fitProjection(t){var e,i,r,o,n;const s=this.projection,a=this.config,c=[...this.areas],l=Fe(a.xAccessor,"lon"),u=Fe(a.yAccessor,"lat"),h=this.getPoints();if(h.length>0){const t=h.map(t=>[l(t),u(t)]);c.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const f=Ce(a.lineDataAccessor);for(const t of this.lineData){const e=f(t);if(e&&e.length>0){const t=e.map(t=>[l(t),u(t)]);c.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==c.length){if(a.projectionExtent){const[[e,i],[r,o]]=a.projectionExtent;s.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[e,i],[r,i],[r,o],[e,o],[e,i]]]}})}else if(s.clipAngle&&(null!==(e=s.clipAngle())&&void 0!==e?e:0)>0){const e=null!==(i=a.fitPadding)&&void 0!==i?i:0,r=Math.min(t.width,t.height);s.scale(r/2-r*e),s.translate([t.width/2,t.height/2])}else{const e=null!==(r=a.fitPadding)&&void 0!==r?r:0,i=t.width*e,o=t.height*e;s.fitExtent([[i,o],[t.width-i,t.height-o]],{type:"FeatureCollection",features:c})}this.baseScale=s.scale(),this.baseTranslate=s.translate(),this.baseRotation=null!==(n=null===(o=s.rotate)||void 0===o?void 0:o.call(s))&&void 0!==n?n:[0,0,0]}}applyZoomTransform(t,e){const i=this.projection;i&&(i.scale(this.baseScale*t.k),i.translate([this.baseTranslate[0]*t.k+t.x,this.baseTranslate[1]*t.k+t.y]),this.currentZoom=t.k,this.geoPath=Y(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyZoomScale(t,e){const i=this.projection;i&&(i.scale(this.baseScale*t),i.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=Y(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyRotation(t,e){const i=this.projection;i&&i.rotate&&(i.rotate(t),this.geoPath=Y(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}setRotation(t){const e=this.projection;e&&e.rotate&&e.rotate(t)}getRotation(){var t,e,i;return null!==(i=null===(e=null===(t=this.projection)||void 0===t?void 0:t.rotate)||void 0===e?void 0:e.call(t))&&void 0!==i?i:this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}buildSceneNodes(t){var e,i,r;const o=[],{config:n}=this,s=this.projection,a=this.geoPath,c=Fe(n.xAccessor,"lon"),l=Fe(n.yAccessor,"lat");if(n.graticule){const e=!0===n.graticule?{}:n.graticule,i=X();e.step&&i.step(e.step);const r=a(i())||"";r&&o.push({type:"geoarea",pathData:r,centroid:[t.width/2,t.height/2],bounds:[[0,0],[t.width,t.height]],screenArea:0,style:{fill:"none",stroke:e.stroke||"#e0e0e0",strokeWidth:e.strokeWidth||.5,strokeDasharray:e.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const t of this.areas){const e=a(t);if(!e)continue;const i=a.centroid(t),r=a.bounds(t),s=a.area(t),c=Ie(n.areaStyle,t,Ye);o.push({type:"geoarea",pathData:e,centroid:i,bounds:r,screenArea:s,style:c,datum:t,interactive:!0})}const u=Ce(n.lineDataAccessor);for(const e of this.lineData){const i=u(e);if(!i||2>i.length)continue;const r=i.map(t=>[c(t),l(t)]);let a;if("geo"===n.lineType){const t=[];for(let e=0;r.length-1>e;e++){const i=r[e],o=r[e+1],n=q(i,o)||0,s=Math.max(2,Math.ceil(n/(Math.PI/180))),a=G(i,o);for(let i=0;s>=i;i++)e>0&&0===i||t.push(a(i/s))}a=t.map(([t,e])=>s([t,e])).filter(t=>null!=t)}else a=r.map(([t,e])=>s([t,e])).filter(t=>null!=t);if(2>a.length)continue;const h=Ie(n.lineStyle,e,qe),f="number"==typeof h.strokeWidth?h.strokeWidth:1;2!==r.length||2>a.length||"arc"!==n.flowStyle?2!==r.length||2>a.length||"offset"!==n.flowStyle||(a="geo"===n.lineType?He(a,f):Ze(a[0],a[a.length-1],0,0,f)):a=Ve(a[0],a[a.length-1]);const d=Ge(a,t.width);if(d.length>1)for(const t of d){if(2>t.length)continue;const i={type:"line",path:t,style:Object.assign(Object.assign({},h),{_edgeFade:!0}),datum:e};o.push(i)}else o.push({type:"line",path:2>a.length&&d[0]||a,style:h,datum:e})}const h=this.getPoints(),f=n.pointIdAccessor?"function"==typeof n.pointIdAccessor?n.pointIdAccessor:t=>t[n.pointIdAccessor]:null,d=s.clipAngle&&null!==(e=s.clipAngle())&&void 0!==e?e:0,g=d>0?d*Math.PI/180:null,y=s.rotate?s.rotate():[0,0,0],p="function"==typeof s.center?s.center():[0,0],m=[(null!==(i=p[0])&&void 0!==i?i:0)-y[0],(null!==(r=p[1])&&void 0!==r?r:0)-y[1]];for(let t=0;h.length>t;t++){const e=h[t],i=c(e),r=l(e);if(null!=g&&q([i,r],m)>g)continue;const a=s([i,r]);if(!a)continue;const u=n.pointStyle?n.pointStyle(e):Object.assign({},Xe),d={type:"point",x:a[0],y:a[1],r:u.r||4,style:u,datum:e,pointId:f?f(e)+"":void 0};o.push(d)}return o}applyCartogramTransform(t,e){var i,r,o;const n=this.scene.filter(t=>"point"===t.type);if(2>n.length)return;const s=null!==(i=t.strength)&&void 0!==i?i:1;if(0===s)return;const c=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:t=>t.id,l="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],u=n.find(e=>c(e.datum)+""==t.center+"");if(!u)return void("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`));const h=u.x,f=u.y,d=n.map(t=>l(t.datum)).filter(t=>isFinite(t)&&t>=0),g=Math.max(...d,1),y=Math.min(e.width,e.height)/2,p=a().domain([0,g]).range([0,y]);this.cartogramLayout={cx:h,cy:f,maxCost:g,availableRadius:y},this.areas.length>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them."),this.scene=this.scene.filter(t=>"geoarea"!==t.type||!t.interactive);for(const t of n){if(t===u)continue;const e=Math.atan2(t.y-f,t.x-h),i=Math.sqrt(Math.pow(t.x-h,2)+Math.pow(t.y-f,2)),r=l(t.datum),o=i+((isFinite(r)?p(r):i)-i)*s;t.x=h+Math.cos(e)*o,t.y=f+Math.sin(e)*o}const m=e.width/2,x=e.height/2,v=m-u.x,b=x-u.y;if(Math.abs(v)>.5||Math.abs(b)>.5)for(const t of n)t.x+=v,t.y+=b;this.cartogramLayout={cx:m,cy:x,maxCost:g,availableRadius:y};const k=this.scene.filter(t=>"line"===t.type);if(k.length>0&&"fractional"!==t.lineMode){const t=new Map;for(const e of n)e.pointId&&t.set(e.pointId,[e.x,e.y]);for(const e of k){const i=null===(r=e.datum)||void 0===r?void 0:r.source,n=null===(o=e.datum)||void 0===o?void 0:o.target;if(i&&n){const r=t.get(i+""),o=t.get(n+"");r&&o&&(e.path=[r,o])}}}}applyDecay(){var t,e,i;const r=this.config.decay;if(!r||!this.pointBuffer)return;const o=this.pointBuffer.size;if(0===o)return;const n=null!==(t=r.minOpacity)&&void 0!==t?t:.1,s=null!==(e=r.halfLife)&&void 0!==e?e:o/2,a=null!==(i=r.stepThreshold)&&void 0!==i?i:.5*o,c=this.scene.filter(t=>"point"===t.type);for(let t=0;c.length>t;t++){const e=o-1-t;let i;switch(r.type){case"exponential":i=n+Math.pow(.5,e/s)*(1-n);break;case"step":i=a>e?1:n;break;default:i=n+(o>1?1-e/(o-1):1)*(1-n)}c[t]._decayOpacity=i,c[t].style=Object.assign(Object.assign({},c[t].style),{opacity:i})}}applyPulse(){var t,e;const i=this.config.pulse;if(!i||!this.timestampBuffer)return;const r=null!==(t=i.duration)&&void 0!==t?t:500,o=performance.now(),n=this.scene.filter(t=>"point"===t.type),s=this.timestampBuffer.toArray();for(let t=0;n.length>t&&s.length>t;t++){const a=o-s[t];r>a&&(n[t]._pulseIntensity=1-a/r,n[t]._pulseColor=i.color||"rgba(255,255,255,0.6)",n[t]._pulseGlowRadius=null!==(e=i.glowRadius)&&void 0!==e?e:4)}}get hasActivePulses(){var t,e;if(!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const i=null!==(e=null===(t=this.config.pulse)||void 0===t?void 0:t.duration)&&void 0!==e?e:500,r=this.timestampBuffer.toArray()[this.timestampBuffer.size-1];return performance.now()-r<i}startTransition(t){var e,i;const r=null!==(i=null===(e=this.config.transition)||void 0===e?void 0:e.duration)&&void 0!==i?i:300;if(0>=r)return;const o=new Map;for(const e of t)"point"===e.type&&e.pointId&&o.set(e.pointId,[e.x,e.y]);const n=this.scene.filter(t=>"point"===t.type);let s=!1;for(const t of n)if(t.pointId){const e=o.get(t.pointId);e&&(t._targetX=t.x,t._targetY=t.y,t.x=e[0],t.y=e[1],(Math.abs(e[0]-t._targetX)>.5||Math.abs(e[1]-t._targetY)>.5)&&(s=!0))}s&&(this.activeTransition={startTime:performance.now(),duration:r})}advanceTransition(t){if(!this.activeTransition)return!1;const e=ht(t,this.activeTransition),i=ut(e),r=this.scene.filter(t=>"point"===t.type);for(const t of r)if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=ft(t.x,t._targetX,i),t.y=ft(e,t._targetY,i)}if(e>=1){for(const t of r)null!=t._targetX&&(t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0);return this.activeTransition=null,!1}return!0}}function Ue(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}function Qe(e,i){var r,o,n;switch(e.type){case"line":{const r=e;if(0===r.path.length)return null;const o="M"+r.path.map(([t,e])=>`${t},${e}`).join("L");return t.createElement("path",{key:"line-"+i,d:o,fill:"none",stroke:r.style.stroke||"#4e79a7",strokeWidth:r.style.strokeWidth||2,strokeDasharray:r.style.strokeDasharray,opacity:r.style.opacity})}case"area":{const n=e;if(0===n.topPath.length)return null;const s=n.topPath.map(([t,e])=>`${t},${e}`).join("L"),a=[...n.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return t.createElement("path",{key:"area-"+i,d:`M${s}L${a}Z`,fill:Ue(n.style.fill),fillOpacity:null!==(o=null!==(r=n.style.fillOpacity)&&void 0!==r?r:n.style.opacity)&&void 0!==o?o:.7,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})}case"point":{const r=e;return t.createElement("circle",{key:"point-"+i,cx:r.x,cy:r.y,r:r.r,fill:Ue(r.style.fill),opacity:null!==(n=r.style.opacity)&&void 0!==n?n:.8,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})}case"rect":{const r=e;return t.createElement("rect",{key:"rect-"+i,x:r.x,y:r.y,width:r.w,height:r.h,fill:Ue(r.style.fill),opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})}case"heatcell":{const r=e;if(r.showValues&&null!=r.value&&r.w>=20&&r.h>=20){const e=r.valueFormat?r.valueFormat(r.value):Number.isInteger(r.value)?r.value+"":100>Math.abs(r.value)?1>Math.abs(r.value)?r.value.toPrecision(3):r.value.toFixed(1):r.value.toFixed(0),[o,n,s]=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]}(r.fill),a=.299*o+.587*n+.114*s>128?"#000":"#fff",c=Math.max(10,Math.min(16,.3*Math.min(r.w,r.h)));return t.createElement("g",{key:"heatcell-"+i},t.createElement("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:r.fill}),t.createElement("text",{x:r.x+r.w/2,y:r.y+r.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:c+"px"},e))}return t.createElement("rect",{key:"heatcell-"+i,x:r.x,y:r.y,width:r.w,height:r.h,fill:r.fill})}case"candlestick":{const r=e,o=Math.min(r.openY,r.closeY),n=Math.max(Math.abs(r.openY-r.closeY),1),s=r.isUp?r.upColor:r.downColor;return t.createElement("g",{key:"candle-"+i},t.createElement("line",{x1:r.x,y1:r.highY,x2:r.x,y2:r.lowY,stroke:r.wickColor,strokeWidth:r.wickWidth}),t.createElement("rect",{x:r.x-r.bodyWidth/2,y:o,width:r.bodyWidth,height:n,fill:s,stroke:s,strokeWidth:1}))}default:return null}}function Je(e,i){var r,o,n,s,a;const c=e.category||e.group||"",l=t=>`ord-${e.type}-${c}-${i}-${t}`,u=`ord-${e.type}-${c}-${i}`;switch(e.type){case"rect":{const i=e;return t.createElement("rect",{key:u,x:i.x,y:i.y,width:i.w,height:i.h,fill:Ue(i.style.fill),opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})}case"point":{const i=e;return t.createElement("circle",{key:u,cx:i.x,cy:i.y,r:i.r,fill:Ue(i.style.fill),opacity:null!==(r=i.style.opacity)&&void 0!==r?r:.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})}case"wedge":{const i=e,r=T().innerRadius(i.innerRadius).outerRadius(i.outerRadius).startAngle(i.startAngle).endAngle(i.endAngle)({})||"";return t.createElement("path",{key:u,d:r,transform:`translate(${i.cx},${i.cy})`,fill:Ue(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}case"boxplot":{const i=e,r=i.columnWidth/2;return"vertical"===i.projection?t.createElement("g",{key:u},t.createElement("line",{x1:i.x,y1:i.minPos,x2:i.x,y2:i.maxPos,stroke:i.style.stroke||"#333",strokeWidth:1}),t.createElement("rect",{x:i.x-r,y:Math.min(i.q1Pos,i.q3Pos),width:i.columnWidth,height:Math.abs(i.q3Pos-i.q1Pos),fill:Ue(i.style.fill),fillOpacity:null!==(o=i.style.fillOpacity)&&void 0!==o?o:.6,stroke:i.style.stroke||"#333",strokeWidth:1}),t.createElement("line",{x1:i.x-r,y1:i.medianPos,x2:i.x+r,y2:i.medianPos,stroke:i.style.stroke||"#333",strokeWidth:2}),t.createElement("line",{x1:i.x-.5*r,y1:i.minPos,x2:i.x+.5*r,y2:i.minPos,stroke:i.style.stroke||"#333",strokeWidth:1}),t.createElement("line",{x1:i.x-.5*r,y1:i.maxPos,x2:i.x+.5*r,y2:i.maxPos,stroke:i.style.stroke||"#333",strokeWidth:1})):t.createElement("g",{key:u},t.createElement("line",{x1:i.minPos,y1:i.y,x2:i.maxPos,y2:i.y,stroke:i.style.stroke||"#333",strokeWidth:1}),t.createElement("rect",{x:Math.min(i.q1Pos,i.q3Pos),y:i.y-r,width:Math.abs(i.q3Pos-i.q1Pos),height:i.columnWidth,fill:Ue(i.style.fill),fillOpacity:null!==(n=i.style.fillOpacity)&&void 0!==n?n:.6,stroke:i.style.stroke||"#333",strokeWidth:1}),t.createElement("line",{x1:i.medianPos,y1:i.y-r,x2:i.medianPos,y2:i.y+r,stroke:i.style.stroke||"#333",strokeWidth:2}),t.createElement("line",{x1:i.minPos,y1:i.y-.5*r,x2:i.minPos,y2:i.y+.5*r,stroke:i.style.stroke||"#333",strokeWidth:1}),t.createElement("line",{x1:i.maxPos,y1:i.y-.5*r,x2:i.maxPos,y2:i.y+.5*r,stroke:i.style.stroke||"#333",strokeWidth:1}))}case"violin":{const i=e,r=[t.createElement("path",{key:l("path"),d:i.pathString,transform:i.translateX||i.translateY?`translate(${i.translateX},${i.translateY})`:void 0,fill:Ue(i.style.fill),fillOpacity:null!==(s=i.style.fillOpacity)&&void 0!==s?s:.6,stroke:i.style.stroke||"#333",strokeWidth:i.style.strokeWidth||1})];if(i.iqrLine&&i.bounds){const e=i.bounds,o=e.x+e.width/2,n=e.y+e.height/2;e.height>e.width?r.push(t.createElement("line",{key:l("iqr"),x1:o,y1:i.iqrLine.q1Pos,x2:o,y2:i.iqrLine.q3Pos,stroke:i.style.stroke||"#333",strokeWidth:2}),t.createElement("circle",{key:l("med"),cx:o,cy:i.iqrLine.medianPos,r:3,fill:"white",stroke:i.style.stroke||"#333",strokeWidth:1})):r.push(t.createElement("line",{key:l("iqr"),x1:i.iqrLine.q1Pos,y1:n,x2:i.iqrLine.q3Pos,y2:n,stroke:i.style.stroke||"#333",strokeWidth:2}),t.createElement("circle",{key:l("med"),cx:i.iqrLine.medianPos,cy:n,r:3,fill:"white",stroke:i.style.stroke||"#333",strokeWidth:1}))}return t.createElement("g",{key:u},r)}case"connector":return t.createElement("line",{key:u,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:null!==(a=e.style.opacity)&&void 0!==a?a:.5});case"trapezoid":{const i=e,r=i.points.map(t=>`${t[0]},${t[1]}`).join(" ");return t.createElement("polygon",{key:u,points:r,fill:Ue(i.style.fill,"#999"),opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})}default:return null}}const ti={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}},ei={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}},ii={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"};e(null),function(t){const e=new EventTarget;let i=t(function(t){i=Object.assign(Object.assign({},i),t(i)),e.dispatchEvent(new CustomEvent("update"))})}(t=>({theme:ti,setTheme(e){t(t=>{if("light"===e)return{theme:ti};if("dark"===e)return{theme:ei};if("high-contrast"===e)return{theme:ii};if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?ei:ti;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||{})})}})}}));const ri={light:ti,dark:ei,"high-contrast":ii,pastels:{mode:"light",colors:{primary:"#c9a0dc",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",text:"#4a3728",textSecondary:"#8b7355",grid:"#e8d5c4",border:"#e8d5c4",focus:"#c9a0dc"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",text:"#2c3e50",textSecondary:"#7f8c9b",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}};function oi(t){if(!t)return ti;if("string"==typeof t){if("light"===t)return ti;if("dark"===t)return ei;if("high-contrast"===t)return ii;return ri[t]||ti}const e="dark"===t.mode?ei:ti;return Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{}),tooltip:Object.assign(Object.assign({},e.tooltip),t.tooltip||{})})}function ni(t){return{background:t.colors.background,text:t.colors.text,textSecondary:t.colors.textSecondary,grid:t.colors.grid,border:t.colors.border,primary:t.colors.primary,fontFamily:t.typography.fontFamily,titleSize:t.typography.titleSize,labelSize:t.typography.labelSize,tickSize:t.typography.tickSize,categorical:t.colors.categorical}}function si(e){const{categories:i,colorScheme:r,theme:o,position:n="right",totalWidth:s,totalHeight:a,margin:c,hasTitle:l=!1}=e;if(!i||0===i.length)return null;const u=function(t,e,i){const r=Array.isArray(e)?e:i.colors.categorical.length>0?i.colors.categorical:m;return h().domain(t).range(r)}(i,r,o);let f,d;if("left"===n?(f=4,d=c.top):"top"===n?(f=c.left,d=l?32:8):"bottom"===n?(f=c.left,d=a-c.bottom+8):(f=s-c.right+10,d=c.top),"top"===n||"bottom"===n){let e=0;const r=i.map((i,r)=>{const n=e;return e+=22+6.5*i.length+8,t.createElement("g",{key:"legend-"+r,transform:`translate(${n},0)`},t.createElement("rect",{width:14,height:14,fill:u(i),rx:2}),t.createElement("text",{x:20,y:7,dominantBaseline:"central",fontSize:o.typography.tickSize,fill:o.colors.text,fontFamily:o.typography.fontFamily},i))});return t.createElement("g",{className:"semiotic-legend",transform:`translate(${f},${d})`},r)}const g=i.map((e,i)=>t.createElement("g",{key:"legend-"+i,transform:`translate(0,${20*i})`},t.createElement("rect",{width:14,height:14,fill:u(e),rx:2}),t.createElement("text",{x:20,y:7,dominantBaseline:"central",fontSize:o.typography.tickSize,fill:o.colors.text,fontFamily:o.typography.fontFamily},e)));return t.createElement("g",{className:"semiotic-legend",transform:`translate(${f},${d})`},g)}function ai(t,e){if(!e||!t||0===t.length)return[];const i="function"==typeof e?e:t=>t[e],r=new Set;for(const e of t){const t=i(e);null!=t&&r.add(t+"")}return Array.from(r)}function ci(e){const{annotations:i}=e;if(!i||0===i.length)return null;const r=[];for(let t=0;i.length>t;t++){const o=li(i[t],t,e);o&&r.push(o)}return r.length>0?t.createElement("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations"},r):null}function li(e,i,r){var o,n,s,a;const{scales:c,layout:l,theme:u,xAccessor:h,yAccessor:f}=r;switch(e.type){case"y-threshold":{const n=e.value;if(null==n)return null;const s=e.color||u.colors.primary,a=e.label,h=e.labelPosition||"right",f=e.strokeDasharray||"6,4",d=null!==(o=e.strokeWidth)&&void 0!==o?o:1.5;if("horizontal"===r.projection&&c.r){const e=c.r(n);return null==e?null:t.createElement("g",{key:"ann-ythresh-"+i},t.createElement("line",{x1:e,y1:0,x2:e,y2:l.height,stroke:s,strokeWidth:d,strokeDasharray:f}),a&&t.createElement("text",{x:e+4,y:12,textAnchor:"start",fontSize:u.typography.tickSize,fill:s,fontFamily:u.typography.fontFamily},a))}const g=c.y?c.y(n):c.r?c.r(n):null;return null==g?null:t.createElement("g",{key:"ann-ythresh-"+i},t.createElement("line",{x1:0,y1:g,x2:l.width,y2:g,stroke:s,strokeWidth:d,strokeDasharray:f}),a&&t.createElement("text",{x:"left"===h?4:"center"===h?l.width/2:l.width-4,y:g-6,textAnchor:"left"===h?"start":"center"===h?"middle":"end",fontSize:u.typography.tickSize,fill:s,fontFamily:u.typography.fontFamily},a))}case"x-threshold":{const r=e.value;if(null==r||!c.x)return null;const o=c.x(r);if(null==o)return null;const s=e.color||u.colors.primary,a=e.label,h=e.labelPosition||"top",f=null!==(n=e.strokeWidth)&&void 0!==n?n:1.5;return t.createElement("g",{key:"ann-xthresh-"+i},t.createElement("line",{x1:o,y1:0,x2:o,y2:l.height,stroke:s,strokeWidth:f,strokeDasharray:e.strokeDasharray||"6,4"}),a&&t.createElement("text",{x:o+4,y:"bottom"===h?l.height-4:"center"===h?l.height/2:12,textAnchor:"start",fontSize:u.typography.tickSize,fill:s,fontFamily:u.typography.fontFamily},a))}case"band":{const r=null!=e.y0&&c.y?c.y(e.y0):null,o=null!=e.y1&&c.y?c.y(e.y1):null;if(null==r||null==o)return null;const n=Math.min(r,o),a=e.fill||e.color||u.colors.primary,h=null!==(s=e.opacity)&&void 0!==s?s:.1;return t.createElement("g",{key:"ann-band-"+i},t.createElement("rect",{x:0,y:n,width:l.width,height:Math.abs(o-r),fill:a,opacity:h}),e.label&&t.createElement("text",{x:l.width-4,y:n+12,textAnchor:"end",fontSize:u.typography.tickSize,fill:a,fontFamily:u.typography.fontFamily},e.label))}case"category-highlight":{if(!e.category||!c.o)return null;const o=c.o(e.category);if(null==o)return null;const n=c.o.bandwidth?c.o.bandwidth():40,s=e.color||u.colors.primary,h=null!==(a=e.opacity)&&void 0!==a?a:.1;return t.createElement("rect","horizontal"===r.projection?{key:"ann-cathighlight-"+i,x:0,y:o,width:l.width,height:n,fill:s,opacity:h}:{key:"ann-cathighlight-"+i,x:o,y:0,width:n,height:l.height,fill:s,opacity:h})}case"label":case"text":{const r=function(t,e,i){return null!=t.x&&e.x?e.x(t.x):i&&null!=t[i]&&e.x?e.x(t[i]):null}(e,c,h),o=function(t,e,i){return null!=t.y&&e.y?e.y(t.y):i&&null!=t[i]&&e.y?e.y(t[i]):null}(e,c,f);if(null==r||null==o)return null;const n=e.dx||0,s=e.dy||0,a=e.color||u.colors.text;return t.createElement("g",{key:"ann-label-"+i},"label"===e.type&&t.createElement("line",{x1:r,y1:o,x2:r+n,y2:o+s,stroke:u.colors.textSecondary,strokeWidth:1}),t.createElement("text",{x:r+n,y:o+s,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||u.typography.labelSize,fill:a,fontFamily:u.typography.fontFamily,fontWeight:e.fontWeight},e.label||e.title))}default:return null}}const ui=require("react-dom/server");function hi(t){return Math.round(100*t)/100+""}function fi(e,i){const r=ni(i.theme),o=i.idPrefix?i.idPrefix+"-":"",n="string"==typeof i.title?i.title:void 0,s=n?o+"semiotic-title":void 0,a=i.description?o+"semiotic-desc":void 0,c=[s,a].filter(Boolean).join(" ")||void 0;return t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:i.className,width:i.width,height:i.height,role:"img","aria-labelledby":c,style:{fontFamily:r.fontFamily}},n&&t.createElement("title",{id:s},n),i.description&&t.createElement("desc",{id:a},i.description),i.defs&&t.createElement("defs",null,i.defs),i.background&&"transparent"!==i.background&&t.createElement("rect",{x:0,y:0,width:i.width,height:i.height,fill:i.background}),t.createElement("g",{id:o+"data-area",transform:i.innerTransform},e),n&&t.createElement("text",{id:o+"chart-title",x:i.width/2,y:16,textAnchor:"middle",fontSize:r.titleSize,fontWeight:"bold",fill:r.text,fontFamily:r.fontFamily},n),i.legend&&t.createElement("g",{id:o+"legend"},i.legend),i.outerElements)}function di(e){var i,r,o,n;const s=oi(e.theme),a=e.size||[500,300],c=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),e.margin),l=e.legendPosition;e.showLegend&&(l&&"right"!==l?"left"===l?c.left=Math.max(c.left,100):"bottom"===l?c.bottom=Math.max(c.bottom,70):"top"===l&&(c.top=Math.max(c.top,40)):c.right=Math.max(c.right,100));const u=a[0]-c.left-c.right,h=a[1]-c.top-c.bottom,f="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),d={chartType:e.chartType,windowSize:null!==(i=e.windowSize)&&void 0!==i?i:200,windowMode:null!==(r=e.windowMode)&&void 0!==r?r:"sliding",arrowOfTime:f&&null!==(o=e.arrowOfTime)&&void 0!==o?o:"right",extentPadding:null!==(n=e.extentPadding)&&void 0!==n?n:.1,xAccessor:f?void 0:e.xAccessor,yAccessor:f?void 0:e.yAccessor,timeAccessor:f?e.timeAccessor:void 0,valueAccessor:e.valueAccessor,colorAccessor:e.colorAccessor,sizeAccessor:e.sizeAccessor,groupAccessor:e.groupAccessor,categoryAccessor:e.categoryAccessor,lineDataAccessor:e.lineDataAccessor,xExtent:e.xExtent,yExtent:e.yExtent,sizeRange:e.sizeRange,binSize:e.binSize,normalize:e.normalize,boundsAccessor:e.boundsAccessor,boundsStyle:e.boundsStyle,openAccessor:e.openAccessor,highAccessor:e.highAccessor,lowAccessor:e.lowAccessor,closeAccessor:e.closeAccessor,candlestickStyle:e.candlestickStyle,lineStyle:e.lineStyle,pointStyle:e.pointStyle,areaStyle:e.areaStyle,colorScheme:e.colorScheme||s.colors.categorical,barColors:e.barColors},g=new St(d);if(e.data&&g.ingest({inserts:e.data,bounded:!0}),g.computeScene({width:u,height:h}),!g.scales||0===g.scene.length)return ui.renderToStaticMarkup(fi(null,{width:a[0],height:a[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:s,innerTransform:`translate(${c.left},${c.top})`,idPrefix:e._idPrefix}));const y=e._idPrefix,p=e.showGrid?function(e,i,r,o){const{grid:n}=ni(r),s=o?o+"-":"",a=e.x.ticks(5),c=e.y.ticks(5);return t.createElement("g",{id:s+"grid",className:"semiotic-grid",opacity:.8},a.map((r,o)=>{const s=e.x(r);return t.createElement("line",{key:"gx-"+o,x1:s,y1:0,x2:s,y2:i.height,stroke:n,strokeWidth:.5})}),c.map((r,o)=>{const s=e.y(r);return t.createElement("line",{key:"gy-"+o,x1:0,y1:s,x2:i.width,y2:s,stroke:n,strokeWidth:.5})}))}(g.scales,{width:u,height:h},s,y):null,m=g.scene.map((t,e)=>Qe(t,e)).filter(Boolean),x=!1!==e.showAxes?function(e,i,r,o,n){var s,a,c,l;const u=ni(o),h=e.x.ticks(5).map(t=>({pixel:e.x(t),label:(r.xFormat||r.tickFormatTime||hi)(t)})),f=e.y.ticks(5).map(t=>({pixel:e.y(t),label:(r.yFormat||r.tickFormatValue||hi)(t)}));return t.createElement("g",{id:(n?n+"-":"")+"axes",className:"stream-axes"},t.createElement("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:u.border,strokeWidth:1}),h.map((e,r)=>t.createElement("g",{key:"xtick-"+r,transform:`translate(${e.pixel},${i.height})`},t.createElement("line",{y2:5,stroke:u.border,strokeWidth:1}),t.createElement("text",{y:18,textAnchor:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily},e.label))),r.xLabel&&t.createElement("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily},r.xLabel),t.createElement("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:u.border,strokeWidth:1}),f.map((e,i)=>t.createElement("g",{key:"ytick-"+i,transform:`translate(0,${e.pixel})`},t.createElement("line",{x2:-5,stroke:u.border,strokeWidth:1}),t.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily},e.label))),r.yLabel&&t.createElement("text",{x:15-(null!==(a=null===(s=r.margin)||void 0===s?void 0:s.left)&&void 0!==a?a:40),y:i.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-(null!==(l=null===(c=r.margin)||void 0===c?void 0:c.left)&&void 0!==l?l:40)}, ${i.height/2})`},r.yLabel))}(g.scales,{width:u,height:h},e,s,y):null,v=e.annotations?ci({annotations:e.annotations,scales:{x:g.scales.x,y:g.scales.y},layout:{width:u,height:h},theme:s,xAccessor:"string"==typeof e.xAccessor?e.xAccessor:void 0,yAccessor:"string"==typeof e.yAccessor?e.yAccessor:void 0,idPrefix:y}):null,b=e.showLegend?(()=>{const t=ai(e.data||[],e.colorAccessor||e.groupAccessor);return 0===t.length?null:si({categories:t,colorScheme:e.colorScheme,theme:s,position:e.legendPosition||"right",totalWidth:a[0],totalHeight:a[1],margin:c,hasTitle:!!e.title})})():null,k=t.createElement(t.Fragment,null,p,v,m,x);return ui.renderToStaticMarkup(fi(k,{width:a[0],height:a[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:s,innerTransform:`translate(${c.left},${c.top})`,legend:b,idPrefix:e._idPrefix}))}function gi(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const yi=new Set(["tree","cluster","treemap","circlepack","partition"]);function pi(e){const i=oi(e.theme),r=e.chartType||"force",o=e.size||[500,500],n=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),e.margin),s=o[0]-n.left-n.right,a=o[1]-n.top-n.bottom,c=function(t){return Te[t]}(r);if(!c)throw Error(`No layout plugin found for chart type: "${r}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const l={chartType:r,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,colorBy:e.colorBy,colorScheme:e.colorScheme||i.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange};let u,h;if(yi.has(r)){const t=e.data||e.edges;if(!t||Array.isArray(t))return ui.renderToStaticMarkup(fi(null,{width:o[0],height:o[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,idPrefix:e._idPrefix}));l.__hierarchyRoot=t,u=[],h=[]}else{const t=e.nodes||[],r=Array.isArray(e.edges)?e.edges:[];if(0===t.length&&0===r.length)return ui.renderToStaticMarkup(fi(null,{width:o[0],height:o[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,idPrefix:e._idPrefix}));if(h=function(t,e){const i=gi(e.sourceAccessor,"source"),r=gi(e.targetAccessor,"target"),o=gi(e.valueAccessor,"value");return t.map(t=>({source:i(t)+"",target:r(t)+"",value:Number(o(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(r,l),0===t.length&&h.length>0){const t=new Set;for(const e of h){const i="string"==typeof e.target?e.target:e.target.id;t.add("string"==typeof e.source?e.source:e.source.id),t.add(i)}u=Array.from(t).map(t=>({id:t,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:t}}))}else u=function(t,e){const i=gi(e.nodeIDAccessor,"id");return t.map(t=>{var e,r;return{id:i(t)+"",x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(r=t.y)&&void 0!==r?r:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}})}(t,l)}c.computeLayout(u,h,l,[s,a]);const{sceneNodes:f,sceneEdges:d,labels:g}=c.buildScene(u,h,l,[s,a]),y=ni(i);for(const t of g)t.fill||(t.fill=y.text);const p=d.map((e,i)=>function(e,i){switch(e.type){case"line":return t.createElement("line",{key:"net-edge-"+i,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity});case"bezier":{const r=e;return t.createElement("path",{key:"net-edge-"+i,d:r.pathD,fill:Ue(r.style.fill,"#999"),fillOpacity:r.style.fillOpacity,stroke:r.style.stroke||"none",strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"ribbon":{const r=e;return t.createElement("path",{key:"net-edge-"+i,d:r.pathD,fill:Ue(r.style.fill,"#999"),fillOpacity:r.style.fillOpacity,stroke:r.style.stroke||"none",strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"curved":{const r=e;return t.createElement("path",{key:"net-edge-"+i,d:r.pathD,fill:Ue(r.style.fill,"none"),stroke:r.style.stroke||"#999",strokeWidth:r.style.strokeWidth||1,opacity:r.style.opacity})}default:return null}}(e,i)).filter(Boolean),m=f.map((e,i)=>function(e,i){switch(e.type){case"circle":{const r=e;return t.createElement("circle",{key:"net-circle-"+i,cx:r.cx,cy:r.cy,r:r.r,fill:Ue(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"rect":{const r=e;return t.createElement("rect",{key:"net-rect-"+i,x:r.x,y:r.y,width:r.w,height:r.h,fill:Ue(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"arc":{const r=e,o=T().innerRadius(r.innerR).outerRadius(r.outerR).startAngle(r.startAngle).endAngle(r.endAngle)({})||"";return t.createElement("path",{key:"net-arc-"+i,d:o,transform:`translate(${r.cx},${r.cy})`,fill:Ue(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}default:return null}}(e,i)).filter(Boolean),x=g.map((e,i)=>function(e,i){return t.createElement("text",{key:"net-label-"+i,x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"#333",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder},e.text)}(e,i)).filter(Boolean),v=t.createElement(t.Fragment,null,p,m,x);return ui.renderToStaticMarkup(fi(v,{width:o[0],height:o[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,idPrefix:e._idPrefix}))}function mi(e){var i,r,o,n,s;const a=oi(e.theme),c=e.size||[500,400],l=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),e.margin),u=e.legendPosition;e.showLegend&&(u&&"right"!==u?"left"===u?l.left=Math.max(l.left,100):"bottom"===u?l.bottom=Math.max(l.bottom,70):"top"===u&&(l.top=Math.max(l.top,40)):l.right=Math.max(l.right,100));const h=c[0]-l.left-l.right,f=c[1]-l.top-l.bottom,d=e.projection||"vertical",g="radial"===d,y={chartType:e.chartType,windowSize:null!==(i=e.windowSize)&&void 0!==i?i:1e4,windowMode:null!==(r=e.windowMode)&&void 0!==r?r:"sliding",extentPadding:null!==(o=e.extentPadding)&&void 0!==o?o:.05,projection:d,oAccessor:e.oAccessor,rAccessor:e.rAccessor,colorAccessor:e.colorAccessor,stackBy:e.stackBy,groupBy:e.groupBy,categoryAccessor:e.categoryAccessor,valueAccessor:e.valueAccessor,timeAccessor:e.timeAccessor,rExtent:e.rExtent,oExtent:e.oExtent,barPadding:e.barPadding,innerRadius:e.innerRadius,normalize:e.normalize,startAngle:e.startAngle,bins:e.bins,showOutliers:e.showOutliers,showIQR:e.showIQR,amplitude:e.amplitude,oSort:e.oSort,connectorAccessor:e.connectorAccessor,connectorStyle:e.connectorStyle,dynamicColumnWidth:e.dynamicColumnWidth,pieceStyle:e.pieceStyle,summaryStyle:e.summaryStyle,colorScheme:e.colorScheme||a.colors.categorical,barColors:e.barColors},p=new We(y);if(e.data&&p.ingest({inserts:e.data,bounded:!0}),p.computeScene({width:h,height:f}),!p.scales||0===p.scene.length)return ui.renderToStaticMarkup(fi(null,{width:c[0],height:c[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:a,innerTransform:`translate(${l.left},${l.top})`,idPrefix:e._idPrefix}));const m=e._idPrefix,x=e.showGrid?function(e,i,r,o){const n=e.scales;if(!n||"radial"===n.projection)return null;const{grid:s}=ni(r),a=o?o+"-":"",c="vertical"===n.projection,l=n.r.ticks(5);return t.createElement("g",{id:a+"grid",className:"semiotic-grid",opacity:.8},l.map(c?(e,r)=>{const o=n.r(e);return t.createElement("line",{key:"gr-"+r,x1:0,y1:o,x2:i.width,y2:o,stroke:s,strokeWidth:.5})}:(e,r)=>{const o=n.r(e);return t.createElement("line",{key:"gr-"+r,x1:o,y1:0,x2:o,y2:i.height,stroke:s,strokeWidth:.5})}))}(p,{width:h,height:f},a,m):null,v=p.scene.some(t=>{var e;return"rect"===t.type&&(null===(e=t.datum)||void 0===e?void 0:e.__barFunnelIsDropoff)});let b=null;if(v){const i=function(t){const e=t._idPrefix||t.chartId;if(e){const t=(e+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(t)?t:"c"+t}const i=`${t.chartType||""}:${t.title||""}:${Array.isArray(t.data)?t.data.length:0}`;let r=0;for(let t=0;i.length>t;t++)r=31*r+i.charCodeAt(t)|0;return"c"+(r>>>0).toString(36)}(e),r=new Set;for(const t of p.scene)"rect"===t.type&&(null===(n=t.datum)||void 0===n?void 0:n.__barFunnelIsDropoff)&&r.add("string"==typeof t.style.fill?t.style.fill:"#666");b=Array.from(r).map((e,r)=>function(e){const{id:i,background:r="transparent",stroke:o="#000",lineWidth:n=1.5,spacing:s=6,angle:a=45}=e,c=Math.max(8,Math.ceil(2*s));return t.createElement("pattern",{key:i,id:i,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==a?`rotate(${a})`:void 0},r&&"transparent"!==r&&t.createElement("rect",{width:c,height:c,fill:r}),t.createElement("line",{x1:0,y1:0,x2:0,y2:c,stroke:o,strokeWidth:n}),t.createElement("line",{x1:s,y1:0,x2:s,y2:c,stroke:o,strokeWidth:n}))}({id:`funnel-hatch-${i}-${r}`,background:e,stroke:"transparent"===a.colors.background?"#fff":a.colors.background,lineWidth:1.5,spacing:5,angle:45}));const o=new Map;Array.from(r).forEach((t,e)=>o.set(t,`funnel-hatch-${i}-${e}`));for(const t of p.scene)if("rect"===t.type&&(null===(s=t.datum)||void 0===s?void 0:s.__barFunnelIsDropoff)){const e="string"==typeof t.style.fill?t.style.fill:"#666";t.style=Object.assign(Object.assign({},t.style),{fill:`url(#${o.get(e)})`})}}const k=p.scene.map((t,e)=>Je(t,e)).filter(Boolean),w=!1!==e.showAxes?function(e,i,r,o,n){var s,a,c,l,u,h,f,d;const g=e.scales;if(!g)return null;if("radial"===g.projection)return null;const y=ni(o),p="vertical"===g.projection,m=Object.values(e.columns).map(t=>({pixel:t.middle,label:(r.oFormat||String)(t.name)})),x=g.r.ticks(5).map(t=>({pixel:g.r(t),label:(r.rFormat||hi)(t)}));return p?t.createElement("g",{id:(n?n+"-":"")+"axes",className:"ordinal-axes"},t.createElement("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:y.border,strokeWidth:1}),m.map((e,r)=>t.createElement("g",{key:"oxtick-"+r,transform:`translate(${e.pixel},${i.height})`},t.createElement("line",{y2:5,stroke:y.border,strokeWidth:1}),t.createElement("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily},e.label))),r.oLabel&&t.createElement("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily},r.oLabel),t.createElement("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:y.border,strokeWidth:1}),x.map((e,i)=>t.createElement("g",{key:"oytick-"+i,transform:`translate(0,${e.pixel})`},t.createElement("line",{x2:-5,stroke:y.border,strokeWidth:1}),t.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily},e.label))),r.rLabel&&t.createElement("text",{x:15-(null!==(a=null===(s=r.margin)||void 0===s?void 0:s.left)&&void 0!==a?a:40),y:i.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(l=null===(c=r.margin)||void 0===c?void 0:c.left)&&void 0!==l?l:40)}, ${i.height/2})`},r.rLabel)):t.createElement("g",{id:(n?n+"-":"")+"axes",className:"ordinal-axes"},t.createElement("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:y.border,strokeWidth:1}),x.map((e,r)=>t.createElement("g",{key:"oxtick-"+r,transform:`translate(${e.pixel},${i.height})`},t.createElement("line",{y2:5,stroke:y.border,strokeWidth:1}),t.createElement("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily},e.label))),r.rLabel&&t.createElement("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily},r.rLabel),t.createElement("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:y.border,strokeWidth:1}),m.map((e,i)=>t.createElement("g",{key:"oytick-"+i,transform:`translate(0,${e.pixel})`},t.createElement("line",{x2:-5,stroke:y.border,strokeWidth:1}),t.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily},e.label))),r.oLabel&&t.createElement("text",{x:15-(null!==(h=null===(u=r.margin)||void 0===u?void 0:u.left)&&void 0!==h?h:40),y:i.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(d=null===(f=r.margin)||void 0===f?void 0:f.left)&&void 0!==d?d:40)}, ${i.height/2})`},r.oLabel))}(p,{width:h,height:f},e,a,m):null,A=e.annotations?ci({annotations:e.annotations,scales:{r:p.scales.r,y:"vertical"===p.scales.projection?p.scales.r:void 0},layout:{width:h,height:f},theme:a,projection:d,idPrefix:m}):null,S=e.showLegend?(()=>{const t=ai(e.data||[],e.colorAccessor||e.stackBy||e.groupBy);return 0===t.length?null:si({categories:t,colorScheme:e.colorScheme,theme:a,position:e.legendPosition||"right",totalWidth:c[0],totalHeight:c[1],margin:l,hasTitle:!!e.title})})():null,_=g?l.left+h/2:l.left,P=g?l.top+f/2:l.top,E=t.createElement(t.Fragment,null,x,A,k,w);return ui.renderToStaticMarkup(fi(E,{width:c[0],height:c[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:a,innerTransform:`translate(${_},${P})`,legend:S,defs:b,idPrefix:e._idPrefix}))}function xi(e){var i,r,o,n,s,a,c,l;const u=oi(e.theme),h=e.size||[e.width||600,e.height||400],f=Object.assign(Object.assign({},{top:10,right:10,bottom:10,left:10}),e.margin),d=h[0]-(null!==(i=f.left)&&void 0!==i?i:0)-(null!==(r=f.right)&&void 0!==r?r:0),g=h[1]-(null!==(o=f.top)&&void 0!==o?o:0)-(null!==(n=f.bottom)&&void 0!==n?n:0),y=new Ke({projection:e.projection||"equalEarth",xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineType:e.lineType,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform});if(e.areas){if("string"==typeof e.areas)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${e.areas}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${e.areas}')\` before calling renderGeoToStaticSVG.`);y.setAreas(e.areas)}if(e.points&&y.setPoints(e.points),e.lines&&y.setLines(e.lines),y.computeScene({width:d,height:g}),0===y.scene.length)return ui.renderToStaticMarkup(fi(null,{width:h[0],height:h[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:u,innerTransform:`translate(${null!==(s=f.left)&&void 0!==s?s:0},${null!==(a=f.top)&&void 0!==a?a:0})`,idPrefix:e._idPrefix}));const p=y.scene.map((e,i)=>function(e,i){var r,o,n,s,a,c;switch(e.type){case"geoarea":{const n=e;return n.pathData?t.createElement("path",{key:"geoarea-"+i,d:n.pathData,fill:Ue(n.style.fill,"#e0e0e0"),fillOpacity:null!==(r=n.style.fillOpacity)&&void 0!==r?r:1,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth||.5,strokeDasharray:n.style.strokeDasharray,opacity:null!==(o=n._decayOpacity)&&void 0!==o?o:1}):null}case"point":{const r=e;return t.createElement("circle",{key:"point-"+i,cx:r.x,cy:r.y,r:r.r,fill:Ue(r.style.fill),fillOpacity:null!==(n=r.style.fillOpacity)&&void 0!==n?n:.8,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:null!==(s=r._decayOpacity)&&void 0!==s?s:null!==(a=r.style.opacity)&&void 0!==a?a:1})}case"line":{const r=e;if(2>r.path.length)return null;const o="M"+r.path.map(t=>`${t[0]},${t[1]}`).join("L");return t.createElement("path",{key:"line-"+i,d:o,fill:"none",stroke:r.style.stroke||"#4e79a7",strokeWidth:r.style.strokeWidth||1.5,strokeDasharray:r.style.strokeDasharray,opacity:null!==(c=r.style.opacity)&&void 0!==c?c:1})}default:return null}}(e,i)).filter(Boolean),m=t.createElement(t.Fragment,null,p);return ui.renderToStaticMarkup(fi(m,{width:h[0],height:h[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:u,innerTransform:`translate(${null!==(c=f.left)&&void 0!==c?c:0},${null!==(l=f.top)&&void 0!==l?l:0})`,idPrefix:e._idPrefix}))}function vi(t,e){switch(t){case"xy":return di(e);case"ordinal":return mi(e);case"network":return pi(e);case"geo":return xi(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", or "geo".`)}}function bi(t){return di(t)}function ki(t){return mi(t)}function wi(t){return pi(t)}function Ai(t){return xi(t)}function Si(e,i,r){var o,n,s,a,c,l,u,h;const{data:f,width:d=600,height:g=400,theme:y,title:p,description:m,showLegend:x,showGrid:v,background:b,className:k,annotations:w,margin:A,colorScheme:S,colorBy:_,legendPosition:P}=i,E=function(t,e){var i={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&0>e.indexOf(r)&&(i[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);r.length>o;o++)0>e.indexOf(r[o])&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(i[r[o]]=t[r[o]])}return i}(i,["data","width","height","theme","title","description","showLegend","showGrid","background","className","annotations","margin","colorScheme","colorBy","legendPosition"]),M=[d,g],O=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},E.frameProps||{}),{theme:y,title:p,description:m,showLegend:x,showGrid:v,background:b,className:k,annotations:w,size:M}),void 0!==A&&{margin:A}),void 0!==S&&{colorScheme:S}),void 0!==P&&{legendPosition:P}),{_idPrefix:E._idPrefix});switch(e){case"Sparkline":return di(Object.assign(Object.assign({chartType:"line",data:f,xAccessor:E.xAccessor||"x",yAccessor:E.yAccessor||"y",groupAccessor:E.lineBy||_,colorAccessor:_},O),{showAxes:!1,margin:O.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0}));case"LineChart":return di(Object.assign({chartType:"line",data:f,xAccessor:E.xAccessor||"x",yAccessor:E.yAccessor||"y",groupAccessor:E.lineBy||_,lineDataAccessor:E.lineDataAccessor,colorAccessor:_},O));case"AreaChart":return di(Object.assign({chartType:"area",data:f,xAccessor:E.xAccessor||"x",yAccessor:E.yAccessor||"y",groupAccessor:E.areaBy||_,colorAccessor:_},O));case"StackedAreaChart":return di(Object.assign({chartType:"stackedarea",data:f,xAccessor:E.xAccessor||"x",yAccessor:E.yAccessor||"y",groupAccessor:E.areaBy,colorAccessor:_||E.areaBy,normalize:E.normalize},O));case"Scatterplot":case"BubbleChart":return di(Object.assign({chartType:"scatter",data:f,xAccessor:E.xAccessor||"x",yAccessor:E.yAccessor||"y",colorAccessor:_,sizeAccessor:E.sizeBy,sizeRange:E.sizeRange||("BubbleChart"===e?[5,40]:void 0)},O));case"ConnectedScatterplot":return di(Object.assign({chartType:"scatter",data:f,xAccessor:E.xAccessor||"x",yAccessor:E.yAccessor||"y",colorAccessor:_},O));case"Heatmap":return di(Object.assign({chartType:"heatmap",data:f,xAccessor:E.xAccessor||"x",yAccessor:E.yAccessor||"y",valueAccessor:E.valueAccessor||"value",colorScheme:S||"blues"},O));case"BarChart":return mi(Object.assign({chartType:"bar",data:f,oAccessor:E.categoryAccessor||"category",rAccessor:E.valueAccessor||"value",projection:"horizontal"===E.orientation?"horizontal":"vertical",colorAccessor:_,barPadding:E.barPadding},O));case"StackedBarChart":return mi(Object.assign({chartType:"bar",data:f,oAccessor:E.categoryAccessor||"category",rAccessor:E.valueAccessor||"value",stackBy:E.stackBy,projection:"horizontal"===E.orientation?"horizontal":"vertical",colorAccessor:_||E.stackBy,normalize:E.normalize,barPadding:E.barPadding},O));case"GroupedBarChart":return mi(Object.assign({chartType:"clusterbar",data:f,oAccessor:E.categoryAccessor||"category",rAccessor:E.valueAccessor||"value",groupBy:E.groupBy,projection:"horizontal"===E.orientation?"horizontal":"vertical",colorAccessor:_||E.groupBy,barPadding:E.barPadding},O));case"PieChart":return mi(Object.assign({chartType:"pie",data:f,oAccessor:E.categoryAccessor||"category",rAccessor:E.valueAccessor||"value",projection:"radial",colorAccessor:_||E.categoryAccessor||"category"},O));case"DonutChart":return mi(Object.assign({chartType:"donut",data:f,oAccessor:E.categoryAccessor||"category",rAccessor:E.valueAccessor||"value",projection:"radial",innerRadius:E.innerRadius||60,colorAccessor:_||E.categoryAccessor||"category"},O));case"Histogram":return mi(Object.assign({chartType:"histogram",data:f,oAccessor:E.categoryAccessor||"category",rAccessor:E.valueAccessor||"value",bins:E.bins||25,projection:"horizontal"},O));case"BoxPlot":return mi(Object.assign({chartType:"boxplot",data:f,oAccessor:E.categoryAccessor||"category",rAccessor:E.valueAccessor||"value",colorAccessor:_},O));case"ViolinPlot":return mi(Object.assign({chartType:"violin",data:f,oAccessor:E.categoryAccessor||"category",rAccessor:E.valueAccessor||"value",colorAccessor:_,bins:E.bins},O));case"SwarmPlot":return mi(Object.assign({chartType:"swarm",data:f,oAccessor:E.categoryAccessor||"category",rAccessor:E.valueAccessor||"value",colorAccessor:_},O));case"DotPlot":return mi(Object.assign(Object.assign({chartType:"point",data:f,oAccessor:E.categoryAccessor||"category",rAccessor:E.valueAccessor||"value",colorAccessor:_},O),{showGrid:null==v||v}));case"SwimlaneChart":return mi(Object.assign({chartType:"swimlane",data:f,oAccessor:E.categoryAccessor||"category",rAccessor:E.valueAccessor||"value",stackBy:E.subcategoryAccessor,projection:"vertical"===E.orientation?"vertical":"horizontal",colorAccessor:_||E.subcategoryAccessor,barPadding:E.barPadding},O));case"FunnelChart":{const t="vertical"===E.orientation;return mi(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:t?"bar-funnel":"funnel",data:f,oAccessor:E.stepAccessor||"step",rAccessor:E.valueAccessor||"value"},E.categoryAccessor&&{stackBy:E.categoryAccessor}),{projection:t?"vertical":"horizontal",colorAccessor:_||E.categoryAccessor,barPadding:t?null!==(o=E.barPadding)&&void 0!==o?o:40:null!==(n=E.barPadding)&&void 0!==n?n:0}),!t&&{connectorAccessor:()=>!0,connectorStyle:{opacity:null!==(s=E.connectorOpacity)&&void 0!==s?s:.3}}),{showAxes:t,showCategoryTicks:t,showGrid:t,showLabels:E.showLabels}),O))}case"RidgelinePlot":return mi(Object.assign({chartType:"ridgeline",data:f,oAccessor:E.categoryAccessor||"category",rAccessor:E.valueAccessor||"value",bins:E.bins,amplitude:E.amplitude},O));case"GaugeChart":{const e=null!==(a=E.min)&&void 0!==a?a:0,i=null!==(c=E.max)&&void 0!==c?c:100,r=null!==(l=E.sweep)&&void 0!==l?l:240,o=null!==(u=E.arcWidth)&&void 0!==u?u:.3,n=180+(360-r)/2,s=E.thresholds||[{value:i,color:"#4e79a7"}],f=s.map((t,i)=>({category:t.label||"zone-"+i,value:t.value-(i>0?s[i-1].value:e)})),p={};s.forEach((t,e)=>{p[t.label||"zone-"+e]=t.color||"#4e79a7"});const m=O.margin||{top:20,right:20,bottom:30,left:40},x=(d||300)-m.left-m.right,v=(g||300)-m.top-m.bottom,b=Math.min(x,v),k=Math.max(10,b/2*(1-o)),w=Math.max(e,Math.min(i,null!==(h=E.value)&&void 0!==h?h:e)),A=(n+(i===e?0:(w-e)/(i-e))*r-90)*Math.PI/180,S=b/2*.85,_=m.left+x/2,P=m.top+v/2,M=oi(y).colors.text,L=mi(Object.assign(Object.assign({chartType:"donut",data:f,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:k,sweepAngle:r,startAngle:n,oSort:!1,pieceStyle:(t,e)=>({fill:p[e||""]||"#4e79a7"})},O),{showAxes:!1})),D=ui.renderToStaticMarkup(t.createElement(t.Fragment,null,t.createElement("line",{x1:_,y1:P,x2:_+S*Math.cos(A),y2:P+S*Math.sin(A),stroke:M,strokeWidth:2.5,strokeLinecap:"round"}),t.createElement("circle",{cx:_,cy:P,r:4,fill:M})));return L.replace("</svg>",D+"</svg>")}case"ForceDirectedGraph":return pi(Object.assign({chartType:"force",nodes:E.nodes,edges:E.edges,nodeIDAccessor:E.nodeIDAccessor,sourceAccessor:E.sourceAccessor,targetAccessor:E.targetAccessor,colorBy:_,colorScheme:S,iterations:E.iterations,forceStrength:E.forceStrength,showLabels:E.showLabels,nodeLabel:E.nodeLabel,nodeSize:E.nodeSize,nodeSizeRange:E.nodeSizeRange,nodeStyle:E.nodeStyle,edgeStyle:E.edgeStyle},O));case"SankeyDiagram":return pi(Object.assign({chartType:"sankey",nodes:E.nodes,edges:E.edges,nodeIDAccessor:E.nodeIdAccessor||E.nodeIDAccessor,sourceAccessor:E.sourceAccessor,targetAccessor:E.targetAccessor,valueAccessor:E.valueAccessor,orientation:E.orientation,nodeAlign:E.nodeAlign,nodeWidth:E.nodeWidth,nodePaddingRatio:E.nodePaddingRatio,showLabels:E.showLabels,nodeLabel:E.nodeLabel,colorBy:_,edgeColorBy:E.edgeColorBy,edgeOpacity:E.edgeOpacity,nodeStyle:E.nodeStyle,edgeStyle:E.edgeStyle,colorScheme:S},O));case"ChordDiagram":return pi(Object.assign({chartType:"chord",nodes:E.nodes,edges:E.edges,valueAccessor:E.valueAccessor,padAngle:E.padAngle,groupWidth:E.groupWidth,showLabels:E.showLabels,colorBy:_,edgeColorBy:E.edgeColorBy,colorScheme:S},O));case"TreeDiagram":return pi(Object.assign({chartType:"cluster"===E.layout?"cluster":"tree",data:f,childrenAccessor:E.childrenAccessor,colorBy:_,colorByDepth:E.colorByDepth,orientation:E.orientation,showLabels:E.showLabels,colorScheme:S},O));case"Treemap":return pi(Object.assign({chartType:"treemap",data:f,childrenAccessor:E.childrenAccessor,hierarchySum:E.valueAccessor,colorBy:_,colorByDepth:E.colorByDepth,showLabels:E.showLabels,colorScheme:S},O));case"CirclePack":return pi(Object.assign({chartType:"circlepack",data:f,childrenAccessor:E.childrenAccessor,hierarchySum:E.valueAccessor,colorBy:_,colorByDepth:E.colorByDepth,colorScheme:S},O));case"ChoroplethMap":return xi(Object.assign({areas:E.areas,projection:E.projection||"equalEarth",areaStyle:E.areaStyle,graticule:E.graticule,fitPadding:E.fitPadding},O));case"ProportionalSymbolMap":return xi(Object.assign({points:E.points,areas:E.areas,xAccessor:E.xAccessor||"lon",yAccessor:E.yAccessor||"lat",pointStyle:E.pointStyle,projection:E.projection||"equalEarth",graticule:E.graticule,fitPadding:E.fitPadding},O));default:throw Error(`Unknown chart component: "${e}". See CLAUDE.md for supported chart types.`)}}function _i(t,e){return J(this,arguments,void 0,function*(t,e,i={}){var r,o;const{format:n="png",scale:s=1,background:a}=i;let c,l;c=["xy","ordinal","network","geo"].includes(t)?vi(t,e):Si(t,e),a&&(c=c.replace(/<svg /,`<svg style="background:${a}" `));try{l=require("sharp")}catch(t){throw Error('Image export requires the "sharp" package and a Node.js runtime. Install it:\n npm install sharp\nsharp is listed as an optional dependency of semiotic.')}const u=e.width||(null===(r=e.size)||void 0===r?void 0:r[0])||600,h=e.height||(null===(o=e.size)||void 0===o?void 0:o[1])||400,f=l(void 0!==globalThis.Buffer?globalThis.Buffer.from(c):(new TextEncoder).encode(c),{density:72*s}).resize(Math.round(u*s),Math.round(h*s));return"jpeg"===n?f.jpeg({quality:90}).toBuffer():f.png().toBuffer()})}function Pi(e,i={}){var r;const{title:o,subtitle:n,theme:s,width:a=1200,height:c,layout:l={},background:u}=i,h=ni(oi(s)),f=l.columns||2,d=null!==(r=l.gap)&&void 0!==r?r:16;let g=0;o&&(g+=30),n&&(g+=20),g>0&&(g+=10);const y=Math.floor((a-d-d*(f-1))/f),p=[];let m=0,x=g+d,v=0;for(const t of e){const e=Math.min(t.colSpan||1,f),i=t.props.height||300;m+e>f&&(x+=v+d,m=0,v=0),p.push({chart:t,x:d/2+m*(y+d),y:x,w:y*e+d*(e-1),h:i}),v=Math.max(v,i),m+=e}const b=c||x+v+d,k=p.map((e,i)=>{const{chart:r,x:o,y:n,w:a,h:c}=e,l=Object.assign(Object.assign({},r.props),{width:a,height:c,theme:s,_idPrefix:"chart-"+i});let u;return u=r.component?Si(r.component,l):r.frameType?vi(r.frameType,l):`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${c}"></svg>`,t.createElement("g",{key:"dashboard-chart-"+i,transform:`translate(${o},${n})`},t.createElement("foreignObject",{width:a,height:c},t.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:u}})))}),w=t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:a,height:b,role:"img","aria-label":o||"Dashboard",style:{fontFamily:h.fontFamily}},o&&t.createElement("title",null,o),u&&t.createElement("rect",{x:0,y:0,width:a,height:b,fill:u}),o&&t.createElement("text",{x:a/2,y:24,textAnchor:"middle",fontSize:h.titleSize+4,fontWeight:"bold",fill:h.text,fontFamily:h.fontFamily},o),n&&t.createElement("text",{x:a/2,y:o?46:20,textAnchor:"middle",fontSize:h.labelSize,fill:h.textSecondary,fontFamily:h.fontFamily},n),k);return ui.renderToStaticMarkup(w)}const Ei=require("react-dom/server");function Mi(t,e,i,r={}){const{stepSize:o,windowSize:n,frameCount:s,xExtent:a,yExtent:c,transitionFrames:l=4,fps:u=12,easing:h="ease-out",decay:f}=r,d=i.width||600,g=i.height||400,y=oi(i.theme),p=Object.assign(Object.assign(Object.assign({},i),a&&{xExtent:a}),c&&{yExtent:c});if(!e||0===e.length)return[];const m=o||Math.max(1,Math.ceil(e.length/(s||Math.min(60,Math.max(10,e.length))))),x=[];for(let t=m;e.length>=t;t+=m)x.push(t);x[x.length-1]!==e.length&&x.push(e.length);const v=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(t),b=Object.assign({top:20,right:20,bottom:30,left:40},i.margin),k=d-b.left-b.right,w=g-b.top-b.bottom,A=[];if(v)for(let r=0;x.length>r;r++){const o=x[r],s=e.slice(n?Math.max(0,o-n):0,o),a=Object.assign({chartType:t,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:i.projection||"vertical",oAccessor:i.oAccessor||i.categoryAccessor||"category",rAccessor:i.rAccessor||i.valueAccessor||"value",colorAccessor:i.colorAccessor||i.colorBy,stackBy:i.stackBy,groupBy:i.groupBy,barPadding:i.barPadding,innerRadius:i.innerRadius,normalize:i.normalize,bins:i.bins,colorScheme:i.colorScheme||y.colors.categorical},f&&{decay:f}),c=new We(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:k,height:w}),c.scene.length>0&&A.push(zi(c.scene,d,g,y,p))}else for(let r=0;x.length>r;r++){const o=x[r],s=e.slice(n?Math.max(0,o-n):0,o),m=Object.assign(Object.assign({chartType:t,windowSize:s.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:i.colorAccessor||i.colorBy,groupAccessor:i.groupAccessor||i.lineBy,lineDataAccessor:i.lineDataAccessor,xExtent:a,yExtent:c,colorScheme:i.colorScheme||y.colors.categorical,lineStyle:i.lineStyle,pointStyle:i.pointStyle,areaStyle:i.areaStyle,sizeAccessor:i.sizeAccessor||i.sizeBy,sizeRange:i.sizeRange},f&&{decay:f}),l>0&&{transition:{duration:l*(1e3/u),easing:h}}),v=new St(m);if(v.ingest({inserts:s,bounded:!0}),v.computeScene({width:k,height:w}),0===v.scene.length)continue;const b=v.scales?{y:v.scales.y}:void 0;if(A.push(Di(v.scene,d,g,y,p,b)),l>0&&r>0&&v.activeTransition){const t=l*(1e3/u);for(let e=1;l>=e;e++)v.advanceTransition(v.activeTransition.startTime+e/l*t),A.push(Di(v.scene,d,g,y,p,b))}}return A}function Oi(t,e,i={}){return e.map(e=>{try{return Si(t,Object.assign(Object.assign({},i),e))}catch(t){return`<svg xmlns="http://www.w3.org/2000/svg" width="${i.width||e.width||600}" height="${i.height||e.height||400}"></svg>`}})}function Li(t,e){const i=t.background||e.colors.background;return i&&"transparent"!==i?i:null}function Di(e,i,r,o,n,s){const a=ni(o),c=Object.assign({top:20,right:20,bottom:30,left:40},n.margin),l=i-c.left-c.right,u=r-c.top-c.bottom,h=Li(n,o),f=e.map((t,e)=>Qe(t,e)).filter(Boolean),d=function(e,i,r,o,n,s){var a;if(!e||0===e.length)return null;const c=ni(o),l=[];for(let o=0;e.length>o;o++){const u=e[o];if("y-threshold"===u.type&&null!=u.value){let e=null;if(s)e=s(u.value);else if(n){const[t,i]=n,o=i-t;if(0===o)continue;e=r-(u.value-t)/o*r}if(null==e)continue;const h=u.color||c.primary,f=null!==(a=u.strokeWidth)&&void 0!==a?a:1.5,d=u.labelPosition||"right";l.push(t.createElement("g",{key:"ann-"+o},t.createElement("line",{x1:0,y1:e,x2:i,y2:e,stroke:h,strokeWidth:f,strokeDasharray:u.strokeDasharray||"6,4"}),u.label&&t.createElement("text",{x:"left"===d?4:"center"===d?i/2:i-4,y:e-5,textAnchor:"left"===d?"start":"center"===d?"middle":"end",fontSize:c.tickSize,fill:h,fontFamily:c.fontFamily},u.label)))}}return l.length>0?t.createElement(t.Fragment,null,l):null}(n.annotations,l,u,o,n.yExtent,null==s?void 0:s.y),g="string"==typeof n.title?n.title:void 0,y="string"==typeof n.description?n.description:void 0,p=g?"semiotic-title":void 0,m=y?"semiotic-desc":void 0,x=[p,m].filter(Boolean).join(" ")||void 0,v=t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:i,height:r,role:"img","aria-labelledby":x,style:{fontFamily:a.fontFamily}},g&&t.createElement("title",{id:p},g),y&&t.createElement("desc",{id:m},y),h&&t.createElement("rect",{x:0,y:0,width:i,height:r,fill:h}),t.createElement("g",{transform:`translate(${c.left},${c.top})`},d,f),g&&t.createElement("text",{x:i/2,y:16,textAnchor:"middle",fontSize:a.titleSize,fontWeight:"bold",fill:a.text,fontFamily:a.fontFamily},g));return Ei.renderToStaticMarkup(v)}function zi(e,i,r,o,n){const s=ni(o),a=Object.assign({top:20,right:20,bottom:30,left:40},n.margin),c="radial"===n.projection,l=c?a.left+(i-a.left-a.right)/2:a.left,u=c?a.top+(r-a.top-a.bottom)/2:a.top,h=Li(n,o),f=e.map((t,e)=>Je(t,e)).filter(Boolean),d="string"==typeof n.title?n.title:void 0,g="string"==typeof n.description?n.description:void 0,y=d?"semiotic-title":void 0,p=g?"semiotic-desc":void 0,m=[y,p].filter(Boolean).join(" ")||void 0,x=t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:i,height:r,role:"img","aria-labelledby":m,style:{fontFamily:s.fontFamily}},d&&t.createElement("title",{id:y},d),g&&t.createElement("desc",{id:p},g),h&&t.createElement("rect",{x:0,y:0,width:i,height:r,fill:h}),t.createElement("g",{transform:`translate(${l},${u})`},f),d&&t.createElement("text",{x:i/2,y:16,textAnchor:"middle",fontSize:s.titleSize,fontWeight:"bold",fill:s.text,fontFamily:s.fontFamily},d));return Ei.renderToStaticMarkup(x)}function ji(t,e,i){return J(this,arguments,void 0,function*(t,e,i,r={}){const{fps:o=12,loop:n=!0,scale:s=1,background:a}=r,c=i.height||400,l=Math.round((i.width||600)*s),u=Math.round(c*s),h=Mi(t,e,a?Object.assign(Object.assign({},i),{background:a}):i,r);if(0===h.length)throw Error("No frames generated — check that data is not empty");let f,d,g,y;try{f=require("sharp")}catch(t){throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t=require("gifenc");d=t.GIFEncoder,g=t.quantize,y=t.applyPalette}catch(t){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc')}const p=Math.round(1e3/o),m=d();for(let t=0;h.length>t;t++){const e=h[t],i=yield f(Buffer.from(e),{density:72*s}).resize(l,u).ensureAlpha().raw().toBuffer(),r=new Uint8Array(i),o=g(r,256),a=y(r,o);m.writeFrame(a,l,u,{palette:o,delay:p,repeat:n?0:-1})}return m.finish(),Buffer.from(m.bytes())})}export{Mi as generateFrameSVGs,Oi as generateFrameSequence,Si as renderChart,Pi as renderDashboard,Ai as renderGeoToStaticSVG,wi as renderNetworkToStaticSVG,ki as renderOrdinalToStaticSVG,ji as renderToAnimatedGif,_i as renderToImage,vi as renderToStaticSVG,bi as renderXYToStaticSVG,oi as resolveTheme,ni as themeStyles};
|
|
1
|
+
import*as t from"react";import{createContext as e,useMemo as i,useContext as o,useRef as r,useCallback as n,useSyncExternalStore as s}from"react";import{scaleLinear as a,scaleLog as c,scaleTime as l,scaleBand as u,scaleOrdinal as h}from"d3-scale";import{quadtree as f}from"d3-quadtree";import{interpolateViridis as d,interpolateGreens as g,interpolateReds as y,interpolateBlues as p,schemeCategory10 as m}from"d3-scale-chromatic";import{min as x,groups as v,max as b,sum as k,mean as A,group as w,quantile as S}from"d3-array";import{interpolateNumber as _}from"d3-interpolate";import{forceLink as P,forceSimulation as E,forceManyBody as M,forceCenter as O,forceX as T,forceY as L}from"d3-force";import{ribbon as $,chord as z}from"d3-chord";import{arc as D,pie as j}from"d3-shape";import{hierarchy as N,partition as B,pack as R,treemap as W,treemapBinary as F,cluster as C,tree as I}from"d3-hierarchy";import{geoPath as Y,geoGraticule as X,geoDistance as q,geoInterpolate as G,geoEqualEarth as V,geoEquirectangular as H,geoNaturalEarth1 as Z,geoOrthographic as K,geoAlbersUsa as U,geoMercator as Q}from"d3-geo";function J(t,e,i,o){return new(i||(i=Promise))(function(r,n){function s(t){try{c(o.next(t))}catch(t){n(t)}}function a(t){try{c(o.throw(t))}catch(t){n(t)}}function c(t){t.done?r(t.value):function(t){return t instanceof i?t:new i(function(e){e(t)})}(t.value).then(s,a)}c((o=o.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class tt{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 i of t){const t=this.push(i);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 i=0;this._size>i;i++)t(this.buffer[(e+i)%this._capacity],i)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)t[i]=this.buffer[(e+i)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),i=[];for(;e.length>t;)i.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 i}update(t,e){const i=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++){const n=(o+r)%this._capacity,s=this.buffer[n];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:Object.assign({},s),i.push(t),this.buffer[n]=e(s)}}return i}remove(t){const e=[],i=[];if(this.forEach(o=>{t(o)?i.push(o):e.push(o)}),0===i.length)return i;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return i}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 et{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 i of t){const t=e?e(i):i;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 it(t,e,i,o,r){const n=new Map;for(const s of t){const t=e(s),a=i(s);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const c=Math.floor(t/o)*o;let l=n.get(c);if(l||(l={start:c,end:c+o,total:0,categories:new Map},n.set(c,l)),l.total+=a,r){const t=r(s);l.categories.set(t,(l.categories.get(t)||0)+a)}}return n}function ot(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function rt(t,e){if("function"==typeof t)return e=>+t(e);const i=t||e;return t=>+t[i]}function nt(t,e){if("function"==typeof t)return t;const i=t||e;return t=>t[i]}function st(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}const at=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function ct(t,e,i){var o,r,n;if(1>=i)return 1;const s=null!==(o=t.minOpacity)&&void 0!==o?o:.1,a=i-1-e;switch(t.type){case"linear":return s+(1-a/(i-1))*(1-s);case"exponential":{const e=null!==(r=t.halfLife)&&void 0!==r?r:i/2;return s+Math.pow(.5,a/e)*(1-s)}case"step":return(null!==(n=t.stepThreshold)&&void 0!==n?n:.5*i)>a?1:s;default:return 1}}function lt(t,e,i){var o;const r=null!==(o=t.duration)&&void 0!==o?o:500,n=i-e;return r>n?1-n/r:0}function ut(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function ht(t,e){return Math.min((t-e.startTime)/e.duration,1)}function ft(t,e,i){return t+(e-t)*i}function dt(){return"undefined"!=typeof performance?performance.now():Date.now()}function gt(t,e,i){var o,r,n,s;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const i=t.getX(e.datum),o=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${i}:${o}`;if(null!=i&&null!=o)return`p:${i}:${o}`}return"p:"+i;case"rect":return`r:${e.group||""}:${null!==(s=null!==(r=null===(o=e.datum)||void 0===o?void 0:o.binStart)&&void 0!==r?r:null===(n=e.datum)||void 0===n?void 0:n.category)&&void 0!==s?s:i}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+i:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function yt(t,e,i,o,r,n){const s=[];for(const r of t){const t=i(r),n=o(r);null==t||null==n||Number.isNaN(t)||Number.isNaN(n)||s.push({px:e.x(t),py:e.y(n),rawY:n,d:r})}s.sort((t,e)=>t.px-e.px);const a=Array(s.length),c=Array(s.length),l=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];a[t]=[e.px,e.py],c[t]=e.rawY,l[t]=e.d}return{type:"line",path:a,rawValues:c,style:r,datum:l,group:n}}function pt(t,e,i,o,r,n,s,a){const c=[];for(const n of t){const t=i(n),s=o(n);if(null==t||null==s||Number.isNaN(t)||Number.isNaN(s))continue;const l=e.x(t),u=a?a(n):r;c.push({px:l,topY:e.y(s),botY:e.y(u)})}c.sort((t,e)=>t.px-e.px);const l=Array(c.length),u=Array(c.length);for(let t=0;c.length>t;t++){const e=c[t];l[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:l,bottomPath:u,style:n,datum:t,group:s}}function mt(t,e,i,o,r,n,s){const a=i(t),c=o(t);if(null==a||null==c||Number.isNaN(a)||Number.isNaN(c))return null;const l={type:"point",x:e.x(a),y:e.y(c),r:r,style:n,datum:t};return void 0!==s&&(l.pointId=s),l}function xt(t,e,i,o,r,n,s){return{type:"rect",x:t,y:e,w:i,h:o,style:r,datum:n,group:s}}function vt(t,e,i,o,r,n,s){const a={type:"heatcell",x:t,y:e,w:i,h:o,fill:r,datum:n};return(null==s?void 0:s.showValues)&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function bt(t,e,i){if(!t.getBounds||!t.scales)return null;const o=[],r=[];for(const i of e){const e=t.getX(i),n=t.getY(i);if(null==e||null==n||Number.isNaN(e)||Number.isNaN(n))continue;const s=t.getBounds(i),a=t.scales.x(e);if(s&&0!==s)o.push([a,t.scales.y(n+s)]),r.push([a,t.scales.y(n-s)]);else{const e=t.scales.y(n);o.push([a,e]),r.push([a,e])}}return 2>o.length?null:{type:"area",topPath:o,bottomPath:r,style:t.resolveBoundsStyle(i,e[0]),datum:e,group:i,interactive:!1}}function kt(t,e,i,o){var r;if(!t.config.pointStyle)return;const n=null!=o?o:t.getY;for(const o of e){const e=t.resolveGroupColor(o.key);for(const s of o.data){let o=t.config.pointStyle(s);!o.fill&&e&&(o=Object.assign(Object.assign({},o),{fill:e}));const a=null!==(r=o.r)&&void 0!==r?r:3,c=t.getPointId?t.getPointId(s)+"":void 0,l=mt(s,t.scales,t.getX,n,a,o,c);l&&i.push(l)}}}const At={blues:p,reds:y,greens:g,viridis:d},wt=new Map;class St{constructor(t){if(this.xExtent=new et,this.yExtent=new et,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 tt(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=rt(t.timeAccessor||t.xAccessor,"time"),this.getY=rt(t.valueAccessor||t.yAccessor,"value")):(this.getX=rt(t.xAccessor,"x"),this.getY=rt(t.yAccessor,"y")),this.getGroup=st(t.groupAccessor),this.getCategory=st(t.categoryAccessor),this.getSize=t.sizeAccessor?rt(t.sizeAccessor,"size"):void 0,this.getColor=st(t.colorAccessor),this.getBounds=t.boundsAccessor?rt(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?rt(t.y0Accessor,"y0"):void 0,this.getPointId=st(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,i=null!=t.closeAccessor;this.getOpen=e?rt(t.openAccessor,"open"):void 0,this.getHigh=rt(t.highAccessor,"high"),this.getLow=rt(t.lowAccessor,"low"),this.getClose=i?rt(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!i}t.pulse&&(this.timestampBuffer=new tt(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?rt(this.config.timeAccessor||this.config.xAccessor,"time"):rt(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],i=this.config.xAccessor,o="function"==typeof i?i(e):e[i||"x"],r=o instanceof Date,n="string"==typeof o&&o.length>=10&&!isNaN(new Date(o).getTime())&&isNaN(Number(o));if(this.xIsDate=r||n,n){const t="string"==typeof i?i:void 0;this.getX=t?e=>+new Date(e[t]):t=>+(i(t)instanceof Date?i(t):new Date(i(t)))}}const i=t.totalSize||t.inserts.length;i>this.buffer.capacity&&(this.buffer.resize(i),this.timestampBuffer&&i>this.timestampBuffer.capacity&&this.timestampBuffer.resize(i));for(const i of t.inserts)this.buffer.push(i),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(i)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(i)),this.yExtent.push(this.getLow(i))):(this.yExtent.push(this.getY(i)),this.getY0&&this.yExtent.push(this.getY0(i)))}else for(const i 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(i);this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(i)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(i)),this.yExtent.push(this.getLow(i))):(this.yExtent.push(this.getY(i)),this.getY0&&this.yExtent.push(this.getY0(i))),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,i,o,r,n,s,u;const{config:h,buffer:f}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(e=this.config.scalePadding)&&void 0!==e?e:0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);if(this.xExtent.dirty&&this.xExtent.recalculate(f,this.getX),this.yExtent.dirty)if("candlestick"===h.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of f)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(f,this.getY);const d=this.getBufferArray(),g=this.xExtent.extent,y=this.yExtent.extent;let p=h.xExtent?[null!==(i=h.xExtent[0])&&void 0!==i?i:g[0],null!==(o=h.xExtent[1])&&void 0!==o?o:g[1]]:g,m=h.yExtent?[null!==(r=h.yExtent[0])&&void 0!==r?r:y[0],null!==(n=h.yExtent[1])&&void 0!==n?n:y[1]]:y;const x=h.yExtent&&null!=h.yExtent[0]&&null!=h.yExtent[1];if("stackedarea"===h.chartType&&!x&&f.size>0)if(h.normalize)m=[0,1+h.extentPadding];else{const t=`${f.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)m=this._stackExtentCache.yDomain;else{const e=this.groupData(d),i=new Map;for(const t of e)for(const e of t.data){const t=this.getX(e),o=this.getY(e);null==t||null==o||Number.isNaN(t)||Number.isNaN(o)||i.set(t,(i.get(t)||0)+o)}let o=0;for(const t of i.values())t>o&&(o=t);m=[0,o+(o>0?o*h.extentPadding:1)],this._stackExtentCache={key:t,yDomain:m}}}else if("bar"===h.chartType&&h.binSize&&!x&&f.size>0){const[,t]=function(t,e,i,o,r){const n=it(t,e,i,o,r);if(0===n.size)return[0,0];let s=0;for(const t of n.values())t.total>s&&(s=t.total);return[0,s]}(f,this.getX,this.getY,h.binSize,this.getCategory);m=[0,t+t*h.extentPadding]}else if("waterfall"===h.chartType&&!x&&f.size>0){const[t,e]=function(t,e){let i=0,o=0,r=0;for(const n of t){const t=e(n);null==t||Number.isNaN(t)||(r+=t,i>r&&(i=r),r>o&&(o=r))}return[i,o]}(f,this.getY),i=e-t,o=i>0?i*h.extentPadding:1;m=[Math.min(0,t-Math.abs(o)),Math.max(0,e+Math.abs(o))]}else if(!x&&m[0]!==1/0){if(this.getBounds)for(const t of d){const e=this.getY(t),i=this.getBounds(t);null!=e&&!Number.isNaN(e)&&i&&(e+i>m[1]&&(m[1]=e+i),m[0]>e-i&&(m[0]=e-i))}const t=m[1]-m[0],e=t>0?t*h.extentPadding:1,i=null===(s=h.yExtent)||void 0===s?void 0:s[0],o=null===(u=h.yExtent)||void 0===u?void 0:u[1];m=[null!=i?m[0]:m[0]-e,null!=o?m[1]:m[1]+e],"log"===h.yScaleType&&0>=m[0]&&y[0]>0&&(m[0]=null!=i?m[0]:y[0]/(1+h.extentPadding))}if(p[0]===1/0||p[1]===-1/0)if("time"===h.xScaleType){const t=Date.now();p=[t-864e5,t]}else p=[0,1];m[0]!==1/0&&m[1]!==-1/0||(m=[0,1]);const v="streaming"===h.runtimeMode,b=Math.max(0,Math.min(h.scalePadding||0,Math.min(t.width,t.height)/2-1));if(v)if("x"==("up"===(k=h.arrowOfTime)||"down"===k?"y":"x")){const e="right"===h.arrowOfTime?[b,t.width-b]:[t.width-b,b];this.scales={x:a().domain(p).range(e),y:a().domain(m).range([t.height-b,b])}}else{const e="down"===h.arrowOfTime?[b,t.height-b]:[t.height-b,b];this.scales={x:a().domain(m).range([b,t.width-b]),y:a().domain(p).range(e)}}else{const e=(t,e,i)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return c().domain(t).range(i).clamp(!0)}return"time"===t?l().domain([new Date(e[0]),new Date(e[1])]).range(i):a().domain(e).range(i)};this.scales={x:e(h.xScaleType,p,[b,t.width-b]),y:e(h.yScaleType,m,[t.height-b,b])}}var k;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,d),this.config.decay&&this.applyDecay(this.scene,d),this.config.pulse&&this.applyPulse(this.scene,d),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}rebuildQuadtree(){const t=this.config.chartType;if("scatter"!==t&&"bubble"!==t)return void(this._quadtree=null);const e=this.scene.filter(t=>"point"===t.type);this._quadtree=e.length>St.QUADTREE_THRESHOLD?f().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,i=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const o of t.path)o[0]*=e,o[1]*=i;break;case"area":for(const o of t.topPath)o[0]*=e,o[1]*=i;for(const o of t.bottomPath)o[0]*=e,o[1]*=i;break;case"point":t.x*=e,t.y*=i;break;case"rect":case"heatcell":t.x*=e,t.y*=i,t.w*=e,t.h*=i;break;case"candlestick":t.x*=e,t.openY*=i,t.closeY*=i,t.highY*=i,t.lowY*=i}const o=this.scales.x.domain(),r=this.scales.y.domain(),n=this.scales.x.range(),s=this.scales.y.range(),u=(t,e,i)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return c().domain(t).range(i).clamp(!0)}return"time"===t?l().domain([new Date(e[0]),new Date(e[1])]).range(i):a().domain(e).range(i)},h=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),f=s[1]>s[0];this.scales={x:u(this.config.xScaleType,o,n[0]>n[1]?[t.width-h,h]:[h,t.width-h]),y:u(this.config.yScaleType,r,f?[h,t.height-h]:[t.height-h,h])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){var i;const{config:o,scales:r}=this;if(!r||0===e.length)return[];const n={scales:r,config:o,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,getBounds:this.getBounds,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(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 i;const o=t.groupData(e),r=[],n=null===(i=t.config.annotations)||void 0===i?void 0:i.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 o){const i=bt(t,e.data,e.key);i&&r.push(i)}for(const e of o){const i=t.resolveLineStyle(e.key,e.data[0]),o=yt(e.data,t.scales,t.getX,t.getY,i,e.key);n&&n.length>0&&(o.colorThresholds=n),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),r.push(o)}return kt(t,o,r),r}(n,e);case"area":return function(t,e){const i=t.groupData(e),o=[],r=t.scales.y.domain()[0],n=t.getY0?e=>{const i=t.getY0(e);return null==i?r:i}:void 0;for(const e of i){const i=t.resolveAreaStyle(e.key,e.data[0]),s=pt(e.data,t.scales,t.getX,t.getY,r,i,e.key,n);t.config.gradientFill&&(s.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),o.push(s)}return kt(t,i,o),o}(n,e);case"mixed":return function(t,e){const i=t.groupData(e),o=[],r=t.config.areaGroups||new Set,n=t.scales.y.domain()[0],s=t.getY0?e=>{const i=t.getY0(e);return null==i?n:i}:void 0;for(const e of i)if(r.has(e.key)){const i=t.resolveAreaStyle(e.key,e.data[0]),r=pt(e.data,t.scales,t.getX,t.getY,n,i,e.key,s);t.config.gradientFill&&(r.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),o.push(r)}else{const i=t.resolveLineStyle(e.key,e.data[0]),r=yt(e.data,t.scales,t.getX,t.getY,i,e.key);t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),o.push(r)}return kt(t,i,o),o}(n,e);case"stackedarea":return function(t,e){const i=t.groupData(e);i.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);const o=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,{nodes:r,stackedTops:n}=function(t,e,i,o,r,n,s){var a;const c=new Set;for(const e of t)for(const t of e.data){const e=i(t);null==e||Number.isNaN(e)||c.add(e)}const l=Array.from(c).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=i(r),n=o(r);null==e||null==n||Number.isNaN(e)||Number.isNaN(n)||t.set(e,(t.get(e)||0)+n)}u.set(e.key,t)}let h;if(n){h=new Map;for(const e of l){let i=0;for(const o of t)i+=(null===(a=u.get(o.key))||void 0===a?void 0:a.get(e))||0;h.set(e,i||1)}}const f=[],d=new Map,g=new Map;for(const t of l)g.set(t,0);for(const i of t){const t=u.get(i.key),o=[],a=[],c=new Map;for(const i of l){let r=t.get(i)||0;const s=g.get(i);n&&(r/=h.get(i));const l=s+r,u=e.x(i);a.push([u,e.y(s)]),o.push([u,e.y(l)]),g.set(i,l),c.set(i,l)}d.set(i.key,c);const y={type:"area",topPath:o,bottomPath:a,style:r(i.key,i.data[0]),datum:i.data,group:i.key};s&&(y.curve=s),f.push(y)}return{nodes:f,stackedTops:d}}(i,t.scales,t.getX,t.getY,(e,i)=>t.resolveAreaStyle(e,i),t.config.normalize,o),s=r;if(t.config.pointStyle){const e=new WeakMap;for(const o of i){const i=n.get(o.key);if(i)for(const r of o.data){const o=t.getX(r),n=t.getY(r);null==o||Number.isNaN(o)||null==n||Number.isNaN(n)||!i.has(o)||e.set(r,i.get(o))}}const o=i=>{var o;return null!==(o=e.get(i))&&void 0!==o?o:t.getY(i)};kt(t,i,s,o)}return s}(n,e);case"scatter":case"bubble":return function(t,e){const i=[],o="bubble"===t.config.chartType?10:5,r=t.config.sizeRange||[3,15];let n=null;if(t.getSize&&!t.config.pointStyle){const i=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(i.length>0){let t=1/0,e=-1/0;for(const o of i)t>o&&(t=o),o>e&&(e=o);n=i=>t===e?(r[0]+r[1])/2:r[0]+(i-t)/(e-t)*(r[1]-r[0])}}const s=t.getColor?t.resolveColorMap(e):null;for(const r of e){let e=t.config.pointStyle?t.config.pointStyle(r):{fill:"#4e79a7",opacity:.8},a=e.r||o;if(n&&t.getSize){const e=t.getSize(r);null==e||Number.isNaN(e)||(a=n(e))}if(s&&t.getColor&&!e.fill){const i=t.getColor(r);i&&s.has(i)&&(e=Object.assign(Object.assign({},e),{fill:s.get(i)}))}const c=t.getPointId?t.getPointId(r)+"":void 0,l=mt(r,t.scales,t.getX,t.getY,a,e,c);l&&i.push(l)}return i}(n,e);case"heatmap":return function(t,e,i){if(t.config.heatmapAggregation)return function(t,e,i){var o,r,n;const s=Math.max(1,Math.floor(null!==(o=t.config.heatmapXBins)&&void 0!==o?o:20)),a=Math.max(1,Math.floor(null!==(r=t.config.heatmapYBins)&&void 0!==r?r:20)),c=null!==(n=t.config.heatmapAggregation)&&void 0!==n?n:"count",l=rt(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[u,h]=t.scales.x.domain(),[f,d]=t.scales.y.domain(),g=(h-u||1)/s,y=(d-f||1)/a,p=s*a;if(p>1e6)return[];const m=new Int32Array(p),x=new Float64Array(p);for(let i=0;e.length>i;i++){const o=e[i],r=t.getX(o),n=t.getY(o);if(!isFinite(r)||!isFinite(n))continue;const c=Math.min(Math.floor((r-u)/g),s-1),h=Math.min(Math.floor((n-f)/y),a-1);if(0>c||0>h)continue;const d=h*s+c;m[d]++;const p=l(o);x[d]+=isFinite(p)?p:0}let v=1/0,b=-1/0;for(let t=0;p>t;t++){if(0===m[t])continue;let e;switch(c){case"sum":e=x[t];break;case"mean":e=x[t]/m[t];break;default:e=m[t]}v>e&&(v=e),e>b&&(b=e)}if(!isFinite(v))return[];const k=b-v||1,A=i.width/s,w=i.height/a,S=t.config.showValues,_=t.config.heatmapValueFormat,P=[];for(let t=0;a>t;t++){const e=t*s;for(let i=0;s>i;i++){const o=e+i;if(0===m[o])continue;let r;switch(c){case"sum":r=x[o];break;case"mean":r=x[o]/m[o];break;default:r=m[o]}const n=(r-v)/k;P.push(vt(i*A,(a-1-t)*w,A,w,`rgb(${220-(180*n+.5)|0},${220-(100*n+.5)|0},${255-(50*n+.5)|0})`,{xi:i,yi:t,value:r,count:m[o],sum:x[o]},S?{value:r,showValues:!0,valueFormat:_}:void 0))}}return P}(t,e,i);if(0===e.length)return[];const o=rt(t.config.valueAccessor,"value"),r=nt(t.config.xAccessor,"x"),n=nt(t.config.yAccessor,"y"),s=new Map,a=new Map,c=Array(e.length),l=Array(e.length);for(let t=0;e.length>t;t++){const i=e[t],o=r(i),u=n(i);c[t]=o,l[t]=u,s.has(o)||s.set(o,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,h=a.size;if(0===u||0===h)return[];const f=Array.from(s.keys()),d=Array.from(a.keys()),g=f.every(t=>"number"==typeof t&&!isNaN(t)),y=d.every(t=>"number"==typeof t&&!isNaN(t));if(g){f.sort((t,e)=>t-e),s.clear();for(let t=0;f.length>t;t++)s.set(f[t],t)}if(y){d.sort((t,e)=>t-e),a.clear();for(let t=0;d.length>t;t++)a.set(d[t],t)}const m=new Float64Array(e.length),x=new Float64Array(e.length),v=Array(e.length),b=new Map;let k=0;for(let t=0;e.length>t;t++){const i=e[t],r=s.get(c[t]),n=a.get(l[t]);if(void 0===r||void 0===n)continue;const h=o(i),f=n*u+r,d=b.get(f);let g;void 0!==d?g=d:(g=k++,b.set(f,g)),m[g]=f,x[g]=h,v[g]=i}let A=1/0,w=-1/0;for(let t=0;k>t;t++){const e=x[t];isFinite(e)&&(A>e&&(A=e),e>w&&(w=e))}if(!isFinite(A)||!isFinite(w))return[];const S=function(t){const e=t in At?t:"blues";let i=wt.get(e);if(i)return i;i=Array(256);const o=At[e]||p;for(let t=0;256>t;t++)i[t]=o(t/255);return wt.set(e,i),i}("string"==typeof t.config.colorScheme?t.config.colorScheme:"blues"),_=255/(w-A||1),P=i.width/u,E=i.height/h,M=t.config.showValues,O=t.config.heatmapValueFormat,T=[];for(let t=0;k>t;t++){const e=x[t];if(!isFinite(e))continue;const i=m[t],o=i%u;T.push(vt(o*P,(h-1-(i-o)/u)*E,P,E,S[Math.min((e-A)*_+.5|0,255)],v[t],M?{value:e,showValues:!0,valueFormat:O}:void 0))}return T}(n,e,t);case"bar":{const t=function(t,e){var i;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const o=it(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===o.size)return{nodes:[],binBoundaries:[]};let r=null;if(t.getCategory){const e=new Set;for(const t of o.values())for(const i of t.categories.keys())e.add(i);const i=t.config.barColors?Object.keys(t.config.barColors):[],n=new Set(i),s=Array.from(e).filter(t=>!n.has(t)).sort(),a=i.filter(t=>e.has(t)),c=a.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===c?r=t.barCategoryCache.order:(r=[...a,...s],t.barCategoryCache={key:c,order:r})}const n=[],s=t.scales,[a,c]=s.x.domain();for(const e of o.values()){const o=Math.max(e.start,a),l=Math.min(e.end,c);if(o>=l)continue;const u=s.x(o),h=s.x(l),f=Math.abs(h-u),d=f>2?1:0,g=Math.min(u,h)+d/2,y=Math.max(f-d,1);if(y>0)if(r&&e.categories.size>0){let o=0;for(const a of r){const r=e.categories.get(a)||0;if(0===r)continue;const c=s.y(o),l=s.y(o+r);n.push(xt(g,Math.min(c,l),y,Math.abs(c-l),{fill:(null===(i=t.config.barColors)||void 0===i?void 0:i[a])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:a,categoryValue:r},a)),o+=r}}else{const t=s.y(0),i=s.y(e.total);n.push(xt(g,Math.min(t,i),y,Math.abs(t-i),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}const l=new Set;for(const t of o.values())l.add(t.start),l.add(t.end);return{nodes:n,binBoundaries:Array.from(l).sort((t,e)=>t-e)}}(n,e);return this._barCategoryCache=null!==(i=n.barCategoryCache)&&void 0!==i?i:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var i,o,r,n;const s=[],a=t.config.swarmStyle||{},c=null!==(i=a.radius)&&void 0!==i?i:3,l=null!==(o=a.fill)&&void 0!==o?o:"#007bff",u=null!==(r=a.opacity)&&void 0!==r?r:.7,h=a.stroke,f=a.strokeWidth;for(const i of e){const e=t.getX(i),o=t.getY(i);if(null==o||Number.isNaN(o))continue;const r=t.scales.x(e),a=t.scales.y(o);let d=l;if(t.getCategory){const e=t.getCategory(i);d=(null===(n=t.config.barColors)||void 0===n?void 0:n[e])||d}const g={type:"point",x:r,y:a,r:c,style:{fill:d,opacity:u,stroke:h,strokeWidth:f},datum:i};t.getPointId&&(g.pointId=t.getPointId(i)+""),s.push(g)}return s}(n,e);case"waterfall":return function(t,e,i){var o,r,n;const s=[],a=t.scales,c=t.config.waterfallStyle,l=e.filter(e=>{const i=t.getY(e),o=t.getX(e);return null!=i&&!Number.isNaN(i)&&null!=o&&isFinite(o)});if(0===l.length)return s;const u=null!==(o=null==c?void 0:c.positiveColor)&&void 0!==o?o:"#28a745",h=null!==(r=null==c?void 0:c.negativeColor)&&void 0!==r?r:"#dc3545",f=null!==(n=null==c?void 0:c.gap)&&void 0!==n?n:1,d=null==c?void 0:c.stroke,g=null==c?void 0:c.strokeWidth;let y=0;for(let e=0;l.length>e;e++){const o=l[e],r=t.getX(o),n=t.getY(o),p=y+n;let m;m=l.length-1>e?t.getX(l[e+1])-r:e>0?r-t.getX(l[e-1]):0;const x=a.x(r),v=0!==m?a.x(r+m):x+i.width/10,b=Math.min(x,v)+f/2,k=Math.max(x,v)-f/2-b;if(0>=k){y=p;continue}const A=a.y(y),w=a.y(p);s.push(xt(b,Math.min(A,w),k,Math.abs(A-w),{fill:0>n?h:u,stroke:d,strokeWidth:g},Object.assign(Object.assign({},o),{baseline:y,cumEnd:p,delta:n,_connectorStroke:null==c?void 0:c.connectorStroke,_connectorWidth:null==c?void 0:c.connectorWidth}))),y=p}return s}(n,e,t);case"candlestick":return function(t,e){var i,o;if(!t.getHigh||!t.getLow||!t.scales)return[];const r=null!==(i=t.config.candlestickRangeMode)&&void 0!==i&&i;if(!(r||t.getOpen&&t.getClose))return[];const n=[],s=t.config.candlestickStyle||{},a=s.rangeColor||"#6366f1",c=r?a:s.upColor||"#28a745",l=r?a:s.downColor||"#dc3545",u=r?a:s.wickColor||"#333",h=s.wickWidth||(r?2:1),f=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let d=r?0:null!==(o=s.bodyWidth)&&void 0!==o?o:0;if(!r&&null==s.bodyWidth&&f.length>1){let e=1/0;for(let i=1;f.length>i;i++){const o=Math.abs(t.scales.x(f[i])-t.scales.x(f[i-1]));o>0&&e>o&&(e=o)}d=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else r||null!=s.bodyWidth||(d=6);for(const i of e){const e=t.getX(i);if(null==e||Number.isNaN(e))continue;const o=t.getHigh(i),s=t.getLow(i);if(null==o||Number.isNaN(o)||null==s||Number.isNaN(s))continue;const a=r?o:t.getOpen(i),f=r?s:t.getClose(i);if(!r&&[a,f].some(t=>null==t||Number.isNaN(t)))continue;const g=f>=a,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(a),closeY:t.scales.y(f),highY:t.scales.y(o),lowY:t.scales.y(s),bodyWidth:d,upColor:c,downColor:l,wickColor:u,wickWidth:h,isUp:g,datum:i};r&&(y.isRange=!0),n.push(y)}return n}(n,e);default:return[]}}resolveBoundsStyle(t,e){const i=this.config.boundsStyle;return"function"==typeof i?i(e||{},t):i&&"object"==typeof i?i:{fill:this.resolveLineStyle(t,e).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?ct(i,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,i){var o,r;const n=i.length;if(1>=n)return;const s=new Map;for(let t=0;i.length>t;t++)s.set(i[t],t);for(const i of e){if("line"===i.type){const e=Array.isArray(i.datum)?i.datum:[];if(2>e.length)continue;const o=Array(e.length);let r=!1;for(let i=0;e.length>i;i++){const a=s.get(e[i]);null!=a?(o[i]=ct(t,a,n),1>o[i]&&(r=!0)):o[i]=1}r&&(i._decayOpacities=o);continue}if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[],o=i.topPath?i.topPath.length:e.length;if(2>o)continue;if(e.length===o){const r=Array(o);let a=!1;for(let i=0;e.length>i;i++){const o=s.get(e[i]);null!=o?(r[i]=ct(t,o,n),1>r[i]&&(a=!0)):r[i]=1}a&&(i._decayOpacities=r)}else{let r=1;for(const i of e){const e=s.get(i);if(null!=e){const i=ct(t,e,n);r>i&&(r=i)}}if(1>r){const t=Array(o);t.fill(r),i._decayOpacities=t}}continue}const e=s.get(i.datum);if(null==e)continue;const a=ct(t,e,n);if("heatcell"===i.type)i.style={opacity:a};else if("candlestick"===i.type)i._decayOpacity=a;else{const t=null!==(r=null===(o=i.style)||void 0===o?void 0:o.opacity)&&void 0!==r?r:1;i.style=Object.assign(Object.assign({},i.style),{opacity:t*a})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,i,o){var r,n;const s="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(r=t.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",c=null!==(n=t.glowRadius)&&void 0!==n?n:4,l=new Map;for(let t=0;i.length>t;t++)l.set(i[t],t);for(const i of e){if("line"===i.type)continue;if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[i.datum];let r=0;for(const i of e){const e=l.get(i);if(null==e)continue;const n=o.get(e);if(null==n)continue;const a=lt(t,n,s);a>r&&(r=a)}r>0&&(i._pulseIntensity=r,i._pulseColor=a);continue}const e=l.get(i.datum);if(null==e)continue;const r=o.get(e);if(null==r)continue;const n=lt(t,r,s);n>0&&(i._pulseIntensity=n,i._pulseColor=a,i._pulseGlowRadius=c)}}(this.config.pulse,t,e,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(t,e){var i;if(!e||0===e.size)return!1;const o="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(i=t.duration)&&void 0!==i?i:500,n=e.peek();return null!=n&&r>o-n}(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,i,o){var r,n,s;i.clear(),o.clear();for(let a=0;e.length>a;a++){const c=e[a],l=gt(t,c,a);l&&("point"===c.type?i.set(l,{x:c.x,y:c.y,r:c.r,opacity:c.style.opacity}):"rect"===c.type?i.set(l,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:c.style.opacity}):"heatcell"===c.type?i.set(l,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:null===(r=c.style)||void 0===r?void 0:r.opacity}):"candlestick"===c.type?i.set(l,{x:c.x,y:c.openY}):"line"===c.type?o.set(l,{path:c.path.map(t=>[t[0],t[1]]),opacity:null===(n=c.style)||void 0===n?void 0:n.opacity}):"area"===c.type&&o.set(l,{topPath:c.topPath.map(t=>[t[0],t[1]]),bottomPath:c.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(s=c.style)||void 0===s?void 0:s.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}startTransition(){if(!this.config.transition)return;const t=function(t,e,i,o,r){var n,s,a,c,l,u,h,f,d,g,y,p,m,x,v,b,k,A,w,S,_,P,E,M,O,T,L,$;if(0===o.size&&0===r.size)return i;const z=null!==(n=e.duration)&&void 0!==n?n:300;if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}let D=!1;const j=new Set,N=new Set;for(let e=0;i.scene.length>e;e++){const n=i.scene[e],w=gt(t,n,e);if(!w)continue;if(n._transitionKey=w,"line"===n.type||"area"===n.type){const t=r.get(w);if(t){if(N.add(w),"line"===n.type&&t.path&&t.path.length===n.path.length){n._targetPath=n.path.map(t=>[t[0],t[1]]),n._prevPath=t.path;for(let e=0;n.path.length>e;e++)n.path[e]=[t.path[e][0],t.path[e][1]];D=!0}else if("area"===n.type&&t.topPath&&t.bottomPath&&t.topPath.length===n.topPath.length&&t.bottomPath.length===n.bottomPath.length){n._targetTopPath=n.topPath.map(t=>[t[0],t[1]]),n._targetBottomPath=n.bottomPath.map(t=>[t[0],t[1]]),n._prevTopPath=t.topPath,n._prevBottomPath=t.bottomPath;for(let e=0;n.topPath.length>e;e++)n.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;n.bottomPath.length>e;e++)n.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];D=!0}n._targetOpacity=null!==(s=n.style.opacity)&&void 0!==s?s:1,n._startOpacity=null!==(c=null!==(a=t.opacity)&&void 0!==a?a:n.style.opacity)&&void 0!==c?c:1}else n._targetOpacity=null!==(l=n.style.opacity)&&void 0!==l?l:1,n._startOpacity=0,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),D=!0;continue}const S=o.get(w);if("point"===n.type)if(S){j.add(w);const t={x:n.x,y:n.y,r:n.r};n._targetOpacity=null!==(u=n.style.opacity)&&void 0!==u?u:1,S.x===t.x&&S.y===t.y&&S.r===t.r||(n._targetX=t.x,n._targetY=t.y,n._targetR=t.r,n.x=S.x,n.y=S.y,n.r=null!==(h=S.r)&&void 0!==h?h:n.r,D=!0)}else n._targetOpacity=null!==(f=n.style.opacity)&&void 0!==f?f:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),D=!0;else if("rect"===n.type)if(S){j.add(w);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=null!==(d=n.style.opacity)&&void 0!==d?d:1,S.x===t.x&&S.y===t.y&&S.w===t.w&&S.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=S.x,n.y=S.y,n.w=null!==(g=S.w)&&void 0!==g?g:n.w,n.h=null!==(y=S.h)&&void 0!==y?y:n.h,D=!0)}else n._targetOpacity=null!==(p=n.style.opacity)&&void 0!==p?p:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),D=!0;else if("heatcell"===n.type)if(S){j.add(w);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=null!==(x=null===(m=n.style)||void 0===m?void 0:m.opacity)&&void 0!==x?x:1,S.x===t.x&&S.y===t.y&&S.w===t.w&&S.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=S.x,n.y=S.y,n.w=null!==(v=S.w)&&void 0!==v?v:n.w,n.h=null!==(b=S.h)&&void 0!==b?b:n.h,D=!0)}else n._targetOpacity=null!==(A=null===(k=n.style)||void 0===k?void 0:k.opacity)&&void 0!==A?A:1,n.style=Object.assign(Object.assign({},n.style||{}),{opacity:0}),D=!0}for(const[t,e]of r)if(!N.has(t))if(t.startsWith("l:")&&e.path){const o={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(w=e.opacity)&&void 0!==w?w:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),D=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const o={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!==(S=e.opacity)&&void 0!==S?S:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),D=!0}for(const[t,e]of o)if(!j.has(t)){if(t.startsWith("p:")){const o={type:"point",x:e.x,y:e.y,r:null!==(_=e.r)&&void 0!==_?_:3,style:{opacity:null!==(P=e.opacity)&&void 0!==P?P:1},datum:null,_targetOpacity:0,_transitionKey:t};i.exitNodes.push(o)}else if(t.startsWith("r:")){const o={type:"rect",x:e.x,y:e.y,w:null!==(E=e.w)&&void 0!==E?E:0,h:null!==(M=e.h)&&void 0!==M?M:0,style:{opacity:null!==(O=e.opacity)&&void 0!==O?O:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};i.exitNodes.push(o)}else if(t.startsWith("h:")){const o={type:"heatcell",x:e.x,y:e.y,w:null!==(T=e.w)&&void 0!==T?T:0,h:null!==(L=e.h)&&void 0!==L?L:0,fill:"#999",datum:null,style:{opacity:null!==($=e.opacity)&&void 0!==$?$:1},_targetOpacity:0,_transitionKey:t};i.exitNodes.push(o)}D=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),D&&(i.activeTransition={startTime:dt(),duration:z}),i}(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},i=function(t,e,i,o){var r,n,s,a,c;if(!i.activeTransition)return!1;const l=ht(t,i.activeTransition),u=ut(l,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of i.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,n=i?null!==(r=i.opacity)&&void 0!==r?r:1:0;t.style.opacity=ft(n,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=ft(i.x,t._targetX,u),t.y=ft(i.y,t._targetY,u),void 0!==t._targetR&&void 0!==i.r&&(t.r=ft(i.r,t._targetR,u))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,r=i?null!==(n=i.opacity)&&void 0!==n?n:1:0;t.style.opacity=ft(r,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=ft(i.x,t._targetX,u),t.y=ft(i.y,t._targetY,u),void 0!==i.w&&(t.w=ft(i.w,t._targetW,u)),void 0!==i.h&&(t.h=ft(i.h,t._targetH,u))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,r=i?null!==(s=i.opacity)&&void 0!==s?s:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:ft(r,t._targetOpacity,u)})}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=ft(i.x,t._targetX,u),t.y=ft(i.y,t._targetY,u),void 0!==i.w&&(t.w=ft(i.w,t._targetW,u)),void 0!==i.h&&(t.h=ft(i.h,t._targetH,u))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=null!==(a=t._startOpacity)&&void 0!==a?a:0;t.style=Object.assign(Object.assign({},t.style),{opacity:ft(e,t._targetOpacity,u)})}const e=t._prevPath,i=t._targetPath;if(e&&i&&e.length===t.path.length)for(let o=0;t.path.length>o;o++)t.path[o][0]=ft(e[o][0],i[o][0],u),t.path[o][1]=ft(e[o][1],i[o][1],u)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(c=t._startOpacity)&&void 0!==c?c:0;t.style=Object.assign(Object.assign({},t.style),{opacity:ft(e,t._targetOpacity,u)})}const e=t._prevTopPath,i=t._prevBottomPath,o=t._targetTopPath,r=t._targetBottomPath;if(e&&o&&e.length===t.topPath.length)for(let i=0;t.topPath.length>i;i++)t.topPath[i][0]=ft(e[i][0],o[i][0],u),t.topPath[i][1]=ft(e[i][1],o[i][1],u);if(i&&r&&i.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=ft(i[e][0],r[e][0],u),t.bottomPath[e][1]=ft(i[e][1],r[e][1],u)}}if(l>=1){for(const t of i.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 i=0;t.path.length>i;i++)t.path[i]=e[i];t._prevPath=void 0,t._targetPath=void 0}else if("area"===t.type){const e=t._targetTopPath,i=t._targetBottomPath;if(e)for(let i=0;t.topPath.length>i;i++)t.topPath[i]=e[i];if(i)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=i[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0}}if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}return i.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,i}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const i of t){const t=this.getGroup(i);e.has(t)||e.set(t,[]),e.get(t).push(i)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveColorMap(t){const e=new Set;for(const i of t){const t=this.getColor(i);t&&e.add(t)}const i=Array.from(e).sort(),o=i.join("\0");if(this._colorMapCache&&this._colorMapCache.key===o)return this._colorMapCache.map;const r=Array.isArray(this.config.colorScheme)?this.config.colorScheme:at,n=new Map;for(let t=0;i.length>t;t++)n.set(i[t],r[t%r.length]);return this._colorMapCache={key:o,map:n},n}resolveLineStyle(t,e){const i=this.config.lineStyle;if("function"==typeof i){const o=i(e||{},t);if(o&&!o.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},o),{stroke:e})}return o}return i&&"object"==typeof i?{stroke:i.stroke||"#007bff",strokeWidth:i.strokeWidth||2,strokeDasharray:i.strokeDasharray,fill:i.fill,fillOpacity:i.fillOpacity,opacity:i.opacity}:{stroke:this.resolveGroupColor(t)||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var i;if(this.config.areaStyle){const i=this.config.areaStyle(e||{});if(i&&!i.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{fill:e,stroke:i.stroke||e})}return i}const o=this.config.lineStyle;if("function"==typeof o){const i=o(e||{},t);if(i&&!i.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{fill:e,stroke:i.stroke||e})}return i}if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||"#4e79a7",fillOpacity:null!==(i=o.fillOpacity)&&void 0!==i?i:.7,stroke:o.stroke||"#4e79a7",strokeWidth:o.strokeWidth||2};const r=this.resolveGroupColor(t)||"#4e79a7";return{fill:r,fillOpacity:.7,stroke:r,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 i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:at,o=i[this._groupColorMap.size%i.length];return this._groupColorMap.set(t,o),o}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),i=this.getPointId,o=t=>e.has(i(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,i)=>{o(t)&&e.add(i)}),this.timestampBuffer.clear();for(let i=0;t.length>i;i++)e.has(i)||this.timestampBuffer.push(t[i])}const r=this.buffer.remove(o);if(0===r.length)return r;for(const t of r)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,r}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const i=new Set(Array.isArray(t)?t:[t]),o=this.getPointId,r=new Set;this.buffer.forEach((t,e)=>{i.has(o(t))&&r.add(e)});const n=this.buffer.update(t=>i.has(o(t)),e);if(0===n.length)return n;for(const t of n)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.buffer.forEach((t,e)=>{r.has(e)&&(this.xExtent.push(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))):(this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,n}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,i,o,r;const n=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 s=!1;Object.assign(this.config,t);const a="chartType"in t&&t.chartType!==n.chartType||"runtimeMode"in t&&t.runtimeMode!==n.runtimeMode;if(a||void 0!==t.xAccessor||void 0!==t.yAccessor||void 0!==t.timeAccessor||void 0!==t.valueAccessor){const c=a||!ot(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(i=n.xAccessor)&&void 0!==i?i:n.timeAccessor),l=a||!ot(null!==(o=t.yAccessor)&&void 0!==o?o:t.valueAccessor,null!==(r=n.yAccessor)&&void 0!==r?r:n.valueAccessor);(c||l)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=rt(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=rt(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=rt(this.config.xAccessor,"x"),this.getY=rt(this.config.yAccessor,"y")),s=!0)}if("groupAccessor"in t&&!ot(t.groupAccessor,n.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?st(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in t&&!ot(t.categoryAccessor,n.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?st(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in t&&!ot(t.sizeAccessor,n.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?rt(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in t&&!ot(t.colorAccessor,n.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?st(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in t&&!ot(t.y0Accessor,n.y0Accessor)&&(this.getY0=this.config.y0Accessor?rt(this.config.y0Accessor,"y0"):void 0,s=!0),"pointIdAccessor"in t&&!ot(t.pointIdAccessor,n.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?st(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&("openAccessor"in t&&!ot(t.openAccessor,n.openAccessor)||"closeAccessor"in t&&!ot(t.closeAccessor,n.closeAccessor)||"highAccessor"in t&&!ot(t.highAccessor,n.highAccessor)||"lowAccessor"in t&&!ot(t.lowAccessor,n.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?rt(this.config.openAccessor,"open"):void 0,this.getHigh=rt(this.config.highAccessor,"high"),this.getLow=rt(this.config.lowAccessor,"low"),this.getClose=e?rt(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,s=!0}if(!s){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const i of e)if(t[i]!==n[i]){s=!0;break}}s&&(this.needsFullRebuild=!0)}}function _t(t,e){var i=t.get(e);if(!i)throw Error("missing: "+e);return i}function Pt(t,e){var i,o=[],r=[],n=[],s={},a=[];function c(t){n[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],n[e]&&c(e)})}function l(t){var e,o,h=!1;for(r.push(t),n[t]=!0,e=0;a[t].length>e;e++)(o=a[t][e])===i?(u(i,r),h=!0):n[o]||(h=l(o));if(h)c(t);else for(e=0;a[t].length>e;e++){var f=s[o=a[t][e]];f||(s[o]=f={}),f[o]=!0}return r.pop(),h}function u(t,e){var i=[].concat(e).concat(t);o.push(i)}function h(e){!function(e){for(var i=0;t.length>i;i++)i>=e&&t[i]||(t[i]=[]),t[i]=t[i].filter(function(t){return t>=e})}(e);for(var i,o=function(t){for(var e=t.length,i=Array(e),o=Array(e),r=Array(e),n=Array(e),s=Array(e),a=Array(e),c=0;e>c;++c)i[c]=-1,o[c]=0,r[c]=!1,n[c]=0,s[c]=-1,a[c]=[];var l,u=0,h=[],f=[];function d(e){var c=[e],l=[e];for(i[e]=o[e]=u,r[e]=!0,u+=1;l.length>0;){var d=t[e=l[l.length-1]];if(d.length>n[e]){for(var g=n[e];d.length>g;++g){var y=d[g];if(0>i[y]){i[y]=o[y]=u,r[y]=!0,u+=1,c.push(y),l.push(y);break}r[y]&&(o[e]=0|Math.min(o[e],o[y])),0>s[y]||a[e].push(s[y])}n[e]=g}else{if(o[e]===i[e]){var p=[],m=[],x=0;for(g=c.length-1;g>=0;--g){var v=c[g];if(r[v]=!1,p.push(v),m.push(a[v]),x+=a[v].length,s[v]=h.length,v===e){c.length=g;break}}h.push(p);var b=Array(x);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)b[--x]=m[g][k];f.push(b)}l.pop()}}}for(c=0;e>c;++c)0>i[c]&&d(c);for(c=0;f.length>c;c++){var g=f[c];if(0!==g.length){g.sort(function(t,e){return t-e}),l=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&l.push(g[y]);f[c]=l}}return{components:h,adjacencyList:f}}(t),r=o.components.filter(function(t){return t.length>1}),n=1/0,s=0;r.length>s;s++)for(var a=0;r[s].length>a;a++)n>r[s][a]&&(n=r[s][a],i=s);var c=r[i];if(!c)return!1;var l=t.map(function(t,e){return-1===c.indexOf(e)?[]:t.filter(function(t){return-1!==c.indexOf(t)})});return{leastVertex:n,adjList:l}}i=0;for(var f=t.length;f>i;){var d=h(i);if(i=d.leastVertex,a=d.adjList){for(var g=0;a.length>g;g++)for(var y=0;a[g].length>y;y++){var p=a[g][y];n[+p]=!1,s[p]={}}l(i),i+=1}else i=f}return o}function Et(t){return t.y0-t.y1>0?"up":"down"}function Mt(t,e){return e(t.source)==e(t.target)}function Ot(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var i=0;return t.target.targetLinks.forEach(function(t){i=t.circular?i+1:i}),1>=e&&1>=i}function Tt(t){return t.target.x0-t.source.x1}function Lt(t,e){var i=zt(t),o=Tt(e)/Math.tan(i);return"up"==Et(t)?t.y1-o:t.y1+o}function $t(t,e){var i=zt(t),o=Tt(e)/Math.tan(i);return"up"==Et(t)?t.y1+o:t.y1-o}function zt(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function Dt(t,e){return e(t)}function jt(t){return Bt(t.source)}function Nt(t){return Bt(t.target)}function Bt(t){return(t.y0+t.y1)/2}function Rt(t){return t.virtual?0:t.value}function Wt(t,e){var i=0;t.sourceLinks.forEach(function(t){i=t.circular&&!Mt(t,e)?i+1:i});var o=0;return t.targetLinks.forEach(function(t){o=t.circular&&!Mt(t,e)?o+1:o}),i+o}function Ft(t){return t.target.depth}function Ct(t,e){return t.sourceLinks.length?t.depth:e-1}function It(t,e){return t.y0-e.y0}function Yt(t,e){return e.y0-t.y0}function Xt(t,e){return t.y1-e.y1}function qt(t,e){return e.y1-t.y1}function Gt(t,e){return Ht(t.source,e.source)||t.index-e.index}function Vt(t,e){return Ht(t.target,e.target)||t.index-e.index}function Ht(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Zt(t,e){return Kt(t)==Kt(e)?"bottom"==t.circularLinkType?Yt(t,e):It(t,e):Kt(e)-Kt(t)}function Kt(t){return t.target.column-t.source.column}function Ut(t,e){return Qt(t)==Qt(e)}function Qt(t){return t.y0-t.y1>0?"up":"down"}function Jt(t,e,i,o,r){let n=t;var s=Math.max(8,.15*(n.y1-n.y0));n.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,s))});var a=x(n.links,function(t){return t.source.y0});n.links.forEach(function(t){t.circular&&(t.circularPathData={})});var c=n.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}),te(n.links.filter(function(t){return"top"==t.circularLinkType}),e,i),te(n.links.filter(function(t){return"bottom"==t.circularLinkType}),e,i),n.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+o,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,Mt(t,e)&&Ot(t))t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=o+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 s=t.source.column,c=t.circularLinkType,l=n.links.filter(function(t){return t.source.column==s&&t.circularLinkType==c});l.sort("bottom"==t.circularLinkType?Yt:It);var u=0;l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2+r*i+u),u+=e._circularWidth||e.width}),s=t.target.column,(l=n.links.filter(function(t){return t.target.column==s&&t.circularLinkType==c})).sort("bottom"==t.circularLinkType?qt:Xt),u=0,l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2+r*i+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(n.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=a-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,i=t.y0,o=t.target.x0,r=t.y1,n=(e+o)/2;return"M"+e+","+i+"C"+n+","+i+" "+n+","+r+" "+o+","+r}(t)}),n}function te(t,e,i){t.sort(Zt);var o=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,r){var n=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(Mt(t,e)&&Ot(t))t.circularPathData.verticalBuffer=n+t._circularWidth/2;else{for(var s=0;o.length>s;s++){var a=o[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&ee(t,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+i;n=c>n?c:n}}t.circularPathData.verticalBuffer=n+t._circularWidth/2}}),t}function ee(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function ie(t){return function(){return t}}function oe(t){return t.index}function re(t){return t.nodes}function ne(t){return t.links}function se(t,e,i){var o=v(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});o.forEach(function(r,n){var s=r.length;if(e)r.sort(e);else if(n>0){var a=new Map;r.forEach(function(t,e){var i,o,r,n=(o=0,r=0,(i=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=Bt(t.source)*e,o+=e}}),i.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=Bt(t.target)*e,o+=e}}),o>0?r/o:NaN);a.set(t,{bc:n,idx:e})}),r.sort(function(t,e){var i=a.get(t),o=a.get(e),r=i.bc,n=o.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(n)?isNaN(r)?isNaN(n)?i.idx-o.idx:1:-1:r-n})}else r.sort(function(t,e){return t.circularLinkType==e.circularLinkType?Wt(e,i)-Wt(t,i):"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==o.length-1&&1==s||0==e.depth&&1==s?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==Wt(e,i)?(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)/s*r,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-s/2+r,e.y1=e.y0+e.value*t.ky)})})}function ae(t,e,i,o,r,n){var s=v(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});u();for(var a=1,c=n;c>0;--c)l(a*=.99,i),u();function l(e,i){var o=s.length;s.forEach(function(r){var n=r.length,s=r[0].depth;r.forEach(function(r){var a;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&Wt(r,i)>0){var c=A(r.sourceLinks,Nt),l=A(r.targetLinks,jt),u=c&&l?(c+l)/2:c||l;if(u){var h=(u-Bt(r))*e*.3;r.y0+=h,r.y1+=h}}else if(0==s&&1==n)r.y0=t.y1/2-(a=r.y1-r.y0)/2,r.y1=t.y1/2+a/2;else if(s==o-1&&1==n)r.y0=t.y1/2-(a=r.y1-r.y0)/2,r.y1=t.y1/2+a/2;else if(1==r.targetLinks.length&&1==r.targetLinks[0].source.sourceLinks.length)a=r.y1-r.y0,r.y0=r.targetLinks[0].source.y0,r.y1=r.y0+a;else{var f=A(r.sourceLinks,Nt),d=A(r.targetLinks,jt),g=((f&&d?(f+d)/2:f||d)-Bt(r))*e;r.y0+=g,r.y1+=g}})})}function u(){s.forEach(function(i){var n,s,a,c=t.y0,l=i.length;for(i.sort(e||Ht),a=0;l>a;++a)(s=c-(n=i[a]).y0)>0&&(n.y0+=s,n.y1+=s),c=n.y1+o;if((s=c-o-t.y1)>0)for(c=n.y0-=s,n.y1-=s,a=l-2;a>=0;--a)(s=(n=i[a]).y1+r-c)>0&&(n.y0-=s,n.y1-=s),c=n.y0})}}function ce(t){t.nodes.forEach(function(t){t.sourceLinks.sort(Vt),t.targetLinks.sort(Gt)}),t.nodes.forEach(function(t){var e=t.y0,i=e,o=t.y1,r=o;t.sourceLinks.forEach(function(t){t.circular?(t.y0=o-t.width/2,o-=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=i+t.width/2,i+=t.width)})})}function le(){var t=0,e=0,i=1,o=1,r=24,n=8,s=null,a=oe,c=Ct,l=void 0,u=32,h=2,f=re,d=ne;function g(){var g={nodes:f.apply(null,arguments),links:d.apply(null,arguments)};return function(f){f.x0=t,f.y0=e,f.x1=i,f.y1=o,f.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var i=function(t,e){var i=new Map;return w(t,e).forEach(function(t,e){i.set(e,t[0])}),i}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var o=t.source,r=t.target;"object"!=typeof o&&(o=t.source=_t(i,o)),"object"!=typeof r&&(r=t.target=_t(i,r)),o.sourceLinks.push(t),r.targetLinks.push(t)})}(f,a),function(t,e){var i=0;if(null==e){for(var o=[],r=0;t.links.length>r;r++){var n=t.links[r],s=n.source.index,a=n.target.index;o[s]||(o[s]=[]),o[a]||(o[a]=[]),-1===o[s].indexOf(a)&&o[s].push(a)}var c=Pt(o);c.sort(function(t,e){return t.length-e.length});var l={};for(r=0;c.length>r;r++){var u=c[r].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,o=t.source.index;e===o||l[o]&&l[o][e]?(t.circular=!0,t.circularLinkID=i++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=i++)})}(f,l),function(t,e){var i=0,o=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:o>i?"top":"bottom","top"==r.circularLinkType?i++:o++,t.nodes.forEach(function(t){Dt(t,e)!=Dt(r.source,e)&&Dt(t,e)!=Dt(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),Mt(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(f,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(k(t.sourceLinks,Rt),k(t.targetLinks,Rt)),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,i){var o,r,n;if(null!=e){t.nodes.sort(function(t,i){return e(t)<e(i)?-1:1});var s=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==a?s:s+1,a=e(t)==a?a:e(t),t.column=s})}for(o=t.nodes,r=[],n=0;o.length;++n,o=r,r=[])o.forEach(function(t){t.depth=n,t.sourceLinks.forEach(function(t){0>r.indexOf(t.target)&&!t.circular&&r.push(t.target)})});for(o=t.nodes,r=[],n=0;o.length;++n,o=r,r=[])o.forEach(function(t){t.height=n,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?i(t,n):t.column})}(f,l,c);var d=n;if(null!==s){var g=v(f.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),y=b(g,function(t){return t.length});y>1&&(d=Math.max(1,(o-e)*s/(y-1)))}(function(t,e,i){var o=v(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=x(o,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/k(e,function(t){return t.value})});t.ky=r,t.links.forEach(function(e){e.width=e.value*t.ky});var n=b(t.nodes,function(t){return t.column});t.nodes.forEach(n>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-i)/n),e.x1=e.x0+i}:function(e){e.x0=t.x0,e.x1=e.x0+i})})(f,d,r),se(f,l,a),ae(f,l,a,d,d,u),ce(f),Jt(f,a,h,10,8),se(f,l,a),ae(f,l,a,d,d,u),ce(f),Jt(f,a,h,10,8),function(t,e){let i=t;i.nodes.forEach(function(t){t.y+(t.y1-t.y0)>i.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-i.y1));var o=i.links.filter(function(i){return Dt(i.source,e)==Dt(t,e)}),r=o.length;r>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!Ut(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var i=Lt(e,t);return t.y1-i}if(e.target.column>t.target.column)return Lt(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 n=t.y0;o.forEach(function(t){t.y0=n+t.width/2,n+=t.width}),o.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var n=i+1,s=0;r>n;n++)s+=o[n].width;e.y0=t.y1-s-e.width/2}})})}(f,a),function(t,e){let i=t;i.nodes.forEach(function(t){var o=i.links.filter(function(i){return Dt(i.target,e)==Dt(t,e)}),r=o.length;r>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!Ut(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var i=$t(e,t);return t.y0-i}if(e.source.column>t.source.column)return $t(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 n=t.y0;o.forEach(function(t){t.y1=n+t.width/2,n+=t.width}),o.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var n=i+1,s=0;r>n;n++)s+=o[n].width;e.y1=t.y1-s-e.width/2}})})}(f,a),function(t){var e=t.nodes,i=t.links,o=!1,r=!1;if(i.forEach(function(t){"top"==t.circularLinkType?o=!0:"bottom"==t.circularLinkType&&(r=!0)}),0==o||0==r){var n=x(e,function(t){return t.y0}),s=b(e,function(t){return t.y1}),a=(t.y1-t.y0)/(s-n);function c(e){return(e-n)/(s-n)*(t.y1-t.y0)+t.y0}1>a?(e.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1)}),i.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1),t.width=t.width*a})):e.forEach(function(t){var e=t.y1-t.y0,i=c(t.y0)-t.y0;t.y0=c(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+i}),t.targetLinks.forEach(function(t){t.y1=t.y1+i})})}}(f),Jt(f,a,h,10,8)}(g),g}return g.update=function(t){return ce(t),Jt(t,a,h,10,8),t},g.nodeWidth=function(t){return arguments.length?(r=+t,g):r},g.nodePadding=function(t){return arguments.length?(n=+t,g):n},g.nodePaddingRatio=function(t){return arguments.length?(s=+t,g):s},g.nodes=function(t){return arguments.length?(f="function"==typeof t?t:ie(t),g):f},g.links=function(t){return arguments.length?(d="function"==typeof t?t:ie(t),g):d},g.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:ie(t),g):a},g.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:ie(t),g):c},g.nodeSort=function(t){return arguments.length?(l=t,g):l},g.iterations=function(t){return arguments.length?(u=+t,g):u},g.circularLinkGap=function(t){return arguments.length?(h=+t,g):h},g.extent=function(r){return arguments.length?(t=+r[0][0],e=+r[0][1],i=+r[1][0],o=+r[1][1],g):[[t,e],[i,o]]},g.size=function(r){return arguments.length?(t=e=0,i=+r[0],o=+r[1],g):[i-t,o-e]},g}St.QUADTREE_THRESHOLD=500;const ue=t=>{let e,i,o,r,n,s,a,c,l;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,i=t.y1-t.sankeyWidth/2,o=t.y1+t.sankeyWidth/2,r=t.y0+t.sankeyWidth/2,n=t.source.x1,s=t.target.x0,a=_(n,s),c=a(.5),l=a(.5),`M${e},${n}C${e},${c} ${i},${l} ${i},${s}L${o},${s}C${o},${l} ${r},${c} ${r},${n}Z`):(e=t.source.x1,i=t.target.x0,a=_(e,i),o=a(.5),r=a(.5),n=t.y0-t.sankeyWidth/2,s=t.y1-t.sankeyWidth/2,c=t.y1+t.sankeyWidth/2,l=t.y0+t.sankeyWidth/2,`M${e},${n}C${o},${n} ${r},${s} ${i},${s}L${i},${c}C${r},${c} ${o},${l} ${e},${l}Z`)};function he(t){var e;const i=t.sankeyWidth/2,o=(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,o=r.sourceY,n=r.targetX,s=r.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(r.rightFullExtent-e))),c=Math.max(15,Math.min(40,.33*(n-r.leftFullExtent)));return`M${e},${o-i}L${e+a},${o-i}L${e+a},${o+i}L${e},${o+i}ZM${n},${s-i}L${n-c},${s-i}L${n-c},${s+i}L${n},${s+i}Z`}const n=r.sourceX,s=r.sourceY,a=r.targetX,c=r.targetY,l=r.rightFullExtent,u=r.leftFullExtent,h=r.verticalFullExtent,f="bottom"===t.circularLinkType?1:-1,d=Math.max(4,Math.min(o,15));return`M${n},${s-f*i}L${l},${s-f*i}L${l+o},${s-f*i+f*d}L${l+o},${h+f*o-f*d}L${l+o-d},${h+f*o}L${u-o+d},${h+f*o}L${u-o},${h+f*o-f*d}L${u-o},${c-f*i+f*d}L${u-o+d},${c-f*i}L${a},${c-f*i}L${a},${c+f*i}L${u+o},${c+f*i}L${u+o},${h-f*o}L${l-o},${h-f*o}L${l-o},${s+f*i}L${n},${s+f*i}Z`}const fe=new Set,de=new WeakMap;function ge(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let i=de.get(t);if(i){const t=i.get(e);if(t)return t}else i=new Map,de.set(t,i);const o=new Proxy(t,{get(t,i,o){if("string"==typeof i&&!(i in t)&&t.data&&i in t.data){const t=`${e}:${i}`;fe.has(t)||(fe.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${i}" on the wrapper object, but it only exists on ".data". Use d.data.${i} (or d.data?.${i}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,i,o)}});return i.set(e,o),o}const ye={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(Ft))-1:0},justify:Ct},pe={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,o){var r,n,s,a,c,l,u;if(0===t.length)return;const h="vertical"===i.orientation?"down":"right",f=i.nodeAlign||"justify",d=null!==(r=i.nodeWidth)&&void 0!==r?r:15,g=null!==(n=i.nodePaddingRatio)&&void 0!==n?n:.05,y=null!==(s=i.iterations)&&void 0!==s?s: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 x;x="down"===h?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const v=le().extent(x).links(m).nodes(p).nodeAlign(ye[f]||Ct).nodeId(t=>t.id).nodeWidth(d).iterations(y);v.nodePaddingRatio&&v.nodePaddingRatio(g),v();{let t=1/0,e=-1/0,i=1/0,r=-1/0;for(const o of p)t>o.x0&&(t=o.x0),o.x1>e&&(e=o.x1),i>o.y0&&(i=o.y0),o.y1>r&&(r=o.y1);for(const o of m){if(!o.circular||!o.circularPathData)continue;const n=o.circularPathData,s=(null!==(c=null!==(a=o._circularWidth)&&void 0!==a?a:o.width)&&void 0!==c?c:0)/2;t>n.leftFullExtent-s&&(t=n.leftFullExtent-s),n.rightFullExtent+s>e&&(e=n.rightFullExtent+s),i>n.verticalFullExtent-s&&(i=n.verticalFullExtent-s),n.verticalFullExtent+s>r&&(r=n.verticalFullExtent+s)}const n=e-t,s=r-i,u=o[0],h=o[1];if(n>0&&s>0&&(0>t||0>i||e>u||r>h)){const e=Math.min(u/n,h/s),o=-t*e+(u-n*e)/2,r=-i*e+(h-s*e)/2;for(const t of p)t.x0=t.x0*e+o,t.x1=t.x1*e+o,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!==(l=t.width)&&void 0!==l?l:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const i=t.circularPathData;i.sourceX=i.sourceX*e+o,i.targetX=i.targetX*e+o,i.sourceY=i.sourceY*e+r,i.targetY=i.targetY*e+r,i.rightFullExtent=i.rightFullExtent*e+o,i.leftFullExtent=i.leftFullExtent*e+o,i.verticalFullExtent=i.verticalFullExtent*e+r,i.rightInnerExtent=i.rightInnerExtent*e+o,i.leftInnerExtent=i.leftInnerExtent*e+o,i.verticalRightInnerExtent=i.verticalRightInnerExtent*e+r,i.verticalLeftInnerExtent=i.verticalLeftInnerExtent*e+r,i.rightSmallArcRadius*=e,i.rightLargeArcRadius*=e,i.leftSmallArcRadius*=e,i.leftLargeArcRadius*=e,i.sourceWidth*=e,i.rightNodeBuffer*=e,i.leftNodeBuffer*=e,i.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,i=t.target,o="object"==typeof e&&null!==e?e.id:e+"",r="object"==typeof i&&null!==i?i.id:i+"",n=k.get(t._edgeKey?t._edgeKey:`${o}\0${r}`);if(n){n.y0=t.y0,n.y1=t.y1,n.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,n.circular=!!t.circular,n.circularPathData=t.circularPathData,n._circularWidth=t._circularWidth,n._circularStub=t._circularStub,n.path=t.path,n.circularLinkType=t.circularLinkType,n.direction=h;const e=b.get(o),i=b.get(r);e&&(n.source=e),i&&(n.target=i)}}},buildScene(t,e,i,o){var r,n,s,a;const c="vertical"===i.orientation?"down":"right",l=i.nodeStyle,u=i.edgeStyle,h=null!==(r=i.edgeOpacity)&&void 0!==r?r:.5,f=i.edgeColorBy||"source",d=Array.isArray(i.colorScheme)?i.colorScheme:m,g=new Map;t.forEach((t,e)=>{g.set(t.id,d[e%d.length])});const y=[],p=[],x=[],v=new Map;for(const e of t){const t=e.x1-e.x0,i=e.y1-e.y0;if(0>=t||0>=i)continue;const o=l?l(ge(e,"nodeStyle")):{},r={fill:o.fill||g.get(e.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};v.set(e.id,("string"==typeof r.fill?r.fill:null)||g.get(e.id)||"#4d430c"),y.push("down"===c?{type:"rect",x:e.y0,y:e.x0,w:i,h:t,style:r,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:i,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,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let o="#999";o="function"==typeof f?f(t)||o:"target"===f?v.get(i.id)||g.get(i.id)||o:v.get(e.id)||g.get(e.id)||o;const r=u?u(ge(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,i=t.sankeyWidth/2,a=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),c=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),l=r.fill||o;p.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-i}L${e.sourceX+a},${e.sourceY-i}L${e.sourceX+a},${e.sourceY+i}L${e.sourceX},${e.sourceY+i}Z`,style:{fill:l,fillOpacity:null!==(n=r.fillOpacity)&&void 0!==n?n:h,stroke:"none",opacity:r.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+a}}),p.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-i}L${e.targetX-c},${e.targetY-i}L${e.targetX-c},${e.targetY+i}L${e.targetX},${e.targetY+i}Z`,style:{fill:l,fillOpacity:null!==(s=r.fillOpacity)&&void 0!==s?s:h,stroke:"none",opacity:r.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-c,x1:e.targetX}});continue}let c;if(c=t.circular&&t.circularPathData?he(t):ue(t),!c)continue;const l={fill:r.fill||o,fillOpacity:null!==(a=r.fillOpacity)&&void 0!==a?a:h,stroke:r.stroke||"none",strokeWidth:r.strokeWidth,opacity:r.opacity};p.push({type:"bezier",pathD:c,bezierCache:t.bezier,style:l,datum:t})}if(!1!==i.showLabels){const e=(k=i.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null;for(const i of t){const t=i.x1-i.x0,r=i.y1-i.y0;if(0>=t||0>=r)continue;const n=e?e(i):i.id;if(!n)continue;let s,a,l;"down"===c?(s=i.y0+(i.y1-i.y0)/2,a=i.x1+14,l="middle"):(o[0]/2>i.x0+t/2?(s=i.x0-6,l="end"):(s=i.x1+6,l="start"),a=i.y0+r/2),x.push({x:s,y:a,text:n+"",anchor:l,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:y,sceneEdges:p,labels:x}}},me={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,o){var r,n;if(0===t.length)return;const s=null!==(r=i.forceStrength)&&void 0!==r?r:.1,a=o[0]/2,c=o[1]/2,l=i.__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),i=null==l?void 0:l.get(e.id);t?u++:i?(e.x=i.x,e.y=i.y,u++):h.push(e)}const f=u>0&&.3>=(t.length>0?h.length/t.length:1);if(f){const i=new Map;for(const e of t)i.set(e.id,e);for(const t of h){const o=xe(t.id,e,i);if(o.length>0){let e=0,i=0;for(const t of o)e+=t.x,i+=t.y;const r=ve(t.id),n=r%360*(Math.PI/180),s=10+r%20;t.x=e/o.length+s*Math.cos(n),t.y=i/o.length+s*Math.sin(n)}else{const e=ve(t.id),i=e%360*(Math.PI/180),o=15+e%30;t.x=a+o*Math.cos(i),t.y=c+o*Math.sin(i)}}}else{const e=2.399963229728653;for(let i=0;t.length>i;i++){const o=t[i];if(null==o.x||null==o.y||0===o.x&&0===o.y){const t=10*Math.sqrt(i+.5),r=i*e;o.x=a+t*Math.cos(r),o.y=c+t*Math.sin(r)}}}const d=null!==(n=i.iterations)&&void 0!==n?n:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),g=0===i.iterations?0:f?40:d,y=be(i.nodeSize,i.nodeSizeRange,t),p=t=>y(t);if(g>0){const i=P().strength(t=>Math.min(2.5,t.weight?t.weight*s:s)).id(t=>t.id),o=E().force("charge",M().strength(t=>-25*p(t))).force("center",O(a,c).strength(.8)).force("x",T(a).strength(.15)).force("y",L(c).strength(.15));if(o.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}));o.force("link",i),o.force("link").links(t)}f?o.alpha(.3):.1>o.alpha()&&o.alpha(1),o.stop();for(let t=0;g>t;++t)o.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=p(e);e.x=Math.max(t,Math.min(o[0]-t,e.x)),e.y=Math.max(t,Math.min(o[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const m=new Map;for(const e of t)m.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=m.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=m.get(t.target);e&&(t.target=e)}}},buildScene(t,e,i,o){var r,n,s;const a=i.nodeStyle,c=i.edgeStyle,l=be(i.nodeSize,i.nodeSizeRange,t),u=Array.isArray(i.colorScheme)?i.colorScheme:m,h=new Map;t.forEach((t,e)=>{h.set(t.id,u[e%u.length])});const f=[],d=[],g=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=l(ge(e,"nodeSize")),i=a?a(ge(e,"nodeStyle")):{},o={fill:i.fill||h.get(e.id)||"#007bff",stroke:i.stroke||"#fff",strokeWidth:null!==(r=i.strokeWidth)&&void 0!==r?r:2,opacity:i.opacity};f.push({type:"circle",cx:e.x,cy:e.y,r:t,style:o,datum:e,id:e.id,label:e.id})}const y=new Map;for(const e of t)y.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:y.get(t.source),i="object"==typeof t.target?t.target:y.get(t.target);if(!e||!i)continue;if(null==e.x||null==e.y)continue;if(null==i.x||null==i.y)continue;const o=c?c(ge(t,"edgeStyle")):{},r={stroke:o.stroke||"#999",strokeWidth:null!==(n=o.strokeWidth)&&void 0!==n?n:1,opacity:null!==(s=o.opacity)&&void 0!==s?s:.6};d.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:r,datum:t})}if(!1!==i.showLabels){const e=(p=i.nodeLabel)?"function"==typeof p?p:t=>t[p]||t.id:null;for(const i of t){if(null==i.x||null==i.y)continue;const t=e?e(i):i.id;if(!t)continue;const o=l(ge(i,"nodeSize"));g.push({x:i.x,y:i.y-o-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var p;return{sceneNodes:f,sceneEdges:d,labels:g}}};function xe(t,e,i){const o=[];for(const r of e){const e="string"==typeof r.source?r.source:r.source.id,n="string"==typeof r.target?r.target:r.target.id;let s=null;if(e===t?s=n:n===t&&(s=e),s){const t=i.get(s);!t||0===t.x&&0===t.y||o.push({x:t.x,y:t.y})}}return o}function ve(t){let e=0;for(let i=0;t.length>i;i++)e=(e<<5)-e+t.charCodeAt(i)|0;return Math.abs(e)}function be(t,e,i){var o,r;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const n=e||[5,20],s=i.map(e=>{var i;return null===(i=e.data)||void 0===i?void 0:i[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===s.length)return()=>n[0];const c=null!==(o=x(s))&&void 0!==o?o:0,l=null!==(r=b(s))&&void 0!==r?r:1;if(c===l)return()=>(n[0]+n[1])/2;const u=a().domain([c,l]).range(n).clamp(!0);return e=>{var i;const o=null===(i=e.data)||void 0===i?void 0:i[t];return null==o||"number"!=typeof o?n[0]:u(o)}}const ke=m,Ae={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,i,o){if(0===t.length)return;const{padAngle:r=.01,groupWidth:n=20,sortGroups:s}=i,a=Math.min(o[0],o[1])/2,c=a-n,l=o[0]/2,u=o[1]/2,h=(f=i.valueAccessor)?"function"==typeof f?f:t=>{var e;return null!==(e=t[f])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var f;const d=new Map;for(let e=0;t.length>e;e++)d.set(t[e].id,e);const g=t.length,y=Array.from({length:g},()=>Array.from({length:g},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,i=d.get("string"==typeof t.source?t.source:t.source.id),o=d.get(e);if(void 0===i||void 0===o)continue;const r=h(t);y[i][o]=r}const p=z().padAngle(r);s&&p.sortGroups(s);const m=p(y),x=m.groups,v=D().innerRadius(c).outerRadius(a);for(const e of x){const i=t[e.index],o=v.centroid(e);i.x=o[0]+l,i.y=o[1]+u,i.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,i=b.get("string"==typeof t.source?t.source:t.source.id),o=b.get(e);i&&(t.source=i),o&&(t.target=o)}const k=new Map;for(const t of e)k.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 m){const i=t[e.source.index].id,o=t[e.target.index].id,r=k.get(`${i}\0${o}`)||k.get(`${o}\0${i}`);r&&(r.chordData=e)}},buildScene(t,e,i,o){var r,n;const{groupWidth:s=20,edgeOpacity:a=.5}=i,c=Math.min(o[0],o[1])/2,l=c-s,u=o[0]/2,h=o[1]/2,f=i.nodeStyle,d=i.edgeStyle,g=i.edgeColorBy||"source",y=Array.isArray(i.colorScheme)?i.colorScheme:ke,p=new Map;t.forEach((t,e)=>{p.set(t.id,y[e%y.length])});const m=$().radius(l),x=[],v=[],b=[];for(let e=0;t.length>e;e++){const i=t[e],o=i.arcData;if(!o)continue;let n;n=f?f(ge(i,"nodeStyle")).fill||p.get(i.id)||y[e%y.length]:p.get(i.id)||y[e%y.length];const s=f?f(ge(i,"nodeStyle")):{},a={fill:n,stroke:s.stroke||"black",strokeWidth:null!==(r=s.strokeWidth)&&void 0!==r?r:1,opacity:s.opacity};x.push({type:"arc",cx:u,cy:h,innerR:l,outerR:c,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:a,datum:i,id:i.id,label:i.id})}for(const t of e){const e=t.chordData;if(!e)continue;const i=m(e);if(!i)continue;const o=we(i,u,h);let r="#999";if(d)r=d(ge(t,"edgeStyle")).fill||r;else{const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;"target"===g&&i?r=p.get(i.id)||r:e&&(r=p.get(e.id)||r)}const s=d?d(ge(t,"edgeStyle")):{},c={fill:r,fillOpacity:null!==(n=s.fillOpacity)&&void 0!==n?n:a,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity};v.push({type:"ribbon",pathD:o,style:c,datum:t})}if(!1!==i.showLabels){const e=(k=i.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null,o=c+12;for(const i of t){const t=i.arcData;if(!t)continue;const r=e?e(i):i.id;if(!r)continue;const n=(t.startAngle+t.endAngle)/2,s=n-Math.PI/2;b.push({x:u+Math.cos(s)*o,y:h+Math.sin(s)*o,text:r+"",anchor:n>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var k;return{sceneNodes:x,sceneEdges:v,labels:b}}};function we(t,e,i){const o=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return t;const r=[];let n=0;for(;o.length>n;){const t=o[n];if("M"===t||"L"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)r.push(Number(o[n])+e+""),n++,o.length>n&&!isNaN(Number(o[n]))&&(r.push(Number(o[n])+i+""),n++);else if("C"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)for(let t=0;3>t&&o.length>n&&!isNaN(Number(o[n]));t++)r.push(Number(o[n])+e+""),n++,o.length>n&&!isNaN(Number(o[n]))&&(r.push(Number(o[n])+i+""),n++);else if("Q"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)for(let t=0;2>t&&o.length>n&&!isNaN(Number(o[n]));t++)r.push(Number(o[n])+e+""),n++,o.length>n&&!isNaN(Number(o[n]))&&(r.push(Number(o[n])+i+""),n++);else if("A"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&(r.push(Number(o[n])+e+""),n++),o.length>n&&(r.push(Number(o[n])+i+""),n++);else"Z"===t||"z"===t?(r.push(t),n++):(r.push(o[n]),n++)}return r.join(" ")}const Se=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function _e(t){const[e,i,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]}(t);return.299*e+.587*i+.114*o>150?"#222":"#fff"}function Pe(t,e,i){const o=e.nodeIDAccessor;return"function"==typeof o?o(t.data)+"":"string"==typeof o&&void 0!==t.data[o]?t.data[o]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+i}function Ee(t){return t?"function"==typeof t?t:e=>{var i;return(null===(i=e.data)||void 0===i?void 0:i[t])||e[t]||e.id}:null}function Me(t){return Array.isArray(t.colorScheme)?t.colorScheme:Se}function Oe(t){return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:"#4d430c"}function Te(t,e,i,o,r){if("horizontal"===r){const r=(t+i)/2;return`M ${t},${e} C ${r},${e} ${r},${o} ${i},${o}`}if("radial"===r){const r=(t+i)/2;return`M ${t},${e} Q ${r},${e} ${r},${(e+o)/2} T ${i},${o}`}{const r=(e+o)/2;return`M ${t},${e} C ${t},${r} ${i},${r} ${i},${o}`}}const Le={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,i,o){var r;const n=i.__hierarchyRoot;if(!n)return;const s=i.chartType,a=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(i.childrenAccessor),c=i.hierarchySum,l="function"==typeof c?c:"string"==typeof c?t=>{var e;return null!==(e=t[c])&&void 0!==e?e:0}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0},u=N(n,a);u.sum(l),u.sort((t,e)=>{var i,o;return(null!==(i=e.value)&&void 0!==i?i:0)-(null!==(o=t.value)&&void 0!==o?o:0)});const[h,f]=o;switch(s){case"tree":!function(t,e,i,o){const r=e.treeOrientation||"vertical",n=I();n.size("horizontal"===r?[o,i]:"radial"===r?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),n(t)}(u,i,h,f);break;case"cluster":!function(t,e,i,o){const r=e.treeOrientation||"vertical",n=C();n.size("horizontal"===r?[o,i]:"radial"===r?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),n(t)}(u,i,h,f);break;case"treemap":!function(t,e,i,o){var r,n;const s=null!==(r=e.padding)&&void 0!==r?r:4,a=null!==(n=e.paddingTop)&&void 0!==n?n:0,c=W().size([i,o]).tile(F).padding(s);a>0&&c.paddingTop(a),c(t)}(u,i,h,f);break;case"circlepack":!function(t,e,i,o){var r;const n=null!==(r=e.padding)&&void 0!==r?r:4;R().size([i,o]).padding(n)(t)}(u,i,h,f);break;case"partition":!function(t,e,i,o){var r;B().size([i,o]).padding(null!==(r=e.padding)&&void 0!==r?r:1)(t)}(u,i,h,f)}const d=u.descendants();t.length=0,e.length=0;const g=new Map;for(let e=0;d.length>e;e++){const o=d[e],n={id:Pe(o,i,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(r=o.value)&&void 0!==r?r:0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===s||"cluster"===s?$e(n,o,i):"treemap"===s||"partition"===s?ze(n,o):"circlepack"===s&&De(n,o),n.__hierarchyNode=o,t.push(n),g.set(o,n)}if("tree"===s||"cluster"===s)for(const t of d)if(t.parent){const i=g.get(t.parent),o=g.get(t);i&&o&&e.push({source:i,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,i,o){const r=i.nodeStyle||(()=>({})),n=i.edgeStyle||(()=>({}));switch(i.chartType){case"tree":case"cluster":return function(t,e,i,o,r,n){var s,a,c,l,u;const h=[],f=[],d=[],g=i.treeOrientation||"vertical",y="radial"===g,p=o[0]/2,m=o[1]/2,x="number"==typeof(v=i.nodeSize)?v:5;var v;for(const e of t){let t=e.x,o=e.y;y&&(t+=p,o+=m);const n=r(ge(e,"nodeStyle"));let a=n.fill||Oe(i);if(i.colorByDepth&&void 0!==e.depth){const t=Me(i);a=t[e.depth%t.length]}const c={fill:a,stroke:n.stroke||"#fff",strokeWidth:null!==(s=n.strokeWidth)&&void 0!==s?s:1,opacity:n.opacity};h.push({type:"circle",cx:t,cy:o,r:x,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const b=null!==(a=i.edgeOpacity)&&void 0!==a?a:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let o=e.x,r=e.y,s=i.x,a=i.y;y&&(o+=p,r+=m,s+=p,a+=m);const u=Te(o,r,s,a,g),h=n(ge(t,"edgeStyle")),d={fill:"none",stroke:h.stroke||"#999",strokeWidth:null!==(c=h.strokeWidth)&&void 0!==c?c:1.5,opacity:null!==(l=h.opacity)&&void 0!==l?l:b};f.push({type:"curved",pathD:u,style:d,datum:t})}if(!1!==i.showLabels){const e=Ee(i.nodeLabel);for(const i of t){const t=e?e(i):i.id;if(!t)continue;let o,r,n,s=i.x,a=i.y;if(y&&(s+=p,a+=m),y){const t=s-p,e=a-m,i=Math.sqrt(t*t+e*e);i>0?(o=s+t/i*10,r=a+e/i*10,n=0>t?"end":"start"):(o=s,r=a-12,n="middle")}else"horizontal"===g?((null===(u=i.data)||void 0===u?void 0:u.children)&&0!==i.data.children.length?(o=s-x-6,n="end"):(o=s+x+6,n="start"),r=a):(o=s,r=a+x+14,n="middle");d.push({x:o,y:r,text:t+"",anchor:n,baseline:"middle",fontSize:11})}}return{sceneNodes:h,sceneEdges:f,labels:d}}(t,e,i,o,r,n);case"treemap":case"partition":return function(t,e,i,o){var r,n;const s=[],a=[];for(const i of t){const t=i.x1-i.x0,n=i.y1-i.y0;if(0>=t||0>=n)continue;const a=o(ge(i,"nodeStyle"));let c=a.fill||Oe(e);if(e.colorByDepth&&void 0!==i.depth){const t=Me(e);c=t[i.depth%t.length]}const l={fill:c,stroke:a.stroke||"#fff",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.opacity};s.push({type:"rect",x:i.x0,y:i.y0,w:t,h:n,style:l,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Ee(e.nodeLabel),r=e.labelMode||"leaf",s="partition"===e.chartType;for(const c of t){const t=c.x1-c.x0,l=c.y1-c.y0;if(0>=t||0>=l)continue;const u=!((null===(n=c.data)||void 0===n?void 0:n.children)&&c.data.children.length>0);if(!s){if("leaf"===r&&!u)continue;if("parent"===r&&u)continue}const h=i?i(c):c.id;if(!h)continue;if((u?30:40)>t||(u?16:14)>l)continue;let f=o(ge(c,"nodeStyle")).fill||Oe(e);if(e.colorByDepth&&void 0!==c.depth){const t=Me(e);f=t[c.depth%t.length]}const d=_e(f);a.push(u?{x:c.x0+t/2,y:c.y0+l/2,text:h+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,l)/6)),fill:d}:{x:c.x0+4,y:c.y0+12,text:h+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:d})}}return{sceneNodes:s,sceneEdges:[],labels:a}}(t,i,0,r);case"circlepack":return function(t,e,i,o){var r,n,s,a,c;const l=[],u=[];for(const i of t){const t=null!==(r=i.__radius)&&void 0!==r?r:5;if(0>=t)continue;const a=o(ge(i,"nodeStyle"));let c=a.fill||Oe(e);if(e.colorByDepth&&void 0!==i.depth){const t=Me(e);c=t[i.depth%t.length]}const u={fill:c,stroke:a.stroke||"#fff",strokeWidth:null!==(n=a.strokeWidth)&&void 0!==n?n:1,opacity:null!==(s=a.opacity)&&void 0!==s?s:.7};l.push({type:"circle",cx:i.x,cy:i.y,r:t,style:u,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Ee(e.nodeLabel);for(const r of t){const t=null!==(a=r.__radius)&&void 0!==a?a:5,n=i?i(r):r.id;if(!n)continue;if(15>t)continue;const s=!((null===(c=r.data)||void 0===c?void 0:c.children)&&r.data.children.length>0);let l=o(ge(r,"nodeStyle")).fill||Oe(e);if(e.colorByDepth&&void 0!==r.depth){const t=Me(e);l=t[r.depth%t.length]}if(s){const e=_e(l);u.push({x:r.x,y:r.y,text:n+"",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:n+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:"#000",stroke:"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:l,sceneEdges:[],labels:u}}(t,i,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function $e(t,e,i){const o=i.treeOrientation||"vertical";if("radial"===o){const i=e.x,o=e.y;t.x=o*Math.cos(i-Math.PI/2),t.y=o*Math.sin(i-Math.PI/2)}else"horizontal"===o?(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 ze(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 De(t,e){var i;const o=null!==(i=e.r)&&void 0!==i?i:0;t.x=e.x,t.y=e.y,t.x0=e.x-o,t.x1=e.x+o,t.y0=e.y-o,t.y1=e.y+o,t.width=2*o,t.height=2*o,t.__radius=o}function je(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const Ne={sankey:pe,force:me,chord:Ae,tree:Le,cluster:Le,treemap:Le,circlepack:Le,partition:Le,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,i,o){const r=i.__hierarchyRoot;r&&function(t,e,i,o,r){var n,s;const a=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(i.childrenAccessor),c=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>{var i;return(null!==(i=t[e])&&void 0!==i?i:"")+""}}(i.nodeIDAccessor),l=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(i.orbitMode),u=null!==(n=i.orbitSize)&&void 0!==n?n:2.95,h=null!==(s=i.orbitEccentricity)&&void 0!==s?s:1,f="number"==typeof u?()=>u:u,d="number"==typeof h?()=>h:h,g=je(i);g.metaMap.clear(),o.length=0,r.length=0;const y=new Map;function p(t){var e;const i=null!==(e=y.get(t))&&void 0!==e?e:0;return y.set(t,i+1),0===i?t:`${t}__${i}`}const m=e[0]/2,x=e[1]/2,v=Math.min(e[0],e[1])/2*.85,b=p(c(t));o.push({id:b,x:m,y:x,x0:m,x1:m,y0:x,y1:x,width:0,height:0,value:0,depth:0,data:t}),g.metaMap.set(b,{ring:v,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,i,n,s,u,h,y){const m=a(e);if(!(null==m?void 0:m.length))return;const x=m.length;let v=0,b=0,k=0;for(;x>b;)b+=l[Math.min(k,l.length-1)],k++,v++;let A=0;for(let x=0;v>x;x++){const b=l[Math.min(x,l.length-1)],k=m.slice(A,A+b);if(!k.length)break;const w=(x+1)/v,S={id:i,depth:h,data:e,parentId:i},_=y?u/f(S)*w:u*w,P=j().value(t=>{var e;return(null===(e=a(t))||void 0===e?void 0:e.length)?4:1}).sort(null),E=P(k),M=d(S);for(let e=0;k.length>e;e++){const a=(E[e].startAngle+E[e].endAngle)/2,l=k[e],u=p(c(l)),f=n+_*Math.sin(a),d=s+_*Math.cos(a)*M;o.push({id:u,x:f,y:d,x0:f,x1:f,y0:d,y1:d,width:0,height:0,value:0,depth:h,data:l}),g.metaMap.set(u,{ring:_,angle:a,depth:h,parentId:i,eccentricity:M}),r.push({source:i,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:u}}),t(l,u,f,d,_,h+1,!0)}A+=b}}(t,b,m,x,v,1,!1)}(r,o,i,t,e)},buildScene(t,e,i,o){var r,n,s,a,c;const l=i.nodeStyle,u=i.nodeSize,h="number"==typeof u?()=>u:"function"==typeof u?u:()=>6,f=[],d=[],g=[];if(!1!==i.orbitShowRings){const e=je(i),o=new Map;for(const e of t)o.set(e.id,e);const r=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=o.get(t.parentId);if(!e)continue;const i=`${t.parentId}:${t.ring}`;r.has(i)||r.set(i,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const n=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:i,ecc:o}]of r)for(let r=0;n>r;r++){const a=r/n*Math.PI*2,c=(r+1)/n*Math.PI*2;d.push({type:"line",x1:t+i*Math.sin(a),y1:e+i*Math.cos(a)*o,x2:t+i*Math.sin(c),y2:e+i*Math.cos(c)*o,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=h(ge(e,"nodeSize")),i=l?l(ge(e,"nodeStyle")):{},o={fill:i.fill||"#6366f1",stroke:i.stroke||"#fff",strokeWidth:null!==(r=i.strokeWidth)&&void 0!==r?r:1,opacity:null!==(n=i.opacity)&&void 0!==n?n:0===(null!==(s=e.depth)&&void 0!==s?s:0)?1:.85};f.push({type:"circle",cx:e.x,cy:e.y,r:t,style:o,datum:e,id:e.id,label:e.id,depth:e.depth})}const y=new Map;for(const e of t)y.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:y.get(t.source),i="object"==typeof t.target?t.target:y.get(t.target);e&&i&&(null!=e.x&&null!=i.x&&d.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(i.showLabels){const e=i.nodeLabel;for(const i of t){const t=h(ge(i,"nodeSize"));if(4>=t)continue;const o="function"==typeof e?e(i):e&&null!==(c=null===(a=i.data)||void 0===a?void 0:a[e])&&void 0!==c?c:i.id;g.push({x:i.x,y:i.y+t+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:f,sceneEdges:d,labels:g}},tick:(t,e,i,o,r)=>!1!==i.orbitAnimated&&(function(t,e){var i,o;const r=je(e),n=null!==(i=e.orbitSpeed)&&void 0!==i?i:.25,s=null!==(o=e.orbitRevolution)&&void 0!==o?o: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 i=null!==(e=t.depth)&&void 0!==e?e:0;return(i%2==0?1:-1)/(i+1)};default:return t=>{var e;return 1/((null!==(e=t.depth)&&void 0!==e?e:0)+1)}}}(e.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-r.startTime)/1e3,c=n*(Math.PI/6),l=new Map;for(const e of t)l.set(e.id,e);for(const e of t){const t=r.metaMap.get(e.id);if(!t||!t.parentId)continue;const i=l.get(t.parentId);if(!i)continue;const o=t.angle+a*c*s({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=i.x+t.ring*Math.sin(o),e.y=i.y+t.ring*Math.cos(o)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,i),!0)}};function Be(t,e){const{columns:i,config:o,resolvePieceStyle:r}=t,n=[],s=Math.min(e.width,e.height)/2-4,a="donut"===o.chartType?o.innerRadius||60:0,c=-Math.PI/2+(o.startAngle||0)*Math.PI/180,l=null!=o.sweepAngle?o.sweepAngle*Math.PI/180:2*Math.PI;for(const t of Object.values(i)){const e=c+t.pctStart*l,i=c+(t.pctStart+t.pct)*l,u=r(t.pieceData[0],t.name);n.push(Object.assign(Object.assign({type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:e,endAngle:i},o.cornerRadius&&{cornerRadius:o.cornerRadius}),{style:u,datum:t.pieceData,category:t.name}))}return n}function Re(t){var e,i,o;const r=t.length,n=t[0],s=t[r-1];return{n:r,min:n,q1:null!==(e=S(t,.25))&&void 0!==e?e:n,median:null!==(i=S(t,.5))&&void 0!==i?i:(n+s)/2,q3:null!==(o=S(t,.75))&&void 0!==o?o:s,max:s,mean:t.reduce((t,e)=>t+e,0)/r}}const We={bar:function(t,e){var i;const{scales:o,columns:r,config:n,getR:s,getStack:a,resolvePieceStyle:c}=t,{r:l,projection:u}=o,h=[],f="vertical"===u,d="horizontal"===u,g=n.normalize,y=[];if(a){const t=new Set;for(const e of Object.values(r))for(const i of e.pieceData){const e=a(i);t.has(e)||(t.add(e),y.push(e))}}else y.push("_default");for(const t of Object.values(r)){const e=new Map;for(const i of t.pieceData){const t=a?a(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t);o.total+=s(i),o.pieces.push(i)}let i=0;if(g)for(const t of e.values())i+=Math.abs(t.total);let o=0,r=0;for(const n of y){const s=e.get(n);if(!s)continue;let u=s.total;g&&i>0&&(u/=i);const y=c(s.pieces[0],a?n:t.name),p=Object.assign(Object.assign({},s.pieces[0]),{__aggregateValue:s.total,__pieceCount:s.pieces.length,category:t.name});if(f){const e=l(0>u?r:o+u),i=0>u?l(r+u)-l(r):l(o)-l(o+u);h.push(xt(t.x,e,t.width,Math.abs(i),y,p,n)),0>u?r+=u:o+=u}else if(d){const e=l(0>u?r+u:o),i=0>u?l(r)-l(r+u):l(o+u)-l(o);h.push(xt(e,t.x,Math.abs(i),t.width,y,p,n)),0>u?r+=u:o+=u}}}if(n.roundedTop&&n.roundedTop>0){const t=Math.max(0,n.roundedTop),e=new Map;for(const t of h){if("rect"!==t.type)continue;const o=(null===(i=t.datum)||void 0===i?void 0:i.category)||"";e.has(o)||e.set(o,[]),e.get(o).push(t)}const o="vertical"===u;for(const i of e.values()){if(0===i.length)continue;const e=i.filter(t=>{var e,i;return(null!==(i=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==i?i:0)>=0}),r=i.filter(t=>{var e,i;return 0>(null!==(i=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==i?i:0)});if(e.length>0){const i=e.reduce(o?(t,e)=>e.y>t.y?t:e:(t,e)=>t.x+t.w>e.x+e.w?t:e);i.roundedTop=t,i.roundedEdge=o?"top":"right"}if(r.length>0){const e=r.reduce(o?(t,e)=>t.y+t.h>e.y+e.h?t:e:(t,e)=>e.x>t.x?t:e);e.roundedTop=t,e.roundedEdge=o?"bottom":"left"}}}return h},clusterbar:function(t,e){const{scales:i,columns:o,config:r,getR:n,getGroup:s,resolvePieceStyle:a}=t,{r:c,projection:l}=i,u=[],h="vertical"===l,f=[],d=new Set;for(const t of Object.values(o))for(const e of t.pieceData){const t=s?s(e):"_default";d.has(t)||(d.add(t),f.push(t))}const g=f.length||1;for(const t of Object.values(o)){const e=t.width/g,i=.2*e,o=e-i,r=new Map;for(const e of t.pieceData){const t=s?s(e):"_default";r.has(t)||r.set(t,[]),r.get(t).push(e)}for(let s=0;f.length>s;s++){const l=r.get(f[s])||[];for(const r of l){const l=n(r),d=a(r,f[s]);if(h){const n=t.x+s*e+i/2,a=c(0),h=c(l);u.push(xt(n,Math.min(a,h),o,Math.abs(a-h),d,r,f[s]))}else{const n=t.x+s*e+i/2,a=c(0),h=c(l);u.push(xt(Math.min(a,h),n,Math.abs(h-a),o,d,r,f[s]))}}}}if(r.roundedTop&&r.roundedTop>0){const t=Math.max(0,r.roundedTop);for(const e of u){if("rect"!==e.type)continue;const i=n(e.datum);e.roundedTop=t,e.roundedEdge=h?0>i?"bottom":"top":0>i?"left":"right"}}return u},point:function(t,e){var i,o;const{scales:r,columns:n,getR:s,multiScales:a,resolvePieceStyle:c}=t,{r:l,projection:u}=r,h=[],f="vertical"===u,d="radial"===u,g=a.length>0,y=2*Math.PI,p=-Math.PI/2;for(const t of Object.values(n))for(const e of t.pieceData){const r=null!==(i=e.__rIndex)&&void 0!==i?i:0,n=null!==(o=e.__rValue)&&void 0!==o?o:s(e),u=g&&a[r]||l,m=c(e,t.name),x=m.r||5;let v,b;if(d){const e=p+(t.pctStart+t.pct/2)*y,i=u(n);v=Math.cos(e)*i,b=Math.sin(e)*i}else f?(v=t.middle,b=u(n)):(v=u(n),b=t.middle);h.push({type:"point",x:v,y:b,r:x,style:m,datum:e})}return h},swarm:function(t,e){const{scales:i,columns:o,getR:r,resolvePieceStyle:n}=t,{r:s,projection:a}=i,c=[],l="vertical"===a;for(const t of Object.values(o)){const e=t.width/2;for(let i=0;t.pieceData.length>i;i++){const o=t.pieceData[i],a=r(o),u=n(o,t.name),h=u.r||4,f=(7919*i%100/100-.5)*e*.8,d=l?t.middle+f:s(a),g=l?s(a):t.middle+f;c.push({type:"point",x:d,y:g,r:h,style:u,datum:o})}}return c},pie:Be,donut:Be,boxplot:function(t,e){var i,o,r,n,s;const{scales:a,columns:c,config:l,getR:u,resolveSummaryStyle:h}=t,{r:f,projection:d}=a,g=[],y="vertical"===d,p=!1!==l.showOutliers;for(const t of Object.values(c)){const e=t.pieceData.map(t=>u(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===e.length)continue;const a=e[0],c=e[e.length-1],l=null!==(i=S(e,.25))&&void 0!==i?i:a,d=null!==(o=S(e,.5))&&void 0!==o?o:(a+c)/2,m=null!==(r=S(e,.75))&&void 0!==r?r:c,x=m-l,v=l-1.5*x,b=m+1.5*x,k=null!==(n=e.find(t=>t>=v))&&void 0!==n?n:a,A=null!==(s=[...e].reverse().find(t=>b>=t))&&void 0!==s?s:c,w=h(t.pieceData[0],t.name),_=[];if(p)for(const e of t.pieceData){const i=u(e);if(v>i||i>b){const o=y?t.middle:f(i),r=y?f(i):t.middle;_.push({px:o,py:r,value:i,datum:e})}}if(g.push({type:"boxplot",x:y?t.middle:0,y:y?0:t.middle,projection:y?"vertical":"horizontal",columnWidth:.6*t.width,minPos:f(k),q1Pos:f(l),medianPos:f(d),q3Pos:f(m),maxPos:f(A),stats:{n:e.length,min:k,q1:l,median:d,q3:m,max:A,mean:e.reduce((t,e)=>t+e,0)/e.length},style:w,datum:t.pieceData,category:t.name,outliers:_}),p)for(const t of _)g.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:w.fill||"#999",opacity:.6},datum:t.datum})}return g},violin:function(t,e){var i,o,r;const{scales:n,columns:s,config:a,getR:c,resolveSummaryStyle:l}=t,{r:u,projection:h}=n,f=[],d="vertical"===h,g=a.bins||20,y=!1!==a.showIQR;for(const t of Object.values(s)){const e=t.pieceData.map(t=>c(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const n=e[0],s=e[e.length-1],a=(s-n)/g||1,h=Array(g).fill(0);for(const t of e)h[Math.min(Math.floor((t-n)/a),g-1)]++;const p=Math.max(...h,1),m=t.width/2*.9;let x="";if(d){x=`M ${t.middle} ${u(n)}`;for(let e=0;g>e;e++){const i=u(n+(e+.5)*a);x+=` L ${t.middle+h[e]/p*m} ${i}`}x+=` L ${t.middle} ${u(s)}`;for(let e=g-1;e>=0;e--){const i=u(n+(e+.5)*a);x+=` L ${t.middle-h[e]/p*m} ${i}`}x+=" Z"}else{x=`M ${u(n)} ${t.middle}`;for(let e=0;g>e;e++)x+=` L ${u(n+(e+.5)*a)} ${t.middle-h[e]/p*m}`;x+=` L ${u(s)} ${t.middle}`;for(let e=g-1;e>=0;e--)x+=` L ${u(n+(e+.5)*a)} ${t.middle+h[e]/p*m}`;x+=" Z"}const v=l(t.pieceData[0],t.name);let b;if(y&&e.length>=4){const a=null!==(i=S(e,.25))&&void 0!==i?i:n,c=null!==(o=S(e,.5))&&void 0!==o?o:(n+s)/2,l=null!==(r=S(e,.75))&&void 0!==r?r:s;b={q1Pos:u(a),medianPos:u(c),q3Pos:u(l),centerPos:t.middle,isVertical:d}}const k=d?{x:t.x,y:Math.min(u(s),u(n)),width:t.width,height:Math.abs(u(s)-u(n))}:{x:Math.min(u(n),u(s)),y:t.x,width:Math.abs(u(s)-u(n)),height:t.width};f.push({type:"violin",pathString:x,translateX:0,translateY:0,bounds:k,iqrLine:b,stats:Re(e),style:v,datum:t.pieceData,category:t.name})}return f},histogram:function(t,e){var i;const{scales:o,columns:r,config:n,getR:s,resolveSummaryStyle:a}=t,{r:c}=o,l=[],u=n.bins||25,h=n.normalize,f=null===(i=c.domain)||void 0===i?void 0:i.call(c),d=f?+f[0]:void 0,g=f?+f[1]:void 0;for(const t of Object.values(r)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const i=null!=d&&isFinite(d)?d:Math.min(...e),o=null!=g&&isFinite(g)?g:Math.max(...e),r=(o-i)/u||1,n=Array(u).fill(0);for(const t of e)i>t||t>o||n[Math.min(Math.floor((t-i)/r),u-1)]++;const f=e.length,y=Math.max(...n,1),p=a(t.pieceData[0],t.name);for(let e=0;u>e;e++){if(0===n[e])continue;const o=(h?n[e]/f:n[e]/y)*t.width*.9,s=c(i+e*r),a=c(i+(e+1)*r);l.push(xt(Math.min(s,a),t.x+t.width-o,Math.abs(a-s),o,p,{bin:e,count:n[e],range:[i+e*r,i+(e+1)*r],category:t.name},t.name))}}return l},ridgeline:function(t,e){var i;const{scales:o,columns:r,config:n,getR:s,resolveSummaryStyle:a}=t,{r:c,projection:l}=o,u=[],h=n.bins||20,f="horizontal"===l,d=n.amplitude||1.5;for(const t of Object.values(r)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const o=e[0],r=e[e.length-1],n=(r-o)/h||1,l=Array(h).fill(0);for(const t of e)o>t||t>r||l[Math.min(Math.floor((t-o)/n),h-1)]++;const g=Math.max(...l,1),y=a(t.pieceData[0],t.name),p=t.width*d;let m="";if(f){const e=t.x+t.width;m=`M ${c(o)} ${e}`;for(let t=0;h>t;t++)m+=` L ${c(o+(t+.5)*n)} ${e-l[t]/g*p}`;m+=` L ${c(r)} ${e} Z`}else{const e=t.x;m=`M ${e} ${c(o)}`;for(let t=0;h>t;t++){const i=c(o+(t+.5)*n);m+=` L ${e+l[t]/g*p} ${i}`}m+=` L ${e} ${c(r)} Z`}const x=f?{x:Math.min(c(o),c(r)),y:t.x,width:Math.abs(c(r)-c(o)),height:t.width}:{x:t.x,y:Math.min(c(r),c(o)),width:t.width,height:Math.abs(c(r)-c(o))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:x,stats:Re(e),style:Object.assign(Object.assign({},y),{fillOpacity:null!==(i=y.fillOpacity)&&void 0!==i?i:.5}),datum:t.pieceData,category:t.name})}return u},timeline:function(t,e){const{scales:i,columns:o,getRawRange:r,resolvePieceStyle:n}=t,{r:s,projection:a}=i,c=[],l="horizontal"===a;for(const t of Object.values(o))for(const e of t.pieceData){const i=r(e);if(!i)continue;const[o,a]=i,u=n(e,t.name);if(l){const i=s(Math.min(o,a)),r=s(Math.max(o,a));c.push(xt(i,t.x,r-i,t.width,u,e,t.name))}else{const i=s(Math.max(o,a)),r=s(Math.min(o,a));c.push(xt(t.x,i,t.width,r-i,u,e,t.name))}}return c},funnel:function(t,e){var i,o,r,n,s,c,l;const{columns:u,getR:h,getStack:f,resolvePieceStyle:d}=t,g=[],y=e.width/2,p=!1!==t.config.showLabels,m=t.scales.o.domain().map(t=>u[t]).filter(Boolean);if(0===m.length)return g;const x=[],v=new Set;for(const t of m)for(const e of t.pieceData){const t=f?f(e):"_default";v.has(t)||(v.add(t),x.push(t))}const b=x.length>1&&"_default"!==x[0],k=[];let A=0;for(const t of m){const e=new Map;let i=0;for(const o of t.pieceData){const t=f?f(o):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const r=e.get(t),n=h(o);r.total+=n,r.pieces.push(o),i+=n}k.push({col:t,groups:e,stepTotal:i}),b||i>A&&(A=i)}if(b)for(const t of k){let e=0,i=0;for(let o=0;x.length>o;o++){const r=t.groups.get(x[o]);r&&(o%2==0?e+=r.total:i+=r.total)}const o=Math.max(e,i);o>A&&(A=o)}if(0===A)return g;const w=new Map;for(const t of x){const e=k[0].groups.get(t);w.set(t,null!==(i=null==e?void 0:e.total)&&void 0!==i?i:0)}const S=k[0].stepTotal,_=b?.95*y:.9*e.width,P=a().domain([0,A]).range([0,_]),E=null!==(o=t.config.connectorOpacity)&&void 0!==o?o:.3;let M=new Map;for(let t=0;k.length>t;t++){const e=k[t],i=e.col,o=0===t,a=i.width,u=.55*a,h=i.x+(a-u)/2,f=new Map;if(b){let t=0;for(const i of x){const o=e.groups.get(i);o&&(t+=P(o.total))}let r=y,n=y;for(let a=0;x.length>a;a++){const c=x[a],l=e.groups.get(c);if(!l)continue;const m=P(l.total),v=a%2==0,b=v?r:n-m;v?r+=m:n-=m;const k=d(l.pieces[0],c),A=null!==(s=w.get(c))&&void 0!==s?s:l.total,S=A>0?l.total/A*100:0,_=Object.assign(Object.assign({},l.pieces[0]),{__funnelValue:l.total,__funnelPercent:S,__funnelStep:i.name,__funnelIsFirstStep:o,__aggregateValue:l.total,__pieceCount:l.pieces.length,category:c});p&&(0===a&&(_.__funnelStepLabel=i.name,_.__funnelStepLabelX=y,_.__funnelStepLabelY=h,_.__funnelRowWidth=t),_.__funnelValueLabelX=b+m/2,_.__funnelValueLabelY=h,_.__funnelBarW=m),g.push(xt(b,h,m,u,k,_,c)),f.set(c,{x:b,y:h,w:m,h:u})}}else{const t=e.stepTotal,s=P(t),a=y-s/2,c=x[0],l="_default"!==c,m=null!==(n=null===(r=e.groups.get(c))||void 0===r?void 0:r.pieces[0])&&void 0!==n?n:i.pieceData[0],v=l?c:i.name,b=d(m,v),k=S>0?t/S*100:0,A=Object.assign(Object.assign({},m),{__funnelValue:t,__funnelPercent:k,__funnelStep:i.name,__funnelIsFirstStep:o,category:l?c:i.name});p&&(A.__funnelStepLabel=i.name,A.__funnelStepLabelX=y,A.__funnelStepLabelY=h,A.__funnelRowWidth=s,A.__funnelValueLabelX=y,A.__funnelValueLabelY=h,A.__funnelBarW=s),g.push(xt(a,h,s,u,b,A,v)),f.set(c,{x:a,y:h,w:s,h:u})}if(t>0&&M.size>0){const t=b?x:[x[0]];for(const o of t){const t=M.get(o),r=f.get(o);if(!t||!r)continue;const n=(()=>{const t=e.groups.get(o);return d(t?t.pieces[0]:i.pieceData[0],"_default"===o?i.name:o)})(),s={type:"trapezoid",points:[[t.x,t.y+t.h],[t.x+t.w,t.y+t.h],[r.x+r.w,r.y],[r.x,r.y]],style:{fill:n.fill||"#999",opacity:E},datum:null!==(l=null===(c=e.groups.get(o))||void 0===c?void 0:c.pieces[0])&&void 0!==l?l:i.pieceData[0],category:"_default"===o?i.name:o};g.push(s)}}M=f}return g},"bar-funnel":function(t,e){var i,o,r,n;const{columns:s,getR:a,getStack:c,resolvePieceStyle:l,scales:u}=t,h=[],f=u.o.domain().map(t=>s[t]).filter(Boolean);if(0===f.length)return h;const d=[],g=new Set;for(const t of f)for(const e of t.pieceData){const t=c?c(e):"_default";g.has(t)||(g.add(t),d.push(t))}const y=d.length>1&&"_default"!==d[0],p=[];for(const t of f){const e=new Map;let i=0;for(const o of t.pieceData){const t=c?c(o):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const r=e.get(t),n=a(o);r.total+=n,r.pieces.push(o),i+=n}p.push({col:t,groups:e,stepTotal:i})}const m=new Map;for(const t of d){const e=null===(i=p[0])||void 0===i?void 0:i.groups.get(t);m.set(t,null!==(o=null==e?void 0:e.total)&&void 0!==o?o:0)}const x=u.r,v=y?d.length:1,b=y?.15:0;for(let t=0;p.length>t;t++){const e=p[t],i=e.col,o=0===t,s=t>0?p[t-1]:null,a=i.width/v,c=a*b,u=a-c;for(let t=0;d.length>t;t++){const f=d[t],g=e.groups.get(f);if(!g)continue;const p=g.total,v=null!==(r=m.get(f))&&void 0!==r?r:p,b=v>0?p/v*100:0,k=null==s?void 0:s.groups.get(f),A=null!==(n=null==k?void 0:k.total)&&void 0!==n?n:p,w=o?0:Math.max(0,A-p),S=i.x+t*a+c/2,_=x(p),P=x(0)-_,E=l(g.pieces[0],y?f:i.name),M=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:p,__barFunnelPercent:b,__barFunnelIsFirstStep:o,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:w,__barFunnelCategory:"_default"===f?void 0:f,category:y?f:i.name,__barFunnelLabelX:S+u/2,__barFunnelLabelY:x(p+w)});if(h.push(xt(S,_,u,P,E,M,y?f:i.name)),w>0){const t=x(p+w),e=_-t,o=Object.assign({},E),r=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:w,__barFunnelPercent:v>0?w/v*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===f?void 0:f,category:y?f:i.name});h.push(xt(S,t,u,e,o,r,y?f:i.name))}}}return h},swimlane:function(t,e){const{scales:i,columns:o,getR:r,getStack:n,resolvePieceStyle:s}=t,{r:a,projection:c}=i,l=[],u="horizontal"===c;for(const t of Object.values(o)){let e=0;for(const i of t.pieceData){const o=Math.abs(r(i));if(0===o)continue;const c=n?n(i):t.name,h=s(i,c);if(u){const r=a(e),n=a(e+o);l.push(xt(r,t.x,n-r,t.width,h,i,c))}else{const r=a(e+o),n=a(e);l.push(xt(t.x,r,t.width,n-r,h,i,c))}e+=o}}return l}};class Fe{constructor(t){this.rExtent=new et,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.version=0,this.config=t,this.buffer=new tt(t.windowSize),this.getO=st(t.oAccessor||t.categoryAccessor,"category");const e="streaming"===t.runtimeMode,i=t.rAccessor;Array.isArray(i)?(this.rAccessors=i.map(t=>rt(t,"value")),this.getR=this.rAccessors[0],this.rExtents=i.map(()=>new et)):(this.getR=rt(e&&(t.timeAccessor||t.valueAccessor)&&t.valueAccessor||i,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=st(t.stackBy),this.getGroup=st(t.groupBy),this.getColor=st(t.colorAccessor),this.getConnector=st(t.connectorAccessor),this.getDataId=st(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new tt(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,t.bounded){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=t.totalSize||t.inserts.length;i>this.buffer.capacity&&(this.buffer.resize(i),this.timestampBuffer&&i>this.timestampBuffer.capacity&&this.timestampBuffer.resize(i));for(const i of t.inserts)this.buffer.push(i),this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i)}else{this._hasStreamingData=!0;for(const i of t.inserts){const t=this.buffer.push(i);this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i),null!=t&&this.evictValueExtent(t)}}return!0}pushValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.push(e[0]),this.rExtent.push(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].push(this.rAccessors[e](t));this.rExtent.push(this.getR(t))}else this.rExtent.push(this.getR(t))}evictValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.evict(e[0]),this.rExtent.evict(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].evict(this.rAccessors[e](t));this.rExtent.evict(this.getR(t))}else this.rExtent.evict(this.getR(t))}getRawRange(t){const e=this.config.rAccessor;if(!e)return null;const i="function"==typeof e?e(t):t[e];return Array.isArray(i)&&i.length>=2?[+i[0],+i[1]]:null}computeScene(t){const{config:e,buffer:i}=this;if(0===i.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(i,this.getR);const o=i.toArray(),r=e.projection||"vertical",n=e.oExtent||this.resolveCategories(o),s=this.computeValueDomain(o,n),c="horizontal"===r,l=null!=e.barPadding?e.barPadding/("vertical"===r?t.width:t.height):.1;let h,f;if("radial"===r){h=u().domain(n).range([0,1]).padding(0);const i=Math.min(t.width,t.height)/2,o=e.innerRadius||0;f=a().domain(s).range([o,i])}else c?(h=u().domain(n).range([0,t.height]).padding(l),f=a().domain(s).range([0,t.width])):(h=u().domain(n).range([0,t.width]).padding(l),f=a().domain(s).range([t.height,0]));this.scales={o:h,r:f,projection:r},this.multiScales=this.rAccessors.length>1&&e.multiAxis?this.rAccessors.map((o,r)=>{var n;const s=this.rExtents[r];s.dirty&&s.recalculate(i,o);let[l,u]=s.extent;l===1/0&&(l=0,u=1);const h=null!==(n=e.extentPadding)&&void 0!==n?n:.05,f=u-l,d=f>0?f*h:1;return l-=d,u+=d,l>0&&(l=0),c?a().domain([l,u]).range([0,t.width]):a().domain([l,u]).range([t.height,0])}):[];let d=o;this.rAccessors.length>1&&(d=o.flatMap(t=>this.rAccessors.map((e,i)=>Object.assign(Object.assign({},t),{__rIndex:i,__rValue:e(t),__rName:this.resolveRAccessorName(i)})))),this.columns=this.buildColumns(d,n,h,r,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(d,t),this.config.decay&&this.applyDecay(this.scene,o),this.config.pulse&&this.applyPulse(this.scene,o),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(t){const e=Array.isArray(this.config.rAccessor)?this.config.rAccessor[t]:this.config.rAccessor;return"string"==typeof e?e:"value"+t}resolveCategories(t){const e=Array.from(this.categories),i=this.config.oSort;if(("streaming"===this.config.runtimeMode||this._hasStreamingData)&&void 0===i){const i=new Set;for(const e of t)i.add(this.getO(e));const o=Math.max(50,3*i.size);if(this.categories.size>o){let t=this.categories.size-o;for(const e of this.categories){if(0>=t)break;i.has(e)||(this.categories.delete(e),t--)}}return e.filter(t=>i.has(t))}if(!1===i)return e;if("function"==typeof i)return e.sort(i);const o=new Map;for(const e of t){const t=this.getO(e);o.set(t,(o.get(t)||0)+Math.abs(this.getR(e)))}return e.sort("asc"===i?(t,e)=>(o.get(t)||0)-(o.get(e)||0):(t,e)=>(o.get(e)||0)-(o.get(t)||0))}computeValueDomain(t,e){var i,o,r,n,s;const a=this.config.chartType,c=null!==(i=this.config.extentPadding)&&void 0!==i?i:.05;if("radial"===this.config.projection&&("pie"===a||"donut"===a))return[0,1];let l=0,u=0;if("bar"===a&&this.getStack&&this.config.normalize)l=0,u=1;else if("bar"===a&&this.getStack){const e=new Map,i=new Map;for(const o of t){const t=this.getO(o),r=this.getR(o);0>r?i.set(t,(i.get(t)||0)+r):e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>u&&(u=t);for(const t of i.values())l>t&&(l=t)}else if("bar"===a){const e=new Map;for(const i of t){const t=this.getO(i),o=this.getR(i);e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>u&&(u=t),l>t&&(l=t)}else if("swimlane"===a){const e=new Map;for(const i of t){const t=this.getO(i),o=Math.abs(this.getR(i));e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>u&&(u=t)}else if("clusterbar"===a||"bar-funnel"===a)for(const e of t){const t=this.getR(e);t>u&&(u=t),l>t&&(l=t)}else{const t=this.rExtent.extent[0],e=this.rExtent.extent[1];t!==1/0&&(l=t),e!==-1/0&&(u=e)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(l=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(u=this.config.rExtent[1]));const h="bar"===a||"clusterbar"===a||"bar-funnel"===a||"swimlane"===a;if(h&&null==(null===(o=this.config.rExtent)||void 0===o?void 0:o[0])&&null==(null===(r=this.config.rExtent)||void 0===r?void 0:r[1])&&(l>0&&(l=0),0>u&&(u=0)),"bar-funnel"!==a){const t=u-l,e=t>0?t*c:1;null!=(null===(n=this.config.rExtent)||void 0===n?void 0:n[0])||h&&!this.config.baselinePadding&&0===l||(l-=e),null!=(null===(s=this.config.rExtent)||void 0===s?void 0:s[1])||h&&!this.config.baselinePadding&&0===u||"swimlane"===a||(u+=e)}return[l,u]}buildColumns(t,e,i,o,r){var n;const s={},a=new Map;for(const e of t){const t=this.getO(e);a.has(t)||a.set(t,[]),a.get(t).push(e)}let c=0;if("radial"===o)for(const e of t)c+=Math.abs(this.getR(e));const l=this.config.dynamicColumnWidth;let u=null;if(l&&"radial"!==o){u=new Map;let t=0;for(const i of e){const e=a.get(i)||[];let o;o="string"==typeof l?e.reduce((t,e)=>t+(Number(e[l])||0),0):l(e),u.set(i,o),t+=o}const n=("horizontal"===o?r.height:r.width)-i.padding()*i.step()*e.length;if(t>0)for(const[e,i]of u)u.set(e,i/t*n)}let h=0,f=0;for(const t of e){const e=a.get(t)||[],o=e.reduce((t,e)=>t+Math.abs(this.getR(e)),0),r=c>0?o/c:0;let l,d;u?(l=f,d=u.get(t)||i.bandwidth(),f+=d+i.padding()*i.step()):(l=null!==(n=i(t))&&void 0!==n?n:0,d=i.bandwidth()),s[t]={name:t,x:l,y:0,width:d,middle:l+d/2,padding:i.padding()*i.step(),pieceData:e,pct:r,pctStart:h},h+=r}return s}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(t,e)=>this.resolvePieceStyle(t,e),resolveSummaryStyle:(t,e)=>this.resolveSummaryStyle(t,e),getRawRange:t=>this.getRawRange(t)}}buildSceneNodes(t,e){if(!this.scales)return[];const i=this.getSceneContext(),o=We[this.config.chartType];let r=o?o(i,e):[];if(this.getConnector&&this.scales){const t=function(t,e){const{scales:i,config:o,getConnector:r,getO:n}=t;if(!r||!i)return[];const s=[],{projection:a}=i,c=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const i=r(e);if(!i)continue;let o,s;"point"===t.type?(o=t.x,s=t.y):(o=t.x+t.w/2,s=t.y+("vertical"===a?0:t.h/2)),c.has(i)||c.set(i,[]),c.get(i).push({x:o,y:s,datum:e,category:n(e)})}const l=i.o.domain(),u=o.connectorStyle;for(const[t,e]of c)if(e.length>=2){e.sort((t,e)=>l.indexOf(t.category)-l.indexOf(e.category));for(let i=0;e.length-1>i;i++){const o=e[i],r=e[i+1],n="function"==typeof u?u(o.datum):u||{stroke:"#999",strokeWidth:1,opacity:.5};s.push({type:"connector",x1:o.x,y1:o.y,x2:r.x,y2:r.y,style:n,datum:o.datum,group:t})}}return s}(i,r);r=[...t,...r]}return r}resolvePieceStyle(t,e){if("function"==typeof this.config.pieceStyle){const i=this.config.pieceStyle(t,e);return i&&!i.fill&&e?Object.assign(Object.assign({},i),{fill:this.getColorFromScheme(e)}):i}return this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&e?{fill:this.config.barColors[e]||"#007bff"}:e?{fill:this.getColorFromScheme(e)}:{fill:"#007bff"}}getColorFromScheme(t){this._colorSchemeMap||(this._colorSchemeMap=new Map);const e=this._colorSchemeMap.get(t);if(e)return e;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:at,o=i[this._colorSchemeIndex%i.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(t,o),o}resolveSummaryStyle(t,e){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(t,e):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?ct(i,t,e):1}applyDecay(t,e){var i,o;if(!this.config.decay)return;const r=e.length;if(1>=r)return;const n=new Map;for(let t=0;e.length>t;t++)n.set(e[t],t);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;const t=n.get(e.datum);if(null==t)continue;const s=this.computeDecayOpacity(t,r),a=null!==(o=null===(i=e.style)||void 0===i?void 0:i.opacity)&&void 0!==o?o:1;e.style=Object.assign(Object.assign({},e.style),{opacity:a*s})}}applyPulse(t,e){var i,o,r;if(!this.config.pulse||!this.timestampBuffer)return;const n="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(i=this.config.pulse.duration)&&void 0!==i?i:500,a=null!==(o=this.config.pulse.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",c=null!==(r=this.config.pulse.glowRadius)&&void 0!==r?r:4,l=new Map;for(let t=0;e.length>t;t++)l.set(e[t],t);for(const i of t){if("connector"===i.type||"violin"===i.type||"boxplot"===i.type)continue;if("wedge"===i.type){const t=i.category;if(!t)continue;let o=0;for(let i=0;e.length>i;i++){const r=e[i],a=this.config.oAccessor;if(("function"==typeof a?a(r):r[a||"category"])!==t)continue;const c=this.timestampBuffer.get(i);if(null==c)continue;const l=n-c;if(s>l){const t=1-l/s;t>o&&(o=t)}}o>0&&(i._pulseIntensity=o,i._pulseColor=a);continue}const t=l.get(i.datum);if(null==t)continue;const o=this.timestampBuffer.get(t);if(null==o)continue;const r=n-o;s>r&&(i._pulseIntensity=1-r/s,i._pulseColor=a,i._pulseGlowRadius=c)}}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(),i=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,o=this.timestampBuffer.peek();return null!=o&&i>e-o}getNodeKey(t,e){var i,o;if("point"===t.type){const i=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,o=e.get(i)||0;return e.set(i,o+1),`${i}:${o}`}return"rect"===t.type?`r:${t.group||""}:${null!==(o=null===(i=t.datum)||void 0===i?void 0:i.category)&&void 0!==o?o:""}`:null}snapshotPositions(){this.prevPositionMap.clear();const t=new Map;for(let e=0;this.scene.length>e;e++){const i=this.scene[e],o=this.getNodeKey(i,t);o&&("point"===i.type?this.prevPositionMap.set(o,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity}):"rect"===i.type&&this.prevPositionMap.set(o,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity}))}}startTransition(){var t,e,i,o,r,n,s,a,c,l,u,h;if(!this.config.transition||0===this.prevPositionMap.size)return;const f=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 d=!1;const g=new Set,y=new Map;for(let t=0;this.scene.length>t;t++){const a=this.scene[t],c=this.getNodeKey(a,y);if(!c)continue;a._transitionKey=c;const l=this.prevPositionMap.get(c);"point"===a.type?l?(g.add(c),a._targetOpacity=null!==(e=a.style.opacity)&&void 0!==e?e:1,l.x===a.x&&l.y===a.y||(a._targetX=a.x,a._targetY=a.y,a.x=l.x,a.y=l.y,d=!0)):(a._targetOpacity=null!==(i=a.style.opacity)&&void 0!==i?i:1,a.style=Object.assign(Object.assign({},a.style),{opacity:0}),d=!0):"rect"===a.type&&(l?(g.add(c),a._targetOpacity=null!==(o=a.style.opacity)&&void 0!==o?o:1,l.x===a.x&&l.y===a.y&&l.w===a.w&&l.h===a.h||(a._targetX=a.x,a._targetY=a.y,a._targetW=a.w,a._targetH=a.h,a.x=l.x,a.y=l.y,a.w=null!==(r=l.w)&&void 0!==r?r:a.w,a.h=null!==(n=l.h)&&void 0!==n?n:a.h,d=!0)):(a._targetOpacity=null!==(s=a.style.opacity)&&void 0!==s?s:1,a.style=Object.assign(Object.assign({},a.style),{opacity:0}),d=!0))}this.exitNodes=[];for(const[t,e]of this.prevPositionMap)g.has(t)||(t.startsWith("p:")?this.exitNodes.push({type:"point",x:e.x,y:e.y,r:null!==(a=e.r)&&void 0!==a?a:3,style:{opacity:null!==(c=e.opacity)&&void 0!==c?c:1},datum:null,_targetOpacity:0,_transitionKey:t}):t.startsWith("r:")&&this.exitNodes.push({type:"rect",x:e.x,y:e.y,w:null!==(l=e.w)&&void 0!==l?l:0,h:null!==(u=e.h)&&void 0!==u?u:0,style:{opacity:null!==(h=e.opacity)&&void 0!==h?h:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t}),d=!0);this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),d&&(this.activeTransition={startTime:dt(),duration:f})}advanceTransition(t){var e,i,o;if(!this.activeTransition)return!1;const r=ht(t,this.activeTransition),n=ut(r,"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(e)if("point"===t.type){if(void 0!==t._targetOpacity){const o=this.prevPositionMap.get(e),r=o?null!==(i=o.opacity)&&void 0!==i?i:1:0;t.style.opacity=ft(r,t._targetOpacity,n)}if(void 0===t._targetX)continue;const o=this.prevPositionMap.get(e);if(!o)continue;t.x=ft(o.x,t._targetX,n),t.y=ft(o.y,t._targetY,n)}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e),r=i?null!==(o=i.opacity)&&void 0!==o?o:1:0;t.style.opacity=ft(r,t._targetOpacity,n)}if(void 0===t._targetX)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=ft(i.x,t._targetX,n),t.y=ft(i.y,t._targetY,n),void 0!==i.w&&(t.w=ft(i.w,t._targetW,n),t.h=ft(i.h,t._targetH,n))}}if(r>=1){for(const t of this.scene)if(void 0!==t._targetOpacity&&(t.style=Object.assign(Object.assign({},t.style||{}),{opacity:0===t._targetOpacity?0:t._targetOpacity}),t._targetOpacity=void 0),"point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=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}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}getData(){return this.buffer.toArray()}remove(t){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),i=this.getDataId,o=t=>e.has(i(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,i)=>{o(t)&&e.add(i)}),this.timestampBuffer.clear();for(let i=0;t.length>i;i++)e.has(i)||this.timestampBuffer.push(t[i])}const r=this.buffer.remove(o);if(0===r.length)return r;for(const t of r)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach(t=>this.categories.add(this.getO(t))),this.version++,r}update(t,e){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const i=new Set(Array.isArray(t)?t:[t]),o=this.getDataId,r=new Set;this.buffer.forEach((t,e)=>{i.has(o(t))&&r.add(e)});const n=this.buffer.update(t=>i.has(o(t)),e);if(0===n.length)return n;for(const t of n)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach((t,e)=>{this.categories.add(this.getO(t)),r.has(e)&&this.pushValueExtent(t)}),this.version++,n}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}updateConfig(t){const e=Object.assign({},this.config);if(t.colorScheme!==this.config.colorScheme&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),Object.assign(this.config,t),(void 0!==t.oAccessor||void 0!==t.categoryAccessor)&&(ot(t.oAccessor||t.categoryAccessor,e.oAccessor||e.categoryAccessor)||(this.getO=st(this.config.oAccessor||this.config.categoryAccessor,"category"),this.categories.clear())),void 0!==t.rAccessor){const i=Array.isArray(t.rAccessor)?t.rAccessor:[t.rAccessor],o=Array.isArray(e.rAccessor)?e.rAccessor:[e.rAccessor];if(i.length!==o.length||i.some((t,e)=>!ot(t,o[e]))){const t=this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>rt(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new et)):(this.getR=rt(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!ot(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?st(this.config.stackBy):void 0),"groupBy"in t&&!ot(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?st(this.config.groupBy):void 0),"colorAccessor"in t&&!ot(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?st(this.config.colorAccessor):void 0),"connectorAccessor"in t&&!ot(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?st(this.config.connectorAccessor):void 0)}}const Ce={mercator:Q,equalEarth:V,albersUsa:U,orthographic:K,naturalEarth:Z,equirectangular:H};function Ie(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function Ye(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function Xe(t,e,i){return t?Object.assign(Object.assign({},i),"function"==typeof t?t(e):t):i}const qe={fill:"#e0e0e0",stroke:"#999",strokeWidth:.5,fillOpacity:1},Ge={fill:"#4e79a7",r:4,fillOpacity:.8},Ve={stroke:"#4e79a7",strokeWidth:1.5,fill:"none"};function He(t,e){if(2>t.length)return[t];const i=.4*e,o=[];let r=[t[0]];for(let e=1;t.length>e;e++){const n=t[e];Math.abs(n[0]-t[e-1][0])>i?(2>r.length||o.push(r),r=[n]):r.push(n)}return 2>r.length||o.push(r),o}function Ze(t,e,i=24){const o=e[0]-t[0],r=e[1]-t[1],n=Math.sqrt(o*o+r*r);if(0===n)return[t,e];const s=-r/n,a=o/n,c=Math.min(.3*n,80),l=(t[0]+e[0])/2+s*c,u=(t[1]+e[1])/2+a*c,h=[];for(let o=0;i>=o;o++){const r=o/i,n=1-r;h.push([n*n*t[0]+2*n*r*l+r*r*e[0],n*n*t[1]+2*n*r*u+r*r*e[1]])}return h}function Ke(t,e){if(2>t.length)return t;const i=e/2+1,o=[];for(let e=0;t.length>e;e++){const r=t[e];let n,s;0===e?(n=t[1][0]-r[0],s=t[1][1]-r[1]):e===t.length-1?(n=r[0]-t[e-1][0],s=r[1]-t[e-1][1]):(n=t[e+1][0]-t[e-1][0],s=t[e+1][1]-t[e-1][1]);const a=Math.sqrt(n*n+s*s)||1;o.push([r[0]+s/a*i,r[1]+-n/a*i])}return o}function Ue(t,e,i,o,r){const n=e[0]-t[0],s=e[1]-t[1],a=Math.sqrt(n*n+s*s);if(0===a)return[t,e];const c=s/a,l=-n/a,u=r/2+1;return[[t[0]+c*u,t[1]+l*u],[e[0]+c*u,e[1]+l*u]]}class Qe{constructor(t){this.scene=[],this.scales=null,this.version=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this.config=t}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}setAreas(t){this.areas=t}setPoints(t){this.pointData=t,this.streaming=!1}setLines(t){this.lineData=t}initStreaming(t=500){this.pointBuffer=new tt(t),this.timestampBuffer=new tt(t),this.streaming=!0}pushPoint(t){this.pointBuffer||this.initStreaming(),this.pointBuffer.push(t),this.timestampBuffer.push(performance.now()),this.lastIngestTime=performance.now()}pushMany(t){this.pointBuffer||this.initStreaming();const e=performance.now();for(const i of t)this.pointBuffer.push(i),this.timestampBuffer.push(e);this.lastIngestTime=e}removePoint(t){const{pointIdAccessor:e}=this.config;if(!e)throw Error("removePoint() requires pointIdAccessor to be configured");const i="function"==typeof e?e:t=>t[e],o=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>o.has(i(t)+"");if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),i=new Set;this.pointBuffer.forEach((e,o)=>{t(e)&&i.add(o)}),this.timestampBuffer.clear();for(let t=0;e.length>t;t++)i.has(t)||this.timestampBuffer.push(e[t])}const e=this.pointBuffer.remove(t);return e.length>0&&this.version++,e}{const t=[];return this.pointData=this.pointData.filter(e=>!o.has(i(e)+"")||(t.push(e),!1)),t.length>0&&this.version++,t}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.scene=[],this.scales=null,this.version++}computeScene(t){const{config:e}=this;this.projection=function(t){if(!t)return V();if("string"==typeof t){const e=Ce[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),V())}if("object"==typeof t&&"type"in t){const e=Ce[t.type],i=e?e():V();return t.rotate&&"rotate"in i&&i.rotate(t.rotate),t.center&&"center"in i&&i.center(t.center),i}return t}(e.projection),this.geoPath=Y(this.projection),this.fitProjection(t),this.geoPath=Y(this.projection);const i=this.projection;this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null};const o=this.scene;this.scene=this.buildSceneNodes(t),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&o.length>0&&this.startTransition(o),this.version++}fitProjection(t){var e,i,o,r,n;const s=this.projection,a=this.config,c=[...this.areas],l=Ie(a.xAccessor,"lon"),u=Ie(a.yAccessor,"lat"),h=this.getPoints();if(h.length>0){const t=h.map(t=>[l(t),u(t)]);c.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const f=Ye(a.lineDataAccessor);for(const t of this.lineData){const e=f(t);if(e&&e.length>0){const t=e.map(t=>[l(t),u(t)]);c.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==c.length){if(a.projectionExtent){const[[e,i],[o,r]]=a.projectionExtent;s.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[e,i],[o,i],[o,r],[e,r],[e,i]]]}})}else if(s.clipAngle&&(null!==(e=s.clipAngle())&&void 0!==e?e:0)>0){const e=null!==(i=a.fitPadding)&&void 0!==i?i:0,o=Math.min(t.width,t.height);s.scale(o/2-o*e),s.translate([t.width/2,t.height/2])}else{const e=null!==(o=a.fitPadding)&&void 0!==o?o:0,i=t.width*e,r=t.height*e;s.fitExtent([[i,r],[t.width-i,t.height-r]],{type:"FeatureCollection",features:c})}this.baseScale=s.scale(),this.baseTranslate=s.translate(),this.baseRotation=null!==(n=null===(r=s.rotate)||void 0===r?void 0:r.call(s))&&void 0!==n?n:[0,0,0]}}applyZoomTransform(t,e){const i=this.projection;i&&(i.scale(this.baseScale*t.k),i.translate([this.baseTranslate[0]*t.k+t.x,this.baseTranslate[1]*t.k+t.y]),this.currentZoom=t.k,this.geoPath=Y(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyZoomScale(t,e){const i=this.projection;i&&(i.scale(this.baseScale*t),i.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=Y(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyRotation(t,e){const i=this.projection;i&&i.rotate&&(i.rotate(t),this.geoPath=Y(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}setRotation(t){const e=this.projection;e&&e.rotate&&e.rotate(t)}getRotation(){var t,e,i;return null!==(i=null===(e=null===(t=this.projection)||void 0===t?void 0:t.rotate)||void 0===e?void 0:e.call(t))&&void 0!==i?i:this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}buildSceneNodes(t){var e,i,o;const r=[],{config:n}=this,s=this.projection,a=this.geoPath,c=Ie(n.xAccessor,"lon"),l=Ie(n.yAccessor,"lat");if(n.graticule){const e=!0===n.graticule?{}:n.graticule,i=X();e.step&&i.step(e.step);const o=a(i())||"";o&&r.push({type:"geoarea",pathData:o,centroid:[t.width/2,t.height/2],bounds:[[0,0],[t.width,t.height]],screenArea:0,style:{fill:"none",stroke:e.stroke||"#e0e0e0",strokeWidth:e.strokeWidth||.5,strokeDasharray:e.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const t of this.areas){const e=a(t);if(!e)continue;const i=a.centroid(t),o=a.bounds(t),s=a.area(t),c=Xe(n.areaStyle,t,qe);r.push({type:"geoarea",pathData:e,centroid:i,bounds:o,screenArea:s,style:c,datum:t,interactive:!0})}const u=Ye(n.lineDataAccessor);for(const e of this.lineData){const i=u(e);if(!i||2>i.length)continue;const o=i.map(t=>[c(t),l(t)]);let a;if("geo"===n.lineType){const t=[];for(let e=0;o.length-1>e;e++){const i=o[e],r=o[e+1],n=q(i,r)||0,s=Math.max(2,Math.ceil(n/(Math.PI/180))),a=G(i,r);for(let i=0;s>=i;i++)e>0&&0===i||t.push(a(i/s))}a=t.map(([t,e])=>s([t,e])).filter(t=>null!=t)}else a=o.map(([t,e])=>s([t,e])).filter(t=>null!=t);if(2>a.length)continue;const h=Xe(n.lineStyle,e,Ve),f="number"==typeof h.strokeWidth?h.strokeWidth:1;2!==o.length||2>a.length||"arc"!==n.flowStyle?2!==o.length||2>a.length||"offset"!==n.flowStyle||(a="geo"===n.lineType?Ke(a,f):Ue(a[0],a[a.length-1],0,0,f)):a=Ze(a[0],a[a.length-1]);const d=He(a,t.width);if(d.length>1)for(const t of d){if(2>t.length)continue;const i={type:"line",path:t,style:Object.assign(Object.assign({},h),{_edgeFade:!0}),datum:e};r.push(i)}else r.push({type:"line",path:2>a.length&&d[0]||a,style:h,datum:e})}const h=this.getPoints(),f=n.pointIdAccessor?"function"==typeof n.pointIdAccessor?n.pointIdAccessor:t=>t[n.pointIdAccessor]:null,d=s.clipAngle&&null!==(e=s.clipAngle())&&void 0!==e?e:0,g=d>0?d*Math.PI/180:null,y=s.rotate?s.rotate():[0,0,0],p="function"==typeof s.center?s.center():[0,0],m=[(null!==(i=p[0])&&void 0!==i?i:0)-y[0],(null!==(o=p[1])&&void 0!==o?o:0)-y[1]];for(let t=0;h.length>t;t++){const e=h[t],i=c(e),o=l(e);if(null!=g&&q([i,o],m)>g)continue;const a=s([i,o]);if(!a)continue;const u=n.pointStyle?n.pointStyle(e):Object.assign({},Ge),d={type:"point",x:a[0],y:a[1],r:u.r||4,style:u,datum:e,pointId:f?f(e)+"":void 0};r.push(d)}return r}applyCartogramTransform(t,e){var i,o,r;const n=this.scene.filter(t=>"point"===t.type);if(2>n.length)return;const s=null!==(i=t.strength)&&void 0!==i?i:1;if(0===s)return;const c=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:t=>t.id,l="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],u=n.find(e=>c(e.datum)+""==t.center+"");if(!u)return void("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`));const h=u.x,f=u.y,d=n.map(t=>l(t.datum)).filter(t=>isFinite(t)&&t>=0),g=Math.max(...d,1),y=Math.min(e.width,e.height)/2,p=a().domain([0,g]).range([0,y]);this.cartogramLayout={cx:h,cy:f,maxCost:g,availableRadius:y},this.areas.length>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them."),this.scene=this.scene.filter(t=>"geoarea"!==t.type||!t.interactive);for(const t of n){if(t===u)continue;const e=Math.atan2(t.y-f,t.x-h),i=Math.sqrt(Math.pow(t.x-h,2)+Math.pow(t.y-f,2)),o=l(t.datum),r=i+((isFinite(o)?p(o):i)-i)*s;t.x=h+Math.cos(e)*r,t.y=f+Math.sin(e)*r}const m=e.width/2,x=e.height/2,v=m-u.x,b=x-u.y;if(Math.abs(v)>.5||Math.abs(b)>.5)for(const t of n)t.x+=v,t.y+=b;this.cartogramLayout={cx:m,cy:x,maxCost:g,availableRadius:y};const k=this.scene.filter(t=>"line"===t.type);if(k.length>0&&"fractional"!==t.lineMode){const t=new Map;for(const e of n)e.pointId&&t.set(e.pointId,[e.x,e.y]);for(const e of k){const i=null===(o=e.datum)||void 0===o?void 0:o.source,n=null===(r=e.datum)||void 0===r?void 0:r.target;if(i&&n){const o=t.get(i+""),r=t.get(n+"");o&&r&&(e.path=[o,r])}}}}applyDecay(){const t=this.config.decay;if(!t||!this.pointBuffer)return;const e=this.pointBuffer.size;if(0===e)return;const i=this.scene.filter(t=>"point"===t.type);for(let o=0;i.length>o;o++){const r=ct(t,o,e);i[o]._decayOpacity=r,i[o].style=Object.assign(Object.assign({},i[o].style),{opacity:r})}}applyPulse(){var t,e;const i=this.config.pulse;if(!i||!this.timestampBuffer)return;const o=null!==(t=i.duration)&&void 0!==t?t:500,r=performance.now(),n=this.scene.filter(t=>"point"===t.type),s=this.timestampBuffer.toArray();for(let t=0;n.length>t&&s.length>t;t++){const a=r-s[t];o>a&&(n[t]._pulseIntensity=1-a/o,n[t]._pulseColor=i.color||"rgba(255,255,255,0.6)",n[t]._pulseGlowRadius=null!==(e=i.glowRadius)&&void 0!==e?e:4)}}get hasActivePulses(){var t,e;if(!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const i=null!==(e=null===(t=this.config.pulse)||void 0===t?void 0:t.duration)&&void 0!==e?e:500,o=this.timestampBuffer.toArray()[this.timestampBuffer.size-1];return performance.now()-o<i}startTransition(t){var e,i;const o=null!==(i=null===(e=this.config.transition)||void 0===e?void 0:e.duration)&&void 0!==i?i:300;if(0>=o)return;const r=new Map;for(const e of t)"point"===e.type&&e.pointId&&r.set(e.pointId,[e.x,e.y]);const n=this.scene.filter(t=>"point"===t.type);let s=!1;for(const t of n)if(t.pointId){const e=r.get(t.pointId);e&&(t._targetX=t.x,t._targetY=t.y,t.x=e[0],t.y=e[1],(Math.abs(e[0]-t._targetX)>.5||Math.abs(e[1]-t._targetY)>.5)&&(s=!0))}s&&(this.activeTransition={startTime:performance.now(),duration:o})}advanceTransition(t){if(!this.activeTransition)return!1;const e=ht(t,this.activeTransition),i=ut(e),o=this.scene.filter(t=>"point"===t.type);for(const t of o)if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=ft(t.x,t._targetX,i),t.y=ft(e,t._targetY,i)}if(e>=1){for(const t of o)null!=t._targetX&&(t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0);return this.activeTransition=null,!1}return!0}}function Je(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}function ti(e,i){var o,r,n;switch(e.type){case"line":{const o=e;if(0===o.path.length)return null;const r="M"+o.path.map(([t,e])=>`${t},${e}`).join("L");return t.createElement("path",{key:"line-"+i,d:r,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||2,strokeDasharray:o.style.strokeDasharray,opacity:o.style.opacity})}case"area":{const n=e;if(0===n.topPath.length)return null;const s=n.topPath.map(([t,e])=>`${t},${e}`).join("L"),a=[...n.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return t.createElement("path",{key:"area-"+i,d:`M${s}L${a}Z`,fill:Je(n.style.fill),fillOpacity:null!==(r=null!==(o=n.style.fillOpacity)&&void 0!==o?o:n.style.opacity)&&void 0!==r?r:.7,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})}case"point":{const o=e;return t.createElement("circle",{key:"point-"+i,cx:o.x,cy:o.y,r:o.r,fill:Je(o.style.fill),opacity:null!==(n=o.style.opacity)&&void 0!==n?n:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})}case"rect":{const o=e;return t.createElement("rect",{key:"rect-"+i,x:o.x,y:o.y,width:o.w,height:o.h,fill:Je(o.style.fill),opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})}case"heatcell":{const o=e;if(o.showValues&&null!=o.value&&o.w>=20&&o.h>=20){const e=o.valueFormat?o.valueFormat(o.value):Number.isInteger(o.value)?o.value+"":100>Math.abs(o.value)?1>Math.abs(o.value)?o.value.toPrecision(3):o.value.toFixed(1):o.value.toFixed(0),[r,n,s]=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]}(o.fill),a=.299*r+.587*n+.114*s>128?"#000":"#fff",c=Math.max(10,Math.min(16,.3*Math.min(o.w,o.h)));return t.createElement("g",{key:"heatcell-"+i},t.createElement("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill}),t.createElement("text",{x:o.x+o.w/2,y:o.y+o.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:c+"px"},e))}return t.createElement("rect",{key:"heatcell-"+i,x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill})}case"candlestick":{const o=e,r=Math.min(o.openY,o.closeY),n=Math.max(Math.abs(o.openY-o.closeY),1),s=o.isUp?o.upColor:o.downColor;return t.createElement("g",{key:"candle-"+i},t.createElement("line",{x1:o.x,y1:o.highY,x2:o.x,y2:o.lowY,stroke:o.wickColor,strokeWidth:o.wickWidth}),t.createElement("rect",{x:o.x-o.bodyWidth/2,y:r,width:o.bodyWidth,height:n,fill:s,stroke:s,strokeWidth:1}))}default:return null}}function ei(e,i){var o,r,n,s,a;const c=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",l=t=>`ord-${e.type}-${c}-${i}-${t}`,u=`ord-${e.type}-${c}-${i}`;switch(e.type){case"rect":{const i=e;if(i.roundedTop&&i.roundedTop>0){const e=Math.min(i.roundedTop,i.w/2,i.h/2),{x:o,y:r,w:n,h:s}=i;let a;switch(i.roundedEdge){case"right":a=`M${o},${r} L${o+n-e},${r} A${e},${e} 0 0 1 ${o+n},${r+e} L${o+n},${r+s-e} A${e},${e} 0 0 1 ${o+n-e},${r+s} L${o},${r+s} Z`;break;case"left":a=`M${o+n},${r} L${o+e},${r} A${e},${e} 0 0 0 ${o},${r+e} L${o},${r+s-e} A${e},${e} 0 0 0 ${o+e},${r+s} L${o+n},${r+s} Z`;break;case"bottom":a=`M${o},${r} L${o+n},${r} L${o+n},${r+s-e} A${e},${e} 0 0 1 ${o+n-e},${r+s} L${o+e},${r+s} A${e},${e} 0 0 1 ${o},${r+s-e} Z`;break;default:a=`M${o},${r+s} L${o},${r+e} A${e},${e} 0 0 1 ${o+e},${r} L${o+n-e},${r} A${e},${e} 0 0 1 ${o+n},${r+e} L${o+n},${r+s} Z`}return t.createElement("path",{key:u,d:a,fill:Je(i.style.fill),opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})}return t.createElement("rect",{key:u,x:i.x,y:i.y,width:i.w,height:i.h,fill:Je(i.style.fill),opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})}case"point":{const i=e;return t.createElement("circle",{key:u,cx:i.x,cy:i.y,r:i.r,fill:Je(i.style.fill),opacity:null!==(o=i.style.opacity)&&void 0!==o?o:.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})}case"wedge":{const i=e,o=D().innerRadius(i.innerRadius).outerRadius(i.outerRadius).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2);i.cornerRadius&&o.cornerRadius(i.cornerRadius);const r=o({})||"";return t.createElement("path",{key:u,d:r,transform:`translate(${i.cx},${i.cy})`,fill:Je(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}case"boxplot":{const i=e,o=i.columnWidth/2;return"vertical"===i.projection?t.createElement("g",{key:u},t.createElement("line",{x1:i.x,y1:i.minPos,x2:i.x,y2:i.maxPos,stroke:i.style.stroke||"#333",strokeWidth:1}),t.createElement("rect",{x:i.x-o,y:Math.min(i.q1Pos,i.q3Pos),width:i.columnWidth,height:Math.abs(i.q3Pos-i.q1Pos),fill:Je(i.style.fill),fillOpacity:null!==(r=i.style.fillOpacity)&&void 0!==r?r:.6,stroke:i.style.stroke||"#333",strokeWidth:1}),t.createElement("line",{x1:i.x-o,y1:i.medianPos,x2:i.x+o,y2:i.medianPos,stroke:i.style.stroke||"#333",strokeWidth:2}),t.createElement("line",{x1:i.x-.5*o,y1:i.minPos,x2:i.x+.5*o,y2:i.minPos,stroke:i.style.stroke||"#333",strokeWidth:1}),t.createElement("line",{x1:i.x-.5*o,y1:i.maxPos,x2:i.x+.5*o,y2:i.maxPos,stroke:i.style.stroke||"#333",strokeWidth:1})):t.createElement("g",{key:u},t.createElement("line",{x1:i.minPos,y1:i.y,x2:i.maxPos,y2:i.y,stroke:i.style.stroke||"#333",strokeWidth:1}),t.createElement("rect",{x:Math.min(i.q1Pos,i.q3Pos),y:i.y-o,width:Math.abs(i.q3Pos-i.q1Pos),height:i.columnWidth,fill:Je(i.style.fill),fillOpacity:null!==(n=i.style.fillOpacity)&&void 0!==n?n:.6,stroke:i.style.stroke||"#333",strokeWidth:1}),t.createElement("line",{x1:i.medianPos,y1:i.y-o,x2:i.medianPos,y2:i.y+o,stroke:i.style.stroke||"#333",strokeWidth:2}),t.createElement("line",{x1:i.minPos,y1:i.y-.5*o,x2:i.minPos,y2:i.y+.5*o,stroke:i.style.stroke||"#333",strokeWidth:1}),t.createElement("line",{x1:i.maxPos,y1:i.y-.5*o,x2:i.maxPos,y2:i.y+.5*o,stroke:i.style.stroke||"#333",strokeWidth:1}))}case"violin":{const i=e,o=[t.createElement("path",{key:l("path"),d:i.pathString,transform:i.translateX||i.translateY?`translate(${i.translateX},${i.translateY})`:void 0,fill:Je(i.style.fill),fillOpacity:null!==(s=i.style.fillOpacity)&&void 0!==s?s:.6,stroke:i.style.stroke||"#333",strokeWidth:i.style.strokeWidth||1})];if(i.iqrLine&&i.bounds){const e=i.bounds,r=e.x+e.width/2,n=e.y+e.height/2;e.height>e.width?o.push(t.createElement("line",{key:l("iqr"),x1:r,y1:i.iqrLine.q1Pos,x2:r,y2:i.iqrLine.q3Pos,stroke:i.style.stroke||"#333",strokeWidth:2}),t.createElement("circle",{key:l("med"),cx:r,cy:i.iqrLine.medianPos,r:3,fill:"white",stroke:i.style.stroke||"#333",strokeWidth:1})):o.push(t.createElement("line",{key:l("iqr"),x1:i.iqrLine.q1Pos,y1:n,x2:i.iqrLine.q3Pos,y2:n,stroke:i.style.stroke||"#333",strokeWidth:2}),t.createElement("circle",{key:l("med"),cx:i.iqrLine.medianPos,cy:n,r:3,fill:"white",stroke:i.style.stroke||"#333",strokeWidth:1}))}return t.createElement("g",{key:u},o)}case"connector":return t.createElement("line",{key:u,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:null!==(a=e.style.opacity)&&void 0!==a?a:.5});case"trapezoid":{const i=e,o=i.points.map(t=>`${t[0]},${t[1]}`).join(" ");return t.createElement("polygon",{key:u,points:o,fill:Je(i.style.fill,"#999"),opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})}default:return null}}const ii={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},oi={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},ri={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"};e(null),function(t){const e=new EventTarget;let i=t(function(t){i=Object.assign(Object.assign({},i),t(i)),e.dispatchEvent(new CustomEvent("update"))})}(t=>({theme:ii,setTheme(e){t(t=>{if("light"===e)return{theme:ii};if("dark"===e)return{theme:oi};if("high-contrast"===e)return{theme:ri};if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?oi:ii;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||{})})}})}}));const ni={light:ii,dark:oi,"high-contrast":ri,pastels:{mode:"light",colors:{primary:"#c9a0dc",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",text:"#4a3728",textSecondary:"#8b7355",grid:"#e8d5c4",border:"#e8d5c4",focus:"#c9a0dc"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",text:"#2c3e50",textSecondary:"#7f8c9b",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#e45050"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:18,labelSize:12,tickSize:10,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}};function si(t){if(!t)return ii;if("string"==typeof t){if("light"===t)return ii;if("dark"===t)return oi;if("high-contrast"===t)return ri;return ni[t]||ii}const e="dark"===t.mode?oi:ii;return Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{}),tooltip:Object.assign(Object.assign({},e.tooltip),t.tooltip||{})})}function ai(t){var e,i,o,r;return{background:t.colors.background,text:t.colors.text,textSecondary:t.colors.textSecondary,grid:t.colors.grid,border:t.colors.border,primary:t.colors.primary,fontFamily:t.typography.fontFamily,titleSize:t.typography.titleSize,labelSize:t.typography.labelSize,tickSize:t.typography.tickSize,categorical:t.colors.categorical,annotation:null!==(e=t.colors.annotation)&&void 0!==e?e:t.colors.text,legendSize:null!==(i=t.typography.legendSize)&&void 0!==i?i:t.typography.labelSize,titleFontSize:null!==(o=t.typography.titleFontSize)&&void 0!==o?o:t.typography.titleSize,tickFontFamily:null!==(r=t.typography.tickFontFamily)&&void 0!==r?r:t.typography.fontFamily}}function ci(e){const{categories:i,colorScheme:o,theme:r,position:n="right",totalWidth:s,totalHeight:a,margin:c,hasTitle:l=!1}=e;if(!i||0===i.length)return null;const u=function(t,e,i){const o=Array.isArray(e)?e:i.colors.categorical.length>0?i.colors.categorical:m;return h().domain(t).range(o)}(i,o,r),f="top"===n||"bottom"===n;let d,g;if("left"===n?(d=4,g=c.top):"top"===n?(d=c.left,g=l?32:8):"bottom"===n?(d=c.left,g=Math.min(a-c.bottom+38,a-16)):(d=s-c.right+10,g=c.top),f){let e=0;const o=i.map((i,o)=>{const n=e;return e+=22+6.5*i.length+8,t.createElement("g",{key:"legend-"+o,transform:`translate(${n},0)`},t.createElement("rect",{width:14,height:14,fill:u(i),rx:2}),t.createElement("text",{x:20,y:7,dominantBaseline:"central",fontSize:r.typography.tickSize,fill:r.colors.text,fontFamily:r.typography.fontFamily},i))});return t.createElement("g",{className:"semiotic-legend",transform:`translate(${d},${g})`},o)}const y=i.map((e,i)=>t.createElement("g",{key:"legend-"+i,transform:`translate(0,${20*i})`},t.createElement("rect",{width:14,height:14,fill:u(e),rx:2}),t.createElement("text",{x:20,y:7,dominantBaseline:"central",fontSize:r.typography.tickSize,fill:r.colors.text,fontFamily:r.typography.fontFamily},e)));return t.createElement("g",{className:"semiotic-legend",transform:`translate(${d},${g})`},y)}function li(t,e){if(!e||!t||0===t.length)return[];const i="function"==typeof e?e:t=>t[e],o=new Set;for(const e of t){const t=i(e);null!=t&&o.add(t+"")}return Array.from(o)}function ui(t,e){return t.color||e.colors.annotation||e.colors.text}function hi(e){const{annotations:i}=e;if(!i||0===i.length)return null;const o=[];for(let t=0;i.length>t;t++){const r=fi(i[t],t,e);r&&o.push(r)}return o.length>0?t.createElement("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations"},o):null}function fi(e,i,o){var r,n,s,a;const{scales:c,layout:l,theme:u,xAccessor:h,yAccessor:f}=o;switch(e.type){case"y-threshold":{const n=e.value;if(null==n)return null;const s=ui(e,u),a=e.label,h=e.labelPosition||"right",f=e.strokeDasharray||"6,4",d=null!==(r=e.strokeWidth)&&void 0!==r?r:1.5;if("horizontal"===o.projection&&c.r){const e=c.r(n);return null==e?null:t.createElement("g",{key:"ann-ythresh-"+i},t.createElement("line",{x1:e,y1:0,x2:e,y2:l.height,stroke:s,strokeWidth:d,strokeDasharray:f}),a&&t.createElement("text",{x:e+4,y:12,textAnchor:"start",fontSize:u.typography.tickSize,fill:s,fontFamily:u.typography.fontFamily},a))}const g=c.y?c.y(n):c.r?c.r(n):null;return null==g?null:t.createElement("g",{key:"ann-ythresh-"+i},t.createElement("line",{x1:0,y1:g,x2:l.width,y2:g,stroke:s,strokeWidth:d,strokeDasharray:f}),a&&t.createElement("text",{x:"left"===h?4:"center"===h?l.width/2:l.width-4,y:g-6,textAnchor:"left"===h?"start":"center"===h?"middle":"end",fontSize:u.typography.tickSize,fill:s,fontFamily:u.typography.fontFamily},a))}case"x-threshold":{const o=e.value;if(null==o||!c.x)return null;const r=c.x(o);if(null==r)return null;const s=ui(e,u),a=e.label,h=e.labelPosition||"top",f=null!==(n=e.strokeWidth)&&void 0!==n?n:1.5;return t.createElement("g",{key:"ann-xthresh-"+i},t.createElement("line",{x1:r,y1:0,x2:r,y2:l.height,stroke:s,strokeWidth:f,strokeDasharray:e.strokeDasharray||"6,4"}),a&&t.createElement("text",{x:r+4,y:"bottom"===h?l.height-4:"center"===h?l.height/2:12,textAnchor:"start",fontSize:u.typography.tickSize,fill:s,fontFamily:u.typography.fontFamily},a))}case"band":{const o=null!=e.y0&&c.y?c.y(e.y0):null,r=null!=e.y1&&c.y?c.y(e.y1):null;if(null==o||null==r)return null;const n=Math.min(o,r),a=Math.abs(r-o),h=e.fill||ui(e,u),f=null!==(s=e.opacity)&&void 0!==s?s:.1;return t.createElement("g",{key:"ann-band-"+i},t.createElement("rect",{x:0,y:n,width:l.width,height:a,fill:h,opacity:f}),e.label&&t.createElement("text",{x:l.width-4,y:n+12,textAnchor:"end",fontSize:u.typography.tickSize,fill:h,fontFamily:u.typography.fontFamily},e.label))}case"category-highlight":{if(!e.category||!c.o)return null;const r=c.o(e.category);if(null==r)return null;const n=c.o.bandwidth?c.o.bandwidth():40,s=ui(e,u),h=null!==(a=e.opacity)&&void 0!==a?a:.1;return t.createElement("rect","horizontal"===o.projection?{key:"ann-cathighlight-"+i,x:0,y:r,width:l.width,height:n,fill:s,opacity:h}:{key:"ann-cathighlight-"+i,x:r,y:0,width:n,height:l.height,fill:s,opacity:h})}case"label":case"text":{const o=function(t,e,i){return null!=t.x&&e.x?e.x(t.x):i&&null!=t[i]&&e.x?e.x(t[i]):null}(e,c,h),r=function(t,e,i){return null!=t.y&&e.y?e.y(t.y):i&&null!=t[i]&&e.y?e.y(t[i]):null}(e,c,f);if(null==o||null==r)return null;const n=e.dx||0,s=e.dy||0,a=e.color||u.colors.text;return t.createElement("g",{key:"ann-label-"+i},"label"===e.type&&t.createElement("line",{x1:o,y1:r,x2:o+n,y2:r+s,stroke:u.colors.textSecondary,strokeWidth:1}),t.createElement("text",{x:o+n,y:r+s,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||u.typography.labelSize,fill:a,fontFamily:u.typography.fontFamily,fontWeight:e.fontWeight},e.label||e.title))}default:return null}}const di={Sparkline:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign(Object.assign({chartType:"line",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.lineBy||e,colorAccessor:e},o),{showAxes:!1,margin:o.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0})},LineChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"line",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.lineBy||e,colorAccessor:e,colorScheme:i,lineStyle:r.lineStyle},o)},AreaChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"area",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",y0Accessor:r.y0Accessor,groupAccessor:r.areaBy||e,colorAccessor:e,colorScheme:i},o)},StackedAreaChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"stackedarea",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.areaBy,colorAccessor:e||r.areaBy,colorScheme:i,normalize:r.normalize},o)},Scatterplot:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"scatter",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,sizeAccessor:r.sizeBy,colorScheme:i},o)},BubbleChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"scatter",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,sizeAccessor:r.sizeBy,sizeRange:r.sizeRange||[5,40],colorScheme:i},o)},ConnectedScatterplot:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"line",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,colorScheme:i,showPoints:!0},o)},Heatmap:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"heatmap",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",valueAccessor:r.valueAccessor,colorScheme:i||r.colorScheme||"blues",showValues:r.showValues,cellBorderColor:r.cellBorderColor},o)},BarChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:null!==(n=r.sort)&&void 0!==n&&n,colorAccessor:e,colorScheme:i,barPadding:r.barPadding},null!=r.roundedTop&&{roundedTop:r.roundedTop}),o)}},StackedBarChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.stackBy,colorAccessor:e||r.stackBy,colorScheme:i,projection:"horizontal"===r.orientation?"horizontal":"vertical",normalize:r.normalize,oSort:null!==(n=r.sort)&&void 0!==n&&n},null!=r.roundedTop&&{roundedTop:r.roundedTop}),o)}},GroupedBarChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"clusterbar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",groupBy:r.groupBy,colorAccessor:e||r.groupBy,colorScheme:i,projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:null!==(n=r.sort)&&void 0!==n&&n,barPadding:r.barPadding},null!=r.roundedTop&&{roundedTop:r.roundedTop}),o)}},PieChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign(Object.assign({chartType:"pie",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",colorAccessor:e||r.categoryAccessor,colorScheme:i},null!=r.cornerRadius&&{cornerRadius:r.cornerRadius}),o)},DonutChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign(Object.assign({chartType:"donut",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",innerRadius:r.innerRadius||60,colorAccessor:e||r.categoryAccessor,colorScheme:i},null!=r.cornerRadius&&{cornerRadius:r.cornerRadius}),o)},Histogram:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"histogram",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"horizontal",bins:r.bins,colorAccessor:e,colorScheme:i},o)},BoxPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"boxplot",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorScheme:i},o)},ViolinPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"violin",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",bins:r.bins,colorScheme:i},o)},SwarmPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"swarm",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:e,colorScheme:i},o)},DotPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"point",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:e,colorScheme:i},o),{showGrid:null===(n=o.showGrid)||void 0===n||n})}},SwimlaneChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"swimlane",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.subcategoryAccessor,colorAccessor:e||r.subcategoryAccessor,categoryAccessor:r.categoryAccessor,subcategoryAccessor:r.subcategoryAccessor,colorScheme:i,projection:"horizontal"===r.orientation?"horizontal":"vertical"},o)},RidgelinePlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"ridgeline",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",bins:r.bins,amplitude:r.amplitude},o)},LikertChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"bar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.levelAccessor||"level",colorAccessor:e||r.levelAccessor||"level",colorScheme:i,normalize:!0,projection:"vertical"===r.orientation?"vertical":"horizontal"},o)},FunnelChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{const n="vertical"===r.orientation;return Object.assign({chartType:n?"bar-funnel":"funnel",data:t,oAccessor:r.stepAccessor||"step",rAccessor:r.valueAccessor||"value",colorAccessor:e||r.categoryAccessor,categoryAccessor:r.categoryAccessor,projection:n?"vertical":"horizontal",connectorAccessor:r.connectorAccessor,connectorStyle:r.connectorStyle,colorScheme:i},o)}},GaugeChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n,s,a,c;const l=null!==(n=r.min)&&void 0!==n?n:0,u=null!==(s=r.max)&&void 0!==s?s:100,h=null!==(a=r.sweep)&&void 0!==a?a:240,f=null!==(c=r.arcWidth)&&void 0!==c?c:.3,d=180+(360-h)/2,g=r.thresholds||[{value:u,color:"#4e79a7"}],y=g.map((t,e)=>({category:t.label||"zone-"+e,value:t.value-(e>0?g[e-1].value:l)})),p={};g.forEach((t,e)=>{p[t.label||"zone-"+e]=t.color||"#4e79a7"});const m=o.margin||{top:20,right:20,bottom:30,left:40},[x,v]=o.size||[300,300];return Object.assign(Object.assign({chartType:"donut",data:y,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:Math.max(10,Math.min(x-(m.left||0)-(m.right||0),v-(m.top||0)-(m.bottom||0))/2*(1-f)),sweepAngle:h,startAngle:d,oSort:!1,pieceStyle:(t,e)=>({fill:p[e||""]||"#4e79a7"})},o),{showAxes:!1,__gauge:{gMin:l,gMax:u,sweep:h,arcWidth:f,value:r.value,startAngleDeg:d,thresholds:g}})}},ForceDirectedGraph:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"force",nodes:r.nodes,edges:r.edges,nodeIDAccessor:r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,colorBy:e,colorScheme:i,iterations:r.iterations,forceStrength:r.forceStrength,showLabels:r.showLabels,nodeLabel:r.nodeLabel,nodeSize:r.nodeSize,nodeSizeRange:r.nodeSizeRange,nodeStyle:r.nodeStyle,edgeStyle:r.edgeStyle},o)},SankeyDiagram:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"sankey",nodes:r.nodes,edges:r.edges,nodeIDAccessor:r.nodeIdAccessor||r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,valueAccessor:r.valueAccessor,orientation:r.orientation,nodeAlign:r.nodeAlign,nodeWidth:r.nodeWidth,nodePaddingRatio:r.nodePaddingRatio,showLabels:r.showLabels,nodeLabel:r.nodeLabel,colorBy:e,edgeColorBy:r.edgeColorBy,edgeOpacity:r.edgeOpacity,nodeStyle:r.nodeStyle,edgeStyle:r.edgeStyle,colorScheme:i},o)},ChordDiagram:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"chord",nodes:r.nodes,edges:r.edges,valueAccessor:r.valueAccessor,padAngle:r.padAngle,groupWidth:r.groupWidth,showLabels:r.showLabels,colorBy:e,edgeColorBy:r.edgeColorBy,colorScheme:i},o)},TreeDiagram:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"cluster"===r.layout?"cluster":"tree",data:t,childrenAccessor:r.childrenAccessor,colorBy:e,colorByDepth:r.colorByDepth,orientation:r.orientation,showLabels:r.showLabels,colorScheme:i},o)},Treemap:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"treemap",data:t,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:e,colorByDepth:r.colorByDepth,showLabels:r.showLabels,colorScheme:i},o)},CirclePack:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"circlepack",data:t,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:e,colorByDepth:r.colorByDepth,colorScheme:i},o)},ChoroplethMap:{frameType:"geo",buildProps:(t,e,i,o,r)=>Object.assign({areas:r.areas,projection:r.projection||"equalEarth",areaStyle:r.areaStyle,valueAccessor:r.valueAccessor,colorScheme:i||"blues",graticule:r.graticule,fitPadding:r.fitPadding},o)},ProportionalSymbolMap:{frameType:"geo",buildProps:(t,e,i,o,r)=>Object.assign({points:t||r.points,xAccessor:r.xAccessor||"lon",yAccessor:r.yAccessor||"lat",areas:r.areas,areaStyle:r.areaStyle,sizeBy:r.sizeBy,colorBy:e,colorScheme:i,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding},o)}},gi=require("react-dom/server");function yi(t){return Math.round(100*t)/100+""}function pi(e,i){const o=ai(i.theme),r=i.idPrefix?i.idPrefix+"-":"",n="string"==typeof i.title?i.title:void 0,s=n?r+"semiotic-title":void 0,a=i.description?r+"semiotic-desc":void 0,c=[s,a].filter(Boolean).join(" ")||void 0;return t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:i.className,width:i.width,height:i.height,role:"img","aria-labelledby":c,style:{fontFamily:o.fontFamily}},n&&t.createElement("title",{id:s},n),i.description&&t.createElement("desc",{id:a},i.description),i.defs&&t.createElement("defs",null,i.defs),i.background&&"transparent"!==i.background&&t.createElement("rect",{x:0,y:0,width:i.width,height:i.height,fill:i.background}),t.createElement("g",{id:r+"data-area",transform:i.innerTransform},e),n&&t.createElement("text",{id:r+"chart-title",x:i.width/2,y:16,textAnchor:"middle",fontSize:o.titleSize,fontWeight:"bold",fill:o.text,fontFamily:o.fontFamily},n),i.legend&&t.createElement("g",{id:r+"legend"},i.legend),i.outerElements)}function mi(e){var i,o,r,n;const s=si(e.theme),a=e.size||[500,300],c=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),e.margin),l=e.legendPosition;e.showLegend&&(l&&"right"!==l?"left"===l?c.left=Math.max(c.left,100):"bottom"===l?c.bottom=Math.max(c.bottom,70):"top"===l&&(c.top=Math.max(c.top,40)):c.right=Math.max(c.right,100));const u=a[0]-c.left-c.right,h=a[1]-c.top-c.bottom,f="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),d={chartType:e.chartType,windowSize:null!==(i=e.windowSize)&&void 0!==i?i:200,windowMode:null!==(o=e.windowMode)&&void 0!==o?o:"sliding",arrowOfTime:f&&null!==(r=e.arrowOfTime)&&void 0!==r?r:"right",extentPadding:null!==(n=e.extentPadding)&&void 0!==n?n:.1,xAccessor:f?void 0:e.xAccessor,yAccessor:f?void 0:e.yAccessor,timeAccessor:f?e.timeAccessor:void 0,valueAccessor:e.valueAccessor,colorAccessor:e.colorAccessor,sizeAccessor:e.sizeAccessor,groupAccessor:e.groupAccessor,categoryAccessor:e.categoryAccessor,lineDataAccessor:e.lineDataAccessor,xExtent:e.xExtent,yExtent:e.yExtent,sizeRange:e.sizeRange,binSize:e.binSize,normalize:e.normalize,boundsAccessor:e.boundsAccessor,boundsStyle:e.boundsStyle,openAccessor:e.openAccessor,highAccessor:e.highAccessor,lowAccessor:e.lowAccessor,closeAccessor:e.closeAccessor,candlestickStyle:e.candlestickStyle,lineStyle:e.lineStyle,pointStyle:e.pointStyle,areaStyle:e.areaStyle,colorScheme:e.colorScheme||s.colors.categorical,barColors:e.barColors},g=new St(d);if(e.data&&g.ingest({inserts:e.data,bounded:!0}),g.computeScene({width:u,height:h}),!g.scales||0===g.scene.length)return gi.renderToStaticMarkup(pi(null,{width:a[0],height:a[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:s,innerTransform:`translate(${c.left},${c.top})`,idPrefix:e._idPrefix}));const y=e._idPrefix,p=e.showGrid?function(e,i,o,r){const{grid:n}=ai(o),s=r?r+"-":"",a=e.x.ticks(5),c=e.y.ticks(5);return t.createElement("g",{id:s+"grid",className:"semiotic-grid",opacity:.8},a.map((o,r)=>{const s=e.x(o);return t.createElement("line",{key:"gx-"+r,x1:s,y1:0,x2:s,y2:i.height,stroke:n,strokeWidth:.5})}),c.map((o,r)=>{const s=e.y(o);return t.createElement("line",{key:"gy-"+r,x1:0,y1:s,x2:i.width,y2:s,stroke:n,strokeWidth:.5})}))}(g.scales,{width:u,height:h},s,y):null,m=g.scene.map((t,e)=>ti(t,e)).filter(Boolean),x=!1!==e.showAxes?function(e,i,o,r,n){var s,a,c,l;const u=ai(r),h=e.x.ticks(5).map(t=>({pixel:e.x(t),label:(o.xFormat||o.tickFormatTime||yi)(t)})),f=e.y.ticks(5).map(t=>({pixel:e.y(t),label:(o.yFormat||o.tickFormatValue||yi)(t)}));return t.createElement("g",{id:(n?n+"-":"")+"axes",className:"stream-axes"},t.createElement("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:u.border,strokeWidth:1}),h.map((e,o)=>t.createElement("g",{key:"xtick-"+o,transform:`translate(${e.pixel},${i.height})`},t.createElement("line",{y2:5,stroke:u.border,strokeWidth:1}),t.createElement("text",{y:18,textAnchor:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily},e.label))),o.xLabel&&t.createElement("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily},o.xLabel),t.createElement("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:u.border,strokeWidth:1}),f.map((e,i)=>t.createElement("g",{key:"ytick-"+i,transform:`translate(0,${e.pixel})`},t.createElement("line",{x2:-5,stroke:u.border,strokeWidth:1}),t.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily},e.label))),o.yLabel&&t.createElement("text",{x:15-(null!==(a=null===(s=o.margin)||void 0===s?void 0:s.left)&&void 0!==a?a:40),y:i.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-(null!==(l=null===(c=o.margin)||void 0===c?void 0:c.left)&&void 0!==l?l:40)}, ${i.height/2})`},o.yLabel))}(g.scales,{width:u,height:h},e,s,y):null,v=e.annotations?hi({annotations:e.annotations,scales:{x:g.scales.x,y:g.scales.y},layout:{width:u,height:h},theme:s,xAccessor:"string"==typeof e.xAccessor?e.xAccessor:void 0,yAccessor:"string"==typeof e.yAccessor?e.yAccessor:void 0,idPrefix:y}):null,b=e.showLegend?(()=>{const t=li(e.data||[],e.colorAccessor||e.groupAccessor);return 0===t.length?null:ci({categories:t,colorScheme:e.colorScheme,theme:s,position:e.legendPosition||"right",totalWidth:a[0],totalHeight:a[1],margin:c,hasTitle:!!e.title})})():null,k=t.createElement(t.Fragment,null,p,v,m,x);return gi.renderToStaticMarkup(pi(k,{width:a[0],height:a[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:s,innerTransform:`translate(${c.left},${c.top})`,legend:b,idPrefix:e._idPrefix}))}function xi(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const vi=new Set(["tree","cluster","treemap","circlepack","partition"]);function bi(e){const i=si(e.theme),o=e.chartType||"force",r=e.size||[500,500],n=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),e.margin),s=r[0]-n.left-n.right,a=r[1]-n.top-n.bottom,c=function(t){return Ne[t]}(o);if(!c)throw Error(`No layout plugin found for chart type: "${o}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const l={chartType:o,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,colorBy:e.colorBy,colorScheme:e.colorScheme||i.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange};let u,h;if(vi.has(o)){const t=e.data||e.edges;if(!t||Array.isArray(t))return gi.renderToStaticMarkup(pi(null,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,idPrefix:e._idPrefix}));l.__hierarchyRoot=t,u=[],h=[]}else{const t=e.nodes||[],o=Array.isArray(e.edges)?e.edges:[];if(0===t.length&&0===o.length)return gi.renderToStaticMarkup(pi(null,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,idPrefix:e._idPrefix}));if(h=function(t,e){const i=xi(e.sourceAccessor,"source"),o=xi(e.targetAccessor,"target"),r=xi(e.valueAccessor,"value");return t.map(t=>({source:i(t)+"",target:o(t)+"",value:Number(r(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(o,l),0===t.length&&h.length>0){const t=new Set;for(const e of h){const i="string"==typeof e.target?e.target:e.target.id;t.add("string"==typeof e.source?e.source:e.source.id),t.add(i)}u=Array.from(t).map(t=>({id:t,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:t}}))}else u=function(t,e){const i=xi(e.nodeIDAccessor,"id");return t.map(t=>{var e,o;return{id:i(t)+"",x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(o=t.y)&&void 0!==o?o:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}})}(t,l)}c.computeLayout(u,h,l,[s,a]);const{sceneNodes:f,sceneEdges:d,labels:g}=c.buildScene(u,h,l,[s,a]),y=ai(i);for(const t of g)t.fill||(t.fill=y.text);const p=d.map((e,i)=>function(e,i){switch(e.type){case"line":return t.createElement("line",{key:"net-edge-"+i,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity});case"bezier":{const o=e;return t.createElement("path",{key:"net-edge-"+i,d:o.pathD,fill:Je(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity})}case"ribbon":{const o=e;return t.createElement("path",{key:"net-edge-"+i,d:o.pathD,fill:Je(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity})}case"curved":{const o=e;return t.createElement("path",{key:"net-edge-"+i,d:o.pathD,fill:Je(o.style.fill,"none"),stroke:o.style.stroke||"#999",strokeWidth:o.style.strokeWidth||1,opacity:o.style.opacity})}default:return null}}(e,i)).filter(Boolean),m=f.map((e,i)=>function(e,i){switch(e.type){case"circle":{const o=e;return t.createElement("circle",{key:"net-circle-"+i,cx:o.cx,cy:o.cy,r:o.r,fill:Je(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity})}case"rect":{const o=e;return t.createElement("rect",{key:"net-rect-"+i,x:o.x,y:o.y,width:o.w,height:o.h,fill:Je(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity})}case"arc":{const o=e,r=D().innerRadius(o.innerR).outerRadius(o.outerR).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2)({})||"";return t.createElement("path",{key:"net-arc-"+i,d:r,transform:`translate(${o.cx},${o.cy})`,fill:Je(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity})}default:return null}}(e,i)).filter(Boolean),x=g.map((e,i)=>function(e,i){return t.createElement("text",{key:"net-label-"+i,x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"#333",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder},e.text)}(e,i)).filter(Boolean),v=t.createElement(t.Fragment,null,p,m,x);return gi.renderToStaticMarkup(pi(v,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,idPrefix:e._idPrefix}))}function ki(e){var i,o,r,n,s;const a=si(e.theme),c=e.size||[500,400],l=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),e.margin),u=e.legendPosition;e.showLegend&&(u&&"right"!==u?"left"===u?l.left=Math.max(l.left,100):"bottom"===u?l.bottom=Math.max(l.bottom,70):"top"===u&&(l.top=Math.max(l.top,40)):l.right=Math.max(l.right,100));const h=c[0]-l.left-l.right,f=c[1]-l.top-l.bottom,d=e.projection||"vertical",g="radial"===d,y={chartType:e.chartType,windowSize:null!==(i=e.windowSize)&&void 0!==i?i:1e4,windowMode:null!==(o=e.windowMode)&&void 0!==o?o:"sliding",extentPadding:null!==(r=e.extentPadding)&&void 0!==r?r:.05,projection:d,oAccessor:e.oAccessor,rAccessor:e.rAccessor,colorAccessor:e.colorAccessor,stackBy:e.stackBy,groupBy:e.groupBy,categoryAccessor:e.categoryAccessor,valueAccessor:e.valueAccessor,timeAccessor:e.timeAccessor,rExtent:e.rExtent,oExtent:e.oExtent,barPadding:e.barPadding,roundedTop:e.roundedTop,innerRadius:e.innerRadius,cornerRadius:e.cornerRadius,normalize:e.normalize,startAngle:e.startAngle,sweepAngle:e.sweepAngle,bins:e.bins,showOutliers:e.showOutliers,showIQR:e.showIQR,amplitude:e.amplitude,oSort:e.oSort,connectorAccessor:e.connectorAccessor,connectorStyle:e.connectorStyle,dynamicColumnWidth:e.dynamicColumnWidth,pieceStyle:e.pieceStyle,summaryStyle:e.summaryStyle,colorScheme:e.colorScheme||a.colors.categorical,barColors:e.barColors},p=new Fe(y);if(e.data&&p.ingest({inserts:e.data,bounded:!0}),p.computeScene({width:h,height:f}),!p.scales||0===p.scene.length)return gi.renderToStaticMarkup(pi(null,{width:c[0],height:c[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:a,innerTransform:`translate(${l.left},${l.top})`,idPrefix:e._idPrefix}));const m=e._idPrefix,x=e.showGrid?function(e,i,o,r){const n=e.scales;if(!n||"radial"===n.projection)return null;const{grid:s}=ai(o),a=r?r+"-":"",c="vertical"===n.projection,l=n.r.ticks(5);return t.createElement("g",{id:a+"grid",className:"semiotic-grid",opacity:.8},l.map(c?(e,o)=>{const r=n.r(e);return t.createElement("line",{key:"gr-"+o,x1:0,y1:r,x2:i.width,y2:r,stroke:s,strokeWidth:.5})}:(e,o)=>{const r=n.r(e);return t.createElement("line",{key:"gr-"+o,x1:r,y1:0,x2:r,y2:i.height,stroke:s,strokeWidth:.5})}))}(p,{width:h,height:f},a,m):null,v=p.scene.some(t=>{var e;return"rect"===t.type&&(null===(e=t.datum)||void 0===e?void 0:e.__barFunnelIsDropoff)});let b=null;if(v){const i=function(t){const e=t._idPrefix||t.chartId;if(e){const t=(e+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(t)?t:"c"+t}const i=`${t.chartType||""}:${t.title||""}:${Array.isArray(t.data)?t.data.length:0}`;let o=0;for(let t=0;i.length>t;t++)o=31*o+i.charCodeAt(t)|0;return"c"+(o>>>0).toString(36)}(e),o=new Set;for(const t of p.scene)"rect"===t.type&&(null===(n=t.datum)||void 0===n?void 0:n.__barFunnelIsDropoff)&&o.add("string"==typeof t.style.fill?t.style.fill:"#666");b=Array.from(o).map((e,o)=>function(e){const{id:i,background:o="transparent",stroke:r="#000",lineWidth:n=1.5,spacing:s=6,angle:a=45}=e,c=Math.max(8,Math.ceil(2*s));return t.createElement("pattern",{key:i,id:i,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==a?`rotate(${a})`:void 0},o&&"transparent"!==o&&t.createElement("rect",{width:c,height:c,fill:o}),t.createElement("line",{x1:0,y1:0,x2:0,y2:c,stroke:r,strokeWidth:n}),t.createElement("line",{x1:s,y1:0,x2:s,y2:c,stroke:r,strokeWidth:n}))}({id:`funnel-hatch-${i}-${o}`,background:e,stroke:"transparent"===a.colors.background?"#fff":a.colors.background,lineWidth:1.5,spacing:5,angle:45}));const r=new Map;Array.from(o).forEach((t,e)=>r.set(t,`funnel-hatch-${i}-${e}`));for(const t of p.scene)if("rect"===t.type&&(null===(s=t.datum)||void 0===s?void 0:s.__barFunnelIsDropoff)){const e="string"==typeof t.style.fill?t.style.fill:"#666";t.style=Object.assign(Object.assign({},t.style),{fill:`url(#${r.get(e)})`})}}const k=p.scene.map((t,e)=>ei(t,e)).filter(Boolean),A=!1!==e.showAxes?function(e,i,o,r,n){var s,a,c,l,u,h,f,d;const g=e.scales;if(!g)return null;if("radial"===g.projection)return null;const y=ai(r),p="vertical"===g.projection,m=Object.values(e.columns).map(t=>({pixel:t.middle,label:(o.oFormat||String)(t.name)})),x=g.r.ticks(5).map(t=>({pixel:g.r(t),label:(o.rFormat||yi)(t)}));return p?t.createElement("g",{id:(n?n+"-":"")+"axes",className:"ordinal-axes"},t.createElement("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:y.border,strokeWidth:1}),m.map((e,o)=>t.createElement("g",{key:"oxtick-"+o,transform:`translate(${e.pixel},${i.height})`},t.createElement("line",{y2:5,stroke:y.border,strokeWidth:1}),t.createElement("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily},e.label))),o.oLabel&&t.createElement("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily},o.oLabel),t.createElement("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:y.border,strokeWidth:1}),x.map((e,i)=>t.createElement("g",{key:"oytick-"+i,transform:`translate(0,${e.pixel})`},t.createElement("line",{x2:-5,stroke:y.border,strokeWidth:1}),t.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily},e.label))),o.rLabel&&t.createElement("text",{x:15-(null!==(a=null===(s=o.margin)||void 0===s?void 0:s.left)&&void 0!==a?a:40),y:i.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(l=null===(c=o.margin)||void 0===c?void 0:c.left)&&void 0!==l?l:40)}, ${i.height/2})`},o.rLabel)):t.createElement("g",{id:(n?n+"-":"")+"axes",className:"ordinal-axes"},t.createElement("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:y.border,strokeWidth:1}),x.map((e,o)=>t.createElement("g",{key:"oxtick-"+o,transform:`translate(${e.pixel},${i.height})`},t.createElement("line",{y2:5,stroke:y.border,strokeWidth:1}),t.createElement("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily},e.label))),o.rLabel&&t.createElement("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily},o.rLabel),t.createElement("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:y.border,strokeWidth:1}),m.map((e,i)=>t.createElement("g",{key:"oytick-"+i,transform:`translate(0,${e.pixel})`},t.createElement("line",{x2:-5,stroke:y.border,strokeWidth:1}),t.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily},e.label))),o.oLabel&&t.createElement("text",{x:15-(null!==(h=null===(u=o.margin)||void 0===u?void 0:u.left)&&void 0!==h?h:40),y:i.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(d=null===(f=o.margin)||void 0===f?void 0:f.left)&&void 0!==d?d:40)}, ${i.height/2})`},o.oLabel))}(p,{width:h,height:f},e,a,m):null,w=e.annotations?hi({annotations:e.annotations,scales:{r:p.scales.r,y:"vertical"===p.scales.projection?p.scales.r:void 0},layout:{width:h,height:f},theme:a,projection:d,idPrefix:m}):null,S=e.showLegend?(()=>{const t=li(e.data||[],e.colorAccessor||e.stackBy||e.groupBy);return 0===t.length?null:ci({categories:t,colorScheme:e.colorScheme,theme:a,position:e.legendPosition||"right",totalWidth:c[0],totalHeight:c[1],margin:l,hasTitle:!!e.title})})():null,_=g?l.left+h/2:l.left,P=g?l.top+f/2:l.top,E=t.createElement(t.Fragment,null,x,w,k,A);return gi.renderToStaticMarkup(pi(E,{width:c[0],height:c[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:a,innerTransform:`translate(${_},${P})`,legend:S,defs:b,idPrefix:e._idPrefix}))}function Ai(e){var i,o,r,n,s,a,c,l;const u=si(e.theme),h=e.size||[e.width||600,e.height||400],f=Object.assign(Object.assign({},{top:10,right:10,bottom:10,left:10}),e.margin),d=h[0]-(null!==(i=f.left)&&void 0!==i?i:0)-(null!==(o=f.right)&&void 0!==o?o:0),g=h[1]-(null!==(r=f.top)&&void 0!==r?r:0)-(null!==(n=f.bottom)&&void 0!==n?n:0),y=new Qe({projection:e.projection||"equalEarth",xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineType:e.lineType,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform});if(e.areas){if("string"==typeof e.areas)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${e.areas}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${e.areas}')\` before calling renderGeoToStaticSVG.`);y.setAreas(e.areas)}if(e.points&&y.setPoints(e.points),e.lines&&y.setLines(e.lines),y.computeScene({width:d,height:g}),0===y.scene.length)return gi.renderToStaticMarkup(pi(null,{width:h[0],height:h[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:u,innerTransform:`translate(${null!==(s=f.left)&&void 0!==s?s:0},${null!==(a=f.top)&&void 0!==a?a:0})`,idPrefix:e._idPrefix}));const p=y.scene.map((e,i)=>function(e,i){var o,r,n,s,a,c;switch(e.type){case"geoarea":{const n=e;return n.pathData?t.createElement("path",{key:"geoarea-"+i,d:n.pathData,fill:Je(n.style.fill,"#e0e0e0"),fillOpacity:null!==(o=n.style.fillOpacity)&&void 0!==o?o:1,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth||.5,strokeDasharray:n.style.strokeDasharray,opacity:null!==(r=n._decayOpacity)&&void 0!==r?r:1}):null}case"point":{const o=e;return t.createElement("circle",{key:"point-"+i,cx:o.x,cy:o.y,r:o.r,fill:Je(o.style.fill),fillOpacity:null!==(n=o.style.fillOpacity)&&void 0!==n?n:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:null!==(s=o._decayOpacity)&&void 0!==s?s:null!==(a=o.style.opacity)&&void 0!==a?a:1})}case"line":{const o=e;if(2>o.path.length)return null;const r="M"+o.path.map(t=>`${t[0]},${t[1]}`).join("L");return t.createElement("path",{key:"line-"+i,d:r,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||1.5,strokeDasharray:o.style.strokeDasharray,opacity:null!==(c=o.style.opacity)&&void 0!==c?c:1})}default:return null}}(e,i)).filter(Boolean),m=t.createElement(t.Fragment,null,p);return gi.renderToStaticMarkup(pi(m,{width:h[0],height:h[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:u,innerTransform:`translate(${null!==(c=f.left)&&void 0!==c?c:0},${null!==(l=f.top)&&void 0!==l?l:0})`,idPrefix:e._idPrefix}))}function wi(t,e){switch(t){case"xy":return mi(e);case"ordinal":return ki(e);case"network":return bi(e);case"geo":return Ai(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", or "geo".`)}}function Si(t){return mi(t)}function _i(t){return ki(t)}function Pi(t){return bi(t)}function Ei(t){return Ai(t)}function Mi(e,i,o){var r;const{data:n,width:s=600,height:a=400,theme:c,title:l,description:u,showLegend:h,showGrid:f,background:d,className:g,annotations:y,margin:p,colorScheme:m,colorBy:x,legendPosition:v}=i,b=function(t,e){var i={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&0>e.indexOf(o)&&(i[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);o.length>r;r++)0>e.indexOf(o[r])&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(i[o[r]]=t[o[r]])}return i}(i,["data","width","height","theme","title","description","showLegend","showGrid","background","className","annotations","margin","colorScheme","colorBy","legendPosition"]),k=[s,a],A=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},b.frameProps||{}),{theme:c,title:l,description:u,showLegend:h,showGrid:f,background:d,className:g,annotations:y,size:k}),void 0!==p&&{margin:p}),void 0!==m&&{colorScheme:m}),void 0!==v&&{legendPosition:v}),{_idPrefix:b._idPrefix}),w=di[e];if(!w)throw Error(`Unknown chart component: "${e}". See CLAUDE.md for supported chart types.`);const S=w.buildProps(n,x,m,A,b);let _=(0,{xy:mi,ordinal:ki,network:bi,geo:Ai}[w.frameType])(S);if("GaugeChart"===e&&S.__gauge){const e=S.__gauge,i=A.margin||{top:20,right:20,bottom:30,left:40},o=(s||300)-i.left-i.right,n=(a||300)-i.top-i.bottom,l=Math.min(o,n)/2*.85,u=i.left+o/2,h=i.top+n/2,f=Math.max(e.gMin,Math.min(e.gMax,null!==(r=e.value)&&void 0!==r?r:e.gMin)),d=(e.startAngleDeg+(e.gMax===e.gMin?0:(f-e.gMin)/(e.gMax-e.gMin))*e.sweep-90)*Math.PI/180,g=si(c).colors.text,y=gi.renderToStaticMarkup(t.createElement(t.Fragment,null,t.createElement("line",{x1:u,y1:h,x2:u+l*Math.cos(d),y2:h+l*Math.sin(d),stroke:g,strokeWidth:2.5,strokeLinecap:"round"}),t.createElement("circle",{cx:u,cy:h,r:4,fill:g})));_=_.replace("</svg>",y+"</svg>")}return _}function Oi(t,e){return J(this,arguments,void 0,function*(t,e,i={}){var o,r;const{format:n="png",scale:s=1,background:a}=i;let c,l;c=["xy","ordinal","network","geo"].includes(t)?wi(t,e):Mi(t,e),a&&(c=c.replace(/<svg /,`<svg style="background:${a}" `));try{l=require("sharp")}catch(t){throw Error('Image export requires the "sharp" package and a Node.js runtime. Install it:\n npm install sharp\nsharp is listed as an optional dependency of semiotic.')}const u=e.width||(null===(o=e.size)||void 0===o?void 0:o[0])||600,h=e.height||(null===(r=e.size)||void 0===r?void 0:r[1])||400,f=l(void 0!==globalThis.Buffer?globalThis.Buffer.from(c):(new TextEncoder).encode(c),{density:72*s}).resize(Math.round(u*s),Math.round(h*s));return"jpeg"===n?f.jpeg({quality:90}).toBuffer():f.png().toBuffer()})}function Ti(e,i={}){var o;const{title:r,subtitle:n,theme:s,width:a=1200,height:c,layout:l={},background:u}=i,h=ai(si(s)),f=l.columns||2,d=null!==(o=l.gap)&&void 0!==o?o:16;let g=0;r&&(g+=30),n&&(g+=20),g>0&&(g+=10);const y=Math.floor((a-d-d*(f-1))/f),p=[];let m=0,x=g+d,v=0;for(const t of e){const e=Math.min(t.colSpan||1,f),i=t.props.height||300;m+e>f&&(x+=v+d,m=0,v=0),p.push({chart:t,x:d/2+m*(y+d),y:x,w:y*e+d*(e-1),h:i}),v=Math.max(v,i),m+=e}const b=c||x+v+d,k=p.map((e,i)=>{const{chart:o,x:r,y:n,w:a,h:c}=e,l=Object.assign(Object.assign({},o.props),{width:a,height:c,theme:s,_idPrefix:"chart-"+i});let u;return u=o.component?Mi(o.component,l):o.frameType?wi(o.frameType,l):`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${c}"></svg>`,t.createElement("g",{key:"dashboard-chart-"+i,transform:`translate(${r},${n})`},t.createElement("foreignObject",{width:a,height:c},t.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:u}})))}),A=t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:a,height:b,role:"img","aria-label":r||"Dashboard",style:{fontFamily:h.fontFamily}},r&&t.createElement("title",null,r),u&&t.createElement("rect",{x:0,y:0,width:a,height:b,fill:u}),r&&t.createElement("text",{x:a/2,y:24,textAnchor:"middle",fontSize:h.titleSize+4,fontWeight:"bold",fill:h.text,fontFamily:h.fontFamily},r),n&&t.createElement("text",{x:a/2,y:r?46:20,textAnchor:"middle",fontSize:h.labelSize,fill:h.textSecondary,fontFamily:h.fontFamily},n),k);return gi.renderToStaticMarkup(A)}const Li=require("react-dom/server");function $i(t,e,i,o={}){const{stepSize:r,windowSize:n,frameCount:s,xExtent:a,yExtent:c,transitionFrames:l=4,fps:u=12,easing:h="ease-out",decay:f}=o,d=i.width||600,g=i.height||400,y=si(i.theme),p=Object.assign(Object.assign(Object.assign({},i),a&&{xExtent:a}),c&&{yExtent:c});if(!e||0===e.length)return[];const m=r||Math.max(1,Math.ceil(e.length/(s||Math.min(60,Math.max(10,e.length))))),x=[];for(let t=m;e.length>=t;t+=m)x.push(t);x[x.length-1]!==e.length&&x.push(e.length);const v=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(t),b=Object.assign({top:20,right:20,bottom:30,left:40},i.margin),k=d-b.left-b.right,A=g-b.top-b.bottom,w=[];if(v)for(let o=0;x.length>o;o++){const r=x[o],s=e.slice(n?Math.max(0,r-n):0,r),a=Object.assign({chartType:t,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:i.projection||"vertical",oAccessor:i.oAccessor||i.categoryAccessor||"category",rAccessor:i.rAccessor||i.valueAccessor||"value",colorAccessor:i.colorAccessor||i.colorBy,stackBy:i.stackBy,groupBy:i.groupBy,barPadding:i.barPadding,innerRadius:i.innerRadius,normalize:i.normalize,bins:i.bins,colorScheme:i.colorScheme||y.colors.categorical},f&&{decay:f}),c=new Fe(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:k,height:A}),c.scene.length>0&&w.push(Ni(c.scene,d,g,y,p))}else for(let o=0;x.length>o;o++){const r=x[o],s=e.slice(n?Math.max(0,r-n):0,r),m=Object.assign(Object.assign({chartType:t,windowSize:s.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:i.colorAccessor||i.colorBy,groupAccessor:i.groupAccessor||i.lineBy,lineDataAccessor:i.lineDataAccessor,xExtent:a,yExtent:c,colorScheme:i.colorScheme||y.colors.categorical,lineStyle:i.lineStyle,pointStyle:i.pointStyle,areaStyle:i.areaStyle,sizeAccessor:i.sizeAccessor||i.sizeBy,sizeRange:i.sizeRange},f&&{decay:f}),l>0&&{transition:{duration:l*(1e3/u),easing:h}}),v=new St(m);if(v.ingest({inserts:s,bounded:!0}),v.computeScene({width:k,height:A}),0===v.scene.length)continue;const b=v.scales?{y:v.scales.y}:void 0;if(w.push(ji(v.scene,d,g,y,p,b)),l>0&&o>0&&v.activeTransition){const t=l*(1e3/u);for(let e=1;l>=e;e++)v.advanceTransition(v.activeTransition.startTime+e/l*t),w.push(ji(v.scene,d,g,y,p,b))}}return w}function zi(t,e,i={}){return e.map(e=>{try{return Mi(t,Object.assign(Object.assign({},i),e))}catch(t){return`<svg xmlns="http://www.w3.org/2000/svg" width="${i.width||e.width||600}" height="${i.height||e.height||400}"></svg>`}})}function Di(t,e){const i=t.background||e.colors.background;return i&&"transparent"!==i?i:null}function ji(e,i,o,r,n,s){const a=ai(r),c=Object.assign({top:20,right:20,bottom:30,left:40},n.margin),l=i-c.left-c.right,u=o-c.top-c.bottom,h=Di(n,r),f=e.map((t,e)=>ti(t,e)).filter(Boolean),d=function(e,i,o,r,n,s){var a;if(!e||0===e.length)return null;const c=ai(r),l=[];for(let r=0;e.length>r;r++){const u=e[r];if("y-threshold"===u.type&&null!=u.value){let e=null;if(s)e=s(u.value);else if(n){const[t,i]=n,r=i-t;if(0===r)continue;e=o-(u.value-t)/r*o}if(null==e)continue;const h=u.color||c.primary,f=null!==(a=u.strokeWidth)&&void 0!==a?a:1.5,d=u.labelPosition||"right";l.push(t.createElement("g",{key:"ann-"+r},t.createElement("line",{x1:0,y1:e,x2:i,y2:e,stroke:h,strokeWidth:f,strokeDasharray:u.strokeDasharray||"6,4"}),u.label&&t.createElement("text",{x:"left"===d?4:"center"===d?i/2:i-4,y:e-5,textAnchor:"left"===d?"start":"center"===d?"middle":"end",fontSize:c.tickSize,fill:h,fontFamily:c.fontFamily},u.label)))}}return l.length>0?t.createElement(t.Fragment,null,l):null}(n.annotations,l,u,r,n.yExtent,null==s?void 0:s.y),g="string"==typeof n.title?n.title:void 0,y="string"==typeof n.description?n.description:void 0,p=g?"semiotic-title":void 0,m=y?"semiotic-desc":void 0,x=[p,m].filter(Boolean).join(" ")||void 0,v=t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:i,height:o,role:"img","aria-labelledby":x,style:{fontFamily:a.fontFamily}},g&&t.createElement("title",{id:p},g),y&&t.createElement("desc",{id:m},y),h&&t.createElement("rect",{x:0,y:0,width:i,height:o,fill:h}),t.createElement("g",{transform:`translate(${c.left},${c.top})`},d,f),g&&t.createElement("text",{x:i/2,y:16,textAnchor:"middle",fontSize:a.titleSize,fontWeight:"bold",fill:a.text,fontFamily:a.fontFamily},g));return Li.renderToStaticMarkup(v)}function Ni(e,i,o,r,n){const s=ai(r),a=Object.assign({top:20,right:20,bottom:30,left:40},n.margin),c="radial"===n.projection,l=c?a.left+(i-a.left-a.right)/2:a.left,u=c?a.top+(o-a.top-a.bottom)/2:a.top,h=Di(n,r),f=e.map((t,e)=>ei(t,e)).filter(Boolean),d="string"==typeof n.title?n.title:void 0,g="string"==typeof n.description?n.description:void 0,y=d?"semiotic-title":void 0,p=g?"semiotic-desc":void 0,m=[y,p].filter(Boolean).join(" ")||void 0,x=t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:i,height:o,role:"img","aria-labelledby":m,style:{fontFamily:s.fontFamily}},d&&t.createElement("title",{id:y},d),g&&t.createElement("desc",{id:p},g),h&&t.createElement("rect",{x:0,y:0,width:i,height:o,fill:h}),t.createElement("g",{transform:`translate(${l},${u})`},f),d&&t.createElement("text",{x:i/2,y:16,textAnchor:"middle",fontSize:s.titleSize,fontWeight:"bold",fill:s.text,fontFamily:s.fontFamily},d));return Li.renderToStaticMarkup(x)}function Bi(t,e,i){return J(this,arguments,void 0,function*(t,e,i,o={}){const{fps:r=12,loop:n=!0,scale:s=1,background:a}=o,c=i.height||400,l=Math.round((i.width||600)*s),u=Math.round(c*s),h=$i(t,e,a?Object.assign(Object.assign({},i),{background:a}):i,o);if(0===h.length)throw Error("No frames generated — check that data is not empty");let f,d,g,y;try{f=require("sharp")}catch(t){throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t=require("gifenc");d=t.GIFEncoder,g=t.quantize,y=t.applyPalette}catch(t){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc')}const p=Math.round(1e3/r),m=d();for(let t=0;h.length>t;t++){const e=h[t],i=yield f(Buffer.from(e),{density:72*s}).resize(l,u).ensureAlpha().raw().toBuffer(),o=new Uint8Array(i),r=g(o,256),a=y(o,r);m.writeFrame(a,l,u,{palette:r,delay:p,repeat:n?0:-1})}return m.finish(),Buffer.from(m.bytes())})}export{$i as generateFrameSVGs,zi as generateFrameSequence,Mi as renderChart,Ti as renderDashboard,Ei as renderGeoToStaticSVG,Pi as renderNetworkToStaticSVG,_i as renderOrdinalToStaticSVG,Bi as renderToAnimatedGif,Oi as renderToImage,wi as renderToStaticSVG,Si as renderXYToStaticSVG,si as resolveTheme,ai as themeStyles};
|