semiotic 3.4.1 → 3.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{jsx as t,jsxs as e,Fragment as i}from"react/jsx-runtime";import*as o from"react-dom/server";import{scaleOrdinal as r,scaleLinear as n,scaleLog as s,scaleTime as a,scaleBand as c}from"d3-scale";import{quadtree as l}from"d3-quadtree";import{interpolatePlasma as h,interpolateViridis as u,interpolatePurples as d,interpolateOranges as f,interpolateGreens as g,interpolateReds as y,interpolateBlues as p,schemeSet3 as m,schemeTableau10 as v,schemeCategory10 as x,interpolateTurbo as b,interpolateCividis as k,interpolateMagma as A,interpolateInferno as w,interpolateGreys as S}from"d3-scale-chromatic";import{min as _,groups as P,max as M,sum as O,mean as T,group as E,quantile as L}from"d3-array";import{interpolateNumber as j}from"d3-interpolate";import{forceLink as D,forceSimulation as z,forceManyBody as $,forceCenter as R,forceX as C,forceY as N}from"d3-force";import{ribbon as W,chord as B}from"d3-chord";import{arc as F,pie as Y}from"d3-shape";import{hierarchy as I,partition as X,pack as q,treemap as G,treemapBinary as V,cluster as H,tree as Q}from"d3-hierarchy";import{geoPath as Z,geoGraticule as U,geoDistance as K,geoInterpolate as J,geoEqualEarth as tt,geoEquirectangular as et,geoNaturalEarth1 as it,geoOrthographic as ot,geoAlbersUsa as rt,geoMercator as nt}from"d3-geo";import*as st from"react";import{createContext as at,useMemo as ct,useContext as lt,useRef as ht,useCallback as ut,useSyncExternalStore as dt}from"react";function ft(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 gt{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;return{next:()=>this._size>t?{done:!1,value:this.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 yt{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 pt(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 mt(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function vt(t,e){if("function"==typeof t)return e=>+t(e);const i=t||e;return t=>+t[i]}function xt(t,e){if("function"==typeof t)return t;const i=t||e;return t=>t[i]}function bt(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}const kt={category10:x,tableau10:v,set3:m,blues:p,reds:y,greens:g,oranges:f,purples:d,viridis:u,plasma:h},At=x,wt=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],St=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function _t(t,e,i="category10"){const o=Array.from(new Set(t.map(t=>null==t?void 0:t[e]).filter(t=>null!=t))),n=o.every(t=>"number"==typeof t||!isNaN(Number(t)));if(Array.isArray(i))return r().domain(o).range(i).unknown("#999");const s=kt[i]||kt.category10;if(n&&"function"==typeof s){let t=-1/0;for(const e of o){const i=Number(e);i>t&&(t=i)}return e=>s(Number(e)/t)}{const t=Array.isArray(s)?s:At;return r().domain(o).range(t).unknown("#999")}}function Pt(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 Mt(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 Ot(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function Tt(t,e){return Math.min((t-e.startTime)/e.duration,1)}function Et(t,e,i){return t+(e-t)*i}function Lt(){return"undefined"!=typeof performance?performance.now():Date.now()}function jt(t,e,i){var o,r,n,s;if(e._transitionKey)return e._transitionKey;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 Dt(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 zt(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),h=a?a(n):r;c.push({px:l,topY:e.y(s),botY:e.y(h)})}c.sort((t,e)=>t.px-e.px);const l=Array(c.length),h=Array(c.length);for(let t=0;c.length>t;t++){const e=c[t];l[t]=[e.px,e.topY],h[t]=[e.px,e.botY]}return{type:"area",topPath:l,bottomPath:h,style:n,datum:t,group:s}}function $t(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 Rt(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 Ct(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 Nt(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 Wt(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=$t(s,t.scales,t.getX,n,a,o,c);l&&i.push(l)}}}const Bt={blues:p,reds:y,greens:g,viridis:u,oranges:f,purples:d,greys:S,plasma:h,inferno:w,magma:A,cividis:k,turbo:b},Ft=new Map;class Yt{constructor(t){if(this.xExtent=new yt,this.yExtent=new yt,this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,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._maxPointRadius=0,this.config=t,this.buffer=new gt(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=vt(t.timeAccessor||t.xAccessor,"time"),this.getY=vt(t.valueAccessor||t.yAccessor,"value")):(this.getX=vt(t.xAccessor,"x"),this.getY=vt(t.yAccessor,"y")),this.getGroup=bt(t.groupAccessor),this.getCategory=bt(t.categoryAccessor),this.getSize=t.sizeAccessor?vt(t.sizeAccessor,"size"):void 0,this.getColor=bt(t.colorAccessor),this.getBounds=t.boundsAccessor?vt(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?vt(t.y0Accessor,"y0"):void 0,this.getPointId=bt(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,i=null!=t.closeAccessor;this.getOpen=e?vt(t.openAccessor,"open"):void 0,this.getHigh=vt(t.highAccessor,"high"),this.getLow=vt(t.lowAccessor,"low"),this.getClose=i?vt(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!i}t.pulse&&(this.timestampBuffer=new gt(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?vt(this.config.timeAccessor||this.config.xAccessor,"time"):vt(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,c,l,h;const{config:u,buffer:d}=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(d,this.getX),this.yExtent.dirty)if("candlestick"===u.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of d)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(d,this.getY);const f=this.getBufferArray(),g=this.xExtent.extent,y=this.yExtent.extent;let p=u.xExtent?[null!==(i=u.xExtent[0])&&void 0!==i?i:g[0],null!==(o=u.xExtent[1])&&void 0!==o?o:g[1]]:g,m=u.yExtent?[null!==(r=u.yExtent[0])&&void 0!==r?r:y[0],null!==(c=u.yExtent[1])&&void 0!==c?c:y[1]]:y;const v=u.yExtent&&null!=u.yExtent[0]&&null!=u.yExtent[1];if("stackedarea"===u.chartType&&!v&&d.size>0)if(u.normalize)m=[0,1+u.extentPadding];else{const t=`${d.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)m=this._stackExtentCache.yDomain;else{const e=this.groupData(f),i=new Map;let o=0;for(const t of e)for(const e of t.data){const t=this.getX(e),r=this.getY(e);if(null==t||null==r||Number.isNaN(t)||Number.isNaN(r))continue;const n=(i.get(t)||0)+r;i.set(t,n),n>o&&(o=n)}m=[0,o+(o>0?o*u.extentPadding:1)],this._stackExtentCache={key:t,yDomain:m}}}else if("bar"===u.chartType&&u.binSize&&!v&&d.size>0){const[,t]=function(t,e,i,o,r){const n=pt(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]}(d,this.getX,this.getY,u.binSize,this.getCategory);m=[0,t+t*u.extentPadding]}else if("waterfall"===u.chartType&&!v&&d.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]}(d,this.getY),i=e-t,o=i>0?i*u.extentPadding:1;m=[Math.min(0,t-Math.abs(o)),Math.max(0,e+Math.abs(o))]}else if(!v&&m[0]!==1/0){if(this.getBounds)for(const t of f){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*u.extentPadding:1,i=null===(l=u.yExtent)||void 0===l?void 0:l[0],o=null===(h=u.yExtent)||void 0===h?void 0:h[1];m=[null!=i?m[0]:m[0]-e,null!=o?m[1]:m[1]+e],"log"===u.yScaleType&&0>=m[0]&&y[0]>0&&(m[0]=null!=i?m[0]:y[0]/(1+u.extentPadding))}if(p[0]===1/0||p[1]===-1/0)if("time"===u.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 x="streaming"===u.runtimeMode,b=Math.max(0,Math.min(u.scalePadding||0,Math.min(t.width,t.height)/2-1));if(x)if("x"==("up"===(k=u.arrowOfTime)||"down"===k?"y":"x")){const e="right"===u.arrowOfTime?[b,t.width-b]:[t.width-b,b];this.scales={x:n().domain(p).range(e),y:n().domain(m).range([t.height-b,b])}}else{const e="down"===u.arrowOfTime?[b,t.height-b]:[t.height-b,b];this.scales={x:n().domain(m).range([b,t.width-b]),y:n().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 s().domain(t).range(i).clamp(!0)}return"time"===t?a().domain([new Date(e[0]),new Date(e[1])]).range(i):n().domain(e).range(i)};this.scales={x:e(u.xScaleType,p,[b,t.width-b]),y:e(u.yScaleType,m,[t.height-b,b])}}var k;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,f),this.config.decay&&this.applyDecay(this.scene,f),this.config.pulse&&this.applyPulse(this.scene,f),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),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 this._quadtree=null,void(this._maxPointRadius=0);let e=0,i=0;for(const t of this.scene)"point"===t.type&&(e++,t.r>i&&(i=t.r));if(this._maxPointRadius=i,Yt.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const o=Array(e);let r=0;for(const t of this.scene)"point"===t.type&&(o[r++]=t);this._quadtree=l().x(t=>t.x).y(t=>t.y).addAll(o)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}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(),c=this.scales.x.range(),l=this.scales.y.range(),h=(t,e,i)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return s().domain(t).range(i).clamp(!0)}return"time"===t?a().domain([new Date(e[0]),new Date(e[1])]).range(i):n().domain(e).range(i)},u=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),d=l[1]>l[0];this.scales={x:h(this.config.xScaleType,o,c[0]>c[1]?[t.width-u,u]:[u,t.width-u]),y:h(this.config.yScaleType,r,d?[u,t.height-u]:[t.height-u,u])},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=Nt(t,e.data,e.key);i&&r.push(i)}for(const e of o){const i=t.resolveLineStyle(e.key,e.data[0]),o=Dt(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 Wt(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=zt(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 Wt(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=zt(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=Dt(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 Wt(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),h=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)}h.set(e.key,t)}let u;if(n){u=new Map;for(const e of l){let i=0;for(const o of t)i+=(null===(a=h.get(o.key))||void 0===a?void 0:a.get(e))||0;u.set(e,i||1)}}const d=[],f=new Map,g=new Map;for(const t of l)g.set(t,0);for(const i of t){const t=h.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/=u.get(i));const l=s+r,h=e.x(i);a.push([h,e.y(s)]),o.push([h,e.y(l)]),g.set(i,l),c.set(i,l)}f.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),d.push(y)}return{nodes:d,stackedTops:f}}(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)};Wt(t,i,s,o)}return s}(n,e);case"scatter":case"bubble":return function(t,e){var i;const o=[],r="bubble"===t.config.chartType?10:5,n=t.config.sizeRange||[3,15];let s=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);s=i=>t===e?(n[0]+n[1])/2:n[0]+(i-t)/(e-t)*(n[1]-n[0])}}const a=t.getColor?t.resolveColorMap(e):null,c=(null===(i=t.config.themeSemantic)||void 0===i?void 0:i.primary)||"#4e79a7";for(const i of e){let e=t.config.pointStyle?t.config.pointStyle(i):{fill:c,opacity:.8},n=e.r||r;if(s&&t.getSize){const e=t.getSize(i);null==e||Number.isNaN(e)||(n=s(e))}if(a&&t.getColor&&!e.fill){const o=t.getColor(i);o&&a.has(o)&&(e=Object.assign(Object.assign({},e),{fill:a.get(o)}))}const l=t.getPointId?t.getPointId(i)+"":void 0,h=$t(i,t.scales,t.getX,t.getY,n,e,l);h&&o.push(h)}return o}(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=vt(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[h,u]=t.scales.x.domain(),[d,f]=t.scales.y.domain(),g=(u-h||1)/s,y=(f-d||1)/a,p=s*a;if(p>1e6)return[];const m=new Int32Array(p),v=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-h)/g),s-1),u=Math.min(Math.floor((n-d)/y),a-1);if(0>c||0>u)continue;const f=u*s+c;m[f]++;const p=l(o);v[f]+=isFinite(p)?p:0}let x=1/0,b=-1/0;for(let t=0;p>t;t++){if(0===m[t])continue;let e;switch(c){case"sum":e=v[t];break;case"mean":e=v[t]/m[t];break;default:e=m[t]}x>e&&(x=e),e>b&&(b=e)}if(!isFinite(x))return[];const k=b-x||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=v[o];break;case"mean":r=v[o]/m[o];break;default:r=m[o]}const n=(r-x)/k;P.push(Ct(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:v[o]},S?{value:r,showValues:!0,valueFormat:_}:void 0))}}return P}(t,e,i);if(0===e.length)return[];const o=vt(t.config.valueAccessor,"value"),r=xt(t.config.xAccessor,"x"),n=xt(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),h=n(i);c[t]=o,l[t]=h,s.has(o)||s.set(o,s.size),a.has(h)||a.set(h,a.size)}const h=s.size,u=a.size;if(0===h||0===u)return[];const d=Array.from(s.keys()),f=Array.from(a.keys()),g=d.every(t=>"number"==typeof t&&!isNaN(t)),y=f.every(t=>"number"==typeof t&&!isNaN(t));if(g){d.sort((t,e)=>t-e),s.clear();for(let t=0;d.length>t;t++)s.set(d[t],t)}if(y){f.sort((t,e)=>t-e),a.clear();for(let t=0;f.length>t;t++)a.set(f[t],t)}const m=new Float64Array(e.length),v=new Float64Array(e.length),x=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 u=o(i),d=n*h+r,f=b.get(d);let g;void 0!==f?g=f:(g=k++,b.set(d,g)),m[g]=d,v[g]=u,x[g]=i}let A=1/0,w=-1/0;for(let t=0;k>t;t++){const e=v[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 Bt?t:"blues";let i=Ft.get(e);if(i)return i;i=Array(256);const o=Bt[e]||p;for(let t=0;256>t;t++)i[t]=o(t/255);return Ft.set(e,i),i}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),_=255/(w-A||1),P=i.width/h,M=i.height/u,O=t.config.showValues,T=t.config.heatmapValueFormat,E=[];for(let t=0;k>t;t++){const e=v[t];if(!isFinite(e))continue;const i=m[t],o=i%h;E.push(Ct(o*P,(u-1-(i-o)/h)*M,P,M,S[Math.min((e-A)*_+.5|0,255)],x[t],O?{value:e,showValues:!0,valueFormat:T}:void 0))}return E}(n,e,t);case"bar":{const t=function(t,e){var i,o;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const r=pt(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===r.size)return{nodes:[],binBoundaries:[]};let n=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):[],o=new Set(i),s=Array.from(e).filter(t=>!o.has(t)).sort(),a=i.filter(t=>e.has(t)),c=a.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===c?n=t.barCategoryCache.order:(n=[...a,...s],t.barCategoryCache={key:c,order:n})}const s=[],a=t.scales,[c,l]=a.x.domain(),h=t.config.barStyle,u=null===(i=t.config.themeSemantic)||void 0===i?void 0:i.primary,d=null==h?void 0:h.gap,f="number"!=typeof d||0>d?1:d,g={};(null==h?void 0:h.stroke)&&(g.stroke=h.stroke),"number"==typeof(null==h?void 0:h.strokeWidth)&&(g.strokeWidth=h.strokeWidth),"number"==typeof(null==h?void 0:h.opacity)&&(g.opacity=h.opacity);for(const e of r.values()){const i=Math.max(e.start,c),r=Math.min(e.end,l);if(i>=r)continue;const d=a.x(i),y=a.x(r),p=Math.abs(y-d),m=p>f+1?f:0,v=Math.min(d,y)+m/2,x=Math.max(p-m,1);if(x>0)if(n&&e.categories.size>0){let i=0;for(const r of n){const n=e.categories.get(r)||0;if(0===n)continue;const c=a.y(i),l=a.y(i+n),d=(null===(o=t.config.barColors)||void 0===o?void 0:o[r])||(null==h?void 0:h.fill)||u||"#4e79a7";s.push(Rt(v,Math.min(c,l),x,Math.abs(c-l),Object.assign({fill:d},g),{binStart:e.start,binEnd:e.end,total:e.total,category:r,categoryValue:n},r)),i+=n}}else{const t=a.y(0),i=a.y(e.total);s.push(Rt(v,Math.min(t,i),x,Math.abs(t-i),Object.assign({fill:(null==h?void 0:h.fill)||u||"#007bff"},g),{binStart:e.start,binEnd:e.end,total:e.total}))}}const y=new Set;for(const t of r.values())y.add(t.start),y.add(t.end);return{nodes:s,binBoundaries:Array.from(y).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,s,a;const c=[],l=t.config.swarmStyle||{},h=null!==(i=l.radius)&&void 0!==i?i:3,u=null!==(n=null!==(o=l.fill)&&void 0!==o?o:null===(r=t.config.themeSemantic)||void 0===r?void 0:r.primary)&&void 0!==n?n:"#007bff",d=null!==(s=l.opacity)&&void 0!==s?s:.7,f=l.stroke,g=l.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),n=t.scales.y(o);let s=u;if(t.getCategory){const e=t.getCategory(i);s=(null===(a=t.config.barColors)||void 0===a?void 0:a[e])||s}const l={type:"point",x:r,y:n,r:h,style:{fill:s,opacity:d,stroke:f,strokeWidth:g},datum:i};t.getPointId&&(l.pointId=t.getPointId(i)+""),c.push(l)}return c}(n,e);case"waterfall":return function(t,e,i){var o,r,n,s,a,c,l;const h=[],u=t.scales,d=t.config.waterfallStyle,f=e.filter(e=>{const i=t.getY(e),o=t.getX(e);return null!=i&&!Number.isNaN(i)&&null!=o&&isFinite(o)});if(0===f.length)return h;const g=null!==(n=null!==(o=null==d?void 0:d.positiveColor)&&void 0!==o?o:null===(r=t.config.themeSemantic)||void 0===r?void 0:r.success)&&void 0!==n?n:"#28a745",y=null!==(c=null!==(s=null==d?void 0:d.negativeColor)&&void 0!==s?s:null===(a=t.config.themeSemantic)||void 0===a?void 0:a.danger)&&void 0!==c?c:"#dc3545",p=null!==(l=null==d?void 0:d.gap)&&void 0!==l?l:1,m=null==d?void 0:d.stroke,v=null==d?void 0:d.strokeWidth,x=null==d?void 0:d.opacity;let b=0;for(let e=0;f.length>e;e++){const o=f[e],r=t.getX(o),n=t.getY(o),s=b+n;let a;a=f.length-1>e?t.getX(f[e+1])-r:e>0?r-t.getX(f[e-1]):0;const c=u.x(r),l=0!==a?u.x(r+a):c+i.width/10,k=Math.min(c,l)+p/2,A=Math.max(c,l)-p/2-k;if(0>=A){b=s;continue}const w=u.y(b),S=u.y(s),_=Math.min(w,S),P=Math.abs(w-S),M={fill:0>n?y:g,stroke:m,strokeWidth:v};null!=x&&(M.opacity=x),h.push(Rt(k,_,A,P,M,Object.assign(Object.assign({},o),{baseline:b,cumEnd:s,delta:n,_connectorStroke:null==d?void 0:d.connectorStroke,_connectorWidth:null==d?void 0:d.connectorWidth}))),b=s}return h}(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",h=r?a:s.wickColor||"#333",u=s.wickWidth||(r?2:1),d=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let f=null!==(o=s.bodyWidth)&&void 0!==o?o:0;if(null==s.bodyWidth)if(d.length>1){let e=1/0;for(let i=1;d.length>i;i++){const o=Math.abs(t.scales.x(d[i])-t.scales.x(d[i-1]));o>0&&e>o&&(e=o)}f=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else f=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),d=r?s:t.getClose(i);if(!r&&[a,d].some(t=>null==t||Number.isNaN(t)))continue;const g=d>=a,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(a),closeY:t.scales.y(d),highY:t.scales.y(o),lowY:t.scales.y(s),bodyWidth:f,upColor:c,downColor:l,wickColor:h,wickWidth:u,isUp:g,datum:i};r&&(y.isRange=!0),n.push(y)}return n}(n,e);default:return[]}}resolveBoundsStyle(t,e){var i;const o=this.config.boundsStyle;return"function"==typeof o?o(e||{},t):o&&"object"==typeof o?o:{fill:this.resolveLineStyle(t,e).stroke||(null===(i=this.config.themeSemantic)||void 0===i?void 0:i.primary)||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?Pt(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]=Pt(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]=Pt(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=Pt(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=Pt(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=Mt(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=Mt(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,a;i.clear(),o.clear();for(let c=0;e.length>c;c++){const l=e[c],h=jt(t,l,c);h&&("point"===l.type?i.set(h,{x:l.x,y:l.y,r:l.r,opacity:l.style.opacity}):"rect"===l.type?i.set(h,{x:l.x,y:l.y,w:l.w,h:l.h,opacity:l.style.opacity}):"heatcell"===l.type?i.set(h,{x:l.x,y:l.y,w:l.w,h:l.h,opacity:null===(r=l.style)||void 0===r?void 0:r.opacity}):"candlestick"===l.type?i.set(h,{x:l.x,y:l.openY,w:l.bodyWidth,openY:l.openY,closeY:l.closeY,highY:l.highY,lowY:l.lowY,opacity:null===(n=l.style)||void 0===n?void 0:n.opacity}):"line"===l.type?o.set(h,{path:l.path.map(t=>[t[0],t[1]]),opacity:null===(s=l.style)||void 0===s?void 0:s.opacity}):"area"===l.type&&o.set(h,{topPath:l.topPath.map(t=>[t[0],t[1]]),bottomPath:l.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(a=l.style)||void 0===a?void 0:a.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){var t,e,i;this.prevPositionMap.clear(),this.prevPathMap.clear();const o=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.y(0))&&void 0!==e?e:0;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],r=jt(this.transitionContext,e,t);r&&("point"===e.type?this.prevPositionMap.set(r,{x:e.x,y:e.y,r:0,opacity:0}):"rect"===e.type?this.prevPositionMap.set(r,{x:e.x,y:o,w:e.w,h:0,opacity:null!==(i=e.style.opacity)&&void 0!==i?i:1}):"heatcell"===e.type?this.prevPositionMap.set(r,{x:e.x,y:e.y,w:e.w,h:e.h,opacity:0}):"line"===e.type?(e._introClipFraction=0,this.prevPathMap.set(r,{path:e.path.map(t=>[t[0],t[1]]),opacity:e.style.opacity})):"area"===e.type&&(e._introClipFraction=0,this.prevPathMap.set(r,{topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),opacity:e.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,i,o,r){var n,s,a,c,l,h,u,d,f,g,y,p,m,v,x,b,k,A,w,S,_,P,M,O,T,E,L,j,D,z,$,R,C,N,W,B,F,Y,I,X,q;if(0===o.size&&0===r.size)return i;const G=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 V=!1;const H=new Set,Q=new Set;for(let e=0;i.scene.length>e;e++){const n=i.scene[e],E=jt(t,n,e);if(!E)continue;if(n._transitionKey=E,"line"===n.type||"area"===n.type){const t=r.get(E);if(t){if(Q.add(E),"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]];V=!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]];V=!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}),V=!0;continue}const L=o.get(E);if("point"===n.type)if(L){H.add(E);const t={x:n.x,y:n.y,r:n.r};n._targetOpacity=null!==(h=n.style.opacity)&&void 0!==h?h:1,L.x===t.x&&L.y===t.y&&L.r===t.r||(n._targetX=t.x,n._targetY=t.y,n._targetR=t.r,n.x=L.x,n.y=L.y,n.r=null!==(u=L.r)&&void 0!==u?u:n.r,V=!0)}else n._targetOpacity=null!==(d=n.style.opacity)&&void 0!==d?d:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),V=!0;else if("rect"===n.type)if(L){H.add(E);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=null!==(f=n.style.opacity)&&void 0!==f?f:1,L.x===t.x&&L.y===t.y&&L.w===t.w&&L.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=L.x,n.y=L.y,n.w=null!==(g=L.w)&&void 0!==g?g:n.w,n.h=null!==(y=L.h)&&void 0!==y?y:n.h,V=!0)}else n._targetOpacity=null!==(p=n.style.opacity)&&void 0!==p?p:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),V=!0;else if("heatcell"===n.type)if(L){H.add(E);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=null!==(v=null===(m=n.style)||void 0===m?void 0:m.opacity)&&void 0!==v?v:1,L.x===t.x&&L.y===t.y&&L.w===t.w&&L.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=L.x,n.y=L.y,n.w=null!==(x=L.w)&&void 0!==x?x:n.w,n.h=null!==(b=L.h)&&void 0!==b?b:n.h,V=!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}),V=!0;else if("candlestick"===n.type)if(L&&null!=L.openY){H.add(E);const t={x:n.x,openY:n.openY,closeY:n.closeY,highY:n.highY,lowY:n.lowY};n._targetOpacity=null!==(S=null===(w=n.style)||void 0===w?void 0:w.opacity)&&void 0!==S?S:1,(L.x!==t.x||L.openY!==t.openY||L.closeY!==t.closeY||L.highY!==t.highY||L.lowY!==t.lowY)&&(n._targetX=t.x,n._targetOpenY=t.openY,n._targetCloseY=t.closeY,n._targetHighY=t.highY,n._targetLowY=t.lowY,n.x=L.x,n.openY=L.openY,n.closeY=null!==(_=L.closeY)&&void 0!==_?_:n.closeY,n.highY=null!==(P=L.highY)&&void 0!==P?P:n.highY,n.lowY=null!==(M=L.lowY)&&void 0!==M?M:n.lowY,V=!0)}else n._targetOpacity=null!==(T=null===(O=n.style)||void 0===O?void 0:O.opacity)&&void 0!==T?T:1,n.style=Object.assign(Object.assign({},n.style||{}),{opacity:0}),V=!0}for(const[t,e]of r)if(!Q.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!==(E=e.opacity)&&void 0!==E?E:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),V=!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!==(L=e.opacity)&&void 0!==L?L:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),V=!0}for(const[t,e]of o)if(!H.has(t)){if(t.startsWith("p:")){const o={type:"point",x:e.x,y:e.y,r:null!==(j=e.r)&&void 0!==j?j:3,style:{opacity:null!==(D=e.opacity)&&void 0!==D?D: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!==(z=e.w)&&void 0!==z?z:0,h:null!==($=e.h)&&void 0!==$?$:0,style:{opacity:null!==(R=e.opacity)&&void 0!==R?R: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!==(C=e.w)&&void 0!==C?C:0,h:null!==(N=e.h)&&void 0!==N?N:0,fill:"#999",datum:null,style:{opacity:null!==(W=e.opacity)&&void 0!==W?W:1},_targetOpacity:0,_transitionKey:t};i.exitNodes.push(o)}else if(t.startsWith("c:")){const o=null!==(B=e.openY)&&void 0!==B?B:e.y,r={type:"candlestick",x:e.x,openY:o,closeY:null!==(F=e.closeY)&&void 0!==F?F:o,highY:null!==(Y=e.highY)&&void 0!==Y?Y:o,lowY:null!==(I=e.lowY)&&void 0!==I?I:o,bodyWidth:null!==(X=e.w)&&void 0!==X?X:6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:null!==(q=e.opacity)&&void 0!==q?q:1},_targetOpacity:0,_transitionKey:t};i.exitNodes.push(r)}V=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),V&&(i.activeTransition={startTime:Lt(),duration:G}),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,l;if(!i.activeTransition)return!1;const h=Tt(t,i.activeTransition),u=Ot(h,"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=Et(n,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Et(i.x,t._targetX,u),t.y=Et(i.y,t._targetY,u),void 0!==t._targetR&&void 0!==i.r&&(t.r=Et(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=Et(r,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Et(i.x,t._targetX,u),t.y=Et(i.y,t._targetY,u),void 0!==i.w&&(t.w=Et(i.w,t._targetW,u)),void 0!==i.h&&(t.h=Et(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:Et(r,t._targetOpacity,u)})}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Et(i.x,t._targetX,u),t.y=Et(i.y,t._targetY,u),void 0!==i.w&&(t.w=Et(i.w,t._targetW,u)),void 0!==i.h&&(t.h=Et(i.h,t._targetH,u))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,r=i?null!==(a=i.opacity)&&void 0!==a?a:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:Et(r,t._targetOpacity,u)})}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Et(i.x,t._targetX,u),void 0!==i.openY&&(t.openY=Et(i.openY,t._targetOpenY,u)),void 0!==i.closeY&&(t.closeY=Et(i.closeY,t._targetCloseY,u)),void 0!==i.highY&&(t.highY=Et(i.highY,t._targetHighY,u)),void 0!==i.lowY&&(t.lowY=Et(i.lowY,t._targetLowY,u))}else if("line"===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:Et(e,t._targetOpacity,u)})}void 0!==t._introClipFraction&&(t._introClipFraction=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]=Et(e[o][0],i[o][0],u),t.path[o][1]=Et(e[o][1],i[o][1],u)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(l=t._startOpacity)&&void 0!==l?l:0;t.style=Object.assign(Object.assign({},t.style),{opacity:Et(e,t._targetOpacity,u)})}void 0!==t._introClipFraction&&(t._introClipFraction=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]=Et(e[i][0],o[i][0],u),t.topPath[i][1]=Et(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]=Et(i[e][0],r[e][0],u),t.bottomPath[e][1]=Et(i[e][1],r[e][1],u)}}if(h>=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("candlestick"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=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,t._introClipFraction=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,t._introClipFraction=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){if(this._colorMapCache&&this._colorMapCache.version===this._ingestVersion)return this._colorMapCache.map;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.version=this._ingestVersion,this._colorMapCache.map;const r=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||wt,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,version:this._ingestVersion},n}resolveLineStyle(t,e){var i;const o=this.config.lineStyle;if("function"==typeof o){const i=o(e||{},t);if(i&&!i.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{stroke:e})}return i}const r=null===(i=this.config.themeSemantic)||void 0===i?void 0:i.primary;return o&&"object"==typeof o?{stroke:o.stroke||r||"#007bff",strokeWidth:o.strokeWidth||2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity}:{stroke:this.resolveGroupColor(t)||r||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var i,o;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}const n=null===(i=this.config.themeSemantic)||void 0===i?void 0:i.primary;if(r&&"object"==typeof r)return{fill:r.fill||r.stroke||n||"#4e79a7",fillOpacity:null!==(o=r.fillOpacity)&&void 0!==o?o:.7,stroke:r.stroke||n||"#4e79a7",strokeWidth:r.strokeWidth||2};const s=this.resolveGroupColor(t)||n||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,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.length>0?this.config.colorScheme:null)||(Array.isArray(this.config.themeCategorical)&&this.config.themeCategorical.length>0?this.config.themeCategorical:null)||wt;if(0===i.length)return null;const o=i[this._groupColorCounter%i.length];if(this._groupColorCounter++,this._groupColorMap.set(t,o),this._groupColorMap.size>Yt.GROUP_COLOR_MAP_CAP){const t=this._groupColorMap.keys().next().value;void 0!==t&&this._groupColorMap.delete(t)}return 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._hasRenderedOnce=!1,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._maxPointRadius=0,this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,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);("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(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||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const c=a||!mt(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(i=n.xAccessor)&&void 0!==i?i:n.timeAccessor),l=a||!mt(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=vt(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=vt(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=vt(this.config.xAccessor,"x"),this.getY=vt(this.config.yAccessor,"y")),s=!0)}if("groupAccessor"in t&&!mt(t.groupAccessor,n.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?bt(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in t&&!mt(t.categoryAccessor,n.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?bt(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in t&&!mt(t.sizeAccessor,n.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?vt(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in t&&!mt(t.colorAccessor,n.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?bt(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in t&&!mt(t.y0Accessor,n.y0Accessor)&&(this.getY0=this.config.y0Accessor?vt(this.config.y0Accessor,"y0"):void 0,s=!0),"pointIdAccessor"in t&&!mt(t.pointIdAccessor,n.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?bt(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&("openAccessor"in t&&!mt(t.openAccessor,n.openAccessor)||"closeAccessor"in t&&!mt(t.closeAccessor,n.closeAccessor)||"highAccessor"in t&&!mt(t.highAccessor,n.highAccessor)||"lowAccessor"in t&&!mt(t.lowAccessor,n.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?vt(this.config.openAccessor,"open"):void 0,this.getHigh=vt(this.config.highAccessor,"high"),this.getLow=vt(this.config.lowAccessor,"low"),this.getClose=e?vt(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 It(t,e){var i=t.get(e);if(!i)throw Error("missing: "+e);return i}function Xt(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,u=!1;for(r.push(t),n[t]=!0,e=0;a[t].length>e;e++)(o=a[t][e])===i?(h(i,r),u=!0):n[o]||(u=l(o));if(u)c(t);else for(e=0;a[t].length>e;e++){var d=s[o=a[t][e]];d||(s[o]=d={}),d[o]=!0}return r.pop(),u}function h(t,e){var i=[].concat(e).concat(t);o.push(i)}function u(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,h=0,u=[],d=[];function f(e){var c=[e],l=[e];for(i[e]=o[e]=h,r[e]=!0,h+=1;l.length>0;){var f=t[e=l[l.length-1]];if(f.length>n[e]){for(var g=n[e];f.length>g;++g){var y=f[g];if(0>i[y]){i[y]=o[y]=h,r[y]=!0,h+=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=[],v=0;for(g=c.length-1;g>=0;--g){var x=c[g];if(r[x]=!1,p.push(x),m.push(a[x]),v+=a[x].length,s[x]=u.length,x===e){c.length=g;break}}u.push(p);var b=Array(v);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)b[--v]=m[g][k];d.push(b)}l.pop()}}}for(c=0;e>c;++c)0>i[c]&&f(c);for(c=0;d.length>c;c++){var g=d[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]);d[c]=l}}return{components:u,adjacencyList:d}}(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 d=t.length;d>i;){var f=u(i);if(i=f.leastVertex,a=f.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=d}return o}function qt(t){return t.y0-t.y1>0?"up":"down"}function Gt(t,e){return e(t.source)==e(t.target)}function Vt(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 Ht(t){return t.target.x0-t.source.x1}function Qt(t,e){var i=Ut(t),o=Ht(e)/Math.tan(i);return"up"==qt(t)?t.y1-o:t.y1+o}function Zt(t,e){var i=Ut(t),o=Ht(e)/Math.tan(i);return"up"==qt(t)?t.y1+o:t.y1-o}function Ut(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function Kt(t,e){return e(t)}function Jt(t){return ee(t.source)}function te(t){return ee(t.target)}function ee(t){return(t.y0+t.y1)/2}function ie(t){return t.virtual?0:t.value}function oe(t,e){var i=0;t.sourceLinks.forEach(function(t){i=t.circular&&!Gt(t,e)?i+1:i});var o=0;return t.targetLinks.forEach(function(t){o=t.circular&&!Gt(t,e)?o+1:o}),i+o}function re(t){return t.target.depth}function ne(t,e){return t.sourceLinks.length?t.depth:e-1}function se(t,e){return t.y0-e.y0}function ae(t,e){return e.y0-t.y0}function ce(t,e){return t.y1-e.y1}function le(t,e){return e.y1-t.y1}function he(t,e){return de(t.source,e.source)||t.index-e.index}function ue(t,e){return de(t.target,e.target)||t.index-e.index}function de(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function fe(t,e){return ge(t)==ge(e)?"bottom"==t.circularLinkType?ae(t,e):se(t,e):ge(e)-ge(t)}function ge(t){return t.target.column-t.source.column}function ye(t,e){return pe(t)==pe(e)}function pe(t){return t.y0-t.y1>0?"up":"down"}function me(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=_(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}),ve(n.links.filter(function(t){return"top"==t.circularLinkType}),e,i),ve(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,Gt(t,e)&&Vt(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?ae:se);var h=0;l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2+h,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2+r*i+h),h+=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?le:ce),h=0,l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2+h,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2+r*i+h),h+=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 ve(t,e,i){t.sort(fe);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(Gt(t,e)&&Vt(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&&xe(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 xe(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function be(t){return function(){return t}}function ke(t){return t.index}function Ae(t){return t.nodes}function we(t){return t.links}function Se(t,e,i){var o=P(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+=ee(t.source)*e,o+=e}}),i.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=ee(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?oe(e,i)-oe(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==oe(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 _e(t,e,i,o,r,n){var s=P(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});h();for(var a=1,c=n;c>0;--c)l(a*=.99,i),h();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&&oe(r,i)>0){var c=T(r.sourceLinks,te),l=T(r.targetLinks,Jt),h=c&&l?(c+l)/2:c||l;if(h){var u=(h-ee(r))*e*.3;r.y0+=u,r.y1+=u}}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 d=T(r.sourceLinks,te),f=T(r.targetLinks,Jt),g=((d&&f?(d+f)/2:d||f)-ee(r))*e;r.y0+=g,r.y1+=g}})})}function h(){s.forEach(function(i){var n,s,a,c=t.y0,l=i.length;for(i.sort(e||de),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 Pe(t){t.nodes.forEach(function(t){t.sourceLinks.sort(ue),t.targetLinks.sort(he)}),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 Me(){var t=0,e=0,i=1,o=1,r=24,n=8,s=null,a=ke,c=ne,l=void 0,h=32,u=2,d=Ae,f=we;function g(){var g={nodes:d.apply(null,arguments),links:f.apply(null,arguments)};return function(d){d.x0=t,d.y0=e,d.x1=i,d.y1=o,d.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 E(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=It(i,o)),"object"!=typeof r&&(r=t.target=It(i,r)),o.sourceLinks.push(t),r.targetLinks.push(t)})}(d,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=Xt(o);c.sort(function(t,e){return t.length-e.length});var l={};for(r=0;c.length>r;r++){var h=c[r].slice(-2);l[h[0]]||(l[h[0]]={}),l[h[0]][h[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++)})}(d,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){Kt(t,e)!=Kt(r.source,e)&&Kt(t,e)!=Kt(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),Gt(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(d,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(O(t.sourceLinks,ie),O(t.targetLinks,ie)),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)})})}(d),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})}(d,l,c);var f=n;if(null!==s){var g=P(d.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),y=M(g,function(t){return t.length});y>1&&(f=Math.max(1,(o-e)*s/(y-1)))}(function(t,e,i){var o=P(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=_(o,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/O(e,function(t){return t.value})});t.ky=r,t.links.forEach(function(e){e.width=e.value*t.ky});var n=M(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})})(d,f,r),Se(d,l,a),_e(d,l,a,f,f,h),Pe(d),me(d,a,u,10,8),Se(d,l,a),_e(d,l,a,f,f,h),Pe(d),me(d,a,u,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 Kt(i.source,e)==Kt(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(!ye(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var i=Qt(e,t);return t.y1-i}if(e.target.column>t.target.column)return Qt(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}})})}(d,a),function(t,e){let i=t;i.nodes.forEach(function(t){var o=i.links.filter(function(i){return Kt(i.target,e)==Kt(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(!ye(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;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}})})}(d,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=_(e,function(t){return t.y0}),s=M(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})})}}(d),me(d,a,u,10,8)}(g),g}return g.update=function(t){return Pe(t),me(t,a,u,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?(d="function"==typeof t?t:be(t),g):d},g.links=function(t){return arguments.length?(f="function"==typeof t?t:be(t),g):f},g.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:be(t),g):a},g.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:be(t),g):c},g.nodeSort=function(t){return arguments.length?(l=t,g):l},g.iterations=function(t){return arguments.length?(h=+t,g):h},g.circularLinkGap=function(t){return arguments.length?(u=+t,g):u},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}Yt.GROUP_COLOR_MAP_CAP=1e3,Yt.QUADTREE_THRESHOLD=500;const Oe=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=j(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=j(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 Te(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,h=r.leftFullExtent,u=r.verticalFullExtent,d="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(o,15));return`M${n},${s-d*i}L${l},${s-d*i}L${l+o},${s-d*i+d*f}L${l+o},${u+d*o-d*f}L${l+o-f},${u+d*o}L${h-o+f},${u+d*o}L${h-o},${u+d*o-d*f}L${h-o},${c-d*i+d*f}L${h-o+f},${c-d*i}L${a},${c-d*i}L${a},${c+d*i}L${h+o},${c+d*i}L${h+o},${u-d*o}L${l-o},${u-d*o}L${l-o},${s+d*i}L${n},${s+d*i}Z`}const Ee=new Set,Le=new WeakMap;function je(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let i=Le.get(t);if(i){const t=i.get(e);if(t)return t}else i=new Map,Le.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}`;Ee.has(t)||(Ee.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 De={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(re))-1:0},justify:ne},ze={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,o){var r,n,s,a,c,l,h;if(0===t.length)return;const u="vertical"===i.orientation?"down":"right",d=i.nodeAlign||"justify",f=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 v;v="down"===u?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const x=Me().extent(v).links(m).nodes(p).nodeAlign(De[d]||ne).nodeId(t=>t.id).nodeWidth(f).iterations(y);x.nodePaddingRatio&&x.nodePaddingRatio(g),x();{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,h=o[0],u=o[1];if(n>0&&s>0&&(0>t||0>i||e>h||r>u)){const e=Math.min(h/n,u/s),o=-t*e+(h-n*e)/2,r=-i*e+(u-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!==(h=t.width)&&void 0!==h?h: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=u;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,c,l;const h="vertical"===i.orientation?"down":"right",u=i.nodeStyle,d=i.edgeStyle,f=null!==(r=i.edgeOpacity)&&void 0!==r?r:.5,g=i.edgeColorBy||"source",y=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:x,p=new Map;t.forEach((t,e)=>{p.set(t.id,y[e%y.length])});const m=[],v=[],b=[],k=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=u?u(je(e,"nodeStyle")):{},r={fill:o.fill||p.get(e.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};k.set(e.id,("string"==typeof r.fill?r.fill:null)||p.get(e.id)||"#4d430c"),m.push("down"===h?{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 A=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of A){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let r=(null===(n=i.themeSemantic)||void 0===n?void 0:n.border)||(null===(s=i.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";r="function"==typeof g?g(t)||r:"target"===g?k.get(o.id)||p.get(o.id)||r:k.get(e.id)||p.get(e.id)||r;const h=d?d(je(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,i=t.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),n=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),s=h.fill||r;v.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-i}L${e.sourceX+o},${e.sourceY-i}L${e.sourceX+o},${e.sourceY+i}L${e.sourceX},${e.sourceY+i}Z`,style:{fill:s,fillOpacity:null!==(a=h.fillOpacity)&&void 0!==a?a:f,stroke:"none",opacity:h.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+o}}),v.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-i}L${e.targetX-n},${e.targetY-i}L${e.targetX-n},${e.targetY+i}L${e.targetX},${e.targetY+i}Z`,style:{fill:s,fillOpacity:null!==(c=h.fillOpacity)&&void 0!==c?c:f,stroke:"none",opacity:h.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-n,x1:e.targetX}});continue}let u;if(u=t.circular&&t.circularPathData?Te(t):Oe(t),!u)continue;const y={fill:h.fill||r,fillOpacity:null!==(l=h.fillOpacity)&&void 0!==l?l:f,stroke:h.stroke||"none",strokeWidth:h.strokeWidth,opacity:h.opacity};v.push({type:"bezier",pathD:u,bezierCache:t.bezier,style:y,datum:t})}if(!1!==i.showLabels){const e=(w=i.nodeLabel)?"function"==typeof w?w:t=>t[w]||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,c;"down"===h?(s=i.y0+(i.y1-i.y0)/2,a=i.x1+14,c="middle"):(o[0]/2>i.x0+t/2?(s=i.x0-6,c="end"):(s=i.x1+6,c="start"),a=i.y0+r/2),b.push({x:s,y:a,text:n+"",anchor:c,baseline:"middle",fontSize:11})}}var w;return{sceneNodes:m,sceneEdges:v,labels:b}}},$e={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 h=0;const u=[];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?h++:i?(e.x=i.x,e.y=i.y,h++):u.push(e)}const d=h>0&&.3>=(t.length>0?u.length/t.length:1);if(d){const i=new Map;for(const e of t)i.set(e.id,e);for(const t of u){const o=Re(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=Ce(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=Ce(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 f=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:d?40:f,y=Ne(i.nodeSize,i.nodeSizeRange,t),p=t=>y(t);if(g>0){const i=D().strength(t=>{const e=t.weight;return Math.min(2.5,e?e*s:s)}).id(t=>t.id),o=z().force("charge",$().strength(t=>-25*p(t))).force("center",R(a,c).strength(.8)).force("x",C(a).strength(.15)).force("y",N(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)}d?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,a,c,l,h;const u=i.nodeStyle,d=i.edgeStyle,f=Ne(i.nodeSize,i.nodeSizeRange,t),g=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:x,y=new Map;t.forEach((t,e)=>{y.set(t.id,g[e%g.length])});const p=[],m=[],v=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=f(je(e,"nodeSize")),o=u?u(je(e,"nodeStyle")):{},a={fill:o.fill||y.get(e.id)||(null===(r=i.themeSemantic)||void 0===r?void 0:r.primary)||"#007bff",stroke:o.stroke||(null===(n=i.themeSemantic)||void 0===n?void 0:n.surface)||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:2,opacity:o.opacity};p.push({type:"circle",cx:e.x,cy:e.y,r:t,style:a,datum:e,id:e.id,label:e.id})}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:b.get(t.source),o="object"==typeof t.target?t.target:b.get(t.target);if(!e||!o)continue;if(null==e.x||null==e.y)continue;if(null==o.x||null==o.y)continue;const r=d?d(je(t,"edgeStyle")):{},n={stroke:r.stroke||(null===(a=i.themeSemantic)||void 0===a?void 0:a.border)||(null===(c=i.themeSemantic)||void 0===c?void 0:c.secondary)||"#999",strokeWidth:null!==(l=r.strokeWidth)&&void 0!==l?l:1,opacity:null!==(h=r.opacity)&&void 0!==h?h:.6};m.push({type:"line",x1:e.x,y1:e.y,x2:o.x,y2:o.y,style:n,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){if(null==i.x||null==i.y)continue;const t=e?e(i):i.id;if(!t)continue;const o=f(je(i,"nodeSize"));v.push({x:i.x,y:i.y-o-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var k;return{sceneNodes:p,sceneEdges:m,labels:v}}};function Re(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 Ce(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 Ne(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 s=e||[5,20],a=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===a.length)return()=>s[0];const c=null!==(o=_(a))&&void 0!==o?o:0,l=null!==(r=M(a))&&void 0!==r?r:1;if(c===l)return()=>(s[0]+s[1])/2;const h=n().domain([c,l]).range(s).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?s[0]:h(o)}}const We=x,Be={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,h=o[1]/2,u=(d=i.valueAccessor)?"function"==typeof d?d:t=>{var e;return null!==(e=t[d])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var d;const f=new Map;for(let e=0;t.length>e;e++)f.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=f.get("string"==typeof t.source?t.source:t.source.id),o=f.get(e);if(void 0===i||void 0===o)continue;const r=u(t);y[i][o]=r}const p=B().padAngle(r);s&&p.sortGroups(s);const m=p(y),v=m.groups,x=F().innerRadius(c).outerRadius(a);for(const e of v){const i=t[e.index],o=x.centroid(e);i.x=o[0]+l,i.y=o[1]+h,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,s,a;const{groupWidth:c=20,edgeOpacity:l=.5}=i,h=Math.min(o[0],o[1])/2,u=h-c,d=o[0]/2,f=o[1]/2,g=i.nodeStyle,y=i.edgeStyle,p=i.edgeColorBy||"source",m=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:We,v=new Map;t.forEach((t,e)=>{v.set(t.id,m[e%m.length])});const x=W().radius(u),b=[],k=[],A=[];for(let e=0;t.length>e;e++){const i=t[e],o=i.arcData;if(!o)continue;let n;n=g?g(je(i,"nodeStyle")).fill||v.get(i.id)||m[e%m.length]:v.get(i.id)||m[e%m.length];const s=g?g(je(i,"nodeStyle")):{},a={fill:n,stroke:s.stroke||"black",strokeWidth:null!==(r=s.strokeWidth)&&void 0!==r?r:1,opacity:s.opacity};b.push({type:"arc",cx:d,cy:f,innerR:u,outerR:h,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 o=x(e);if(!o)continue;const r=Fe(o,d,f);let c=(null===(n=i.themeSemantic)||void 0===n?void 0:n.border)||(null===(s=i.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";if(y)c=y(je(t,"edgeStyle")).fill||c;else{const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;"target"===p&&i?c=v.get(i.id)||c:e&&(c=v.get(e.id)||c)}const h=y?y(je(t,"edgeStyle")):{},u={fill:c,fillOpacity:null!==(a=h.fillOpacity)&&void 0!==a?a:l,stroke:h.stroke||"none",strokeWidth:h.strokeWidth,opacity:h.opacity};k.push({type:"ribbon",pathD:r,style:u,datum:t})}if(!1!==i.showLabels){const e=(w=i.nodeLabel)?"function"==typeof w?w:t=>t[w]||t.id:null,o=h+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;A.push({x:d+Math.cos(s)*o,y:f+Math.sin(s)*o,text:r+"",anchor:n>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:b,sceneEdges:k,labels:A}}};function Fe(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 Ye=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Ie(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 Xe(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 qe(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 Ge(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:Ye}function Ve(t){var e;return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)?t.themeSemantic.primary:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical[0]:"#4d430c"}function He(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 Qe={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},h=I(n,a);h.sum(l),h.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[u,d]=o;switch(s){case"tree":!function(t,e,i,o){const r=e.treeOrientation||"vertical",n=Q();n.size("horizontal"===r?[o,i]:"radial"===r?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),n(t)}(h,i,u,d);break;case"cluster":!function(t,e,i,o){const r=e.treeOrientation||"vertical",n=H();n.size("horizontal"===r?[o,i]:"radial"===r?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),n(t)}(h,i,u,d);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=G().size([i,o]).tile(V).padding(s);a>0&&c.paddingTop(a),c(t)}(h,i,u,d);break;case"circlepack":!function(t,e,i,o){var r;const n=null!==(r=e.padding)&&void 0!==r?r:4;q().size([i,o]).padding(n)(t)}(h,i,u,d);break;case"partition":!function(t,e,i,o){var r;X().size([i,o]).padding(null!==(r=e.padding)&&void 0!==r?r:1)(t)}(h,i,u,d)}const f=h.descendants();t.length=0,e.length=0;const g=new Map;for(let e=0;f.length>e;e++){const o=f[e],n={id:Xe(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?Ze(n,o,i):"treemap"===s||"partition"===s?Ue(n,o):"circlepack"===s&&Ke(n,o),n.__hierarchyNode=o,t.push(n),g.set(o,n)}if("tree"===s||"cluster"===s)for(const t of f)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,h,u,d,f;const g=[],y=[],p=[],m=i.treeOrientation||"vertical",v="radial"===m,x=o[0]/2,b=o[1]/2,k="number"==typeof(A=i.nodeSize)?A:5;var A;for(const e of t){let t=e.x,o=e.y;v&&(t+=x,o+=b);const n=r(je(e,"nodeStyle"));let c=n.fill||Ve(i);if(i.colorByDepth&&void 0!==e.depth){const t=Ge(i);c=t[e.depth%t.length]}const l={fill:c,stroke:n.stroke||(null===(s=i.themeSemantic)||void 0===s?void 0:s.surface)||"#fff",strokeWidth:null!==(a=n.strokeWidth)&&void 0!==a?a:1,opacity:n.opacity};g.push({type:"circle",cx:t,cy:o,r:k,style:l,datum:e,id:e.id,label:e.id,depth:e.depth})}const w=null!==(c=i.edgeOpacity)&&void 0!==c?c:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let r=e.x,s=e.y,a=o.x,c=o.y;v&&(r+=x,s+=b,a+=x,c+=b);const f=He(r,s,a,c,m),g=n(je(t,"edgeStyle")),p={fill:"none",stroke:g.stroke||(null===(l=i.themeSemantic)||void 0===l?void 0:l.border)||(null===(h=i.themeSemantic)||void 0===h?void 0:h.secondary)||"#999",strokeWidth:null!==(u=g.strokeWidth)&&void 0!==u?u:1.5,opacity:null!==(d=g.opacity)&&void 0!==d?d:w};y.push({type:"curved",pathD:f,style:p,datum:t})}if(!1!==i.showLabels){const e=qe(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(v&&(s+=x,a+=b),v){const t=s-x,e=a-b,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"===m?((null===(f=i.data)||void 0===f?void 0:f.children)&&0!==i.data.children.length?(o=s-k-6,n="end"):(o=s+k+6,n="start"),r=a):(o=s,r=a+k+14,n="middle");p.push({x:o,y:r,text:t+"",anchor:n,baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:y,labels:p}}(t,e,i,o,r,n);case"treemap":case"partition":return function(t,e,i,o){var r,n,s,a,c;const l=[],h=[];for(const i of t){const t=i.x1-i.x0,s=i.y1-i.y0;if(0>=t||0>=s)continue;const a=o(je(i,"nodeStyle"));let c=a.fill||Ve(e);if(e.colorByDepth&&void 0!==i.depth){const t=Ge(e);c=t[i.depth%t.length]}const h={fill:c,stroke:a.stroke||(null===(r=e.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(n=a.strokeWidth)&&void 0!==n?n:1,opacity:a.opacity};l.push({type:"rect",x:i.x0,y:i.y0,w:t,h:s,style:h,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=qe(e.nodeLabel),r=e.labelMode||"leaf",n="partition"===e.chartType;for(const l of t){const t=l.x1-l.x0,u=l.y1-l.y0;if(0>=t||0>=u)continue;const d=!((null===(s=l.data)||void 0===s?void 0:s.children)&&l.data.children.length>0);if(!n){if("leaf"===r&&!d)continue;if("parent"===r&&d)continue}const f=i?i(l):l.id;if(!f)continue;if((d?30:40)>t||(d?16:14)>u)continue;let g=o(je(l,"nodeStyle")).fill||Ve(e);if(e.colorByDepth&&void 0!==l.depth){const t=Ge(e);g=t[l.depth%t.length]}const y="string"==typeof g?Ie(g):null!==(c=null===(a=e.themeSemantic)||void 0===a?void 0:a.text)&&void 0!==c?c:"#000";h.push(d?{x:l.x0+t/2,y:l.y0+u/2,text:f+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,u)/6)),fill:y}:{x:l.x0+4,y:l.y0+12,text:f+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:y})}}return{sceneNodes:l,sceneEdges:[],labels:h}}(t,i,0,r);case"circlepack":return function(t,e,i,o){var r,n,s,a,c,l,h,u,d,f;const g=[],y=[];for(const i of t){const t=null!==(r=i.__radius)&&void 0!==r?r:5;if(0>=t)continue;const c=o(je(i,"nodeStyle"));let l=c.fill||Ve(e);if(e.colorByDepth&&void 0!==i.depth){const t=Ge(e);l=t[i.depth%t.length]}const h={fill:l,stroke:c.stroke||(null===(n=e.themeSemantic)||void 0===n?void 0:n.surface)||"#fff",strokeWidth:null!==(s=c.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=c.opacity)&&void 0!==a?a:.7};g.push({type:"circle",cx:i.x,cy:i.y,r:t,style:h,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=qe(e.nodeLabel);for(const r of t){const t=null!==(c=r.__radius)&&void 0!==c?c:5,n=i?i(r):r.id;if(!n)continue;if(15>t)continue;const s=!((null===(l=r.data)||void 0===l?void 0:l.children)&&r.data.children.length>0);let a=o(je(r,"nodeStyle")).fill||Ve(e);if(e.colorByDepth&&void 0!==r.depth){const t=Ge(e);a=t[r.depth%t.length]}if(s){const i="string"==typeof a?Ie(a):null!==(u=null===(h=e.themeSemantic)||void 0===h?void 0:h.text)&&void 0!==u?u:"#000";y.push({x:r.x,y:r.y,text:n+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:i})}else y.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:(null===(d=e.themeSemantic)||void 0===d?void 0:d.text)||"#000",stroke:(null===(f=e.themeSemantic)||void 0===f?void 0:f.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:g,sceneEdges:[],labels:y}}(t,i,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Ze(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 Ue(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 Ke(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 ti={sankey:ze,force:$e,chord:Be,tree:Qe,cluster:Qe,treemap:Qe,circlepack:Qe,partition:Qe,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),h=null!==(n=i.orbitSize)&&void 0!==n?n:2.95,u=null!==(s=i.orbitEccentricity)&&void 0!==s?s:1,d="number"==typeof h?()=>h:h,f="number"==typeof u?()=>u:u,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,v=e[1]/2,x=Math.min(e[0],e[1])/2*.85,b=p(c(t));o.push({id:b,x:m,y:v,x0:m,x1:m,y0:v,y1:v,width:0,height:0,value:0,depth:0,data:t}),g.metaMap.set(b,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,i,n,s,h,u,y){const m=a(e);if(!(null==m?void 0:m.length))return;const v=m.length;let x=0,b=0,k=0;for(;v>b;)b+=l[Math.min(k,l.length-1)],k++,x++;let A=0;for(let v=0;x>v;v++){const b=l[Math.min(v,l.length-1)],k=m.slice(A,A+b);if(!k.length)break;const w=(v+1)/x,S={id:i,depth:u,data:e,parentId:i},_=y?h/d(S)*w:h*w,P=Y().value(t=>{var e;return(null===(e=a(t))||void 0===e?void 0:e.length)?4:1}).sort(null),M=P(k),O=f(S);for(let e=0;k.length>e;e++){const a=(M[e].startAngle+M[e].endAngle)/2,l=k[e],h=p(c(l)),d=n+_*Math.sin(a),f=s+_*Math.cos(a)*O;o.push({id:h,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:u,data:l}),g.metaMap.set(h,{ring:_,angle:a,depth:u,parentId:i,eccentricity:O}),r.push({source:i,target:h,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:h}}),t(l,h,d,f,_,u+1,!0)}A+=b}}(t,b,m,v,x,1,!1)}(r,o,i,t,e)},buildScene(t,e,i,o){var r,n,s,a,c,l,h;const u=i.nodeStyle,d=i.nodeSize,f="number"==typeof d?()=>d:"function"==typeof d?d:()=>6,g=[],y=[],p=[];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;y.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=f(je(e,"nodeSize")),o=u?u(je(e,"nodeStyle")):{},l={fill:o.fill||(null===(r=i.themeSemantic)||void 0===r?void 0:r.primary)||"#6366f1",stroke:o.stroke||(null===(n=i.themeSemantic)||void 0===n?void 0:n.surface)||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=o.opacity)&&void 0!==a?a:0===(null!==(c=e.depth)&&void 0!==c?c:0)?1:.85};g.push({type:"circle",cx:e.x,cy:e.y,r:t,style:l,datum:e,id:e.id,label:e.id,depth:e.depth})}const m=new Map;for(const e of t)m.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:m.get(t.source),i="object"==typeof t.target?t.target:m.get(t.target);e&&i&&(null!=e.x&&null!=i.x&&y.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=f(je(i,"nodeSize"));if(4>=t)continue;const o="function"==typeof e?e(i):e&&null!==(h=null===(l=i.data)||void 0===l?void 0:l[e])&&void 0!==h?h:i.id;p.push({x:i.x,y:i.y+t+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:g,sceneEdges:y,labels:p}},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 ei(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,h=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:h,datum:t.pieceData,category:t.name}))}return n}function ii(t){var e,i,o;const r=t.length,n=t[0],s=t[r-1];return{n:r,min:n,q1:null!==(e=L(t,.25))&&void 0!==e?e:n,median:null!==(i=L(t,.5))&&void 0!==i?i:(n+s)/2,q3:null!==(o=L(t,.75))&&void 0!==o?o:s,max:s,mean:t.reduce((t,e)=>t+e,0)/r}}const oi={bar:function(t,e){var i,o,r;const{scales:n,columns:s,config:a,getR:c,getStack:l,resolvePieceStyle:h}=t,{r:u,projection:d}=n,f=[],g="vertical"===d,y="horizontal"===d,p=a.normalize,m=[];if(l){const t=new Set;for(const e of Object.values(s))for(const i of e.pieceData){const e=l(i);t.has(e)||(t.add(e),m.push(e))}}else m.push("_default");for(const t of Object.values(s)){const e=new Map;for(const i of t.pieceData){const t=l?l(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t);o.total+=c(i),o.pieces.push(i)}let i=0;if(p)for(const t of e.values())i+=Math.abs(t.total);let o=0,r=0;for(const n of m){const s=e.get(n);if(!s)continue;let a=s.total;p&&i>0&&(a/=i);const c=h(s.pieces[0],l?n:t.name),d=Object.assign(Object.assign({},s.pieces[0]),{__aggregateValue:s.total,__pieceCount:s.pieces.length,category:t.name});if(g){const e=u(0>a?r:o+a),i=0>a?u(r+a)-u(r):u(o)-u(o+a);f.push(Rt(t.x,e,t.width,Math.abs(i),c,d,n)),0>a?r+=a:o+=a}else if(y){const e=u(0>a?r+a:o),i=0>a?u(r)-u(r+a):u(o+a)-u(o);f.push(Rt(e,t.x,Math.abs(i),t.width,c,d,n)),0>a?r+=a:o+=a}}}const v="vertical"===d,x=a.roundedTop&&a.roundedTop>0?Math.max(0,a.roundedTop):0;for(const t of f){if("rect"!==t.type)continue;const e=null!==(o=null===(i=t.datum)||void 0===i?void 0:i.__aggregateValue)&&void 0!==o?o:0;t.roundedEdge=v?0>e?"bottom":"top":0>e?"left":"right",a.gradientFill&&(t.fillGradient=a.gradientFill)}if(x>0){const t=new Map;for(const e of f){if("rect"!==e.type)continue;const i=(null===(r=e.datum)||void 0===r?void 0:r.category)||"";t.has(i)||t.set(i,[]),t.get(i).push(e)}for(const e of t.values()){if(0===e.length)continue;const t=e.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}),i=e.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)});t.length>0&&(t.reduce(v?(t,e)=>e.y>t.y?t:e:(t,e)=>t.x+t.w>e.x+e.w?t:e).roundedTop=x),i.length>0&&(i.reduce(v?(t,e)=>t.y+t.h>e.y+e.h?t:e:(t,e)=>e.x>t.x?t:e).roundedTop=x)}}return f},clusterbar:function(t,e){const{scales:i,columns:o,config:r,getR:n,getGroup:s,resolvePieceStyle:a}=t,{r:c,projection:l}=i,h=[],u="vertical"===l,d=[],f=new Set;for(const t of Object.values(o))for(const e of t.pieceData){const t=s?s(e):"_default";f.has(t)||(f.add(t),d.push(t))}const g=d.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;d.length>s;s++){const l=r.get(d[s])||[];for(const r of l){const l=n(r),f=a(r,d[s]);if(u){const n=t.x+s*e+i/2,a=c(0),u=c(l);h.push(Rt(n,Math.min(a,u),o,Math.abs(a-u),f,r,d[s]))}else{const n=t.x+s*e+i/2,a=c(0),u=c(l);h.push(Rt(Math.min(a,u),n,Math.abs(u-a),o,f,r,d[s]))}}}}const y=r.roundedTop&&r.roundedTop>0?Math.max(0,r.roundedTop):0;for(const t of h){if("rect"!==t.type)continue;const e=n(t.datum);y>0&&(t.roundedTop=y),t.roundedEdge=u?0>e?"bottom":"top":0>e?"left":"right",r.gradientFill&&(t.fillGradient=r.gradientFill)}return h},point:function(t,e){var i,o;const{scales:r,columns:n,getR:s,multiScales:a,resolvePieceStyle:c}=t,{r:l,projection:h}=r,u=[],d="vertical"===h,f="radial"===h,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),h=g&&a[r]||l,m=c(e,t.name),v=m.r||5;let x,b;if(f){const e=p+(t.pctStart+t.pct/2)*y,i=h(n);x=Math.cos(e)*i,b=Math.sin(e)*i}else d?(x=t.middle,b=h(n)):(x=h(n),b=t.middle);u.push({type:"point",x:x,y:b,r:v,style:m,datum:e})}return u},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),h=n(o,t.name),u=h.r||4,d=(7919*i%100/100-.5)*e*.8,f=l?t.middle+d:s(a),g=l?s(a):t.middle+d;c.push({type:"point",x:f,y:g,r:u,style:h,datum:o})}}return c},pie:ei,donut:ei,boxplot:function(t,e){var i,o,r,n,s,a;const{scales:c,columns:l,config:h,getR:u,resolveSummaryStyle:d}=t,{r:f,projection:g}=c,y=[],p="vertical"===g,m=!1!==h.showOutliers;for(const e of Object.values(l)){const c=e.pieceData.map(t=>u(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===c.length)continue;const l=c[0],h=c[c.length-1],g=null!==(i=L(c,.25))&&void 0!==i?i:l,v=null!==(o=L(c,.5))&&void 0!==o?o:(l+h)/2,x=null!==(r=L(c,.75))&&void 0!==r?r:h,b=x-g,k=g-1.5*b,A=x+1.5*b,w=null!==(n=c.find(t=>t>=k))&&void 0!==n?n:l,S=null!==(s=[...c].reverse().find(t=>A>=t))&&void 0!==s?s:h,_=d(e.pieceData[0],e.name),P=[];if(m)for(const t of e.pieceData){const i=u(t);if(k>i||i>A){const o=p?e.middle:f(i),r=p?f(i):e.middle;P.push({px:o,py:r,value:i,datum:t})}}if(y.push({type:"boxplot",x:p?e.middle:0,y:p?0:e.middle,projection:p?"vertical":"horizontal",columnWidth:.6*e.width,minPos:f(w),q1Pos:f(g),medianPos:f(v),q3Pos:f(x),maxPos:f(S),stats:{n:c.length,min:w,q1:g,median:v,q3:x,max:S,mean:c.reduce((t,e)=>t+e,0)/c.length},style:_,datum:e.pieceData,category:e.name,outliers:P}),m)for(const e of P)y.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:_.fill||(null===(a=t.config.themeSemantic)||void 0===a?void 0:a.secondary)||"#999",opacity:.6},datum:e.datum})}return y},violin:function(t,e){var i,o,r;const{scales:n,columns:s,config:a,getR:c,resolveSummaryStyle:l}=t,{r:h,projection:u}=n,d=[],f="vertical"===u,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,u=Array(g).fill(0);for(const t of e)u[Math.min(Math.floor((t-n)/a),g-1)]++;const p=Math.max(...u,1),m=t.width/2*.9;let v="";if(f){v=`M ${t.middle} ${h(n)}`;for(let e=0;g>e;e++){const i=h(n+(e+.5)*a);v+=` L ${t.middle+u[e]/p*m} ${i}`}v+=` L ${t.middle} ${h(s)}`;for(let e=g-1;e>=0;e--){const i=h(n+(e+.5)*a);v+=` L ${t.middle-u[e]/p*m} ${i}`}v+=" Z"}else{v=`M ${h(n)} ${t.middle}`;for(let e=0;g>e;e++)v+=` L ${h(n+(e+.5)*a)} ${t.middle-u[e]/p*m}`;v+=` L ${h(s)} ${t.middle}`;for(let e=g-1;e>=0;e--)v+=` L ${h(n+(e+.5)*a)} ${t.middle+u[e]/p*m}`;v+=" Z"}const x=l(t.pieceData[0],t.name);let b;if(y&&e.length>=4){const a=null!==(i=L(e,.25))&&void 0!==i?i:n,c=null!==(o=L(e,.5))&&void 0!==o?o:(n+s)/2,l=null!==(r=L(e,.75))&&void 0!==r?r:s;b={q1Pos:h(a),medianPos:h(c),q3Pos:h(l),centerPos:t.middle,isVertical:f}}const k=f?{x:t.x,y:Math.min(h(s),h(n)),width:t.width,height:Math.abs(h(s)-h(n))}:{x:Math.min(h(n),h(s)),y:t.x,width:Math.abs(h(s)-h(n)),height:t.width};d.push({type:"violin",pathString:v,translateX:0,translateY:0,bounds:k,iqrLine:b,stats:ii(e),style:x,datum:t.pieceData,category:t.name})}return d},histogram:function(t,e){var i;const{scales:o,columns:r,config:n,getR:s,resolveSummaryStyle:a}=t,{r:c}=o,l=[],h=n.bins||25,u=n.normalize,d=null===(i=c.domain)||void 0===i?void 0:i.call(c),f=d?+d[0]:void 0,g=d?+d[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!=f&&isFinite(f)?f:Math.min(...e),o=null!=g&&isFinite(g)?g:Math.max(...e),r=(o-i)/h||1,n=Array(h).fill(0);for(const t of e)i>t||t>o||n[Math.min(Math.floor((t-i)/r),h-1)]++;const d=e.length,y=Math.max(...n,1),p=a(t.pieceData[0],t.name);for(let e=0;h>e;e++){if(0===n[e])continue;const o=(u?n[e]/d:n[e]/y)*t.width*.9,s=c(i+e*r),a=c(i+(e+1)*r);l.push(Rt(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,h=[],u=n.bins||20,d="horizontal"===l,f=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)/u||1,l=Array(u).fill(0);for(const t of e)o>t||t>r||l[Math.min(Math.floor((t-o)/n),u-1)]++;const g=Math.max(...l,1),y=a(t.pieceData[0],t.name),p=t.width*f;let m="";if(d){const e=t.x+t.width;m=`M ${c(o)} ${e}`;for(let t=0;u>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;u>t;t++){const i=c(o+(t+.5)*n);m+=` L ${e+l[t]/g*p} ${i}`}m+=` L ${e} ${c(r)} Z`}const v=d?{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))};h.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:v,stats:ii(e),style:Object.assign(Object.assign({},y),{fillOpacity:null!==(i=y.fillOpacity)&&void 0!==i?i:.5}),datum:t.pieceData,category:t.name})}return h},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,h=n(e,t.name);if(l){const i=s(Math.min(o,a)),r=s(Math.max(o,a));c.push(Rt(i,t.x,r-i,t.width,h,e,t.name))}else{const i=s(Math.max(o,a)),r=s(Math.min(o,a));c.push(Rt(t.x,i,t.width,r-i,h,e,t.name))}}return c},funnel:function(t,e){var i,o,r,s,a,c,l,h;const{columns:u,getR:d,getStack:f,resolvePieceStyle:g}=t,y=[],p=e.width/2,m=!1!==t.config.showLabels,v=t.scales.o.domain().map(t=>u[t]).filter(Boolean);if(0===v.length)return y;const x=[],b=new Set;for(const t of v)for(const e of t.pieceData){const t=f?f(e):"_default";b.has(t)||(b.add(t),x.push(t))}const k=x.length>1&&"_default"!==x[0],A=[];let w=0;for(const t of v){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=d(o);r.total+=n,r.pieces.push(o),i+=n}A.push({col:t,groups:e,stepTotal:i}),k||i>w&&(w=i)}if(k)for(const t of A){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>w&&(w=o)}if(0===w)return y;const S=new Map;for(const t of x){const e=A[0].groups.get(t);S.set(t,null!==(i=null==e?void 0:e.total)&&void 0!==i?i:0)}const _=A[0].stepTotal,P=k?.95*p:.9*e.width,M=n().domain([0,w]).range([0,P]),O=null!==(o=t.config.connectorOpacity)&&void 0!==o?o:.3;let T=new Map;for(let e=0;A.length>e;e++){const i=A[e],o=i.col,n=0===e,u=o.width,d=.55*u,f=o.x+(u-d)/2,v=new Map;if(k){let t=0;for(const e of x){const o=i.groups.get(e);o&&(t+=M(o.total))}let e=p,r=p;for(let s=0;x.length>s;s++){const c=x[s],l=i.groups.get(c);if(!l)continue;const h=M(l.total),u=s%2==0,b=u?e:r-h;u?e+=h:r-=h;const k=g(l.pieces[0],c),A=null!==(a=S.get(c))&&void 0!==a?a:l.total,w=A>0?l.total/A*100:0,_=Object.assign(Object.assign({},l.pieces[0]),{__funnelValue:l.total,__funnelPercent:w,__funnelStep:o.name,__funnelIsFirstStep:n,__aggregateValue:l.total,__pieceCount:l.pieces.length,category:c});m&&(0===s&&(_.__funnelStepLabel=o.name,_.__funnelStepLabelX=p,_.__funnelStepLabelY=f,_.__funnelRowWidth=t),_.__funnelValueLabelX=b+h/2,_.__funnelValueLabelY=f,_.__funnelBarW=h),y.push(Rt(b,f,h,d,k,_,c)),v.set(c,{x:b,y:f,w:h,h:d})}}else{const t=i.stepTotal,e=M(t),a=p-e/2,c=x[0],l="_default"!==c,h=null!==(s=null===(r=i.groups.get(c))||void 0===r?void 0:r.pieces[0])&&void 0!==s?s:o.pieceData[0],u=l?c:o.name,b=g(h,u),k=_>0?t/_*100:0,A=Object.assign(Object.assign({},h),{__funnelValue:t,__funnelPercent:k,__funnelStep:o.name,__funnelIsFirstStep:n,category:l?c:o.name});m&&(A.__funnelStepLabel=o.name,A.__funnelStepLabelX=p,A.__funnelStepLabelY=f,A.__funnelRowWidth=e,A.__funnelValueLabelX=p,A.__funnelValueLabelY=f,A.__funnelBarW=e),y.push(Rt(a,f,e,d,b,A,u)),v.set(c,{x:a,y:f,w:e,h:d})}if(e>0&&T.size>0){const e=k?x:[x[0]];for(const r of e){const e=T.get(r),n=v.get(r);if(!e||!n)continue;const s=(()=>{const t=i.groups.get(r);return g(t?t.pieces[0]:o.pieceData[0],"_default"===r?o.name:r)})(),a={type:"trapezoid",points:[[e.x,e.y+e.h],[e.x+e.w,e.y+e.h],[n.x+n.w,n.y],[n.x,n.y]],style:{fill:s.fill||(null===(c=t.config.themeSemantic)||void 0===c?void 0:c.secondary)||"#999",opacity:O},datum:null!==(h=null===(l=i.groups.get(r))||void 0===l?void 0:l.pieces[0])&&void 0!==h?h:o.pieceData[0],category:"_default"===r?o.name:r};y.push(a)}}T=v}return y},"bar-funnel":function(t,e){var i,o,r,n;const{columns:s,getR:a,getStack:c,resolvePieceStyle:l,scales:h}=t,u=[],d=h.o.domain().map(t=>s[t]).filter(Boolean);if(0===d.length)return u;const f=[],g=new Set;for(const t of d)for(const e of t.pieceData){const t=c?c(e):"_default";g.has(t)||(g.add(t),f.push(t))}const y=f.length>1&&"_default"!==f[0],p=[];for(const t of d){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 f){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 v=h.r,x=y?f.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/x,c=a*b,h=a-c;for(let t=0;f.length>t;t++){const d=f[t],g=e.groups.get(d);if(!g)continue;const p=g.total,x=null!==(r=m.get(d))&&void 0!==r?r:p,b=x>0?p/x*100:0,k=null==s?void 0:s.groups.get(d),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,_=v(p),P=v(0)-_,M=l(g.pieces[0],y?d:i.name),O=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:p,__barFunnelPercent:b,__barFunnelIsFirstStep:o,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:w,__barFunnelCategory:"_default"===d?void 0:d,category:y?d:i.name,__barFunnelLabelX:S+h/2,__barFunnelLabelY:v(p+w)});if(u.push(Rt(S,_,h,P,M,O,y?d:i.name)),w>0){const t=v(p+w),e=_-t,o=Object.assign({},M),r=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:w,__barFunnelPercent:x>0?w/x*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===d?void 0:d,category:y?d:i.name});u.push(Rt(S,t,h,e,o,r,y?d:i.name))}}}return u},swimlane:function(t,e){const{scales:i,columns:o,getR:r,getStack:n,resolvePieceStyle:s}=t,{r:a,projection:c}=i,l=[],h="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,u=s(i,c);if(h){const r=a(e),n=a(e+o);l.push(Rt(r,t.x,n-r,t.width,u,i,c))}else{const r=a(e+o),n=a(e);l.push(Rt(t.x,r,t.width,n-r,u,i,c))}e+=o}}return l}};class ri{constructor(t){this.rExtent=new yt,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._dataVersion=0,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=t,this.buffer=new gt(t.windowSize),this.getO=bt(t.categoryAccessor||t.oAccessor,"category");const e=t.valueAccessor||t.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(t=>vt(t,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new yt)):(this.getR=vt(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=bt(t.stackBy),this.getGroup=bt(t.groupBy),this.getColor=bt(t.colorAccessor),this.getConnector=bt(t.connectorAccessor),this.getDataId=bt(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new gt(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this._dataVersion++,t.bounded){this.buffer.clear(),this.rExtent.clear();for(const t of this.rExtents)t.clear();t.preserveCategoryOrder?this._hasStreamingData=!0: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.valueAccessor||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",s=e.oExtent||this.resolveCategories(o),a=this.computeValueDomain(o,s),l="horizontal"===r,h="radial"===r,u=Math.min(.9,Math.max(0,null!=e.barPadding?e.barPadding/("vertical"===r?t.width:t.height):.1));let d,f;if(h){d=c().domain(s).range([0,1]).padding(0);const i=Math.min(t.width,t.height)/2,o=e.innerRadius||0;f=n().domain(a).range([o,i])}else l?(d=c().domain(s).range([0,t.height]).padding(u),f=n().domain(a).range([0,t.width])):(d=c().domain(s).range([0,t.width]).padding(u),f=n().domain(a).range([t.height,0]));this.scales={o:d,r:f,projection:r},this.multiScales=this.rAccessors.length>1&&e.multiAxis?this.rAccessors.map((o,r)=>{var s;const a=this.rExtents[r];a.dirty&&a.recalculate(i,o);let[c,h]=a.extent;c===1/0&&(c=0,h=1);const u=null!==(s=e.extentPadding)&&void 0!==s?s:.05,d=h-c,f=d>0?d*u:1;return c-=f,h+=f,c>0&&(c=0),l?n().domain([c,h]).range([0,t.width]):n().domain([c,h]).range([t.height,0])}):[];let g=o;this.rAccessors.length>1&&(g=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(g,s,d,r,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(g,t),this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,o),this.config.pulse&&this.applyPulse(this.scene,o),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(t){const e=this.config.valueAccessor||this.config.rAccessor,i=Array.isArray(e)?e[t]:e;return"string"==typeof i?i:"value"+t}resolveCategories(t){const e=this.config.oSort,i="streaming"===this.config.runtimeMode||this._hasStreamingData,o="auto"===e?void 0:e;let r=null;if(i){r=new Set;for(const e of t)r.add(this.getO(e))}const n=r?Array.from(this.categories).filter(t=>r.has(t)):Array.from(this.categories);if(i&&void 0===o){const t=Math.max(50,3*r.size);if(this.categories.size>t){let e=this.categories.size-t;for(const t of this.categories){if(0>=e)break;r.has(t)||(this.categories.delete(t),e--)}}return n}if(!1===o)return n;if("function"==typeof o)return n.sort(o);const s=new Map;for(const e of t){const t=this.getO(e);s.set(t,(s.get(t)||0)+Math.abs(this.getR(e)))}return n.sort("asc"===o?(t,e)=>(s.get(t)||0)-(s.get(e)||0):(t,e)=>(s.get(e)||0)-(s.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,h=0;if("bar"===a&&this.getStack&&this.config.normalize)l=0,h=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>h&&(h=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>h&&(h=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>h&&(h=t)}else if("clusterbar"===a||"bar-funnel"===a)for(const e of t){const t=this.getR(e);t>h&&(h=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&&(h=e)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(l=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(h=this.config.rExtent[1]));const u="bar"===a||"clusterbar"===a||"bar-funnel"===a||"swimlane"===a;if(u&&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>h&&(h=0)),"bar-funnel"!==a){const t=h-l,e=t>0?t*c:1;null!=(null===(n=this.config.rExtent)||void 0===n?void 0:n[0])||u&&!this.config.baselinePadding&&0===l||(l-=e),null!=(null===(s=this.config.rExtent)||void 0===s?void 0:s[1])||u&&!this.config.baselinePadding&&0===h||"swimlane"===a||(h+=e)}return[l,h]}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 h=null;if(l&&"radial"!==o){h=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),h.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 h)h.set(e,i/t*n)}let u=0,d=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,f;h?(l=d,f=h.get(t)||i.bandwidth(),d+=f+i.padding()*i.step()):(l=null!==(n=i(t))&&void 0!==n?n:0,f=i.bandwidth()),s[t]={name:t,x:l,y:0,width:f,middle:l+f/2,padding:i.padding()*i.step(),pieceData:e,pct:r,pctStart:u},u+=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=oi[this.config.chartType];let r=o?o(i,e):[];if(this.getConnector&&this.scales){const t=function(t,e){var i,o;const{scales:r,config:n,getConnector:s,getO:a}=t;if(!s||!r)return[];const c=[],{projection:l}=r,h=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const i=s(e);if(!i)continue;let o,r;"point"===t.type?(o=t.x,r=t.y):(o=t.x+t.w/2,r=t.y+("vertical"===l?0:t.h/2)),h.has(i)||h.set(i,[]),h.get(i).push({x:o,y:r,datum:e,category:a(e)})}const u=r.o.domain(),d=n.connectorStyle;for(const[e,r]of h)if(r.length>=2){r.sort((t,e)=>u.indexOf(t.category)-u.indexOf(e.category));for(let n=0;r.length-1>n;n++){const s=r[n],a=r[n+1],l="function"==typeof d?d(s.datum):d||{stroke:(null===(i=t.config.themeSemantic)||void 0===i?void 0:i.border)||(null===(o=t.config.themeSemantic)||void 0===o?void 0:o.secondary)||"#999",strokeWidth:1,opacity:.5};c.push({type:"connector",x1:s.x,y1:s.y,x2:a.x,y2:a.y,style:l,datum:s.datum,group:e})}}return c}(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:this.config.themeCategorical||wt,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?Pt(i,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const e=new Map;for(let i=0;t.length>i;i++)e.set(t[i],i);return this._datumIndexCache={version:this._dataVersion,map:e},e}getCategoryIndexMap(t){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const e=this.config.categoryAccessor||this.config.oAccessor,i="function"==typeof e,o=i?null:e||"category",r=new Map;for(let n=0;t.length>n;n++){const s=t[n],a=i?e(s):s[o];let c=r.get(a);c||(c=[],r.set(a,c)),c.push(n)}return this._categoryIndexCache={version:this._dataVersion,map:r},r}rebuildPointQuadtree(){let t=0,e=0;for(const i of this.scene)"point"===i.type&&(t++,i.r>e&&(e=i.r));if(this._maxPointRadius=e,ri.QUADTREE_THRESHOLD>=t)return void(this._pointQuadtree=null);const i=Array(t);let o=0;for(const t of this.scene)"point"===t.type&&(i[o++]=t);this._pointQuadtree=l().x(t=>t.x).y(t=>t.y).addAll(i)}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(t,e){var i,o;if(!this.config.decay)return;const r=e.length;if(1>=r)return;const n=this.getDatumIndexMap(e);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=this.getDatumIndexMap(e);let h=null;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;h||(h=this.getCategoryIndexMap(e));const o=h.get(t);if(!o)continue;let r=0;for(let t=0;o.length>t;t++){const e=this.timestampBuffer.get(o[t]);if(null==e)continue;const i=n-e;if(s>i){const t=1-i/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 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}synthesizeIntroPositions(){var t,e,i,o,r;this.prevPositionMap.clear();const n=new Map,s=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.r(0))&&void 0!==e?e:0,a="horizontal"!==(null===(i=this.scales)||void 0===i?void 0:i.projection);let c;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],i=this.getNodeKey(e,n);i&&("rect"===e.type?this.prevPositionMap.set(i,a?{x:e.x,y:s,w:e.w,h:0,opacity:null!==(o=e.style.opacity)&&void 0!==o?o:1}:{x:s,y:e.y,w:0,h:e.h,opacity:null!==(r=e.style.opacity)&&void 0!==r?r:1}):"point"===e.type?this.prevPositionMap.set(i,{x:e.x,y:e.y,r:0,opacity:0}):"wedge"===e.type&&(void 0===c&&(c=e.startAngle),this.prevPositionMap.set(i,{x:e.cx,y:e.cy,startAngle:c,endAngle:c,innerRadius:e.innerRadius,outerRadius:e.outerRadius,opacity:0})))}}getNodeKey(t,e){var i,o,r;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:""}`:"wedge"===t.type?"w:"+(null!==(r=t.category)&&void 0!==r?r:""):null}snapshotPositions(){var t;this.prevPositionMap.clear();const e=new Map;for(let i=0;this.scene.length>i;i++){const o=this.scene[i],r=this.getNodeKey(o,e);r&&("point"===o.type?this.prevPositionMap.set(r,{x:o.x,y:o.y,r:o.r,opacity:o.style.opacity}):"rect"===o.type?this.prevPositionMap.set(r,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style.opacity}):"wedge"===o.type&&this.prevPositionMap.set(r,{x:o.cx,y:o.cy,startAngle:o.startAngle,endAngle:o.endAngle,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:null!==(t=o.style.opacity)&&void 0!==t?t:1}))}}startTransition(){var t,e,i,o,r,n,s,a,c,l,h,u,d,f,g,y,p,m,v,x,b;if(!this.config.transition||0===this.prevPositionMap.size)return;const k=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 A=!1;const w=new Set,S=new Map;for(let t=0;this.scene.length>t;t++){const l=this.scene[t],h=this.getNodeKey(l,S);if(!h)continue;l._transitionKey=h;const u=this.prevPositionMap.get(h);if("point"===l.type)u?(w.add(h),l._targetOpacity=null!==(e=l.style.opacity)&&void 0!==e?e:1,(u.x!==l.x||u.y!==l.y||void 0!==u.r&&u.r!==l.r)&&(l._targetX=l.x,l._targetY=l.y,l._targetR=l.r,l.x=u.x,l.y=u.y,void 0!==u.r&&(l.r=u.r),A=!0)):(l._targetOpacity=null!==(i=l.style.opacity)&&void 0!==i?i:1,l._targetR=l.r,l.r=0,l.style=Object.assign(Object.assign({},l.style),{opacity:0}),A=!0);else if("rect"===l.type)u?(w.add(h),l._targetOpacity=null!==(o=l.style.opacity)&&void 0!==o?o:1,u.x===l.x&&u.y===l.y&&u.w===l.w&&u.h===l.h||(l._targetX=l.x,l._targetY=l.y,l._targetW=l.w,l._targetH=l.h,l.x=u.x,l.y=u.y,l.w=null!==(r=u.w)&&void 0!==r?r:l.w,l.h=null!==(n=u.h)&&void 0!==n?n:l.h,A=!0)):(l._targetOpacity=null!==(s=l.style.opacity)&&void 0!==s?s:1,l.style=Object.assign(Object.assign({},l.style),{opacity:0}),A=!0);else if("wedge"===l.type)if(u)w.add(h),l._targetOpacity=null!==(a=l.style.opacity)&&void 0!==a?a:1,u.startAngle===l.startAngle&&u.endAngle===l.endAngle||(l._targetStartAngle=l.startAngle,l._targetEndAngle=l.endAngle,l.startAngle=u.startAngle,l.endAngle=u.endAngle,A=!0);else{l._targetOpacity=null!==(c=l.style.opacity)&&void 0!==c?c:1,l._targetStartAngle=l.startAngle,l._targetEndAngle=l.endAngle;const t=l.startAngle;l.startAngle=t,l.endAngle=t,l.style=Object.assign(Object.assign({},l.style),{opacity:0}),this.prevPositionMap.set(h,{x:l.cx,y:l.cy,startAngle:t,endAngle:t,innerRadius:l.innerRadius,outerRadius:l.outerRadius,opacity:0}),A=!0}}this.exitNodes=[];for(const[t,e]of this.prevPositionMap)if(!w.has(t)){if(t.startsWith("p:"))this.exitNodes.push({type:"point",x:e.x,y:e.y,r:null!==(l=e.r)&&void 0!==l?l:3,style:{opacity:null!==(h=e.opacity)&&void 0!==h?h:1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))this.exitNodes.push({type:"rect",x:e.x,y:e.y,w:null!==(u=e.w)&&void 0!==u?u:0,h:null!==(d=e.h)&&void 0!==d?d:0,style:{opacity:null!==(f=e.opacity)&&void 0!==f?f:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("w:")){const i=((null!==(g=e.startAngle)&&void 0!==g?g:0)+(null!==(y=e.endAngle)&&void 0!==y?y:0))/2;this.exitNodes.push({type:"wedge",cx:e.x,cy:e.y,innerRadius:null!==(p=e.innerRadius)&&void 0!==p?p:0,outerRadius:null!==(m=e.outerRadius)&&void 0!==m?m:100,startAngle:null!==(v=e.startAngle)&&void 0!==v?v:0,endAngle:null!==(x=e.endAngle)&&void 0!==x?x:0,style:{opacity:null!==(b=e.opacity)&&void 0!==b?b:1},datum:null,category:t.slice(2),_targetStartAngle:i,_targetEndAngle:i,_targetOpacity:0,_transitionKey:t})}A=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),A&&(this.activeTransition={startTime:Lt(),duration:k})}advanceTransition(t){var e,i,o,r;if(!this.activeTransition)return!1;const n=Tt(t,this.activeTransition),s=Ot(n,"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=Et(r,t._targetOpacity,s)}const o=this.prevPositionMap.get(e);void 0!==t._targetX&&o&&(t.x=Et(o.x,t._targetX,s),t.y=Et(o.y,t._targetY,s)),void 0!==t._targetR&&void 0!==(null==o?void 0:o.r)&&(t.r=Et(o.r,t._targetR,s))}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=Et(r,t._targetOpacity,s)}if(void 0===t._targetX)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=Et(i.x,t._targetX,s),t.y=Et(i.y,t._targetY,s),void 0!==i.w&&(t.w=Et(i.w,t._targetW,s),t.h=Et(i.h,t._targetH,s))}else if("wedge"===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=Object.assign(Object.assign({},t.style),{opacity:Et(o,t._targetOpacity,s)})}if(void 0!==t._targetStartAngle&&void 0!==t._targetEndAngle){const i=this.prevPositionMap.get(e);i&&void 0!==i.startAngle&&(t.startAngle=Et(i.startAngle,t._targetStartAngle,s),t.endAngle=Et(i.endAngle,t._targetEndAngle,s))}}}if(n>=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&&void 0===t._targetR)continue;void 0!==t._targetX&&(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"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=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._dataVersion++,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._dataVersion++,this.version++,n}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!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._pointQuadtree=null,this._maxPointRadius=0,this._dataVersion++,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(("colorScheme"in t&&t.colorScheme!==e.colorScheme||"themeCategorical"in t&&t.themeCategorical!==e.themeCategorical||"colorAccessor"in t&&!mt(t.colorAccessor,e.colorAccessor))&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),("categoryAccessor"in t&&!mt(t.categoryAccessor,e.categoryAccessor)||"oAccessor"in t&&!mt(t.oAccessor,e.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,t),("categoryAccessor"in t||"oAccessor"in t)&&(mt(t.categoryAccessor||t.oAccessor,e.categoryAccessor||e.oAccessor)||(this.getO=bt(this.config.categoryAccessor||this.config.oAccessor,"category"),this.categories.clear())),"valueAccessor"in t||"rAccessor"in t){const i=t.valueAccessor||t.rAccessor,o=e.valueAccessor||e.rAccessor,r=Array.isArray(i)?i:[i],n=Array.isArray(o)?o:[o];if(r.length!==n.length||r.some((t,e)=>!mt(t,n[e]))){const t=this.config.valueAccessor||this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>vt(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new yt)):(this.getR=vt(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!mt(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?bt(this.config.stackBy):void 0),"groupBy"in t&&!mt(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?bt(this.config.groupBy):void 0),"colorAccessor"in t&&!mt(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?bt(this.config.colorAccessor):void 0),"connectorAccessor"in t&&!mt(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?bt(this.config.connectorAccessor):void 0)}}ri.QUADTREE_THRESHOLD=500;const ni={mercator:nt,equalEarth:tt,albersUsa:rt,orthographic:ot,naturalEarth:it,equirectangular:et};function si(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function ai(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function ci(t,e,i){return t?Object.assign(Object.assign({},i),"function"==typeof t?t(e):t):Object.assign({},i)}function li(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 hi(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,h=(t[1]+e[1])/2+a*c,u=[];for(let o=0;i>=o;o++){const r=o/i,n=1-r;u.push([n*n*t[0]+2*n*r*l+r*r*e[0],n*n*t[1]+2*n*r*h+r*r*e[1]])}return u}function ui(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 di(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,h=r/2+1;return[[t[0]+c*h,t[1]+l*h],[e[0]+c*h,e[1]+l*h]]}class fi{constructor(t){this.scene=[],this.scales=null,this.version=0,this._quadtree=null,this._maxPointRadius=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._hasRenderedOnce=!1,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 gt(t),this.timestampBuffer=new gt(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._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.version++}computeScene(t){const{config:e}=this;this.projection=function(t){if(!t)return tt();if("string"==typeof t){const e=ni[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),tt())}if("object"==typeof t&&"type"in t){const e=ni[t.type],i=e?e():tt();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=Z(this.projection),this.fitProjection(t),this.geoPath=Z(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;if(this.scene=this.buildSceneNodes(t),this.rebuildQuadtree(),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&!this._hasRenderedOnce&&this.scene.length>0&&e.introAnimation){const e=t.width/2,i=t.height/2,o=this.scene.filter(t=>"point"===t.type).map(t=>Object.assign(Object.assign({},t),{x:e,y:i}));o.length>0&&this.startTransition(o)}this._hasRenderedOnce=!0,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=si(a.xAccessor,"lon"),h=si(a.yAccessor,"lat"),u=this.getPoints();if(u.length>0){const t=u.map(t=>[l(t),h(t)]);c.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const d=ai(a.lineDataAccessor);for(const t of this.lineData){const e=d(t);if(e&&e.length>0){const t=e.map(t=>[l(t),h(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=Z(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.rebuildQuadtree(),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=Z(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.rebuildQuadtree(),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=Z(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.rebuildQuadtree(),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}rebuildQuadtree(){let t=0,e=0;for(const i of this.scene)"point"===i.type&&(e++,i.r>t&&(t=i.r));if(this._maxPointRadius=t,fi.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const i=Array(e);let o=0;for(const t of this.scene)"point"===t.type&&(i[o++]=t);this._quadtree=l().x(t=>t.x).y(t=>t.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(t){var e,i,o;const r=[],{config:n}=this,s=this.projection,a=this.geoPath,c=si(n.xAccessor,"lon"),l=si(n.yAccessor,"lat"),h=function(t){var e,i;return{fill:(null===(e=t.themeSemantic)||void 0===e?void 0:e.surface)||"#e0e0e0",stroke:(null===(i=t.themeSemantic)||void 0===i?void 0:i.border)||"#999",strokeWidth:.5,fillOpacity:1}}(n),u=function(t){var e;return{stroke:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",strokeWidth:1.5,fill:"none"}}(n),d=function(t){var e;return{fill:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",r:4,fillOpacity:.8}}(n);if(n.graticule){const e=!0===n.graticule?{}:n.graticule,i=U();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=ci(n.areaStyle,t,h);r.push({type:"geoarea",pathData:e,centroid:i,bounds:o,screenArea:s,style:c,datum:t,interactive:!0})}const f=ai(n.lineDataAccessor);for(const e of this.lineData){const i=f(e);if(!i||2>i.length)continue;let o=[];if("geo"===n.lineType){const t=Array(i.length);for(let e=0;i.length>e;e++)t[e]=[c(i[e]),l(i[e])];for(let e=0;t.length-1>e;e++){const i=t[e],r=t[e+1],n=K(i,r)||0,a=Math.max(2,Math.ceil(n/(Math.PI/180))),c=J(i,r);for(let t=0;a>=t;t++){if(e>0&&0===t)continue;const i=s(c(t/a));null!=i&&o.push(i)}}}else for(let t=0;i.length>t;t++){const e=i[t],r=s([c(e),l(e)]);null!=r&&o.push(r)}if(2>o.length)continue;const a=ci(n.lineStyle,e,u),h="number"==typeof a.strokeWidth?a.strokeWidth:1;2!==i.length||2>o.length||"arc"!==n.flowStyle?2!==i.length||2>o.length||"offset"!==n.flowStyle||(o="geo"===n.lineType?ui(o,h):di(o[0],o[o.length-1],0,0,h)):o=hi(o[0],o[o.length-1]);const d=li(o,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({},a),{_edgeFade:!0}),datum:e};r.push(i)}else r.push({type:"line",path:2>o.length&&d[0]||o,style:a,datum:e})}const g=this.getPoints(),y=n.pointIdAccessor?"function"==typeof n.pointIdAccessor?n.pointIdAccessor:t=>t[n.pointIdAccessor]:null,p=s.clipAngle&&null!==(e=s.clipAngle())&&void 0!==e?e:0,m=p>0?p*Math.PI/180:null,v=s.rotate?s.rotate():[0,0,0],x="function"==typeof s.center?s.center():[0,0],b=[(null!==(i=x[0])&&void 0!==i?i:0)-v[0],(null!==(o=x[1])&&void 0!==o?o:0)-v[1]];for(let t=0;g.length>t;t++){const e=g[t],i=c(e),o=l(e);if(null!=m&&K([i,o],b)>m)continue;const a=s([i,o]);if(!a)continue;const h=n.pointStyle?n.pointStyle(e):Object.assign({},d),u={type:"point",x:a[0],y:a[1],r:h.r||4,style:h,datum:e,pointId:y?y(e)+"":void 0};r.push(u)}return r}applyCartogramTransform(t,e){var i,o,r;const s=this.scene.filter(t=>"point"===t.type);if(2>s.length)return;const a=null!==(i=t.strength)&&void 0!==i?i:1;if(0===a)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],h=s.find(e=>c(e.datum)+""==t.center+"");if(!h)return void("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`));const u=h.x,d=h.y,f=s.map(t=>l(t.datum)).filter(t=>isFinite(t)&&t>=0),g=Math.max(...f,1),y=Math.min(e.width,e.height)/2,p=n().domain([0,g]).range([0,y]);this.cartogramLayout={cx:u,cy:d,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 s){if(t===h)continue;const e=Math.atan2(t.y-d,t.x-u),i=Math.sqrt(Math.pow(t.x-u,2)+Math.pow(t.y-d,2)),o=l(t.datum),r=i+((isFinite(o)?p(o):i)-i)*a;t.x=u+Math.cos(e)*r,t.y=d+Math.sin(e)*r}const m=e.width/2,v=e.height/2,x=m-h.x,b=v-h.y;if(Math.abs(x)>.5||Math.abs(b)>.5)for(const t of s)t.x+=x,t.y+=b;this.cartogramLayout={cx:m,cy:v,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 s)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=Pt(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=Tt(t,this.activeTransition),i=Ot(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=Et(t.x,t._targetX,i),t.y=Et(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 gi(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}function yi(i,o){var r,n,s;switch(i.type){case"line":{const e=i;if(0===e.path.length)return null;const r="M"+e.path.map(([t,e])=>`${t},${e}`).join("L");return t("path",{d:r,fill:"none",stroke:e.style.stroke||"#4e79a7",strokeWidth:e.style.strokeWidth||2,strokeDasharray:e.style.strokeDasharray,opacity:e.style.opacity},"line-"+o)}case"area":{const e=i;if(0===e.topPath.length)return null;const s=e.topPath.map(([t,e])=>`${t},${e}`).join("L"),a=[...e.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return t("path",{d:`M${s}L${a}Z`,fill:gi(e.style.fill),fillOpacity:null!==(n=null!==(r=e.style.fillOpacity)&&void 0!==r?r:e.style.opacity)&&void 0!==n?n:.7,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"area-"+o)}case"point":{const e=i;return t("circle",{cx:e.x,cy:e.y,r:e.r,fill:gi(e.style.fill),opacity:null!==(s=e.style.opacity)&&void 0!==s?s:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"point-"+o)}case"rect":{const e=i;return t("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:gi(e.style.fill),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"rect-"+o)}case"heatcell":{const r=i;if(r.showValues&&null!=r.value&&r.w>=20&&r.h>=20){const i=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),[n,s,a]=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),c=.299*n+.587*s+.114*a>128?"#000":"#fff",l=Math.max(10,Math.min(16,.3*Math.min(r.w,r.h)));return e("g",{children:[t("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:r.fill}),t("text",{x:r.x+r.w/2,y:r.y+r.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:c,fontSize:l+"px",children:i})]},"heatcell-"+o)}return t("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:r.fill},"heatcell-"+o)}case"candlestick":{const r=i,n=Math.min(r.openY,r.closeY),s=Math.max(Math.abs(r.openY-r.closeY),1),a=r.isUp?r.upColor:r.downColor;return e("g",{children:[t("line",{x1:r.x,y1:r.highY,x2:r.x,y2:r.lowY,stroke:r.wickColor,strokeWidth:r.wickWidth}),t("rect",{x:r.x-r.bodyWidth/2,y:n,width:r.bodyWidth,height:s,fill:a,stroke:a,strokeWidth:1})]},"candle-"+o)}default:return null}}function pi(i,o){var r,n,s,a,c;const l=("category"in i?i.category:void 0)||("group"in i?i.group:void 0)||"",h=t=>`ord-${i.type}-${l}-${o}-${t}`,u=`ord-${i.type}-${l}-${o}`;switch(i.type){case"rect":{const o=i,r=function(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}(u)+"-grad",n=function(e,i){const o=e.fillGradient;if(!o)return null;let r=e.x,n=e.y,s=e.x,a=e.y+e.h;"bottom"===e.roundedEdge?(n=e.y+e.h,a=e.y):"right"===e.roundedEdge?(r=e.x+e.w,n=e.y,s=e.x,a=e.y):"left"===e.roundedEdge&&(r=e.x,n=e.y,s=e.x+e.w,a=e.y);const c=[];if("colorStops"in o){const e=o.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>e.length)return null;for(let i=0;e.length>i;i++)c.push(t("stop",{offset:e[i].offset,stopColor:e[i].color},i))}else{const i=gi(e.style.fill);c.push(t("stop",{offset:0,stopColor:i,stopOpacity:o.topOpacity},"0")),c.push(t("stop",{offset:1,stopColor:i,stopOpacity:o.bottomOpacity},"1"))}return t("linearGradient",{id:i,gradientUnits:"userSpaceOnUse",x1:r,y1:n,x2:s,y2:a,children:c})}(o,r),s=n?`url(#${r})`:gi(o.style.fill);if(o.roundedTop&&o.roundedTop>0){const i=Math.min(o.roundedTop,o.w/2,o.h/2),{x:r,y:a,w:c,h:l}=o;let h;switch(o.roundedEdge){case"right":h=`M${r},${a} L${r+c-i},${a} A${i},${i} 0 0 1 ${r+c},${a+i} L${r+c},${a+l-i} A${i},${i} 0 0 1 ${r+c-i},${a+l} L${r},${a+l} Z`;break;case"left":h=`M${r+c},${a} L${r+i},${a} A${i},${i} 0 0 0 ${r},${a+i} L${r},${a+l-i} A${i},${i} 0 0 0 ${r+i},${a+l} L${r+c},${a+l} Z`;break;case"bottom":h=`M${r},${a} L${r+c},${a} L${r+c},${a+l-i} A${i},${i} 0 0 1 ${r+c-i},${a+l} L${r+i},${a+l} A${i},${i} 0 0 1 ${r},${a+l-i} Z`;break;default:h=`M${r},${a+l} L${r},${a+i} A${i},${i} 0 0 1 ${r+i},${a} L${r+c-i},${a} A${i},${i} 0 0 1 ${r+c},${a+i} L${r+c},${a+l} Z`}return e(st.Fragment,{children:[n&&t("defs",{children:n}),t("path",{d:h,fill:s,opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},u)}return e(st.Fragment,{children:[n&&t("defs",{children:n}),t("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:s,opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},u)}case"point":{const e=i;return t("circle",{cx:e.x,cy:e.y,r:e.r,fill:gi(e.style.fill),opacity:null!==(r=e.style.opacity)&&void 0!==r?r:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},u)}case"wedge":{const e=i,o=F().innerRadius(e.innerRadius).outerRadius(e.outerRadius).startAngle(e.startAngle+Math.PI/2).endAngle(e.endAngle+Math.PI/2);e.cornerRadius&&o.cornerRadius(e.cornerRadius);const r=o({})||"";return t("path",{d:r,transform:`translate(${e.cx},${e.cy})`,fill:gi(e.style.fill),stroke:e.style.stroke,strokeWidth:e.style.strokeWidth,opacity:e.style.opacity},u)}case"boxplot":{const o=i,r=o.columnWidth/2;return e("g","vertical"===o.projection?{children:[t("line",{x1:o.x,y1:o.minPos,x2:o.x,y2:o.maxPos,stroke:o.style.stroke||"#333",strokeWidth:1}),t("rect",{x:o.x-r,y:Math.min(o.q1Pos,o.q3Pos),width:o.columnWidth,height:Math.abs(o.q3Pos-o.q1Pos),fill:gi(o.style.fill),fillOpacity:null!==(n=o.style.fillOpacity)&&void 0!==n?n:.6,stroke:o.style.stroke||"#333",strokeWidth:1}),t("line",{x1:o.x-r,y1:o.medianPos,x2:o.x+r,y2:o.medianPos,stroke:o.style.stroke||"#333",strokeWidth:2}),t("line",{x1:o.x-.5*r,y1:o.minPos,x2:o.x+.5*r,y2:o.minPos,stroke:o.style.stroke||"#333",strokeWidth:1}),t("line",{x1:o.x-.5*r,y1:o.maxPos,x2:o.x+.5*r,y2:o.maxPos,stroke:o.style.stroke||"#333",strokeWidth:1})]}:{children:[t("line",{x1:o.minPos,y1:o.y,x2:o.maxPos,y2:o.y,stroke:o.style.stroke||"#333",strokeWidth:1}),t("rect",{x:Math.min(o.q1Pos,o.q3Pos),y:o.y-r,width:Math.abs(o.q3Pos-o.q1Pos),height:o.columnWidth,fill:gi(o.style.fill),fillOpacity:null!==(s=o.style.fillOpacity)&&void 0!==s?s:.6,stroke:o.style.stroke||"#333",strokeWidth:1}),t("line",{x1:o.medianPos,y1:o.y-r,x2:o.medianPos,y2:o.y+r,stroke:o.style.stroke||"#333",strokeWidth:2}),t("line",{x1:o.minPos,y1:o.y-.5*r,x2:o.minPos,y2:o.y+.5*r,stroke:o.style.stroke||"#333",strokeWidth:1}),t("line",{x1:o.maxPos,y1:o.y-.5*r,x2:o.maxPos,y2:o.y+.5*r,stroke:o.style.stroke||"#333",strokeWidth:1})]},u)}case"violin":{const e=i,o=[t("path",{d:e.pathString,transform:e.translateX||e.translateY?`translate(${e.translateX},${e.translateY})`:void 0,fill:gi(e.style.fill),fillOpacity:null!==(a=e.style.fillOpacity)&&void 0!==a?a:.6,stroke:e.style.stroke||"#333",strokeWidth:e.style.strokeWidth||1},h("path"))];if(e.iqrLine&&e.bounds){const i=e.bounds,r=i.x+i.width/2,n=i.y+i.height/2;i.height>i.width?o.push(t("line",{x1:r,y1:e.iqrLine.q1Pos,x2:r,y2:e.iqrLine.q3Pos,stroke:e.style.stroke||"#333",strokeWidth:2},h("iqr")),t("circle",{cx:r,cy:e.iqrLine.medianPos,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},h("med"))):o.push(t("line",{x1:e.iqrLine.q1Pos,y1:n,x2:e.iqrLine.q3Pos,y2:n,stroke:e.style.stroke||"#333",strokeWidth:2},h("iqr")),t("circle",{cx:e.iqrLine.medianPos,cy:n,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},h("med")))}return t("g",{children:o},u)}case"connector":return t("line",{x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,stroke:i.style.stroke||"#999",strokeWidth:i.style.strokeWidth||1,opacity:null!==(c=i.style.opacity)&&void 0!==c?c:.5},u);case"trapezoid":{const e=i,o=e.points.map(t=>`${t[0]},${t[1]}`).join(" ");return t("polygon",{points:o,fill:gi(e.style.fill,"#999"),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},u)}default:return null}}function mi(t){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{categorical:vi})})),t.accessibility.highContrast){const t="dark"===e.mode;e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{text:t?"#ffffff":"#000000",textSecondary:t?"#cccccc":"#333333",grid:t?"#666666":"#999999",border:t?"#888888":"#000000"})})}return e}fi.QUADTREE_THRESHOLD=500;const vi=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],xi={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},bi={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},ki={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:vi,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},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"};at(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:xi,setTheme(e){t(t=>{if("light"===e)return{theme:xi};if("dark"===e)return{theme:bi};if("high-contrast"===e)return{theme:ki};if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?bi:xi;return{theme:mi(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:mi(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 Ai={light:xi,dark:bi,"high-contrast":ki,pastels:{mode:"light",colors:{primary:"#c9a0dc",secondary:"#b8a8c8",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",surface:"#fff5ee",text:"#4a3728",textSecondary:"#8b7355",grid:"#e8d5c4",border:"#e8d5c4",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#9ad4a3",danger:"#e8869a",warning:"#f0c888",error:"#c86070",info:"#9cb8e0"},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",secondary:"#a899c0",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",surface:"#251e35",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#88d4ab",danger:"#f0a0c0",warning:"#f0c888",error:"#e87690",info:"#9cb8e0"},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",secondary:"#6b7280",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",surface:"#ffffff",text:"#2c3e50",textSecondary:"#7f8c9b",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb",annotation:"#2563eb",success:"#10b981",danger:"#ef4444",warning:"#f59e0b",error:"#dc2626",info:"#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",secondary:"#9ca3af",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",surface:"#1f2937",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6",annotation:"#3b82f6",success:"#34d399",danger:"#f87171",warning:"#fbbf24",error:"#ef4444",info:"#60a5fa"},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",secondary:"#666666",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",surface:"#ffffff",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000",annotation:"#cc0000",success:"#556b2f",danger:"#cc0000",warning:"#c8a415",error:"#8b0000",info:"#4682b4"},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",secondary:"#aaaaaa",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",surface:"#1a1a1a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333",annotation:"#ff3333",success:"#7a8b5a",danger:"#ff3333",warning:"#d4a843",error:"#cc0000",info:"#6aa4d4"},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",secondary:"#555555",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",surface:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000",success:"#556b2f",danger:"#8b0000",warning:"#b88700",error:"#6b0000",info:"#4a5568"},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",secondary:"#a09880",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",surface:"#262520",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050",annotation:"#c05050",success:"#7a8b5a",danger:"#c05050",warning:"#c8a060",error:"#a04040",info:"#8090a0"},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",secondary:"#666666",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",surface:"#f8f8f8",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#e45050",success:"#2d7a3d",danger:"#c8303a",warning:"#d4a843",error:"#a02028",info:"#3a86c8"},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",secondary:"#a0a0a0",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",surface:"#1e1e1e",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b",annotation:"#ff6b6b",success:"#6fba78",danger:"#ff6b6b",warning:"#e0c060",error:"#d04040",info:"#5a9fd8"},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",secondary:"#7c5a9e",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",surface:"#ffffff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6",annotation:"#8b5cf6",success:"#10d870",danger:"#ff4b6e",warning:"#ffaa33",error:"#e11d48",info:"#06b6d4"},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",secondary:"#b8a0d8",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",surface:"#1f1138",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa",annotation:"#a78bfa",success:"#4ade80",danger:"#fb7185",warning:"#fbbf24",error:"#f43f5e",info:"#22d3ee"},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",secondary:"#525252",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe",annotation:"#0f62fe",success:"#24a148",danger:"#da1e28",warning:"#f1c21b",error:"#a2191f",info:"#0043ce"},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",secondary:"#a8a8a8",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",surface:"#262626",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff",annotation:"#4589ff",success:"#42be65",danger:"#fa4d56",warning:"#f1c21b",error:"#da1e28",info:"#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 wi(t){if(!t)return xi;if("string"==typeof t){if("light"===t)return xi;if("dark"===t)return bi;if("high-contrast"===t)return ki;return Ai[t]||xi}const e="dark"===t.mode?bi:xi;return mi(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 Si(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 _i(i){const{categories:o,colorScheme:n,theme:s,position:a="right",totalWidth:c,totalHeight:l,margin:h,hasTitle:u=!1}=i;if(!o||0===o.length)return null;const d=function(t,e,i){const o=Array.isArray(e)?e:i.colors.categorical.length>0?i.colors.categorical:x;return r().domain(t).range(o)}(o,n,s),f="top"===a||"bottom"===a;let g,y;if("left"===a?(g=4,y=h.top):"top"===a?(g=h.left,y=u?32:8):"bottom"===a?(g=h.left,y=Math.min(l-h.bottom+38,l-16)):(g=c-h.right+10,y=h.top),f){let i=0;const r=o.map((o,r)=>{const n=i;return i+=22+6.5*o.length+8,e("g",{transform:`translate(${n},0)`,children:[t("rect",{width:14,height:14,fill:d(o),rx:2}),t("text",{x:20,y:7,dominantBaseline:"central",fontSize:s.typography.tickSize,fill:s.colors.text,fontFamily:s.typography.fontFamily,children:o})]},"legend-"+r)});return t("g",{className:"semiotic-legend",transform:`translate(${g},${y})`,children:r})}const p=o.map((i,o)=>e("g",{transform:`translate(0,${20*o})`,children:[t("rect",{width:14,height:14,fill:d(i),rx:2}),t("text",{x:20,y:7,dominantBaseline:"central",fontSize:s.typography.tickSize,fill:s.colors.text,fontFamily:s.typography.fontFamily,children:i})]},"legend-"+o));return t("g",{className:"semiotic-legend",transform:`translate(${g},${y})`,children:p})}function Pi(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 Mi(t,e){return t.color||e.colors.annotation||e.colors.text}function Oi(e){const{annotations:i}=e;if(!i||0===i.length)return null;const o=[];for(let t=0;i.length>t;t++){const r=Ti(i[t],t,e);r&&o.push(r)}return o.length>0?t("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:o}):null}function Ti(i,o,r){var n,s,a,c;const{scales:l,layout:h,theme:u,xAccessor:d,yAccessor:f}=r;switch(i.type){case"y-threshold":{const s=i.value;if(null==s)return null;const a=Mi(i,u),c=i.label,d=i.labelPosition||"right",f=i.strokeDasharray||"6,4",g=null!==(n=i.strokeWidth)&&void 0!==n?n:1.5;if("horizontal"===r.projection&&l.r){const i=l.r(s);return null==i?null:e("g",{children:[t("line",{x1:i,y1:0,x2:i,y2:h.height,stroke:a,strokeWidth:g,strokeDasharray:f}),c&&t("text",{x:i+4,y:12,textAnchor:"start",fontSize:u.typography.tickSize,fill:a,fontFamily:u.typography.fontFamily,children:c})]},"ann-ythresh-"+o)}const y=l.y?l.y(s):l.r?l.r(s):null;return null==y?null:e("g",{children:[t("line",{x1:0,y1:y,x2:h.width,y2:y,stroke:a,strokeWidth:g,strokeDasharray:f}),c&&t("text",{x:"left"===d?4:"center"===d?h.width/2:h.width-4,y:y-6,textAnchor:"left"===d?"start":"center"===d?"middle":"end",fontSize:u.typography.tickSize,fill:a,fontFamily:u.typography.fontFamily,children:c})]},"ann-ythresh-"+o)}case"x-threshold":{const r=i.value;if(null==r||!l.x)return null;const n=l.x(r);if(null==n)return null;const a=Mi(i,u),c=i.label,d=i.labelPosition||"top",f=null!==(s=i.strokeWidth)&&void 0!==s?s:1.5;return e("g",{children:[t("line",{x1:n,y1:0,x2:n,y2:h.height,stroke:a,strokeWidth:f,strokeDasharray:i.strokeDasharray||"6,4"}),c&&t("text",{x:n+4,y:"bottom"===d?h.height-4:"center"===d?h.height/2:12,textAnchor:"start",fontSize:u.typography.tickSize,fill:a,fontFamily:u.typography.fontFamily,children:c})]},"ann-xthresh-"+o)}case"band":{const r=null!=i.y0&&l.y?l.y(i.y0):null,n=null!=i.y1&&l.y?l.y(i.y1):null;if(null==r||null==n)return null;const s=Math.min(r,n),c=Math.abs(n-r),d=i.fill||Mi(i,u),f=null!==(a=i.opacity)&&void 0!==a?a:.1;return e("g",{children:[t("rect",{x:0,y:s,width:h.width,height:c,fill:d,opacity:f}),i.label&&t("text",{x:h.width-4,y:s+12,textAnchor:"end",fontSize:u.typography.tickSize,fill:d,fontFamily:u.typography.fontFamily,children:i.label})]},"ann-band-"+o)}case"category-highlight":{if(!i.category||!l.o)return null;const e=l.o(i.category);if(null==e)return null;const n=l.o.bandwidth?l.o.bandwidth():40,s=Mi(i,u),a=null!==(c=i.opacity)&&void 0!==c?c:.1;return t("rect","horizontal"===r.projection?{x:0,y:e,width:h.width,height:n,fill:s,opacity:a}:{x:e,y:0,width:n,height:h.height,fill:s,opacity:a},"ann-cathighlight-"+o)}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}(i,l,d),n=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}(i,l,f);if(null==r||null==n)return null;const s=i.dx||0,a=i.dy||0,c=i.color||u.colors.text;return e("g",{children:["label"===i.type&&t("line",{x1:r,y1:n,x2:r+s,y2:n+a,stroke:u.colors.textSecondary,strokeWidth:1}),t("text",{x:r+s,y:n+a,textAnchor:i.textAnchor||"start",fontSize:i.fontSize||u.typography.labelSize,fill:c,fontFamily:u.typography.fontFamily,fontWeight:i.fontWeight,children:i.label||i.title})]},"ann-label-"+o)}default:return null}}const Ei={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)},CandlestickChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"candlestick",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.highAccessor||"high",highAccessor:r.highAccessor||"high",lowAccessor:r.lowAccessor||"low",openAccessor:r.openAccessor,closeAccessor:r.closeAccessor,candlestickStyle:r.candlestickStyle},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,h=null!==(s=r.max)&&void 0!==s?s:100,u=null!==(a=r.sweep)&&void 0!==a?a:240,d=null!==(c=r.arcWidth)&&void 0!==c?c:.3,f=180+(360-u)/2,g=r.thresholds||[{value:h,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},[v,x]=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(v-(m.left||0)-(m.right||0),x-(m.top||0)-(m.bottom||0))/2*(1-d)),sweepAngle:u,startAngle:f,oSort:!1,pieceStyle:(t,e)=>({fill:p[e||""]||"#4e79a7"})},o),{showAxes:!1,__gauge:{gMin:l,gMax:h,sweep:u,arcWidth:d,value:r.value,startAngleDeg:f,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)},FlowMap:{frameType:"geo",buildProps:(t,e,i,o,r)=>{var n,s,a,c,l;const h=(Array.isArray(t)?t:null)||r.flows||[],u=r.nodeIdAccessor||"id",d=r.valueAccessor||"value",f=r.xAccessor||"lon",g=r.yAccessor||"lat",y="function"==typeof f?f:t=>t[f],p="function"==typeof g?g:t=>t[g],m=(r.nodes||[]).map(t=>Object.assign(Object.assign({},t),{x:y(t),y:p(t)})),v=new Map;for(const t of m)v.set(t[u]+"",t);const x=null!==(n=r.edgeColorBy)&&void 0!==n?n:e,b="function"==typeof x,k=h.map(t=>{if(!t||null==t.source||null==t.target)return null;const e=v.get(t.source+""),i=v.get(t.target+"");return e&&i?Object.assign(Object.assign({},t),{coordinates:[{x:e.x,y:e.y},{x:i.x,y:i.y}]}):null}).filter(Boolean),A="__flowMapEdgeColor",w=x?b?_t(k.map(t=>({[A]:x(t)})),A,i||"category10"):_t(k,x,i||"category10"):null,S=t=>x&&w?function(t,e,i){if("function"==typeof e){const o=e(t);return i&&o&&"string"==typeof o&&!function(t){const e=t.toLowerCase();return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")||St.has(e)}(o)?i(o):o}const o=null==t?void 0:t[e];return i?i(o):At[Math.abs(function(t){let e=0;for(let i=0;t.length>i;i++)e=(e<<5)-e+t.charCodeAt(i),e&=e;return Math.abs(e)}(o+""))%At.length]}(t,x,w):"#007bff";let _=1/0,P=-1/0;for(const t of k){const e=Number(null!==(s=t[d])&&void 0!==s?s:0);isFinite(e)&&(_>e&&(_=e),e>P&&(P=e))}const M=P>_?P-_:0,[O,T]=null!==(a=r.edgeWidthRange)&&void 0!==a?a:[1,8],E=T-O,L=null!==(c=r.edgeOpacity)&&void 0!==c?c:.6,j=null!==(l=r.edgeLinecap)&&void 0!==l?l:"round";return Object.assign({lines:k,points:m,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:r.lineType||"geo",flowStyle:r.flowStyle||"basic",areas:r.areas,areaStyle:r.areaStyle,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding,colorScheme:i,lineStyle:t=>{const e=Number(null==t?void 0:t[d]),i=O+Math.max(0,Math.min(1,M>0?((Number.isFinite(e)?e:_)-_)/M:0))*E;return{stroke:S(t),strokeWidth:i,strokeLinecap:j,opacity:L,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8})},o)}}};function Li(t){return Math.round(100*t)/100+""}function ji(i,o){const r=Si(o.theme),n=o.idPrefix?o.idPrefix+"-":"",s="string"==typeof o.title?o.title:void 0,a=s?n+"semiotic-title":void 0,c=o.description?n+"semiotic-desc":void 0,l=[a,c].filter(Boolean).join(" ")||void 0;return e("svg",{xmlns:"http://www.w3.org/2000/svg",className:o.className,width:o.width,height:o.height,role:"img","aria-labelledby":l,style:{fontFamily:r.fontFamily},children:[s&&t("title",{id:a,children:s}),o.description&&t("desc",{id:c,children:o.description}),o.defs&&t("defs",{children:o.defs}),o.background&&"transparent"!==o.background&&t("rect",{x:0,y:0,width:o.width,height:o.height,fill:o.background}),t("g",{id:n+"data-area",transform:o.innerTransform,children:i}),s&&t("text",{id:n+"chart-title",x:o.width/2,y:16,textAnchor:"middle",fontSize:r.titleSize,fontWeight:"bold",fill:r.text,fontFamily:r.fontFamily,children:s}),o.legend&&t("g",{id:n+"legend",children:o.legend}),o.outerElements]})}function Di(r){var n,s,a,c;const l=wi(r.theme),h=r.size||[500,300],u=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),r.margin),d=r.legendPosition;r.showLegend&&(d&&"right"!==d?"left"===d?u.left=Math.max(u.left,100):"bottom"===d?u.bottom=Math.max(u.bottom,70):"top"===d&&(u.top=Math.max(u.top,40)):u.right=Math.max(u.right,100));const f=h[0]-u.left-u.right,g=h[1]-u.top-u.bottom,y="streaming"===r.runtimeMode||["bar","swarm","waterfall"].includes(r.chartType),p={chartType:r.chartType,windowSize:null!==(n=r.windowSize)&&void 0!==n?n:200,windowMode:null!==(s=r.windowMode)&&void 0!==s?s:"sliding",arrowOfTime:y&&null!==(a=r.arrowOfTime)&&void 0!==a?a:"right",extentPadding:null!==(c=r.extentPadding)&&void 0!==c?c:.1,xAccessor:y?void 0:r.xAccessor,yAccessor:y?void 0:r.yAccessor,timeAccessor:y?r.timeAccessor:void 0,valueAccessor:r.valueAccessor,colorAccessor:r.colorAccessor,sizeAccessor:r.sizeAccessor,groupAccessor:r.groupAccessor,categoryAccessor:r.categoryAccessor,lineDataAccessor:r.lineDataAccessor,xExtent:r.xExtent,yExtent:r.yExtent,sizeRange:r.sizeRange,binSize:r.binSize,normalize:r.normalize,boundsAccessor:r.boundsAccessor,boundsStyle:r.boundsStyle,openAccessor:r.openAccessor,highAccessor:r.highAccessor,lowAccessor:r.lowAccessor,closeAccessor:r.closeAccessor,candlestickStyle:r.candlestickStyle,lineStyle:r.lineStyle,pointStyle:r.pointStyle,areaStyle:r.areaStyle,colorScheme:r.colorScheme||l.colors.categorical,barColors:r.barColors},m=new Yt(p);if(r.data&&m.ingest({inserts:r.data,bounded:!0}),m.computeScene({width:f,height:g}),!m.scales||0===m.scene.length)return o.renderToStaticMarkup(ji(null,{width:h[0],height:h[1],className:"stream-xy-frame"+(r.className?" "+r.className:""),title:r.title,description:r.description,background:r.background,theme:l,innerTransform:`translate(${u.left},${u.top})`,idPrefix:r._idPrefix}));const v=r._idPrefix,x=r.showGrid?function(i,o,r,n){const{grid:s}=Si(r),a=n?n+"-":"",c=i.x.ticks(5),l=i.y.ticks(5);return e("g",{id:a+"grid",className:"semiotic-grid",opacity:.8,children:[c.map((e,r)=>{const n=i.x(e);return t("line",{x1:n,y1:0,x2:n,y2:o.height,stroke:s,strokeWidth:.5},"gx-"+r)}),l.map((e,r)=>{const n=i.y(e);return t("line",{x1:0,y1:n,x2:o.width,y2:n,stroke:s,strokeWidth:.5},"gy-"+r)})]})}(m.scales,{width:f,height:g},l,v):null,b=m.scene.map((t,e)=>yi(t,e)).filter(Boolean),k=!1!==r.showAxes?function(i,o,r,n,s){var a,c,l,h;const u=Si(n),d=i.x.ticks(5).map(t=>({pixel:i.x(t),label:(r.xFormat||r.tickFormatTime||Li)(t)})),f=i.y.ticks(5).map(t=>({pixel:i.y(t),label:(r.yFormat||r.tickFormatValue||Li)(t)}));return e("g",{id:(s?s+"-":"")+"axes",className:"stream-axes",children:[t("line",{x1:0,y1:o.height,x2:o.width,y2:o.height,stroke:u.border,strokeWidth:1}),d.map((i,r)=>e("g",{transform:`translate(${i.pixel},${o.height})`,children:[t("line",{y2:5,stroke:u.border,strokeWidth:1}),t("text",{y:18,textAnchor:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:i.label})]},"xtick-"+r)),r.xLabel&&t("text",{x:o.width/2,y:o.height+40,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,children:r.xLabel}),t("line",{x1:0,y1:0,x2:0,y2:o.height,stroke:u.border,strokeWidth:1}),f.map((i,o)=>e("g",{transform:`translate(0,${i.pixel})`,children:[t("line",{x2:-5,stroke:u.border,strokeWidth:1}),t("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:i.label})]},"ytick-"+o)),r.yLabel&&t("text",{x:15-(null!==(c=null===(a=r.margin)||void 0===a?void 0:a.left)&&void 0!==c?c:40),y:o.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-(null!==(h=null===(l=r.margin)||void 0===l?void 0:l.left)&&void 0!==h?h:40)}, ${o.height/2})`,children:r.yLabel})]})}(m.scales,{width:f,height:g},r,l,v):null,A=r.annotations?Oi({annotations:r.annotations,scales:{x:m.scales.x,y:m.scales.y},layout:{width:f,height:g},theme:l,xAccessor:"string"==typeof r.xAccessor?r.xAccessor:void 0,yAccessor:"string"==typeof r.yAccessor?r.yAccessor:void 0,idPrefix:v}):null,w=r.showLegend?(()=>{const t=Pi(r.data||[],r.colorAccessor||r.groupAccessor);return 0===t.length?null:_i({categories:t,colorScheme:r.colorScheme,theme:l,position:r.legendPosition||"right",totalWidth:h[0],totalHeight:h[1],margin:u,hasTitle:!!r.title})})():null,S=e(i,{children:[x,A,b,k]});return o.renderToStaticMarkup(ji(S,{width:h[0],height:h[1],className:"stream-xy-frame"+(r.className?" "+r.className:""),title:r.title,description:r.description,background:r.background,theme:l,innerTransform:`translate(${u.left},${u.top})`,legend:w,idPrefix:r._idPrefix}))}function zi(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const $i=new Set(["tree","cluster","treemap","circlepack","partition"]);function Ri(r){const n=wi(r.theme),s=r.chartType||"force",a=r.size||[500,500],c=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),r.margin),l=a[0]-c.left-c.right,h=a[1]-c.top-c.bottom,u=function(t){return ti[t]}(s);if(!u)throw Error(`No layout plugin found for chart type: "${s}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const d={chartType:s,nodeIDAccessor:r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,valueAccessor:r.valueAccessor,childrenAccessor:r.childrenAccessor,hierarchySum:r.hierarchySum,orientation:r.orientation,nodeAlign:r.nodeAlign,nodePaddingRatio:r.nodePaddingRatio,nodeWidth:r.nodeWidth,iterations:r.iterations,forceStrength:r.forceStrength,padAngle:r.padAngle,groupWidth:r.groupWidth,sortGroups:r.sortGroups,edgeSort:r.edgeSort,treeOrientation:r.treeOrientation,edgeType:r.edgeType,padding:r.padding,paddingTop:r.paddingTop,nodeStyle:r.nodeStyle,edgeStyle:r.edgeStyle,nodeLabel:r.nodeLabel,showLabels:r.showLabels,colorBy:r.colorBy,colorScheme:r.colorScheme||n.colors.categorical,edgeColorBy:r.edgeColorBy,edgeOpacity:r.edgeOpacity,colorByDepth:r.colorByDepth,nodeSize:r.nodeSize,nodeSizeRange:r.nodeSizeRange};let f,g;if($i.has(s)){const t=r.data||r.edges;if(!t||Array.isArray(t))return o.renderToStaticMarkup(ji(null,{width:a[0],height:a[1],className:"stream-network-frame"+(r.className?" "+r.className:""),title:r.title,description:r.description,background:r.background,theme:n,innerTransform:`translate(${c.left},${c.top})`,idPrefix:r._idPrefix}));d.__hierarchyRoot=t,f=[],g=[]}else{const t=r.nodes||[],e=Array.isArray(r.edges)?r.edges:[];if(0===t.length&&0===e.length)return o.renderToStaticMarkup(ji(null,{width:a[0],height:a[1],className:"stream-network-frame"+(r.className?" "+r.className:""),title:r.title,description:r.description,background:r.background,theme:n,innerTransform:`translate(${c.left},${c.top})`,idPrefix:r._idPrefix}));if(g=function(t,e){const i=zi(e.sourceAccessor,"source"),o=zi(e.targetAccessor,"target"),r=zi(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}))}(e,d),0===t.length&&g.length>0){const t=new Set;for(const e of g){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)}f=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 f=function(t,e){const i=zi(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,d)}u.computeLayout(f,g,d,[l,h]);const{sceneNodes:y,sceneEdges:p,labels:m}=u.buildScene(f,g,d,[l,h]),v=Si(n);for(const t of m)t.fill||(t.fill=v.text);const x=p.map((e,i)=>function(e,i){switch(e.type){case"line":return t("line",{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},"net-edge-"+i);case"bezier":{const o=e;return t("path",{d:o.pathD,fill:gi(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+i)}case"ribbon":{const o=e;return t("path",{d:o.pathD,fill:gi(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+i)}case"curved":{const o=e;return t("path",{d:o.pathD,fill:gi(o.style.fill,"none"),stroke:o.style.stroke||"#999",strokeWidth:o.style.strokeWidth||1,opacity:o.style.opacity},"net-edge-"+i)}default:return null}}(e,i)).filter(Boolean),b=y.map((e,i)=>function(e,i){switch(e.type){case"circle":{const o=e;return t("circle",{cx:o.cx,cy:o.cy,r:o.r,fill:gi(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-circle-"+i)}case"rect":{const o=e;return t("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:gi(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-rect-"+i)}case"arc":{const o=e,r=F().innerRadius(o.innerR).outerRadius(o.outerR).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2)({})||"";return t("path",{d:r,transform:`translate(${o.cx},${o.cy})`,fill:gi(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-arc-"+i)}default:return null}}(e,i)).filter(Boolean),k=m.map((e,i)=>function(e,i){return t("text",{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,children:e.text},"net-label-"+i)}(e,i)).filter(Boolean),A=e(i,{children:[x,b,k]});return o.renderToStaticMarkup(ji(A,{width:a[0],height:a[1],className:"stream-network-frame"+(r.className?" "+r.className:""),title:r.title,description:r.description,background:r.background,theme:n,innerTransform:`translate(${c.left},${c.top})`,idPrefix:r._idPrefix}))}function Ci(r){var n,s,a,c,l;const h=wi(r.theme),u=r.size||[500,400],d=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),r.margin),f=r.legendPosition;r.showLegend&&(f&&"right"!==f?"left"===f?d.left=Math.max(d.left,100):"bottom"===f?d.bottom=Math.max(d.bottom,70):"top"===f&&(d.top=Math.max(d.top,40)):d.right=Math.max(d.right,100));const g=u[0]-d.left-d.right,y=u[1]-d.top-d.bottom,p=r.projection||"vertical",m="radial"===p,v={chartType:r.chartType,windowSize:null!==(n=r.windowSize)&&void 0!==n?n:1e4,windowMode:null!==(s=r.windowMode)&&void 0!==s?s:"sliding",extentPadding:null!==(a=r.extentPadding)&&void 0!==a?a:.05,projection:p,oAccessor:r.oAccessor,rAccessor:r.rAccessor,colorAccessor:r.colorAccessor,stackBy:r.stackBy,groupBy:r.groupBy,categoryAccessor:r.categoryAccessor,valueAccessor:r.valueAccessor,timeAccessor:r.timeAccessor,rExtent:r.rExtent,oExtent:r.oExtent,barPadding:r.barPadding,roundedTop:r.roundedTop,innerRadius:r.innerRadius,cornerRadius:r.cornerRadius,normalize:r.normalize,startAngle:r.startAngle,sweepAngle:r.sweepAngle,bins:r.bins,showOutliers:r.showOutliers,showIQR:r.showIQR,amplitude:r.amplitude,oSort:r.oSort,connectorAccessor:r.connectorAccessor,connectorStyle:r.connectorStyle,dynamicColumnWidth:r.dynamicColumnWidth,pieceStyle:r.pieceStyle,summaryStyle:r.summaryStyle,colorScheme:r.colorScheme||h.colors.categorical,barColors:r.barColors},x=new ri(v);if(r.data&&x.ingest({inserts:r.data,bounded:!0}),x.computeScene({width:g,height:y}),!x.scales||0===x.scene.length)return o.renderToStaticMarkup(ji(null,{width:u[0],height:u[1],className:"stream-ordinal-frame"+(r.className?" "+r.className:""),title:r.title,description:r.description,background:r.background,theme:h,innerTransform:`translate(${d.left},${d.top})`,idPrefix:r._idPrefix}));const b=r._idPrefix,k=r.showGrid?function(e,i,o,r){const n=e.scales;if(!n||"radial"===n.projection)return null;const{grid:s}=Si(o),a=r?r+"-":"",c="vertical"===n.projection,l=n.r.ticks(5);return t("g",c?{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,o)=>{const r=n.r(e);return t("line",{x1:0,y1:r,x2:i.width,y2:r,stroke:s,strokeWidth:.5},"gr-"+o)})}:{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,o)=>{const r=n.r(e);return t("line",{x1:r,y1:0,x2:r,y2:i.height,stroke:s,strokeWidth:.5},"gr-"+o)})})}(x,{width:g,height:y},h,b):null,A=x.scene.some(t=>{var e;return"rect"===t.type&&(null===(e=t.datum)||void 0===e?void 0:e.__barFunnelIsDropoff)});let w=null;if(A){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)}(r),o=new Set;for(const t of x.scene)"rect"===t.type&&(null===(c=t.datum)||void 0===c?void 0:c.__barFunnelIsDropoff)&&o.add("string"==typeof t.style.fill?t.style.fill:"#666");w=Array.from(o).map((o,r)=>function(i){const{id:o,background:r="transparent",stroke:n="#000",lineWidth:s=1.5,spacing:a=6,angle:c=45}=i,l=Math.max(8,Math.ceil(2*a));return e("pattern",{id:o,width:l,height:l,patternUnits:"userSpaceOnUse",patternTransform:0!==c?`rotate(${c})`:void 0,children:[r&&"transparent"!==r&&t("rect",{width:l,height:l,fill:r}),t("line",{x1:0,y1:0,x2:0,y2:l,stroke:n,strokeWidth:s}),t("line",{x1:a,y1:0,x2:a,y2:l,stroke:n,strokeWidth:s})]},o)}({id:`funnel-hatch-${i}-${r}`,background:o,stroke:"transparent"===h.colors.background?"#fff":h.colors.background,lineWidth:1.5,spacing:5,angle:45}));const n=new Map;Array.from(o).forEach((t,e)=>n.set(t,`funnel-hatch-${i}-${e}`));for(const t of x.scene)if("rect"===t.type&&(null===(l=t.datum)||void 0===l?void 0:l.__barFunnelIsDropoff)){const e="string"==typeof t.style.fill?t.style.fill:"#666";t.style=Object.assign(Object.assign({},t.style),{fill:`url(#${n.get(e)})`})}}const S=x.scene.map((t,e)=>pi(t,e)).filter(Boolean),_=!1!==r.showAxes?function(i,o,r,n,s){var a,c,l,h,u,d,f,g;const y=i.scales;if(!y)return null;if("radial"===y.projection)return null;const p=Si(n),m="vertical"===y.projection,v=r.categoryFormat||r.oFormat,x=r.valueFormat||r.rFormat,b=r.categoryLabel||r.oLabel,k=r.valueLabel||r.rLabel,A=Object.values(i.columns).map(t=>({pixel:t.middle,label:(v||String)(t.name)})),w=y.r.ticks(5).map(t=>({pixel:y.r(t),label:(x||Li)(t)}));return e("g",m?{id:(s?s+"-":"")+"axes",className:"ordinal-axes",children:[t("line",{x1:0,y1:o.height,x2:o.width,y2:o.height,stroke:p.border,strokeWidth:1}),A.map((i,r)=>e("g",{transform:`translate(${i.pixel},${o.height})`,children:[t("line",{y2:5,stroke:p.border,strokeWidth:1}),t("text",{y:18,textAnchor:"middle",fontSize:p.tickSize,fill:p.textSecondary,fontFamily:p.fontFamily,children:i.label})]},"oxtick-"+r)),b&&t("text",{x:o.width/2,y:o.height+40,textAnchor:"middle",fontSize:p.labelSize,fill:p.text,fontFamily:p.fontFamily,children:b}),t("line",{x1:0,y1:0,x2:0,y2:o.height,stroke:p.border,strokeWidth:1}),w.map((i,o)=>e("g",{transform:`translate(0,${i.pixel})`,children:[t("line",{x2:-5,stroke:p.border,strokeWidth:1}),t("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:p.tickSize,fill:p.textSecondary,fontFamily:p.fontFamily,children:i.label})]},"oytick-"+o)),k&&t("text",{x:15-(null!==(c=null===(a=r.margin)||void 0===a?void 0:a.left)&&void 0!==c?c:40),y:o.height/2,textAnchor:"middle",fontSize:p.labelSize,fill:p.text,fontFamily:p.fontFamily,transform:`rotate(-90, ${15-(null!==(h=null===(l=r.margin)||void 0===l?void 0:l.left)&&void 0!==h?h:40)}, ${o.height/2})`,children:k})]}:{id:(s?s+"-":"")+"axes",className:"ordinal-axes",children:[t("line",{x1:0,y1:o.height,x2:o.width,y2:o.height,stroke:p.border,strokeWidth:1}),w.map((i,r)=>e("g",{transform:`translate(${i.pixel},${o.height})`,children:[t("line",{y2:5,stroke:p.border,strokeWidth:1}),t("text",{y:18,textAnchor:"middle",fontSize:p.tickSize,fill:p.textSecondary,fontFamily:p.fontFamily,children:i.label})]},"oxtick-"+r)),k&&t("text",{x:o.width/2,y:o.height+40,textAnchor:"middle",fontSize:p.labelSize,fill:p.text,fontFamily:p.fontFamily,children:k}),t("line",{x1:0,y1:0,x2:0,y2:o.height,stroke:p.border,strokeWidth:1}),A.map((i,o)=>e("g",{transform:`translate(0,${i.pixel})`,children:[t("line",{x2:-5,stroke:p.border,strokeWidth:1}),t("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:p.tickSize,fill:p.textSecondary,fontFamily:p.fontFamily,children:i.label})]},"oytick-"+o)),b&&t("text",{x:15-(null!==(d=null===(u=r.margin)||void 0===u?void 0:u.left)&&void 0!==d?d:40),y:o.height/2,textAnchor:"middle",fontSize:p.labelSize,fill:p.text,fontFamily:p.fontFamily,transform:`rotate(-90, ${15-(null!==(g=null===(f=r.margin)||void 0===f?void 0:f.left)&&void 0!==g?g:40)}, ${o.height/2})`,children:b})]})}(x,{width:g,height:y},r,h,b):null,P=r.annotations?Oi({annotations:r.annotations,scales:{r:x.scales.r,y:"vertical"===x.scales.projection?x.scales.r:void 0},layout:{width:g,height:y},theme:h,projection:p,idPrefix:b}):null,M=r.showLegend?(()=>{const t=Pi(r.data||[],r.colorAccessor||r.stackBy||r.groupBy);return 0===t.length?null:_i({categories:t,colorScheme:r.colorScheme,theme:h,position:r.legendPosition||"right",totalWidth:u[0],totalHeight:u[1],margin:d,hasTitle:!!r.title})})():null,O=m?d.left+g/2:d.left,T=m?d.top+y/2:d.top,E=e(i,{children:[k,P,S,_]});return o.renderToStaticMarkup(ji(E,{width:u[0],height:u[1],className:"stream-ordinal-frame"+(r.className?" "+r.className:""),title:r.title,description:r.description,background:r.background,theme:h,innerTransform:`translate(${O},${T})`,legend:M,defs:w,idPrefix:r._idPrefix}))}function Ni(e){var r,n,s,a,c,l,h,u;const d=wi(e.theme),f=e.size||[e.width||600,e.height||400],g=Object.assign(Object.assign({},{top:10,right:10,bottom:10,left:10}),e.margin),y=f[0]-(null!==(r=g.left)&&void 0!==r?r:0)-(null!==(n=g.right)&&void 0!==n?n:0),p=f[1]-(null!==(s=g.top)&&void 0!==s?s:0)-(null!==(a=g.bottom)&&void 0!==a?a:0),m=new fi({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.`);m.setAreas(e.areas)}if(e.points&&m.setPoints(e.points),e.lines&&m.setLines(e.lines),m.computeScene({width:y,height:p}),0===m.scene.length)return o.renderToStaticMarkup(ji(null,{width:f[0],height:f[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:d,innerTransform:`translate(${null!==(c=g.left)&&void 0!==c?c:0},${null!==(l=g.top)&&void 0!==l?l:0})`,idPrefix:e._idPrefix}));const v=m.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("path",{d:n.pathData,fill:gi(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},"geoarea-"+i):null}case"point":{const o=e;return t("circle",{cx:o.x,cy:o.y,r:o.r,fill:gi(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},"point-"+i)}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("path",{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},"line-"+i)}default:return null}}(e,i)).filter(Boolean),x=t(i,{children:v});return o.renderToStaticMarkup(ji(x,{width:f[0],height:f[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:d,innerTransform:`translate(${null!==(h=g.left)&&void 0!==h?h:0},${null!==(u=g.top)&&void 0!==u?u:0})`,idPrefix:e._idPrefix}))}function Wi(t,e){switch(t){case"xy":return Di(e);case"ordinal":return Ci(e);case"network":return Ri(e);case"geo":return Ni(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", or "geo".`)}}function Bi(t){return Di(t)}function Fi(t){return Ci(t)}function Yi(t){return Ri(t)}function Ii(t){return Ni(t)}function Xi(r,n,s){var a;const{data:c,width:l=600,height:h=400,theme:u,title:d,description:f,showLegend:g,showGrid:y,background:p,className:m,annotations:v,margin:x,colorScheme:b,colorBy:k,legendPosition:A}=n,w=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}(n,["data","width","height","theme","title","description","showLegend","showGrid","background","className","annotations","margin","colorScheme","colorBy","legendPosition"]),S=[l,h],_=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},w.frameProps||{}),{theme:u,title:d,description:f,showLegend:g,showGrid:y,background:p,className:m,annotations:v,size:S}),void 0!==x&&{margin:x}),void 0!==b&&{colorScheme:b}),void 0!==A&&{legendPosition:A}),{_idPrefix:w._idPrefix}),P=Ei[r];if(!P)throw Error(`Unknown chart component: "${r}". See CLAUDE.md for supported chart types.`);const M=P.buildProps(c,k,b,_,w);let O=(0,{xy:Di,ordinal:Ci,network:Ri,geo:Ni}[P.frameType])(M);if("GaugeChart"===r&&M.__gauge){const r=M.__gauge,n=_.margin||{top:20,right:20,bottom:30,left:40},s=(l||300)-n.left-n.right,c=(h||300)-n.top-n.bottom,d=Math.min(s,c)/2*.85,f=n.left+s/2,g=n.top+c/2,y=Math.max(r.gMin,Math.min(r.gMax,null!==(a=r.value)&&void 0!==a?a:r.gMin)),p=(r.startAngleDeg+(r.gMax===r.gMin?0:(y-r.gMin)/(r.gMax-r.gMin))*r.sweep-90)*Math.PI/180,m=wi(u).colors.text,v=o.renderToStaticMarkup(e(i,{children:[t("line",{x1:f,y1:g,x2:f+d*Math.cos(p),y2:g+d*Math.sin(p),stroke:m,strokeWidth:2.5,strokeLinecap:"round"}),t("circle",{cx:f,cy:g,r:4,fill:m})]}));O=O.replace("</svg>",v+"</svg>")}return O}function qi(t,e){return ft(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):Xi(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 h=e.width||(null===(o=e.size)||void 0===o?void 0:o[0])||600,u=e.height||(null===(r=e.size)||void 0===r?void 0:r[1])||400,d=l(void 0!==globalThis.Buffer?globalThis.Buffer.from(c):(new TextEncoder).encode(c),{density:72*s}).resize(Math.round(h*s),Math.round(u*s));return"jpeg"===n?d.jpeg({quality:90}).toBuffer():d.png().toBuffer()})}function Gi(i,r={}){var n;const{title:s,subtitle:a,theme:c,width:l=1200,height:h,layout:u={},background:d}=r,f=Si(wi(c)),g=u.columns||2,y=null!==(n=u.gap)&&void 0!==n?n:16;let p=0;s&&(p+=30),a&&(p+=20),p>0&&(p+=10);const m=Math.floor((l-y-y*(g-1))/g),v=[];let x=0,b=p+y,k=0;for(const t of i){const e=Math.min(t.colSpan||1,g),i=t.props.height||300;x+e>g&&(b+=k+y,x=0,k=0),v.push({chart:t,x:y/2+x*(m+y),y:b,w:m*e+y*(e-1),h:i}),k=Math.max(k,i),x+=e}const A=h||b+k+y,w=v.map((e,i)=>{const{chart:o,x:r,y:n,w:s,h:a}=e,l=Object.assign(Object.assign({},o.props),{width:s,height:a,theme:c,_idPrefix:"chart-"+i});let h;return h=o.component?Xi(o.component,l):o.frameType?Wi(o.frameType,l):`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${a}"></svg>`,t("g",{transform:`translate(${r},${n})`,children:t("foreignObject",{width:s,height:a,children:t("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:h}})})},"dashboard-chart-"+i)}),S=e("svg",{xmlns:"http://www.w3.org/2000/svg",width:l,height:A,role:"img","aria-label":s||"Dashboard",style:{fontFamily:f.fontFamily},children:[s&&t("title",{children:s}),d&&t("rect",{x:0,y:0,width:l,height:A,fill:d}),s&&t("text",{x:l/2,y:24,textAnchor:"middle",fontSize:f.titleSize+4,fontWeight:"bold",fill:f.text,fontFamily:f.fontFamily,children:s}),a&&t("text",{x:l/2,y:s?46:20,textAnchor:"middle",fontSize:f.labelSize,fill:f.textSecondary,fontFamily:f.fontFamily,children:a}),w]});return o.renderToStaticMarkup(S)}function Vi(t,e,i,o={}){const{stepSize:r,windowSize:n,frameCount:s,xExtent:a,yExtent:c,transitionFrames:l=4,fps:h=12,easing:u="ease-out",decay:d}=o,f=i.width||600,g=i.height||400,y=wi(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))))),v=[];for(let t=m;e.length>=t;t+=m)v.push(t);v[v.length-1]!==e.length&&v.push(e.length);const x=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=f-b.left-b.right,A=g-b.top-b.bottom,w=[];if(x)for(let o=0;v.length>o;o++){const r=v[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},d&&{decay:d}),c=new ri(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:k,height:A}),c.scene.length>0&&w.push(Ui(c.scene,f,g,y,p))}else for(let o=0;v.length>o;o++){const r=v[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},d&&{decay:d}),l>0&&{transition:{duration:l*(1e3/h),easing:u}}),x=new Yt(m);if(x.ingest({inserts:s,bounded:!0}),x.computeScene({width:k,height:A}),0===x.scene.length)continue;const b=x.scales?{y:x.scales.y}:void 0;if(w.push(Zi(x.scene,f,g,y,p,b)),l>0&&o>0&&x.activeTransition){const t=l*(1e3/h);for(let e=1;l>=e;e++)x.advanceTransition(x.activeTransition.startTime+e/l*t),w.push(Zi(x.scene,f,g,y,p,b))}}return w}function Hi(t,e,i={}){return e.map(e=>{try{return Xi(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 Qi(t,e){const i=t.background||e.colors.background;return i&&"transparent"!==i?i:null}function Zi(r,n,s,a,c,l){const h=Si(a),u=Object.assign({top:20,right:20,bottom:30,left:40},c.margin),d=n-u.left-u.right,f=s-u.top-u.bottom,g=Qi(c,a),y=r.map((t,e)=>yi(t,e)).filter(Boolean),p=function(o,r,n,s,a,c){var l;if(!o||0===o.length)return null;const h=Si(s),u=[];for(let i=0;o.length>i;i++){const s=o[i];if("y-threshold"===s.type&&null!=s.value){let o=null;if(c)o=c(s.value);else if(a){const[t,e]=a,i=e-t;if(0===i)continue;o=n-(s.value-t)/i*n}if(null==o)continue;const d=s.color||h.primary,f=null!==(l=s.strokeWidth)&&void 0!==l?l:1.5,g=s.labelPosition||"right";u.push(e("g",{children:[t("line",{x1:0,y1:o,x2:r,y2:o,stroke:d,strokeWidth:f,strokeDasharray:s.strokeDasharray||"6,4"}),s.label&&t("text",{x:"left"===g?4:"center"===g?r/2:r-4,y:o-5,textAnchor:"left"===g?"start":"center"===g?"middle":"end",fontSize:h.tickSize,fill:d,fontFamily:h.fontFamily,children:s.label})]},"ann-"+i))}}return u.length>0?t(i,{children:u}):null}(c.annotations,d,f,a,c.yExtent,null==l?void 0:l.y),m="string"==typeof c.title?c.title:void 0,v="string"==typeof c.description?c.description:void 0,x=m?"semiotic-title":void 0,b=v?"semiotic-desc":void 0,k=[x,b].filter(Boolean).join(" ")||void 0,A=e("svg",{xmlns:"http://www.w3.org/2000/svg",width:n,height:s,role:"img","aria-labelledby":k,style:{fontFamily:h.fontFamily},children:[m&&t("title",{id:x,children:m}),v&&t("desc",{id:b,children:v}),g&&t("rect",{x:0,y:0,width:n,height:s,fill:g}),e("g",{transform:`translate(${u.left},${u.top})`,children:[p,y]}),m&&t("text",{x:n/2,y:16,textAnchor:"middle",fontSize:h.titleSize,fontWeight:"bold",fill:h.text,fontFamily:h.fontFamily,children:m})]});return o.renderToStaticMarkup(A)}function Ui(i,r,n,s,a){const c=Si(s),l=Object.assign({top:20,right:20,bottom:30,left:40},a.margin),h="radial"===a.projection,u=h?l.left+(r-l.left-l.right)/2:l.left,d=h?l.top+(n-l.top-l.bottom)/2:l.top,f=Qi(a,s),g=i.map((t,e)=>pi(t,e)).filter(Boolean),y="string"==typeof a.title?a.title:void 0,p="string"==typeof a.description?a.description:void 0,m=y?"semiotic-title":void 0,v=p?"semiotic-desc":void 0,x=[m,v].filter(Boolean).join(" ")||void 0,b=e("svg",{xmlns:"http://www.w3.org/2000/svg",width:r,height:n,role:"img","aria-labelledby":x,style:{fontFamily:c.fontFamily},children:[y&&t("title",{id:m,children:y}),p&&t("desc",{id:v,children:p}),f&&t("rect",{x:0,y:0,width:r,height:n,fill:f}),t("g",{transform:`translate(${u},${d})`,children:g}),y&&t("text",{x:r/2,y:16,textAnchor:"middle",fontSize:c.titleSize,fontWeight:"bold",fill:c.text,fontFamily:c.fontFamily,children:y})]});return o.renderToStaticMarkup(b)}function Ki(t,e,i){return ft(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),h=Math.round(c*s),u=Vi(t,e,a?Object.assign(Object.assign({},i),{background:a}):i,o);if(0===u.length)throw Error("No frames generated — check that data is not empty");let d,f,g,y;try{d=require("sharp")}catch(t){throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t=require("gifenc");f=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=f();for(let t=0;u.length>t;t++){const e=u[t],i=yield d(Buffer.from(e),{density:72*s}).resize(l,h).ensureAlpha().raw().toBuffer(),o=new Uint8Array(i),r=g(o,256),a=y(o,r);m.writeFrame(a,l,h,{palette:r,delay:p,repeat:n?0:-1})}return m.finish(),Buffer.from(m.bytes())})}export{Vi as generateFrameSVGs,Hi as generateFrameSequence,Xi as renderChart,Gi as renderDashboard,Ii as renderGeoToStaticSVG,Yi as renderNetworkToStaticSVG,Fi as renderOrdinalToStaticSVG,Ki as renderToAnimatedGif,qi as renderToImage,Wi as renderToStaticSVG,Bi as renderXYToStaticSVG,wi as resolveTheme,Si as themeStyles};
1
+ import{jsx as t,jsxs as e,Fragment as i}from"react/jsx-runtime";import*as o from"react-dom/server";import{scaleOrdinal as r,scaleLinear as n,scaleLog as s,scaleTime as a,scaleBand as c}from"d3-scale";import{quadtree as l}from"d3-quadtree";import{interpolatePlasma as h,interpolateViridis as u,interpolatePurples as d,interpolateOranges as f,interpolateGreens as g,interpolateReds as y,interpolateBlues as p,schemeSet3 as m,schemeTableau10 as v,schemeCategory10 as x,interpolateTurbo as b,interpolateCividis as k,interpolateMagma as A,interpolateInferno as w,interpolateGreys as S}from"d3-scale-chromatic";import{min as _,groups as P,max as M,sum as O,mean as T,group as E,quantile as L}from"d3-array";import{interpolateNumber as D}from"d3-interpolate";import{forceLink as j,forceSimulation as z,forceManyBody as $,forceCenter as R,forceX as C,forceY as N}from"d3-force";import{ribbon as W,chord as B}from"d3-chord";import{arc as F,pie as Y}from"d3-shape";import{hierarchy as I,partition as X,pack as q,treemap as G,treemapBinary as V,cluster as H,tree as Q}from"d3-hierarchy";import{geoPath as Z,geoGraticule as U,geoDistance as K,geoInterpolate as J,geoEqualEarth as tt,geoEquirectangular as et,geoNaturalEarth1 as it,geoOrthographic as ot,geoAlbersUsa as rt,geoMercator as nt}from"d3-geo";import*as st from"react";import{createContext as at,useMemo as ct,useContext as lt,useRef as ht,useCallback as ut,useSyncExternalStore as dt}from"react";function ft(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 gt{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;return{next:()=>this._size>t?{done:!1,value:this.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 yt{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 pt(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 mt(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function vt(t,e){if("function"==typeof t)return e=>+t(e);const i=t||e;return t=>+t[i]}function xt(t,e){if("function"==typeof t)return t;const i=t||e;return t=>t[i]}function bt(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}const kt={category10:x,tableau10:v,set3:m,blues:p,reds:y,greens:g,oranges:f,purples:d,viridis:u,plasma:h},At=x,wt=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],St=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function _t(t,e,i="category10"){const o=Array.from(new Set(t.map(t=>null==t?void 0:t[e]).filter(t=>null!=t))),n=o.every(t=>"number"==typeof t||!isNaN(Number(t)));if(Array.isArray(i))return r().domain(o).range(i).unknown("#999");const s=kt[i]||kt.category10;if(n&&"function"==typeof s){let t=-1/0;for(const e of o){const i=Number(e);i>t&&(t=i)}return e=>s(Number(e)/t)}{const t=Array.isArray(s)?s:At;return r().domain(o).range(t).unknown("#999")}}function Pt(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 Mt(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 Ot(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function Tt(t,e){return Math.min((t-e.startTime)/e.duration,1)}function Et(t,e,i){return t+(e-t)*i}function Lt(){return"undefined"!=typeof performance?performance.now():Date.now()}function Dt(t,e,i){var o,r,n,s;if(e._transitionKey)return e._transitionKey;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 jt(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 zt(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),h=a?a(n):r;c.push({px:l,topY:e.y(s),botY:e.y(h)})}c.sort((t,e)=>t.px-e.px);const l=Array(c.length),h=Array(c.length);for(let t=0;c.length>t;t++){const e=c[t];l[t]=[e.px,e.topY],h[t]=[e.px,e.botY]}return{type:"area",topPath:l,bottomPath:h,style:n,datum:t,group:s}}function $t(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 Rt(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 Ct(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 Nt(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 Wt(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=$t(s,t.scales,t.getX,n,a,o,c);l&&i.push(l)}}}const Bt={blues:p,reds:y,greens:g,viridis:u,oranges:f,purples:d,greys:S,plasma:h,inferno:w,magma:A,cividis:k,turbo:b},Ft=new Map;class Yt{constructor(t){if(this.xExtent=new yt,this.yExtent=new yt,this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,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._maxPointRadius=0,this.config=t,this.buffer=new gt(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=vt(t.timeAccessor||t.xAccessor,"time"),this.getY=vt(t.valueAccessor||t.yAccessor,"value")):(this.getX=vt(t.xAccessor,"x"),this.getY=vt(t.yAccessor,"y")),this.getGroup=bt(t.groupAccessor),this.getCategory=bt(t.categoryAccessor),this.getSize=t.sizeAccessor?vt(t.sizeAccessor,"size"):void 0,this.getColor=bt(t.colorAccessor),this.getBounds=t.boundsAccessor?vt(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?vt(t.y0Accessor,"y0"):void 0,this.getPointId=bt(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,i=null!=t.closeAccessor;this.getOpen=e?vt(t.openAccessor,"open"):void 0,this.getHigh=vt(t.highAccessor,"high"),this.getLow=vt(t.lowAccessor,"low"),this.getClose=i?vt(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!i}t.pulse&&(this.timestampBuffer=new gt(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?vt(this.config.timeAccessor||this.config.xAccessor,"time"):vt(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,c,l,h;const{config:u,buffer:d}=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(d,this.getX),this.yExtent.dirty)if("candlestick"===u.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of d)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(d,this.getY);const f=this.getBufferArray(),g=this.xExtent.extent,y=this.yExtent.extent;let p=u.xExtent?[null!==(i=u.xExtent[0])&&void 0!==i?i:g[0],null!==(o=u.xExtent[1])&&void 0!==o?o:g[1]]:g,m=u.yExtent?[null!==(r=u.yExtent[0])&&void 0!==r?r:y[0],null!==(c=u.yExtent[1])&&void 0!==c?c:y[1]]:y;const v=u.yExtent&&null!=u.yExtent[0]&&null!=u.yExtent[1];if("stackedarea"===u.chartType&&!v&&d.size>0)if(u.normalize)m=[0,1+u.extentPadding];else{const t=`${d.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)m=this._stackExtentCache.yDomain;else{const e=this.groupData(f),i=new Map;let o=0;for(const t of e)for(const e of t.data){const t=this.getX(e),r=this.getY(e);if(null==t||null==r||Number.isNaN(t)||Number.isNaN(r))continue;const n=(i.get(t)||0)+r;i.set(t,n),n>o&&(o=n)}m=[0,o+(o>0?o*u.extentPadding:1)],this._stackExtentCache={key:t,yDomain:m}}}else if("bar"===u.chartType&&u.binSize&&!v&&d.size>0){const[,t]=function(t,e,i,o,r){const n=pt(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]}(d,this.getX,this.getY,u.binSize,this.getCategory);m=[0,t+t*u.extentPadding]}else if("waterfall"===u.chartType&&!v&&d.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]}(d,this.getY),i=e-t,o=i>0?i*u.extentPadding:1;m=[Math.min(0,t-Math.abs(o)),Math.max(0,e+Math.abs(o))]}else if(!v&&m[0]!==1/0){if(this.getBounds)for(const t of f){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*u.extentPadding:1,i=null===(l=u.yExtent)||void 0===l?void 0:l[0],o=null===(h=u.yExtent)||void 0===h?void 0:h[1];m=[null!=i?m[0]:m[0]-e,null!=o?m[1]:m[1]+e],"log"===u.yScaleType&&0>=m[0]&&y[0]>0&&(m[0]=null!=i?m[0]:y[0]/(1+u.extentPadding))}if(p[0]===1/0||p[1]===-1/0)if("time"===u.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 x="streaming"===u.runtimeMode,b=Math.max(0,Math.min(u.scalePadding||0,Math.min(t.width,t.height)/2-1));if(x)if("x"==("up"===(k=u.arrowOfTime)||"down"===k?"y":"x")){const e="right"===u.arrowOfTime?[b,t.width-b]:[t.width-b,b];this.scales={x:n().domain(p).range(e),y:n().domain(m).range([t.height-b,b])}}else{const e="down"===u.arrowOfTime?[b,t.height-b]:[t.height-b,b];this.scales={x:n().domain(m).range([b,t.width-b]),y:n().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 s().domain(t).range(i).clamp(!0)}return"time"===t?a().domain([new Date(e[0]),new Date(e[1])]).range(i):n().domain(e).range(i)};this.scales={x:e(u.xScaleType,p,[b,t.width-b]),y:e(u.yScaleType,m,[t.height-b,b])}}var k;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,f),this.config.decay&&this.applyDecay(this.scene,f),this.config.pulse&&this.applyPulse(this.scene,f),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),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 this._quadtree=null,void(this._maxPointRadius=0);let e=0,i=0;for(const t of this.scene)"point"===t.type&&(e++,t.r>i&&(i=t.r));if(this._maxPointRadius=i,Yt.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const o=Array(e);let r=0;for(const t of this.scene)"point"===t.type&&(o[r++]=t);this._quadtree=l().x(t=>t.x).y(t=>t.y).addAll(o)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}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(),c=this.scales.x.range(),l=this.scales.y.range(),h=(t,e,i)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return s().domain(t).range(i).clamp(!0)}return"time"===t?a().domain([new Date(e[0]),new Date(e[1])]).range(i):n().domain(e).range(i)},u=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),d=l[1]>l[0];this.scales={x:h(this.config.xScaleType,o,c[0]>c[1]?[t.width-u,u]:[u,t.width-u]),y:h(this.config.yScaleType,r,d?[u,t.height-u]:[t.height-u,u])},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=Nt(t,e.data,e.key);i&&r.push(i)}for(const e of o){const i=t.resolveLineStyle(e.key,e.data[0]),o=jt(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 Wt(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=zt(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 Wt(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=zt(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=jt(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 Wt(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),h=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)}h.set(e.key,t)}let u;if(n){u=new Map;for(const e of l){let i=0;for(const o of t)i+=(null===(a=h.get(o.key))||void 0===a?void 0:a.get(e))||0;u.set(e,i||1)}}const d=[],f=new Map,g=new Map;for(const t of l)g.set(t,0);for(const i of t){const t=h.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/=u.get(i));const l=s+r,h=e.x(i);a.push([h,e.y(s)]),o.push([h,e.y(l)]),g.set(i,l),c.set(i,l)}f.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),d.push(y)}return{nodes:d,stackedTops:f}}(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)};Wt(t,i,s,o)}return s}(n,e);case"scatter":case"bubble":return function(t,e){var i;const o=[],r="bubble"===t.config.chartType?10:5,n=t.config.sizeRange||[3,15];let s=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);s=i=>t===e?(n[0]+n[1])/2:n[0]+(i-t)/(e-t)*(n[1]-n[0])}}const a=t.getColor?t.resolveColorMap(e):null,c=(null===(i=t.config.themeSemantic)||void 0===i?void 0:i.primary)||"#4e79a7";for(const i of e){let e=t.config.pointStyle?t.config.pointStyle(i):{fill:c,opacity:.8},n=e.r||r;if(s&&t.getSize){const e=t.getSize(i);null==e||Number.isNaN(e)||(n=s(e))}if(a&&t.getColor&&!e.fill){const o=t.getColor(i);o&&a.has(o)&&(e=Object.assign(Object.assign({},e),{fill:a.get(o)}))}const l=t.getPointId?t.getPointId(i)+"":void 0,h=$t(i,t.scales,t.getX,t.getY,n,e,l);h&&o.push(h)}return o}(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=vt(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[h,u]=t.scales.x.domain(),[d,f]=t.scales.y.domain(),g=(u-h||1)/s,y=(f-d||1)/a,p=s*a;if(p>1e6)return[];const m=new Int32Array(p),v=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-h)/g),s-1),u=Math.min(Math.floor((n-d)/y),a-1);if(0>c||0>u)continue;const f=u*s+c;m[f]++;const p=l(o);v[f]+=isFinite(p)?p:0}let x=1/0,b=-1/0;for(let t=0;p>t;t++){if(0===m[t])continue;let e;switch(c){case"sum":e=v[t];break;case"mean":e=v[t]/m[t];break;default:e=m[t]}x>e&&(x=e),e>b&&(b=e)}if(!isFinite(x))return[];const k=b-x||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=v[o];break;case"mean":r=v[o]/m[o];break;default:r=m[o]}const n=(r-x)/k;P.push(Ct(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:v[o]},S?{value:r,showValues:!0,valueFormat:_}:void 0))}}return P}(t,e,i);if(0===e.length)return[];const o=vt(t.config.valueAccessor,"value"),r=xt(t.config.xAccessor,"x"),n=xt(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),h=n(i);c[t]=o,l[t]=h,s.has(o)||s.set(o,s.size),a.has(h)||a.set(h,a.size)}const h=s.size,u=a.size;if(0===h||0===u)return[];const d=Array.from(s.keys()),f=Array.from(a.keys()),g=d.every(t=>"number"==typeof t&&!isNaN(t)),y=f.every(t=>"number"==typeof t&&!isNaN(t));if(g){d.sort((t,e)=>t-e),s.clear();for(let t=0;d.length>t;t++)s.set(d[t],t)}if(y){f.sort((t,e)=>t-e),a.clear();for(let t=0;f.length>t;t++)a.set(f[t],t)}const m=new Float64Array(e.length),v=new Float64Array(e.length),x=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 u=o(i),d=n*h+r,f=b.get(d);let g;void 0!==f?g=f:(g=k++,b.set(d,g)),m[g]=d,v[g]=u,x[g]=i}let A=1/0,w=-1/0;for(let t=0;k>t;t++){const e=v[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 Bt?t:"blues";let i=Ft.get(e);if(i)return i;i=Array(256);const o=Bt[e]||p;for(let t=0;256>t;t++)i[t]=o(t/255);return Ft.set(e,i),i}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),_=255/(w-A||1),P=i.width/h,M=i.height/u,O=t.config.showValues,T=t.config.heatmapValueFormat,E=[];for(let t=0;k>t;t++){const e=v[t];if(!isFinite(e))continue;const i=m[t],o=i%h;E.push(Ct(o*P,(u-1-(i-o)/h)*M,P,M,S[Math.min((e-A)*_+.5|0,255)],x[t],O?{value:e,showValues:!0,valueFormat:T}:void 0))}return E}(n,e,t);case"bar":{const t=function(t,e){var i,o;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const r=pt(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===r.size)return{nodes:[],binBoundaries:[]};let n=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):[],o=new Set(i),s=Array.from(e).filter(t=>!o.has(t)).sort(),a=i.filter(t=>e.has(t)),c=a.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===c?n=t.barCategoryCache.order:(n=[...a,...s],t.barCategoryCache={key:c,order:n})}const s=[],a=t.scales,[c,l]=a.x.domain(),h=t.config.barStyle,u=null===(i=t.config.themeSemantic)||void 0===i?void 0:i.primary,d=null==h?void 0:h.gap,f="number"!=typeof d||0>d?1:d,g={};(null==h?void 0:h.stroke)&&(g.stroke=h.stroke),"number"==typeof(null==h?void 0:h.strokeWidth)&&(g.strokeWidth=h.strokeWidth),"number"==typeof(null==h?void 0:h.opacity)&&(g.opacity=h.opacity);for(const e of r.values()){const i=Math.max(e.start,c),r=Math.min(e.end,l);if(i>=r)continue;const d=a.x(i),y=a.x(r),p=Math.abs(y-d),m=p>f+1?f:0,v=Math.min(d,y)+m/2,x=Math.max(p-m,1);if(x>0)if(n&&e.categories.size>0){let i=0;for(const r of n){const n=e.categories.get(r)||0;if(0===n)continue;const c=a.y(i),l=a.y(i+n),d=(null===(o=t.config.barColors)||void 0===o?void 0:o[r])||(null==h?void 0:h.fill)||u||"#4e79a7";s.push(Rt(v,Math.min(c,l),x,Math.abs(c-l),Object.assign({fill:d},g),{binStart:e.start,binEnd:e.end,total:e.total,category:r,categoryValue:n},r)),i+=n}}else{const t=a.y(0),i=a.y(e.total);s.push(Rt(v,Math.min(t,i),x,Math.abs(t-i),Object.assign({fill:(null==h?void 0:h.fill)||u||"#007bff"},g),{binStart:e.start,binEnd:e.end,total:e.total}))}}const y=new Set;for(const t of r.values())y.add(t.start),y.add(t.end);return{nodes:s,binBoundaries:Array.from(y).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,s,a;const c=[],l=t.config.swarmStyle||{},h=null!==(i=l.radius)&&void 0!==i?i:3,u=null!==(n=null!==(o=l.fill)&&void 0!==o?o:null===(r=t.config.themeSemantic)||void 0===r?void 0:r.primary)&&void 0!==n?n:"#007bff",d=null!==(s=l.opacity)&&void 0!==s?s:.7,f=l.stroke,g=l.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),n=t.scales.y(o);let s=u;if(t.getCategory){const e=t.getCategory(i);s=(null===(a=t.config.barColors)||void 0===a?void 0:a[e])||s}const l={type:"point",x:r,y:n,r:h,style:{fill:s,opacity:d,stroke:f,strokeWidth:g},datum:i};t.getPointId&&(l.pointId=t.getPointId(i)+""),c.push(l)}return c}(n,e);case"waterfall":return function(t,e,i){var o,r,n,s,a,c,l;const h=[],u=t.scales,d=t.config.waterfallStyle,f=e.filter(e=>{const i=t.getY(e),o=t.getX(e);return null!=i&&!Number.isNaN(i)&&null!=o&&isFinite(o)});if(0===f.length)return h;const g=null!==(n=null!==(o=null==d?void 0:d.positiveColor)&&void 0!==o?o:null===(r=t.config.themeSemantic)||void 0===r?void 0:r.success)&&void 0!==n?n:"#28a745",y=null!==(c=null!==(s=null==d?void 0:d.negativeColor)&&void 0!==s?s:null===(a=t.config.themeSemantic)||void 0===a?void 0:a.danger)&&void 0!==c?c:"#dc3545",p=null!==(l=null==d?void 0:d.gap)&&void 0!==l?l:1,m=null==d?void 0:d.stroke,v=null==d?void 0:d.strokeWidth,x=null==d?void 0:d.opacity;let b=0;for(let e=0;f.length>e;e++){const o=f[e],r=t.getX(o),n=t.getY(o),s=b+n;let a;a=f.length-1>e?t.getX(f[e+1])-r:e>0?r-t.getX(f[e-1]):0;const c=u.x(r),l=0!==a?u.x(r+a):c+i.width/10,k=Math.min(c,l)+p/2,A=Math.max(c,l)-p/2-k;if(0>=A){b=s;continue}const w=u.y(b),S=u.y(s),_=Math.min(w,S),P=Math.abs(w-S),M={fill:0>n?y:g,stroke:m,strokeWidth:v};null!=x&&(M.opacity=x),h.push(Rt(k,_,A,P,M,Object.assign(Object.assign({},o),{baseline:b,cumEnd:s,delta:n,_connectorStroke:null==d?void 0:d.connectorStroke,_connectorWidth:null==d?void 0:d.connectorWidth}))),b=s}return h}(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",h=r?a:s.wickColor||"#333",u=s.wickWidth||(r?2:1),d=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let f=null!==(o=s.bodyWidth)&&void 0!==o?o:0;if(null==s.bodyWidth)if(d.length>1){let e=1/0;for(let i=1;d.length>i;i++){const o=Math.abs(t.scales.x(d[i])-t.scales.x(d[i-1]));o>0&&e>o&&(e=o)}f=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else f=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),d=r?s:t.getClose(i);if(!r&&[a,d].some(t=>null==t||Number.isNaN(t)))continue;const g=d>=a,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(a),closeY:t.scales.y(d),highY:t.scales.y(o),lowY:t.scales.y(s),bodyWidth:f,upColor:c,downColor:l,wickColor:h,wickWidth:u,isUp:g,datum:i};r&&(y.isRange=!0),n.push(y)}return n}(n,e);default:return[]}}resolveBoundsStyle(t,e){var i;const o=this.config.boundsStyle;return"function"==typeof o?o(e||{},t):o&&"object"==typeof o?o:{fill:this.resolveLineStyle(t,e).stroke||(null===(i=this.config.themeSemantic)||void 0===i?void 0:i.primary)||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?Pt(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]=Pt(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]=Pt(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=Pt(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=Pt(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=Mt(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=Mt(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,a;i.clear(),o.clear();for(let c=0;e.length>c;c++){const l=e[c],h=Dt(t,l,c);h&&("point"===l.type?i.set(h,{x:l.x,y:l.y,r:l.r,opacity:l.style.opacity}):"rect"===l.type?i.set(h,{x:l.x,y:l.y,w:l.w,h:l.h,opacity:l.style.opacity}):"heatcell"===l.type?i.set(h,{x:l.x,y:l.y,w:l.w,h:l.h,opacity:null===(r=l.style)||void 0===r?void 0:r.opacity}):"candlestick"===l.type?i.set(h,{x:l.x,y:l.openY,w:l.bodyWidth,openY:l.openY,closeY:l.closeY,highY:l.highY,lowY:l.lowY,opacity:null===(n=l.style)||void 0===n?void 0:n.opacity}):"line"===l.type?o.set(h,{path:l.path.map(t=>[t[0],t[1]]),opacity:null===(s=l.style)||void 0===s?void 0:s.opacity}):"area"===l.type&&o.set(h,{topPath:l.topPath.map(t=>[t[0],t[1]]),bottomPath:l.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(a=l.style)||void 0===a?void 0:a.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){var t,e,i;this.prevPositionMap.clear(),this.prevPathMap.clear();const o=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.y(0))&&void 0!==e?e:0;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],r=Dt(this.transitionContext,e,t);r&&("point"===e.type?this.prevPositionMap.set(r,{x:e.x,y:e.y,r:0,opacity:0}):"rect"===e.type?this.prevPositionMap.set(r,{x:e.x,y:o,w:e.w,h:0,opacity:null!==(i=e.style.opacity)&&void 0!==i?i:1}):"heatcell"===e.type?this.prevPositionMap.set(r,{x:e.x,y:e.y,w:e.w,h:e.h,opacity:0}):"line"===e.type?(e._introClipFraction=0,this.prevPathMap.set(r,{path:e.path.map(t=>[t[0],t[1]]),opacity:e.style.opacity})):"area"===e.type&&(e._introClipFraction=0,this.prevPathMap.set(r,{topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),opacity:e.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,i,o,r){var n,s,a,c,l,h,u,d,f,g,y,p,m,v,x,b,k,A,w,S,_,P,M,O,T,E,L,D,j,z,$,R,C,N,W,B,F,Y,I,X,q;if(0===o.size&&0===r.size)return i;const G=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 V=!1;const H=new Set,Q=new Set;for(let e=0;i.scene.length>e;e++){const n=i.scene[e],E=Dt(t,n,e);if(!E)continue;if(n._transitionKey=E,"line"===n.type||"area"===n.type){const t=r.get(E);if(t){if(Q.add(E),"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]];V=!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]];V=!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}),V=!0;continue}const L=o.get(E);if("point"===n.type)if(L){H.add(E);const t={x:n.x,y:n.y,r:n.r};n._targetOpacity=null!==(h=n.style.opacity)&&void 0!==h?h:1,L.x===t.x&&L.y===t.y&&L.r===t.r||(n._targetX=t.x,n._targetY=t.y,n._targetR=t.r,n.x=L.x,n.y=L.y,n.r=null!==(u=L.r)&&void 0!==u?u:n.r,V=!0)}else n._targetOpacity=null!==(d=n.style.opacity)&&void 0!==d?d:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),V=!0;else if("rect"===n.type)if(L){H.add(E);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=null!==(f=n.style.opacity)&&void 0!==f?f:1,L.x===t.x&&L.y===t.y&&L.w===t.w&&L.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=L.x,n.y=L.y,n.w=null!==(g=L.w)&&void 0!==g?g:n.w,n.h=null!==(y=L.h)&&void 0!==y?y:n.h,V=!0)}else n._targetOpacity=null!==(p=n.style.opacity)&&void 0!==p?p:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),V=!0;else if("heatcell"===n.type)if(L){H.add(E);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=null!==(v=null===(m=n.style)||void 0===m?void 0:m.opacity)&&void 0!==v?v:1,L.x===t.x&&L.y===t.y&&L.w===t.w&&L.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=L.x,n.y=L.y,n.w=null!==(x=L.w)&&void 0!==x?x:n.w,n.h=null!==(b=L.h)&&void 0!==b?b:n.h,V=!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}),V=!0;else if("candlestick"===n.type)if(L&&null!=L.openY){H.add(E);const t={x:n.x,openY:n.openY,closeY:n.closeY,highY:n.highY,lowY:n.lowY};n._targetOpacity=null!==(S=null===(w=n.style)||void 0===w?void 0:w.opacity)&&void 0!==S?S:1,(L.x!==t.x||L.openY!==t.openY||L.closeY!==t.closeY||L.highY!==t.highY||L.lowY!==t.lowY)&&(n._targetX=t.x,n._targetOpenY=t.openY,n._targetCloseY=t.closeY,n._targetHighY=t.highY,n._targetLowY=t.lowY,n.x=L.x,n.openY=L.openY,n.closeY=null!==(_=L.closeY)&&void 0!==_?_:n.closeY,n.highY=null!==(P=L.highY)&&void 0!==P?P:n.highY,n.lowY=null!==(M=L.lowY)&&void 0!==M?M:n.lowY,V=!0)}else n._targetOpacity=null!==(T=null===(O=n.style)||void 0===O?void 0:O.opacity)&&void 0!==T?T:1,n.style=Object.assign(Object.assign({},n.style||{}),{opacity:0}),V=!0}for(const[t,e]of r)if(!Q.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!==(E=e.opacity)&&void 0!==E?E:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),V=!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!==(L=e.opacity)&&void 0!==L?L:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),V=!0}for(const[t,e]of o)if(!H.has(t)){if(t.startsWith("p:")){const o={type:"point",x:e.x,y:e.y,r:null!==(D=e.r)&&void 0!==D?D:3,style:{opacity:null!==(j=e.opacity)&&void 0!==j?j: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!==(z=e.w)&&void 0!==z?z:0,h:null!==($=e.h)&&void 0!==$?$:0,style:{opacity:null!==(R=e.opacity)&&void 0!==R?R: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!==(C=e.w)&&void 0!==C?C:0,h:null!==(N=e.h)&&void 0!==N?N:0,fill:"#999",datum:null,style:{opacity:null!==(W=e.opacity)&&void 0!==W?W:1},_targetOpacity:0,_transitionKey:t};i.exitNodes.push(o)}else if(t.startsWith("c:")){const o=null!==(B=e.openY)&&void 0!==B?B:e.y,r={type:"candlestick",x:e.x,openY:o,closeY:null!==(F=e.closeY)&&void 0!==F?F:o,highY:null!==(Y=e.highY)&&void 0!==Y?Y:o,lowY:null!==(I=e.lowY)&&void 0!==I?I:o,bodyWidth:null!==(X=e.w)&&void 0!==X?X:6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:null!==(q=e.opacity)&&void 0!==q?q:1},_targetOpacity:0,_transitionKey:t};i.exitNodes.push(r)}V=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),V&&(i.activeTransition={startTime:Lt(),duration:G}),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,l;if(!i.activeTransition)return!1;const h=Tt(t,i.activeTransition),u=Ot(h,"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=Et(n,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Et(i.x,t._targetX,u),t.y=Et(i.y,t._targetY,u),void 0!==t._targetR&&void 0!==i.r&&(t.r=Et(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=Et(r,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Et(i.x,t._targetX,u),t.y=Et(i.y,t._targetY,u),void 0!==i.w&&(t.w=Et(i.w,t._targetW,u)),void 0!==i.h&&(t.h=Et(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:Et(r,t._targetOpacity,u)})}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Et(i.x,t._targetX,u),t.y=Et(i.y,t._targetY,u),void 0!==i.w&&(t.w=Et(i.w,t._targetW,u)),void 0!==i.h&&(t.h=Et(i.h,t._targetH,u))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,r=i?null!==(a=i.opacity)&&void 0!==a?a:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:Et(r,t._targetOpacity,u)})}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Et(i.x,t._targetX,u),void 0!==i.openY&&(t.openY=Et(i.openY,t._targetOpenY,u)),void 0!==i.closeY&&(t.closeY=Et(i.closeY,t._targetCloseY,u)),void 0!==i.highY&&(t.highY=Et(i.highY,t._targetHighY,u)),void 0!==i.lowY&&(t.lowY=Et(i.lowY,t._targetLowY,u))}else if("line"===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:Et(e,t._targetOpacity,u)})}void 0!==t._introClipFraction&&(t._introClipFraction=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]=Et(e[o][0],i[o][0],u),t.path[o][1]=Et(e[o][1],i[o][1],u)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(l=t._startOpacity)&&void 0!==l?l:0;t.style=Object.assign(Object.assign({},t.style),{opacity:Et(e,t._targetOpacity,u)})}void 0!==t._introClipFraction&&(t._introClipFraction=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]=Et(e[i][0],o[i][0],u),t.topPath[i][1]=Et(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]=Et(i[e][0],r[e][0],u),t.bottomPath[e][1]=Et(i[e][1],r[e][1],u)}}if(h>=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("candlestick"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=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,t._introClipFraction=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,t._introClipFraction=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){if(this._colorMapCache&&this._colorMapCache.version===this._ingestVersion)return this._colorMapCache.map;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.version=this._ingestVersion,this._colorMapCache.map;const r=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||wt,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,version:this._ingestVersion},n}resolveLineStyle(t,e){var i;const o=this.config.lineStyle;if("function"==typeof o){const i=o(e||{},t);if(i&&!i.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{stroke:e})}return i}const r=null===(i=this.config.themeSemantic)||void 0===i?void 0:i.primary;return o&&"object"==typeof o?{stroke:o.stroke||r||"#007bff",strokeWidth:o.strokeWidth||2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity}:{stroke:this.resolveGroupColor(t)||r||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var i,o;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}const n=null===(i=this.config.themeSemantic)||void 0===i?void 0:i.primary;if(r&&"object"==typeof r)return{fill:r.fill||r.stroke||n||"#4e79a7",fillOpacity:null!==(o=r.fillOpacity)&&void 0!==o?o:.7,stroke:r.stroke||n||"#4e79a7",strokeWidth:r.strokeWidth||2};const s=this.resolveGroupColor(t)||n||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,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.length>0?this.config.colorScheme:null)||(Array.isArray(this.config.themeCategorical)&&this.config.themeCategorical.length>0?this.config.themeCategorical:null)||wt;if(0===i.length)return null;const o=i[this._groupColorCounter%i.length];if(this._groupColorCounter++,this._groupColorMap.set(t,o),this._groupColorMap.size>Yt.GROUP_COLOR_MAP_CAP){const t=this._groupColorMap.keys().next().value;void 0!==t&&this._groupColorMap.delete(t)}return 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._hasRenderedOnce=!1,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._maxPointRadius=0,this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,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);("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(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||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const c=a||!mt(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(i=n.xAccessor)&&void 0!==i?i:n.timeAccessor),l=a||!mt(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=vt(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=vt(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=vt(this.config.xAccessor,"x"),this.getY=vt(this.config.yAccessor,"y")),s=!0)}if("groupAccessor"in t&&!mt(t.groupAccessor,n.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?bt(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in t&&!mt(t.categoryAccessor,n.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?bt(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in t&&!mt(t.sizeAccessor,n.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?vt(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in t&&!mt(t.colorAccessor,n.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?bt(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in t&&!mt(t.y0Accessor,n.y0Accessor)&&(this.getY0=this.config.y0Accessor?vt(this.config.y0Accessor,"y0"):void 0,s=!0),"pointIdAccessor"in t&&!mt(t.pointIdAccessor,n.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?bt(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&("openAccessor"in t&&!mt(t.openAccessor,n.openAccessor)||"closeAccessor"in t&&!mt(t.closeAccessor,n.closeAccessor)||"highAccessor"in t&&!mt(t.highAccessor,n.highAccessor)||"lowAccessor"in t&&!mt(t.lowAccessor,n.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?vt(this.config.openAccessor,"open"):void 0,this.getHigh=vt(this.config.highAccessor,"high"),this.getLow=vt(this.config.lowAccessor,"low"),this.getClose=e?vt(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 It(t,e){var i=t.get(e);if(!i)throw Error("missing: "+e);return i}function Xt(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,u=!1;for(r.push(t),n[t]=!0,e=0;a[t].length>e;e++)(o=a[t][e])===i?(h(i,r),u=!0):n[o]||(u=l(o));if(u)c(t);else for(e=0;a[t].length>e;e++){var d=s[o=a[t][e]];d||(s[o]=d={}),d[o]=!0}return r.pop(),u}function h(t,e){var i=[].concat(e).concat(t);o.push(i)}function u(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,h=0,u=[],d=[];function f(e){var c=[e],l=[e];for(i[e]=o[e]=h,r[e]=!0,h+=1;l.length>0;){var f=t[e=l[l.length-1]];if(f.length>n[e]){for(var g=n[e];f.length>g;++g){var y=f[g];if(0>i[y]){i[y]=o[y]=h,r[y]=!0,h+=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=[],v=0;for(g=c.length-1;g>=0;--g){var x=c[g];if(r[x]=!1,p.push(x),m.push(a[x]),v+=a[x].length,s[x]=u.length,x===e){c.length=g;break}}u.push(p);var b=Array(v);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)b[--v]=m[g][k];d.push(b)}l.pop()}}}for(c=0;e>c;++c)0>i[c]&&f(c);for(c=0;d.length>c;c++){var g=d[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]);d[c]=l}}return{components:u,adjacencyList:d}}(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 d=t.length;d>i;){var f=u(i);if(i=f.leastVertex,a=f.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=d}return o}function qt(t){return t.y0-t.y1>0?"up":"down"}function Gt(t,e){return e(t.source)==e(t.target)}function Vt(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 Ht(t){return t.target.x0-t.source.x1}function Qt(t,e){var i=Ut(t),o=Ht(e)/Math.tan(i);return"up"==qt(t)?t.y1-o:t.y1+o}function Zt(t,e){var i=Ut(t),o=Ht(e)/Math.tan(i);return"up"==qt(t)?t.y1+o:t.y1-o}function Ut(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function Kt(t,e){return e(t)}function Jt(t){return ee(t.source)}function te(t){return ee(t.target)}function ee(t){return(t.y0+t.y1)/2}function ie(t){return t.virtual?0:t.value}function oe(t,e){var i=0;t.sourceLinks.forEach(function(t){i=t.circular&&!Gt(t,e)?i+1:i});var o=0;return t.targetLinks.forEach(function(t){o=t.circular&&!Gt(t,e)?o+1:o}),i+o}function re(t){return t.target.depth}function ne(t,e){return t.sourceLinks.length?t.depth:e-1}function se(t,e){return t.y0-e.y0}function ae(t,e){return e.y0-t.y0}function ce(t,e){return t.y1-e.y1}function le(t,e){return e.y1-t.y1}function he(t,e){return de(t.source,e.source)||t.index-e.index}function ue(t,e){return de(t.target,e.target)||t.index-e.index}function de(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function fe(t,e){return ge(t)==ge(e)?"bottom"==t.circularLinkType?ae(t,e):se(t,e):ge(e)-ge(t)}function ge(t){return t.target.column-t.source.column}function ye(t,e){return pe(t)==pe(e)}function pe(t){return t.y0-t.y1>0?"up":"down"}function me(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=_(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}),ve(n.links.filter(function(t){return"top"==t.circularLinkType}),e,i),ve(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,Gt(t,e)&&Vt(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?ae:se);var h=0;l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2+h,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2+r*i+h),h+=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?le:ce),h=0,l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2+h,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2+r*i+h),h+=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 ve(t,e,i){t.sort(fe);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(Gt(t,e)&&Vt(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&&xe(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 xe(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function be(t){return function(){return t}}function ke(t){return t.index}function Ae(t){return t.nodes}function we(t){return t.links}function Se(t,e,i){var o=P(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+=ee(t.source)*e,o+=e}}),i.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=ee(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?oe(e,i)-oe(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==oe(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 _e(t,e,i,o,r,n){var s=P(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});h();for(var a=1,c=n;c>0;--c)l(a*=.99,i),h();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&&oe(r,i)>0){var c=T(r.sourceLinks,te),l=T(r.targetLinks,Jt),h=c&&l?(c+l)/2:c||l;if(h){var u=(h-ee(r))*e*.3;r.y0+=u,r.y1+=u}}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 d=T(r.sourceLinks,te),f=T(r.targetLinks,Jt),g=((d&&f?(d+f)/2:d||f)-ee(r))*e;r.y0+=g,r.y1+=g}})})}function h(){s.forEach(function(i){var n,s,a,c=t.y0,l=i.length;for(i.sort(e||de),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 Pe(t){t.nodes.forEach(function(t){t.sourceLinks.sort(ue),t.targetLinks.sort(he)}),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 Me(){var t=0,e=0,i=1,o=1,r=24,n=8,s=null,a=ke,c=ne,l=void 0,h=32,u=2,d=Ae,f=we;function g(){var g={nodes:d.apply(null,arguments),links:f.apply(null,arguments)};return function(d){d.x0=t,d.y0=e,d.x1=i,d.y1=o,d.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 E(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=It(i,o)),"object"!=typeof r&&(r=t.target=It(i,r)),o.sourceLinks.push(t),r.targetLinks.push(t)})}(d,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=Xt(o);c.sort(function(t,e){return t.length-e.length});var l={};for(r=0;c.length>r;r++){var h=c[r].slice(-2);l[h[0]]||(l[h[0]]={}),l[h[0]][h[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++)})}(d,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){Kt(t,e)!=Kt(r.source,e)&&Kt(t,e)!=Kt(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),Gt(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(d,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(O(t.sourceLinks,ie),O(t.targetLinks,ie)),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)})})}(d),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})}(d,l,c);var f=n;if(null!==s){var g=P(d.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),y=M(g,function(t){return t.length});y>1&&(f=Math.max(1,(o-e)*s/(y-1)))}(function(t,e,i){var o=P(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=_(o,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/O(e,function(t){return t.value})});t.ky=r,t.links.forEach(function(e){e.width=e.value*t.ky});var n=M(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})})(d,f,r),Se(d,l,a),_e(d,l,a,f,f,h),Pe(d),me(d,a,u,10,8),Se(d,l,a),_e(d,l,a,f,f,h),Pe(d),me(d,a,u,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 Kt(i.source,e)==Kt(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(!ye(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var i=Qt(e,t);return t.y1-i}if(e.target.column>t.target.column)return Qt(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}})})}(d,a),function(t,e){let i=t;i.nodes.forEach(function(t){var o=i.links.filter(function(i){return Kt(i.target,e)==Kt(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(!ye(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;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}})})}(d,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=_(e,function(t){return t.y0}),s=M(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})})}}(d),me(d,a,u,10,8)}(g),g}return g.update=function(t){return Pe(t),me(t,a,u,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?(d="function"==typeof t?t:be(t),g):d},g.links=function(t){return arguments.length?(f="function"==typeof t?t:be(t),g):f},g.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:be(t),g):a},g.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:be(t),g):c},g.nodeSort=function(t){return arguments.length?(l=t,g):l},g.iterations=function(t){return arguments.length?(h=+t,g):h},g.circularLinkGap=function(t){return arguments.length?(u=+t,g):u},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}Yt.GROUP_COLOR_MAP_CAP=1e3,Yt.QUADTREE_THRESHOLD=500;const Oe=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=D(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=D(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 Te(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,h=r.leftFullExtent,u=r.verticalFullExtent,d="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(o,15));return`M${n},${s-d*i}L${l},${s-d*i}L${l+o},${s-d*i+d*f}L${l+o},${u+d*o-d*f}L${l+o-f},${u+d*o}L${h-o+f},${u+d*o}L${h-o},${u+d*o-d*f}L${h-o},${c-d*i+d*f}L${h-o+f},${c-d*i}L${a},${c-d*i}L${a},${c+d*i}L${h+o},${c+d*i}L${h+o},${u-d*o}L${l-o},${u-d*o}L${l-o},${s+d*i}L${n},${s+d*i}Z`}const Ee=new Set,Le=new WeakMap;function De(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let i=Le.get(t);if(i){const t=i.get(e);if(t)return t}else i=new Map,Le.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}`;Ee.has(t)||(Ee.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 je={left:function(t){return t.depth},right:function(t,e){return e-1-t.height},center:function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Math.min.apply(Math,t.sourceLinks.map(re))-1:0},justify:ne};function ze(t){return"string"==typeof t?t:t.id}const $e={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,o){var r,n,s,a,c,l,h;if(0===t.length)return;const u="vertical"===i.orientation?"down":"right",d=i.nodeAlign||"justify",f=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 v;v="down"===u?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const x=Me().extent(v).links(m).nodes(p).nodeAlign(je[d]||ne).nodeId(t=>t.id).nodeWidth(f).iterations(y);x.nodePaddingRatio&&x.nodePaddingRatio(g),x();{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,h=o[0],u=o[1];if(n>0&&s>0&&(0>t||0>i||e>h||r>u)){const e=Math.min(h/n,u/s),o=-t*e+(h-n*e)/2,r=-i*e+(u-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=ze(t.source),i=ze(t.target),o=k.get(t._edgeKey?t._edgeKey:`${e}\0${i}`);if(o){o.y0=t.y0,o.y1=t.y1,o.sankeyWidth=null!==(h=t.width)&&void 0!==h?h:0,o.circular=!!t.circular,o.circularPathData=t.circularPathData,o._circularWidth=t._circularWidth,o._circularStub=t._circularStub,o.path=t.path,o.circularLinkType=t.circularLinkType,o.direction=u;const r=b.get(e),n=b.get(i);r&&(o.source=r),n&&(o.target=n)}}},buildScene(t,e,i,o){var r,n,s,a,c,l;const h="vertical"===i.orientation?"down":"right",u=i.nodeStyle,d=i.edgeStyle,f=null!==(r=i.edgeOpacity)&&void 0!==r?r:.5,g=i.edgeColorBy||"source",y=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:x,p=new Map;t.forEach((t,e)=>{p.set(t.id,y[e%y.length])});const m=[],v=[],b=[],k=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=u?u(De(e,"nodeStyle")):{},r={fill:o.fill||p.get(e.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};k.set(e.id,("string"==typeof r.fill?r.fill:null)||p.get(e.id)||"#4d430c"),m.push("down"===h?{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 A=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of A){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let r=(null===(n=i.themeSemantic)||void 0===n?void 0:n.border)||(null===(s=i.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";r="function"==typeof g?g(t)||r:"target"===g?k.get(o.id)||p.get(o.id)||r:k.get(e.id)||p.get(e.id)||r;const h=d?d(De(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,i=t.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),n=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),s=h.fill||r;v.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-i}L${e.sourceX+o},${e.sourceY-i}L${e.sourceX+o},${e.sourceY+i}L${e.sourceX},${e.sourceY+i}Z`,style:{fill:s,fillOpacity:null!==(a=h.fillOpacity)&&void 0!==a?a:f,stroke:"none",opacity:h.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+o}}),v.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-i}L${e.targetX-n},${e.targetY-i}L${e.targetX-n},${e.targetY+i}L${e.targetX},${e.targetY+i}Z`,style:{fill:s,fillOpacity:null!==(c=h.fillOpacity)&&void 0!==c?c:f,stroke:"none",opacity:h.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-n,x1:e.targetX}});continue}let u;if(u=t.circular&&t.circularPathData?Te(t):Oe(t),!u)continue;const y={fill:h.fill||r,fillOpacity:null!==(l=h.fillOpacity)&&void 0!==l?l:f,stroke:h.stroke||"none",strokeWidth:h.strokeWidth,opacity:h.opacity};v.push({type:"bezier",pathD:u,bezierCache:t.bezier,style:y,datum:t})}if(!1!==i.showLabels){const e=(w=i.nodeLabel)?"function"==typeof w?w:t=>t[w]||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,c;"down"===h?(s=i.y0+(i.y1-i.y0)/2,a=i.x1+14,c="start"):(o[0]/2>i.x0+t/2?(s=i.x0-6,c="end"):(s=i.x1+6,c="start"),a=i.y0+r/2),b.push({x:s,y:a,text:n+"",anchor:"down"===h?"middle":c,baseline:"middle",fontSize:11})}}var w;return{sceneNodes:m,sceneEdges:v,labels:b}}},Re={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 h=0;const u=[];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?h++:i?(e.x=i.x,e.y=i.y,h++):u.push(e)}const d=h>0&&.3>=(t.length>0?u.length/t.length:1);if(d){const i=new Map;for(const e of t)i.set(e.id,e);for(const t of u){const o=Ce(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=Ne(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=Ne(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 f=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:d?40:f,y=We(i.nodeSize,i.nodeSizeRange,t),p=t=>y(t);if(g>0){const i=j().strength(t=>{const e=t.weight;return Math.min(2.5,e?e*s:s)}).id(t=>t.id),o=z().force("charge",$().strength(t=>-25*p(t))).force("center",R(a,c).strength(.8)).force("x",C(a).strength(.15)).force("y",N(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)}d?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,a,c,l,h;const u=i.nodeStyle,d=i.edgeStyle,f=We(i.nodeSize,i.nodeSizeRange,t),g=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:x,y=new Map;t.forEach((t,e)=>{y.set(t.id,g[e%g.length])});const p=[],m=[],v=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=f(De(e,"nodeSize")),o=u?u(De(e,"nodeStyle")):{},a={fill:o.fill||y.get(e.id)||(null===(r=i.themeSemantic)||void 0===r?void 0:r.primary)||"#007bff",stroke:o.stroke||(null===(n=i.themeSemantic)||void 0===n?void 0:n.surface)||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:2,opacity:o.opacity};p.push({type:"circle",cx:e.x,cy:e.y,r:t,style:a,datum:e,id:e.id,label:e.id})}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:b.get(t.source),o="object"==typeof t.target?t.target:b.get(t.target);if(!e||!o)continue;if(null==e.x||null==e.y)continue;if(null==o.x||null==o.y)continue;const r=d?d(De(t,"edgeStyle")):{},n={stroke:r.stroke||(null===(a=i.themeSemantic)||void 0===a?void 0:a.border)||(null===(c=i.themeSemantic)||void 0===c?void 0:c.secondary)||"#999",strokeWidth:null!==(l=r.strokeWidth)&&void 0!==l?l:1,opacity:null!==(h=r.opacity)&&void 0!==h?h:.6};m.push({type:"line",x1:e.x,y1:e.y,x2:o.x,y2:o.y,style:n,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){if(null==i.x||null==i.y)continue;const t=e?e(i):i.id;if(!t)continue;const o=f(De(i,"nodeSize"));v.push({x:i.x,y:i.y-o-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var k;return{sceneNodes:p,sceneEdges:m,labels:v}}};function Ce(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 Ne(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 We(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 s=e||[5,20],a=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===a.length)return()=>s[0];const c=null!==(o=_(a))&&void 0!==o?o:0,l=null!==(r=M(a))&&void 0!==r?r:1;if(c===l)return()=>(s[0]+s[1])/2;const h=n().domain([c,l]).range(s).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?s[0]:h(o)}}const Be=x,Fe={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,h=o[1]/2,u=(d=i.valueAccessor)?"function"==typeof d?d:t=>{var e;return null!==(e=t[d])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var d;const f=new Map;for(let e=0;t.length>e;e++)f.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=f.get("string"==typeof t.source?t.source:t.source.id),o=f.get(e);if(void 0===i||void 0===o)continue;const r=u(t);y[i][o]=r}const p=B().padAngle(r);s&&p.sortGroups(s);const m=p(y),v=m.groups,x=F().innerRadius(c).outerRadius(a);for(const e of v){const i=t[e.index],o=x.centroid(e);i.x=o[0]+l,i.y=o[1]+h,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,s,a;const{groupWidth:c=20,edgeOpacity:l=.5}=i,h=Math.min(o[0],o[1])/2,u=h-c,d=o[0]/2,f=o[1]/2,g=i.nodeStyle,y=i.edgeStyle,p=i.edgeColorBy||"source",m=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:Be,v=new Map;t.forEach((t,e)=>{v.set(t.id,m[e%m.length])});const x=W().radius(u),b=[],k=[],A=[];for(let e=0;t.length>e;e++){const i=t[e],o=i.arcData;if(!o)continue;let n;n=g?g(De(i,"nodeStyle")).fill||v.get(i.id)||m[e%m.length]:v.get(i.id)||m[e%m.length];const s=g?g(De(i,"nodeStyle")):{},a={fill:n,stroke:s.stroke||"black",strokeWidth:null!==(r=s.strokeWidth)&&void 0!==r?r:1,opacity:s.opacity};b.push({type:"arc",cx:d,cy:f,innerR:u,outerR:h,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 o=x(e);if(!o)continue;const r=Ye(o,d,f);let c=(null===(n=i.themeSemantic)||void 0===n?void 0:n.border)||(null===(s=i.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";if(y)c=y(De(t,"edgeStyle")).fill||c;else{const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;"target"===p&&i?c=v.get(i.id)||c:e&&(c=v.get(e.id)||c)}const h=y?y(De(t,"edgeStyle")):{},u={fill:c,fillOpacity:null!==(a=h.fillOpacity)&&void 0!==a?a:l,stroke:h.stroke||"none",strokeWidth:h.strokeWidth,opacity:h.opacity};k.push({type:"ribbon",pathD:r,style:u,datum:t})}if(!1!==i.showLabels){const e=(w=i.nodeLabel)?"function"==typeof w?w:t=>t[w]||t.id:null,o=h+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;A.push({x:d+Math.cos(s)*o,y:f+Math.sin(s)*o,text:r+"",anchor:n>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:b,sceneEdges:k,labels:A}}};function Ye(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 Ie=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Xe(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 qe(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 Ge(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 Ve(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:Ie}function He(t){var e;return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)?t.themeSemantic.primary:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical[0]:"#4d430c"}function Qe(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 Ze={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},h=I(n,a);h.sum(l),h.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[u,d]=o;switch(s){case"tree":!function(t,e,i,o){const r=e.treeOrientation||"vertical",n=Q();n.size("horizontal"===r?[o,i]:"radial"===r?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),n(t)}(h,i,u,d);break;case"cluster":!function(t,e,i,o){const r=e.treeOrientation||"vertical",n=H();n.size("horizontal"===r?[o,i]:"radial"===r?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),n(t)}(h,i,u,d);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=G().size([i,o]).tile(V).padding(s);a>0&&c.paddingTop(a),c(t)}(h,i,u,d);break;case"circlepack":!function(t,e,i,o){var r;const n=null!==(r=e.padding)&&void 0!==r?r:4;q().size([i,o]).padding(n)(t)}(h,i,u,d);break;case"partition":!function(t,e,i,o){var r;X().size([i,o]).padding(null!==(r=e.padding)&&void 0!==r?r:1)(t)}(h,i,u,d)}const f=h.descendants();t.length=0,e.length=0;const g=new Map;for(let e=0;f.length>e;e++){const o=f[e],n={id:qe(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?Ue(n,o,i):"treemap"===s||"partition"===s?Ke(n,o):"circlepack"===s&&Je(n,o),n.__hierarchyNode=o,t.push(n),g.set(o,n)}if("tree"===s||"cluster"===s)for(const t of f)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,h,u,d,f;const g=[],y=[],p=[],m=i.treeOrientation||"vertical",v="radial"===m,x=o[0]/2,b=o[1]/2,k="number"==typeof(A=i.nodeSize)?A:5;var A;for(const e of t){let t=e.x,o=e.y;v&&(t+=x,o+=b);const n=r(De(e,"nodeStyle"));let c=n.fill||He(i);if(i.colorByDepth&&void 0!==e.depth){const t=Ve(i);c=t[e.depth%t.length]}const l={fill:c,stroke:n.stroke||(null===(s=i.themeSemantic)||void 0===s?void 0:s.surface)||"#fff",strokeWidth:null!==(a=n.strokeWidth)&&void 0!==a?a:1,opacity:n.opacity};g.push({type:"circle",cx:t,cy:o,r:k,style:l,datum:e,id:e.id,label:e.id,depth:e.depth})}const w=null!==(c=i.edgeOpacity)&&void 0!==c?c:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let r=e.x,s=e.y,a=o.x,c=o.y;v&&(r+=x,s+=b,a+=x,c+=b);const f=Qe(r,s,a,c,m),g=n(De(t,"edgeStyle")),p={fill:"none",stroke:g.stroke||(null===(l=i.themeSemantic)||void 0===l?void 0:l.border)||(null===(h=i.themeSemantic)||void 0===h?void 0:h.secondary)||"#999",strokeWidth:null!==(u=g.strokeWidth)&&void 0!==u?u:1.5,opacity:null!==(d=g.opacity)&&void 0!==d?d:w};y.push({type:"curved",pathD:f,style:p,datum:t})}if(!1!==i.showLabels){const e=Ge(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(v&&(s+=x,a+=b),v){const t=s-x,e=a-b,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"===m?((null===(f=i.data)||void 0===f?void 0:f.children)&&0!==i.data.children.length?(o=s-k-6,n="end"):(o=s+k+6,n="start"),r=a):(o=s,r=a+k+14,n="middle");p.push({x:o,y:r,text:t+"",anchor:n,baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:y,labels:p}}(t,e,i,o,r,n);case"treemap":case"partition":return function(t,e,i,o){var r,n,s,a,c;const l=[],h=[];for(const i of t){const t=i.x1-i.x0,s=i.y1-i.y0;if(0>=t||0>=s)continue;const a=o(De(i,"nodeStyle"));let c=a.fill||He(e);if(e.colorByDepth&&void 0!==i.depth){const t=Ve(e);c=t[i.depth%t.length]}const h={fill:c,stroke:a.stroke||(null===(r=e.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(n=a.strokeWidth)&&void 0!==n?n:1,opacity:a.opacity};l.push({type:"rect",x:i.x0,y:i.y0,w:t,h:s,style:h,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Ge(e.nodeLabel),r=e.labelMode||"leaf",n="partition"===e.chartType;for(const l of t){const t=l.x1-l.x0,u=l.y1-l.y0;if(0>=t||0>=u)continue;const d=!((null===(s=l.data)||void 0===s?void 0:s.children)&&l.data.children.length>0);if(!n){if("leaf"===r&&!d)continue;if("parent"===r&&d)continue}const f=i?i(l):l.id;if(!f)continue;if((d?30:40)>t||(d?16:14)>u)continue;let g=o(De(l,"nodeStyle")).fill||He(e);if(e.colorByDepth&&void 0!==l.depth){const t=Ve(e);g=t[l.depth%t.length]}const y="string"==typeof g?Xe(g):null!==(c=null===(a=e.themeSemantic)||void 0===a?void 0:a.text)&&void 0!==c?c:"#000";h.push(d?{x:l.x0+t/2,y:l.y0+u/2,text:f+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,u)/6)),fill:y}:{x:l.x0+4,y:l.y0+12,text:f+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:y})}}return{sceneNodes:l,sceneEdges:[],labels:h}}(t,i,0,r);case"circlepack":return function(t,e,i,o){var r,n,s,a,c,l,h,u,d,f;const g=[],y=[];for(const i of t){const t=null!==(r=i.__radius)&&void 0!==r?r:5;if(0>=t)continue;const c=o(De(i,"nodeStyle"));let l=c.fill||He(e);if(e.colorByDepth&&void 0!==i.depth){const t=Ve(e);l=t[i.depth%t.length]}const h={fill:l,stroke:c.stroke||(null===(n=e.themeSemantic)||void 0===n?void 0:n.surface)||"#fff",strokeWidth:null!==(s=c.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=c.opacity)&&void 0!==a?a:.7};g.push({type:"circle",cx:i.x,cy:i.y,r:t,style:h,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Ge(e.nodeLabel);for(const r of t){const t=null!==(c=r.__radius)&&void 0!==c?c:5,n=i?i(r):r.id;if(!n)continue;if(15>t)continue;const s=!((null===(l=r.data)||void 0===l?void 0:l.children)&&r.data.children.length>0);let a=o(De(r,"nodeStyle")).fill||He(e);if(e.colorByDepth&&void 0!==r.depth){const t=Ve(e);a=t[r.depth%t.length]}if(s){const i="string"==typeof a?Xe(a):null!==(u=null===(h=e.themeSemantic)||void 0===h?void 0:h.text)&&void 0!==u?u:"#000";y.push({x:r.x,y:r.y,text:n+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:i})}else y.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:(null===(d=e.themeSemantic)||void 0===d?void 0:d.text)||"#000",stroke:(null===(f=e.themeSemantic)||void 0===f?void 0:f.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:g,sceneEdges:[],labels:y}}(t,i,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Ue(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 Ke(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 Je(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 ti(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const ei={sankey:$e,force:Re,chord:Fe,tree:Ze,cluster:Ze,treemap:Ze,circlepack:Ze,partition:Ze,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),h=null!==(n=i.orbitSize)&&void 0!==n?n:2.95,u=null!==(s=i.orbitEccentricity)&&void 0!==s?s:1,d="number"==typeof h?()=>h:h,f="number"==typeof u?()=>u:u,g=ti(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,v=e[1]/2,x=Math.min(e[0],e[1])/2*.85,b=p(c(t));o.push({id:b,x:m,y:v,x0:m,x1:m,y0:v,y1:v,width:0,height:0,value:0,depth:0,data:t}),g.metaMap.set(b,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,i,n,s,h,u,y){const m=a(e);if(!(null==m?void 0:m.length))return;const v=m.length;let x=0,b=0,k=0;for(;v>b;)b+=l[Math.min(k,l.length-1)],k++,x++;let A=0;for(let v=0;x>v;v++){const b=l[Math.min(v,l.length-1)],k=m.slice(A,A+b);if(!k.length)break;const w=(v+1)/x,S={id:i,depth:u,data:e,parentId:i},_=y?h/d(S)*w:h*w,P=Y().value(t=>{var e;return(null===(e=a(t))||void 0===e?void 0:e.length)?4:1}).sort(null),M=P(k),O=f(S);for(let e=0;k.length>e;e++){const a=(M[e].startAngle+M[e].endAngle)/2,l=k[e],h=p(c(l)),d=n+_*Math.sin(a),f=s+_*Math.cos(a)*O;o.push({id:h,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:u,data:l}),g.metaMap.set(h,{ring:_,angle:a,depth:u,parentId:i,eccentricity:O}),r.push({source:i,target:h,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:h}}),t(l,h,d,f,_,u+1,!0)}A+=b}}(t,b,m,v,x,1,!1)}(r,o,i,t,e)},buildScene(t,e,i,o){var r,n,s,a,c,l,h;const u=i.nodeStyle,d=i.nodeSize,f="number"==typeof d?()=>d:"function"==typeof d?d:()=>6,g=[],y=[],p=[];if(!1!==i.orbitShowRings){const e=ti(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;y.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=f(De(e,"nodeSize")),o=u?u(De(e,"nodeStyle")):{},l={fill:o.fill||(null===(r=i.themeSemantic)||void 0===r?void 0:r.primary)||"#6366f1",stroke:o.stroke||(null===(n=i.themeSemantic)||void 0===n?void 0:n.surface)||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=o.opacity)&&void 0!==a?a:0===(null!==(c=e.depth)&&void 0!==c?c:0)?1:.85};g.push({type:"circle",cx:e.x,cy:e.y,r:t,style:l,datum:e,id:e.id,label:e.id,depth:e.depth})}const m=new Map;for(const e of t)m.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:m.get(t.source),i="object"==typeof t.target?t.target:m.get(t.target);e&&i&&(null!=e.x&&null!=i.x&&y.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=f(De(i,"nodeSize"));if(4>=t)continue;const o="function"==typeof e?e(i):e&&null!==(h=null===(l=i.data)||void 0===l?void 0:l[e])&&void 0!==h?h:i.id;p.push({x:i.x,y:i.y+t+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:g,sceneEdges:y,labels:p}},tick:(t,e,i,o,r)=>!1!==i.orbitAnimated&&(function(t,e){var i,o;const r=ti(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 ii(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,h=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:h,datum:t.pieceData,category:t.name}))}return n}function oi(t){var e,i,o;const r=t.length,n=t[0],s=t[r-1];return{n:r,min:n,q1:null!==(e=L(t,.25))&&void 0!==e?e:n,median:null!==(i=L(t,.5))&&void 0!==i?i:(n+s)/2,q3:null!==(o=L(t,.75))&&void 0!==o?o:s,max:s,mean:t.reduce((t,e)=>t+e,0)/r}}const ri={bar:function(t,e){var i,o,r;const{scales:n,columns:s,config:a,getR:c,getStack:l,resolvePieceStyle:h}=t,{r:u,projection:d}=n,f=[],g="vertical"===d,y="horizontal"===d,p=a.normalize,m=[];if(l){const t=new Set;for(const e of Object.values(s))for(const i of e.pieceData){const e=l(i);t.has(e)||(t.add(e),m.push(e))}}else m.push("_default");for(const t of Object.values(s)){const e=new Map;for(const i of t.pieceData){const t=l?l(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t);o.total+=c(i),o.pieces.push(i)}let i=0;if(p)for(const t of e.values())i+=Math.abs(t.total);let o=0,r=0;for(const n of m){const s=e.get(n);if(!s)continue;let a=s.total;p&&i>0&&(a/=i);const c=h(s.pieces[0],l?n:t.name),d=Object.assign(Object.assign({},s.pieces[0]),{__aggregateValue:s.total,__pieceCount:s.pieces.length,category:t.name});if(g){const e=u(0>a?r:o+a),i=0>a?u(r+a)-u(r):u(o)-u(o+a);f.push(Rt(t.x,e,t.width,Math.abs(i),c,d,n)),0>a?r+=a:o+=a}else if(y){const e=u(0>a?r+a:o),i=0>a?u(r)-u(r+a):u(o+a)-u(o);f.push(Rt(e,t.x,Math.abs(i),t.width,c,d,n)),0>a?r+=a:o+=a}}}const v="vertical"===d,x=a.roundedTop&&a.roundedTop>0?Math.max(0,a.roundedTop):0;for(const t of f){if("rect"!==t.type)continue;const e=null!==(o=null===(i=t.datum)||void 0===i?void 0:i.__aggregateValue)&&void 0!==o?o:0;t.roundedEdge=v?0>e?"bottom":"top":0>e?"left":"right",a.gradientFill&&(t.fillGradient=a.gradientFill)}if(x>0){const t=new Map;for(const e of f){if("rect"!==e.type)continue;const i=(null===(r=e.datum)||void 0===r?void 0:r.category)||"";t.has(i)||t.set(i,[]),t.get(i).push(e)}for(const e of t.values()){if(0===e.length)continue;const t=e.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}),i=e.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)});t.length>0&&(t.reduce(v?(t,e)=>e.y>t.y?t:e:(t,e)=>t.x+t.w>e.x+e.w?t:e).roundedTop=x),i.length>0&&(i.reduce(v?(t,e)=>t.y+t.h>e.y+e.h?t:e:(t,e)=>e.x>t.x?t:e).roundedTop=x)}}return f},clusterbar:function(t,e){const{scales:i,columns:o,config:r,getR:n,getGroup:s,resolvePieceStyle:a}=t,{r:c,projection:l}=i,h=[],u="vertical"===l,d=[],f=new Set;for(const t of Object.values(o))for(const e of t.pieceData){const t=s?s(e):"_default";f.has(t)||(f.add(t),d.push(t))}const g=d.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;d.length>s;s++){const l=r.get(d[s])||[];for(const r of l){const l=n(r),f=a(r,d[s]);if(u){const n=t.x+s*e+i/2,a=c(0),u=c(l);h.push(Rt(n,Math.min(a,u),o,Math.abs(a-u),f,r,d[s]))}else{const n=t.x+s*e+i/2,a=c(0),u=c(l);h.push(Rt(Math.min(a,u),n,Math.abs(u-a),o,f,r,d[s]))}}}}const y=r.roundedTop&&r.roundedTop>0?Math.max(0,r.roundedTop):0;for(const t of h){if("rect"!==t.type)continue;if(null==t.datum)continue;const e=n(t.datum);y>0&&(t.roundedTop=y),t.roundedEdge=u?0>e?"bottom":"top":0>e?"left":"right",r.gradientFill&&(t.fillGradient=r.gradientFill)}return h},point:function(t,e){var i,o;const{scales:r,columns:n,getR:s,multiScales:a,resolvePieceStyle:c}=t,{r:l,projection:h}=r,u=[],d="vertical"===h,f="radial"===h,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),h=g&&a[r]||l,m=c(e,t.name),v=m.r||5;let x,b;if(f){const e=p+(t.pctStart+t.pct/2)*y,i=h(n);x=Math.cos(e)*i,b=Math.sin(e)*i}else d?(x=t.middle,b=h(n)):(x=h(n),b=t.middle);u.push({type:"point",x:x,y:b,r:v,style:m,datum:e})}return u},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),h=n(o,t.name),u=h.r||4,d=(7919*i%100/100-.5)*e*.8,f=l?t.middle+d:s(a),g=l?s(a):t.middle+d;c.push({type:"point",x:f,y:g,r:u,style:h,datum:o})}}return c},pie:ii,donut:ii,boxplot:function(t,e){var i,o,r,n,s,a;const{scales:c,columns:l,config:h,getR:u,resolveSummaryStyle:d}=t,{r:f,projection:g}=c,y=[],p="vertical"===g,m=!1!==h.showOutliers;for(const e of Object.values(l)){const c=e.pieceData.map(t=>u(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===c.length)continue;const l=c[0],h=c[c.length-1],g=null!==(i=L(c,.25))&&void 0!==i?i:l,v=null!==(o=L(c,.5))&&void 0!==o?o:(l+h)/2,x=null!==(r=L(c,.75))&&void 0!==r?r:h,b=x-g,k=g-1.5*b,A=x+1.5*b,w=null!==(n=c.find(t=>t>=k))&&void 0!==n?n:l,S=null!==(s=[...c].reverse().find(t=>A>=t))&&void 0!==s?s:h,_=d(e.pieceData[0],e.name),P=[];if(m)for(const t of e.pieceData){const i=u(t);if(k>i||i>A){const o=p?e.middle:f(i),r=p?f(i):e.middle;P.push({px:o,py:r,value:i,datum:t})}}if(y.push({type:"boxplot",x:p?e.middle:0,y:p?0:e.middle,projection:p?"vertical":"horizontal",columnWidth:.6*e.width,minPos:f(w),q1Pos:f(g),medianPos:f(v),q3Pos:f(x),maxPos:f(S),stats:{n:c.length,min:w,q1:g,median:v,q3:x,max:S,mean:c.reduce((t,e)=>t+e,0)/c.length},style:_,datum:e.pieceData,category:e.name,outliers:P}),m)for(const e of P)y.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:_.fill||(null===(a=t.config.themeSemantic)||void 0===a?void 0:a.secondary)||"#999",opacity:.6},datum:e.datum})}return y},violin:function(t,e){var i,o,r;const{scales:n,columns:s,config:a,getR:c,resolveSummaryStyle:l}=t,{r:h,projection:u}=n,d=[],f="vertical"===u,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,u=Array(g).fill(0);for(const t of e)u[Math.min(Math.floor((t-n)/a),g-1)]++;const p=Math.max(...u,1),m=t.width/2*.9;let v="";if(f){v=`M ${t.middle} ${h(n)}`;for(let e=0;g>e;e++){const i=h(n+(e+.5)*a);v+=` L ${t.middle+u[e]/p*m} ${i}`}v+=` L ${t.middle} ${h(s)}`;for(let e=g-1;e>=0;e--){const i=h(n+(e+.5)*a);v+=` L ${t.middle-u[e]/p*m} ${i}`}v+=" Z"}else{v=`M ${h(n)} ${t.middle}`;for(let e=0;g>e;e++)v+=` L ${h(n+(e+.5)*a)} ${t.middle-u[e]/p*m}`;v+=` L ${h(s)} ${t.middle}`;for(let e=g-1;e>=0;e--)v+=` L ${h(n+(e+.5)*a)} ${t.middle+u[e]/p*m}`;v+=" Z"}const x=l(t.pieceData[0],t.name);let b;if(y&&e.length>=4){const a=null!==(i=L(e,.25))&&void 0!==i?i:n,c=null!==(o=L(e,.5))&&void 0!==o?o:(n+s)/2,l=null!==(r=L(e,.75))&&void 0!==r?r:s;b={q1Pos:h(a),medianPos:h(c),q3Pos:h(l),centerPos:t.middle,isVertical:f}}const k=f?{x:t.x,y:Math.min(h(s),h(n)),width:t.width,height:Math.abs(h(s)-h(n))}:{x:Math.min(h(n),h(s)),y:t.x,width:Math.abs(h(s)-h(n)),height:t.width};d.push({type:"violin",pathString:v,translateX:0,translateY:0,bounds:k,iqrLine:b,stats:oi(e),style:x,datum:t.pieceData,category:t.name})}return d},histogram:function(t,e){var i;const{scales:o,columns:r,config:n,getR:s,resolveSummaryStyle:a}=t,{r:c}=o,l=[],h=n.bins||25,u=n.normalize,d=null===(i=c.domain)||void 0===i?void 0:i.call(c),f=d?+d[0]:void 0,g=d?+d[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!=f&&isFinite(f)?f:Math.min(...e),o=null!=g&&isFinite(g)?g:Math.max(...e),r=(o-i)/h||1,n=Array(h).fill(0);for(const t of e)i>t||t>o||n[Math.min(Math.floor((t-i)/r),h-1)]++;const d=e.length,y=Math.max(...n,1),p=a(t.pieceData[0],t.name);for(let e=0;h>e;e++){if(0===n[e])continue;const o=(u?n[e]/d:n[e]/y)*t.width*.9,s=c(i+e*r),a=c(i+(e+1)*r);l.push(Rt(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,h=[],u=n.bins||20,d="horizontal"===l,f=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)/u||1,l=Array(u).fill(0);for(const t of e)o>t||t>r||l[Math.min(Math.floor((t-o)/n),u-1)]++;const g=Math.max(...l,1),y=a(t.pieceData[0],t.name),p=t.width*f;let m="";if(d){const e=t.x+t.width;m=`M ${c(o)} ${e}`;for(let t=0;u>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;u>t;t++){const i=c(o+(t+.5)*n);m+=` L ${e+l[t]/g*p} ${i}`}m+=` L ${e} ${c(r)} Z`}const v=d?{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))};h.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:v,stats:oi(e),style:Object.assign(Object.assign({},y),{fillOpacity:null!==(i=y.fillOpacity)&&void 0!==i?i:.5}),datum:t.pieceData,category:t.name})}return h},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,h=n(e,t.name);if(l){const i=s(Math.min(o,a)),r=s(Math.max(o,a));c.push(Rt(i,t.x,r-i,t.width,h,e,t.name))}else{const i=s(Math.max(o,a)),r=s(Math.min(o,a));c.push(Rt(t.x,i,t.width,r-i,h,e,t.name))}}return c},funnel:function(t,e){var i,o,r,s,a,c,l,h;const{columns:u,getR:d,getStack:f,resolvePieceStyle:g}=t,y=[],p=e.width/2,m=!1!==t.config.showLabels,v=t.scales.o.domain().map(t=>u[t]).filter(Boolean);if(0===v.length)return y;const x=[],b=new Set;for(const t of v)for(const e of t.pieceData){const t=f?f(e):"_default";b.has(t)||(b.add(t),x.push(t))}const k=x.length>1&&"_default"!==x[0],A=[];let w=0;for(const t of v){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=d(o);r.total+=n,r.pieces.push(o),i+=n}A.push({col:t,groups:e,stepTotal:i}),k||i>w&&(w=i)}if(k)for(const t of A){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>w&&(w=o)}if(0===w)return y;const S=new Map;for(const t of x){const e=A[0].groups.get(t);S.set(t,null!==(i=null==e?void 0:e.total)&&void 0!==i?i:0)}const _=A[0].stepTotal,P=k?.95*p:.9*e.width,M=n().domain([0,w]).range([0,P]),O=null!==(o=t.config.connectorOpacity)&&void 0!==o?o:.3;let T=new Map;for(let e=0;A.length>e;e++){const i=A[e],o=i.col,n=0===e,u=o.width,d=.55*u,f=o.x+(u-d)/2,v=new Map;if(k){let t=0;for(const e of x){const o=i.groups.get(e);o&&(t+=M(o.total))}let e=p,r=p;for(let s=0;x.length>s;s++){const c=x[s],l=i.groups.get(c);if(!l)continue;const h=M(l.total),u=s%2==0,b=u?e:r-h;u?e+=h:r-=h;const k=g(l.pieces[0],c),A=null!==(a=S.get(c))&&void 0!==a?a:l.total,w=A>0?l.total/A*100:0,_=Object.assign(Object.assign({},l.pieces[0]),{__funnelValue:l.total,__funnelPercent:w,__funnelStep:o.name,__funnelIsFirstStep:n,__aggregateValue:l.total,__pieceCount:l.pieces.length,category:c});m&&(0===s&&(_.__funnelStepLabel=o.name,_.__funnelStepLabelX=p,_.__funnelStepLabelY=f,_.__funnelRowWidth=t),_.__funnelValueLabelX=b+h/2,_.__funnelValueLabelY=f,_.__funnelBarW=h),y.push(Rt(b,f,h,d,k,_,c)),v.set(c,{x:b,y:f,w:h,h:d})}}else{const t=i.stepTotal,e=M(t),a=p-e/2,c=x[0],l="_default"!==c,h=null!==(s=null===(r=i.groups.get(c))||void 0===r?void 0:r.pieces[0])&&void 0!==s?s:o.pieceData[0],u=l?c:o.name,b=g(h,u),k=_>0?t/_*100:0,A=Object.assign(Object.assign({},h),{__funnelValue:t,__funnelPercent:k,__funnelStep:o.name,__funnelIsFirstStep:n,category:l?c:o.name});m&&(A.__funnelStepLabel=o.name,A.__funnelStepLabelX=p,A.__funnelStepLabelY=f,A.__funnelRowWidth=e,A.__funnelValueLabelX=p,A.__funnelValueLabelY=f,A.__funnelBarW=e),y.push(Rt(a,f,e,d,b,A,u)),v.set(c,{x:a,y:f,w:e,h:d})}if(e>0&&T.size>0){const e=k?x:[x[0]];for(const r of e){const e=T.get(r),n=v.get(r);if(!e||!n)continue;const s=(()=>{const t=i.groups.get(r);return g(t?t.pieces[0]:o.pieceData[0],"_default"===r?o.name:r)})(),a={type:"trapezoid",points:[[e.x,e.y+e.h],[e.x+e.w,e.y+e.h],[n.x+n.w,n.y],[n.x,n.y]],style:{fill:s.fill||(null===(c=t.config.themeSemantic)||void 0===c?void 0:c.secondary)||"#999",opacity:O},datum:null!==(h=null===(l=i.groups.get(r))||void 0===l?void 0:l.pieces[0])&&void 0!==h?h:o.pieceData[0],category:"_default"===r?o.name:r};y.push(a)}}T=v}return y},"bar-funnel":function(t,e){var i,o,r,n;const{columns:s,getR:a,getStack:c,resolvePieceStyle:l,scales:h}=t,u=[],d=h.o.domain().map(t=>s[t]).filter(Boolean);if(0===d.length)return u;const f=[],g=new Set;for(const t of d)for(const e of t.pieceData){const t=c?c(e):"_default";g.has(t)||(g.add(t),f.push(t))}const y=f.length>1&&"_default"!==f[0],p=[];for(const t of d){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 f){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 v=h.r,x=y?f.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/x,c=a*b,h=a-c;for(let t=0;f.length>t;t++){const d=f[t],g=e.groups.get(d);if(!g)continue;const p=g.total,x=null!==(r=m.get(d))&&void 0!==r?r:p,b=x>0?p/x*100:0,k=null==s?void 0:s.groups.get(d),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,_=v(p),P=v(0)-_,M=l(g.pieces[0],y?d:i.name),O=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:p,__barFunnelPercent:b,__barFunnelIsFirstStep:o,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:w,__barFunnelCategory:"_default"===d?void 0:d,category:y?d:i.name,__barFunnelLabelX:S+h/2,__barFunnelLabelY:v(p+w)});if(u.push(Rt(S,_,h,P,M,O,y?d:i.name)),w>0){const t=v(p+w),e=_-t,o=Object.assign({},M),r=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:w,__barFunnelPercent:x>0?w/x*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===d?void 0:d,category:y?d:i.name});u.push(Rt(S,t,h,e,o,r,y?d:i.name))}}}return u},swimlane:function(t,e){const{scales:i,columns:o,getR:r,getStack:n,resolvePieceStyle:s}=t,{r:a,projection:c}=i,l=[],h="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,u=s(i,c);if(h){const r=a(e),n=a(e+o);l.push(Rt(r,t.x,n-r,t.width,u,i,c))}else{const r=a(e+o),n=a(e);l.push(Rt(t.x,r,t.width,n-r,u,i,c))}e+=o}}return l}};class ni{constructor(t){this.rExtent=new yt,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._dataVersion=0,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=t,this.buffer=new gt(t.windowSize),this.getO=bt(t.categoryAccessor||t.oAccessor,"category");const e=t.valueAccessor||t.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(t=>vt(t,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new yt)):(this.getR=vt(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=bt(t.stackBy),this.getGroup=bt(t.groupBy),this.getColor=bt(t.colorAccessor),this.getConnector=bt(t.connectorAccessor),this.getDataId=bt(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new gt(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this._dataVersion++,t.bounded){this.buffer.clear(),this.rExtent.clear();for(const t of this.rExtents)t.clear();t.preserveCategoryOrder?this._hasStreamingData=!0: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.valueAccessor||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",s=e.oExtent||this.resolveCategories(o),a=this.computeValueDomain(o,s),l="horizontal"===r,h="radial"===r,u=Math.min(.9,Math.max(0,null!=e.barPadding?e.barPadding/("vertical"===r?t.width:t.height):.1));let d,f;if(h){d=c().domain(s).range([0,1]).padding(0);const i=Math.min(t.width,t.height)/2,o=e.innerRadius||0;f=n().domain(a).range([o,i])}else l?(d=c().domain(s).range([0,t.height]).padding(u),f=n().domain(a).range([0,t.width])):(d=c().domain(s).range([0,t.width]).padding(u),f=n().domain(a).range([t.height,0]));this.scales={o:d,r:f,projection:r},this.multiScales=this.rAccessors.length>1&&e.multiAxis?this.rAccessors.map((o,r)=>{var s;const a=this.rExtents[r];a.dirty&&a.recalculate(i,o);let[c,h]=a.extent;c===1/0&&(c=0,h=1);const u=null!==(s=e.extentPadding)&&void 0!==s?s:.05,d=h-c,f=d>0?d*u:1;return c-=f,h+=f,c>0&&(c=0),l?n().domain([c,h]).range([0,t.width]):n().domain([c,h]).range([t.height,0])}):[];let g=o;this.rAccessors.length>1&&(g=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(g,s,d,r,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(g,t),this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,o),this.config.pulse&&this.applyPulse(this.scene,o),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(t){const e=this.config.valueAccessor||this.config.rAccessor,i=Array.isArray(e)?e[t]:e;return"string"==typeof i?i:"value"+t}resolveCategories(t){const e=this.config.oSort,i="streaming"===this.config.runtimeMode||this._hasStreamingData,o="auto"===e?void 0:e;let r=null;if(i){r=new Set;for(const e of t)r.add(this.getO(e))}const n=r?Array.from(this.categories).filter(t=>r.has(t)):Array.from(this.categories);if(i&&void 0===o){const t=Math.max(50,3*r.size);if(this.categories.size>t){let e=this.categories.size-t;for(const t of this.categories){if(0>=e)break;r.has(t)||(this.categories.delete(t),e--)}}return n}if(!1===o)return n;if("function"==typeof o)return n.sort(o);const s=new Map;for(const e of t){const t=this.getO(e);s.set(t,(s.get(t)||0)+Math.abs(this.getR(e)))}return n.sort("asc"===o?(t,e)=>(s.get(t)||0)-(s.get(e)||0):(t,e)=>(s.get(e)||0)-(s.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,h=0;if("bar"===a&&this.getStack&&this.config.normalize)l=0,h=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>h&&(h=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>h&&(h=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>h&&(h=t)}else if("clusterbar"===a||"bar-funnel"===a)for(const e of t){const t=this.getR(e);t>h&&(h=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&&(h=e)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(l=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(h=this.config.rExtent[1]));const u="bar"===a||"clusterbar"===a||"bar-funnel"===a||"swimlane"===a;if(u&&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>h&&(h=0)),"bar-funnel"!==a){const t=h-l,e=t>0?t*c:1;null!=(null===(n=this.config.rExtent)||void 0===n?void 0:n[0])||u&&!this.config.baselinePadding&&0===l||(l-=e),null!=(null===(s=this.config.rExtent)||void 0===s?void 0:s[1])||u&&!this.config.baselinePadding&&0===h||"swimlane"===a||(h+=e)}return[l,h]}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 h=null;if(l&&"radial"!==o){h=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),h.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 h)h.set(e,i/t*n)}let u=0,d=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,f;h?(l=d,f=h.get(t)||i.bandwidth(),d+=f+i.padding()*i.step()):(l=null!==(n=i(t))&&void 0!==n?n:0,f=i.bandwidth()),s[t]={name:t,x:l,y:0,width:f,middle:l+f/2,padding:i.padding()*i.step(),pieceData:e,pct:r,pctStart:u},u+=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=ri[this.config.chartType];let r=o?o(i,e):[];if(this.getConnector&&this.scales){const t=function(t,e){var i,o;const{scales:r,config:n,getConnector:s,getO:a}=t;if(!s||!r)return[];const c=[],{projection:l}=r,h=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const i=s(e);if(!i)continue;let o,r;"point"===t.type?(o=t.x,r=t.y):(o=t.x+t.w/2,r=t.y+("vertical"===l?0:t.h/2)),h.has(i)||h.set(i,[]),h.get(i).push({x:o,y:r,datum:e,category:a(e)})}const u=r.o.domain(),d=n.connectorStyle;for(const[e,r]of h)if(r.length>=2){r.sort((t,e)=>u.indexOf(t.category)-u.indexOf(e.category));for(let n=0;r.length-1>n;n++){const s=r[n],a=r[n+1],l="function"==typeof d?d(s.datum):d||{stroke:(null===(i=t.config.themeSemantic)||void 0===i?void 0:i.border)||(null===(o=t.config.themeSemantic)||void 0===o?void 0:o.secondary)||"#999",strokeWidth:1,opacity:.5};c.push({type:"connector",x1:s.x,y1:s.y,x2:a.x,y2:a.y,style:l,datum:s.datum,group:e})}}return c}(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:this.config.themeCategorical||wt,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?Pt(i,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const e=new Map;for(let i=0;t.length>i;i++)e.set(t[i],i);return this._datumIndexCache={version:this._dataVersion,map:e},e}getCategoryIndexMap(t){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const e=this.config.categoryAccessor||this.config.oAccessor,i="function"==typeof e,o=i?null:e||"category",r=new Map;for(let n=0;t.length>n;n++){const s=t[n],a=i?e(s):s[o];let c=r.get(a);c||(c=[],r.set(a,c)),c.push(n)}return this._categoryIndexCache={version:this._dataVersion,map:r},r}rebuildPointQuadtree(){let t=0,e=0;for(const i of this.scene)"point"===i.type&&(t++,i.r>e&&(e=i.r));if(this._maxPointRadius=e,ni.QUADTREE_THRESHOLD>=t)return void(this._pointQuadtree=null);const i=Array(t);let o=0;for(const t of this.scene)"point"===t.type&&(i[o++]=t);this._pointQuadtree=l().x(t=>t.x).y(t=>t.y).addAll(i)}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(t,e){var i,o;if(!this.config.decay)return;const r=e.length;if(1>=r)return;const n=this.getDatumIndexMap(e);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=this.getDatumIndexMap(e);let h=null;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;h||(h=this.getCategoryIndexMap(e));const o=h.get(t);if(!o)continue;let r=0;for(let t=0;o.length>t;t++){const e=this.timestampBuffer.get(o[t]);if(null==e)continue;const i=n-e;if(s>i){const t=1-i/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 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}synthesizeIntroPositions(){var t,e,i,o,r;this.prevPositionMap.clear();const n=new Map,s=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.r(0))&&void 0!==e?e:0,a="horizontal"!==(null===(i=this.scales)||void 0===i?void 0:i.projection);let c;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],i=this.getNodeKey(e,n);i&&("rect"===e.type?this.prevPositionMap.set(i,a?{x:e.x,y:s,w:e.w,h:0,opacity:null!==(o=e.style.opacity)&&void 0!==o?o:1}:{x:s,y:e.y,w:0,h:e.h,opacity:null!==(r=e.style.opacity)&&void 0!==r?r:1}):"point"===e.type?this.prevPositionMap.set(i,{x:e.x,y:e.y,r:0,opacity:0}):"wedge"===e.type&&(void 0===c&&(c=e.startAngle),this.prevPositionMap.set(i,{x:e.cx,y:e.cy,startAngle:c,endAngle:c,innerRadius:e.innerRadius,outerRadius:e.outerRadius,opacity:0})))}}getNodeKey(t,e){var i,o,r;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:""}`:"wedge"===t.type?"w:"+(null!==(r=t.category)&&void 0!==r?r:""):null}snapshotPositions(){var t;this.prevPositionMap.clear();const e=new Map;for(let i=0;this.scene.length>i;i++){const o=this.scene[i],r=this.getNodeKey(o,e);r&&("point"===o.type?this.prevPositionMap.set(r,{x:o.x,y:o.y,r:o.r,opacity:o.style.opacity}):"rect"===o.type?this.prevPositionMap.set(r,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style.opacity}):"wedge"===o.type&&this.prevPositionMap.set(r,{x:o.cx,y:o.cy,startAngle:o.startAngle,endAngle:o.endAngle,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:null!==(t=o.style.opacity)&&void 0!==t?t:1}))}}startTransition(){var t,e,i,o,r,n,s,a,c,l,h,u,d,f,g,y,p,m,v,x,b;if(!this.config.transition||0===this.prevPositionMap.size)return;const k=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 A=!1;const w=new Set,S=new Map;for(let t=0;this.scene.length>t;t++){const l=this.scene[t],h=this.getNodeKey(l,S);if(!h)continue;l._transitionKey=h;const u=this.prevPositionMap.get(h);if("point"===l.type)u?(w.add(h),l._targetOpacity=null!==(e=l.style.opacity)&&void 0!==e?e:1,(u.x!==l.x||u.y!==l.y||void 0!==u.r&&u.r!==l.r)&&(l._targetX=l.x,l._targetY=l.y,l._targetR=l.r,l.x=u.x,l.y=u.y,void 0!==u.r&&(l.r=u.r),A=!0)):(l._targetOpacity=null!==(i=l.style.opacity)&&void 0!==i?i:1,l._targetR=l.r,l.r=0,l.style=Object.assign(Object.assign({},l.style),{opacity:0}),A=!0);else if("rect"===l.type)u?(w.add(h),l._targetOpacity=null!==(o=l.style.opacity)&&void 0!==o?o:1,u.x===l.x&&u.y===l.y&&u.w===l.w&&u.h===l.h||(l._targetX=l.x,l._targetY=l.y,l._targetW=l.w,l._targetH=l.h,l.x=u.x,l.y=u.y,l.w=null!==(r=u.w)&&void 0!==r?r:l.w,l.h=null!==(n=u.h)&&void 0!==n?n:l.h,A=!0)):(l._targetOpacity=null!==(s=l.style.opacity)&&void 0!==s?s:1,l.style=Object.assign(Object.assign({},l.style),{opacity:0}),A=!0);else if("wedge"===l.type)if(u)w.add(h),l._targetOpacity=null!==(a=l.style.opacity)&&void 0!==a?a:1,u.startAngle===l.startAngle&&u.endAngle===l.endAngle||(l._targetStartAngle=l.startAngle,l._targetEndAngle=l.endAngle,l.startAngle=u.startAngle,l.endAngle=u.endAngle,A=!0);else{l._targetOpacity=null!==(c=l.style.opacity)&&void 0!==c?c:1,l._targetStartAngle=l.startAngle,l._targetEndAngle=l.endAngle;const t=l.startAngle;l.startAngle=t,l.endAngle=t,l.style=Object.assign(Object.assign({},l.style),{opacity:0}),this.prevPositionMap.set(h,{x:l.cx,y:l.cy,startAngle:t,endAngle:t,innerRadius:l.innerRadius,outerRadius:l.outerRadius,opacity:0}),A=!0}}this.exitNodes=[];for(const[t,e]of this.prevPositionMap)if(!w.has(t)){if(t.startsWith("p:"))this.exitNodes.push({type:"point",x:e.x,y:e.y,r:null!==(l=e.r)&&void 0!==l?l:3,style:{opacity:null!==(h=e.opacity)&&void 0!==h?h:1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))this.exitNodes.push({type:"rect",x:e.x,y:e.y,w:null!==(u=e.w)&&void 0!==u?u:0,h:null!==(d=e.h)&&void 0!==d?d:0,style:{opacity:null!==(f=e.opacity)&&void 0!==f?f:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("w:")){const i=((null!==(g=e.startAngle)&&void 0!==g?g:0)+(null!==(y=e.endAngle)&&void 0!==y?y:0))/2,o={type:"wedge",cx:e.x,cy:e.y,innerRadius:null!==(p=e.innerRadius)&&void 0!==p?p:0,outerRadius:null!==(m=e.outerRadius)&&void 0!==m?m:100,startAngle:null!==(v=e.startAngle)&&void 0!==v?v:0,endAngle:null!==(x=e.endAngle)&&void 0!==x?x:0,style:{opacity:null!==(b=e.opacity)&&void 0!==b?b:1},datum:null,category:t.slice(2),_targetStartAngle:i,_targetEndAngle:i,_targetOpacity:0,_transitionKey:t};this.exitNodes.push(o)}A=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),A&&(this.activeTransition={startTime:Lt(),duration:k})}advanceTransition(t){var e,i,o,r;if(!this.activeTransition)return!1;const n=Tt(t,this.activeTransition),s=Ot(n,"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=Et(r,t._targetOpacity,s)}const o=this.prevPositionMap.get(e);void 0!==t._targetX&&o&&(t.x=Et(o.x,t._targetX,s),t.y=Et(o.y,t._targetY,s)),void 0!==t._targetR&&void 0!==(null==o?void 0:o.r)&&(t.r=Et(o.r,t._targetR,s))}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=Et(r,t._targetOpacity,s)}if(void 0===t._targetX)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=Et(i.x,t._targetX,s),t.y=Et(i.y,t._targetY,s),void 0!==i.w&&(t.w=Et(i.w,t._targetW,s),t.h=Et(i.h,t._targetH,s))}else if("wedge"===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=Object.assign(Object.assign({},t.style),{opacity:Et(o,t._targetOpacity,s)})}if(void 0!==t._targetStartAngle&&void 0!==t._targetEndAngle){const i=this.prevPositionMap.get(e);i&&void 0!==i.startAngle&&(t.startAngle=Et(i.startAngle,t._targetStartAngle,s),t.endAngle=Et(i.endAngle,t._targetEndAngle,s))}}}if(n>=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&&void 0===t._targetR)continue;void 0!==t._targetX&&(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"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=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._dataVersion++,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._dataVersion++,this.version++,n}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!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._pointQuadtree=null,this._maxPointRadius=0,this._dataVersion++,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(("colorScheme"in t&&t.colorScheme!==e.colorScheme||"themeCategorical"in t&&t.themeCategorical!==e.themeCategorical||"colorAccessor"in t&&!mt(t.colorAccessor,e.colorAccessor))&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),("categoryAccessor"in t&&!mt(t.categoryAccessor,e.categoryAccessor)||"oAccessor"in t&&!mt(t.oAccessor,e.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,t),("categoryAccessor"in t||"oAccessor"in t)&&(mt(t.categoryAccessor||t.oAccessor,e.categoryAccessor||e.oAccessor)||(this.getO=bt(this.config.categoryAccessor||this.config.oAccessor,"category"),this.categories.clear())),"valueAccessor"in t||"rAccessor"in t){const i=t.valueAccessor||t.rAccessor,o=e.valueAccessor||e.rAccessor,r=Array.isArray(i)?i:[i],n=Array.isArray(o)?o:[o];if(r.length!==n.length||r.some((t,e)=>!mt(t,n[e]))){const t=this.config.valueAccessor||this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>vt(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new yt)):(this.getR=vt(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!mt(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?bt(this.config.stackBy):void 0),"groupBy"in t&&!mt(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?bt(this.config.groupBy):void 0),"colorAccessor"in t&&!mt(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?bt(this.config.colorAccessor):void 0),"connectorAccessor"in t&&!mt(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?bt(this.config.connectorAccessor):void 0)}}ni.QUADTREE_THRESHOLD=500;const si={mercator:nt,equalEarth:tt,albersUsa:rt,orthographic:ot,naturalEarth:it,equirectangular:et};function ai(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function ci(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function li(t,e,i){return t?Object.assign(Object.assign({},i),"function"==typeof t?t(e):t):Object.assign({},i)}function hi(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 ui(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,h=(t[1]+e[1])/2+a*c,u=[];for(let o=0;i>=o;o++){const r=o/i,n=1-r;u.push([n*n*t[0]+2*n*r*l+r*r*e[0],n*n*t[1]+2*n*r*h+r*r*e[1]])}return u}function di(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 fi(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,h=r/2+1;return[[t[0]+c*h,t[1]+l*h],[e[0]+c*h,e[1]+l*h]]}class gi{constructor(t){this.scene=[],this.scales=null,this.version=0,this._quadtree=null,this._maxPointRadius=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._hasRenderedOnce=!1,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 gt(t),this.timestampBuffer=new gt(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._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.version++}computeScene(t){const{config:e}=this;this.projection=function(t){if(!t)return tt();if("string"==typeof t){const e=si[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),tt())}if("object"==typeof t&&"type"in t){const e=si[t.type],i=e?e():tt();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=Z(this.projection),this.fitProjection(t),this.geoPath=Z(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;if(this.scene=this.buildSceneNodes(t),this.rebuildQuadtree(),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&!this._hasRenderedOnce&&this.scene.length>0&&e.introAnimation){const e=t.width/2,i=t.height/2,o=this.scene.filter(t=>"point"===t.type).map(t=>Object.assign(Object.assign({},t),{x:e,y:i}));o.length>0&&this.startTransition(o)}this._hasRenderedOnce=!0,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=ai(a.xAccessor,"lon"),h=ai(a.yAccessor,"lat"),u=this.getPoints();if(u.length>0){const t=u.map(t=>[l(t),h(t)]);c.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const d=ci(a.lineDataAccessor);for(const t of this.lineData){const e=d(t);if(e&&e.length>0){const t=e.map(t=>[l(t),h(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=Z(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.rebuildQuadtree(),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=Z(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.rebuildQuadtree(),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=Z(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.rebuildQuadtree(),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}rebuildQuadtree(){let t=0,e=0;for(const i of this.scene)"point"===i.type&&(e++,i.r>t&&(t=i.r));if(this._maxPointRadius=t,gi.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const i=Array(e);let o=0;for(const t of this.scene)"point"===t.type&&(i[o++]=t);this._quadtree=l().x(t=>t.x).y(t=>t.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(t){var e,i,o;const r=[],{config:n}=this,s=this.projection,a=this.geoPath,c=ai(n.xAccessor,"lon"),l=ai(n.yAccessor,"lat"),h=function(t){var e,i;return{fill:(null===(e=t.themeSemantic)||void 0===e?void 0:e.surface)||"#e0e0e0",stroke:(null===(i=t.themeSemantic)||void 0===i?void 0:i.border)||"#999",strokeWidth:.5,fillOpacity:1}}(n),u=function(t){var e;return{stroke:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",strokeWidth:1.5,fill:"none"}}(n),d=function(t){var e;return{fill:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",r:4,fillOpacity:.8}}(n);if(n.graticule){const e=!0===n.graticule?{}:n.graticule,i=U();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=li(n.areaStyle,t,h);r.push({type:"geoarea",pathData:e,centroid:i,bounds:o,screenArea:s,style:c,datum:t,interactive:!0})}const f=ci(n.lineDataAccessor);for(const e of this.lineData){const i=f(e);if(!i||2>i.length)continue;let o=[];if("geo"===n.lineType){const t=Array(i.length);for(let e=0;i.length>e;e++)t[e]=[c(i[e]),l(i[e])];for(let e=0;t.length-1>e;e++){const i=t[e],r=t[e+1],n=K(i,r)||0,a=Math.max(2,Math.ceil(n/(Math.PI/180))),c=J(i,r);for(let t=0;a>=t;t++){if(e>0&&0===t)continue;const i=s(c(t/a));null!=i&&o.push(i)}}}else for(let t=0;i.length>t;t++){const e=i[t],r=s([c(e),l(e)]);null!=r&&o.push(r)}if(2>o.length)continue;const a=li(n.lineStyle,e,u),h="number"==typeof a.strokeWidth?a.strokeWidth:1;2!==i.length||2>o.length||"arc"!==n.flowStyle?2!==i.length||2>o.length||"offset"!==n.flowStyle||(o="geo"===n.lineType?di(o,h):fi(o[0],o[o.length-1],0,0,h)):o=ui(o[0],o[o.length-1]);const d=hi(o,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({},a),{_edgeFade:!0}),datum:e};r.push(i)}else r.push({type:"line",path:2>o.length&&d[0]||o,style:a,datum:e})}const g=this.getPoints(),y=n.pointIdAccessor?"function"==typeof n.pointIdAccessor?n.pointIdAccessor:t=>t[n.pointIdAccessor]:null,p=s.clipAngle&&null!==(e=s.clipAngle())&&void 0!==e?e:0,m=p>0?p*Math.PI/180:null,v=s.rotate?s.rotate():[0,0,0],x="function"==typeof s.center?s.center():[0,0],b=[(null!==(i=x[0])&&void 0!==i?i:0)-v[0],(null!==(o=x[1])&&void 0!==o?o:0)-v[1]];for(let t=0;g.length>t;t++){const e=g[t],i=c(e),o=l(e);if(null!=m&&K([i,o],b)>m)continue;const a=s([i,o]);if(!a)continue;const h=n.pointStyle?n.pointStyle(e):Object.assign({},d),u={type:"point",x:a[0],y:a[1],r:h.r||4,style:h,datum:e,pointId:y?y(e)+"":void 0};r.push(u)}return r}applyCartogramTransform(t,e){var i,o,r;const s=this.scene.filter(t=>"point"===t.type);if(2>s.length)return;const a=null!==(i=t.strength)&&void 0!==i?i:1;if(0===a)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],h=s.find(e=>e.datum&&c(e.datum)+""==t.center+"");if(!h)return void("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`));const u=h.x,d=h.y,f=s.map(t=>t.datum?l(t.datum):NaN).filter(t=>isFinite(t)&&t>=0),g=Math.max(...f,1),y=Math.min(e.width,e.height)/2,p=n().domain([0,g]).range([0,y]);this.cartogramLayout={cx:u,cy:d,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 s){if(t===h)continue;if(!t.datum)continue;const e=Math.atan2(t.y-d,t.x-u),i=Math.sqrt(Math.pow(t.x-u,2)+Math.pow(t.y-d,2)),o=l(t.datum),r=i+((isFinite(o)?p(o):i)-i)*a;t.x=u+Math.cos(e)*r,t.y=d+Math.sin(e)*r}const m=e.width/2,v=e.height/2,x=m-h.x,b=v-h.y;if(Math.abs(x)>.5||Math.abs(b)>.5)for(const t of s)t.x+=x,t.y+=b;this.cartogramLayout={cx:m,cy:v,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 s)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=Pt(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=Tt(t,this.activeTransition),i=Ot(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=Et(t.x,t._targetX,i),t.y=Et(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 yi(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}function pi(i,o){var r,n,s;switch(i.type){case"line":{const e=i;if(0===e.path.length)return null;const r="M"+e.path.map(([t,e])=>`${t},${e}`).join("L");return t("path",{d:r,fill:"none",stroke:e.style.stroke||"#4e79a7",strokeWidth:e.style.strokeWidth||2,strokeDasharray:e.style.strokeDasharray,opacity:e.style.opacity},"line-"+o)}case"area":{const e=i;if(0===e.topPath.length)return null;const s=e.topPath.map(([t,e])=>`${t},${e}`).join("L"),a=[...e.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return t("path",{d:`M${s}L${a}Z`,fill:yi(e.style.fill),fillOpacity:null!==(n=null!==(r=e.style.fillOpacity)&&void 0!==r?r:e.style.opacity)&&void 0!==n?n:.7,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"area-"+o)}case"point":{const e=i;return t("circle",{cx:e.x,cy:e.y,r:e.r,fill:yi(e.style.fill),opacity:null!==(s=e.style.opacity)&&void 0!==s?s:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"point-"+o)}case"rect":{const e=i;return t("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:yi(e.style.fill),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"rect-"+o)}case"heatcell":{const r=i;if(r.showValues&&null!=r.value&&r.w>=20&&r.h>=20){const i=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),[n,s,a]=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),c=.299*n+.587*s+.114*a>128?"#000":"#fff",l=Math.max(10,Math.min(16,.3*Math.min(r.w,r.h)));return e("g",{children:[t("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:r.fill}),t("text",{x:r.x+r.w/2,y:r.y+r.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:c,fontSize:l+"px",children:i})]},"heatcell-"+o)}return t("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:r.fill},"heatcell-"+o)}case"candlestick":{const r=i,n=Math.min(r.openY,r.closeY),s=Math.max(Math.abs(r.openY-r.closeY),1),a=r.isUp?r.upColor:r.downColor;return e("g",{children:[t("line",{x1:r.x,y1:r.highY,x2:r.x,y2:r.lowY,stroke:r.wickColor,strokeWidth:r.wickWidth}),t("rect",{x:r.x-r.bodyWidth/2,y:n,width:r.bodyWidth,height:s,fill:a,stroke:a,strokeWidth:1})]},"candle-"+o)}default:return null}}function mi(i,o){var r,n,s,a,c;const l=("category"in i?i.category:void 0)||("group"in i?i.group:void 0)||"",h=t=>`ord-${i.type}-${l}-${o}-${t}`,u=`ord-${i.type}-${l}-${o}`;switch(i.type){case"rect":{const o=i,r=function(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}(u)+"-grad",n=function(e,i){const o=e.fillGradient;if(!o)return null;let r=e.x,n=e.y,s=e.x,a=e.y+e.h;"bottom"===e.roundedEdge?(n=e.y+e.h,a=e.y):"right"===e.roundedEdge?(r=e.x+e.w,n=e.y,s=e.x,a=e.y):"left"===e.roundedEdge&&(r=e.x,n=e.y,s=e.x+e.w,a=e.y);const c=[];if("colorStops"in o){const e=o.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>e.length)return null;for(let i=0;e.length>i;i++)c.push(t("stop",{offset:e[i].offset,stopColor:e[i].color},i))}else{const i=yi(e.style.fill);c.push(t("stop",{offset:0,stopColor:i,stopOpacity:o.topOpacity},"0")),c.push(t("stop",{offset:1,stopColor:i,stopOpacity:o.bottomOpacity},"1"))}return t("linearGradient",{id:i,gradientUnits:"userSpaceOnUse",x1:r,y1:n,x2:s,y2:a,children:c})}(o,r),s=n?`url(#${r})`:yi(o.style.fill);if(o.roundedTop&&o.roundedTop>0){const i=Math.min(o.roundedTop,o.w/2,o.h/2),{x:r,y:a,w:c,h:l}=o;let h;switch(o.roundedEdge){case"right":h=`M${r},${a} L${r+c-i},${a} A${i},${i} 0 0 1 ${r+c},${a+i} L${r+c},${a+l-i} A${i},${i} 0 0 1 ${r+c-i},${a+l} L${r},${a+l} Z`;break;case"left":h=`M${r+c},${a} L${r+i},${a} A${i},${i} 0 0 0 ${r},${a+i} L${r},${a+l-i} A${i},${i} 0 0 0 ${r+i},${a+l} L${r+c},${a+l} Z`;break;case"bottom":h=`M${r},${a} L${r+c},${a} L${r+c},${a+l-i} A${i},${i} 0 0 1 ${r+c-i},${a+l} L${r+i},${a+l} A${i},${i} 0 0 1 ${r},${a+l-i} Z`;break;default:h=`M${r},${a+l} L${r},${a+i} A${i},${i} 0 0 1 ${r+i},${a} L${r+c-i},${a} A${i},${i} 0 0 1 ${r+c},${a+i} L${r+c},${a+l} Z`}return e(st.Fragment,{children:[n&&t("defs",{children:n}),t("path",{d:h,fill:s,opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},u)}return e(st.Fragment,{children:[n&&t("defs",{children:n}),t("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:s,opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},u)}case"point":{const e=i;return t("circle",{cx:e.x,cy:e.y,r:e.r,fill:yi(e.style.fill),opacity:null!==(r=e.style.opacity)&&void 0!==r?r:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},u)}case"wedge":{const e=i,o=F().innerRadius(e.innerRadius).outerRadius(e.outerRadius).startAngle(e.startAngle+Math.PI/2).endAngle(e.endAngle+Math.PI/2);e.cornerRadius&&o.cornerRadius(e.cornerRadius);const r=o({})||"";return t("path",{d:r,transform:`translate(${e.cx},${e.cy})`,fill:yi(e.style.fill),stroke:e.style.stroke,strokeWidth:e.style.strokeWidth,opacity:e.style.opacity},u)}case"boxplot":{const o=i,r=o.columnWidth/2;return e("g","vertical"===o.projection?{children:[t("line",{x1:o.x,y1:o.minPos,x2:o.x,y2:o.maxPos,stroke:o.style.stroke||"#333",strokeWidth:1}),t("rect",{x:o.x-r,y:Math.min(o.q1Pos,o.q3Pos),width:o.columnWidth,height:Math.abs(o.q3Pos-o.q1Pos),fill:yi(o.style.fill),fillOpacity:null!==(n=o.style.fillOpacity)&&void 0!==n?n:.6,stroke:o.style.stroke||"#333",strokeWidth:1}),t("line",{x1:o.x-r,y1:o.medianPos,x2:o.x+r,y2:o.medianPos,stroke:o.style.stroke||"#333",strokeWidth:2}),t("line",{x1:o.x-.5*r,y1:o.minPos,x2:o.x+.5*r,y2:o.minPos,stroke:o.style.stroke||"#333",strokeWidth:1}),t("line",{x1:o.x-.5*r,y1:o.maxPos,x2:o.x+.5*r,y2:o.maxPos,stroke:o.style.stroke||"#333",strokeWidth:1})]}:{children:[t("line",{x1:o.minPos,y1:o.y,x2:o.maxPos,y2:o.y,stroke:o.style.stroke||"#333",strokeWidth:1}),t("rect",{x:Math.min(o.q1Pos,o.q3Pos),y:o.y-r,width:Math.abs(o.q3Pos-o.q1Pos),height:o.columnWidth,fill:yi(o.style.fill),fillOpacity:null!==(s=o.style.fillOpacity)&&void 0!==s?s:.6,stroke:o.style.stroke||"#333",strokeWidth:1}),t("line",{x1:o.medianPos,y1:o.y-r,x2:o.medianPos,y2:o.y+r,stroke:o.style.stroke||"#333",strokeWidth:2}),t("line",{x1:o.minPos,y1:o.y-.5*r,x2:o.minPos,y2:o.y+.5*r,stroke:o.style.stroke||"#333",strokeWidth:1}),t("line",{x1:o.maxPos,y1:o.y-.5*r,x2:o.maxPos,y2:o.y+.5*r,stroke:o.style.stroke||"#333",strokeWidth:1})]},u)}case"violin":{const e=i,o=[t("path",{d:e.pathString,transform:e.translateX||e.translateY?`translate(${e.translateX},${e.translateY})`:void 0,fill:yi(e.style.fill),fillOpacity:null!==(a=e.style.fillOpacity)&&void 0!==a?a:.6,stroke:e.style.stroke||"#333",strokeWidth:e.style.strokeWidth||1},h("path"))];if(e.iqrLine&&e.bounds){const i=e.bounds,r=i.x+i.width/2,n=i.y+i.height/2;i.height>i.width?o.push(t("line",{x1:r,y1:e.iqrLine.q1Pos,x2:r,y2:e.iqrLine.q3Pos,stroke:e.style.stroke||"#333",strokeWidth:2},h("iqr")),t("circle",{cx:r,cy:e.iqrLine.medianPos,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},h("med"))):o.push(t("line",{x1:e.iqrLine.q1Pos,y1:n,x2:e.iqrLine.q3Pos,y2:n,stroke:e.style.stroke||"#333",strokeWidth:2},h("iqr")),t("circle",{cx:e.iqrLine.medianPos,cy:n,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},h("med")))}return t("g",{children:o},u)}case"connector":return t("line",{x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,stroke:i.style.stroke||"#999",strokeWidth:i.style.strokeWidth||1,opacity:null!==(c=i.style.opacity)&&void 0!==c?c:.5},u);case"trapezoid":{const e=i,o=e.points.map(t=>`${t[0]},${t[1]}`).join(" ");return t("polygon",{points:o,fill:yi(e.style.fill,"#999"),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},u)}default:return null}}function vi(t){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{categorical:xi})})),t.accessibility.highContrast){const t="dark"===e.mode;e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{text:t?"#ffffff":"#000000",textSecondary:t?"#cccccc":"#333333",grid:t?"#666666":"#999999",border:t?"#888888":"#000000"})})}return e}gi.QUADTREE_THRESHOLD=500;const xi=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],bi={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},ki={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},Ai={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:xi,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},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"};at(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:bi,setTheme(e){t(t=>{if("light"===e)return{theme:bi};if("dark"===e)return{theme:ki};if("high-contrast"===e)return{theme:Ai};if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?ki:bi;return{theme:vi(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:vi(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 wi={light:bi,dark:ki,"high-contrast":Ai,pastels:{mode:"light",colors:{primary:"#c9a0dc",secondary:"#b8a8c8",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",surface:"#fff5ee",text:"#4a3728",textSecondary:"#8b7355",grid:"#e8d5c4",border:"#e8d5c4",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#9ad4a3",danger:"#e8869a",warning:"#f0c888",error:"#c86070",info:"#9cb8e0"},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",secondary:"#a899c0",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",surface:"#251e35",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#88d4ab",danger:"#f0a0c0",warning:"#f0c888",error:"#e87690",info:"#9cb8e0"},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",secondary:"#6b7280",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",surface:"#ffffff",text:"#2c3e50",textSecondary:"#7f8c9b",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb",annotation:"#2563eb",success:"#10b981",danger:"#ef4444",warning:"#f59e0b",error:"#dc2626",info:"#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",secondary:"#9ca3af",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",surface:"#1f2937",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6",annotation:"#3b82f6",success:"#34d399",danger:"#f87171",warning:"#fbbf24",error:"#ef4444",info:"#60a5fa"},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",secondary:"#666666",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",surface:"#ffffff",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000",annotation:"#cc0000",success:"#556b2f",danger:"#cc0000",warning:"#c8a415",error:"#8b0000",info:"#4682b4"},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",secondary:"#aaaaaa",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",surface:"#1a1a1a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333",annotation:"#ff3333",success:"#7a8b5a",danger:"#ff3333",warning:"#d4a843",error:"#cc0000",info:"#6aa4d4"},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",secondary:"#555555",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",surface:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000",success:"#556b2f",danger:"#8b0000",warning:"#b88700",error:"#6b0000",info:"#4a5568"},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",secondary:"#a09880",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",surface:"#262520",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050",annotation:"#c05050",success:"#7a8b5a",danger:"#c05050",warning:"#c8a060",error:"#a04040",info:"#8090a0"},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",secondary:"#666666",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",surface:"#f8f8f8",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#e45050",success:"#2d7a3d",danger:"#c8303a",warning:"#d4a843",error:"#a02028",info:"#3a86c8"},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",secondary:"#a0a0a0",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",surface:"#1e1e1e",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b",annotation:"#ff6b6b",success:"#6fba78",danger:"#ff6b6b",warning:"#e0c060",error:"#d04040",info:"#5a9fd8"},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",secondary:"#7c5a9e",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",surface:"#ffffff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6",annotation:"#8b5cf6",success:"#10d870",danger:"#ff4b6e",warning:"#ffaa33",error:"#e11d48",info:"#06b6d4"},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",secondary:"#b8a0d8",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",surface:"#1f1138",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa",annotation:"#a78bfa",success:"#4ade80",danger:"#fb7185",warning:"#fbbf24",error:"#f43f5e",info:"#22d3ee"},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",secondary:"#525252",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe",annotation:"#0f62fe",success:"#24a148",danger:"#da1e28",warning:"#f1c21b",error:"#a2191f",info:"#0043ce"},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",secondary:"#a8a8a8",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",surface:"#262626",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff",annotation:"#4589ff",success:"#42be65",danger:"#fa4d56",warning:"#f1c21b",error:"#da1e28",info:"#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 bi;if("string"==typeof t){if("light"===t)return bi;if("dark"===t)return ki;if("high-contrast"===t)return Ai;return wi[t]||bi}const e="dark"===t.mode?ki:bi;return vi(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 _i(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 Pi(i){const{categories:o,colorScheme:n,theme:s,position:a="right",totalWidth:c,totalHeight:l,margin:h,hasTitle:u=!1}=i;if(!o||0===o.length)return null;const d=function(t,e,i){const o=Array.isArray(e)?e:i.colors.categorical.length>0?i.colors.categorical:x;return r().domain(t).range(o)}(o,n,s),f="top"===a||"bottom"===a;let g,y;if("left"===a?(g=4,y=h.top):"top"===a?(g=h.left,y=u?32:8):"bottom"===a?(g=h.left,y=Math.min(l-h.bottom+38,l-16)):(g=c-h.right+10,y=h.top),f){let i=0;const r=o.map((o,r)=>{const n=i;return i+=22+6.5*o.length+8,e("g",{transform:`translate(${n},0)`,children:[t("rect",{width:14,height:14,fill:d(o),rx:2}),t("text",{x:20,y:7,dominantBaseline:"central",fontSize:s.typography.tickSize,fill:s.colors.text,fontFamily:s.typography.fontFamily,children:o})]},"legend-"+r)});return t("g",{className:"semiotic-legend",transform:`translate(${g},${y})`,children:r})}const p=o.map((i,o)=>e("g",{transform:`translate(0,${20*o})`,children:[t("rect",{width:14,height:14,fill:d(i),rx:2}),t("text",{x:20,y:7,dominantBaseline:"central",fontSize:s.typography.tickSize,fill:s.colors.text,fontFamily:s.typography.fontFamily,children:i})]},"legend-"+o));return t("g",{className:"semiotic-legend",transform:`translate(${g},${y})`,children:p})}function Mi(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 Oi(t,e){return t.color||e.colors.annotation||e.colors.text}function Ti(e){const{annotations:i}=e;if(!i||0===i.length)return null;const o=[];for(let t=0;i.length>t;t++){const r=Ei(i[t],t,e);r&&o.push(r)}return o.length>0?t("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:o}):null}function Ei(i,o,r){var n,s,a,c;const{scales:l,layout:h,theme:u,xAccessor:d,yAccessor:f}=r;switch(i.type){case"y-threshold":{const s=i.value;if(null==s)return null;const a=Oi(i,u),c=i.label,d=i.labelPosition||"right",f=i.strokeDasharray||"6,4",g=null!==(n=i.strokeWidth)&&void 0!==n?n:1.5;if("horizontal"===r.projection&&l.r){const i=l.r(s);return null==i?null:e("g",{children:[t("line",{x1:i,y1:0,x2:i,y2:h.height,stroke:a,strokeWidth:g,strokeDasharray:f}),c&&t("text",{x:i+4,y:12,textAnchor:"start",fontSize:u.typography.tickSize,fill:a,fontFamily:u.typography.fontFamily,children:c})]},"ann-ythresh-"+o)}const y=l.y?l.y(s):l.r?l.r(s):null;return null==y?null:e("g",{children:[t("line",{x1:0,y1:y,x2:h.width,y2:y,stroke:a,strokeWidth:g,strokeDasharray:f}),c&&t("text",{x:"left"===d?4:"center"===d?h.width/2:h.width-4,y:y-6,textAnchor:"left"===d?"start":"center"===d?"middle":"end",fontSize:u.typography.tickSize,fill:a,fontFamily:u.typography.fontFamily,children:c})]},"ann-ythresh-"+o)}case"x-threshold":{const r=i.value;if(null==r||!l.x)return null;const n=l.x(r);if(null==n)return null;const a=Oi(i,u),c=i.label,d=i.labelPosition||"top",f=null!==(s=i.strokeWidth)&&void 0!==s?s:1.5;return e("g",{children:[t("line",{x1:n,y1:0,x2:n,y2:h.height,stroke:a,strokeWidth:f,strokeDasharray:i.strokeDasharray||"6,4"}),c&&t("text",{x:n+4,y:"bottom"===d?h.height-4:"center"===d?h.height/2:12,textAnchor:"start",fontSize:u.typography.tickSize,fill:a,fontFamily:u.typography.fontFamily,children:c})]},"ann-xthresh-"+o)}case"band":{const r=null!=i.y0&&l.y?l.y(i.y0):null,n=null!=i.y1&&l.y?l.y(i.y1):null;if(null==r||null==n)return null;const s=Math.min(r,n),c=Math.abs(n-r),d=i.fill||Oi(i,u),f=null!==(a=i.opacity)&&void 0!==a?a:.1;return e("g",{children:[t("rect",{x:0,y:s,width:h.width,height:c,fill:d,opacity:f}),i.label&&t("text",{x:h.width-4,y:s+12,textAnchor:"end",fontSize:u.typography.tickSize,fill:d,fontFamily:u.typography.fontFamily,children:i.label})]},"ann-band-"+o)}case"category-highlight":{if(!i.category||!l.o)return null;const e=l.o(i.category);if(null==e)return null;const n=l.o.bandwidth?l.o.bandwidth():40,s=Oi(i,u),a=null!==(c=i.opacity)&&void 0!==c?c:.1;return t("rect","horizontal"===r.projection?{x:0,y:e,width:h.width,height:n,fill:s,opacity:a}:{x:e,y:0,width:n,height:h.height,fill:s,opacity:a},"ann-cathighlight-"+o)}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}(i,l,d),n=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}(i,l,f);if(null==r||null==n)return null;const s=i.dx||0,a=i.dy||0,c=i.color||u.colors.text;return e("g",{children:["label"===i.type&&t("line",{x1:r,y1:n,x2:r+s,y2:n+a,stroke:u.colors.textSecondary,strokeWidth:1}),t("text",{x:r+s,y:n+a,textAnchor:i.textAnchor||"start",fontSize:i.fontSize||u.typography.labelSize,fill:c,fontFamily:u.typography.fontFamily,fontWeight:i.fontWeight,children:i.label||i.title})]},"ann-label-"+o)}default:return null}}const Li={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)},CandlestickChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"candlestick",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.highAccessor||"high",highAccessor:r.highAccessor||"high",lowAccessor:r.lowAccessor||"low",openAccessor:r.openAccessor,closeAccessor:r.closeAccessor,candlestickStyle:r.candlestickStyle},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,h=null!==(s=r.max)&&void 0!==s?s:100,u=null!==(a=r.sweep)&&void 0!==a?a:240,d=null!==(c=r.arcWidth)&&void 0!==c?c:.3,f=180+(360-u)/2,g=r.thresholds||[{value:h,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},[v,x]=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(v-(m.left||0)-(m.right||0),x-(m.top||0)-(m.bottom||0))/2*(1-d)),sweepAngle:u,startAngle:f,oSort:!1,pieceStyle:(t,e)=>({fill:p[e||""]||"#4e79a7"})},o),{showAxes:!1,__gauge:{gMin:l,gMax:h,sweep:u,arcWidth:d,value:r.value,startAngleDeg:f,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)},FlowMap:{frameType:"geo",buildProps:(t,e,i,o,r)=>{var n,s,a,c,l;const h=(Array.isArray(t)?t:null)||r.flows||[],u=r.nodeIdAccessor||"id",d=r.valueAccessor||"value",f=r.xAccessor||"lon",g=r.yAccessor||"lat",y="function"==typeof f?f:t=>t[f],p="function"==typeof g?g:t=>t[g],m=(r.nodes||[]).map(t=>Object.assign(Object.assign({},t),{x:y(t),y:p(t)})),v=new Map;for(const t of m)v.set(t[u]+"",t);const x=null!==(n=r.edgeColorBy)&&void 0!==n?n:e,b="function"==typeof x,k=h.map(t=>{if(!t||null==t.source||null==t.target)return null;const e=v.get(t.source+""),i=v.get(t.target+"");return e&&i?Object.assign(Object.assign({},t),{coordinates:[{x:e.x,y:e.y},{x:i.x,y:i.y}]}):null}).filter(Boolean),A="__flowMapEdgeColor",w=x?b?_t(k.map(t=>({[A]:x(t)})),A,i||"category10"):_t(k,x,i||"category10"):null,S=t=>x&&w?function(t,e,i){if("function"==typeof e){const o=e(t);return i&&o&&"string"==typeof o&&!function(t){const e=t.toLowerCase();return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")||St.has(e)}(o)?i(o):o}const o=null==t?void 0:t[e];return i?i(o):At[Math.abs(function(t){let e=0;for(let i=0;t.length>i;i++)e=(e<<5)-e+t.charCodeAt(i),e&=e;return Math.abs(e)}(o+""))%At.length]}(t,x,w):"#007bff";let _=1/0,P=-1/0;for(const t of k){const e=Number(null!==(s=t[d])&&void 0!==s?s:0);isFinite(e)&&(_>e&&(_=e),e>P&&(P=e))}const M=P>_?P-_:0,[O,T]=null!==(a=r.edgeWidthRange)&&void 0!==a?a:[1,8],E=T-O,L=null!==(c=r.edgeOpacity)&&void 0!==c?c:.6,D=null!==(l=r.edgeLinecap)&&void 0!==l?l:"round";return Object.assign({lines:k,points:m,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:r.lineType||"geo",flowStyle:r.flowStyle||"basic",areas:r.areas,areaStyle:r.areaStyle,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding,colorScheme:i,lineStyle:t=>{const e=Number(null==t?void 0:t[d]),i=O+Math.max(0,Math.min(1,M>0?((Number.isFinite(e)?e:_)-_)/M:0))*E;return{stroke:S(t),strokeWidth:i,strokeLinecap:D,opacity:L,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8})},o)}}};function Di(t){return Math.round(100*t)/100+""}function ji(i,o){const r=_i(o.theme),n=o.idPrefix?o.idPrefix+"-":"",s="string"==typeof o.title?o.title:void 0,a=s?n+"semiotic-title":void 0,c=o.description?n+"semiotic-desc":void 0,l=[a,c].filter(Boolean).join(" ")||void 0;return e("svg",{xmlns:"http://www.w3.org/2000/svg",className:o.className,width:o.width,height:o.height,role:"img","aria-labelledby":l,style:{fontFamily:r.fontFamily},children:[s&&t("title",{id:a,children:s}),o.description&&t("desc",{id:c,children:o.description}),o.defs&&t("defs",{children:o.defs}),o.background&&"transparent"!==o.background&&t("rect",{x:0,y:0,width:o.width,height:o.height,fill:o.background}),t("g",{id:n+"data-area",transform:o.innerTransform,children:i}),s&&t("text",{id:n+"chart-title",x:o.width/2,y:16,textAnchor:"middle",fontSize:r.titleSize,fontWeight:"bold",fill:r.text,fontFamily:r.fontFamily,children:s}),o.legend&&t("g",{id:n+"legend",children:o.legend}),o.outerElements]})}function zi(r){var n,s,a,c;const l=Si(r.theme),h=r.size||[500,300],u=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),r.margin),d=r.legendPosition;r.showLegend&&(d&&"right"!==d?"left"===d?u.left=Math.max(u.left,100):"bottom"===d?u.bottom=Math.max(u.bottom,70):"top"===d&&(u.top=Math.max(u.top,40)):u.right=Math.max(u.right,100));const f=h[0]-u.left-u.right,g=h[1]-u.top-u.bottom,y="streaming"===r.runtimeMode||["bar","swarm","waterfall"].includes(r.chartType),p={chartType:r.chartType,windowSize:null!==(n=r.windowSize)&&void 0!==n?n:200,windowMode:null!==(s=r.windowMode)&&void 0!==s?s:"sliding",arrowOfTime:y&&null!==(a=r.arrowOfTime)&&void 0!==a?a:"right",extentPadding:null!==(c=r.extentPadding)&&void 0!==c?c:.1,xAccessor:y?void 0:r.xAccessor,yAccessor:y?void 0:r.yAccessor,timeAccessor:y?r.timeAccessor:void 0,valueAccessor:r.valueAccessor,colorAccessor:r.colorAccessor,sizeAccessor:r.sizeAccessor,groupAccessor:r.groupAccessor,categoryAccessor:r.categoryAccessor,lineDataAccessor:r.lineDataAccessor,xExtent:r.xExtent,yExtent:r.yExtent,sizeRange:r.sizeRange,binSize:r.binSize,normalize:r.normalize,boundsAccessor:r.boundsAccessor,boundsStyle:r.boundsStyle,openAccessor:r.openAccessor,highAccessor:r.highAccessor,lowAccessor:r.lowAccessor,closeAccessor:r.closeAccessor,candlestickStyle:r.candlestickStyle,lineStyle:r.lineStyle,pointStyle:r.pointStyle,areaStyle:r.areaStyle,colorScheme:r.colorScheme||l.colors.categorical,barColors:r.barColors},m=new Yt(p);if(r.data&&m.ingest({inserts:r.data,bounded:!0}),m.computeScene({width:f,height:g}),!m.scales||0===m.scene.length)return o.renderToStaticMarkup(ji(null,{width:h[0],height:h[1],className:"stream-xy-frame"+(r.className?" "+r.className:""),title:r.title,description:r.description,background:r.background,theme:l,innerTransform:`translate(${u.left},${u.top})`,idPrefix:r._idPrefix}));const v=r._idPrefix,x=r.showGrid?function(i,o,r,n){const{grid:s}=_i(r),a=n?n+"-":"",c=i.x.ticks(5),l=i.y.ticks(5);return e("g",{id:a+"grid",className:"semiotic-grid",opacity:.8,children:[c.map((e,r)=>{const n=i.x(e);return t("line",{x1:n,y1:0,x2:n,y2:o.height,stroke:s,strokeWidth:.5},"gx-"+r)}),l.map((e,r)=>{const n=i.y(e);return t("line",{x1:0,y1:n,x2:o.width,y2:n,stroke:s,strokeWidth:.5},"gy-"+r)})]})}(m.scales,{width:f,height:g},l,v):null,b=m.scene.map((t,e)=>pi(t,e)).filter(Boolean),k=!1!==r.showAxes?function(i,o,r,n,s){var a,c,l,h;const u=_i(n),d=i.x.ticks(5).map(t=>({pixel:i.x(t),label:(r.xFormat||r.tickFormatTime||Di)(t)})),f=i.y.ticks(5).map(t=>({pixel:i.y(t),label:(r.yFormat||r.tickFormatValue||Di)(t)}));return e("g",{id:(s?s+"-":"")+"axes",className:"stream-axes",children:[t("line",{x1:0,y1:o.height,x2:o.width,y2:o.height,stroke:u.border,strokeWidth:1}),d.map((i,r)=>e("g",{transform:`translate(${i.pixel},${o.height})`,children:[t("line",{y2:5,stroke:u.border,strokeWidth:1}),t("text",{y:18,textAnchor:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:i.label})]},"xtick-"+r)),r.xLabel&&t("text",{x:o.width/2,y:o.height+40,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,children:r.xLabel}),t("line",{x1:0,y1:0,x2:0,y2:o.height,stroke:u.border,strokeWidth:1}),f.map((i,o)=>e("g",{transform:`translate(0,${i.pixel})`,children:[t("line",{x2:-5,stroke:u.border,strokeWidth:1}),t("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:i.label})]},"ytick-"+o)),r.yLabel&&t("text",{x:15-(null!==(c=null===(a=r.margin)||void 0===a?void 0:a.left)&&void 0!==c?c:40),y:o.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-(null!==(h=null===(l=r.margin)||void 0===l?void 0:l.left)&&void 0!==h?h:40)}, ${o.height/2})`,children:r.yLabel})]})}(m.scales,{width:f,height:g},r,l,v):null,A=r.annotations?Ti({annotations:r.annotations,scales:{x:m.scales.x,y:m.scales.y},layout:{width:f,height:g},theme:l,xAccessor:"string"==typeof r.xAccessor?r.xAccessor:void 0,yAccessor:"string"==typeof r.yAccessor?r.yAccessor:void 0,idPrefix:v}):null,w=r.showLegend?(()=>{const t=Mi(r.data||[],r.colorAccessor||r.groupAccessor);return 0===t.length?null:Pi({categories:t,colorScheme:r.colorScheme,theme:l,position:r.legendPosition||"right",totalWidth:h[0],totalHeight:h[1],margin:u,hasTitle:!!r.title})})():null,S=e(i,{children:[x,A,b,k]});return o.renderToStaticMarkup(ji(S,{width:h[0],height:h[1],className:"stream-xy-frame"+(r.className?" "+r.className:""),title:r.title,description:r.description,background:r.background,theme:l,innerTransform:`translate(${u.left},${u.top})`,legend:w,idPrefix:r._idPrefix}))}function $i(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const Ri=new Set(["tree","cluster","treemap","circlepack","partition"]);function Ci(r){const n=Si(r.theme),s=r.chartType||"force",a=r.size||[500,500],c=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),r.margin),l=a[0]-c.left-c.right,h=a[1]-c.top-c.bottom,u=function(t){return ei[t]}(s);if(!u)throw Error(`No layout plugin found for chart type: "${s}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const d={chartType:s,nodeIDAccessor:r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,valueAccessor:r.valueAccessor,childrenAccessor:r.childrenAccessor,hierarchySum:r.hierarchySum,orientation:r.orientation,nodeAlign:r.nodeAlign,nodePaddingRatio:r.nodePaddingRatio,nodeWidth:r.nodeWidth,iterations:r.iterations,forceStrength:r.forceStrength,padAngle:r.padAngle,groupWidth:r.groupWidth,sortGroups:r.sortGroups,edgeSort:r.edgeSort,treeOrientation:r.treeOrientation,edgeType:r.edgeType,padding:r.padding,paddingTop:r.paddingTop,nodeStyle:r.nodeStyle,edgeStyle:r.edgeStyle,nodeLabel:r.nodeLabel,showLabels:r.showLabels,colorBy:r.colorBy,colorScheme:r.colorScheme||n.colors.categorical,edgeColorBy:r.edgeColorBy,edgeOpacity:r.edgeOpacity,colorByDepth:r.colorByDepth,nodeSize:r.nodeSize,nodeSizeRange:r.nodeSizeRange};let f,g;if(Ri.has(s)){const t=r.data||r.edges;if(!t||Array.isArray(t))return o.renderToStaticMarkup(ji(null,{width:a[0],height:a[1],className:"stream-network-frame"+(r.className?" "+r.className:""),title:r.title,description:r.description,background:r.background,theme:n,innerTransform:`translate(${c.left},${c.top})`,idPrefix:r._idPrefix}));d.__hierarchyRoot=t,f=[],g=[]}else{const t=r.nodes||[],e=Array.isArray(r.edges)?r.edges:[];if(0===t.length&&0===e.length)return o.renderToStaticMarkup(ji(null,{width:a[0],height:a[1],className:"stream-network-frame"+(r.className?" "+r.className:""),title:r.title,description:r.description,background:r.background,theme:n,innerTransform:`translate(${c.left},${c.top})`,idPrefix:r._idPrefix}));if(g=function(t,e){const i=$i(e.sourceAccessor,"source"),o=$i(e.targetAccessor,"target"),r=$i(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}))}(e,d),0===t.length&&g.length>0){const t=new Set;for(const e of g){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)}f=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 f=function(t,e){const i=$i(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,d)}u.computeLayout(f,g,d,[l,h]);const{sceneNodes:y,sceneEdges:p,labels:m}=u.buildScene(f,g,d,[l,h]),v=_i(n);for(const t of m)t.fill||(t.fill=v.text);const x=p.map((e,i)=>function(e,i){switch(e.type){case"line":return t("line",{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},"net-edge-"+i);case"bezier":{const o=e;return t("path",{d:o.pathD,fill:yi(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+i)}case"ribbon":{const o=e;return t("path",{d:o.pathD,fill:yi(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+i)}case"curved":{const o=e;return t("path",{d:o.pathD,fill:yi(o.style.fill,"none"),stroke:o.style.stroke||"#999",strokeWidth:o.style.strokeWidth||1,opacity:o.style.opacity},"net-edge-"+i)}default:return null}}(e,i)).filter(Boolean),b=y.map((e,i)=>function(e,i){switch(e.type){case"circle":{const o=e;return t("circle",{cx:o.cx,cy:o.cy,r:o.r,fill:yi(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-circle-"+i)}case"rect":{const o=e;return t("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:yi(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-rect-"+i)}case"arc":{const o=e,r=F().innerRadius(o.innerR).outerRadius(o.outerR).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2)({})||"";return t("path",{d:r,transform:`translate(${o.cx},${o.cy})`,fill:yi(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-arc-"+i)}default:return null}}(e,i)).filter(Boolean),k=m.map((e,i)=>function(e,i){return t("text",{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,children:e.text},"net-label-"+i)}(e,i)).filter(Boolean),A=e(i,{children:[x,b,k]});return o.renderToStaticMarkup(ji(A,{width:a[0],height:a[1],className:"stream-network-frame"+(r.className?" "+r.className:""),title:r.title,description:r.description,background:r.background,theme:n,innerTransform:`translate(${c.left},${c.top})`,idPrefix:r._idPrefix}))}function Ni(r){var n,s,a,c,l;const h=Si(r.theme),u=r.size||[500,400],d=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),r.margin),f=r.legendPosition;r.showLegend&&(f&&"right"!==f?"left"===f?d.left=Math.max(d.left,100):"bottom"===f?d.bottom=Math.max(d.bottom,70):"top"===f&&(d.top=Math.max(d.top,40)):d.right=Math.max(d.right,100));const g=u[0]-d.left-d.right,y=u[1]-d.top-d.bottom,p=r.projection||"vertical",m="radial"===p,v={chartType:r.chartType,windowSize:null!==(n=r.windowSize)&&void 0!==n?n:1e4,windowMode:null!==(s=r.windowMode)&&void 0!==s?s:"sliding",extentPadding:null!==(a=r.extentPadding)&&void 0!==a?a:.05,projection:p,oAccessor:r.oAccessor,rAccessor:r.rAccessor,colorAccessor:r.colorAccessor,stackBy:r.stackBy,groupBy:r.groupBy,categoryAccessor:r.categoryAccessor,valueAccessor:r.valueAccessor,timeAccessor:r.timeAccessor,rExtent:r.rExtent,oExtent:r.oExtent,barPadding:r.barPadding,roundedTop:r.roundedTop,innerRadius:r.innerRadius,cornerRadius:r.cornerRadius,normalize:r.normalize,startAngle:r.startAngle,sweepAngle:r.sweepAngle,bins:r.bins,showOutliers:r.showOutliers,showIQR:r.showIQR,amplitude:r.amplitude,oSort:r.oSort,connectorAccessor:r.connectorAccessor,connectorStyle:r.connectorStyle,dynamicColumnWidth:r.dynamicColumnWidth,pieceStyle:r.pieceStyle,summaryStyle:r.summaryStyle,colorScheme:r.colorScheme||h.colors.categorical,barColors:r.barColors},x=new ni(v);if(r.data&&x.ingest({inserts:r.data,bounded:!0}),x.computeScene({width:g,height:y}),!x.scales||0===x.scene.length)return o.renderToStaticMarkup(ji(null,{width:u[0],height:u[1],className:"stream-ordinal-frame"+(r.className?" "+r.className:""),title:r.title,description:r.description,background:r.background,theme:h,innerTransform:`translate(${d.left},${d.top})`,idPrefix:r._idPrefix}));const b=r._idPrefix,k=r.showGrid?function(e,i,o,r){const n=e.scales;if(!n||"radial"===n.projection)return null;const{grid:s}=_i(o),a=r?r+"-":"",c="vertical"===n.projection,l=n.r.ticks(5);return t("g",c?{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,o)=>{const r=n.r(e);return t("line",{x1:0,y1:r,x2:i.width,y2:r,stroke:s,strokeWidth:.5},"gr-"+o)})}:{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,o)=>{const r=n.r(e);return t("line",{x1:r,y1:0,x2:r,y2:i.height,stroke:s,strokeWidth:.5},"gr-"+o)})})}(x,{width:g,height:y},h,b):null,A=x.scene.some(t=>{var e;return"rect"===t.type&&(null===(e=t.datum)||void 0===e?void 0:e.__barFunnelIsDropoff)});let w=null;if(A){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)}(r),o=new Set;for(const t of x.scene)"rect"===t.type&&(null===(c=t.datum)||void 0===c?void 0:c.__barFunnelIsDropoff)&&o.add("string"==typeof t.style.fill?t.style.fill:"#666");w=Array.from(o).map((o,r)=>function(i){const{id:o,background:r="transparent",stroke:n="#000",lineWidth:s=1.5,spacing:a=6,angle:c=45}=i,l=Math.max(8,Math.ceil(2*a));return e("pattern",{id:o,width:l,height:l,patternUnits:"userSpaceOnUse",patternTransform:0!==c?`rotate(${c})`:void 0,children:[r&&"transparent"!==r&&t("rect",{width:l,height:l,fill:r}),t("line",{x1:0,y1:0,x2:0,y2:l,stroke:n,strokeWidth:s}),t("line",{x1:a,y1:0,x2:a,y2:l,stroke:n,strokeWidth:s})]},o)}({id:`funnel-hatch-${i}-${r}`,background:o,stroke:"transparent"===h.colors.background?"#fff":h.colors.background,lineWidth:1.5,spacing:5,angle:45}));const n=new Map;Array.from(o).forEach((t,e)=>n.set(t,`funnel-hatch-${i}-${e}`));for(const t of x.scene)if("rect"===t.type&&(null===(l=t.datum)||void 0===l?void 0:l.__barFunnelIsDropoff)){const e="string"==typeof t.style.fill?t.style.fill:"#666";t.style=Object.assign(Object.assign({},t.style),{fill:`url(#${n.get(e)})`})}}const S=x.scene.map((t,e)=>mi(t,e)).filter(Boolean),_=!1!==r.showAxes?function(i,o,r,n,s){var a,c,l,h,u,d,f,g;const y=i.scales;if(!y)return null;if("radial"===y.projection)return null;const p=_i(n),m="vertical"===y.projection,v=r.categoryFormat||r.oFormat,x=r.valueFormat||r.rFormat,b=r.categoryLabel||r.oLabel,k=r.valueLabel||r.rLabel,A=Object.values(i.columns).map(t=>({pixel:t.middle,label:(v||String)(t.name)})),w=y.r.ticks(5).map(t=>({pixel:y.r(t),label:(x||Di)(t)}));return e("g",m?{id:(s?s+"-":"")+"axes",className:"ordinal-axes",children:[t("line",{x1:0,y1:o.height,x2:o.width,y2:o.height,stroke:p.border,strokeWidth:1}),A.map((i,r)=>e("g",{transform:`translate(${i.pixel},${o.height})`,children:[t("line",{y2:5,stroke:p.border,strokeWidth:1}),t("text",{y:18,textAnchor:"middle",fontSize:p.tickSize,fill:p.textSecondary,fontFamily:p.fontFamily,children:i.label})]},"oxtick-"+r)),b&&t("text",{x:o.width/2,y:o.height+40,textAnchor:"middle",fontSize:p.labelSize,fill:p.text,fontFamily:p.fontFamily,children:b}),t("line",{x1:0,y1:0,x2:0,y2:o.height,stroke:p.border,strokeWidth:1}),w.map((i,o)=>e("g",{transform:`translate(0,${i.pixel})`,children:[t("line",{x2:-5,stroke:p.border,strokeWidth:1}),t("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:p.tickSize,fill:p.textSecondary,fontFamily:p.fontFamily,children:i.label})]},"oytick-"+o)),k&&t("text",{x:15-(null!==(c=null===(a=r.margin)||void 0===a?void 0:a.left)&&void 0!==c?c:40),y:o.height/2,textAnchor:"middle",fontSize:p.labelSize,fill:p.text,fontFamily:p.fontFamily,transform:`rotate(-90, ${15-(null!==(h=null===(l=r.margin)||void 0===l?void 0:l.left)&&void 0!==h?h:40)}, ${o.height/2})`,children:k})]}:{id:(s?s+"-":"")+"axes",className:"ordinal-axes",children:[t("line",{x1:0,y1:o.height,x2:o.width,y2:o.height,stroke:p.border,strokeWidth:1}),w.map((i,r)=>e("g",{transform:`translate(${i.pixel},${o.height})`,children:[t("line",{y2:5,stroke:p.border,strokeWidth:1}),t("text",{y:18,textAnchor:"middle",fontSize:p.tickSize,fill:p.textSecondary,fontFamily:p.fontFamily,children:i.label})]},"oxtick-"+r)),k&&t("text",{x:o.width/2,y:o.height+40,textAnchor:"middle",fontSize:p.labelSize,fill:p.text,fontFamily:p.fontFamily,children:k}),t("line",{x1:0,y1:0,x2:0,y2:o.height,stroke:p.border,strokeWidth:1}),A.map((i,o)=>e("g",{transform:`translate(0,${i.pixel})`,children:[t("line",{x2:-5,stroke:p.border,strokeWidth:1}),t("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:p.tickSize,fill:p.textSecondary,fontFamily:p.fontFamily,children:i.label})]},"oytick-"+o)),b&&t("text",{x:15-(null!==(d=null===(u=r.margin)||void 0===u?void 0:u.left)&&void 0!==d?d:40),y:o.height/2,textAnchor:"middle",fontSize:p.labelSize,fill:p.text,fontFamily:p.fontFamily,transform:`rotate(-90, ${15-(null!==(g=null===(f=r.margin)||void 0===f?void 0:f.left)&&void 0!==g?g:40)}, ${o.height/2})`,children:b})]})}(x,{width:g,height:y},r,h,b):null,P=r.annotations?Ti({annotations:r.annotations,scales:{r:x.scales.r,y:"vertical"===x.scales.projection?x.scales.r:void 0},layout:{width:g,height:y},theme:h,projection:p,idPrefix:b}):null,M=r.showLegend?(()=>{const t=Mi(r.data||[],r.colorAccessor||r.stackBy||r.groupBy);return 0===t.length?null:Pi({categories:t,colorScheme:r.colorScheme,theme:h,position:r.legendPosition||"right",totalWidth:u[0],totalHeight:u[1],margin:d,hasTitle:!!r.title})})():null,O=m?d.left+g/2:d.left,T=m?d.top+y/2:d.top,E=e(i,{children:[k,P,S,_]});return o.renderToStaticMarkup(ji(E,{width:u[0],height:u[1],className:"stream-ordinal-frame"+(r.className?" "+r.className:""),title:r.title,description:r.description,background:r.background,theme:h,innerTransform:`translate(${O},${T})`,legend:M,defs:w,idPrefix:r._idPrefix}))}function Wi(e){var r,n,s,a,c,l,h,u;const d=Si(e.theme),f=e.size||[e.width||600,e.height||400],g=Object.assign(Object.assign({},{top:10,right:10,bottom:10,left:10}),e.margin),y=f[0]-(null!==(r=g.left)&&void 0!==r?r:0)-(null!==(n=g.right)&&void 0!==n?n:0),p=f[1]-(null!==(s=g.top)&&void 0!==s?s:0)-(null!==(a=g.bottom)&&void 0!==a?a:0),m=new gi({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.`);m.setAreas(e.areas)}if(e.points&&m.setPoints(e.points),e.lines&&m.setLines(e.lines),m.computeScene({width:y,height:p}),0===m.scene.length)return o.renderToStaticMarkup(ji(null,{width:f[0],height:f[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:d,innerTransform:`translate(${null!==(c=g.left)&&void 0!==c?c:0},${null!==(l=g.top)&&void 0!==l?l:0})`,idPrefix:e._idPrefix}));const v=m.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("path",{d:n.pathData,fill:yi(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},"geoarea-"+i):null}case"point":{const o=e;return t("circle",{cx:o.x,cy:o.y,r:o.r,fill:yi(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},"point-"+i)}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("path",{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},"line-"+i)}default:return null}}(e,i)).filter(Boolean),x=t(i,{children:v});return o.renderToStaticMarkup(ji(x,{width:f[0],height:f[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:d,innerTransform:`translate(${null!==(h=g.left)&&void 0!==h?h:0},${null!==(u=g.top)&&void 0!==u?u:0})`,idPrefix:e._idPrefix}))}function Bi(t,e){switch(t){case"xy":return zi(e);case"ordinal":return Ni(e);case"network":return Ci(e);case"geo":return Wi(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", or "geo".`)}}function Fi(t){return zi(t)}function Yi(t){return Ni(t)}function Ii(t){return Ci(t)}function Xi(t){return Wi(t)}function qi(r,n,s){var a;const{data:c,width:l=600,height:h=400,theme:u,title:d,description:f,showLegend:g,showGrid:y,background:p,className:m,annotations:v,margin:x,colorScheme:b,colorBy:k,legendPosition:A}=n,w=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}(n,["data","width","height","theme","title","description","showLegend","showGrid","background","className","annotations","margin","colorScheme","colorBy","legendPosition"]),S=[l,h],_=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},w.frameProps||{}),{theme:u,title:d,description:f,showLegend:g,showGrid:y,background:p,className:m,annotations:v,size:S}),void 0!==x&&{margin:x}),void 0!==b&&{colorScheme:b}),void 0!==A&&{legendPosition:A}),{_idPrefix:w._idPrefix}),P=Li[r];if(!P)throw Error(`Unknown chart component: "${r}". See CLAUDE.md for supported chart types.`);const M=P.buildProps(c,k,b,_,w);let O=(0,{xy:zi,ordinal:Ni,network:Ci,geo:Wi}[P.frameType])(M);if("GaugeChart"===r&&M.__gauge){const r=M.__gauge,n=_.margin||{top:20,right:20,bottom:30,left:40},s=(l||300)-n.left-n.right,c=(h||300)-n.top-n.bottom,d=Math.min(s,c)/2*.85,f=n.left+s/2,g=n.top+c/2,y=Math.max(r.gMin,Math.min(r.gMax,null!==(a=r.value)&&void 0!==a?a:r.gMin)),p=(r.startAngleDeg+(r.gMax===r.gMin?0:(y-r.gMin)/(r.gMax-r.gMin))*r.sweep-90)*Math.PI/180,m=Si(u).colors.text,v=o.renderToStaticMarkup(e(i,{children:[t("line",{x1:f,y1:g,x2:f+d*Math.cos(p),y2:g+d*Math.sin(p),stroke:m,strokeWidth:2.5,strokeLinecap:"round"}),t("circle",{cx:f,cy:g,r:4,fill:m})]}));O=O.replace("</svg>",v+"</svg>")}return O}function Gi(t,e){return ft(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)?Bi(t,e):qi(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 h=e.width||(null===(o=e.size)||void 0===o?void 0:o[0])||600,u=e.height||(null===(r=e.size)||void 0===r?void 0:r[1])||400,d=l(void 0!==globalThis.Buffer?globalThis.Buffer.from(c):(new TextEncoder).encode(c),{density:72*s}).resize(Math.round(h*s),Math.round(u*s));return"jpeg"===n?d.jpeg({quality:90}).toBuffer():d.png().toBuffer()})}function Vi(i,r={}){var n;const{title:s,subtitle:a,theme:c,width:l=1200,height:h,layout:u={},background:d}=r,f=_i(Si(c)),g=u.columns||2,y=null!==(n=u.gap)&&void 0!==n?n:16;let p=0;s&&(p+=30),a&&(p+=20),p>0&&(p+=10);const m=Math.floor((l-y-y*(g-1))/g),v=[];let x=0,b=p+y,k=0;for(const t of i){const e=Math.min(t.colSpan||1,g),i=t.props.height||300;x+e>g&&(b+=k+y,x=0,k=0),v.push({chart:t,x:y/2+x*(m+y),y:b,w:m*e+y*(e-1),h:i}),k=Math.max(k,i),x+=e}const A=h||b+k+y,w=v.map((e,i)=>{const{chart:o,x:r,y:n,w:s,h:a}=e,l=Object.assign(Object.assign({},o.props),{width:s,height:a,theme:c,_idPrefix:"chart-"+i});let h;return h=o.component?qi(o.component,l):o.frameType?Bi(o.frameType,l):`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${a}"></svg>`,t("g",{transform:`translate(${r},${n})`,children:t("foreignObject",{width:s,height:a,children:t("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:h}})})},"dashboard-chart-"+i)}),S=e("svg",{xmlns:"http://www.w3.org/2000/svg",width:l,height:A,role:"img","aria-label":s||"Dashboard",style:{fontFamily:f.fontFamily},children:[s&&t("title",{children:s}),d&&t("rect",{x:0,y:0,width:l,height:A,fill:d}),s&&t("text",{x:l/2,y:24,textAnchor:"middle",fontSize:f.titleSize+4,fontWeight:"bold",fill:f.text,fontFamily:f.fontFamily,children:s}),a&&t("text",{x:l/2,y:s?46:20,textAnchor:"middle",fontSize:f.labelSize,fill:f.textSecondary,fontFamily:f.fontFamily,children:a}),w]});return o.renderToStaticMarkup(S)}function Hi(t,e,i,o={}){const{stepSize:r,windowSize:n,frameCount:s,xExtent:a,yExtent:c,transitionFrames:l=4,fps:h=12,easing:u="ease-out",decay:d}=o,f=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))))),v=[];for(let t=m;e.length>=t;t+=m)v.push(t);v[v.length-1]!==e.length&&v.push(e.length);const x=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=f-b.left-b.right,A=g-b.top-b.bottom,w=[];if(x)for(let o=0;v.length>o;o++){const r=v[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},d&&{decay:d}),c=new ni(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:k,height:A}),c.scene.length>0&&w.push(Ki(c.scene,f,g,y,p))}else for(let o=0;v.length>o;o++){const r=v[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},d&&{decay:d}),l>0&&{transition:{duration:l*(1e3/h),easing:u}}),x=new Yt(m);if(x.ingest({inserts:s,bounded:!0}),x.computeScene({width:k,height:A}),0===x.scene.length)continue;const b=x.scales?{y:x.scales.y}:void 0;if(w.push(Ui(x.scene,f,g,y,p,b)),l>0&&o>0&&x.activeTransition){const t=l*(1e3/h);for(let e=1;l>=e;e++)x.advanceTransition(x.activeTransition.startTime+e/l*t),w.push(Ui(x.scene,f,g,y,p,b))}}return w}function Qi(t,e,i={}){return e.map(e=>{try{return qi(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 Zi(t,e){const i=t.background||e.colors.background;return i&&"transparent"!==i?i:null}function Ui(r,n,s,a,c,l){const h=_i(a),u=Object.assign({top:20,right:20,bottom:30,left:40},c.margin),d=n-u.left-u.right,f=s-u.top-u.bottom,g=Zi(c,a),y=r.map((t,e)=>pi(t,e)).filter(Boolean),p=function(o,r,n,s,a,c){var l;if(!o||0===o.length)return null;const h=_i(s),u=[];for(let i=0;o.length>i;i++){const s=o[i];if("y-threshold"===s.type&&null!=s.value){let o=null;if(c)o=c(s.value);else if(a){const[t,e]=a,i=e-t;if(0===i)continue;o=n-(s.value-t)/i*n}if(null==o)continue;const d=s.color||h.primary,f=null!==(l=s.strokeWidth)&&void 0!==l?l:1.5,g=s.labelPosition||"right";u.push(e("g",{children:[t("line",{x1:0,y1:o,x2:r,y2:o,stroke:d,strokeWidth:f,strokeDasharray:s.strokeDasharray||"6,4"}),s.label&&t("text",{x:"left"===g?4:"center"===g?r/2:r-4,y:o-5,textAnchor:"left"===g?"start":"center"===g?"middle":"end",fontSize:h.tickSize,fill:d,fontFamily:h.fontFamily,children:s.label})]},"ann-"+i))}}return u.length>0?t(i,{children:u}):null}(c.annotations,d,f,a,c.yExtent,null==l?void 0:l.y),m="string"==typeof c.title?c.title:void 0,v="string"==typeof c.description?c.description:void 0,x=m?"semiotic-title":void 0,b=v?"semiotic-desc":void 0,k=[x,b].filter(Boolean).join(" ")||void 0,A=e("svg",{xmlns:"http://www.w3.org/2000/svg",width:n,height:s,role:"img","aria-labelledby":k,style:{fontFamily:h.fontFamily},children:[m&&t("title",{id:x,children:m}),v&&t("desc",{id:b,children:v}),g&&t("rect",{x:0,y:0,width:n,height:s,fill:g}),e("g",{transform:`translate(${u.left},${u.top})`,children:[p,y]}),m&&t("text",{x:n/2,y:16,textAnchor:"middle",fontSize:h.titleSize,fontWeight:"bold",fill:h.text,fontFamily:h.fontFamily,children:m})]});return o.renderToStaticMarkup(A)}function Ki(i,r,n,s,a){const c=_i(s),l=Object.assign({top:20,right:20,bottom:30,left:40},a.margin),h="radial"===a.projection,u=h?l.left+(r-l.left-l.right)/2:l.left,d=h?l.top+(n-l.top-l.bottom)/2:l.top,f=Zi(a,s),g=i.map((t,e)=>mi(t,e)).filter(Boolean),y="string"==typeof a.title?a.title:void 0,p="string"==typeof a.description?a.description:void 0,m=y?"semiotic-title":void 0,v=p?"semiotic-desc":void 0,x=[m,v].filter(Boolean).join(" ")||void 0,b=e("svg",{xmlns:"http://www.w3.org/2000/svg",width:r,height:n,role:"img","aria-labelledby":x,style:{fontFamily:c.fontFamily},children:[y&&t("title",{id:m,children:y}),p&&t("desc",{id:v,children:p}),f&&t("rect",{x:0,y:0,width:r,height:n,fill:f}),t("g",{transform:`translate(${u},${d})`,children:g}),y&&t("text",{x:r/2,y:16,textAnchor:"middle",fontSize:c.titleSize,fontWeight:"bold",fill:c.text,fontFamily:c.fontFamily,children:y})]});return o.renderToStaticMarkup(b)}function Ji(t,e,i){return ft(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),h=Math.round(c*s),u=Hi(t,e,a?Object.assign(Object.assign({},i),{background:a}):i,o);if(0===u.length)throw Error("No frames generated — check that data is not empty");let d,f,g,y;try{d=require("sharp")}catch(t){throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t=require("gifenc");f=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=f();for(let t=0;u.length>t;t++){const e=u[t],i=yield d(Buffer.from(e),{density:72*s}).resize(l,h).ensureAlpha().raw().toBuffer(),o=new Uint8Array(i),r=g(o,256),a=y(o,r);m.writeFrame(a,l,h,{palette:r,delay:p,repeat:n?0:-1})}return m.finish(),Buffer.from(m.bytes())})}export{Hi as generateFrameSVGs,Qi as generateFrameSequence,qi as renderChart,Vi as renderDashboard,Xi as renderGeoToStaticSVG,Ii as renderNetworkToStaticSVG,Yi as renderOrdinalToStaticSVG,Ji as renderToAnimatedGif,Gi as renderToImage,Bi as renderToStaticSVG,Fi as renderXYToStaticSVG,Si as resolveTheme,_i as themeStyles};