semiotic 3.2.2 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CLAUDE.md +118 -222
  2. package/README.md +37 -17
  3. package/ai/schema.json +64 -1
  4. package/ai/system-prompt.md +3 -3
  5. package/dist/components/Tooltip/Tooltip.d.ts +6 -1
  6. package/dist/components/charts/index.d.ts +2 -0
  7. package/dist/components/charts/ordinal/BarChart.d.ts +2 -0
  8. package/dist/components/charts/ordinal/GaugeChart.d.ts +55 -0
  9. package/dist/components/charts/ordinal/GroupedBarChart.d.ts +1 -0
  10. package/dist/components/charts/ordinal/StackedBarChart.d.ts +1 -0
  11. package/dist/components/charts/ordinal/SwimlaneChart.d.ts +4 -0
  12. package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +2 -0
  13. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +2 -0
  14. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +2 -0
  15. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +2 -0
  16. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +2 -0
  17. package/dist/components/charts/shared/hooks.d.ts +5 -1
  18. package/dist/components/charts/shared/types.d.ts +14 -5
  19. package/dist/components/charts/shared/useChartSetup.d.ts +2 -0
  20. package/dist/components/charts/xy/AreaChart.d.ts +17 -2
  21. package/dist/components/charts/xy/LineChart.d.ts +14 -3
  22. package/dist/components/realtime/RingBuffer.d.ts +11 -0
  23. package/dist/components/realtime/types.d.ts +4 -0
  24. package/dist/components/semiotic-ordinal.d.ts +2 -0
  25. package/dist/components/semiotic-server.d.ts +6 -1
  26. package/dist/components/semiotic-utils.d.ts +2 -1
  27. package/dist/components/semiotic.d.ts +3 -3
  28. package/dist/components/server/animatedGif.d.ts +78 -0
  29. package/dist/components/server/renderToStaticSVG.d.ts +85 -5
  30. package/dist/components/server/staticAnnotations.d.ts +40 -0
  31. package/dist/components/server/staticLegend.d.ts +39 -0
  32. package/dist/components/server/svgHatchPattern.d.ts +26 -0
  33. package/dist/components/server/themeResolver.d.ts +35 -0
  34. package/dist/components/store/LinkedCrosshairStore.d.ts +6 -2
  35. package/dist/components/stream/CanvasHitTester.d.ts +13 -0
  36. package/dist/components/stream/GeoPipelineStore.d.ts +6 -1
  37. package/dist/components/stream/NetworkPipelineStore.d.ts +20 -0
  38. package/dist/components/stream/OrdinalPipelineStore.d.ts +11 -0
  39. package/dist/components/stream/OrdinalSVGOverlay.d.ts +6 -1
  40. package/dist/components/stream/PipelineStore.d.ts +28 -1
  41. package/dist/components/stream/SVGOverlay.d.ts +11 -5
  42. package/dist/components/stream/accessorUtils.d.ts +3 -3
  43. package/dist/components/stream/geoTypes.d.ts +2 -0
  44. package/dist/components/stream/hitTestUtils.d.ts +15 -0
  45. package/dist/components/stream/networkTypes.d.ts +33 -0
  46. package/dist/components/stream/ordinalTypes.d.ts +37 -4
  47. package/dist/components/stream/renderers/resolveCSSColor.d.ts +17 -0
  48. package/dist/components/stream/types.d.ts +58 -5
  49. package/dist/components/stream/xySceneBuilders/mixedScene.d.ts +12 -0
  50. package/dist/components/stream/xySceneBuilders/types.d.ts +15 -0
  51. package/dist/geo.min.js +1 -1
  52. package/dist/geo.module.min.js +1 -1
  53. package/dist/network.min.js +1 -1
  54. package/dist/network.module.min.js +1 -1
  55. package/dist/ordinal.min.js +1 -1
  56. package/dist/ordinal.module.min.js +1 -1
  57. package/dist/realtime.min.js +1 -1
  58. package/dist/realtime.module.min.js +1 -1
  59. package/dist/semiotic-ai.min.js +1 -1
  60. package/dist/semiotic-ai.module.min.js +1 -1
  61. package/dist/semiotic-ordinal.d.ts +2 -0
  62. package/dist/semiotic-server.d.ts +6 -1
  63. package/dist/semiotic-utils.d.ts +2 -1
  64. package/dist/semiotic-utils.min.js +1 -1
  65. package/dist/semiotic-utils.module.min.js +1 -1
  66. package/dist/semiotic.d.ts +3 -3
  67. package/dist/semiotic.min.js +1 -1
  68. package/dist/semiotic.module.min.js +1 -1
  69. package/dist/server.min.js +1 -1
  70. package/dist/server.module.min.js +1 -1
  71. package/dist/xy.min.js +1 -1
  72. package/dist/xy.module.min.js +1 -1
  73. package/package.json +21 -7
@@ -1 +1 @@
1
- "use strict";const t=require("react"),e=require("d3-scale"),i=require("d3-quadtree"),n=require("d3-scale-chromatic"),r=require("d3-array"),o=require("d3-interpolate"),s=require("d3-force"),a=require("d3-chord"),c=require("d3-shape"),l=require("d3-hierarchy"),u=require("d3-geo");function h(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const i in t)if("default"!==i){const n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})}return e.default=t,Object.freeze(e)}const f=h(t);class d{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const i of t){const t=this.push(i);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;const e=this;return{next:()=>e._size>t?{done:!1,value:e.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)t(this.buffer[(e+i)%this._capacity],i)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)t[i]=this.buffer[(e+i)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),i=[];for(;e.length>t;)i.push(e.shift());this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(const t of e)this.push(t);return i}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 g{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 y(t,e,i,n,r){const o=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/n)*n;let l=o.get(c);if(l||(l={start:c,end:c+n,total:0,categories:new Map},o.set(c,l)),l.total+=a,r){const t=r(s);l.categories.set(t,(l.categories.get(t)||0)+a)}}return o}function p(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function m(t,e){if("function"==typeof t)return e=>+t(e);const i=t||e;return t=>+t[i]}function v(t,e){if("function"==typeof t)return t;const i=t||e;return t=>t[i]}function x(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}const b=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function k(t,e,i){var n,r,o;if(1>=i)return 1;const s=null!==(n=t.minOpacity)&&void 0!==n?n:.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!==(o=t.stepThreshold)&&void 0!==o?o:.5*i)>a?1:s;default:return 1}}function w(t,e,i){var n;const r=null!==(n=t.duration)&&void 0!==n?n:500,o=i-e;return r>o?1-o/r:0}function _(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function A(t,e){return Math.min((t-e.startTime)/e.duration,1)}function S(t,e,i){return t+(e-t)*i}function P(){return"undefined"!=typeof performance?performance.now():Date.now()}function M(t,e,i){var n,r,o,s;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const i=t.getX(e.datum),n=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${i}:${n}`;if(null!=i&&null!=n)return`p:${i}:${n}`}return"p:"+i;case"rect":return`r:${e.group||""}:${null!==(s=null!==(r=null===(n=e.datum)||void 0===n?void 0:n.binStart)&&void 0!==r?r:null===(o=e.datum)||void 0===o?void 0:o.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 E(t,e,i,n,r,o){const s=[];for(const r of t){const t=i(r),o=n(r);null==t||null==o||Number.isNaN(t)||Number.isNaN(o)||s.push({px:e.x(t),py:e.y(o),rawY:o,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:o}}function L(t,e,i,n,r,o,s,a){const c=[];for(const o of t){const t=i(o),s=n(o);if(null==t||null==s||Number.isNaN(t)||Number.isNaN(s))continue;const l=e.x(t),u=a?a(o):r;c.push({px:l,topY:e.y(s),botY:e.y(u)})}c.sort((t,e)=>t.px-e.px);const l=Array(c.length),u=Array(c.length);for(let t=0;c.length>t;t++){const e=c[t];l[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:l,bottomPath:u,style:o,datum:t,group:s}}function D(t,e,i,n,r,o,s){const a=i(t),c=n(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:o,datum:t};return void 0!==s&&(l.pointId=s),l}function O(t,e,i,n,r,o,s){return{type:"rect",x:t,y:e,w:i,h:n,style:r,datum:o,group:s}}function N(t,e,i,n,r,o,s){const a={type:"heatcell",x:t,y:e,w:i,h:n,fill:r,datum:o};return(null==s?void 0:s.showValues)&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function $(t,e,i){if(!t.getBounds||!t.scales)return null;const n=[],r=[];for(const i of e){const e=t.getX(i),o=t.getY(i);if(null==e||null==o||Number.isNaN(e)||Number.isNaN(o))continue;const s=t.getBounds(i),a=t.scales.x(e);if(s&&0!==s)n.push([a,t.scales.y(o+s)]),r.push([a,t.scales.y(o-s)]);else{const e=t.scales.y(o);n.push([a,e]),r.push([a,e])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:r,style:t.resolveBoundsStyle(i,e[0]),datum:e,group:i,interactive:!1}}function T(t,e,i,n){var r;if(!t.config.pointStyle)return;const o=null!=n?n:t.getY;for(const n of e){const e=t.resolveGroupColor(n.key);for(const s of n.data){let n=t.config.pointStyle(s);!n.fill&&e&&(n=Object.assign(Object.assign({},n),{fill:e}));const a=null!==(r=n.r)&&void 0!==r?r:3,c=t.getPointId?t.getPointId(s)+"":void 0,l=D(s,t.scales,t.getX,o,a,n,c);l&&i.push(l)}}}const W={blues:n.interpolateBlues,reds:n.interpolateReds,greens:n.interpolateGreens,viridis:n.interpolateViridis};class j{constructor(t){this.xExtent=new g,this.yExtent=new g,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.xIsDate=!1,this._quadtree=null,this.config=t,this.buffer=new d(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=m(t.timeAccessor||t.xAccessor,"time"),this.getY=m(t.valueAccessor||t.yAccessor,"value")):(this.getX=m(t.xAccessor,"x"),this.getY=m(t.yAccessor,"y")),this.getGroup=x(t.groupAccessor),this.getCategory=x(t.categoryAccessor),this.getSize=t.sizeAccessor?m(t.sizeAccessor,"size"):void 0,this.getColor=x(t.colorAccessor),this.getBounds=t.boundsAccessor?m(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?m(t.y0Accessor,"y0"):void 0,this.getPointId=x(t.pointIdAccessor),"candlestick"===t.chartType&&(this.getOpen=m(t.openAccessor,"open"),this.getHigh=m(t.highAccessor,"high"),this.getLow=m(t.lowAccessor,"low"),this.getClose=m(t.closeAccessor,"close")),t.pulse&&(this.timestampBuffer=new d(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.bounded){if(this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.getX=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?m(this.config.timeAccessor||this.config.xAccessor,"time"):m(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],i=this.config.xAccessor,n="function"==typeof i?i(e):e[i||"x"],r=n instanceof Date,o="string"==typeof n&&n.length>=10&&!isNaN(new Date(n).getTime())&&isNaN(Number(n));if(this.xIsDate=r||o,o){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 i,n,r,o,s,a;const{config:c,buffer:l}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);if(this.xExtent.dirty&&this.xExtent.recalculate(l,this.getX),this.yExtent.dirty)if("candlestick"===c.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of l)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(l,this.getY);const u=this.getBufferArray(),h=this.xExtent.extent,f=this.yExtent.extent;let d=c.xExtent?[null!==(i=c.xExtent[0])&&void 0!==i?i:h[0],null!==(n=c.xExtent[1])&&void 0!==n?n:h[1]]:h,g=c.yExtent?[null!==(r=c.yExtent[0])&&void 0!==r?r:f[0],null!==(o=c.yExtent[1])&&void 0!==o?o:f[1]]:f;const p=c.yExtent&&null!=c.yExtent[0]&&null!=c.yExtent[1];if("stackedarea"===c.chartType&&!p&&l.size>0)if(c.normalize)g=[0,1+c.extentPadding];else{const t=`${l.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)g=this._stackExtentCache.yDomain;else{const e=this.groupData(u),i=new Map;for(const t of e)for(const e of t.data){const t=this.getX(e),n=this.getY(e);null==t||null==n||Number.isNaN(t)||Number.isNaN(n)||i.set(t,(i.get(t)||0)+n)}let n=0;for(const t of i.values())t>n&&(n=t);g=[0,n+(n>0?n*c.extentPadding:1)],this._stackExtentCache={key:t,yDomain:g}}}else if("bar"===c.chartType&&c.binSize&&!p&&l.size>0){const[,t]=function(t,e,i,n,r){const o=y(t,e,i,n,r);if(0===o.size)return[0,0];let s=0;for(const t of o.values())t.total>s&&(s=t.total);return[0,s]}(l,this.getX,this.getY,c.binSize,this.getCategory);g=[0,t+t*c.extentPadding]}else if("waterfall"===c.chartType&&!p&&l.size>0){const[t,e]=function(t,e){let i=0,n=0,r=0;for(const o of t){const t=e(o);null==t||Number.isNaN(t)||(r+=t,i>r&&(i=r),r>n&&(n=r))}return[i,n]}(l,this.getY),i=e-t,n=i>0?i*c.extentPadding:1;g=[Math.min(0,t-Math.abs(n)),Math.max(0,e+Math.abs(n))]}else if(!p&&g[0]!==1/0){if(this.getBounds)for(const t of u){const e=this.getY(t),i=this.getBounds(t);null!=e&&!Number.isNaN(e)&&i&&(e+i>g[1]&&(g[1]=e+i),g[0]>e-i&&(g[0]=e-i))}const t=g[1]-g[0],e=t>0?t*c.extentPadding:1,i=null===(s=c.yExtent)||void 0===s?void 0:s[0],n=null===(a=c.yExtent)||void 0===a?void 0:a[1];g=[null!=i?g[0]:g[0]-e,null!=n?g[1]:g[1]+e],"log"===c.yScaleType&&0>=g[0]&&f[0]>0&&(g[0]=null!=i?g[0]:f[0]/(1+c.extentPadding))}if(d[0]!==1/0&&d[1]!==-1/0||(d=[0,1]),g[0]!==1/0&&g[1]!==-1/0||(g=[0,1]),"streaming"===c.runtimeMode)if("x"==("up"===(m=c.arrowOfTime)||"down"===m?"y":"x")){const i="right"===c.arrowOfTime?[0,t.width]:[t.width,0];this.scales={x:e.scaleLinear().domain(d).range(i),y:e.scaleLinear().domain(g).range([t.height,0])}}else{const i="down"===c.arrowOfTime?[0,t.height]:[t.height,0];this.scales={x:e.scaleLinear().domain(g).range([0,t.width]),y:e.scaleLinear().domain(d).range(i)}}else{const i=(t,i,n)=>{if("log"===t){const t=[Math.max(i[0],1e-6),Math.max(i[1],1e-6)];return e.scaleLog().domain(t).range(n).clamp(!0)}return e.scaleLinear().domain(i).range(n)};this.scales={x:i(c.xScaleType,d,[0,t.width]),y:i(c.yScaleType,g,[t.height,0])}}var m;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,u),this.config.decay&&this.applyDecay(this.scene,u),this.config.pulse&&this.applyPulse(this.scene,u),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}rebuildQuadtree(){const t=this.config.chartType;if("scatter"!==t&&"bubble"!==t)return void(this._quadtree=null);const e=this.scene.filter(t=>"point"===t.type);this._quadtree=e.length>j.QUADTREE_THRESHOLD?i.quadtree().x(t=>t.x).y(t=>t.y).addAll(e):null}get quadtree(){return this._quadtree}remapScene(t){const i=t.width/this.lastLayout.width,n=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const e of t.path)e[0]*=i,e[1]*=n;break;case"area":for(const e of t.topPath)e[0]*=i,e[1]*=n;for(const e of t.bottomPath)e[0]*=i,e[1]*=n;break;case"point":t.x*=i,t.y*=n;break;case"rect":case"heatcell":t.x*=i,t.y*=n,t.w*=i,t.h*=n;break;case"candlestick":t.x*=i,t.openY*=n,t.closeY*=n,t.highY*=n,t.lowY*=n}const r=this.scales.x.domain(),o=this.scales.y.domain(),s=this.scales.x.range(),a=this.scales.y.range(),c=(t,i,n)=>{if("log"===t){const t=[Math.max(i[0],1e-6),Math.max(i[1],1e-6)];return e.scaleLog().domain(t).range(n).clamp(!0)}return e.scaleLinear().domain(i).range(n)};this.scales={x:c(this.config.xScaleType,r,[s[0]*i,s[1]*i]),y:c(this.config.yScaleType,o,[a[0]*n,a[1]*n])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,i){var r;const{config:o,scales:s}=this;if(!s||0===i.length)return[];const a={scales:s,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 n=t.groupData(e),r=[],o=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 n){const i=$(t,e.data,e.key);i&&r.push(i)}for(const e of n){const i=t.resolveLineStyle(e.key,e.data[0]),n=E(e.data,t.scales,t.getX,t.getY,i,e.key);o&&o.length>0&&(n.colorThresholds=o),t.config.curve&&"linear"!==t.config.curve&&(n.curve=t.config.curve),r.push(n)}return T(t,n,r),r}(a,i);case"area":return function(t,e){const i=t.groupData(e),n=[],r=t.scales.y.domain()[0],o=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=L(e.data,t.scales,t.getX,t.getY,r,i,e.key,o);t.config.gradientFill&&(s.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),n.push(s)}return T(t,i,n),n}(a,i);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 n=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,{nodes:r,stackedTops:o}=function(t,e,i,n,r,o,s){var a;const c=new Set;for(const e of t)for(const t of e.data){const e=i(t);null==e||Number.isNaN(e)||c.add(e)}const l=Array.from(c).sort((t,e)=>t-e),u=new Map;for(const e of t){const t=new Map;for(const r of e.data){const e=i(r),o=n(r);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||t.set(e,(t.get(e)||0)+o)}u.set(e.key,t)}let h;if(o){h=new Map;for(const e of l){let i=0;for(const n of t)i+=(null===(a=u.get(n.key))||void 0===a?void 0:a.get(e))||0;h.set(e,i||1)}}const f=[],d=new Map,g=new Map;for(const t of l)g.set(t,0);for(const i of t){const t=u.get(i.key),n=[],a=[],c=new Map;for(const i of l){let r=t.get(i)||0;const s=g.get(i);o&&(r/=h.get(i));const l=s+r,u=e.x(i);a.push([u,e.y(s)]),n.push([u,e.y(l)]),g.set(i,l),c.set(i,l)}d.set(i.key,c);const y={type:"area",topPath:n,bottomPath:a,style:r(i.key,i.data[0]),datum:i.data,group:i.key};s&&(y.curve=s),f.push(y)}return{nodes:f,stackedTops:d}}(i,t.scales,t.getX,t.getY,(e,i)=>t.resolveAreaStyle(e,i),t.config.normalize,n),s=r;if(t.config.pointStyle){const e=new WeakMap;for(const n of i){const i=o.get(n.key);if(i)for(const r of n.data){const n=t.getX(r),o=t.getY(r);null==n||Number.isNaN(n)||null==o||Number.isNaN(o)||!i.has(n)||e.set(r,i.get(n))}}const n=i=>{var n;return null!==(n=e.get(i))&&void 0!==n?n:t.getY(i)};T(t,i,s,n)}return s}(a,i);case"scatter":case"bubble":return function(t,e){const i=[],n="bubble"===t.config.chartType?10:5,r=t.config.sizeRange||[3,15];let o=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 n of i)t>n&&(t=n),n>e&&(e=n);o=i=>t===e?(r[0]+r[1])/2:r[0]+(i-t)/(e-t)*(r[1]-r[0])}}const s=t.getColor?t.resolveColorMap(e):null;for(const r of e){let e=t.config.pointStyle?t.config.pointStyle(r):{fill:"#4e79a7",opacity:.8},a=e.r||n;if(o&&t.getSize){const e=t.getSize(r);null==e||Number.isNaN(e)||(a=o(e))}if(s&&t.getColor&&!e.fill){const i=t.getColor(r);i&&s.has(i)&&(e=Object.assign(Object.assign({},e),{fill:s.get(i)}))}const c=t.getPointId?t.getPointId(r)+"":void 0,l=D(r,t.scales,t.getX,t.getY,a,e,c);l&&i.push(l)}return i}(a,i);case"heatmap":return function(t,i,r){if(t.config.heatmapAggregation)return function(t,e,i){var n,r,o;const s=[],a=Math.max(1,Math.floor(null!==(n=t.config.heatmapXBins)&&void 0!==n?n:20)),c=Math.max(1,Math.floor(null!==(r=t.config.heatmapYBins)&&void 0!==r?r:20)),l=null!==(o=t.config.heatmapAggregation)&&void 0!==o?o:"count",u=m(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return s;const[h,f]=t.scales.x.domain(),[d,g]=t.scales.y.domain(),y=(f-h||1)/a,p=(g-d||1)/c,v=new Map;for(const i of e){const e=t.getX(i),n=t.getY(i);if(!isFinite(e)||!isFinite(n))continue;const r=Math.min(Math.floor((e-h)/y),a-1),o=Math.min(Math.floor((n-d)/p),c-1);if(0>r||0>o)continue;const s=u(i),l=`${r}_${o}`;let f=v.get(l);f||(f={sum:0,count:0,data:[]},v.set(l,f)),f.count++,f.sum+=isFinite(s)?s:0,f.data.push(i)}let x=1/0,b=-1/0;const k=new Map;for(const[t,e]of v){let i;switch(l){case"sum":i=e.sum;break;case"mean":i=e.count>0?e.sum/e.count:0;break;default:i=e.count}k.set(t,i),x>i&&(x=i),i>b&&(b=i)}const w=b-x||1,_=i.width/a,A=i.height/c;for(const[e,i]of k){const[n,r]=e.split("_"),o=+n,a=+r,l=(i-x)/w,u=`rgb(${Math.round(220-180*l)},${Math.round(220-100*l)},${Math.round(255-50*l)})`,h=v.get(e);s.push(N(o*_,(c-1-a)*A,_,A,u,{xi:o,yi:a,value:i,count:h.count,sum:h.sum,data:h.data},t.config.showValues?{value:i,showValues:!0,valueFormat:t.config.heatmapValueFormat}:void 0))}return s}(t,i,r);const o=[],s=m(t.config.valueAccessor,"value"),a=v(t.config.xAccessor,"x"),c=v(t.config.yAccessor,"y"),l=new Set,u=new Set;for(const t of i)l.add(a(t)),u.add(c(t));const h=Array.from(l),f=Array.from(u),d=h.every(t=>"number"==typeof t&&!isNaN(t)),g=f.every(t=>"number"==typeof t&&!isNaN(t)),y=d?h.sort((t,e)=>t-e):h,p=g?f.sort((t,e)=>t-e):f;if(0===y.length||0===p.length)return o;const x=r.width/y.length,b=r.height/p.length,k=new Map;for(const t of i){const e=`${a(t)}\0${c(t)}`;k.set(e,{val:s(t),datum:t})}let w=1/0,_=-1/0;for(const{val:t}of k.values())isFinite(t)&&(w>t&&(w=t),t>_&&(_=t));if(!isFinite(w)||!isFinite(_))return o;const A=e.scaleSequential(W["string"==typeof t.config.colorScheme?t.config.colorScheme:"blues"]||n.interpolateBlues).domain([w,_]);for(let e=0;y.length>e;e++)for(let i=0;p.length>i;i++){const n=k.get(`${y[e]}\0${p[i]}`);if(!n||!isFinite(n.val))continue;const r=A(n.val);o.push(N(e*x,(p.length-1-i)*b,x,b,r,n.datum,t.config.showValues?{value:n.val,showValues:!0,valueFormat:t.config.heatmapValueFormat}:void 0))}return o}(a,i,t);case"bar":{const t=function(t,e){var i;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const n=y(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===n.size)return{nodes:[],binBoundaries:[]};let r=null;if(t.getCategory){const e=new Set;for(const t of n.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?r=t.barCategoryCache.order:(r=[...a,...s],t.barCategoryCache={key:c,order:r})}const o=[],s=t.scales,[a,c]=s.x.domain();for(const e of n.values()){const n=Math.max(e.start,a),l=Math.min(e.end,c);if(n>=l)continue;const u=s.x(n),h=s.x(l),f=Math.abs(h-u),d=f>2?1:0,g=Math.min(u,h)+d/2,y=Math.max(f-d,1);if(y>0)if(r&&e.categories.size>0){let n=0;for(const a of r){const r=e.categories.get(a)||0;if(0===r)continue;const c=s.y(n),l=s.y(n+r);o.push(O(g,Math.min(c,l),y,Math.abs(c-l),{fill:(null===(i=t.config.barColors)||void 0===i?void 0:i[a])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:a,categoryValue:r},a)),n+=r}}else{const t=s.y(0),i=s.y(e.total);o.push(O(g,Math.min(t,i),y,Math.abs(t-i),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}const l=new Set;for(const t of n.values())l.add(t.start),l.add(t.end);return{nodes:o,binBoundaries:Array.from(l).sort((t,e)=>t-e)}}(a,i);return this._barCategoryCache=null!==(r=a.barCategoryCache)&&void 0!==r?r:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var i,n,r,o;const s=[],a=t.config.swarmStyle||{},c=null!==(i=a.radius)&&void 0!==i?i:3,l=null!==(n=a.fill)&&void 0!==n?n:"#007bff",u=null!==(r=a.opacity)&&void 0!==r?r:.7,h=a.stroke,f=a.strokeWidth;for(const i of e){const e=t.getX(i),n=t.getY(i);if(null==n||Number.isNaN(n))continue;const r=t.scales.x(e),a=t.scales.y(n);let d=l;if(t.getCategory){const e=t.getCategory(i);d=(null===(o=t.config.barColors)||void 0===o?void 0:o[e])||d}const g={type:"point",x:r,y:a,r:c,style:{fill:d,opacity:u,stroke:h,strokeWidth:f},datum:i};t.getPointId&&(g.pointId=t.getPointId(i)+""),s.push(g)}return s}(a,i);case"waterfall":return function(t,e,i){var n,r,o;const s=[],a=t.scales,c=t.config.waterfallStyle,l=e.filter(e=>{const i=t.getY(e),n=t.getX(e);return null!=i&&!Number.isNaN(i)&&null!=n&&isFinite(n)});if(0===l.length)return s;const u=null!==(n=null==c?void 0:c.positiveColor)&&void 0!==n?n:"#28a745",h=null!==(r=null==c?void 0:c.negativeColor)&&void 0!==r?r:"#dc3545",f=null!==(o=null==c?void 0:c.gap)&&void 0!==o?o:1,d=null==c?void 0:c.stroke,g=null==c?void 0:c.strokeWidth;let y=0;for(let e=0;l.length>e;e++){const n=l[e],r=t.getX(n),o=t.getY(n),p=y+o;let m;m=l.length-1>e?t.getX(l[e+1])-r:e>0?r-t.getX(l[e-1]):0;const v=a.x(r),x=0!==m?a.x(r+m):v+i.width/10,b=Math.min(v,x)+f/2,k=Math.max(v,x)-f/2-b;if(0>=k){y=p;continue}const w=a.y(y),_=a.y(p);s.push(O(b,Math.min(w,_),k,Math.abs(w-_),{fill:0>o?h:u,stroke:d,strokeWidth:g},Object.assign(Object.assign({},n),{baseline:y,cumEnd:p,delta:o,_connectorStroke:null==c?void 0:c.connectorStroke,_connectorWidth:null==c?void 0:c.connectorWidth}))),y=p}return s}(a,i,t);case"candlestick":return function(t,e){if(!(t.getOpen&&t.getHigh&&t.getLow&&t.getClose&&t.scales))return[];const i=[],n=t.config.candlestickStyle||{},r=n.upColor||"#28a745",o=n.downColor||"#dc3545",s=n.wickColor||"#333",a=n.wickWidth||1,c=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let l=n.bodyWidth||6;if(!n.bodyWidth&&c.length>1){let e=1/0;for(let i=1;c.length>i;i++){const n=Math.abs(t.scales.x(c[i])-t.scales.x(c[i-1]));n>0&&e>n&&(e=n)}e!==1/0&&(l=Math.max(2,Math.min(.6*e,20)))}for(const n of e){const e=t.getX(n);if(null==e||Number.isNaN(e))continue;const c=t.getOpen(n),u=t.getHigh(n),h=t.getLow(n),f=t.getClose(n);if([c,u,h,f].some(t=>null==t||Number.isNaN(t)))continue;const d=f>=c;i.push({type:"candlestick",x:t.scales.x(e),openY:t.scales.y(c),closeY:t.scales.y(f),highY:t.scales.y(u),lowY:t.scales.y(h),bodyWidth:l,upColor:r,downColor:o,wickColor:s,wickWidth:a,isUp:d,datum:n})}return i}(a,i);default:return[]}}resolveBoundsStyle(t,e){const i=this.config.boundsStyle;return"function"==typeof i?i(e||{},t):i&&"object"==typeof i?i:{fill:this.resolveLineStyle(t,e).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?k(i,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,i){var n,r;const o=i.length;if(1>=o)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 n=Array(e.length);let r=!1;for(let i=0;e.length>i;i++){const a=s.get(e[i]);null!=a?(n[i]=k(t,a,o),1>n[i]&&(r=!0)):n[i]=1}r&&(i._decayOpacities=n);continue}if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[],n=i.topPath?i.topPath.length:e.length;if(2>n)continue;if(e.length===n){const r=Array(n);let a=!1;for(let i=0;e.length>i;i++){const n=s.get(e[i]);null!=n?(r[i]=k(t,n,o),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=k(t,e,o);r>i&&(r=i)}}if(1>r){const t=Array(n);t.fill(r),i._decayOpacities=t}}continue}const e=s.get(i.datum);if(null==e)continue;const a=k(t,e,o);if("heatcell"===i.type)i.style={opacity:a};else if("candlestick"===i.type)i._decayOpacity=a;else{const t=null!==(r=null===(n=i.style)||void 0===n?void 0:n.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,n){var r,o;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!==(o=t.glowRadius)&&void 0!==o?o: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 o=n.get(e);if(null==o)continue;const a=w(t,o,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=n.get(e);if(null==r)continue;const o=w(t,r,s);o>0&&(i._pulseIntensity=o,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 n="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(i=t.duration)&&void 0!==i?i:500,o=e.peek();return null!=o&&r>n-o}(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,n){var r,o,s;i.clear(),n.clear();for(let a=0;e.length>a;a++){const c=e[a],l=M(t,c,a);l&&("point"===c.type?i.set(l,{x:c.x,y:c.y,r:c.r,opacity:c.style.opacity}):"rect"===c.type?i.set(l,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:c.style.opacity}):"heatcell"===c.type?i.set(l,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:null===(r=c.style)||void 0===r?void 0:r.opacity}):"candlestick"===c.type?i.set(l,{x:c.x,y:c.openY}):"line"===c.type?n.set(l,{path:c.path.map(t=>[t[0],t[1]]),opacity:null===(o=c.style)||void 0===o?void 0:o.opacity}):"area"===c.type&&n.set(l,{topPath:c.topPath.map(t=>[t[0],t[1]]),bottomPath:c.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(s=c.style)||void 0===s?void 0:s.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}startTransition(){if(!this.config.transition)return;const t=function(t,e,i,n,r){var o,s,a,c,l,u,h,f,d,g,y,p,m,v,x,b,k,w,_,A,S,E,L,D,O,N,$,T;if(0===n.size&&0===r.size)return i;const W=null!==(o=e.duration)&&void 0!==o?o:300;if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}let j=!1;const C=new Set,R=new Set;for(let e=0;i.scene.length>e;e++){const o=i.scene[e],_=M(t,o,e);if(!_)continue;if(o._transitionKey=_,"line"===o.type||"area"===o.type){const t=r.get(_);if(t){if(R.add(_),"line"===o.type&&t.path&&t.path.length===o.path.length){o._targetPath=o.path.map(t=>[t[0],t[1]]),o._prevPath=t.path;for(let e=0;o.path.length>e;e++)o.path[e]=[t.path[e][0],t.path[e][1]];j=!0}else if("area"===o.type&&t.topPath&&t.bottomPath&&t.topPath.length===o.topPath.length&&t.bottomPath.length===o.bottomPath.length){o._targetTopPath=o.topPath.map(t=>[t[0],t[1]]),o._targetBottomPath=o.bottomPath.map(t=>[t[0],t[1]]),o._prevTopPath=t.topPath,o._prevBottomPath=t.bottomPath;for(let e=0;o.topPath.length>e;e++)o.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;o.bottomPath.length>e;e++)o.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];j=!0}o._targetOpacity=null!==(s=o.style.opacity)&&void 0!==s?s:1,o._startOpacity=null!==(c=null!==(a=t.opacity)&&void 0!==a?a:o.style.opacity)&&void 0!==c?c:1}else o._targetOpacity=null!==(l=o.style.opacity)&&void 0!==l?l:1,o._startOpacity=0,o.style=Object.assign(Object.assign({},o.style),{opacity:0}),j=!0;continue}const A=n.get(_);if("point"===o.type)if(A){C.add(_);const t={x:o.x,y:o.y,r:o.r};o._targetOpacity=null!==(u=o.style.opacity)&&void 0!==u?u:1,A.x===t.x&&A.y===t.y&&A.r===t.r||(o._targetX=t.x,o._targetY=t.y,o._targetR=t.r,o.x=A.x,o.y=A.y,o.r=null!==(h=A.r)&&void 0!==h?h:o.r,j=!0)}else o._targetOpacity=null!==(f=o.style.opacity)&&void 0!==f?f:1,o.style=Object.assign(Object.assign({},o.style),{opacity:0}),j=!0;else if("rect"===o.type)if(A){C.add(_);const t={x:o.x,y:o.y,w:o.w,h:o.h};o._targetOpacity=null!==(d=o.style.opacity)&&void 0!==d?d:1,A.x===t.x&&A.y===t.y&&A.w===t.w&&A.h===t.h||(o._targetX=t.x,o._targetY=t.y,o._targetW=t.w,o._targetH=t.h,o.x=A.x,o.y=A.y,o.w=null!==(g=A.w)&&void 0!==g?g:o.w,o.h=null!==(y=A.h)&&void 0!==y?y:o.h,j=!0)}else o._targetOpacity=null!==(p=o.style.opacity)&&void 0!==p?p:1,o.style=Object.assign(Object.assign({},o.style),{opacity:0}),j=!0;else if("heatcell"===o.type)if(A){C.add(_);const t={x:o.x,y:o.y,w:o.w,h:o.h};o._targetOpacity=null!==(v=null===(m=o.style)||void 0===m?void 0:m.opacity)&&void 0!==v?v:1,A.x===t.x&&A.y===t.y&&A.w===t.w&&A.h===t.h||(o._targetX=t.x,o._targetY=t.y,o._targetW=t.w,o._targetH=t.h,o.x=A.x,o.y=A.y,o.w=null!==(x=A.w)&&void 0!==x?x:o.w,o.h=null!==(b=A.h)&&void 0!==b?b:o.h,j=!0)}else o._targetOpacity=null!==(w=null===(k=o.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,o.style=Object.assign(Object.assign({},o.style||{}),{opacity:0}),j=!0}for(const[t,e]of r)if(!R.has(t))if(t.startsWith("l:")&&e.path){const n={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(_=e.opacity)&&void 0!==_?_:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(n),j=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const n={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:null!==(A=e.opacity)&&void 0!==A?A:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(n),j=!0}for(const[t,e]of n)if(!C.has(t)){if(t.startsWith("p:")){const n={type:"point",x:e.x,y:e.y,r:null!==(S=e.r)&&void 0!==S?S:3,style:{opacity:null!==(E=e.opacity)&&void 0!==E?E:1},datum:null,_targetOpacity:0,_transitionKey:t};i.exitNodes.push(n)}else if(t.startsWith("r:")){const n={type:"rect",x:e.x,y:e.y,w:null!==(L=e.w)&&void 0!==L?L:0,h:null!==(D=e.h)&&void 0!==D?D:0,style:{opacity:null!==(O=e.opacity)&&void 0!==O?O:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};i.exitNodes.push(n)}else if(t.startsWith("h:")){const n={type:"heatcell",x:e.x,y:e.y,w:null!==(N=e.w)&&void 0!==N?N:0,h:null!==($=e.h)&&void 0!==$?$:0,fill:"#999",datum:null,style:{opacity:null!==(T=e.opacity)&&void 0!==T?T:1},_targetOpacity:0,_transitionKey:t};i.exitNodes.push(n)}j=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),j&&(i.activeTransition={startTime:P(),duration:W}),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,n){var r,o,s,a,c;if(!i.activeTransition)return!1;const l=A(t,i.activeTransition),u=_(l,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of i.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const i=e?n.get(e):void 0,o=i?null!==(r=i.opacity)&&void 0!==r?r:1:0;t.style.opacity=S(o,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const i=n.get(e);if(!i)continue;t.x=S(i.x,t._targetX,u),t.y=S(i.y,t._targetY,u),void 0!==t._targetR&&void 0!==i.r&&(t.r=S(i.r,t._targetR,u))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=e?n.get(e):void 0,r=i?null!==(o=i.opacity)&&void 0!==o?o:1:0;t.style.opacity=S(r,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const i=n.get(e);if(!i)continue;t.x=S(i.x,t._targetX,u),t.y=S(i.y,t._targetY,u),void 0!==i.w&&(t.w=S(i.w,t._targetW,u)),void 0!==i.h&&(t.h=S(i.h,t._targetH,u))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const i=e?n.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:S(r,t._targetOpacity,u)})}if(void 0===t._targetX)continue;if(!e)continue;const i=n.get(e);if(!i)continue;t.x=S(i.x,t._targetX,u),t.y=S(i.y,t._targetY,u),void 0!==i.w&&(t.w=S(i.w,t._targetW,u)),void 0!==i.h&&(t.h=S(i.h,t._targetH,u))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=null!==(a=t._startOpacity)&&void 0!==a?a:0;t.style=Object.assign(Object.assign({},t.style),{opacity:S(e,t._targetOpacity,u)})}const e=t._prevPath,i=t._targetPath;if(e&&i&&e.length===t.path.length)for(let n=0;t.path.length>n;n++)t.path[n][0]=S(e[n][0],i[n][0],u),t.path[n][1]=S(e[n][1],i[n][1],u)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(c=t._startOpacity)&&void 0!==c?c:0;t.style=Object.assign(Object.assign({},t.style),{opacity:S(e,t._targetOpacity,u)})}const e=t._prevTopPath,i=t._prevBottomPath,n=t._targetTopPath,r=t._targetBottomPath;if(e&&n&&e.length===t.topPath.length)for(let i=0;t.topPath.length>i;i++)t.topPath[i][0]=S(e[i][0],n[i][0],u),t.topPath[i][1]=S(e[i][1],n[i][1],u);if(i&&r&&i.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=S(i[e][0],r[e][0],u),t.bottomPath[e][1]=S(i[e][1],r[e][1],u)}}if(l>=1){for(const t of i.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style=Object.assign(Object.assign({},"line"===t.type||"area"===t.type?t.style:t.style||{}),{opacity:0===e?0:e}),t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let i=0;t.path.length>i;i++)t.path[i]=e[i];t._prevPath=void 0,t._targetPath=void 0}else if("area"===t.type){const e=t._targetTopPath,i=t._targetBottomPath;if(e)for(let i=0;t.topPath.length>i;i++)t.topPath[i]=e[i];if(i)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=i[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0}}if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}return i.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,i}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const i of t){const t=this.getGroup(i);e.has(t)||e.set(t,[]),e.get(t).push(i)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveColorMap(t){const e=new Set;for(const i of t){const t=this.getColor(i);t&&e.add(t)}const i=Array.from(e).sort(),n=i.join("\0");if(this._colorMapCache&&this._colorMapCache.key===n)return this._colorMapCache.map;const r=Array.isArray(this.config.colorScheme)?this.config.colorScheme:b,o=new Map;for(let t=0;i.length>t;t++)o.set(i[t],r[t%r.length]);return this._colorMapCache={key:n,map:o},o}resolveLineStyle(t,e){const i=this.config.lineStyle;if("function"==typeof i){const n=i(e||{},t);if(n&&!n.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{stroke:e})}return n}return i&&"object"==typeof i?{stroke:i.stroke||"#007bff",strokeWidth:i.strokeWidth||2,strokeDasharray:i.strokeDasharray,fill:i.fill,fillOpacity:i.fillOpacity,opacity:i.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var i;if(this.config.areaStyle){const i=this.config.areaStyle(e||{});if(i&&!i.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{fill:e,stroke:i.stroke||e})}return i}const n=this.config.lineStyle;if("function"==typeof n){const i=n(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}return n&&"object"==typeof n?{fill:n.fill||n.stroke||"#4e79a7",fillOpacity:null!==(i=n.fillOpacity)&&void 0!==i?i:.7,stroke:n.stroke||"#4e79a7",strokeWidth:n.strokeWidth||2}:{fill:"#4e79a7",fillOpacity:.7,stroke:"#4e79a7",strokeWidth:2}}resolveGroupColor(t){if(this._colorMapCache){const e=this._colorMapCache.map.get(t);if(e)return e}const e=this._groupColorMap.get(t);if(e)return e;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:b,n=i[this._groupColorMap.size%i.length];return this._groupColorMap.set(t,n),n}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(t){var e,i,n,r;const o=Object.assign({},this.config);void 0!==t.colorScheme&&(this._colorMapCache=null,this._groupColorMap=new Map),void 0===t.barColors&&void 0===t.colorScheme||(this._barCategoryCache=null),void 0===t.normalize&&void 0===t.extentPadding&&void 0===t.xAccessor&&void 0===t.yAccessor&&void 0===t.groupAccessor&&void 0===t.categoryAccessor&&void 0===t.chartType||(this._stackExtentCache=null);let s=!1;Object.assign(this.config,t);const a="chartType"in t&&t.chartType!==o.chartType||"runtimeMode"in t&&t.runtimeMode!==o.runtimeMode;if(a||void 0!==t.xAccessor||void 0!==t.yAccessor||void 0!==t.timeAccessor||void 0!==t.valueAccessor){const c=a||!p(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(i=o.xAccessor)&&void 0!==i?i:o.timeAccessor),l=a||!p(null!==(n=t.yAccessor)&&void 0!==n?n:t.valueAccessor,null!==(r=o.yAccessor)&&void 0!==r?r:o.valueAccessor);(c||l)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=m(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=m(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=m(this.config.xAccessor,"x"),this.getY=m(this.config.yAccessor,"y")),s=!0)}if("groupAccessor"in t&&!p(t.groupAccessor,o.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?x(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in t&&!p(t.categoryAccessor,o.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?x(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in t&&!p(t.sizeAccessor,o.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?m(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in t&&!p(t.colorAccessor,o.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?x(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in t&&!p(t.y0Accessor,o.y0Accessor)&&(this.getY0=this.config.y0Accessor?m(this.config.y0Accessor,"y0"):void 0,s=!0),"pointIdAccessor"in t&&!p(t.pointIdAccessor,o.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?x(this.config.pointIdAccessor):void 0,s=!0),!s){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const i of e)if(t[i]!==o[i]){s=!0;break}}s&&(this.needsFullRebuild=!0)}}function C(t,e){var i=t.get(e);if(!i)throw Error("missing: "+e);return i}function R(t,e){var i,n=[],r=[],o=[],s={},a=[];function c(t){o[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],o[e]&&c(e)})}function l(t){var e,n,h=!1;for(r.push(t),o[t]=!0,e=0;a[t].length>e;e++)(n=a[t][e])===i?(u(i,r),h=!0):o[n]||(h=l(n));if(h)c(t);else for(e=0;a[t].length>e;e++){var f=s[n=a[t][e]];f||(s[n]=f={}),f[n]=!0}return r.pop(),h}function u(t,e){var i=[].concat(e).concat(t);n.push(i)}function h(e){!function(e){for(var i=0;t.length>i;i++)i>=e&&t[i]||(t[i]=[]),t[i]=t[i].filter(function(t){return t>=e})}(e);for(var i,n=function(t){for(var e=t.length,i=Array(e),n=Array(e),r=Array(e),o=Array(e),s=Array(e),a=Array(e),c=0;e>c;++c)i[c]=-1,n[c]=0,r[c]=!1,o[c]=0,s[c]=-1,a[c]=[];var l,u=0,h=[],f=[];function d(e){var c=[e],l=[e];for(i[e]=n[e]=u,r[e]=!0,u+=1;l.length>0;){var d=t[e=l[l.length-1]];if(d.length>o[e]){for(var g=o[e];d.length>g;++g){var y=d[g];if(0>i[y]){i[y]=n[y]=u,r[y]=!0,u+=1,c.push(y),l.push(y);break}r[y]&&(n[e]=0|Math.min(n[e],n[y])),0>s[y]||a[e].push(s[y])}o[e]=g}else{if(n[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]=h.length,x===e){c.length=g;break}}h.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];f.push(b)}l.pop()}}}for(c=0;e>c;++c)0>i[c]&&d(c);for(c=0;f.length>c;c++){var g=f[c];if(0!==g.length){g.sort(function(t,e){return t-e}),l=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&l.push(g[y]);f[c]=l}}return{components:h,adjacencyList:f}}(t),r=n.components.filter(function(t){return t.length>1}),o=1/0,s=0;r.length>s;s++)for(var a=0;r[s].length>a;a++)o>r[s][a]&&(o=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:o,adjList:l}}i=0;for(var f=t.length;f>i;){var d=h(i);if(i=d.leastVertex,a=d.adjList){for(var g=0;a.length>g;g++)for(var y=0;a[g].length>y;y++){var p=a[g][y];o[+p]=!1,s[p]={}}l(i),i+=1}else i=f}return n}function z(t){return t.y0-t.y1>0?"up":"down"}function B(t,e){return e(t.source)==e(t.target)}function I(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 Y(t){return t.target.x0-t.source.x1}function X(t,e){var i=q(t),n=Y(e)/Math.tan(i);return"up"==z(t)?t.y1-n:t.y1+n}function F(t,e){var i=q(t),n=Y(e)/Math.tan(i);return"up"==z(t)?t.y1+n:t.y1-n}function q(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function V(t,e){return e(t)}function G(t){return Z(t.source)}function H(t){return Z(t.target)}function Z(t){return(t.y0+t.y1)/2}function K(t){return t.virtual?0:t.value}function Q(t,e){var i=0;t.sourceLinks.forEach(function(t){i=t.circular&&!B(t,e)?i+1:i});var n=0;return t.targetLinks.forEach(function(t){n=t.circular&&!B(t,e)?n+1:n}),i+n}function U(t){return t.target.depth}function J(t,e){return t.sourceLinks.length?t.depth:e-1}function tt(t,e){return t.y0-e.y0}function et(t,e){return e.y0-t.y0}function it(t,e){return t.y1-e.y1}function nt(t,e){return e.y1-t.y1}function rt(t,e){return st(t.source,e.source)||t.index-e.index}function ot(t,e){return st(t.target,e.target)||t.index-e.index}function st(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function at(t,e){return ct(t)==ct(e)?"bottom"==t.circularLinkType?et(t,e):tt(t,e):ct(e)-ct(t)}function ct(t){return t.target.column-t.source.column}function lt(t,e){return ut(t)==ut(e)}function ut(t){return t.y0-t.y1>0?"up":"down"}function ht(t,e,i,n,o){let s=t;var a=Math.max(8,.15*(s.y1-s.y0));s.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,a))});var c=r.min(s.links,function(t){return t.source.y0});s.links.forEach(function(t){t.circular&&(t.circularPathData={})});var l=s.links.filter(function(t){return t.circular});return l.sort(function(t,e){return e.value-t.value}),l.forEach(function(t,e){t._circularStub=e>=4}),ft(s.links.filter(function(t){return"top"==t.circularLinkType}),e,i),ft(s.links.filter(function(t){return"bottom"==t.circularLinkType}),e,i),s.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+n,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,B(t,e)&&I(t))t.circularPathData.rightSmallArcRadius=n+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=n+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=n+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=n+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var r=t.source.column,a=t.circularLinkType,l=s.links.filter(function(t){return t.source.column==r&&t.circularLinkType==a});l.sort("bottom"==t.circularLinkType?et:tt);var u=0;l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=n+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=n+t._circularWidth/2+r*i+u),u+=e._circularWidth||e.width}),r=t.target.column,(l=s.links.filter(function(t){return t.target.column==r&&t.circularLinkType==a})).sort("bottom"==t.circularLinkType?nt:it),u=0,l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=n+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=n+t._circularWidth/2+r*i+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(s.y1,t.source.y1,t.target.y1)+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=c-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,i=t.y0,n=t.target.x0,r=t.y1,o=(e+n)/2;return"M"+e+","+i+"C"+o+","+i+" "+o+","+r+" "+n+","+r}(t)}),s}function ft(t,e,i){t.sort(at);var n=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,r){var o=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(B(t,e)&&I(t))t.circularPathData.verticalBuffer=o+t._circularWidth/2;else{for(var s=0;n.length>s;s++){var a=n[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&dt(t,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+i;o=c>o?c:o}}t.circularPathData.verticalBuffer=o+t._circularWidth/2}}),t}function dt(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function gt(t){return function(){return t}}function yt(t){return t.index}function pt(t){return t.nodes}function mt(t){return t.links}function vt(t,e,i){var n=r.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});n.forEach(function(r,o){var s=r.length;if(e)r.sort(e);else if(o>0){var a=new Map;r.forEach(function(t,e){var i,n,r,o=(n=0,r=0,(i=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=Z(t.source)*e,n+=e}}),i.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=Z(t.target)*e,n+=e}}),n>0?r/n:NaN);a.set(t,{bc:o,idx:e})}),r.sort(function(t,e){var i=a.get(t),n=a.get(e),r=i.bc,o=n.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(r)||isNaN(o)?isNaN(r)?isNaN(o)?i.idx-n.idx:1:-1:r-o})}else r.sort(function(t,e){return t.circularLinkType==e.circularLinkType?Q(e,i)-Q(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==n.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==Q(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 xt(t,e,i,n,o,s){var a=r.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});h();for(var c=1,l=s;l>0;--l)u(c*=.99,i),h();function u(e,i){var n=a.length;a.forEach(function(o){var s=o.length,a=o[0].depth;o.forEach(function(o){var c;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&Q(o,i)>0){var l=r.mean(o.sourceLinks,H),u=r.mean(o.targetLinks,G),h=l&&u?(l+u)/2:l||u;if(h){var f=(h-Z(o))*e*.3;o.y0+=f,o.y1+=f}}else if(0==a&&1==s)o.y0=t.y1/2-(c=o.y1-o.y0)/2,o.y1=t.y1/2+c/2;else if(a==n-1&&1==s)o.y0=t.y1/2-(c=o.y1-o.y0)/2,o.y1=t.y1/2+c/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)c=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+c;else{var d=r.mean(o.sourceLinks,H),g=r.mean(o.targetLinks,G),y=((d&&g?(d+g)/2:d||g)-Z(o))*e;o.y0+=y,o.y1+=y}})})}function h(){a.forEach(function(i){var r,s,a,c=t.y0,l=i.length;for(i.sort(e||st),a=0;l>a;++a)(s=c-(r=i[a]).y0)>0&&(r.y0+=s,r.y1+=s),c=r.y1+n;if((s=c-n-t.y1)>0)for(c=r.y0-=s,r.y1-=s,a=l-2;a>=0;--a)(s=(r=i[a]).y1+o-c)>0&&(r.y0-=s,r.y1-=s),c=r.y0})}}function bt(t){t.nodes.forEach(function(t){t.sourceLinks.sort(ot),t.targetLinks.sort(rt)}),t.nodes.forEach(function(t){var e=t.y0,i=e,n=t.y1,r=n;t.sourceLinks.forEach(function(t){t.circular?(t.y0=n-t.width/2,n-=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 kt(){var t=0,e=0,i=1,n=1,o=24,s=8,a=null,c=yt,l=J,u=void 0,h=32,f=2,d=pt,g=mt;function y(){var y={nodes:d.apply(null,arguments),links:g.apply(null,arguments)};return function(d){d.x0=t,d.y0=e,d.x1=i,d.y1=n,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 r.group(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 n=t.source,r=t.target;"object"!=typeof n&&(n=t.source=C(i,n)),"object"!=typeof r&&(r=t.target=C(i,r)),n.sourceLinks.push(t),r.targetLinks.push(t)})}(d,c),function(t,e){var i=0;if(null==e){for(var n=[],r=0;t.links.length>r;r++){var o=t.links[r],s=o.source.index,a=o.target.index;n[s]||(n[s]=[]),n[a]||(n[a]=[]),-1===n[s].indexOf(a)&&n[s].push(a)}var c=R(n);c.sort(function(t,e){return t.length-e.length});var l={};for(r=0;c.length>r;r++){var u=c[r].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,n=t.source.index;e===n||l[n]&&l[n][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,u),function(t,e){var i=0,n=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:n>i?"top":"bottom","top"==r.circularLinkType?i++:n++,t.nodes.forEach(function(t){V(t,e)!=V(r.source,e)&&V(t,e)!=V(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),B(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(d,c),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(r.sum(t.sourceLinks,K),r.sum(t.targetLinks,K)),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 n,r,o;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(n=t.nodes,r=[],o=0;n.length;++o,n=r,r=[])n.forEach(function(t){t.depth=o,t.sourceLinks.forEach(function(t){0>r.indexOf(t.target)&&!t.circular&&r.push(t.target)})});for(n=t.nodes,r=[],o=0;n.length;++o,n=r,r=[])n.forEach(function(t){t.height=o,t.targetLinks.forEach(function(t){0>r.indexOf(t.source)&&!t.circular&&r.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?i(t,o):t.column})}(d,u,l);var g=s;if(null!==a){var y=r.groups(d.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=r.max(y,function(t){return t.length});p>1&&(g=Math.max(1,(n-e)*a/(p-1)))}(function(t,e,i){var n=r.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var o=r.min(n,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/r.sum(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var s=r.max(t.nodes,function(t){return t.column});t.nodes.forEach(s>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-i)/s),e.x1=e.x0+i}:function(e){e.x0=t.x0,e.x1=e.x0+i})})(d,g,o),vt(d,u,c),xt(d,u,c,g,g,h),bt(d),ht(d,c,f,10,8),vt(d,u,c),xt(d,u,c,g,g,h),bt(d),ht(d,c,f,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 n=i.links.filter(function(i){return V(i.source,e)==V(t,e)}),r=n.length;r>1&&n.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!lt(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var i=X(e,t);return t.y1-i}if(e.target.column>t.target.column)return X(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var o=t.y0;n.forEach(function(t){t.y0=o+t.width/2,o+=t.width}),n.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var o=i+1,s=0;r>o;o++)s+=n[o].width;e.y0=t.y1-s-e.width/2}})})}(d,c),function(t,e){let i=t;i.nodes.forEach(function(t){var n=i.links.filter(function(i){return V(i.target,e)==V(t,e)}),r=n.length;r>1&&n.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!lt(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var i=F(e,t);return t.y0-i}if(e.source.column>t.source.column)return F(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var o=t.y0;n.forEach(function(t){t.y1=o+t.width/2,o+=t.width}),n.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var o=i+1,s=0;r>o;o++)s+=n[o].width;e.y1=t.y1-s-e.width/2}})})}(d,c),function(t){var e=t.nodes,i=t.links,n=!1,o=!1;if(i.forEach(function(t){"top"==t.circularLinkType?n=!0:"bottom"==t.circularLinkType&&(o=!0)}),0==n||0==o){var s=r.min(e,function(t){return t.y0}),a=r.max(e,function(t){return t.y1}),c=(t.y1-t.y0)/(a-s);function l(e){return(e-s)/(a-s)*(t.y1-t.y0)+t.y0}1>c?(e.forEach(function(t){t.y0=l(t.y0),t.y1=l(t.y1)}),i.forEach(function(t){t.y0=l(t.y0),t.y1=l(t.y1),t.width=t.width*c})):e.forEach(function(t){var e=t.y1-t.y0,i=l(t.y0)-t.y0;t.y0=l(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),ht(d,c,f,10,8)}(y),y}return y.update=function(t){return bt(t),ht(t,c,f,10,8),t},y.nodeWidth=function(t){return arguments.length?(o=+t,y):o},y.nodePadding=function(t){return arguments.length?(s=+t,y):s},y.nodePaddingRatio=function(t){return arguments.length?(a=+t,y):a},y.nodes=function(t){return arguments.length?(d="function"==typeof t?t:gt(t),y):d},y.links=function(t){return arguments.length?(g="function"==typeof t?t:gt(t),y):g},y.nodeId=function(t){return arguments.length?(c="function"==typeof t?t:gt(t),y):c},y.nodeAlign=function(t){return arguments.length?(l="function"==typeof t?t:gt(t),y):l},y.nodeSort=function(t){return arguments.length?(u=t,y):u},y.iterations=function(t){return arguments.length?(h=+t,y):h},y.circularLinkGap=function(t){return arguments.length?(f=+t,y):f},y.extent=function(r){return arguments.length?(t=+r[0][0],e=+r[0][1],i=+r[1][0],n=+r[1][1],y):[[t,e],[i,n]]},y.size=function(r){return arguments.length?(t=e=0,i=+r[0],n=+r[1],y):[i-t,n-e]},y}j.QUADTREE_THRESHOLD=500;const wt=t=>{let e,i,n,r,s,a,c,l,u;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,i=t.y1-t.sankeyWidth/2,n=t.y1+t.sankeyWidth/2,r=t.y0+t.sankeyWidth/2,s=t.source.x1,a=t.target.x0,c=o.interpolateNumber(s,a),l=c(.5),u=c(.5),`M${e},${s}C${e},${l} ${i},${u} ${i},${a}L${n},${a}C${n},${u} ${r},${l} ${r},${s}Z`):(e=t.source.x1,i=t.target.x0,c=o.interpolateNumber(e,i),n=c(.5),r=c(.5),s=t.y0-t.sankeyWidth/2,a=t.y1-t.sankeyWidth/2,l=t.y1+t.sankeyWidth/2,u=t.y0+t.sankeyWidth/2,`M${e},${s}C${n},${s} ${r},${a} ${i},${a}L${i},${l}C${r},${l} ${n},${u} ${e},${u}Z`)};function _t(t){var e;const i=t.sankeyWidth/2,n=(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,n=r.sourceY,o=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*(o-r.leftFullExtent)));return`M${e},${n-i}L${e+a},${n-i}L${e+a},${n+i}L${e},${n+i}ZM${o},${s-i}L${o-c},${s-i}L${o-c},${s+i}L${o},${s+i}Z`}const o=r.sourceX,s=r.sourceY,a=r.targetX,c=r.targetY,l=r.rightFullExtent,u=r.leftFullExtent,h=r.verticalFullExtent,f="bottom"===t.circularLinkType?1:-1,d=Math.max(4,Math.min(n,15));return`M${o},${s-f*i}L${l},${s-f*i}L${l+n},${s-f*i+f*d}L${l+n},${h+f*n-f*d}L${l+n-d},${h+f*n}L${u-n+d},${h+f*n}L${u-n},${h+f*n-f*d}L${u-n},${c-f*i+f*d}L${u-n+d},${c-f*i}L${a},${c-f*i}L${a},${c+f*i}L${u+n},${c+f*i}L${u+n},${h-f*n}L${l-n},${h-f*n}L${l-n},${s+f*i}L${o},${s+f*i}Z`}const At=new Set,St=new WeakMap;function Pt(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let i=St.get(t);if(i){const t=i.get(e);if(t)return t}else i=new Map,St.set(t,i);const n=new Proxy(t,{get(t,i,n){if("string"==typeof i&&!(i in t)&&t.data&&i in t.data){const t=`${e}:${i}`;At.has(t)||(At.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,n)}});return i.set(e,n),n}const Mt={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(U))-1:0},justify:J},Et={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,n){var r,o,s,a,c,l,u;if(0===t.length)return;const h="vertical"===i.orientation?"down":"right",f=i.nodeAlign||"justify",d=null!==(r=i.nodeWidth)&&void 0!==r?r:15,g=null!==(o=i.nodePaddingRatio)&&void 0!==o?o:.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"===h?[[0,0],[n[1],n[0]]]:[[0,0],[n[0],n[1]]];const x=kt().extent(v).links(m).nodes(p).nodeAlign(Mt[f]||J).nodeId(t=>t.id).nodeWidth(d).iterations(y);x.nodePaddingRatio&&x.nodePaddingRatio(g),x();{let t=1/0,e=-1/0,i=1/0,r=-1/0;for(const n of p)t>n.x0&&(t=n.x0),n.x1>e&&(e=n.x1),i>n.y0&&(i=n.y0),n.y1>r&&(r=n.y1);for(const n of m){if(!n.circular||!n.circularPathData)continue;const o=n.circularPathData,s=(null!==(c=null!==(a=n._circularWidth)&&void 0!==a?a:n.width)&&void 0!==c?c:0)/2;t>o.leftFullExtent-s&&(t=o.leftFullExtent-s),o.rightFullExtent+s>e&&(e=o.rightFullExtent+s),i>o.verticalFullExtent-s&&(i=o.verticalFullExtent-s),o.verticalFullExtent+s>r&&(r=o.verticalFullExtent+s)}const o=e-t,s=r-i,u=n[0],h=n[1];if(o>0&&s>0&&(0>t||0>i||e>u||r>h)){const e=Math.min(u/o,h/s),n=-t*e+(u-o*e)/2,r=-i*e+(h-s*e)/2;for(const t of p)t.x0=t.x0*e+n,t.x1=t.x1*e+n,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+n,i.targetX=i.targetX*e+n,i.sourceY=i.sourceY*e+r,i.targetY=i.targetY*e+r,i.rightFullExtent=i.rightFullExtent*e+n,i.leftFullExtent=i.leftFullExtent*e+n,i.verticalFullExtent=i.verticalFullExtent*e+r,i.rightInnerExtent=i.rightInnerExtent*e+n,i.leftInnerExtent=i.leftInnerExtent*e+n,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,n="object"==typeof e&&null!==e?e.id:e+"",r="object"==typeof i&&null!==i?i.id:i+"",o=k.get(t._edgeKey?t._edgeKey:`${n}\0${r}`);if(o){o.y0=t.y0,o.y1=t.y1,o.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,o.circular=!!t.circular,o.circularPathData=t.circularPathData,o._circularWidth=t._circularWidth,o._circularStub=t._circularStub,o.path=t.path,o.circularLinkType=t.circularLinkType,o.direction=h;const e=b.get(n),i=b.get(r);e&&(o.source=e),i&&(o.target=i)}}},buildScene(t,e,i,r){var o,s,a,c;const l="vertical"===i.orientation?"down":"right",u=i.nodeStyle,h=i.edgeStyle,f=null!==(o=i.edgeOpacity)&&void 0!==o?o:.5,d=i.edgeColorBy||"source",g=Array.isArray(i.colorScheme)?i.colorScheme:n.schemeCategory10,y=new Map;t.forEach((t,e)=>{y.set(t.id,g[e%g.length])});const p=[],m=[],v=[],x=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 n=u?u(Pt(e,"nodeStyle")):{},r={fill:n.fill||y.get(e.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity};x.set(e.id,("string"==typeof r.fill?r.fill:null)||y.get(e.id)||"#4d430c"),p.push("down"===l?{type:"rect",x:e.y0,y:e.x0,w:i,h:t,style:r,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:i,style:r,datum:e,id:e.id,label:e.id})}const b=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of b){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let n="#999";n="function"==typeof d?d(t)||n:"target"===d?x.get(i.id)||y.get(i.id)||n:x.get(e.id)||y.get(e.id)||n;const r=h?h(Pt(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))),c=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),l=r.fill||n;m.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:l,fillOpacity:null!==(s=r.fillOpacity)&&void 0!==s?s:f,stroke:"none",opacity:r.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+o}}),m.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-i}L${e.targetX-c},${e.targetY-i}L${e.targetX-c},${e.targetY+i}L${e.targetX},${e.targetY+i}Z`,style:{fill:l,fillOpacity:null!==(a=r.fillOpacity)&&void 0!==a?a:f,stroke:"none",opacity:r.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-c,x1:e.targetX}});continue}let o;if(o=t.circular&&t.circularPathData?_t(t):wt(t),!o)continue;const l={fill:r.fill||n,fillOpacity:null!==(c=r.fillOpacity)&&void 0!==c?c:f,stroke:r.stroke||"none",strokeWidth:r.strokeWidth,opacity:r.opacity};m.push({type:"bezier",pathD:o,bezierCache:t.bezier,style:l,datum:t})}if(!1!==i.showLabels){const e=(k=i.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null;for(const i of t){const t=i.x1-i.x0,n=i.y1-i.y0;if(0>=t||0>=n)continue;const o=e?e(i):i.id;if(!o)continue;let s,a,c;"down"===l?(s=i.y0+(i.y1-i.y0)/2,a=i.x1+14,c="middle"):(r[0]/2>i.x0+t/2?(s=i.x0-6,c="end"):(s=i.x1+6,c="start"),a=i.y0+n/2),v.push({x:s,y:a,text:o+"",anchor:c,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:p,sceneEdges:m,labels:v}}},Lt={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,n){var r,o;if(0===t.length)return;const a=null!==(r=i.forceStrength)&&void 0!==r?r:.1,c=n[0]/2,l=n[1]/2,u=i.__previousPositions;let h=0;const f=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),i=null==u?void 0:u.get(e.id);t?h++:i?(e.x=i.x,e.y=i.y,h++):f.push(e)}const d=h>0&&.3>=(t.length>0?f.length/t.length:1);if(d){const i=new Map;for(const e of t)i.set(e.id,e);for(const t of f){const n=Dt(t.id,e,i);if(n.length>0){let e=0,i=0;for(const t of n)e+=t.x,i+=t.y;const r=Ot(t.id),o=r%360*(Math.PI/180),s=10+r%20;t.x=e/n.length+s*Math.cos(o),t.y=i/n.length+s*Math.sin(o)}else{const e=Ot(t.id),i=e%360*(Math.PI/180),n=15+e%30;t.x=c+n*Math.cos(i),t.y=l+n*Math.sin(i)}}}else{const e=2.399963229728653;for(let i=0;t.length>i;i++){const n=t[i];if(null==n.x||null==n.y||0===n.x&&0===n.y){const t=10*Math.sqrt(i+.5),r=i*e;n.x=c+t*Math.cos(r),n.y=l+t*Math.sin(r)}}}const g=null!==(o=i.iterations)&&void 0!==o?o:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),y=d?40:g,p=Nt(i.nodeSize,i.nodeSizeRange,t),m=t=>p(t),v=s.forceLink().strength(t=>Math.min(2.5,t.weight?t.weight*a:a)).id(t=>t.id),x=s.forceSimulation().force("charge",s.forceManyBody().strength(t=>-25*m(t))).force("center",s.forceCenter(c,l).strength(.8)).force("x",s.forceX(c).strength(.15)).force("y",s.forceY(l).strength(.15));if(x.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));x.force("link",v),x.force("link").links(t)}d?x.alpha(.3):.1>x.alpha()&&x.alpha(1),x.stop();for(let t=0;y>t;++t)x.tick();for(const e of t){if(null==e.x||null==e.y)continue;const t=m(e);e.x=Math.max(t,Math.min(n[0]-t,e.x)),e.y=Math.max(t,Math.min(n[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=b.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=b.get(t.target);e&&(t.target=e)}}},buildScene(t,e,i,r){var o,s,a;const c=i.nodeStyle,l=i.edgeStyle,u=Nt(i.nodeSize,i.nodeSizeRange,t),h=Array.isArray(i.colorScheme)?i.colorScheme:n.schemeCategory10,f=new Map;t.forEach((t,e)=>{f.set(t.id,h[e%h.length])});const d=[],g=[],y=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=u(Pt(e,"nodeSize")),i=c?c(Pt(e,"nodeStyle")):{},n={fill:i.fill||f.get(e.id)||"#007bff",stroke:i.stroke||"#fff",strokeWidth:null!==(o=i.strokeWidth)&&void 0!==o?o:2,opacity:i.opacity};d.push({type:"circle",cx:e.x,cy:e.y,r:t,style:n,datum:e,id:e.id,label:e.id})}const p=new Map;for(const e of t)p.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:p.get(t.source),i="object"==typeof t.target?t.target:p.get(t.target);if(!e||!i)continue;if(null==e.x||null==e.y)continue;if(null==i.x||null==i.y)continue;const n=l?l(Pt(t,"edgeStyle")):{},r={stroke:n.stroke||"#999",strokeWidth:null!==(s=n.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=n.opacity)&&void 0!==a?a:.6};g.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:r,datum:t})}if(!1!==i.showLabels){const e=(m=i.nodeLabel)?"function"==typeof m?m:t=>t[m]||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 n=u(Pt(i,"nodeSize"));y.push({x:i.x,y:i.y-n-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var m;return{sceneNodes:d,sceneEdges:g,labels:y}}};function Dt(t,e,i){const n=[];for(const r of e){const e="string"==typeof r.source?r.source:r.source.id,o="string"==typeof r.target?r.target:r.target.id;let s=null;if(e===t?s=o:o===t&&(s=e),s){const t=i.get(s);!t||0===t.x&&0===t.y||n.push({x:t.x,y:t.y})}}return n}function Ot(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 Nt(t,i,n){var o,s;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const a=i||[5,20],c=n.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===c.length)return()=>a[0];const l=null!==(o=r.min(c))&&void 0!==o?o:0,u=null!==(s=r.max(c))&&void 0!==s?s:1;if(l===u)return()=>(a[0]+a[1])/2;const h=e.scaleLinear().domain([l,u]).range(a).clamp(!0);return e=>{var i;const n=null===(i=e.data)||void 0===i?void 0:i[t];return null==n||"number"!=typeof n?a[0]:h(n)}}const $t=n.schemeCategory10,Tt={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,i,n){if(0===t.length)return;const{padAngle:r=.01,groupWidth:o=20,sortGroups:s}=i,l=Math.min(n[0],n[1])/2,u=l-o,h=n[0]/2,f=n[1]/2,d=(g=i.valueAccessor)?"function"==typeof g?g:t=>{var e;return null!==(e=t[g])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var g;const y=new Map;for(let e=0;t.length>e;e++)y.set(t[e].id,e);const p=t.length,m=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,i=y.get("string"==typeof t.source?t.source:t.source.id),n=y.get(e);if(void 0===i||void 0===n)continue;const r=d(t);m[i][n]=r}const v=a.chord().padAngle(r);s&&v.sortGroups(s);const x=v(m),b=x.groups,k=c.arc().innerRadius(u).outerRadius(l);for(const e of b){const i=t[e.index],n=k.centroid(e);i.x=n[0]+h,i.y=n[1]+f,i.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const w=new Map;for(const e of t)w.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,i=w.get("string"==typeof t.source?t.source:t.source.id),n=w.get(e);i&&(t.source=i),n&&(t.target=n)}const _=new Map;for(const t of e)_.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of x){const i=t[e.source.index].id,n=t[e.target.index].id,r=_.get(`${i}\0${n}`)||_.get(`${n}\0${i}`);r&&(r.chordData=e)}},buildScene(t,e,i,n){var r,o;const{groupWidth:s=20,edgeOpacity:c=.5}=i,l=Math.min(n[0],n[1])/2,u=l-s,h=n[0]/2,f=n[1]/2,d=i.nodeStyle,g=i.edgeStyle,y=i.edgeColorBy||"source",p=Array.isArray(i.colorScheme)?i.colorScheme:$t,m=new Map;t.forEach((t,e)=>{m.set(t.id,p[e%p.length])});const v=a.ribbon().radius(u),x=[],b=[],k=[];for(let e=0;t.length>e;e++){const i=t[e],n=i.arcData;if(!n)continue;let o;o=d?d(Pt(i,"nodeStyle")).fill||m.get(i.id)||p[e%p.length]:m.get(i.id)||p[e%p.length];const s=d?d(Pt(i,"nodeStyle")):{},a={fill:o,stroke:s.stroke||"black",strokeWidth:null!==(r=s.strokeWidth)&&void 0!==r?r:1,opacity:s.opacity};x.push({type:"arc",cx:h,cy:f,innerR:u,outerR:l,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:a,datum:i,id:i.id,label:i.id})}for(const t of e){const e=t.chordData;if(!e)continue;const i=v(e);if(!i)continue;const n=Wt(i,h,f);let r="#999";if(g)r=g(Pt(t,"edgeStyle")).fill||r;else{const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;"target"===y&&i?r=m.get(i.id)||r:e&&(r=m.get(e.id)||r)}const s=g?g(Pt(t,"edgeStyle")):{},a={fill:r,fillOpacity:null!==(o=s.fillOpacity)&&void 0!==o?o:c,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity};b.push({type:"ribbon",pathD:n,style:a,datum:t})}if(!1!==i.showLabels){const e=(w=i.nodeLabel)?"function"==typeof w?w:t=>t[w]||t.id:null,n=l+12;for(const i of t){const t=i.arcData;if(!t)continue;const r=e?e(i):i.id;if(!r)continue;const o=(t.startAngle+t.endAngle)/2,s=o-Math.PI/2;k.push({x:h+Math.cos(s)*n,y:f+Math.sin(s)*n,text:r+"",anchor:o>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:x,sceneEdges:b,labels:k}}};function Wt(t,e,i){const n=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!n)return t;const r=[];let o=0;for(;n.length>o;){const t=n[o];if("M"===t||"L"===t)for(r.push(t),o++;n.length>o&&!isNaN(Number(n[o]));)r.push(Number(n[o])+e+""),o++,n.length>o&&!isNaN(Number(n[o]))&&(r.push(Number(n[o])+i+""),o++);else if("C"===t)for(r.push(t),o++;n.length>o&&!isNaN(Number(n[o]));)for(let t=0;3>t&&n.length>o&&!isNaN(Number(n[o]));t++)r.push(Number(n[o])+e+""),o++,n.length>o&&!isNaN(Number(n[o]))&&(r.push(Number(n[o])+i+""),o++);else if("Q"===t)for(r.push(t),o++;n.length>o&&!isNaN(Number(n[o]));)for(let t=0;2>t&&n.length>o&&!isNaN(Number(n[o]));t++)r.push(Number(n[o])+e+""),o++,n.length>o&&!isNaN(Number(n[o]))&&(r.push(Number(n[o])+i+""),o++);else if("A"===t)for(r.push(t),o++;n.length>o&&!isNaN(Number(n[o]));)r.push(n[o++]),n.length>o&&r.push(n[o++]),n.length>o&&r.push(n[o++]),n.length>o&&r.push(n[o++]),n.length>o&&r.push(n[o++]),n.length>o&&(r.push(Number(n[o])+e+""),o++),n.length>o&&(r.push(Number(n[o])+i+""),o++);else"Z"===t||"z"===t?(r.push(t),o++):(r.push(n[o]),o++)}return r.join(" ")}const jt=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Ct(t){const[e,i,n]=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*n>150?"#222":"#fff"}function Rt(t,e,i){const n=e.nodeIDAccessor;return"function"==typeof n?n(t.data)+"":"string"==typeof n&&void 0!==t.data[n]?t.data[n]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+i}function zt(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 Bt(t,e,i,n,r){if("horizontal"===r){const r=(t+i)/2;return`M ${t},${e} C ${r},${e} ${r},${n} ${i},${n}`}if("radial"===r){const r=(t+i)/2;return`M ${t},${e} Q ${r},${e} ${r},${(e+n)/2} T ${i},${n}`}{const r=(e+n)/2;return`M ${t},${e} C ${t},${r} ${i},${r} ${i},${n}`}}const It={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,i,n){var r;const o=i.__hierarchyRoot;if(!o)return;const s=i.chartType,a=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(i.childrenAccessor),c=i.hierarchySum||(t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0}),u=l.hierarchy(o,a);u.sum(c),u.sort((t,e)=>{var i,n;return(null!==(i=e.value)&&void 0!==i?i:0)-(null!==(n=t.value)&&void 0!==n?n:0)});const[h,f]=n;switch(s){case"tree":!function(t,e,i,n){const r=e.treeOrientation||"vertical",o=l.tree();o.size("horizontal"===r?[n,i]:"radial"===r?[2*Math.PI,Math.min(i,n)/2*.8]:[i,n]),o(t)}(u,i,h,f);break;case"cluster":!function(t,e,i,n){const r=e.treeOrientation||"vertical",o=l.cluster();o.size("horizontal"===r?[n,i]:"radial"===r?[2*Math.PI,Math.min(i,n)/2*.8]:[i,n]),o(t)}(u,i,h,f);break;case"treemap":!function(t,e,i,n){var r,o;const s=null!==(r=e.padding)&&void 0!==r?r:4,a=null!==(o=e.paddingTop)&&void 0!==o?o:0,c=l.treemap().size([i,n]).tile(l.treemapBinary).padding(s);a>0&&c.paddingTop(a),c(t)}(u,i,h,f);break;case"circlepack":!function(t,e,i,n){var r;const o=null!==(r=e.padding)&&void 0!==r?r:4;l.pack().size([i,n]).padding(o)(t)}(u,i,h,f);break;case"partition":!function(t,e,i,n){var r;l.partition().size([i,n]).padding(null!==(r=e.padding)&&void 0!==r?r:1)(t)}(u,i,h,f)}const d=u.descendants();t.length=0,e.length=0;const g=new Map;for(let e=0;d.length>e;e++){const n=d[e],o={id:Rt(n,i,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(r=n.value)&&void 0!==r?r:0,depth:n.depth,data:n.data,createdByFrame:!0};"tree"===s||"cluster"===s?Yt(o,n,i):"treemap"===s||"partition"===s?Xt(o,n):"circlepack"===s&&Ft(o,n),o.__hierarchyNode=n,t.push(o),g.set(n,o)}if("tree"===s||"cluster"===s)for(const t of d)if(t.parent){const i=g.get(t.parent),n=g.get(t);i&&n&&e.push({source:i,target:n,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,i,n){const r=i.nodeStyle||(()=>({})),o=i.edgeStyle||(()=>({}));switch(i.chartType){case"tree":case"cluster":return function(t,e,i,n,r,o){var s,a,c,l,u;const h=[],f=[],d=[],g=i.treeOrientation||"vertical",y="radial"===g,p=n[0]/2,m=n[1]/2,v="number"==typeof(x=i.nodeSize)?x:5;var x;for(const e of t){let t=e.x,n=e.y;y&&(t+=p,n+=m);const o=r(Pt(e,"nodeStyle"));let a=o.fill||"#4d430c";i.colorByDepth&&void 0!==e.depth&&(a=jt[e.depth%jt.length]);const c={fill:a,stroke:o.stroke||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:1,opacity:o.opacity};h.push({type:"circle",cx:t,cy:n,r:v,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const b=null!==(a=i.edgeOpacity)&&void 0!==a?a:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let n=e.x,r=e.y,s=i.x,a=i.y;y&&(n+=p,r+=m,s+=p,a+=m);const u=Bt(n,r,s,a,g),h=o(Pt(t,"edgeStyle")),d={fill:"none",stroke:h.stroke||"#999",strokeWidth:null!==(c=h.strokeWidth)&&void 0!==c?c:1.5,opacity:null!==(l=h.opacity)&&void 0!==l?l:b};f.push({type:"curved",pathD:u,style:d,datum:t})}if(!1!==i.showLabels){const e=zt(i.nodeLabel);for(const i of t){const t=e?e(i):i.id;if(!t)continue;let n,r,o,s=i.x,a=i.y;if(y&&(s+=p,a+=m),y){const t=s-p,e=a-m,i=Math.sqrt(t*t+e*e);i>0?(n=s+t/i*10,r=a+e/i*10,o=0>t?"end":"start"):(n=s,r=a-12,o="middle")}else"horizontal"===g?((null===(u=i.data)||void 0===u?void 0:u.children)&&0!==i.data.children.length?(n=s-v-6,o="end"):(n=s+v+6,o="start"),r=a):(n=s,r=a+v+14,o="middle");d.push({x:n,y:r,text:t+"",anchor:o,baseline:"middle",fontSize:11})}}return{sceneNodes:h,sceneEdges:f,labels:d}}(t,e,i,n,r,o);case"treemap":case"partition":return function(t,e,i,n){var r,o;const s=[],a=[];for(const i of t){const t=i.x1-i.x0,o=i.y1-i.y0;if(0>=t||0>=o)continue;const a=n(Pt(i,"nodeStyle"));let c=a.fill||"#4d430c";e.colorByDepth&&void 0!==i.depth&&(c=jt[i.depth%jt.length]);const l={fill:c,stroke:a.stroke||"#fff",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.opacity};s.push({type:"rect",x:i.x0,y:i.y0,w:t,h:o,style:l,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=zt(e.nodeLabel),r=e.labelMode||"leaf",s="partition"===e.chartType;for(const c of t){const t=c.x1-c.x0,l=c.y1-c.y0;if(0>=t||0>=l)continue;const u=!((null===(o=c.data)||void 0===o?void 0:o.children)&&c.data.children.length>0);if(!s){if("leaf"===r&&!u)continue;if("parent"===r&&u)continue}const h=i?i(c):c.id;if(!h)continue;if((u?30:40)>t||(u?16:14)>l)continue;let f=n(Pt(c,"nodeStyle")).fill||"#4d430c";e.colorByDepth&&void 0!==c.depth&&(f=jt[c.depth%jt.length]);const d=Ct(f);a.push(u?{x:c.x0+t/2,y:c.y0+l/2,text:h+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,l)/6)),fill:d}:{x:c.x0+4,y:c.y0+12,text:h+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:d})}}return{sceneNodes:s,sceneEdges:[],labels:a}}(t,i,0,r);case"circlepack":return function(t,e,i,n){var r,o,s,a,c;const l=[],u=[];for(const i of t){const t=null!==(r=i.__radius)&&void 0!==r?r:5;if(0>=t)continue;const a=n(Pt(i,"nodeStyle"));let c=a.fill||"#4d430c";e.colorByDepth&&void 0!==i.depth&&(c=jt[i.depth%jt.length]);const u={fill:c,stroke:a.stroke||"#fff",strokeWidth:null!==(o=a.strokeWidth)&&void 0!==o?o:1,opacity:null!==(s=a.opacity)&&void 0!==s?s:.7};l.push({type:"circle",cx:i.x,cy:i.y,r:t,style:u,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=zt(e.nodeLabel);for(const r of t){const t=null!==(a=r.__radius)&&void 0!==a?a:5,o=i?i(r):r.id;if(!o)continue;if(15>t)continue;const s=!((null===(c=r.data)||void 0===c?void 0:c.children)&&r.data.children.length>0);let l=n(Pt(r,"nodeStyle")).fill||"#4d430c";if(e.colorByDepth&&void 0!==r.depth&&(l=jt[r.depth%jt.length]),s){const e=Ct(l);u.push({x:r.x,y:r.y,text:o+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:e})}else u.push({x:r.x,y:r.y-t+14,text:o+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:"#000",stroke:"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:l,sceneEdges:[],labels:u}}(t,i,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Yt(t,e,i){const n=i.treeOrientation||"vertical";if("radial"===n){const i=e.x,n=e.y;t.x=n*Math.cos(i-Math.PI/2),t.y=n*Math.sin(i-Math.PI/2)}else"horizontal"===n?(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 Xt(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 Ft(t,e){var i;const n=null!==(i=e.r)&&void 0!==i?i:0;t.x=e.x,t.y=e.y,t.x0=e.x-n,t.x1=e.x+n,t.y0=e.y-n,t.y1=e.y+n,t.width=2*n,t.height=2*n,t.__radius=n}function qt(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const Vt={sankey:Et,force:Lt,chord:Tt,tree:It,cluster:It,treemap:It,circlepack:It,partition:It,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,i,n){const r=i.__hierarchyRoot;r&&function(t,e,i,n,r){var o,s;const a=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(i.childrenAccessor),l=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),u=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!==(o=i.orbitSize)&&void 0!==o?o:2.95,f=null!==(s=i.orbitEccentricity)&&void 0!==s?s:1,d="number"==typeof h?()=>h:h,g="number"==typeof f?()=>f:f,y=qt(i);y.metaMap.clear(),n.length=0,r.length=0;const p=new Map;function m(t){var e;const i=null!==(e=p.get(t))&&void 0!==e?e:0;return p.set(t,i+1),0===i?t:`${t}__${i}`}const v=e[0]/2,x=e[1]/2,b=Math.min(e[0],e[1])/2*.85,k=m(l(t));n.push({id:k,x:v,y:x,x0:v,x1:v,y0:x,y1:x,width:0,height:0,value:0,depth:0,data:t}),y.metaMap.set(k,{ring:b,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,i,o,s,h,f,p){const v=a(e);if(!(null==v?void 0:v.length))return;const x=v.length;let b=0,k=0,w=0;for(;x>k;)k+=u[Math.min(w,u.length-1)],w++,b++;let _=0;for(let x=0;b>x;x++){const k=u[Math.min(x,u.length-1)],w=v.slice(_,_+k);if(!w.length)break;const A=(x+1)/b,S={id:i,depth:f,data:e,parentId:i},P=p?h/d(S)*A:h*A,M=c.pie().value(t=>{var e;return(null===(e=a(t))||void 0===e?void 0:e.length)?4:1}).sort(null),E=M(w),L=g(S);for(let e=0;w.length>e;e++){const a=(E[e].startAngle+E[e].endAngle)/2,c=w[e],u=m(l(c)),h=o+P*Math.sin(a),d=s+P*Math.cos(a)*L;n.push({id:u,x:h,y:d,x0:h,x1:h,y0:d,y1:d,width:0,height:0,value:0,depth:f,data:c}),y.metaMap.set(u,{ring:P,angle:a,depth:f,parentId:i,eccentricity:L}),r.push({source:i,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:u}}),t(c,u,h,d,P,f+1,!0)}_+=k}}(t,k,v,x,b,1,!1)}(r,n,i,t,e)},buildScene(t,e,i,n){var r,o,s,a,c;const l=i.nodeStyle,u=i.nodeSize,h="number"==typeof u?()=>u:"function"==typeof u?u:()=>6,f=[],d=[],g=[];if(!1!==i.orbitShowRings){const e=qt(i),n=new Map;for(const e of t)n.set(e.id,e);const r=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=n.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 o=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:i,ecc:n}]of r)for(let r=0;o>r;r++){const a=r/o*Math.PI*2,c=(r+1)/o*Math.PI*2;d.push({type:"line",x1:t+i*Math.sin(a),y1:e+i*Math.cos(a)*n,x2:t+i*Math.sin(c),y2:e+i*Math.cos(c)*n,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=h(Pt(e,"nodeSize")),i=l?l(Pt(e,"nodeStyle")):{},n={fill:i.fill||"#6366f1",stroke:i.stroke||"#fff",strokeWidth:null!==(r=i.strokeWidth)&&void 0!==r?r:1,opacity:null!==(o=i.opacity)&&void 0!==o?o:0===(null!==(s=e.depth)&&void 0!==s?s:0)?1:.85};f.push({type:"circle",cx:e.x,cy:e.y,r:t,style:n,datum:e,id:e.id,label:e.id,depth:e.depth})}const y=new Map;for(const e of t)y.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:y.get(t.source),i="object"==typeof t.target?t.target:y.get(t.target);e&&i&&(null!=e.x&&null!=i.x&&d.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(i.showLabels){const e=i.nodeLabel;for(const i of t){const t=h(Pt(i,"nodeSize"));if(4>=t)continue;const n="function"==typeof e?e(i):e&&null!==(c=null===(a=i.data)||void 0===a?void 0:a[e])&&void 0!==c?c:i.id;g.push({x:i.x,y:i.y+t+12,text:n+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:f,sceneEdges:d,labels:g}},tick:(t,e,i,n,r)=>!1!==i.orbitAnimated&&(function(t,e){var i,n;const r=qt(e),o=null!==(i=e.orbitSpeed)&&void 0!==i?i:.25,s=null!==(n=e.orbitRevolution)&&void 0!==n?n: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=o*(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 n=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(n),e.y=i.y+t.ring*Math.cos(n)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,i),!0)}};function Gt(t,e){const{columns:i,config:n,resolvePieceStyle:r}=t,o=[],s=Math.min(e.width,e.height)/2-4,a="donut"===n.chartType?n.innerRadius||60:0,c=-Math.PI/2+(n.startAngle||0)*Math.PI/180,l=2*Math.PI;for(const t of Object.values(i)){const e=c+t.pctStart*l,i=c+(t.pctStart+t.pct)*l,n=r(t.pieceData[0],t.name);o.push({type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:e,endAngle:i,style:n,datum:t.pieceData,category:t.name})}return o}function Ht(t){var e,i,n;const o=t.length,s=t[0],a=t[o-1];return{n:o,min:s,q1:null!==(e=r.quantile(t,.25))&&void 0!==e?e:s,median:null!==(i=r.quantile(t,.5))&&void 0!==i?i:(s+a)/2,q3:null!==(n=r.quantile(t,.75))&&void 0!==n?n:a,max:a,mean:t.reduce((t,e)=>t+e,0)/o}}const Zt={bar:function(t,e){const{scales:i,columns:n,config:r,getR:o,getStack:s,resolvePieceStyle:a}=t,{r:c,projection:l}=i,u=[],h="vertical"===l,f="horizontal"===l,d=r.normalize,g=[];if(s){const t=new Set;for(const e of Object.values(n))for(const i of e.pieceData){const e=s(i);t.has(e)||(t.add(e),g.push(e))}}else g.push("_default");for(const t of Object.values(n)){const e=new Map;for(const i of t.pieceData){const t=s?s(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const n=e.get(t);n.total+=o(i),n.pieces.push(i)}let i=0;if(d)for(const t of e.values())i+=Math.abs(t.total);let n=0,r=0;for(const o of g){const l=e.get(o);if(!l)continue;let g=l.total;d&&i>0&&(g/=i);const y=a(l.pieces[0],s?o:t.name),p=Object.assign(Object.assign({},l.pieces[0]),{__aggregateValue:l.total,__pieceCount:l.pieces.length,category:t.name});if(h){const e=c(0>g?r:n+g),i=0>g?c(r+g)-c(r):c(n)-c(n+g);u.push(O(t.x,e,t.width,Math.abs(i),y,p,o)),0>g?r+=g:n+=g}else if(f){const e=c(0>g?r+g:n),i=0>g?c(r)-c(r+g):c(n+g)-c(n);u.push(O(e,t.x,Math.abs(i),t.width,y,p,o)),0>g?r+=g:n+=g}}}return u},clusterbar:function(t,e){const{scales:i,columns:n,getR:r,getGroup:o,resolvePieceStyle:s}=t,{r:a,projection:c}=i,l=[],u="vertical"===c,h=[],f=new Set;for(const t of Object.values(n))for(const e of t.pieceData){const t=o?o(e):"_default";f.has(t)||(f.add(t),h.push(t))}const d=h.length||1;for(const t of Object.values(n)){const e=t.width/d,i=.2*e,n=e-i,c=new Map;for(const e of t.pieceData){const t=o?o(e):"_default";c.has(t)||c.set(t,[]),c.get(t).push(e)}for(let o=0;h.length>o;o++){const f=c.get(h[o])||[];for(const c of f){const f=r(c),d=s(c,h[o]);if(u){const r=t.x+o*e+i/2,s=a(0),u=a(f);l.push(O(r,Math.min(s,u),n,Math.abs(s-u),d,c,h[o]))}else{const r=t.x+o*e+i/2,s=a(0),u=a(f);l.push(O(Math.min(s,u),r,Math.abs(u-s),n,d,c,h[o]))}}}}return l},point:function(t,e){var i,n;const{scales:r,columns:o,getR:s,multiScales:a,resolvePieceStyle:c}=t,{r:l,projection:u}=r,h=[],f="vertical"===u,d="radial"===u,g=a.length>0,y=2*Math.PI,p=-Math.PI/2;for(const t of Object.values(o))for(const e of t.pieceData){const r=null!==(i=e.__rIndex)&&void 0!==i?i:0,o=null!==(n=e.__rValue)&&void 0!==n?n:s(e),u=g&&a[r]||l,m=c(e,t.name),v=m.r||5;let x,b;if(d){const e=p+(t.pctStart+t.pct/2)*y,i=u(o);x=Math.cos(e)*i,b=Math.sin(e)*i}else f?(x=t.middle,b=u(o)):(x=u(o),b=t.middle);h.push({type:"point",x:x,y:b,r:v,style:m,datum:e})}return h},swarm:function(t,e){const{scales:i,columns:n,getR:r,resolvePieceStyle:o}=t,{r:s,projection:a}=i,c=[],l="vertical"===a;for(const t of Object.values(n)){const e=t.width/2;for(let i=0;t.pieceData.length>i;i++){const n=t.pieceData[i],a=r(n),u=o(n,t.name),h=u.r||4,f=(7919*i%100/100-.5)*e*.8,d=l?t.middle+f:s(a),g=l?s(a):t.middle+f;c.push({type:"point",x:d,y:g,r:h,style:u,datum:n})}}return c},pie:Gt,donut:Gt,boxplot:function(t,e){var i,n,o,s,a;const{scales:c,columns:l,config:u,getR:h,resolveSummaryStyle:f}=t,{r:d,projection:g}=c,y=[],p="vertical"===g,m=!1!==u.showOutliers;for(const t of Object.values(l)){const e=t.pieceData.map(t=>h(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===e.length)continue;const c=e[0],l=e[e.length-1],u=null!==(i=r.quantile(e,.25))&&void 0!==i?i:c,g=null!==(n=r.quantile(e,.5))&&void 0!==n?n:(c+l)/2,v=null!==(o=r.quantile(e,.75))&&void 0!==o?o:l,x=v-u,b=u-1.5*x,k=v+1.5*x,w=null!==(s=e.find(t=>t>=b))&&void 0!==s?s:c,_=null!==(a=[...e].reverse().find(t=>k>=t))&&void 0!==a?a:l,A=f(t.pieceData[0],t.name),S=[];if(m)for(const e of t.pieceData){const i=h(e);if(b>i||i>k){const n=p?t.middle:d(i),r=p?d(i):t.middle;S.push({px:n,py:r,value:i,datum:e})}}if(y.push({type:"boxplot",x:p?t.middle:0,y:p?0:t.middle,projection:p?"vertical":"horizontal",columnWidth:.6*t.width,minPos:d(w),q1Pos:d(u),medianPos:d(g),q3Pos:d(v),maxPos:d(_),stats:{n:e.length,min:w,q1:u,median:g,q3:v,max:_,mean:e.reduce((t,e)=>t+e,0)/e.length},style:A,datum:t.pieceData,category:t.name,outliers:S}),m)for(const t of S)y.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:A.fill||"#999",opacity:.6},datum:t.datum})}return y},violin:function(t,e){var i,n,o;const{scales:s,columns:a,config:c,getR:l,resolveSummaryStyle:u}=t,{r:h,projection:f}=s,d=[],g="vertical"===f,y=c.bins||20,p=!1!==c.showIQR;for(const t of Object.values(a)){const e=t.pieceData.map(t=>l(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const s=e[0],a=e[e.length-1],c=(a-s)/y||1,f=Array(y).fill(0);for(const t of e)f[Math.min(Math.floor((t-s)/c),y-1)]++;const m=Math.max(...f,1),v=t.width/2*.9;let x="";if(g){x=`M ${t.middle} ${h(s)}`;for(let e=0;y>e;e++){const i=h(s+(e+.5)*c);x+=` L ${t.middle+f[e]/m*v} ${i}`}x+=` L ${t.middle} ${h(a)}`;for(let e=y-1;e>=0;e--){const i=h(s+(e+.5)*c);x+=` L ${t.middle-f[e]/m*v} ${i}`}x+=" Z"}else{x=`M ${h(s)} ${t.middle}`;for(let e=0;y>e;e++)x+=` L ${h(s+(e+.5)*c)} ${t.middle-f[e]/m*v}`;x+=` L ${h(a)} ${t.middle}`;for(let e=y-1;e>=0;e--)x+=` L ${h(s+(e+.5)*c)} ${t.middle+f[e]/m*v}`;x+=" Z"}const b=u(t.pieceData[0],t.name);let k;if(p&&e.length>=4){const c=null!==(i=r.quantile(e,.25))&&void 0!==i?i:s,l=null!==(n=r.quantile(e,.5))&&void 0!==n?n:(s+a)/2,u=null!==(o=r.quantile(e,.75))&&void 0!==o?o:a;k={q1Pos:h(c),medianPos:h(l),q3Pos:h(u),centerPos:t.middle,isVertical:g}}const w=g?{x:t.x,y:Math.min(h(a),h(s)),width:t.width,height:Math.abs(h(a)-h(s))}:{x:Math.min(h(s),h(a)),y:t.x,width:Math.abs(h(a)-h(s)),height:t.width};d.push({type:"violin",pathString:x,translateX:0,translateY:0,bounds:w,iqrLine:k,stats:Ht(e),style:b,datum:t.pieceData,category:t.name})}return d},histogram:function(t,e){var i;const{scales:n,columns:r,config:o,getR:s,resolveSummaryStyle:a}=t,{r:c}=n,l=[],u=o.bins||25,h=o.normalize,f=null===(i=c.domain)||void 0===i?void 0:i.call(c),d=f?+f[0]:void 0,g=f?+f[1]:void 0;for(const t of Object.values(r)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const i=null!=d&&isFinite(d)?d:Math.min(...e),n=null!=g&&isFinite(g)?g:Math.max(...e),r=(n-i)/u||1,o=Array(u).fill(0);for(const t of e)i>t||t>n||o[Math.min(Math.floor((t-i)/r),u-1)]++;const f=e.length,y=Math.max(...o,1),p=a(t.pieceData[0],t.name);for(let e=0;u>e;e++){if(0===o[e])continue;const n=(h?o[e]/f:o[e]/y)*t.width*.9,s=c(i+e*r),a=c(i+(e+1)*r);l.push(O(Math.min(s,a),t.x+t.width-n,Math.abs(a-s),n,p,{bin:e,count:o[e],range:[i+e*r,i+(e+1)*r],category:t.name},t.name))}}return l},ridgeline:function(t,e){var i;const{scales:n,columns:r,config:o,getR:s,resolveSummaryStyle:a}=t,{r:c,projection:l}=n,u=[],h=o.bins||20,f="horizontal"===l,d=o.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 n=e[0],r=e[e.length-1],o=(r-n)/h||1,l=Array(h).fill(0);for(const t of e)n>t||t>r||l[Math.min(Math.floor((t-n)/o),h-1)]++;const g=Math.max(...l,1),y=a(t.pieceData[0],t.name),p=t.width*d;let m="";if(f){const e=t.x+t.width;m=`M ${c(n)} ${e}`;for(let t=0;h>t;t++)m+=` L ${c(n+(t+.5)*o)} ${e-l[t]/g*p}`;m+=` L ${c(r)} ${e} Z`}else{const e=t.x;m=`M ${e} ${c(n)}`;for(let t=0;h>t;t++){const i=c(n+(t+.5)*o);m+=` L ${e+l[t]/g*p} ${i}`}m+=` L ${e} ${c(r)} Z`}const v=f?{x:Math.min(c(n),c(r)),y:t.x,width:Math.abs(c(r)-c(n)),height:t.width}:{x:t.x,y:Math.min(c(r),c(n)),width:t.width,height:Math.abs(c(r)-c(n))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:v,stats:Ht(e),style:Object.assign(Object.assign({},y),{fillOpacity:null!==(i=y.fillOpacity)&&void 0!==i?i:.5}),datum:t.pieceData,category:t.name})}return u},timeline:function(t,e){const{scales:i,columns:n,getRawRange:r,resolvePieceStyle:o}=t,{r:s,projection:a}=i,c=[],l="horizontal"===a;for(const t of Object.values(n))for(const e of t.pieceData){const i=r(e);if(!i)continue;const[n,a]=i,u=o(e,t.name);if(l){const i=s(Math.min(n,a)),r=s(Math.max(n,a));c.push(O(i,t.x,r-i,t.width,u,e,t.name))}else{const i=s(Math.max(n,a)),r=s(Math.min(n,a));c.push(O(t.x,i,t.width,r-i,u,e,t.name))}}return c},funnel:function(t,i){var n,r,o,s,a,c,l;const{columns:u,getR:h,getStack:f,resolvePieceStyle:d}=t,g=[],y=i.width/2,p=!1!==t.config.showLabels,m=t.scales.o.domain().map(t=>u[t]).filter(Boolean);if(0===m.length)return g;const v=[],x=new Set;for(const t of m)for(const e of t.pieceData){const t=f?f(e):"_default";x.has(t)||(x.add(t),v.push(t))}const b=v.length>1&&"_default"!==v[0],k=[];let w=0;for(const t of m){const e=new Map;let i=0;for(const n of t.pieceData){const t=f?f(n):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const r=e.get(t),o=h(n);r.total+=o,r.pieces.push(n),i+=o}k.push({col:t,groups:e,stepTotal:i}),b||i>w&&(w=i)}if(b)for(const t of k){let e=0,i=0;for(let n=0;v.length>n;n++){const r=t.groups.get(v[n]);r&&(n%2==0?e+=r.total:i+=r.total)}const n=Math.max(e,i);n>w&&(w=n)}if(0===w)return g;const _=new Map;for(const t of v){const e=k[0].groups.get(t);_.set(t,null!==(n=null==e?void 0:e.total)&&void 0!==n?n:0)}const A=k[0].stepTotal,S=b?.95*y:.9*i.width,P=e.scaleLinear().domain([0,w]).range([0,S]),M=null!==(r=t.config.connectorOpacity)&&void 0!==r?r:.3;let E=new Map;for(let t=0;k.length>t;t++){const e=k[t],i=e.col,n=0===t,r=i.width,u=.55*r,h=i.x+(r-u)/2,f=new Map;if(b){let t=0;for(const i of v){const n=e.groups.get(i);n&&(t+=P(n.total))}let r=y,o=y;for(let s=0;v.length>s;s++){const c=v[s],l=e.groups.get(c);if(!l)continue;const m=P(l.total),x=s%2==0,b=x?r:o-m;x?r+=m:o-=m;const k=d(l.pieces[0],c),w=null!==(a=_.get(c))&&void 0!==a?a:l.total,A=w>0?l.total/w*100:0,S=Object.assign(Object.assign({},l.pieces[0]),{__funnelValue:l.total,__funnelPercent:A,__funnelStep:i.name,__funnelIsFirstStep:n,__aggregateValue:l.total,__pieceCount:l.pieces.length,category:c});p&&(0===s&&(S.__funnelStepLabel=i.name,S.__funnelStepLabelX=y,S.__funnelStepLabelY=h,S.__funnelRowWidth=t),S.__funnelValueLabelX=b+m/2,S.__funnelValueLabelY=h,S.__funnelBarW=m),g.push(O(b,h,m,u,k,S,c)),f.set(c,{x:b,y:h,w:m,h:u})}}else{const t=e.stepTotal,r=P(t),a=y-r/2,c=v[0],l="_default"!==c,m=null!==(s=null===(o=e.groups.get(c))||void 0===o?void 0:o.pieces[0])&&void 0!==s?s:i.pieceData[0],x=l?c:i.name,b=d(m,x),k=A>0?t/A*100:0,w=Object.assign(Object.assign({},m),{__funnelValue:t,__funnelPercent:k,__funnelStep:i.name,__funnelIsFirstStep:n,category:l?c:i.name});p&&(w.__funnelStepLabel=i.name,w.__funnelStepLabelX=y,w.__funnelStepLabelY=h,w.__funnelRowWidth=r,w.__funnelValueLabelX=y,w.__funnelValueLabelY=h,w.__funnelBarW=r),g.push(O(a,h,r,u,b,w,x)),f.set(c,{x:a,y:h,w:r,h:u})}if(t>0&&E.size>0){const t=b?v:[v[0]];for(const n of t){const t=E.get(n),r=f.get(n);if(!t||!r)continue;const o=(()=>{const t=e.groups.get(n);return d(t?t.pieces[0]:i.pieceData[0],"_default"===n?i.name:n)})(),s={type:"trapezoid",points:[[t.x,t.y+t.h],[t.x+t.w,t.y+t.h],[r.x+r.w,r.y],[r.x,r.y]],style:{fill:o.fill||"#999",opacity:M},datum:null!==(l=null===(c=e.groups.get(n))||void 0===c?void 0:c.pieces[0])&&void 0!==l?l:i.pieceData[0],category:"_default"===n?i.name:n};g.push(s)}}E=f}return g},"bar-funnel":function(t,e){var i,n,r,o;const{columns:s,getR:a,getStack:c,resolvePieceStyle:l,scales:u}=t,h=[],f=u.o.domain().map(t=>s[t]).filter(Boolean);if(0===f.length)return h;const d=[],g=new Set;for(const t of f)for(const e of t.pieceData){const t=c?c(e):"_default";g.has(t)||(g.add(t),d.push(t))}const y=d.length>1&&"_default"!==d[0],p=[];for(const t of f){const e=new Map;let i=0;for(const n of t.pieceData){const t=c?c(n):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const r=e.get(t),o=a(n);r.total+=o,r.pieces.push(n),i+=o}p.push({col:t,groups:e,stepTotal:i})}const m=new Map;for(const t of d){const e=null===(i=p[0])||void 0===i?void 0:i.groups.get(t);m.set(t,null!==(n=null==e?void 0:e.total)&&void 0!==n?n:0)}const v=u.r,x=y?d.length:1,b=y?.15:0;for(let t=0;p.length>t;t++){const e=p[t],i=e.col,n=0===t,s=t>0?p[t-1]:null,a=i.width/x,c=a*b,u=a-c;for(let t=0;d.length>t;t++){const f=d[t],g=e.groups.get(f);if(!g)continue;const p=g.total,x=null!==(r=m.get(f))&&void 0!==r?r:p,b=x>0?p/x*100:0,k=null==s?void 0:s.groups.get(f),w=null!==(o=null==k?void 0:k.total)&&void 0!==o?o:p,_=n?0:Math.max(0,w-p),A=i.x+t*a+c/2,S=v(p),P=v(0)-S,M=l(g.pieces[0],y?f:i.name),E=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:p,__barFunnelPercent:b,__barFunnelIsFirstStep:n,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:_,__barFunnelCategory:"_default"===f?void 0:f,category:y?f:i.name,__barFunnelLabelX:A+u/2,__barFunnelLabelY:v(p+_)});if(h.push(O(A,S,u,P,M,E,y?f:i.name)),_>0){const t=v(p+_),e=S-t,n=Object.assign({},M),r=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:_,__barFunnelPercent:x>0?_/x*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===f?void 0:f,category:y?f:i.name});h.push(O(A,t,u,e,n,r,y?f:i.name))}}}return h},swimlane:function(t,e){const{scales:i,columns:n,getR:r,getStack:o,resolvePieceStyle:s}=t,{r:a,projection:c}=i,l=[],u="horizontal"===c;for(const t of Object.values(n)){let e=0;for(const i of t.pieceData){const n=Math.abs(r(i));if(0===n)continue;const c=o?o(i):t.name,h=s(i,c);if(u){const r=a(e),o=a(e+n);l.push(O(r,t.x,o-r,t.width,h,i,c))}else{const r=a(e+n),o=a(e);l.push(O(t.x,r,t.width,o-r,h,i,c))}e+=n}}return l}};class Kt{constructor(t){this.rExtent=new g,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.version=0,this.config=t,this.buffer=new d(t.windowSize),this.getO=x(t.oAccessor||t.categoryAccessor,"category");const e="streaming"===t.runtimeMode,i=t.rAccessor;Array.isArray(i)?(this.rAccessors=i.map(t=>m(t,"value")),this.getR=this.rAccessors[0],this.rExtents=i.map(()=>new g)):(this.getR=m(e&&(t.timeAccessor||t.valueAccessor)&&t.valueAccessor||i,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=x(t.stackBy),this.getGroup=x(t.groupBy),this.getColor=x(t.colorAccessor),this.getConnector=x(t.connectorAccessor),t.pulse&&(this.timestampBuffer=new d(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,t.bounded){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=t.totalSize||t.inserts.length;i>this.buffer.capacity&&(this.buffer.resize(i),this.timestampBuffer&&i>this.timestampBuffer.capacity&&this.timestampBuffer.resize(i));for(const i of t.inserts)this.buffer.push(i),this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i)}else{this._hasStreamingData=!0;for(const i of t.inserts){const t=this.buffer.push(i);this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i),null!=t&&this.evictValueExtent(t)}}return!0}pushValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.push(e[0]),this.rExtent.push(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].push(this.rAccessors[e](t));this.rExtent.push(this.getR(t))}else this.rExtent.push(this.getR(t))}evictValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.evict(e[0]),this.rExtent.evict(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].evict(this.rAccessors[e](t));this.rExtent.evict(this.getR(t))}else this.rExtent.evict(this.getR(t))}getRawRange(t){const e=this.config.rAccessor;if(!e)return null;const i="function"==typeof e?e(t):t[e];return Array.isArray(i)&&i.length>=2?[+i[0],+i[1]]:null}computeScene(t){const{config:i,buffer:n}=this;if(0===n.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(n,this.getR);const r=n.toArray(),o=i.projection||"vertical",s=i.oExtent||this.resolveCategories(r),a=this.computeValueDomain(r,s),c="horizontal"===o,l=null!=i.barPadding?i.barPadding/("vertical"===o?t.width:t.height):.1;let u,h;if("radial"===o){u=e.scaleBand().domain(s).range([0,1]).padding(0);const n=Math.min(t.width,t.height)/2,r=i.innerRadius||0;h=e.scaleLinear().domain(a).range([r,n])}else c?(u=e.scaleBand().domain(s).range([0,t.height]).padding(l),h=e.scaleLinear().domain(a).range([0,t.width])):(u=e.scaleBand().domain(s).range([0,t.width]).padding(l),h=e.scaleLinear().domain(a).range([t.height,0]));this.scales={o:u,r:h,projection:o},this.multiScales=this.rAccessors.length>1&&i.multiAxis?this.rAccessors.map((r,o)=>{const s=this.rExtents[o];s.dirty&&s.recalculate(n,r);let[a,l]=s.extent;a===1/0&&(a=0,l=1);const u=l-a,h=u>0?u*(i.extentPadding||.05):1;return a-=h,l+=h,a>0&&(a=0),c?e.scaleLinear().domain([a,l]).range([0,t.width]):e.scaleLinear().domain([a,l]).range([t.height,0])}):[];let f=r;this.rAccessors.length>1&&(f=r.flatMap(t=>this.rAccessors.map((e,i)=>Object.assign(Object.assign({},t),{__rIndex:i,__rValue:e(t),__rName:this.resolveRAccessorName(i)})))),this.columns=this.buildColumns(f,s,u,o,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(f,t),this.config.decay&&this.applyDecay(this.scene,r),this.config.pulse&&this.applyPulse(this.scene,r),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(t){const e=Array.isArray(this.config.rAccessor)?this.config.rAccessor[t]:this.config.rAccessor;return"string"==typeof e?e:"value"+t}resolveCategories(t){const e=Array.from(this.categories),i=this.config.oSort;if(("streaming"===this.config.runtimeMode||this._hasStreamingData)&&void 0===i){const i=new Set;for(const e of t)i.add(this.getO(e));const n=Math.max(50,3*i.size);if(this.categories.size>n){let t=this.categories.size-n;for(const e of this.categories){if(0>=t)break;i.has(e)||(this.categories.delete(e),t--)}}return e.filter(t=>i.has(t))}if(!1===i)return e;if("function"==typeof i)return e.sort(i);const n=new Map;for(const e of t){const t=this.getO(e);n.set(t,(n.get(t)||0)+Math.abs(this.getR(e)))}return e.sort("asc"===i?(t,e)=>(n.get(t)||0)-(n.get(e)||0):(t,e)=>(n.get(e)||0)-(n.get(t)||0))}computeValueDomain(t,e){var i,n,r,o;const s=this.config.chartType,a=this.config.extentPadding||.05;if("radial"===this.config.projection&&("pie"===s||"donut"===s))return[0,1];let c=0,l=0;if("bar"===s&&this.getStack&&this.config.normalize)c=0,l=1;else if("bar"===s&&this.getStack){const e=new Map,i=new Map;for(const n of t){const t=this.getO(n),r=this.getR(n);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>l&&(l=t);for(const t of i.values())c>t&&(c=t)}else if("bar"===s){const e=new Map;for(const i of t){const t=this.getO(i),n=this.getR(i);e.set(t,(e.get(t)||0)+n)}for(const t of e.values())t>l&&(l=t),c>t&&(c=t)}else if("swimlane"===s){const e=new Map;for(const i of t){const t=this.getO(i),n=Math.abs(this.getR(i));e.set(t,(e.get(t)||0)+n)}for(const t of e.values())t>l&&(l=t)}else if("clusterbar"===s||"bar-funnel"===s)for(const e of t){const t=this.getR(e);t>l&&(l=t),c>t&&(c=t)}else{const t=this.rExtent.extent[0],e=this.rExtent.extent[1];t!==1/0&&(c=t),e!==-1/0&&(l=e)}if(this.config.rExtent&&(null!=this.config.rExtent[0]&&(c=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(l=this.config.rExtent[1])),"bar-funnel"!==s){const t=l-c,e=t>0?t*a:1;null==(null===(i=this.config.rExtent)||void 0===i?void 0:i[0])&&(c-=e),null==(null===(n=this.config.rExtent)||void 0===n?void 0:n[1])&&(l+=e)}return"bar"!==s&&"clusterbar"!==s&&"bar-funnel"!==s&&"swimlane"!==s||null==(null===(r=this.config.rExtent)||void 0===r?void 0:r[0])&&null==(null===(o=this.config.rExtent)||void 0===o?void 0:o[1])&&(c>0&&(c=0),0>l&&(l=0)),[c,l]}buildColumns(t,e,i,n,r){var o;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"===n)for(const e of t)c+=Math.abs(this.getR(e));const l=this.config.dynamicColumnWidth;let u=null;if(l&&"radial"!==n){u=new Map;let t=0;for(const i of e){const e=a.get(i)||[];let n;n="string"==typeof l?e.reduce((t,e)=>t+(Number(e[l])||0),0):l(e),u.set(i,n),t+=n}const o=("horizontal"===n?r.height:r.width)-i.padding()*i.step()*e.length;if(t>0)for(const[e,i]of u)u.set(e,i/t*o)}let h=0,f=0;for(const t of e){const e=a.get(t)||[],n=e.reduce((t,e)=>t+Math.abs(this.getR(e)),0),r=c>0?n/c:0;let l,d;u?(l=f,d=u.get(t)||i.bandwidth(),f+=d+i.padding()*i.step()):(l=null!==(o=i(t))&&void 0!==o?o:0,d=i.bandwidth()),s[t]={name:t,x:l,y:0,width:d,middle:l+d/2,padding:i.padding()*i.step(),pieceData:e,pct:r,pctStart:h},h+=r}return s}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(t,e)=>this.resolvePieceStyle(t,e),resolveSummaryStyle:(t,e)=>this.resolveSummaryStyle(t,e),getRawRange:t=>this.getRawRange(t)}}buildSceneNodes(t,e){if(!this.scales)return[];const i=this.getSceneContext(),n=Zt[this.config.chartType];let r=n?n(i,e):[];if(this.getConnector&&this.scales){const t=function(t,e){const{scales:i,config:n,getConnector:r,getO:o}=t;if(!r||!i)return[];const s=[],{projection:a}=i,c=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const i=r(e);if(!i)continue;let n,s;"point"===t.type?(n=t.x,s=t.y):(n=t.x+t.w/2,s=t.y+("vertical"===a?0:t.h/2)),c.has(i)||c.set(i,[]),c.get(i).push({x:n,y:s,datum:e,category:o(e)})}const l=i.o.domain(),u=n.connectorStyle;for(const[t,e]of c)if(e.length>=2){e.sort((t,e)=>l.indexOf(t.category)-l.indexOf(e.category));for(let i=0;e.length-1>i;i++){const n=e[i],r=e[i+1],o="function"==typeof u?u(n.datum):u||{stroke:"#999",strokeWidth:1,opacity:.5};s.push({type:"connector",x1:n.x,y1:n.y,x2:r.x,y2:r.y,style:o,datum:n.datum,group:t})}}return s}(i,r);r=[...t,...r]}return r}resolvePieceStyle(t,e){if("function"==typeof this.config.pieceStyle){const i=this.config.pieceStyle(t,e);return i&&!i.fill&&e?Object.assign(Object.assign({},i),{fill:this.getColorFromScheme(e)}):i}return this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&e?{fill:this.config.barColors[e]||"#007bff"}:e?{fill:this.getColorFromScheme(e)}:{fill:"#007bff"}}getColorFromScheme(t){this._colorSchemeMap||(this._colorSchemeMap=new Map);const e=this._colorSchemeMap.get(t);if(e)return e;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:b,n=i[this._colorSchemeIndex%i.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(t,n),n}resolveSummaryStyle(t,e){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(t,e):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(t,e){var i,n,r;const o=this.config.decay;if(!o||1>=e)return 1;const s=null!==(i=o.minOpacity)&&void 0!==i?i:.1,a=e-1-t;switch(o.type){case"linear":return s+(1-a/(e-1))*(1-s);case"exponential":{const t=null!==(n=o.halfLife)&&void 0!==n?n:e/2;return s+Math.pow(.5,a/t)*(1-s)}case"step":return(null!==(r=o.stepThreshold)&&void 0!==r?r:.5*e)>a?1:s;default:return 1}}applyDecay(t,e){var i,n;if(!this.config.decay)return;const r=e.length;if(1>=r)return;const o=new Map;for(let t=0;e.length>t;t++)o.set(e[t],t);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;const t=o.get(e.datum);if(null==t)continue;const s=this.computeDecayOpacity(t,r),a=null!==(n=null===(i=e.style)||void 0===i?void 0:i.opacity)&&void 0!==n?n:1;e.style=Object.assign(Object.assign({},e.style),{opacity:a*s})}}applyPulse(t,e){var i,n,r;if(!this.config.pulse||!this.timestampBuffer)return;const o="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(i=this.config.pulse.duration)&&void 0!==i?i:500,a=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(r=this.config.pulse.glowRadius)&&void 0!==r?r:4,l=new Map;for(let t=0;e.length>t;t++)l.set(e[t],t);for(const i of t){if("connector"===i.type||"violin"===i.type||"boxplot"===i.type)continue;if("wedge"===i.type){const t=i.category;if(!t)continue;let n=0;for(let i=0;e.length>i;i++){const r=e[i],a=this.config.oAccessor;if(("function"==typeof a?a(r):r[a||"category"])!==t)continue;const c=this.timestampBuffer.get(i);if(null==c)continue;const l=o-c;if(s>l){const t=1-l/s;t>n&&(n=t)}}n>0&&(i._pulseIntensity=n,i._pulseColor=a);continue}const t=l.get(i.datum);if(null==t)continue;const n=this.timestampBuffer.get(t);if(null==n)continue;const r=o-n;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,n=this.timestampBuffer.peek();return null!=n&&i>e-n}getNodeKey(t,e){var i,n;if("point"===t.type){const i=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,n=e.get(i)||0;return e.set(i,n+1),`${i}:${n}`}return"rect"===t.type?`r:${t.group||""}:${null!==(n=null===(i=t.datum)||void 0===i?void 0:i.category)&&void 0!==n?n:""}`:null}snapshotPositions(){this.prevPositionMap.clear();const t=new Map;for(let e=0;this.scene.length>e;e++){const i=this.scene[e],n=this.getNodeKey(i,t);n&&("point"===i.type?this.prevPositionMap.set(n,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity}):"rect"===i.type&&this.prevPositionMap.set(n,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity}))}}startTransition(){var t,e,i,n,r,o,s,a,c,l,u,h;if(!this.config.transition||0===this.prevPositionMap.size)return;const f=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}let d=!1;const g=new Set,y=new Map;for(let t=0;this.scene.length>t;t++){const a=this.scene[t],c=this.getNodeKey(a,y);if(!c)continue;a._transitionKey=c;const l=this.prevPositionMap.get(c);"point"===a.type?l?(g.add(c),a._targetOpacity=null!==(e=a.style.opacity)&&void 0!==e?e:1,l.x===a.x&&l.y===a.y||(a._targetX=a.x,a._targetY=a.y,a.x=l.x,a.y=l.y,d=!0)):(a._targetOpacity=null!==(i=a.style.opacity)&&void 0!==i?i:1,a.style=Object.assign(Object.assign({},a.style),{opacity:0}),d=!0):"rect"===a.type&&(l?(g.add(c),a._targetOpacity=null!==(n=a.style.opacity)&&void 0!==n?n:1,l.x===a.x&&l.y===a.y&&l.w===a.w&&l.h===a.h||(a._targetX=a.x,a._targetY=a.y,a._targetW=a.w,a._targetH=a.h,a.x=l.x,a.y=l.y,a.w=null!==(r=l.w)&&void 0!==r?r:a.w,a.h=null!==(o=l.h)&&void 0!==o?o:a.h,d=!0)):(a._targetOpacity=null!==(s=a.style.opacity)&&void 0!==s?s:1,a.style=Object.assign(Object.assign({},a.style),{opacity:0}),d=!0))}this.exitNodes=[];for(const[t,e]of this.prevPositionMap)g.has(t)||(t.startsWith("p:")?this.exitNodes.push({type:"point",x:e.x,y:e.y,r:null!==(a=e.r)&&void 0!==a?a:3,style:{opacity:null!==(c=e.opacity)&&void 0!==c?c:1},datum:null,_targetOpacity:0,_transitionKey:t}):t.startsWith("r:")&&this.exitNodes.push({type:"rect",x:e.x,y:e.y,w:null!==(l=e.w)&&void 0!==l?l:0,h:null!==(u=e.h)&&void 0!==u?u:0,style:{opacity:null!==(h=e.opacity)&&void 0!==h?h:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t}),d=!0);this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),d&&(this.activeTransition={startTime:P(),duration:f})}advanceTransition(t){var e,i,n;if(!this.activeTransition)return!1;const r=A(t,this.activeTransition),o=_(r,"linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?"linear":"ease-out-cubic");for(const t of this.scene){const e=t._transitionKey;if(e)if("point"===t.type){if(void 0!==t._targetOpacity){const n=this.prevPositionMap.get(e),r=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;t.style.opacity=S(r,t._targetOpacity,o)}if(void 0===t._targetX)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=S(n.x,t._targetX,o),t.y=S(n.y,t._targetY,o)}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e),r=i?null!==(n=i.opacity)&&void 0!==n?n:1:0;t.style.opacity=S(r,t._targetOpacity,o)}if(void 0===t._targetX)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=S(i.x,t._targetX,o),t.y=S(i.y,t._targetY,o),void 0!==i.w&&(t.w=S(i.w,t._targetW,o),t.h=S(i.h,t._targetH,o))}}if(r>=1){for(const t of this.scene)if(void 0!==t._targetOpacity&&(t.style=Object.assign(Object.assign({},t.style||{}),{opacity:0===t._targetOpacity?0:t._targetOpacity}),t._targetOpacity=void 0),"point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}getData(){return this.buffer.toArray()}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}updateConfig(t){const e=Object.assign({},this.config);if(t.colorScheme!==this.config.colorScheme&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),Object.assign(this.config,t),(void 0!==t.oAccessor||void 0!==t.categoryAccessor)&&(p(t.oAccessor||t.categoryAccessor,e.oAccessor||e.categoryAccessor)||(this.getO=x(this.config.oAccessor||this.config.categoryAccessor,"category"),this.categories.clear())),void 0!==t.rAccessor){const i=Array.isArray(t.rAccessor)?t.rAccessor:[t.rAccessor],n=Array.isArray(e.rAccessor)?e.rAccessor:[e.rAccessor];if(i.length!==n.length||i.some((t,e)=>!p(t,n[e]))){const t=this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>m(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new g)):(this.getR=m(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!p(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?x(this.config.stackBy):void 0),"groupBy"in t&&!p(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?x(this.config.groupBy):void 0),"colorAccessor"in t&&!p(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?x(this.config.colorAccessor):void 0),"connectorAccessor"in t&&!p(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?x(this.config.connectorAccessor):void 0)}}const Qt={mercator:u.geoMercator,equalEarth:u.geoEqualEarth,albersUsa:u.geoAlbersUsa,orthographic:u.geoOrthographic,naturalEarth:u.geoNaturalEarth1,equirectangular:u.geoEquirectangular};function Ut(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function Jt(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function te(t,e,i){return t?Object.assign(Object.assign({},i),"function"==typeof t?t(e):t):i}const ee={fill:"#e0e0e0",stroke:"#999",strokeWidth:.5,fillOpacity:1},ie={fill:"#4e79a7",r:4,fillOpacity:.8},ne={stroke:"#4e79a7",strokeWidth:1.5,fill:"none"};function re(t,e){if(2>t.length)return[t];const i=.4*e,n=[];let r=[t[0]];for(let e=1;t.length>e;e++){const o=t[e];Math.abs(o[0]-t[e-1][0])>i?(2>r.length||n.push(r),r=[o]):r.push(o)}return 2>r.length||n.push(r),n}function oe(t,e,i=24){const n=e[0]-t[0],r=e[1]-t[1],o=Math.sqrt(n*n+r*r);if(0===o)return[t,e];const s=-r/o,a=n/o,c=Math.min(.3*o,80),l=(t[0]+e[0])/2+s*c,u=(t[1]+e[1])/2+a*c,h=[];for(let n=0;i>=n;n++){const r=n/i,o=1-r;h.push([o*o*t[0]+2*o*r*l+r*r*e[0],o*o*t[1]+2*o*r*u+r*r*e[1]])}return h}function se(t,e){if(2>t.length)return t;const i=e/2+1,n=[];for(let e=0;t.length>e;e++){const r=t[e];let o,s;0===e?(o=t[1][0]-r[0],s=t[1][1]-r[1]):e===t.length-1?(o=r[0]-t[e-1][0],s=r[1]-t[e-1][1]):(o=t[e+1][0]-t[e-1][0],s=t[e+1][1]-t[e-1][1]);const a=Math.sqrt(o*o+s*s)||1;n.push([r[0]+s/a*i,r[1]+-o/a*i])}return n}function ae(t,e,i,n,r){const o=e[0]-t[0],s=e[1]-t[1],a=Math.sqrt(o*o+s*s);if(0===a)return[t,e];const c=s/a,l=-o/a,u=r/2+1;return[[t[0]+c*u,t[1]+l*u],[e[0]+c*u,e[1]+l*u]]}class ce{constructor(t){this.scene=[],this.scales=null,this.version=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this.config=t}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}setAreas(t){this.areas=t}setPoints(t){this.pointData=t,this.streaming=!1}setLines(t){this.lineData=t}initStreaming(t=500){this.pointBuffer=new d(t),this.timestampBuffer=new d(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}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.scene=[],this.scales=null,this.version++}computeScene(t){const{config:e}=this;this.projection=function(t){if(!t)return u.geoEqualEarth();if("string"==typeof t){const e=Qt[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),u.geoEqualEarth())}if("object"==typeof t&&"type"in t){const e=Qt[t.type],i=e?e():u.geoEqualEarth();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=u.geoPath(this.projection),this.fitProjection(t),this.geoPath=u.geoPath(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 n=this.scene;this.scene=this.buildSceneNodes(t),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&n.length>0&&this.startTransition(n),this.version++}fitProjection(t){var e,i,n,r,o;const s=this.projection,a=this.config,c=[...this.areas],l=Ut(a.xAccessor,"lon"),u=Ut(a.yAccessor,"lat"),h=this.getPoints();if(h.length>0){const t=h.map(t=>[l(t),u(t)]);c.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const f=Jt(a.lineDataAccessor);for(const t of this.lineData){const e=f(t);if(e&&e.length>0){const t=e.map(t=>[l(t),u(t)]);c.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==c.length){if(a.projectionExtent){const[[e,i],[n,r]]=a.projectionExtent;s.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[e,i],[n,i],[n,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,n=Math.min(t.width,t.height);s.scale(n/2-n*e),s.translate([t.width/2,t.height/2])}else{const e=null!==(n=a.fitPadding)&&void 0!==n?n: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!==(o=null===(r=s.rotate)||void 0===r?void 0:r.call(s))&&void 0!==o?o:[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=u.geoPath(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyZoomScale(t,e){const i=this.projection;i&&(i.scale(this.baseScale*t),i.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=u.geoPath(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyRotation(t,e){const i=this.projection;i&&i.rotate&&(i.rotate(t),this.geoPath=u.geoPath(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}setRotation(t){const e=this.projection;e&&e.rotate&&e.rotate(t)}getRotation(){var t,e,i;return null!==(i=null===(e=null===(t=this.projection)||void 0===t?void 0:t.rotate)||void 0===e?void 0:e.call(t))&&void 0!==i?i:this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}buildSceneNodes(t){var e,i,n;const r=[],{config:o}=this,s=this.projection,a=this.geoPath,c=Ut(o.xAccessor,"lon"),l=Ut(o.yAccessor,"lat");if(o.graticule){const e=!0===o.graticule?{}:o.graticule,i=u.geoGraticule();e.step&&i.step(e.step);const n=a(i())||"";n&&r.push({type:"geoarea",pathData:n,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),n=a.bounds(t),s=a.area(t),c=te(o.areaStyle,t,ee);r.push({type:"geoarea",pathData:e,centroid:i,bounds:n,screenArea:s,style:c,datum:t,interactive:!0})}const h=Jt(o.lineDataAccessor);for(const e of this.lineData){const i=h(e);if(!i||2>i.length)continue;const n=i.map(t=>[c(t),l(t)]);let a;if("geo"===o.lineType){const t=[];for(let e=0;n.length-1>e;e++){const i=n[e],r=n[e+1],o=u.geoDistance(i,r)||0,s=Math.max(2,Math.ceil(o/(Math.PI/180))),a=u.geoInterpolate(i,r);for(let i=0;s>=i;i++)e>0&&0===i||t.push(a(i/s))}a=t.map(([t,e])=>s([t,e])).filter(t=>null!=t)}else a=n.map(([t,e])=>s([t,e])).filter(t=>null!=t);if(2>a.length)continue;const f=te(o.lineStyle,e,ne),d="number"==typeof f.strokeWidth?f.strokeWidth:1;2!==n.length||2>a.length||"arc"!==o.flowStyle?2!==n.length||2>a.length||"offset"!==o.flowStyle||(a="geo"===o.lineType?se(a,d):ae(a[0],a[a.length-1],0,0,d)):a=oe(a[0],a[a.length-1]);const g=re(a,t.width);if(g.length>1)for(const t of g){if(2>t.length)continue;const i={type:"line",path:t,style:Object.assign(Object.assign({},f),{_edgeFade:!0}),datum:e};r.push(i)}else r.push({type:"line",path:2>a.length&&g[0]||a,style:f,datum:e})}const f=this.getPoints(),d=o.pointIdAccessor?"function"==typeof o.pointIdAccessor?o.pointIdAccessor:t=>t[o.pointIdAccessor]:null,g=s.clipAngle&&null!==(e=s.clipAngle())&&void 0!==e?e:0,y=g>0?g*Math.PI/180:null,p=s.rotate?s.rotate():[0,0,0],m="function"==typeof s.center?s.center():[0,0],v=[(null!==(i=m[0])&&void 0!==i?i:0)-p[0],(null!==(n=m[1])&&void 0!==n?n:0)-p[1]];for(let t=0;f.length>t;t++){const e=f[t],i=c(e),n=l(e);if(null!=y&&u.geoDistance([i,n],v)>y)continue;const a=s([i,n]);if(!a)continue;const h=o.pointStyle?o.pointStyle(e):Object.assign({},ie),g={type:"point",x:a[0],y:a[1],r:h.r||4,style:h,datum:e,pointId:d?d(e)+"":void 0};r.push(g)}return r}applyCartogramTransform(t,i){var n,r,o;const s=this.scene.filter(t=>"point"===t.type);if(2>s.length)return;const a=null!==(n=t.strength)&&void 0!==n?n: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],u=s.find(e=>c(e.datum)+""==t.center+"");if(!u)return void("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`));const h=u.x,f=u.y,d=s.map(t=>l(t.datum)).filter(t=>isFinite(t)&&t>=0),g=Math.max(...d,1),y=Math.min(i.width,i.height)/2,p=e.scaleLinear().domain([0,g]).range([0,y]);this.cartogramLayout={cx:h,cy:f,maxCost:g,availableRadius:y},this.areas.length>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them."),this.scene=this.scene.filter(t=>"geoarea"!==t.type||!t.interactive);for(const t of s){if(t===u)continue;const e=Math.atan2(t.y-f,t.x-h),i=Math.sqrt(Math.pow(t.x-h,2)+Math.pow(t.y-f,2)),n=l(t.datum),r=i+((isFinite(n)?p(n):i)-i)*a;t.x=h+Math.cos(e)*r,t.y=f+Math.sin(e)*r}const m=i.width/2,v=i.height/2,x=m-u.x,b=v-u.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===(r=e.datum)||void 0===r?void 0:r.source,n=null===(o=e.datum)||void 0===o?void 0:o.target;if(i&&n){const r=t.get(i+""),o=t.get(n+"");r&&o&&(e.path=[r,o])}}}}applyDecay(){var t,e,i;const n=this.config.decay;if(!n||!this.pointBuffer)return;const r=this.pointBuffer.size;if(0===r)return;const o=null!==(t=n.minOpacity)&&void 0!==t?t:.1,s=null!==(e=n.halfLife)&&void 0!==e?e:r/2,a=null!==(i=n.stepThreshold)&&void 0!==i?i:.5*r,c=this.scene.filter(t=>"point"===t.type);for(let t=0;c.length>t;t++){const e=r-1-t;let i;switch(n.type){case"exponential":i=o+Math.pow(.5,e/s)*(1-o);break;case"step":i=a>e?1:o;break;default:i=o+(r>1?1-e/(r-1):1)*(1-o)}c[t]._decayOpacity=i,c[t].style=Object.assign(Object.assign({},c[t].style),{opacity:i})}}applyPulse(){var t,e;const i=this.config.pulse;if(!i||!this.timestampBuffer)return;const n=null!==(t=i.duration)&&void 0!==t?t:500,r=performance.now(),o=this.scene.filter(t=>"point"===t.type),s=this.timestampBuffer.toArray();for(let t=0;o.length>t&&s.length>t;t++){const a=r-s[t];n>a&&(o[t]._pulseIntensity=1-a/n,o[t]._pulseColor=i.color||"rgba(255,255,255,0.6)",o[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,n=this.timestampBuffer.toArray()[this.timestampBuffer.size-1];return performance.now()-n<i}startTransition(t){var e,i;const n=null!==(i=null===(e=this.config.transition)||void 0===e?void 0:e.duration)&&void 0!==i?i:300;if(0>=n)return;const r=new Map;for(const e of t)"point"===e.type&&e.pointId&&r.set(e.pointId,[e.x,e.y]);const o=this.scene.filter(t=>"point"===t.type);let s=!1;for(const t of o)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:n})}advanceTransition(t){if(!this.activeTransition)return!1;const e=A(t,this.activeTransition),i=_(e),n=this.scene.filter(t=>"point"===t.type);for(const t of n)if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=S(t.x,t._targetX,i),t.y=S(e,t._targetY,i)}if(e>=1){for(const t of n)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 le(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}const ue=require("react-dom/server");function he(t){return Math.round(100*t)/100+""}function fe(t){var e,i,n,r;const o=t.size||[500,300],s=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),t.margin),a=o[0]-s.left-s.right,c=o[1]-s.top-s.bottom,l="streaming"===t.runtimeMode||["bar","swarm","waterfall"].includes(t.chartType),u={chartType:t.chartType,windowSize:null!==(e=t.windowSize)&&void 0!==e?e:200,windowMode:null!==(i=t.windowMode)&&void 0!==i?i:"sliding",arrowOfTime:l&&null!==(n=t.arrowOfTime)&&void 0!==n?n:"right",extentPadding:null!==(r=t.extentPadding)&&void 0!==r?r:.1,xAccessor:l?void 0:t.xAccessor,yAccessor:l?void 0:t.yAccessor,timeAccessor:l?t.timeAccessor:void 0,valueAccessor:t.valueAccessor,colorAccessor:t.colorAccessor,sizeAccessor:t.sizeAccessor,groupAccessor:t.groupAccessor,categoryAccessor:t.categoryAccessor,lineDataAccessor:t.lineDataAccessor,xExtent:t.xExtent,yExtent:t.yExtent,sizeRange:t.sizeRange,binSize:t.binSize,normalize:t.normalize,boundsAccessor:t.boundsAccessor,boundsStyle:t.boundsStyle,openAccessor:t.openAccessor,highAccessor:t.highAccessor,lowAccessor:t.lowAccessor,closeAccessor:t.closeAccessor,candlestickStyle:t.candlestickStyle,lineStyle:t.lineStyle,pointStyle:t.pointStyle,areaStyle:t.areaStyle,colorScheme:t.colorScheme,barColors:t.barColors},h=new j(u);if(t.data&&h.ingest({inserts:t.data,bounded:!0}),h.computeScene({width:a,height:c}),!h.scales||0===h.scene.length)return ue.renderToStaticMarkup(f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-xy-frame",width:o[0],height:o[1]}));const d=h.scene.map((t,e)=>function(t,e){var i,n,r;switch(t.type){case"line":{const i=t;if(0===i.path.length)return null;const n="M"+i.path.map(([t,e])=>`${t},${e}`).join("L");return f.createElement("path",{key:"line-"+e,d:n,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth||2,strokeDasharray:i.style.strokeDasharray,opacity:i.style.opacity})}case"area":{const r=t;if(0===r.topPath.length)return null;const o=r.topPath.map(([t,e])=>`${t},${e}`).join("L"),s=[...r.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return f.createElement("path",{key:"area-"+e,d:`M${o}L${s}Z`,fill:le(r.style.fill),fillOpacity:null!==(n=null!==(i=r.style.fillOpacity)&&void 0!==i?i:r.style.opacity)&&void 0!==n?n:.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})}case"point":{const i=t;return f.createElement("circle",{key:"point-"+e,cx:i.x,cy:i.y,r:i.r,fill:le(i.style.fill),opacity:null!==(r=i.style.opacity)&&void 0!==r?r:.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})}case"rect":{const i=t;return f.createElement("rect",{key:"rect-"+e,x:i.x,y:i.y,width:i.w,height:i.h,fill:le(i.style.fill),opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})}case"heatcell":{const i=t;if(i.showValues&&null!=i.value&&i.w>=20&&i.h>=20){const t=i.valueFormat?i.valueFormat(i.value):Number.isInteger(i.value)?i.value+"":100>Math.abs(i.value)?1>Math.abs(i.value)?i.value.toPrecision(3):i.value.toFixed(1):i.value.toFixed(0),[n,r,o]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(i.fill),s=.299*n+.587*r+.114*o>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(i.w,i.h)));return f.createElement("g",{key:"heatcell-"+e},f.createElement("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill}),f.createElement("text",{x:i.x+i.w/2,y:i.y+i.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px"},t))}return f.createElement("rect",{key:"heatcell-"+e,x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill})}case"candlestick":{const i=t,n=Math.min(i.openY,i.closeY),r=Math.max(Math.abs(i.openY-i.closeY),1),o=i.isUp?i.upColor:i.downColor;return f.createElement("g",{key:"candle-"+e},f.createElement("line",{x1:i.x,y1:i.highY,x2:i.x,y2:i.lowY,stroke:i.wickColor,strokeWidth:i.wickWidth}),f.createElement("rect",{x:i.x-i.bodyWidth/2,y:n,width:i.bodyWidth,height:r,fill:o,stroke:o,strokeWidth:1}))}default:return null}}(t,e)).filter(Boolean),g=!1!==t.showAxes?function(t,e,i){var n,r,o,s;const a=t.x.ticks(5).map(e=>({pixel:t.x(e),label:(i.xFormat||i.tickFormatTime||he)(e)})),c=t.y.ticks(5).map(e=>({pixel:t.y(e),label:(i.yFormat||i.tickFormatValue||he)(e)}));return f.createElement("g",{className:"stream-axes"},f.createElement("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:"#ccc",strokeWidth:1}),a.map((t,i)=>f.createElement("g",{key:"xtick-"+i,transform:`translate(${t.pixel},${e.height})`},f.createElement("line",{y2:5,stroke:"#ccc",strokeWidth:1}),f.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"#666"},t.label))),i.xLabel&&f.createElement("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:12,fill:"#333"},i.xLabel),f.createElement("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:"#ccc",strokeWidth:1}),c.map((t,e)=>f.createElement("g",{key:"ytick-"+e,transform:`translate(0,${t.pixel})`},f.createElement("line",{x2:-5,stroke:"#ccc",strokeWidth:1}),f.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"#666"},t.label))),i.yLabel&&f.createElement("text",{x:15-(null!==(r=null===(n=i.margin)||void 0===n?void 0:n.left)&&void 0!==r?r:40),y:e.height/2,textAnchor:"middle",fontSize:12,fill:"#333",transform:`rotate(-90, ${15-(null!==(s=null===(o=i.margin)||void 0===o?void 0:o.left)&&void 0!==s?s:40)}, ${e.height/2})`},i.yLabel))}(h.scales,{width:a,height:c},t):null,y=t.title&&"string"==typeof t.title?f.createElement("text",{x:o[0]/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333"},t.title):null,p=t.background?f.createElement("rect",{x:0,y:0,width:a,height:c,fill:t.background}):null,m=f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-xy-frame"+(t.className?" "+t.className:""),width:o[0],height:o[1]},f.createElement("g",{transform:`translate(${s.left},${s.top})`},p,d,g),y);return ue.renderToStaticMarkup(m)}function de(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const ge=new Set(["tree","cluster","treemap","circlepack","partition"]);function ye(t){const e=t.chartType||"force",i=t.size||[500,500],n=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),t.margin),r=i[0]-n.left-n.right,o=i[1]-n.top-n.bottom,s=function(t){return Vt[t]}(e);if(!s)throw Error(`No layout plugin found for chart type: "${e}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const a={chartType:e,nodeIDAccessor:t.nodeIDAccessor,sourceAccessor:t.sourceAccessor,targetAccessor:t.targetAccessor,valueAccessor:t.valueAccessor,childrenAccessor:t.childrenAccessor,hierarchySum:t.hierarchySum,orientation:t.orientation,nodeAlign:t.nodeAlign,nodePaddingRatio:t.nodePaddingRatio,nodeWidth:t.nodeWidth,iterations:t.iterations,forceStrength:t.forceStrength,padAngle:t.padAngle,groupWidth:t.groupWidth,sortGroups:t.sortGroups,edgeSort:t.edgeSort,treeOrientation:t.treeOrientation,edgeType:t.edgeType,padding:t.padding,paddingTop:t.paddingTop,nodeStyle:t.nodeStyle,edgeStyle:t.edgeStyle,nodeLabel:t.nodeLabel,showLabels:t.showLabels,colorBy:t.colorBy,colorScheme:t.colorScheme,edgeColorBy:t.edgeColorBy,edgeOpacity:t.edgeOpacity,colorByDepth:t.colorByDepth,nodeSize:t.nodeSize,nodeSizeRange:t.nodeSizeRange};let l,u;if(ge.has(e)){const e=t.data||t.edges;if(!e||Array.isArray(e))return ue.renderToStaticMarkup(f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-network-frame",width:i[0],height:i[1]}));a.__hierarchyRoot=e,l=[],u=[]}else{const e=t.nodes||[],n=Array.isArray(t.edges)?t.edges:[];if(0===e.length&&0===n.length)return ue.renderToStaticMarkup(f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-network-frame",width:i[0],height:i[1]}));if(u=function(t,e){const i=de(e.sourceAccessor,"source"),n=de(e.targetAccessor,"target"),r=de(e.valueAccessor,"value");return t.map(t=>({source:i(t)+"",target:n(t)+"",value:Number(r(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(n,a),0===e.length&&u.length>0){const t=new Set;for(const e of u){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)}l=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 l=function(t,e){const i=de(e.nodeIDAccessor,"id");return t.map(t=>({id:i(t)+"",x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}))}(e,a)}s.computeLayout(l,u,a,[r,o]);const{sceneNodes:h,sceneEdges:d,labels:g}=s.buildScene(l,u,a,[r,o]),y=d.map((t,e)=>function(t,e){switch(t.type){case"line":return f.createElement("line",{key:"net-edge-"+e,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity});case"bezier":{const i=t;return f.createElement("path",{key:"net-edge-"+e,d:i.pathD,fill:le(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}case"ribbon":{const i=t;return f.createElement("path",{key:"net-edge-"+e,d:i.pathD,fill:le(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}case"curved":{const i=t;return f.createElement("path",{key:"net-edge-"+e,d:i.pathD,fill:le(i.style.fill,"none"),stroke:i.style.stroke||"#999",strokeWidth:i.style.strokeWidth||1,opacity:i.style.opacity})}default:return null}}(t,e)).filter(Boolean),p=h.map((t,e)=>function(t,e){switch(t.type){case"circle":{const i=t;return f.createElement("circle",{key:"net-circle-"+e,cx:i.cx,cy:i.cy,r:i.r,fill:le(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}case"rect":{const i=t;return f.createElement("rect",{key:"net-rect-"+e,x:i.x,y:i.y,width:i.w,height:i.h,fill:le(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}case"arc":{const i=t,n=c.arc().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle).endAngle(i.endAngle)({})||"";return f.createElement("path",{key:"net-arc-"+e,d:n,transform:`translate(${i.cx},${i.cy})`,fill:le(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}default:return null}}(t,e)).filter(Boolean),m=g.map((t,e)=>function(t,e){return f.createElement("text",{key:"net-label-"+e,x:t.x,y:t.y,textAnchor:t.anchor||"middle",dominantBaseline:t.baseline||"auto",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"#333",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder},t.text)}(t,e)).filter(Boolean),v=t.title&&"string"==typeof t.title?f.createElement("text",{x:i[0]/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333"},t.title):null,x=t.background?f.createElement("rect",{x:0,y:0,width:r,height:o,fill:t.background}):null,b=f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-network-frame"+(t.className?" "+t.className:""),width:i[0],height:i[1]},f.createElement("g",{transform:`translate(${n.left},${n.top})`},x,y,p,m),v);return ue.renderToStaticMarkup(b)}function pe(t){var e,i,n;const r=t.size||[500,400],o=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),t.margin),s=r[0]-o.left-o.right,a=r[1]-o.top-o.bottom,l=t.projection||"vertical",u="radial"===l,h={chartType:t.chartType,windowSize:null!==(e=t.windowSize)&&void 0!==e?e:1e4,windowMode:null!==(i=t.windowMode)&&void 0!==i?i:"sliding",extentPadding:null!==(n=t.extentPadding)&&void 0!==n?n:.05,projection:l,oAccessor:t.oAccessor,rAccessor:t.rAccessor,colorAccessor:t.colorAccessor,stackBy:t.stackBy,groupBy:t.groupBy,categoryAccessor:t.categoryAccessor,valueAccessor:t.valueAccessor,timeAccessor:t.timeAccessor,rExtent:t.rExtent,oExtent:t.oExtent,barPadding:t.barPadding,innerRadius:t.innerRadius,normalize:t.normalize,startAngle:t.startAngle,bins:t.bins,showOutliers:t.showOutliers,showIQR:t.showIQR,amplitude:t.amplitude,oSort:t.oSort,connectorAccessor:t.connectorAccessor,connectorStyle:t.connectorStyle,dynamicColumnWidth:t.dynamicColumnWidth,pieceStyle:t.pieceStyle,summaryStyle:t.summaryStyle,colorScheme:t.colorScheme,barColors:t.barColors},d=new Kt(h);if(t.data&&d.ingest({inserts:t.data,bounded:!0}),d.computeScene({width:s,height:a}),!d.scales||0===d.scene.length)return ue.renderToStaticMarkup(f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-ordinal-frame",width:r[0],height:r[1]}));const g=d.scene.map((t,e)=>function(t,e){var i,n,r,o,s;const a=t.category||t.group||"",l=i=>`ord-${t.type}-${a}-${e}-${i}`,u=`ord-${t.type}-${a}-${e}`;switch(t.type){case"rect":{const e=t;return f.createElement("rect",{key:u,x:e.x,y:e.y,width:e.w,height:e.h,fill:le(e.style.fill),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})}case"point":{const e=t;return f.createElement("circle",{key:u,cx:e.x,cy:e.y,r:e.r,fill:le(e.style.fill),opacity:null!==(i=e.style.opacity)&&void 0!==i?i:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})}case"wedge":{const e=t,i=c.arc().innerRadius(e.innerRadius).outerRadius(e.outerRadius).startAngle(e.startAngle).endAngle(e.endAngle)({})||"";return f.createElement("path",{key:u,d:i,transform:`translate(${e.cx},${e.cy})`,fill:le(e.style.fill),stroke:e.style.stroke,strokeWidth:e.style.strokeWidth,opacity:e.style.opacity})}case"boxplot":{const e=t,i=e.columnWidth/2;return"vertical"===e.projection?f.createElement("g",{key:u},f.createElement("line",{x1:e.x,y1:e.minPos,x2:e.x,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:1}),f.createElement("rect",{x:e.x-i,y:Math.min(e.q1Pos,e.q3Pos),width:e.columnWidth,height:Math.abs(e.q3Pos-e.q1Pos),fill:le(e.style.fill),fillOpacity:null!==(n=e.style.fillOpacity)&&void 0!==n?n:.6,stroke:e.style.stroke||"#333",strokeWidth:1}),f.createElement("line",{x1:e.x-i,y1:e.medianPos,x2:e.x+i,y2:e.medianPos,stroke:e.style.stroke||"#333",strokeWidth:2}),f.createElement("line",{x1:e.x-.5*i,y1:e.minPos,x2:e.x+.5*i,y2:e.minPos,stroke:e.style.stroke||"#333",strokeWidth:1}),f.createElement("line",{x1:e.x-.5*i,y1:e.maxPos,x2:e.x+.5*i,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:1})):f.createElement("g",{key:u},f.createElement("line",{x1:e.minPos,y1:e.y,x2:e.maxPos,y2:e.y,stroke:e.style.stroke||"#333",strokeWidth:1}),f.createElement("rect",{x:Math.min(e.q1Pos,e.q3Pos),y:e.y-i,width:Math.abs(e.q3Pos-e.q1Pos),height:e.columnWidth,fill:le(e.style.fill),fillOpacity:null!==(r=e.style.fillOpacity)&&void 0!==r?r:.6,stroke:e.style.stroke||"#333",strokeWidth:1}),f.createElement("line",{x1:e.medianPos,y1:e.y-i,x2:e.medianPos,y2:e.y+i,stroke:e.style.stroke||"#333",strokeWidth:2}),f.createElement("line",{x1:e.minPos,y1:e.y-.5*i,x2:e.minPos,y2:e.y+.5*i,stroke:e.style.stroke||"#333",strokeWidth:1}),f.createElement("line",{x1:e.maxPos,y1:e.y-.5*i,x2:e.maxPos,y2:e.y+.5*i,stroke:e.style.stroke||"#333",strokeWidth:1}))}case"violin":{const e=t,i=[f.createElement("path",{key:l("path"),d:e.pathString,transform:e.translateX||e.translateY?`translate(${e.translateX},${e.translateY})`:void 0,fill:le(e.style.fill),fillOpacity:null!==(o=e.style.fillOpacity)&&void 0!==o?o:.6,stroke:e.style.stroke||"#333",strokeWidth:e.style.strokeWidth||1})];if(e.iqrLine&&e.bounds){const t=e.bounds,n=t.x+t.width/2,r=t.y+t.height/2;t.height>t.width?i.push(f.createElement("line",{key:l("iqr"),x1:n,y1:e.iqrLine.q1Pos,x2:n,y2:e.iqrLine.q3Pos,stroke:e.style.stroke||"#333",strokeWidth:2}),f.createElement("circle",{key:l("med"),cx:n,cy:e.iqrLine.medianPos,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1})):i.push(f.createElement("line",{key:l("iqr"),x1:e.iqrLine.q1Pos,y1:r,x2:e.iqrLine.q3Pos,y2:r,stroke:e.style.stroke||"#333",strokeWidth:2}),f.createElement("circle",{key:l("med"),cx:e.iqrLine.medianPos,cy:r,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1}))}return f.createElement("g",{key:u},i)}case"connector":return f.createElement("line",{key:u,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:null!==(s=t.style.opacity)&&void 0!==s?s:.5});case"trapezoid":{const e=t,i=e.points.map(t=>`${t[0]},${t[1]}`).join(" ");return f.createElement("polygon",{key:u,points:i,fill:le(e.style.fill,"#999"),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})}default:return null}}(t,e)).filter(Boolean),y=!1!==t.showAxes?function(t,e,i){var n,r,o,s,a,c,l,u;const h=t.scales;if(!h)return null;if("radial"===h.projection)return null;const d="vertical"===h.projection,g=Object.values(t.columns).map(t=>({pixel:t.middle,label:(i.oFormat||String)(t.name)})),y=h.r.ticks(5).map(t=>({pixel:h.r(t),label:(i.rFormat||he)(t)}));return d?f.createElement("g",{className:"ordinal-axes"},f.createElement("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:"#ccc",strokeWidth:1}),g.map((t,i)=>f.createElement("g",{key:"oxtick-"+i,transform:`translate(${t.pixel},${e.height})`},f.createElement("line",{y2:5,stroke:"#ccc",strokeWidth:1}),f.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"#666"},t.label))),i.oLabel&&f.createElement("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:12,fill:"#333"},i.oLabel),f.createElement("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:"#ccc",strokeWidth:1}),y.map((t,e)=>f.createElement("g",{key:"oytick-"+e,transform:`translate(0,${t.pixel})`},f.createElement("line",{x2:-5,stroke:"#ccc",strokeWidth:1}),f.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"#666"},t.label))),i.rLabel&&f.createElement("text",{x:15-(null!==(r=null===(n=i.margin)||void 0===n?void 0:n.left)&&void 0!==r?r:40),y:e.height/2,textAnchor:"middle",fontSize:12,fill:"#333",transform:`rotate(-90, ${15-(null!==(s=null===(o=i.margin)||void 0===o?void 0:o.left)&&void 0!==s?s:40)}, ${e.height/2})`},i.rLabel)):f.createElement("g",{className:"ordinal-axes"},f.createElement("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:"#ccc",strokeWidth:1}),y.map((t,i)=>f.createElement("g",{key:"oxtick-"+i,transform:`translate(${t.pixel},${e.height})`},f.createElement("line",{y2:5,stroke:"#ccc",strokeWidth:1}),f.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"#666"},t.label))),i.rLabel&&f.createElement("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:12,fill:"#333"},i.rLabel),f.createElement("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:"#ccc",strokeWidth:1}),g.map((t,e)=>f.createElement("g",{key:"oytick-"+e,transform:`translate(0,${t.pixel})`},f.createElement("line",{x2:-5,stroke:"#ccc",strokeWidth:1}),f.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"#666"},t.label))),i.oLabel&&f.createElement("text",{x:15-(null!==(c=null===(a=i.margin)||void 0===a?void 0:a.left)&&void 0!==c?c:40),y:e.height/2,textAnchor:"middle",fontSize:12,fill:"#333",transform:`rotate(-90, ${15-(null!==(u=null===(l=i.margin)||void 0===l?void 0:l.left)&&void 0!==u?u:40)}, ${e.height/2})`},i.oLabel))}(d,{width:s,height:a},t):null,p=t.title&&"string"==typeof t.title?f.createElement("text",{x:r[0]/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333"},t.title):null,m=t.background?f.createElement("rect",{x:0,y:0,width:s,height:a,fill:t.background}):null,v=f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-ordinal-frame"+(t.className?" "+t.className:""),width:r[0],height:r[1]},f.createElement("g",{transform:`translate(${u?o.left+s/2:o.left},${u?o.top+a/2:o.top})`},m,g,y),p);return ue.renderToStaticMarkup(v)}function me(t){var e,i,n,r,o,s;const a=t.size||[t.width||600,t.height||400],c=Object.assign(Object.assign({},{top:10,right:10,bottom:10,left:10}),t.margin),l=a[0]-(null!==(e=c.left)&&void 0!==e?e:0)-(null!==(i=c.right)&&void 0!==i?i:0),u=a[1]-(null!==(n=c.top)&&void 0!==n?n:0)-(null!==(r=c.bottom)&&void 0!==r?r:0),h=new ce({projection:t.projection||"equalEarth",xAccessor:t.xAccessor,yAccessor:t.yAccessor,lineDataAccessor:t.lineDataAccessor,pointIdAccessor:t.pointIdAccessor,lineType:t.lineType,areaStyle:t.areaStyle,pointStyle:t.pointStyle,lineStyle:t.lineStyle,graticule:t.graticule,fitPadding:t.fitPadding,projectionTransform:t.projectionTransform});if(t.areas){if("string"==typeof t.areas)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${t.areas}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${t.areas}')\` before calling renderGeoToStaticSVG.`);h.setAreas(t.areas)}if(t.points&&h.setPoints(t.points),t.lines&&h.setLines(t.lines),h.computeScene({width:l,height:u}),0===h.scene.length)return ue.renderToStaticMarkup(f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-geo-frame",width:a[0],height:a[1]}));const d=h.scene.map((t,e)=>function(t,e){var i,n,r,o,s,a;switch(t.type){case"geoarea":{const r=t;return r.pathData?f.createElement("path",{key:"geoarea-"+e,d:r.pathData,fill:le(r.style.fill,"#e0e0e0"),fillOpacity:null!==(i=r.style.fillOpacity)&&void 0!==i?i:1,stroke:r.style.stroke||"none",strokeWidth:r.style.strokeWidth||.5,strokeDasharray:r.style.strokeDasharray,opacity:null!==(n=r._decayOpacity)&&void 0!==n?n:1}):null}case"point":{const i=t;return f.createElement("circle",{key:"point-"+e,cx:i.x,cy:i.y,r:i.r,fill:le(i.style.fill),fillOpacity:null!==(r=i.style.fillOpacity)&&void 0!==r?r:.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:null!==(o=i._decayOpacity)&&void 0!==o?o:null!==(s=i.style.opacity)&&void 0!==s?s:1})}case"line":{const i=t;if(2>i.path.length)return null;const n="M"+i.path.map(t=>`${t[0]},${t[1]}`).join("L");return f.createElement("path",{key:"line-"+e,d:n,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth||1.5,strokeDasharray:i.style.strokeDasharray,opacity:null!==(a=i.style.opacity)&&void 0!==a?a:1})}default:return null}}(t,e)).filter(Boolean),g=t.title&&"string"==typeof t.title?f.createElement("text",{x:a[0]/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333"},t.title):null,y=t.background?f.createElement("rect",{x:0,y:0,width:l,height:u,fill:t.background}):null,p=f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-geo-frame"+(t.className?" "+t.className:""),width:a[0],height:a[1]},f.createElement("g",{transform:`translate(${null!==(o=c.left)&&void 0!==o?o:0},${null!==(s=c.top)&&void 0!==s?s:0})`},y,d),g);return ue.renderToStaticMarkup(p)}exports.renderGeoToStaticSVG=function(t){return me(t)},exports.renderNetworkToStaticSVG=function(t){return ye(t)},exports.renderOrdinalToStaticSVG=function(t){return pe(t)},exports.renderToStaticSVG=function(t,e){switch(t){case"xy":return fe(e);case"ordinal":return pe(e);case"network":return ye(e);case"geo":return me(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", or "geo".`)}},exports.renderXYToStaticSVG=function(t){return fe(t)};
1
+ "use strict";const t=require("react"),e=require("d3-scale"),i=require("d3-quadtree"),r=require("d3-scale-chromatic"),o=require("d3-array"),n=require("d3-interpolate"),a=require("d3-force"),s=require("d3-chord"),c=require("d3-shape"),l=require("d3-hierarchy"),u=require("d3-geo");function h(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const i in t)if("default"!==i){const r=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,r.get?r:{enumerable:!0,get:function(){return t[i]}})}return e.default=t,Object.freeze(e)}const f=h(t);function d(t,e,i,r){return new(i||(i=Promise))(function(o,n){function a(t){try{c(r.next(t))}catch(t){n(t)}}function s(t){try{c(r.throw(t))}catch(t){n(t)}}function c(t){t.done?o(t.value):function(t){return t instanceof i?t:new i(function(e){e(t)})}(t.value).then(a,s)}c((r=r.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class g{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const i of t){const t=this.push(i);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;const e=this;return{next:()=>e._size>t?{done:!1,value:e.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)t(this.buffer[(e+i)%this._capacity],i)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)t[i]=this.buffer[(e+i)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),i=[];for(;e.length>t;)i.push(e.shift());this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(const t of e)this.push(t);return i}update(t,e){const i=[],r=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){const n=(r+o)%this._capacity,a=this.buffer[n];if(t(a)){let t;t="object"!=typeof a||null===a?a:Array.isArray(a)?[...a]:Object.assign({},a),i.push(t),this.buffer[n]=e(a)}}return i}remove(t){const e=[],i=[];if(this.forEach(r=>{t(r)?i.push(r):e.push(r)}),0===i.length)return i;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return i}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class y{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 p(t,e,i,r,o){const n=new Map;for(const a of t){const t=e(a),s=i(a);if(null==t||null==s||Number.isNaN(t)||Number.isNaN(s))continue;const c=Math.floor(t/r)*r;let l=n.get(c);if(l||(l={start:c,end:c+r,total:0,categories:new Map},n.set(c,l)),l.total+=s,o){const t=o(a);l.categories.set(t,(l.categories.get(t)||0)+s)}}return n}function m(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function x(t,e){if("function"==typeof t)return e=>+t(e);const i=t||e;return t=>+t[i]}function v(t,e){if("function"==typeof t)return t;const i=t||e;return t=>t[i]}function b(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}const k=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function w(t,e,i){var r,o,n;if(1>=i)return 1;const a=null!==(r=t.minOpacity)&&void 0!==r?r:.1,s=i-1-e;switch(t.type){case"linear":return a+(1-s/(i-1))*(1-a);case"exponential":{const e=null!==(o=t.halfLife)&&void 0!==o?o:i/2;return a+Math.pow(.5,s/e)*(1-a)}case"step":return(null!==(n=t.stepThreshold)&&void 0!==n?n:.5*i)>s?1:a;default:return 1}}function A(t,e,i){var r;const o=null!==(r=t.duration)&&void 0!==r?r:500,n=i-e;return o>n?1-n/o:0}function S(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function _(t,e){return Math.min((t-e.startTime)/e.duration,1)}function E(t,e,i){return t+(e-t)*i}function P(){return"undefined"!=typeof performance?performance.now():Date.now()}function M(t,e,i){var r,o,n,a;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const i=t.getX(e.datum),r=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${i}:${r}`;if(null!=i&&null!=r)return`p:${i}:${r}`}return"p:"+i;case"rect":return`r:${e.group||""}:${null!==(a=null!==(o=null===(r=e.datum)||void 0===r?void 0:r.binStart)&&void 0!==o?o:null===(n=e.datum)||void 0===n?void 0:n.category)&&void 0!==a?a: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 O(t,e,i,r,o,n){const a=[];for(const o of t){const t=i(o),n=r(o);null==t||null==n||Number.isNaN(t)||Number.isNaN(n)||a.push({px:e.x(t),py:e.y(n),rawY:n,d:o})}a.sort((t,e)=>t.px-e.px);const s=Array(a.length),c=Array(a.length),l=Array(a.length);for(let t=0;a.length>t;t++){const e=a[t];s[t]=[e.px,e.py],c[t]=e.rawY,l[t]=e.d}return{type:"line",path:s,rawValues:c,style:o,datum:l,group:n}}function L(t,e,i,r,o,n,a,s){const c=[];for(const n of t){const t=i(n),a=r(n);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const l=e.x(t),u=s?s(n):o;c.push({px:l,topY:e.y(a),botY:e.y(u)})}c.sort((t,e)=>t.px-e.px);const l=Array(c.length),u=Array(c.length);for(let t=0;c.length>t;t++){const e=c[t];l[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:l,bottomPath:u,style:n,datum:t,group:a}}function D(t,e,i,r,o,n,a){const s=i(t),c=r(t);if(null==s||null==c||Number.isNaN(s)||Number.isNaN(c))return null;const l={type:"point",x:e.x(s),y:e.y(c),r:o,style:n,datum:t};return void 0!==a&&(l.pointId=a),l}function z(t,e,i,r,o,n,a){return{type:"rect",x:t,y:e,w:i,h:r,style:o,datum:n,group:a}}function j(t,e,i,r,o,n,a){const s={type:"heatcell",x:t,y:e,w:i,h:r,fill:o,datum:n};return(null==a?void 0:a.showValues)&&(s.showValues=!0,s.value=a.value,a.valueFormat&&(s.valueFormat=a.valueFormat)),s}function T(t,e,i){if(!t.getBounds||!t.scales)return null;const r=[],o=[];for(const i of e){const e=t.getX(i),n=t.getY(i);if(null==e||null==n||Number.isNaN(e)||Number.isNaN(n))continue;const a=t.getBounds(i),s=t.scales.x(e);if(a&&0!==a)r.push([s,t.scales.y(n+a)]),o.push([s,t.scales.y(n-a)]);else{const e=t.scales.y(n);r.push([s,e]),o.push([s,e])}}return 2>r.length?null:{type:"area",topPath:r,bottomPath:o,style:t.resolveBoundsStyle(i,e[0]),datum:e,group:i,interactive:!1}}function N(t,e,i,r){var o;if(!t.config.pointStyle)return;const n=null!=r?r:t.getY;for(const r of e){const e=t.resolveGroupColor(r.key);for(const a of r.data){let r=t.config.pointStyle(a);!r.fill&&e&&(r=Object.assign(Object.assign({},r),{fill:e}));const s=null!==(o=r.r)&&void 0!==o?o:3,c=t.getPointId?t.getPointId(a)+"":void 0,l=D(a,t.scales,t.getX,n,s,r,c);l&&i.push(l)}}}const $={blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,viridis:r.interpolateViridis},B=new Map;class W{constructor(t){if(this.xExtent=new y,this.yExtent=new y,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.xIsDate=!1,this._quadtree=null,this.config=t,this.buffer=new g(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=x(t.timeAccessor||t.xAccessor,"time"),this.getY=x(t.valueAccessor||t.yAccessor,"value")):(this.getX=x(t.xAccessor,"x"),this.getY=x(t.yAccessor,"y")),this.getGroup=b(t.groupAccessor),this.getCategory=b(t.categoryAccessor),this.getSize=t.sizeAccessor?x(t.sizeAccessor,"size"):void 0,this.getColor=b(t.colorAccessor),this.getBounds=t.boundsAccessor?x(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?x(t.y0Accessor,"y0"):void 0,this.getPointId=b(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,i=null!=t.closeAccessor;this.getOpen=e?x(t.openAccessor,"open"):void 0,this.getHigh=x(t.highAccessor,"high"),this.getLow=x(t.lowAccessor,"low"),this.getClose=i?x(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!i}t.pulse&&(this.timestampBuffer=new g(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?x(this.config.timeAccessor||this.config.xAccessor,"time"):x(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],i=this.config.xAccessor,r="function"==typeof i?i(e):e[i||"x"],o=r instanceof Date,n="string"==typeof r&&r.length>=10&&!isNaN(new Date(r).getTime())&&isNaN(Number(r));if(this.xIsDate=o||n,n){const t="string"==typeof i?i:void 0;this.getX=t?e=>+new Date(e[t]):t=>+(i(t)instanceof Date?i(t):new Date(i(t)))}}const i=t.totalSize||t.inserts.length;i>this.buffer.capacity&&(this.buffer.resize(i),this.timestampBuffer&&i>this.timestampBuffer.capacity&&this.timestampBuffer.resize(i));for(const i of t.inserts)this.buffer.push(i),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(i)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(i)),this.yExtent.push(this.getLow(i))):(this.yExtent.push(this.getY(i)),this.getY0&&this.yExtent.push(this.getY0(i)))}else for(const i of t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity||1e6;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const t=this.buffer.push(i);this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(i)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(i)),this.yExtent.push(this.getLow(i))):(this.yExtent.push(this.getY(i)),this.getY0&&this.yExtent.push(this.getY0(i))),null!=t&&(this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):this.yExtent.evict(this.getY(t)))}return!0}computeScene(t){var i,r,o,n,a,s,c;const{config:l,buffer:u}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(i=this.config.scalePadding)&&void 0!==i?i:0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);if(this.xExtent.dirty&&this.xExtent.recalculate(u,this.getX),this.yExtent.dirty)if("candlestick"===l.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of u)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(u,this.getY);const h=this.getBufferArray(),f=this.xExtent.extent,d=this.yExtent.extent;let g=l.xExtent?[null!==(r=l.xExtent[0])&&void 0!==r?r:f[0],null!==(o=l.xExtent[1])&&void 0!==o?o:f[1]]:f,y=l.yExtent?[null!==(n=l.yExtent[0])&&void 0!==n?n:d[0],null!==(a=l.yExtent[1])&&void 0!==a?a:d[1]]:d;const m=l.yExtent&&null!=l.yExtent[0]&&null!=l.yExtent[1];if("stackedarea"===l.chartType&&!m&&u.size>0)if(l.normalize)y=[0,1+l.extentPadding];else{const t=`${u.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)y=this._stackExtentCache.yDomain;else{const e=this.groupData(h),i=new Map;for(const t of e)for(const e of t.data){const t=this.getX(e),r=this.getY(e);null==t||null==r||Number.isNaN(t)||Number.isNaN(r)||i.set(t,(i.get(t)||0)+r)}let r=0;for(const t of i.values())t>r&&(r=t);y=[0,r+(r>0?r*l.extentPadding:1)],this._stackExtentCache={key:t,yDomain:y}}}else if("bar"===l.chartType&&l.binSize&&!m&&u.size>0){const[,t]=function(t,e,i,r,o){const n=p(t,e,i,r,o);if(0===n.size)return[0,0];let a=0;for(const t of n.values())t.total>a&&(a=t.total);return[0,a]}(u,this.getX,this.getY,l.binSize,this.getCategory);y=[0,t+t*l.extentPadding]}else if("waterfall"===l.chartType&&!m&&u.size>0){const[t,e]=function(t,e){let i=0,r=0,o=0;for(const n of t){const t=e(n);null==t||Number.isNaN(t)||(o+=t,i>o&&(i=o),o>r&&(r=o))}return[i,r]}(u,this.getY),i=e-t,r=i>0?i*l.extentPadding:1;y=[Math.min(0,t-Math.abs(r)),Math.max(0,e+Math.abs(r))]}else if(!m&&y[0]!==1/0){if(this.getBounds)for(const t of h){const e=this.getY(t),i=this.getBounds(t);null!=e&&!Number.isNaN(e)&&i&&(e+i>y[1]&&(y[1]=e+i),y[0]>e-i&&(y[0]=e-i))}const t=y[1]-y[0],e=t>0?t*l.extentPadding:1,i=null===(s=l.yExtent)||void 0===s?void 0:s[0],r=null===(c=l.yExtent)||void 0===c?void 0:c[1];y=[null!=i?y[0]:y[0]-e,null!=r?y[1]:y[1]+e],"log"===l.yScaleType&&0>=y[0]&&d[0]>0&&(y[0]=null!=i?y[0]:d[0]/(1+l.extentPadding))}if(g[0]===1/0||g[1]===-1/0)if("time"===l.xScaleType){const t=Date.now();g=[t-864e5,t]}else g=[0,1];y[0]!==1/0&&y[1]!==-1/0||(y=[0,1]);const x="streaming"===l.runtimeMode,v=Math.max(0,Math.min(l.scalePadding||0,Math.min(t.width,t.height)/2-1));if(x)if("x"==("up"===(b=l.arrowOfTime)||"down"===b?"y":"x")){const i="right"===l.arrowOfTime?[v,t.width-v]:[t.width-v,v];this.scales={x:e.scaleLinear().domain(g).range(i),y:e.scaleLinear().domain(y).range([t.height-v,v])}}else{const i="down"===l.arrowOfTime?[v,t.height-v]:[t.height-v,v];this.scales={x:e.scaleLinear().domain(y).range([v,t.width-v]),y:e.scaleLinear().domain(g).range(i)}}else{const i=(t,i,r)=>{if("log"===t){const t=[Math.max(i[0],1e-6),Math.max(i[1],1e-6)];return e.scaleLog().domain(t).range(r).clamp(!0)}return"time"===t?e.scaleTime().domain([new Date(i[0]),new Date(i[1])]).range(r):e.scaleLinear().domain(i).range(r)};this.scales={x:i(l.xScaleType,g,[v,t.width-v]),y:i(l.yScaleType,y,[t.height-v,v])}}var b;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,h),this.config.decay&&this.applyDecay(this.scene,h),this.config.pulse&&this.applyPulse(this.scene,h),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}rebuildQuadtree(){const t=this.config.chartType;if("scatter"!==t&&"bubble"!==t)return void(this._quadtree=null);const e=this.scene.filter(t=>"point"===t.type);this._quadtree=e.length>W.QUADTREE_THRESHOLD?i.quadtree().x(t=>t.x).y(t=>t.y).addAll(e):null}get quadtree(){return this._quadtree}remapScene(t){const i=t.width/this.lastLayout.width,r=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const e of t.path)e[0]*=i,e[1]*=r;break;case"area":for(const e of t.topPath)e[0]*=i,e[1]*=r;for(const e of t.bottomPath)e[0]*=i,e[1]*=r;break;case"point":t.x*=i,t.y*=r;break;case"rect":case"heatcell":t.x*=i,t.y*=r,t.w*=i,t.h*=r;break;case"candlestick":t.x*=i,t.openY*=r,t.closeY*=r,t.highY*=r,t.lowY*=r}const o=this.scales.x.domain(),n=this.scales.y.domain(),a=this.scales.x.range(),s=this.scales.y.range(),c=(t,i,r)=>{if("log"===t){const t=[Math.max(i[0],1e-6),Math.max(i[1],1e-6)];return e.scaleLog().domain(t).range(r).clamp(!0)}return"time"===t?e.scaleTime().domain([new Date(i[0]),new Date(i[1])]).range(r):e.scaleLinear().domain(i).range(r)},l=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),u=s[1]>s[0];this.scales={x:c(this.config.xScaleType,o,a[0]>a[1]?[t.width-l,l]:[l,t.width-l]),y:c(this.config.yScaleType,n,u?[l,t.height-l]:[t.height-l,l])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){var i;const{config:o,scales:n}=this;if(!n||0===e.length)return[];const a={scales:n,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 r=t.groupData(e),o=[],n=null===(i=t.config.annotations)||void 0===i?void 0:i.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.getBounds)for(const e of r){const i=T(t,e.data,e.key);i&&o.push(i)}for(const e of r){const i=t.resolveLineStyle(e.key,e.data[0]),r=O(e.data,t.scales,t.getX,t.getY,i,e.key);n&&n.length>0&&(r.colorThresholds=n),t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),o.push(r)}return N(t,r,o),o}(a,e);case"area":return function(t,e){const i=t.groupData(e),r=[],o=t.scales.y.domain()[0],n=t.getY0?e=>{const i=t.getY0(e);return null==i?o:i}:void 0;for(const e of i){const i=t.resolveAreaStyle(e.key,e.data[0]),a=L(e.data,t.scales,t.getX,t.getY,o,i,e.key,n);t.config.gradientFill&&(a.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(a.curve=t.config.curve),t.config.lineGradient&&(a.strokeGradient=t.config.lineGradient),r.push(a)}return N(t,i,r),r}(a,e);case"mixed":return function(t,e){const i=t.groupData(e),r=[],o=t.config.areaGroups||new Set,n=t.scales.y.domain()[0],a=t.getY0?e=>{const i=t.getY0(e);return null==i?n:i}:void 0;for(const e of i)if(o.has(e.key)){const i=t.resolveAreaStyle(e.key,e.data[0]),o=L(e.data,t.scales,t.getX,t.getY,n,i,e.key,a);t.config.gradientFill&&(o.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),r.push(o)}else{const i=t.resolveLineStyle(e.key,e.data[0]),o=O(e.data,t.scales,t.getX,t.getY,i,e.key);t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),r.push(o)}return N(t,i,r),r}(a,e);case"stackedarea":return function(t,e){const i=t.groupData(e);i.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);const r=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,{nodes:o,stackedTops:n}=function(t,e,i,r,o,n,a){var s;const c=new Set;for(const e of t)for(const t of e.data){const e=i(t);null==e||Number.isNaN(e)||c.add(e)}const l=Array.from(c).sort((t,e)=>t-e),u=new Map;for(const e of t){const t=new Map;for(const o of e.data){const e=i(o),n=r(o);null==e||null==n||Number.isNaN(e)||Number.isNaN(n)||t.set(e,(t.get(e)||0)+n)}u.set(e.key,t)}let h;if(n){h=new Map;for(const e of l){let i=0;for(const r of t)i+=(null===(s=u.get(r.key))||void 0===s?void 0:s.get(e))||0;h.set(e,i||1)}}const f=[],d=new Map,g=new Map;for(const t of l)g.set(t,0);for(const i of t){const t=u.get(i.key),r=[],s=[],c=new Map;for(const i of l){let o=t.get(i)||0;const a=g.get(i);n&&(o/=h.get(i));const l=a+o,u=e.x(i);s.push([u,e.y(a)]),r.push([u,e.y(l)]),g.set(i,l),c.set(i,l)}d.set(i.key,c);const y={type:"area",topPath:r,bottomPath:s,style:o(i.key,i.data[0]),datum:i.data,group:i.key};a&&(y.curve=a),f.push(y)}return{nodes:f,stackedTops:d}}(i,t.scales,t.getX,t.getY,(e,i)=>t.resolveAreaStyle(e,i),t.config.normalize,r),a=o;if(t.config.pointStyle){const e=new WeakMap;for(const r of i){const i=n.get(r.key);if(i)for(const o of r.data){const r=t.getX(o),n=t.getY(o);null==r||Number.isNaN(r)||null==n||Number.isNaN(n)||!i.has(r)||e.set(o,i.get(r))}}const r=i=>{var r;return null!==(r=e.get(i))&&void 0!==r?r:t.getY(i)};N(t,i,a,r)}return a}(a,e);case"scatter":case"bubble":return function(t,e){const i=[],r="bubble"===t.config.chartType?10:5,o=t.config.sizeRange||[3,15];let n=null;if(t.getSize&&!t.config.pointStyle){const i=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(i.length>0){let t=1/0,e=-1/0;for(const r of i)t>r&&(t=r),r>e&&(e=r);n=i=>t===e?(o[0]+o[1])/2:o[0]+(i-t)/(e-t)*(o[1]-o[0])}}const a=t.getColor?t.resolveColorMap(e):null;for(const o of e){let e=t.config.pointStyle?t.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},s=e.r||r;if(n&&t.getSize){const e=t.getSize(o);null==e||Number.isNaN(e)||(s=n(e))}if(a&&t.getColor&&!e.fill){const i=t.getColor(o);i&&a.has(i)&&(e=Object.assign(Object.assign({},e),{fill:a.get(i)}))}const c=t.getPointId?t.getPointId(o)+"":void 0,l=D(o,t.scales,t.getX,t.getY,s,e,c);l&&i.push(l)}return i}(a,e);case"heatmap":return function(t,e,i){if(t.config.heatmapAggregation)return function(t,e,i){var r,o,n;const a=Math.max(1,Math.floor(null!==(r=t.config.heatmapXBins)&&void 0!==r?r:20)),s=Math.max(1,Math.floor(null!==(o=t.config.heatmapYBins)&&void 0!==o?o:20)),c=null!==(n=t.config.heatmapAggregation)&&void 0!==n?n:"count",l=x(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[u,h]=t.scales.x.domain(),[f,d]=t.scales.y.domain(),g=(h-u||1)/a,y=(d-f||1)/s,p=a*s;if(p>1e6)return[];const m=new Int32Array(p),v=new Float64Array(p);for(let i=0;e.length>i;i++){const r=e[i],o=t.getX(r),n=t.getY(r);if(!isFinite(o)||!isFinite(n))continue;const c=Math.min(Math.floor((o-u)/g),a-1),h=Math.min(Math.floor((n-f)/y),s-1);if(0>c||0>h)continue;const d=h*a+c;m[d]++;const p=l(r);v[d]+=isFinite(p)?p:0}let b=1/0,k=-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]}b>e&&(b=e),e>k&&(k=e)}if(!isFinite(b))return[];const w=k-b||1,A=i.width/a,S=i.height/s,_=t.config.showValues,E=t.config.heatmapValueFormat,P=[];for(let t=0;s>t;t++){const e=t*a;for(let i=0;a>i;i++){const r=e+i;if(0===m[r])continue;let o;switch(c){case"sum":o=v[r];break;case"mean":o=v[r]/m[r];break;default:o=m[r]}const n=(o-b)/w;P.push(j(i*A,(s-1-t)*S,A,S,`rgb(${220-(180*n+.5)|0},${220-(100*n+.5)|0},${255-(50*n+.5)|0})`,{xi:i,yi:t,value:o,count:m[r],sum:v[r]},_?{value:o,showValues:!0,valueFormat:E}:void 0))}}return P}(t,e,i);if(0===e.length)return[];const o=x(t.config.valueAccessor,"value"),n=v(t.config.xAccessor,"x"),a=v(t.config.yAccessor,"y"),s=new Map,c=new Map,l=Array(e.length),u=Array(e.length);for(let t=0;e.length>t;t++){const i=e[t],r=n(i),o=a(i);l[t]=r,u[t]=o,s.has(r)||s.set(r,s.size),c.has(o)||c.set(o,c.size)}const h=s.size,f=c.size;if(0===h||0===f)return[];const d=Array.from(s.keys()),g=Array.from(c.keys()),y=d.every(t=>"number"==typeof t&&!isNaN(t)),p=g.every(t=>"number"==typeof t&&!isNaN(t));if(y){d.sort((t,e)=>t-e),s.clear();for(let t=0;d.length>t;t++)s.set(d[t],t)}if(p){g.sort((t,e)=>t-e),c.clear();for(let t=0;g.length>t;t++)c.set(g[t],t)}const m=new Float64Array(e.length),b=new Float64Array(e.length),k=Array(e.length),w=new Map;let A=0;for(let t=0;e.length>t;t++){const i=e[t],r=s.get(l[t]),n=c.get(u[t]);if(void 0===r||void 0===n)continue;const a=o(i),f=n*h+r,d=w.get(f);let g;void 0!==d?g=d:(g=A++,w.set(f,g)),m[g]=f,b[g]=a,k[g]=i}let S=1/0,_=-1/0;for(let t=0;A>t;t++){const e=b[t];isFinite(e)&&(S>e&&(S=e),e>_&&(_=e))}if(!isFinite(S)||!isFinite(_))return[];const E=function(t){const e=t in $?t:"blues";let i=B.get(e);if(i)return i;i=Array(256);const o=$[e]||r.interpolateBlues;for(let t=0;256>t;t++)i[t]=o(t/255);return B.set(e,i),i}("string"==typeof t.config.colorScheme?t.config.colorScheme:"blues"),P=255/(_-S||1),M=i.width/h,O=i.height/f,L=t.config.showValues,D=t.config.heatmapValueFormat,z=[];for(let t=0;A>t;t++){const e=b[t];if(!isFinite(e))continue;const i=m[t],r=i%h;z.push(j(r*M,(f-1-(i-r)/h)*O,M,O,E[Math.min((e-S)*P+.5|0,255)],k[t],L?{value:e,showValues:!0,valueFormat:D}:void 0))}return z}(a,e,t);case"bar":{const t=function(t,e){var i;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const r=p(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===r.size)return{nodes:[],binBoundaries:[]};let o=null;if(t.getCategory){const e=new Set;for(const t of r.values())for(const i of t.categories.keys())e.add(i);const i=t.config.barColors?Object.keys(t.config.barColors):[],n=new Set(i),a=Array.from(e).filter(t=>!n.has(t)).sort(),s=i.filter(t=>e.has(t)),c=s.join("\0")+""+a.join("\0");t.barCategoryCache&&t.barCategoryCache.key===c?o=t.barCategoryCache.order:(o=[...s,...a],t.barCategoryCache={key:c,order:o})}const n=[],a=t.scales,[s,c]=a.x.domain();for(const e of r.values()){const r=Math.max(e.start,s),l=Math.min(e.end,c);if(r>=l)continue;const u=a.x(r),h=a.x(l),f=Math.abs(h-u),d=f>2?1:0,g=Math.min(u,h)+d/2,y=Math.max(f-d,1);if(y>0)if(o&&e.categories.size>0){let r=0;for(const s of o){const o=e.categories.get(s)||0;if(0===o)continue;const c=a.y(r),l=a.y(r+o);n.push(z(g,Math.min(c,l),y,Math.abs(c-l),{fill:(null===(i=t.config.barColors)||void 0===i?void 0:i[s])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:s,categoryValue:o},s)),r+=o}}else{const t=a.y(0),i=a.y(e.total);n.push(z(g,Math.min(t,i),y,Math.abs(t-i),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}const l=new Set;for(const t of r.values())l.add(t.start),l.add(t.end);return{nodes:n,binBoundaries:Array.from(l).sort((t,e)=>t-e)}}(a,e);return this._barCategoryCache=null!==(i=a.barCategoryCache)&&void 0!==i?i:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var i,r,o,n;const a=[],s=t.config.swarmStyle||{},c=null!==(i=s.radius)&&void 0!==i?i:3,l=null!==(r=s.fill)&&void 0!==r?r:"#007bff",u=null!==(o=s.opacity)&&void 0!==o?o:.7,h=s.stroke,f=s.strokeWidth;for(const i of e){const e=t.getX(i),r=t.getY(i);if(null==r||Number.isNaN(r))continue;const o=t.scales.x(e),s=t.scales.y(r);let d=l;if(t.getCategory){const e=t.getCategory(i);d=(null===(n=t.config.barColors)||void 0===n?void 0:n[e])||d}const g={type:"point",x:o,y:s,r:c,style:{fill:d,opacity:u,stroke:h,strokeWidth:f},datum:i};t.getPointId&&(g.pointId=t.getPointId(i)+""),a.push(g)}return a}(a,e);case"waterfall":return function(t,e,i){var r,o,n;const a=[],s=t.scales,c=t.config.waterfallStyle,l=e.filter(e=>{const i=t.getY(e),r=t.getX(e);return null!=i&&!Number.isNaN(i)&&null!=r&&isFinite(r)});if(0===l.length)return a;const u=null!==(r=null==c?void 0:c.positiveColor)&&void 0!==r?r:"#28a745",h=null!==(o=null==c?void 0:c.negativeColor)&&void 0!==o?o:"#dc3545",f=null!==(n=null==c?void 0:c.gap)&&void 0!==n?n:1,d=null==c?void 0:c.stroke,g=null==c?void 0:c.strokeWidth;let y=0;for(let e=0;l.length>e;e++){const r=l[e],o=t.getX(r),n=t.getY(r),p=y+n;let m;m=l.length-1>e?t.getX(l[e+1])-o:e>0?o-t.getX(l[e-1]):0;const x=s.x(o),v=0!==m?s.x(o+m):x+i.width/10,b=Math.min(x,v)+f/2,k=Math.max(x,v)-f/2-b;if(0>=k){y=p;continue}const w=s.y(y),A=s.y(p);a.push(z(b,Math.min(w,A),k,Math.abs(w-A),{fill:0>n?h:u,stroke:d,strokeWidth:g},Object.assign(Object.assign({},r),{baseline:y,cumEnd:p,delta:n,_connectorStroke:null==c?void 0:c.connectorStroke,_connectorWidth:null==c?void 0:c.connectorWidth}))),y=p}return a}(a,e,t);case"candlestick":return function(t,e){var i,r;if(!t.getHigh||!t.getLow||!t.scales)return[];const o=null!==(i=t.config.candlestickRangeMode)&&void 0!==i&&i;if(!(o||t.getOpen&&t.getClose))return[];const n=[],a=t.config.candlestickStyle||{},s=a.rangeColor||"#6366f1",c=o?s:a.upColor||"#28a745",l=o?s:a.downColor||"#dc3545",u=o?s:a.wickColor||"#333",h=a.wickWidth||(o?2:1),f=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let d=o?0:null!==(r=a.bodyWidth)&&void 0!==r?r:0;if(!o&&null==a.bodyWidth&&f.length>1){let e=1/0;for(let i=1;f.length>i;i++){const r=Math.abs(t.scales.x(f[i])-t.scales.x(f[i-1]));r>0&&e>r&&(e=r)}d=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else o||null!=a.bodyWidth||(d=6);for(const i of e){const e=t.getX(i);if(null==e||Number.isNaN(e))continue;const r=t.getHigh(i),a=t.getLow(i);if(null==r||Number.isNaN(r)||null==a||Number.isNaN(a))continue;const s=o?r:t.getOpen(i),f=o?a:t.getClose(i);if(!o&&[s,f].some(t=>null==t||Number.isNaN(t)))continue;const g=f>=s,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(s),closeY:t.scales.y(f),highY:t.scales.y(r),lowY:t.scales.y(a),bodyWidth:d,upColor:c,downColor:l,wickColor:u,wickWidth:h,isUp:g,datum:i};o&&(y.isRange=!0),n.push(y)}return n}(a,e);default:return[]}}resolveBoundsStyle(t,e){const i=this.config.boundsStyle;return"function"==typeof i?i(e||{},t):i&&"object"==typeof i?i:{fill:this.resolveLineStyle(t,e).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?w(i,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,i){var r,o;const n=i.length;if(1>=n)return;const a=new Map;for(let t=0;i.length>t;t++)a.set(i[t],t);for(const i of e){if("line"===i.type){const e=Array.isArray(i.datum)?i.datum:[];if(2>e.length)continue;const r=Array(e.length);let o=!1;for(let i=0;e.length>i;i++){const s=a.get(e[i]);null!=s?(r[i]=w(t,s,n),1>r[i]&&(o=!0)):r[i]=1}o&&(i._decayOpacities=r);continue}if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[],r=i.topPath?i.topPath.length:e.length;if(2>r)continue;if(e.length===r){const o=Array(r);let s=!1;for(let i=0;e.length>i;i++){const r=a.get(e[i]);null!=r?(o[i]=w(t,r,n),1>o[i]&&(s=!0)):o[i]=1}s&&(i._decayOpacities=o)}else{let o=1;for(const i of e){const e=a.get(i);if(null!=e){const i=w(t,e,n);o>i&&(o=i)}}if(1>o){const t=Array(r);t.fill(o),i._decayOpacities=t}}continue}const e=a.get(i.datum);if(null==e)continue;const s=w(t,e,n);if("heatcell"===i.type)i.style={opacity:s};else if("candlestick"===i.type)i._decayOpacity=s;else{const t=null!==(o=null===(r=i.style)||void 0===r?void 0:r.opacity)&&void 0!==o?o:1;i.style=Object.assign(Object.assign({},i.style),{opacity:t*s})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,i,r){var o,n;const a="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(o=t.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",c=null!==(n=t.glowRadius)&&void 0!==n?n:4,l=new Map;for(let t=0;i.length>t;t++)l.set(i[t],t);for(const i of e){if("line"===i.type)continue;if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[i.datum];let o=0;for(const i of e){const e=l.get(i);if(null==e)continue;const n=r.get(e);if(null==n)continue;const s=A(t,n,a);s>o&&(o=s)}o>0&&(i._pulseIntensity=o,i._pulseColor=s);continue}const e=l.get(i.datum);if(null==e)continue;const o=r.get(e);if(null==o)continue;const n=A(t,o,a);n>0&&(i._pulseIntensity=n,i._pulseColor=s,i._pulseGlowRadius=c)}}(this.config.pulse,t,e,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(t,e){var i;if(!e||0===e.size)return!1;const r="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(i=t.duration)&&void 0!==i?i:500,n=e.peek();return null!=n&&o>r-n}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,i,r){var o,n,a;i.clear(),r.clear();for(let s=0;e.length>s;s++){const c=e[s],l=M(t,c,s);l&&("point"===c.type?i.set(l,{x:c.x,y:c.y,r:c.r,opacity:c.style.opacity}):"rect"===c.type?i.set(l,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:c.style.opacity}):"heatcell"===c.type?i.set(l,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:null===(o=c.style)||void 0===o?void 0:o.opacity}):"candlestick"===c.type?i.set(l,{x:c.x,y:c.openY}):"line"===c.type?r.set(l,{path:c.path.map(t=>[t[0],t[1]]),opacity:null===(n=c.style)||void 0===n?void 0:n.opacity}):"area"===c.type&&r.set(l,{topPath:c.topPath.map(t=>[t[0],t[1]]),bottomPath:c.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(a=c.style)||void 0===a?void 0:a.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}startTransition(){if(!this.config.transition)return;const t=function(t,e,i,r,o){var n,a,s,c,l,u,h,f,d,g,y,p,m,x,v,b,k,w,A,S,_,E,O,L,D,z,j,T;if(0===r.size&&0===o.size)return i;const N=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 $=!1;const B=new Set,W=new Set;for(let e=0;i.scene.length>e;e++){const n=i.scene[e],A=M(t,n,e);if(!A)continue;if(n._transitionKey=A,"line"===n.type||"area"===n.type){const t=o.get(A);if(t){if(W.add(A),"line"===n.type&&t.path&&t.path.length===n.path.length){n._targetPath=n.path.map(t=>[t[0],t[1]]),n._prevPath=t.path;for(let e=0;n.path.length>e;e++)n.path[e]=[t.path[e][0],t.path[e][1]];$=!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]];$=!0}n._targetOpacity=null!==(a=n.style.opacity)&&void 0!==a?a:1,n._startOpacity=null!==(c=null!==(s=t.opacity)&&void 0!==s?s: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}),$=!0;continue}const S=r.get(A);if("point"===n.type)if(S){B.add(A);const t={x:n.x,y:n.y,r:n.r};n._targetOpacity=null!==(u=n.style.opacity)&&void 0!==u?u:1,S.x===t.x&&S.y===t.y&&S.r===t.r||(n._targetX=t.x,n._targetY=t.y,n._targetR=t.r,n.x=S.x,n.y=S.y,n.r=null!==(h=S.r)&&void 0!==h?h:n.r,$=!0)}else n._targetOpacity=null!==(f=n.style.opacity)&&void 0!==f?f:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),$=!0;else if("rect"===n.type)if(S){B.add(A);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=null!==(d=n.style.opacity)&&void 0!==d?d:1,S.x===t.x&&S.y===t.y&&S.w===t.w&&S.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=S.x,n.y=S.y,n.w=null!==(g=S.w)&&void 0!==g?g:n.w,n.h=null!==(y=S.h)&&void 0!==y?y:n.h,$=!0)}else n._targetOpacity=null!==(p=n.style.opacity)&&void 0!==p?p:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),$=!0;else if("heatcell"===n.type)if(S){B.add(A);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=null!==(x=null===(m=n.style)||void 0===m?void 0:m.opacity)&&void 0!==x?x:1,S.x===t.x&&S.y===t.y&&S.w===t.w&&S.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=S.x,n.y=S.y,n.w=null!==(v=S.w)&&void 0!==v?v:n.w,n.h=null!==(b=S.h)&&void 0!==b?b:n.h,$=!0)}else n._targetOpacity=null!==(w=null===(k=n.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,n.style=Object.assign(Object.assign({},n.style||{}),{opacity:0}),$=!0}for(const[t,e]of o)if(!W.has(t))if(t.startsWith("l:")&&e.path){const r={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(A=e.opacity)&&void 0!==A?A:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(r),$=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const r={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:null!==(S=e.opacity)&&void 0!==S?S:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(r),$=!0}for(const[t,e]of r)if(!B.has(t)){if(t.startsWith("p:")){const r={type:"point",x:e.x,y:e.y,r:null!==(_=e.r)&&void 0!==_?_:3,style:{opacity:null!==(E=e.opacity)&&void 0!==E?E:1},datum:null,_targetOpacity:0,_transitionKey:t};i.exitNodes.push(r)}else if(t.startsWith("r:")){const r={type:"rect",x:e.x,y:e.y,w:null!==(O=e.w)&&void 0!==O?O:0,h:null!==(L=e.h)&&void 0!==L?L:0,style:{opacity:null!==(D=e.opacity)&&void 0!==D?D:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};i.exitNodes.push(r)}else if(t.startsWith("h:")){const r={type:"heatcell",x:e.x,y:e.y,w:null!==(z=e.w)&&void 0!==z?z:0,h:null!==(j=e.h)&&void 0!==j?j:0,fill:"#999",datum:null,style:{opacity:null!==(T=e.opacity)&&void 0!==T?T:1},_targetOpacity:0,_transitionKey:t};i.exitNodes.push(r)}$=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),$&&(i.activeTransition={startTime:P(),duration:N}),i}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},i=function(t,e,i,r){var o,n,a,s,c;if(!i.activeTransition)return!1;const l=_(t,i.activeTransition),u=S(l,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of i.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const i=e?r.get(e):void 0,n=i?null!==(o=i.opacity)&&void 0!==o?o:1:0;t.style.opacity=E(n,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const i=r.get(e);if(!i)continue;t.x=E(i.x,t._targetX,u),t.y=E(i.y,t._targetY,u),void 0!==t._targetR&&void 0!==i.r&&(t.r=E(i.r,t._targetR,u))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=e?r.get(e):void 0,o=i?null!==(n=i.opacity)&&void 0!==n?n:1:0;t.style.opacity=E(o,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const i=r.get(e);if(!i)continue;t.x=E(i.x,t._targetX,u),t.y=E(i.y,t._targetY,u),void 0!==i.w&&(t.w=E(i.w,t._targetW,u)),void 0!==i.h&&(t.h=E(i.h,t._targetH,u))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const i=e?r.get(e):void 0,o=i?null!==(a=i.opacity)&&void 0!==a?a:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:E(o,t._targetOpacity,u)})}if(void 0===t._targetX)continue;if(!e)continue;const i=r.get(e);if(!i)continue;t.x=E(i.x,t._targetX,u),t.y=E(i.y,t._targetY,u),void 0!==i.w&&(t.w=E(i.w,t._targetW,u)),void 0!==i.h&&(t.h=E(i.h,t._targetH,u))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=null!==(s=t._startOpacity)&&void 0!==s?s:0;t.style=Object.assign(Object.assign({},t.style),{opacity:E(e,t._targetOpacity,u)})}const e=t._prevPath,i=t._targetPath;if(e&&i&&e.length===t.path.length)for(let r=0;t.path.length>r;r++)t.path[r][0]=E(e[r][0],i[r][0],u),t.path[r][1]=E(e[r][1],i[r][1],u)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(c=t._startOpacity)&&void 0!==c?c:0;t.style=Object.assign(Object.assign({},t.style),{opacity:E(e,t._targetOpacity,u)})}const e=t._prevTopPath,i=t._prevBottomPath,r=t._targetTopPath,o=t._targetBottomPath;if(e&&r&&e.length===t.topPath.length)for(let i=0;t.topPath.length>i;i++)t.topPath[i][0]=E(e[i][0],r[i][0],u),t.topPath[i][1]=E(e[i][1],r[i][1],u);if(i&&o&&i.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=E(i[e][0],o[e][0],u),t.bottomPath[e][1]=E(i[e][1],o[e][1],u)}}if(l>=1){for(const t of i.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style=Object.assign(Object.assign({},"line"===t.type||"area"===t.type?t.style:t.style||{}),{opacity:0===e?0:e}),t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let i=0;t.path.length>i;i++)t.path[i]=e[i];t._prevPath=void 0,t._targetPath=void 0}else if("area"===t.type){const e=t._targetTopPath,i=t._targetBottomPath;if(e)for(let i=0;t.topPath.length>i;i++)t.topPath[i]=e[i];if(i)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=i[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0}}if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}return i.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,i}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const i of t){const t=this.getGroup(i);e.has(t)||e.set(t,[]),e.get(t).push(i)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveColorMap(t){const e=new Set;for(const i of t){const t=this.getColor(i);t&&e.add(t)}const i=Array.from(e).sort(),r=i.join("\0");if(this._colorMapCache&&this._colorMapCache.key===r)return this._colorMapCache.map;const o=Array.isArray(this.config.colorScheme)?this.config.colorScheme:k,n=new Map;for(let t=0;i.length>t;t++)n.set(i[t],o[t%o.length]);return this._colorMapCache={key:r,map:n},n}resolveLineStyle(t,e){const i=this.config.lineStyle;if("function"==typeof i){const r=i(e||{},t);if(r&&!r.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},r),{stroke:e})}return r}return i&&"object"==typeof i?{stroke:i.stroke||"#007bff",strokeWidth:i.strokeWidth||2,strokeDasharray:i.strokeDasharray,fill:i.fill,fillOpacity:i.fillOpacity,opacity:i.opacity}:{stroke:this.resolveGroupColor(t)||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var i;if(this.config.areaStyle){const i=this.config.areaStyle(e||{});if(i&&!i.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{fill:e,stroke:i.stroke||e})}return i}const r=this.config.lineStyle;if("function"==typeof r){const i=r(e||{},t);if(i&&!i.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{fill:e,stroke:i.stroke||e})}return i}if(r&&"object"==typeof r)return{fill:r.fill||r.stroke||"#4e79a7",fillOpacity:null!==(i=r.fillOpacity)&&void 0!==i?i:.7,stroke:r.stroke||"#4e79a7",strokeWidth:r.strokeWidth||2};const o=this.resolveGroupColor(t)||"#4e79a7";return{fill:o,fillOpacity:.7,stroke:o,strokeWidth:2}}resolveGroupColor(t){if(this._colorMapCache){const e=this._colorMapCache.map.get(t);if(e)return e}const e=this._groupColorMap.get(t);if(e)return e;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:k,r=i[this._groupColorMap.size%i.length];return this._groupColorMap.set(t,r),r}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");const e=new Set(Array.isArray(t)?t:[t]),i=this.getPointId,r=t=>e.has(i(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,i)=>{r(t)&&e.add(i)}),this.timestampBuffer.clear();for(let i=0;t.length>i;i++)e.has(i)||this.timestampBuffer.push(t[i])}const o=this.buffer.remove(r);if(0===o.length)return o;for(const t of o)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,o}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const i=new Set(Array.isArray(t)?t:[t]),r=this.getPointId,o=new Set;this.buffer.forEach((t,e)=>{i.has(r(t))&&o.add(e)});const n=this.buffer.update(t=>i.has(r(t)),e);if(0===n.length)return n;for(const t of n)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.buffer.forEach((t,e)=>{o.has(e)&&(this.xExtent.push(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))):(this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,n}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(t){var e,i,r,o;const n=Object.assign({},this.config);void 0!==t.colorScheme&&(this._colorMapCache=null,this._groupColorMap=new Map),void 0===t.barColors&&void 0===t.colorScheme||(this._barCategoryCache=null),void 0===t.normalize&&void 0===t.extentPadding&&void 0===t.xAccessor&&void 0===t.yAccessor&&void 0===t.groupAccessor&&void 0===t.categoryAccessor&&void 0===t.chartType||(this._stackExtentCache=null);let a=!1;Object.assign(this.config,t);const s="chartType"in t&&t.chartType!==n.chartType||"runtimeMode"in t&&t.runtimeMode!==n.runtimeMode;if(s||void 0!==t.xAccessor||void 0!==t.yAccessor||void 0!==t.timeAccessor||void 0!==t.valueAccessor){const c=s||!m(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(i=n.xAccessor)&&void 0!==i?i:n.timeAccessor),l=s||!m(null!==(r=t.yAccessor)&&void 0!==r?r:t.valueAccessor,null!==(o=n.yAccessor)&&void 0!==o?o:n.valueAccessor);(c||l)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=x(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=x(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=x(this.config.xAccessor,"x"),this.getY=x(this.config.yAccessor,"y")),a=!0)}if("groupAccessor"in t&&!m(t.groupAccessor,n.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?b(this.config.groupAccessor):void 0,a=!0),"categoryAccessor"in t&&!m(t.categoryAccessor,n.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?b(this.config.categoryAccessor):void 0,a=!0),"sizeAccessor"in t&&!m(t.sizeAccessor,n.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?x(this.config.sizeAccessor,"size"):void 0,a=!0),"colorAccessor"in t&&!m(t.colorAccessor,n.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?b(this.config.colorAccessor):void 0,a=!0),"y0Accessor"in t&&!m(t.y0Accessor,n.y0Accessor)&&(this.getY0=this.config.y0Accessor?x(this.config.y0Accessor,"y0"):void 0,a=!0),"pointIdAccessor"in t&&!m(t.pointIdAccessor,n.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?b(this.config.pointIdAccessor):void 0,a=!0),"candlestick"===this.config.chartType&&("openAccessor"in t&&!m(t.openAccessor,n.openAccessor)||"closeAccessor"in t&&!m(t.closeAccessor,n.closeAccessor)||"highAccessor"in t&&!m(t.highAccessor,n.highAccessor)||"lowAccessor"in t&&!m(t.lowAccessor,n.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?x(this.config.openAccessor,"open"):void 0,this.getHigh=x(this.config.highAccessor,"high"),this.getLow=x(this.config.lowAccessor,"low"),this.getClose=e?x(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,a=!0}if(!a){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const i of e)if(t[i]!==n[i]){a=!0;break}}a&&(this.needsFullRebuild=!0)}}function R(t,e){var i=t.get(e);if(!i)throw Error("missing: "+e);return i}function F(t,e){var i,r=[],o=[],n=[],a={},s=[];function c(t){n[t]=!1,a.hasOwnProperty(t)&&Object.keys(a[t]).forEach(function(e){delete a[t][e],n[e]&&c(e)})}function l(t){var e,r,h=!1;for(o.push(t),n[t]=!0,e=0;s[t].length>e;e++)(r=s[t][e])===i?(u(i,o),h=!0):n[r]||(h=l(r));if(h)c(t);else for(e=0;s[t].length>e;e++){var f=a[r=s[t][e]];f||(a[r]=f={}),f[r]=!0}return o.pop(),h}function u(t,e){var i=[].concat(e).concat(t);r.push(i)}function h(e){!function(e){for(var i=0;t.length>i;i++)i>=e&&t[i]||(t[i]=[]),t[i]=t[i].filter(function(t){return t>=e})}(e);for(var i,r=function(t){for(var e=t.length,i=Array(e),r=Array(e),o=Array(e),n=Array(e),a=Array(e),s=Array(e),c=0;e>c;++c)i[c]=-1,r[c]=0,o[c]=!1,n[c]=0,a[c]=-1,s[c]=[];var l,u=0,h=[],f=[];function d(e){var c=[e],l=[e];for(i[e]=r[e]=u,o[e]=!0,u+=1;l.length>0;){var d=t[e=l[l.length-1]];if(d.length>n[e]){for(var g=n[e];d.length>g;++g){var y=d[g];if(0>i[y]){i[y]=r[y]=u,o[y]=!0,u+=1,c.push(y),l.push(y);break}o[y]&&(r[e]=0|Math.min(r[e],r[y])),0>a[y]||s[e].push(a[y])}n[e]=g}else{if(r[e]===i[e]){var p=[],m=[],x=0;for(g=c.length-1;g>=0;--g){var v=c[g];if(o[v]=!1,p.push(v),m.push(s[v]),x+=s[v].length,a[v]=h.length,v===e){c.length=g;break}}h.push(p);var b=Array(x);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)b[--x]=m[g][k];f.push(b)}l.pop()}}}for(c=0;e>c;++c)0>i[c]&&d(c);for(c=0;f.length>c;c++){var g=f[c];if(0!==g.length){g.sort(function(t,e){return t-e}),l=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&l.push(g[y]);f[c]=l}}return{components:h,adjacencyList:f}}(t),o=r.components.filter(function(t){return t.length>1}),n=1/0,a=0;o.length>a;a++)for(var s=0;o[a].length>s;s++)n>o[a][s]&&(n=o[a][s],i=a);var c=o[i];if(!c)return!1;var l=t.map(function(t,e){return-1===c.indexOf(e)?[]:t.filter(function(t){return-1!==c.indexOf(t)})});return{leastVertex:n,adjList:l}}i=0;for(var f=t.length;f>i;){var d=h(i);if(i=d.leastVertex,s=d.adjList){for(var g=0;s.length>g;g++)for(var y=0;s[g].length>y;y++){var p=s[g][y];n[+p]=!1,a[p]={}}l(i),i+=1}else i=f}return r}function C(t){return t.y0-t.y1>0?"up":"down"}function I(t,e){return e(t.source)==e(t.target)}function Y(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 X(t){return t.target.x0-t.source.x1}function q(t,e){var i=V(t),r=X(e)/Math.tan(i);return"up"==C(t)?t.y1-r:t.y1+r}function G(t,e){var i=V(t),r=X(e)/Math.tan(i);return"up"==C(t)?t.y1+r:t.y1-r}function V(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function H(t,e){return e(t)}function Z(t){return U(t.source)}function K(t){return U(t.target)}function U(t){return(t.y0+t.y1)/2}function Q(t){return t.virtual?0:t.value}function J(t,e){var i=0;t.sourceLinks.forEach(function(t){i=t.circular&&!I(t,e)?i+1:i});var r=0;return t.targetLinks.forEach(function(t){r=t.circular&&!I(t,e)?r+1:r}),i+r}function tt(t){return t.target.depth}function et(t,e){return t.sourceLinks.length?t.depth:e-1}function it(t,e){return t.y0-e.y0}function rt(t,e){return e.y0-t.y0}function ot(t,e){return t.y1-e.y1}function nt(t,e){return e.y1-t.y1}function at(t,e){return ct(t.source,e.source)||t.index-e.index}function st(t,e){return ct(t.target,e.target)||t.index-e.index}function ct(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function lt(t,e){return ut(t)==ut(e)?"bottom"==t.circularLinkType?rt(t,e):it(t,e):ut(e)-ut(t)}function ut(t){return t.target.column-t.source.column}function ht(t,e){return ft(t)==ft(e)}function ft(t){return t.y0-t.y1>0?"up":"down"}function dt(t,e,i,r,n){let a=t;var s=Math.max(8,.15*(a.y1-a.y0));a.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,s))});var c=o.min(a.links,function(t){return t.source.y0});a.links.forEach(function(t){t.circular&&(t.circularPathData={})});var l=a.links.filter(function(t){return t.circular});return l.sort(function(t,e){return e.value-t.value}),l.forEach(function(t,e){t._circularStub=e>=4}),gt(a.links.filter(function(t){return"top"==t.circularLinkType}),e,i),gt(a.links.filter(function(t){return"bottom"==t.circularLinkType}),e,i),a.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+r,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,I(t,e)&&Y(t))t.circularPathData.rightSmallArcRadius=r+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=r+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=r+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=r+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+n+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-n-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var o=t.source.column,s=t.circularLinkType,l=a.links.filter(function(t){return t.source.column==o&&t.circularLinkType==s});l.sort("bottom"==t.circularLinkType?rt:it);var u=0;l.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=r+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=r+t._circularWidth/2+o*i+u),u+=e._circularWidth||e.width}),o=t.target.column,(l=a.links.filter(function(t){return t.target.column==o&&t.circularLinkType==s})).sort("bottom"==t.circularLinkType?nt:ot),u=0,l.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=r+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=r+t._circularWidth/2+o*i+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(a.y1,t.source.y1,t.target.y1)+n+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=c-n-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,i=t.y0,r=t.target.x0,o=t.y1,n=(e+r)/2;return"M"+e+","+i+"C"+n+","+i+" "+n+","+o+" "+r+","+o}(t)}),a}function gt(t,e,i){t.sort(lt);var r=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,o){var n=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(I(t,e)&&Y(t))t.circularPathData.verticalBuffer=n+t._circularWidth/2;else{for(var a=0;r.length>a;a++){var s=r[a];if(s!==t&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&yt(t,s)){var c=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+i;n=c>n?c:n}}t.circularPathData.verticalBuffer=n+t._circularWidth/2}}),t}function yt(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function pt(t){return function(){return t}}function mt(t){return t.index}function xt(t){return t.nodes}function vt(t){return t.links}function bt(t,e,i){var r=o.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});r.forEach(function(o,n){var a=o.length;if(e)o.sort(e);else if(n>0){var s=new Map;o.forEach(function(t,e){var i,r,o,n=(r=0,o=0,(i=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=U(t.source)*e,r+=e}}),i.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=U(t.target)*e,r+=e}}),r>0?o/r:NaN);s.set(t,{bc:n,idx:e})}),o.sort(function(t,e){var i=s.get(t),r=s.get(e),o=i.bc,n=r.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(o)||isNaN(n)?isNaN(o)?isNaN(n)?i.idx-r.idx:1:-1:o-n})}else o.sort(function(t,e){return t.circularLinkType==e.circularLinkType?J(e,i)-J(t,i):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});o.forEach(function(e,o){e.depth==r.length-1&&1==a||0==e.depth&&1==a?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==J(e,i)?(e.y0=t.y1/2+o,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+o,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-o,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/a*o,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-a/2+o,e.y1=e.y0+e.value*t.ky)})})}function kt(t,e,i,r,n,a){var s=o.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});h();for(var c=1,l=a;l>0;--l)u(c*=.99,i),h();function u(e,i){var r=s.length;s.forEach(function(n){var a=n.length,s=n[0].depth;n.forEach(function(n){var c;if(n.sourceLinks.length||n.targetLinks.length)if(n.partOfCycle&&J(n,i)>0){var l=o.mean(n.sourceLinks,K),u=o.mean(n.targetLinks,Z),h=l&&u?(l+u)/2:l||u;if(h){var f=(h-U(n))*e*.3;n.y0+=f,n.y1+=f}}else if(0==s&&1==a)n.y0=t.y1/2-(c=n.y1-n.y0)/2,n.y1=t.y1/2+c/2;else if(s==r-1&&1==a)n.y0=t.y1/2-(c=n.y1-n.y0)/2,n.y1=t.y1/2+c/2;else if(1==n.targetLinks.length&&1==n.targetLinks[0].source.sourceLinks.length)c=n.y1-n.y0,n.y0=n.targetLinks[0].source.y0,n.y1=n.y0+c;else{var d=o.mean(n.sourceLinks,K),g=o.mean(n.targetLinks,Z),y=((d&&g?(d+g)/2:d||g)-U(n))*e;n.y0+=y,n.y1+=y}})})}function h(){s.forEach(function(i){var o,a,s,c=t.y0,l=i.length;for(i.sort(e||ct),s=0;l>s;++s)(a=c-(o=i[s]).y0)>0&&(o.y0+=a,o.y1+=a),c=o.y1+r;if((a=c-r-t.y1)>0)for(c=o.y0-=a,o.y1-=a,s=l-2;s>=0;--s)(a=(o=i[s]).y1+n-c)>0&&(o.y0-=a,o.y1-=a),c=o.y0})}}function wt(t){t.nodes.forEach(function(t){t.sourceLinks.sort(st),t.targetLinks.sort(at)}),t.nodes.forEach(function(t){var e=t.y0,i=e,r=t.y1,o=r;t.sourceLinks.forEach(function(t){t.circular?(t.y0=r-t.width/2,r-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=o-t.width/2,o-=t.width):(t.y1=i+t.width/2,i+=t.width)})})}function At(){var t=0,e=0,i=1,r=1,n=24,a=8,s=null,c=mt,l=et,u=void 0,h=32,f=2,d=xt,g=vt;function y(){var y={nodes:d.apply(null,arguments),links:g.apply(null,arguments)};return function(d){d.x0=t,d.y0=e,d.x1=i,d.y1=r,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 o.group(t,e).forEach(function(t,e){i.set(e,t[0])}),i}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var r=t.source,o=t.target;"object"!=typeof r&&(r=t.source=R(i,r)),"object"!=typeof o&&(o=t.target=R(i,o)),r.sourceLinks.push(t),o.targetLinks.push(t)})}(d,c),function(t,e){var i=0;if(null==e){for(var r=[],o=0;t.links.length>o;o++){var n=t.links[o],a=n.source.index,s=n.target.index;r[a]||(r[a]=[]),r[s]||(r[s]=[]),-1===r[a].indexOf(s)&&r[a].push(s)}var c=F(r);c.sort(function(t,e){return t.length-e.length});var l={};for(o=0;c.length>o;o++){var u=c[o].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,r=t.source.index;e===r||l[r]&&l[r][e]?(t.circular=!0,t.circularLinkID=i++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=i++)})}(d,u),function(t,e){var i=0,r=0;t.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:r>i?"top":"bottom","top"==o.circularLinkType?i++:r++,t.nodes.forEach(function(t){H(t,e)!=H(o.source,e)&&H(t,e)!=H(o.target,e)||(t.circularLinkType=o.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),I(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(d,c),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(o.sum(t.sourceLinks,Q),o.sum(t.targetLinks,Q)),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 r,o,n;if(null!=e){t.nodes.sort(function(t,i){return e(t)<e(i)?-1:1});var a=0,s=e(t.nodes[0]);t.nodes.forEach(function(t){a=e(t)==s?a:a+1,s=e(t)==s?s:e(t),t.column=a})}for(r=t.nodes,o=[],n=0;r.length;++n,r=o,o=[])r.forEach(function(t){t.depth=n,t.sourceLinks.forEach(function(t){0>o.indexOf(t.target)&&!t.circular&&o.push(t.target)})});for(r=t.nodes,o=[],n=0;r.length;++n,r=o,o=[])r.forEach(function(t){t.height=n,t.targetLinks.forEach(function(t){0>o.indexOf(t.source)&&!t.circular&&o.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?i(t,n):t.column})}(d,u,l);var g=a;if(null!==s){var y=o.groups(d.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=o.max(y,function(t){return t.length});p>1&&(g=Math.max(1,(r-e)*s/(p-1)))}(function(t,e,i){var r=o.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var n=o.min(r,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/o.sum(e,function(t){return t.value})});t.ky=n,t.links.forEach(function(e){e.width=e.value*t.ky});var a=o.max(t.nodes,function(t){return t.column});t.nodes.forEach(a>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-i)/a),e.x1=e.x0+i}:function(e){e.x0=t.x0,e.x1=e.x0+i})})(d,g,n),bt(d,u,c),kt(d,u,c,g,g,h),wt(d),dt(d,c,f,10,8),bt(d,u,c),kt(d,u,c,g,g,h),wt(d),dt(d,c,f,10,8),function(t,e){let i=t;i.nodes.forEach(function(t){t.y+(t.y1-t.y0)>i.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-i.y1));var r=i.links.filter(function(i){return H(i.source,e)==H(t,e)}),o=r.length;o>1&&r.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!ht(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var i=q(e,t);return t.y1-i}if(e.target.column>t.target.column)return q(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var n=t.y0;r.forEach(function(t){t.y0=n+t.width/2,n+=t.width}),r.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var n=i+1,a=0;o>n;n++)a+=r[n].width;e.y0=t.y1-a-e.width/2}})})}(d,c),function(t,e){let i=t;i.nodes.forEach(function(t){var r=i.links.filter(function(i){return H(i.target,e)==H(t,e)}),o=r.length;o>1&&r.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!ht(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var i=G(e,t);return t.y0-i}if(e.source.column>t.source.column)return G(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var n=t.y0;r.forEach(function(t){t.y1=n+t.width/2,n+=t.width}),r.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var n=i+1,a=0;o>n;n++)a+=r[n].width;e.y1=t.y1-a-e.width/2}})})}(d,c),function(t){var e=t.nodes,i=t.links,r=!1,n=!1;if(i.forEach(function(t){"top"==t.circularLinkType?r=!0:"bottom"==t.circularLinkType&&(n=!0)}),0==r||0==n){var a=o.min(e,function(t){return t.y0}),s=o.max(e,function(t){return t.y1}),c=(t.y1-t.y0)/(s-a);function l(e){return(e-a)/(s-a)*(t.y1-t.y0)+t.y0}1>c?(e.forEach(function(t){t.y0=l(t.y0),t.y1=l(t.y1)}),i.forEach(function(t){t.y0=l(t.y0),t.y1=l(t.y1),t.width=t.width*c})):e.forEach(function(t){var e=t.y1-t.y0,i=l(t.y0)-t.y0;t.y0=l(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),dt(d,c,f,10,8)}(y),y}return y.update=function(t){return wt(t),dt(t,c,f,10,8),t},y.nodeWidth=function(t){return arguments.length?(n=+t,y):n},y.nodePadding=function(t){return arguments.length?(a=+t,y):a},y.nodePaddingRatio=function(t){return arguments.length?(s=+t,y):s},y.nodes=function(t){return arguments.length?(d="function"==typeof t?t:pt(t),y):d},y.links=function(t){return arguments.length?(g="function"==typeof t?t:pt(t),y):g},y.nodeId=function(t){return arguments.length?(c="function"==typeof t?t:pt(t),y):c},y.nodeAlign=function(t){return arguments.length?(l="function"==typeof t?t:pt(t),y):l},y.nodeSort=function(t){return arguments.length?(u=t,y):u},y.iterations=function(t){return arguments.length?(h=+t,y):h},y.circularLinkGap=function(t){return arguments.length?(f=+t,y):f},y.extent=function(o){return arguments.length?(t=+o[0][0],e=+o[0][1],i=+o[1][0],r=+o[1][1],y):[[t,e],[i,r]]},y.size=function(o){return arguments.length?(t=e=0,i=+o[0],r=+o[1],y):[i-t,r-e]},y}W.QUADTREE_THRESHOLD=500;const St=t=>{let e,i,r,o,a,s,c,l,u;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,i=t.y1-t.sankeyWidth/2,r=t.y1+t.sankeyWidth/2,o=t.y0+t.sankeyWidth/2,a=t.source.x1,s=t.target.x0,c=n.interpolateNumber(a,s),l=c(.5),u=c(.5),`M${e},${a}C${e},${l} ${i},${u} ${i},${s}L${r},${s}C${r},${u} ${o},${l} ${o},${a}Z`):(e=t.source.x1,i=t.target.x0,c=n.interpolateNumber(e,i),r=c(.5),o=c(.5),a=t.y0-t.sankeyWidth/2,s=t.y1-t.sankeyWidth/2,l=t.y1+t.sankeyWidth/2,u=t.y0+t.sankeyWidth/2,`M${e},${a}C${r},${a} ${o},${s} ${i},${s}L${i},${l}C${o},${l} ${r},${u} ${e},${u}Z`)};function _t(t){var e;const i=t.sankeyWidth/2,r=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,o=t.circularPathData;if(!o)return null;if("down"===t.direction)return null;if(t._circularStub){const e=o.sourceX,r=o.sourceY,n=o.targetX,a=o.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const s=Math.max(15,Math.min(40,.33*(o.rightFullExtent-e))),c=Math.max(15,Math.min(40,.33*(n-o.leftFullExtent)));return`M${e},${r-i}L${e+s},${r-i}L${e+s},${r+i}L${e},${r+i}ZM${n},${a-i}L${n-c},${a-i}L${n-c},${a+i}L${n},${a+i}Z`}const n=o.sourceX,a=o.sourceY,s=o.targetX,c=o.targetY,l=o.rightFullExtent,u=o.leftFullExtent,h=o.verticalFullExtent,f="bottom"===t.circularLinkType?1:-1,d=Math.max(4,Math.min(r,15));return`M${n},${a-f*i}L${l},${a-f*i}L${l+r},${a-f*i+f*d}L${l+r},${h+f*r-f*d}L${l+r-d},${h+f*r}L${u-r+d},${h+f*r}L${u-r},${h+f*r-f*d}L${u-r},${c-f*i+f*d}L${u-r+d},${c-f*i}L${s},${c-f*i}L${s},${c+f*i}L${u+r},${c+f*i}L${u+r},${h-f*r}L${l-r},${h-f*r}L${l-r},${a+f*i}L${n},${a+f*i}Z`}const Et=new Set,Pt=new WeakMap;function Mt(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let i=Pt.get(t);if(i){const t=i.get(e);if(t)return t}else i=new Map,Pt.set(t,i);const r=new Proxy(t,{get(t,i,r){if("string"==typeof i&&!(i in t)&&t.data&&i in t.data){const t=`${e}:${i}`;Et.has(t)||(Et.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${i}" on the wrapper object, but it only exists on ".data". Use d.data.${i} (or d.data?.${i}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,i,r)}});return i.set(e,r),r}const Ot={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(tt))-1:0},justify:et},Lt={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,r){var o,n,a,s,c,l,u;if(0===t.length)return;const h="vertical"===i.orientation?"down":"right",f=i.nodeAlign||"justify",d=null!==(o=i.nodeWidth)&&void 0!==o?o:15,g=null!==(n=i.nodePaddingRatio)&&void 0!==n?n:.05,y=null!==(a=i.iterations)&&void 0!==a?a:100,p=t.map(t=>Object.assign({},t)),m=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let x;x="down"===h?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const v=At().extent(x).links(m).nodes(p).nodeAlign(Ot[f]||et).nodeId(t=>t.id).nodeWidth(d).iterations(y);v.nodePaddingRatio&&v.nodePaddingRatio(g),v();{let t=1/0,e=-1/0,i=1/0,o=-1/0;for(const r of p)t>r.x0&&(t=r.x0),r.x1>e&&(e=r.x1),i>r.y0&&(i=r.y0),r.y1>o&&(o=r.y1);for(const r of m){if(!r.circular||!r.circularPathData)continue;const n=r.circularPathData,a=(null!==(c=null!==(s=r._circularWidth)&&void 0!==s?s:r.width)&&void 0!==c?c:0)/2;t>n.leftFullExtent-a&&(t=n.leftFullExtent-a),n.rightFullExtent+a>e&&(e=n.rightFullExtent+a),i>n.verticalFullExtent-a&&(i=n.verticalFullExtent-a),n.verticalFullExtent+a>o&&(o=n.verticalFullExtent+a)}const n=e-t,a=o-i,u=r[0],h=r[1];if(n>0&&a>0&&(0>t||0>i||e>u||o>h)){const e=Math.min(u/n,h/a),r=-t*e+(u-n*e)/2,o=-i*e+(h-a*e)/2;for(const t of p)t.x0=t.x0*e+r,t.x1=t.x1*e+r,t.y0=t.y0*e+o,t.y1=t.y1*e+o;for(const t of m)if(t.y0=t.y0*e+o,t.y1=t.y1*e+o,t.width=(null!==(l=t.width)&&void 0!==l?l:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const i=t.circularPathData;i.sourceX=i.sourceX*e+r,i.targetX=i.targetX*e+r,i.sourceY=i.sourceY*e+o,i.targetY=i.targetY*e+o,i.rightFullExtent=i.rightFullExtent*e+r,i.leftFullExtent=i.leftFullExtent*e+r,i.verticalFullExtent=i.verticalFullExtent*e+o,i.rightInnerExtent=i.rightInnerExtent*e+r,i.leftInnerExtent=i.leftInnerExtent*e+r,i.verticalRightInnerExtent=i.verticalRightInnerExtent*e+o,i.verticalLeftInnerExtent=i.verticalLeftInnerExtent*e+o,i.rightSmallArcRadius*=e,i.rightLargeArcRadius*=e,i.leftSmallArcRadius*=e,i.leftLargeArcRadius*=e,i.sourceWidth*=e,i.rightNodeBuffer*=e,i.leftNodeBuffer*=e,i.arcRadius*=e}}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of p){const e=b.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const k=new Map;for(const t of e)k.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of m){const e=t.source,i=t.target,r="object"==typeof e&&null!==e?e.id:e+"",o="object"==typeof i&&null!==i?i.id:i+"",n=k.get(t._edgeKey?t._edgeKey:`${r}\0${o}`);if(n){n.y0=t.y0,n.y1=t.y1,n.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,n.circular=!!t.circular,n.circularPathData=t.circularPathData,n._circularWidth=t._circularWidth,n._circularStub=t._circularStub,n.path=t.path,n.circularLinkType=t.circularLinkType,n.direction=h;const e=b.get(r),i=b.get(o);e&&(n.source=e),i&&(n.target=i)}}},buildScene(t,e,i,o){var n,a,s,c;const l="vertical"===i.orientation?"down":"right",u=i.nodeStyle,h=i.edgeStyle,f=null!==(n=i.edgeOpacity)&&void 0!==n?n:.5,d=i.edgeColorBy||"source",g=Array.isArray(i.colorScheme)?i.colorScheme:r.schemeCategory10,y=new Map;t.forEach((t,e)=>{y.set(t.id,g[e%g.length])});const p=[],m=[],x=[],v=new Map;for(const e of t){const t=e.x1-e.x0,i=e.y1-e.y0;if(0>=t||0>=i)continue;const r=u?u(Mt(e,"nodeStyle")):{},o={fill:r.fill||y.get(e.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};v.set(e.id,("string"==typeof o.fill?o.fill:null)||y.get(e.id)||"#4d430c"),p.push("down"===l?{type:"rect",x:e.y0,y:e.x0,w:i,h:t,style:o,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:i,style:o,datum:e,id:e.id,label:e.id})}const b=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of b){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let r="#999";r="function"==typeof d?d(t)||r:"target"===d?v.get(i.id)||y.get(i.id)||r:v.get(e.id)||y.get(e.id)||r;const o=h?h(Mt(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,i=t.sankeyWidth/2,n=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),c=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),l=o.fill||r;m.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-i}L${e.sourceX+n},${e.sourceY-i}L${e.sourceX+n},${e.sourceY+i}L${e.sourceX},${e.sourceY+i}Z`,style:{fill:l,fillOpacity:null!==(a=o.fillOpacity)&&void 0!==a?a:f,stroke:"none",opacity:o.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+n}}),m.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-i}L${e.targetX-c},${e.targetY-i}L${e.targetX-c},${e.targetY+i}L${e.targetX},${e.targetY+i}Z`,style:{fill:l,fillOpacity:null!==(s=o.fillOpacity)&&void 0!==s?s:f,stroke:"none",opacity:o.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-c,x1:e.targetX}});continue}let n;if(n=t.circular&&t.circularPathData?_t(t):St(t),!n)continue;const l={fill:o.fill||r,fillOpacity:null!==(c=o.fillOpacity)&&void 0!==c?c:f,stroke:o.stroke||"none",strokeWidth:o.strokeWidth,opacity:o.opacity};m.push({type:"bezier",pathD:n,bezierCache:t.bezier,style:l,datum:t})}if(!1!==i.showLabels){const e=(k=i.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null;for(const i of t){const t=i.x1-i.x0,r=i.y1-i.y0;if(0>=t||0>=r)continue;const n=e?e(i):i.id;if(!n)continue;let a,s,c;"down"===l?(a=i.y0+(i.y1-i.y0)/2,s=i.x1+14,c="middle"):(o[0]/2>i.x0+t/2?(a=i.x0-6,c="end"):(a=i.x1+6,c="start"),s=i.y0+r/2),x.push({x:a,y:s,text:n+"",anchor:c,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:p,sceneEdges:m,labels:x}}},Dt={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,r){var o,n;if(0===t.length)return;const s=null!==(o=i.forceStrength)&&void 0!==o?o:.1,c=r[0]/2,l=r[1]/2,u=i.__previousPositions;let h=0;const f=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),i=null==u?void 0:u.get(e.id);t?h++:i?(e.x=i.x,e.y=i.y,h++):f.push(e)}const d=h>0&&.3>=(t.length>0?f.length/t.length:1);if(d){const i=new Map;for(const e of t)i.set(e.id,e);for(const t of f){const r=zt(t.id,e,i);if(r.length>0){let e=0,i=0;for(const t of r)e+=t.x,i+=t.y;const o=jt(t.id),n=o%360*(Math.PI/180),a=10+o%20;t.x=e/r.length+a*Math.cos(n),t.y=i/r.length+a*Math.sin(n)}else{const e=jt(t.id),i=e%360*(Math.PI/180),r=15+e%30;t.x=c+r*Math.cos(i),t.y=l+r*Math.sin(i)}}}else{const e=2.399963229728653;for(let i=0;t.length>i;i++){const r=t[i];if(null==r.x||null==r.y||0===r.x&&0===r.y){const t=10*Math.sqrt(i+.5),o=i*e;r.x=c+t*Math.cos(o),r.y=l+t*Math.sin(o)}}}const g=null!==(n=i.iterations)&&void 0!==n?n:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),y=0===i.iterations?0:d?40:g,p=Tt(i.nodeSize,i.nodeSizeRange,t),m=t=>p(t);if(y>0){const i=a.forceLink().strength(t=>Math.min(2.5,t.weight?t.weight*s:s)).id(t=>t.id),r=a.forceSimulation().force("charge",a.forceManyBody().strength(t=>-25*m(t))).force("center",a.forceCenter(c,l).strength(.8)).force("x",a.forceX(c).strength(.15)).force("y",a.forceY(l).strength(.15));if(r.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));r.force("link",i),r.force("link").links(t)}d?r.alpha(.3):.1>r.alpha()&&r.alpha(1),r.stop();for(let t=0;y>t;++t)r.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=m(e);e.x=Math.max(t,Math.min(r[0]-t,e.x)),e.y=Math.max(t,Math.min(r[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const x=new Map;for(const e of t)x.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=x.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=x.get(t.target);e&&(t.target=e)}}},buildScene(t,e,i,o){var n,a,s;const c=i.nodeStyle,l=i.edgeStyle,u=Tt(i.nodeSize,i.nodeSizeRange,t),h=Array.isArray(i.colorScheme)?i.colorScheme:r.schemeCategory10,f=new Map;t.forEach((t,e)=>{f.set(t.id,h[e%h.length])});const d=[],g=[],y=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=u(Mt(e,"nodeSize")),i=c?c(Mt(e,"nodeStyle")):{},r={fill:i.fill||f.get(e.id)||"#007bff",stroke:i.stroke||"#fff",strokeWidth:null!==(n=i.strokeWidth)&&void 0!==n?n:2,opacity:i.opacity};d.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id})}const p=new Map;for(const e of t)p.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:p.get(t.source),i="object"==typeof t.target?t.target:p.get(t.target);if(!e||!i)continue;if(null==e.x||null==e.y)continue;if(null==i.x||null==i.y)continue;const r=l?l(Mt(t,"edgeStyle")):{},o={stroke:r.stroke||"#999",strokeWidth:null!==(a=r.strokeWidth)&&void 0!==a?a:1,opacity:null!==(s=r.opacity)&&void 0!==s?s:.6};g.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:o,datum:t})}if(!1!==i.showLabels){const e=(m=i.nodeLabel)?"function"==typeof m?m:t=>t[m]||t.id:null;for(const i of t){if(null==i.x||null==i.y)continue;const t=e?e(i):i.id;if(!t)continue;const r=u(Mt(i,"nodeSize"));y.push({x:i.x,y:i.y-r-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var m;return{sceneNodes:d,sceneEdges:g,labels:y}}};function zt(t,e,i){const r=[];for(const o of e){const e="string"==typeof o.source?o.source:o.source.id,n="string"==typeof o.target?o.target:o.target.id;let a=null;if(e===t?a=n:n===t&&(a=e),a){const t=i.get(a);!t||0===t.x&&0===t.y||r.push({x:t.x,y:t.y})}}return r}function jt(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 Tt(t,i,r){var n,a;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const s=i||[5,20],c=r.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===c.length)return()=>s[0];const l=null!==(n=o.min(c))&&void 0!==n?n:0,u=null!==(a=o.max(c))&&void 0!==a?a:1;if(l===u)return()=>(s[0]+s[1])/2;const h=e.scaleLinear().domain([l,u]).range(s).clamp(!0);return e=>{var i;const r=null===(i=e.data)||void 0===i?void 0:i[t];return null==r||"number"!=typeof r?s[0]:h(r)}}const Nt=r.schemeCategory10,$t={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,i,r){if(0===t.length)return;const{padAngle:o=.01,groupWidth:n=20,sortGroups:a}=i,l=Math.min(r[0],r[1])/2,u=l-n,h=r[0]/2,f=r[1]/2,d=(g=i.valueAccessor)?"function"==typeof g?g:t=>{var e;return null!==(e=t[g])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var g;const y=new Map;for(let e=0;t.length>e;e++)y.set(t[e].id,e);const p=t.length,m=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,i=y.get("string"==typeof t.source?t.source:t.source.id),r=y.get(e);if(void 0===i||void 0===r)continue;const o=d(t);m[i][r]=o}const x=s.chord().padAngle(o);a&&x.sortGroups(a);const v=x(m),b=v.groups,k=c.arc().innerRadius(u).outerRadius(l);for(const e of b){const i=t[e.index],r=k.centroid(e);i.x=r[0]+h,i.y=r[1]+f,i.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const w=new Map;for(const e of t)w.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,i=w.get("string"==typeof t.source?t.source:t.source.id),r=w.get(e);i&&(t.source=i),r&&(t.target=r)}const A=new Map;for(const t of e)A.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 v){const i=t[e.source.index].id,r=t[e.target.index].id,o=A.get(`${i}\0${r}`)||A.get(`${r}\0${i}`);o&&(o.chordData=e)}},buildScene(t,e,i,r){var o,n;const{groupWidth:a=20,edgeOpacity:c=.5}=i,l=Math.min(r[0],r[1])/2,u=l-a,h=r[0]/2,f=r[1]/2,d=i.nodeStyle,g=i.edgeStyle,y=i.edgeColorBy||"source",p=Array.isArray(i.colorScheme)?i.colorScheme:Nt,m=new Map;t.forEach((t,e)=>{m.set(t.id,p[e%p.length])});const x=s.ribbon().radius(u),v=[],b=[],k=[];for(let e=0;t.length>e;e++){const i=t[e],r=i.arcData;if(!r)continue;let n;n=d?d(Mt(i,"nodeStyle")).fill||m.get(i.id)||p[e%p.length]:m.get(i.id)||p[e%p.length];const a=d?d(Mt(i,"nodeStyle")):{},s={fill:n,stroke:a.stroke||"black",strokeWidth:null!==(o=a.strokeWidth)&&void 0!==o?o:1,opacity:a.opacity};v.push({type:"arc",cx:h,cy:f,innerR:u,outerR:l,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:s,datum:i,id:i.id,label:i.id})}for(const t of e){const e=t.chordData;if(!e)continue;const i=x(e);if(!i)continue;const r=Bt(i,h,f);let o="#999";if(g)o=g(Mt(t,"edgeStyle")).fill||o;else{const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;"target"===y&&i?o=m.get(i.id)||o:e&&(o=m.get(e.id)||o)}const a=g?g(Mt(t,"edgeStyle")):{},s={fill:o,fillOpacity:null!==(n=a.fillOpacity)&&void 0!==n?n:c,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};b.push({type:"ribbon",pathD:r,style:s,datum:t})}if(!1!==i.showLabels){const e=(w=i.nodeLabel)?"function"==typeof w?w:t=>t[w]||t.id:null,r=l+12;for(const i of t){const t=i.arcData;if(!t)continue;const o=e?e(i):i.id;if(!o)continue;const n=(t.startAngle+t.endAngle)/2,a=n-Math.PI/2;k.push({x:h+Math.cos(a)*r,y:f+Math.sin(a)*r,text:o+"",anchor:n>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:v,sceneEdges:b,labels:k}}};function Bt(t,e,i){const r=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return t;const o=[];let n=0;for(;r.length>n;){const t=r[n];if("M"===t||"L"===t)for(o.push(t),n++;r.length>n&&!isNaN(Number(r[n]));)o.push(Number(r[n])+e+""),n++,r.length>n&&!isNaN(Number(r[n]))&&(o.push(Number(r[n])+i+""),n++);else if("C"===t)for(o.push(t),n++;r.length>n&&!isNaN(Number(r[n]));)for(let t=0;3>t&&r.length>n&&!isNaN(Number(r[n]));t++)o.push(Number(r[n])+e+""),n++,r.length>n&&!isNaN(Number(r[n]))&&(o.push(Number(r[n])+i+""),n++);else if("Q"===t)for(o.push(t),n++;r.length>n&&!isNaN(Number(r[n]));)for(let t=0;2>t&&r.length>n&&!isNaN(Number(r[n]));t++)o.push(Number(r[n])+e+""),n++,r.length>n&&!isNaN(Number(r[n]))&&(o.push(Number(r[n])+i+""),n++);else if("A"===t)for(o.push(t),n++;r.length>n&&!isNaN(Number(r[n]));)o.push(r[n++]),r.length>n&&o.push(r[n++]),r.length>n&&o.push(r[n++]),r.length>n&&o.push(r[n++]),r.length>n&&o.push(r[n++]),r.length>n&&(o.push(Number(r[n])+e+""),n++),r.length>n&&(o.push(Number(r[n])+i+""),n++);else"Z"===t||"z"===t?(o.push(t),n++):(o.push(r[n]),n++)}return o.join(" ")}const Wt=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Rt(t){const[e,i,r]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*i+.114*r>150?"#222":"#fff"}function Ft(t,e,i){const r=e.nodeIDAccessor;return"function"==typeof r?r(t.data)+"":"string"==typeof r&&void 0!==t.data[r]?t.data[r]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+i}function Ct(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 It(t,e,i,r,o){if("horizontal"===o){const o=(t+i)/2;return`M ${t},${e} C ${o},${e} ${o},${r} ${i},${r}`}if("radial"===o){const o=(t+i)/2;return`M ${t},${e} Q ${o},${e} ${o},${(e+r)/2} T ${i},${r}`}{const o=(e+r)/2;return`M ${t},${e} C ${t},${o} ${i},${o} ${i},${r}`}}const Yt={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,i,r){var o;const n=i.__hierarchyRoot;if(!n)return;const a=i.chartType,s=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(i.childrenAccessor),c=i.hierarchySum||(t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0}),u=l.hierarchy(n,s);u.sum(c),u.sort((t,e)=>{var i,r;return(null!==(i=e.value)&&void 0!==i?i:0)-(null!==(r=t.value)&&void 0!==r?r:0)});const[h,f]=r;switch(a){case"tree":!function(t,e,i,r){const o=e.treeOrientation||"vertical",n=l.tree();n.size("horizontal"===o?[r,i]:"radial"===o?[2*Math.PI,Math.min(i,r)/2*.8]:[i,r]),n(t)}(u,i,h,f);break;case"cluster":!function(t,e,i,r){const o=e.treeOrientation||"vertical",n=l.cluster();n.size("horizontal"===o?[r,i]:"radial"===o?[2*Math.PI,Math.min(i,r)/2*.8]:[i,r]),n(t)}(u,i,h,f);break;case"treemap":!function(t,e,i,r){var o,n;const a=null!==(o=e.padding)&&void 0!==o?o:4,s=null!==(n=e.paddingTop)&&void 0!==n?n:0,c=l.treemap().size([i,r]).tile(l.treemapBinary).padding(a);s>0&&c.paddingTop(s),c(t)}(u,i,h,f);break;case"circlepack":!function(t,e,i,r){var o;const n=null!==(o=e.padding)&&void 0!==o?o:4;l.pack().size([i,r]).padding(n)(t)}(u,i,h,f);break;case"partition":!function(t,e,i,r){var o;l.partition().size([i,r]).padding(null!==(o=e.padding)&&void 0!==o?o:1)(t)}(u,i,h,f)}const d=u.descendants();t.length=0,e.length=0;const g=new Map;for(let e=0;d.length>e;e++){const r=d[e],n={id:Ft(r,i,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=r.value)&&void 0!==o?o:0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===a||"cluster"===a?Xt(n,r,i):"treemap"===a||"partition"===a?qt(n,r):"circlepack"===a&&Gt(n,r),n.__hierarchyNode=r,t.push(n),g.set(r,n)}if("tree"===a||"cluster"===a)for(const t of d)if(t.parent){const i=g.get(t.parent),r=g.get(t);i&&r&&e.push({source:i,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,i,r){const o=i.nodeStyle||(()=>({})),n=i.edgeStyle||(()=>({}));switch(i.chartType){case"tree":case"cluster":return function(t,e,i,r,o,n){var a,s,c,l,u;const h=[],f=[],d=[],g=i.treeOrientation||"vertical",y="radial"===g,p=r[0]/2,m=r[1]/2,x="number"==typeof(v=i.nodeSize)?v:5;var v;for(const e of t){let t=e.x,r=e.y;y&&(t+=p,r+=m);const n=o(Mt(e,"nodeStyle"));let s=n.fill||"#4d430c";i.colorByDepth&&void 0!==e.depth&&(s=Wt[e.depth%Wt.length]);const c={fill:s,stroke:n.stroke||"#fff",strokeWidth:null!==(a=n.strokeWidth)&&void 0!==a?a:1,opacity:n.opacity};h.push({type:"circle",cx:t,cy:r,r:x,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const b=null!==(s=i.edgeOpacity)&&void 0!==s?s:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let r=e.x,o=e.y,a=i.x,s=i.y;y&&(r+=p,o+=m,a+=p,s+=m);const u=It(r,o,a,s,g),h=n(Mt(t,"edgeStyle")),d={fill:"none",stroke:h.stroke||"#999",strokeWidth:null!==(c=h.strokeWidth)&&void 0!==c?c:1.5,opacity:null!==(l=h.opacity)&&void 0!==l?l:b};f.push({type:"curved",pathD:u,style:d,datum:t})}if(!1!==i.showLabels){const e=Ct(i.nodeLabel);for(const i of t){const t=e?e(i):i.id;if(!t)continue;let r,o,n,a=i.x,s=i.y;if(y&&(a+=p,s+=m),y){const t=a-p,e=s-m,i=Math.sqrt(t*t+e*e);i>0?(r=a+t/i*10,o=s+e/i*10,n=0>t?"end":"start"):(r=a,o=s-12,n="middle")}else"horizontal"===g?((null===(u=i.data)||void 0===u?void 0:u.children)&&0!==i.data.children.length?(r=a-x-6,n="end"):(r=a+x+6,n="start"),o=s):(r=a,o=s+x+14,n="middle");d.push({x:r,y:o,text:t+"",anchor:n,baseline:"middle",fontSize:11})}}return{sceneNodes:h,sceneEdges:f,labels:d}}(t,e,i,r,o,n);case"treemap":case"partition":return function(t,e,i,r){var o,n;const a=[],s=[];for(const i of t){const t=i.x1-i.x0,n=i.y1-i.y0;if(0>=t||0>=n)continue;const s=r(Mt(i,"nodeStyle"));let c=s.fill||"#4d430c";e.colorByDepth&&void 0!==i.depth&&(c=Wt[i.depth%Wt.length]);const l={fill:c,stroke:s.stroke||"#fff",strokeWidth:null!==(o=s.strokeWidth)&&void 0!==o?o:1,opacity:s.opacity};a.push({type:"rect",x:i.x0,y:i.y0,w:t,h:n,style:l,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Ct(e.nodeLabel),o=e.labelMode||"leaf",a="partition"===e.chartType;for(const c of t){const t=c.x1-c.x0,l=c.y1-c.y0;if(0>=t||0>=l)continue;const u=!((null===(n=c.data)||void 0===n?void 0:n.children)&&c.data.children.length>0);if(!a){if("leaf"===o&&!u)continue;if("parent"===o&&u)continue}const h=i?i(c):c.id;if(!h)continue;if((u?30:40)>t||(u?16:14)>l)continue;let f=r(Mt(c,"nodeStyle")).fill||"#4d430c";e.colorByDepth&&void 0!==c.depth&&(f=Wt[c.depth%Wt.length]);const d=Rt(f);s.push(u?{x:c.x0+t/2,y:c.y0+l/2,text:h+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,l)/6)),fill:d}:{x:c.x0+4,y:c.y0+12,text:h+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:d})}}return{sceneNodes:a,sceneEdges:[],labels:s}}(t,i,0,o);case"circlepack":return function(t,e,i,r){var o,n,a,s,c;const l=[],u=[];for(const i of t){const t=null!==(o=i.__radius)&&void 0!==o?o:5;if(0>=t)continue;const s=r(Mt(i,"nodeStyle"));let c=s.fill||"#4d430c";e.colorByDepth&&void 0!==i.depth&&(c=Wt[i.depth%Wt.length]);const u={fill:c,stroke:s.stroke||"#fff",strokeWidth:null!==(n=s.strokeWidth)&&void 0!==n?n:1,opacity:null!==(a=s.opacity)&&void 0!==a?a:.7};l.push({type:"circle",cx:i.x,cy:i.y,r:t,style:u,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Ct(e.nodeLabel);for(const o of t){const t=null!==(s=o.__radius)&&void 0!==s?s:5,n=i?i(o):o.id;if(!n)continue;if(15>t)continue;const a=!((null===(c=o.data)||void 0===c?void 0:c.children)&&o.data.children.length>0);let l=r(Mt(o,"nodeStyle")).fill||"#4d430c";if(e.colorByDepth&&void 0!==o.depth&&(l=Wt[o.depth%Wt.length]),a){const e=Rt(l);u.push({x:o.x,y:o.y,text:n+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:e})}else u.push({x:o.x,y:o.y-t+14,text:n+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:"#000",stroke:"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:l,sceneEdges:[],labels:u}}(t,i,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Xt(t,e,i){const r=i.treeOrientation||"vertical";if("radial"===r){const i=e.x,r=e.y;t.x=r*Math.cos(i-Math.PI/2),t.y=r*Math.sin(i-Math.PI/2)}else"horizontal"===r?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function qt(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 Gt(t,e){var i;const r=null!==(i=e.r)&&void 0!==i?i:0;t.x=e.x,t.y=e.y,t.x0=e.x-r,t.x1=e.x+r,t.y0=e.y-r,t.y1=e.y+r,t.width=2*r,t.height=2*r,t.__radius=r}function Vt(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const Ht={sankey:Lt,force:Dt,chord:$t,tree:Yt,cluster:Yt,treemap:Yt,circlepack:Yt,partition:Yt,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,i,r){const o=i.__hierarchyRoot;o&&function(t,e,i,r,o){var n,a;const s=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(i.childrenAccessor),l=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),u=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,f=null!==(a=i.orbitEccentricity)&&void 0!==a?a:1,d="number"==typeof h?()=>h:h,g="number"==typeof f?()=>f:f,y=Vt(i);y.metaMap.clear(),r.length=0,o.length=0;const p=new Map;function m(t){var e;const i=null!==(e=p.get(t))&&void 0!==e?e:0;return p.set(t,i+1),0===i?t:`${t}__${i}`}const x=e[0]/2,v=e[1]/2,b=Math.min(e[0],e[1])/2*.85,k=m(l(t));r.push({id:k,x:x,y:v,x0:x,x1:x,y0:v,y1:v,width:0,height:0,value:0,depth:0,data:t}),y.metaMap.set(k,{ring:b,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,i,n,a,h,f,p){const x=s(e);if(!(null==x?void 0:x.length))return;const v=x.length;let b=0,k=0,w=0;for(;v>k;)k+=u[Math.min(w,u.length-1)],w++,b++;let A=0;for(let v=0;b>v;v++){const k=u[Math.min(v,u.length-1)],w=x.slice(A,A+k);if(!w.length)break;const S=(v+1)/b,_={id:i,depth:f,data:e,parentId:i},E=p?h/d(_)*S:h*S,P=c.pie().value(t=>{var e;return(null===(e=s(t))||void 0===e?void 0:e.length)?4:1}).sort(null),M=P(w),O=g(_);for(let e=0;w.length>e;e++){const s=(M[e].startAngle+M[e].endAngle)/2,c=w[e],u=m(l(c)),h=n+E*Math.sin(s),d=a+E*Math.cos(s)*O;r.push({id:u,x:h,y:d,x0:h,x1:h,y0:d,y1:d,width:0,height:0,value:0,depth:f,data:c}),y.metaMap.set(u,{ring:E,angle:s,depth:f,parentId:i,eccentricity:O}),o.push({source:i,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:u}}),t(c,u,h,d,E,f+1,!0)}A+=k}}(t,k,x,v,b,1,!1)}(o,r,i,t,e)},buildScene(t,e,i,r){var o,n,a,s,c;const l=i.nodeStyle,u=i.nodeSize,h="number"==typeof u?()=>u:"function"==typeof u?u:()=>6,f=[],d=[],g=[];if(!1!==i.orbitShowRings){const e=Vt(i),r=new Map;for(const e of t)r.set(e.id,e);const o=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=r.get(t.parentId);if(!e)continue;const i=`${t.parentId}:${t.ring}`;o.has(i)||o.set(i,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const n=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:i,ecc:r}]of o)for(let o=0;n>o;o++){const s=o/n*Math.PI*2,c=(o+1)/n*Math.PI*2;d.push({type:"line",x1:t+i*Math.sin(s),y1:e+i*Math.cos(s)*r,x2:t+i*Math.sin(c),y2:e+i*Math.cos(c)*r,style:a,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=h(Mt(e,"nodeSize")),i=l?l(Mt(e,"nodeStyle")):{},r={fill:i.fill||"#6366f1",stroke:i.stroke||"#fff",strokeWidth:null!==(o=i.strokeWidth)&&void 0!==o?o:1,opacity:null!==(n=i.opacity)&&void 0!==n?n:0===(null!==(a=e.depth)&&void 0!==a?a:0)?1:.85};f.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id,depth:e.depth})}const y=new Map;for(const e of t)y.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:y.get(t.source),i="object"==typeof t.target?t.target:y.get(t.target);e&&i&&(null!=e.x&&null!=i.x&&d.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(i.showLabels){const e=i.nodeLabel;for(const i of t){const t=h(Mt(i,"nodeSize"));if(4>=t)continue;const r="function"==typeof e?e(i):e&&null!==(c=null===(s=i.data)||void 0===s?void 0:s[e])&&void 0!==c?c:i.id;g.push({x:i.x,y:i.y+t+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:f,sceneEdges:d,labels:g}},tick:(t,e,i,r,o)=>!1!==i.orbitAnimated&&(function(t,e){var i,r;const o=Vt(e),n=null!==(i=e.orbitSpeed)&&void 0!==i?i:.25,a=null!==(r=e.orbitRevolution)&&void 0!==r?r:function(t){switch(t){case"decay":return t=>{var e;return Math.pow(.6,null!==(e=t.depth)&&void 0!==e?e:0)};case"alternate":return t=>{var e;const 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),s=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,c=n*(Math.PI/6),l=new Map;for(const e of t)l.set(e.id,e);for(const e of t){const t=o.metaMap.get(e.id);if(!t||!t.parentId)continue;const i=l.get(t.parentId);if(!i)continue;const r=t.angle+s*c*a({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=i.x+t.ring*Math.sin(r),e.y=i.y+t.ring*Math.cos(r)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,i),!0)}};function Zt(t,e){const{columns:i,config:r,resolvePieceStyle:o}=t,n=[],a=Math.min(e.width,e.height)/2-4,s="donut"===r.chartType?r.innerRadius||60:0,c=-Math.PI/2+(r.startAngle||0)*Math.PI/180,l=null!=r.sweepAngle?r.sweepAngle*Math.PI/180:2*Math.PI;for(const t of Object.values(i)){const e=c+t.pctStart*l,i=c+(t.pctStart+t.pct)*l,r=o(t.pieceData[0],t.name);n.push({type:"wedge",cx:0,cy:0,innerRadius:s,outerRadius:a,startAngle:e,endAngle:i,style:r,datum:t.pieceData,category:t.name})}return n}function Kt(t){var e,i,r;const n=t.length,a=t[0],s=t[n-1];return{n:n,min:a,q1:null!==(e=o.quantile(t,.25))&&void 0!==e?e:a,median:null!==(i=o.quantile(t,.5))&&void 0!==i?i:(a+s)/2,q3:null!==(r=o.quantile(t,.75))&&void 0!==r?r:s,max:s,mean:t.reduce((t,e)=>t+e,0)/n}}const Ut={bar:function(t,e){const{scales:i,columns:r,config:o,getR:n,getStack:a,resolvePieceStyle:s}=t,{r:c,projection:l}=i,u=[],h="vertical"===l,f="horizontal"===l,d=o.normalize,g=[];if(a){const t=new Set;for(const e of Object.values(r))for(const i of e.pieceData){const e=a(i);t.has(e)||(t.add(e),g.push(e))}}else g.push("_default");for(const t of Object.values(r)){const e=new Map;for(const i of t.pieceData){const t=a?a(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const r=e.get(t);r.total+=n(i),r.pieces.push(i)}let i=0;if(d)for(const t of e.values())i+=Math.abs(t.total);let r=0,o=0;for(const n of g){const l=e.get(n);if(!l)continue;let g=l.total;d&&i>0&&(g/=i);const y=s(l.pieces[0],a?n:t.name),p=Object.assign(Object.assign({},l.pieces[0]),{__aggregateValue:l.total,__pieceCount:l.pieces.length,category:t.name});if(h){const e=c(0>g?o:r+g),i=0>g?c(o+g)-c(o):c(r)-c(r+g);u.push(z(t.x,e,t.width,Math.abs(i),y,p,n)),0>g?o+=g:r+=g}else if(f){const e=c(0>g?o+g:r),i=0>g?c(o)-c(o+g):c(r+g)-c(r);u.push(z(e,t.x,Math.abs(i),t.width,y,p,n)),0>g?o+=g:r+=g}}}return u},clusterbar:function(t,e){const{scales:i,columns:r,getR:o,getGroup:n,resolvePieceStyle:a}=t,{r:s,projection:c}=i,l=[],u="vertical"===c,h=[],f=new Set;for(const t of Object.values(r))for(const e of t.pieceData){const t=n?n(e):"_default";f.has(t)||(f.add(t),h.push(t))}const d=h.length||1;for(const t of Object.values(r)){const e=t.width/d,i=.2*e,r=e-i,c=new Map;for(const e of t.pieceData){const t=n?n(e):"_default";c.has(t)||c.set(t,[]),c.get(t).push(e)}for(let n=0;h.length>n;n++){const f=c.get(h[n])||[];for(const c of f){const f=o(c),d=a(c,h[n]);if(u){const o=t.x+n*e+i/2,a=s(0),u=s(f);l.push(z(o,Math.min(a,u),r,Math.abs(a-u),d,c,h[n]))}else{const o=t.x+n*e+i/2,a=s(0),u=s(f);l.push(z(Math.min(a,u),o,Math.abs(u-a),r,d,c,h[n]))}}}}return l},point:function(t,e){var i,r;const{scales:o,columns:n,getR:a,multiScales:s,resolvePieceStyle:c}=t,{r:l,projection:u}=o,h=[],f="vertical"===u,d="radial"===u,g=s.length>0,y=2*Math.PI,p=-Math.PI/2;for(const t of Object.values(n))for(const e of t.pieceData){const o=null!==(i=e.__rIndex)&&void 0!==i?i:0,n=null!==(r=e.__rValue)&&void 0!==r?r:a(e),u=g&&s[o]||l,m=c(e,t.name),x=m.r||5;let v,b;if(d){const e=p+(t.pctStart+t.pct/2)*y,i=u(n);v=Math.cos(e)*i,b=Math.sin(e)*i}else f?(v=t.middle,b=u(n)):(v=u(n),b=t.middle);h.push({type:"point",x:v,y:b,r:x,style:m,datum:e})}return h},swarm:function(t,e){const{scales:i,columns:r,getR:o,resolvePieceStyle:n}=t,{r:a,projection:s}=i,c=[],l="vertical"===s;for(const t of Object.values(r)){const e=t.width/2;for(let i=0;t.pieceData.length>i;i++){const r=t.pieceData[i],s=o(r),u=n(r,t.name),h=u.r||4,f=(7919*i%100/100-.5)*e*.8,d=l?t.middle+f:a(s),g=l?a(s):t.middle+f;c.push({type:"point",x:d,y:g,r:h,style:u,datum:r})}}return c},pie:Zt,donut:Zt,boxplot:function(t,e){var i,r,n,a,s;const{scales:c,columns:l,config:u,getR:h,resolveSummaryStyle:f}=t,{r:d,projection:g}=c,y=[],p="vertical"===g,m=!1!==u.showOutliers;for(const t of Object.values(l)){const e=t.pieceData.map(t=>h(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===e.length)continue;const c=e[0],l=e[e.length-1],u=null!==(i=o.quantile(e,.25))&&void 0!==i?i:c,g=null!==(r=o.quantile(e,.5))&&void 0!==r?r:(c+l)/2,x=null!==(n=o.quantile(e,.75))&&void 0!==n?n:l,v=x-u,b=u-1.5*v,k=x+1.5*v,w=null!==(a=e.find(t=>t>=b))&&void 0!==a?a:c,A=null!==(s=[...e].reverse().find(t=>k>=t))&&void 0!==s?s:l,S=f(t.pieceData[0],t.name),_=[];if(m)for(const e of t.pieceData){const i=h(e);if(b>i||i>k){const r=p?t.middle:d(i),o=p?d(i):t.middle;_.push({px:r,py:o,value:i,datum:e})}}if(y.push({type:"boxplot",x:p?t.middle:0,y:p?0:t.middle,projection:p?"vertical":"horizontal",columnWidth:.6*t.width,minPos:d(w),q1Pos:d(u),medianPos:d(g),q3Pos:d(x),maxPos:d(A),stats:{n:e.length,min:w,q1:u,median:g,q3:x,max:A,mean:e.reduce((t,e)=>t+e,0)/e.length},style:S,datum:t.pieceData,category:t.name,outliers:_}),m)for(const t of _)y.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:S.fill||"#999",opacity:.6},datum:t.datum})}return y},violin:function(t,e){var i,r,n;const{scales:a,columns:s,config:c,getR:l,resolveSummaryStyle:u}=t,{r:h,projection:f}=a,d=[],g="vertical"===f,y=c.bins||20,p=!1!==c.showIQR;for(const t of Object.values(s)){const e=t.pieceData.map(t=>l(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const a=e[0],s=e[e.length-1],c=(s-a)/y||1,f=Array(y).fill(0);for(const t of e)f[Math.min(Math.floor((t-a)/c),y-1)]++;const m=Math.max(...f,1),x=t.width/2*.9;let v="";if(g){v=`M ${t.middle} ${h(a)}`;for(let e=0;y>e;e++){const i=h(a+(e+.5)*c);v+=` L ${t.middle+f[e]/m*x} ${i}`}v+=` L ${t.middle} ${h(s)}`;for(let e=y-1;e>=0;e--){const i=h(a+(e+.5)*c);v+=` L ${t.middle-f[e]/m*x} ${i}`}v+=" Z"}else{v=`M ${h(a)} ${t.middle}`;for(let e=0;y>e;e++)v+=` L ${h(a+(e+.5)*c)} ${t.middle-f[e]/m*x}`;v+=` L ${h(s)} ${t.middle}`;for(let e=y-1;e>=0;e--)v+=` L ${h(a+(e+.5)*c)} ${t.middle+f[e]/m*x}`;v+=" Z"}const b=u(t.pieceData[0],t.name);let k;if(p&&e.length>=4){const c=null!==(i=o.quantile(e,.25))&&void 0!==i?i:a,l=null!==(r=o.quantile(e,.5))&&void 0!==r?r:(a+s)/2,u=null!==(n=o.quantile(e,.75))&&void 0!==n?n:s;k={q1Pos:h(c),medianPos:h(l),q3Pos:h(u),centerPos:t.middle,isVertical:g}}const w=g?{x:t.x,y:Math.min(h(s),h(a)),width:t.width,height:Math.abs(h(s)-h(a))}:{x:Math.min(h(a),h(s)),y:t.x,width:Math.abs(h(s)-h(a)),height:t.width};d.push({type:"violin",pathString:v,translateX:0,translateY:0,bounds:w,iqrLine:k,stats:Kt(e),style:b,datum:t.pieceData,category:t.name})}return d},histogram:function(t,e){var i;const{scales:r,columns:o,config:n,getR:a,resolveSummaryStyle:s}=t,{r:c}=r,l=[],u=n.bins||25,h=n.normalize,f=null===(i=c.domain)||void 0===i?void 0:i.call(c),d=f?+f[0]:void 0,g=f?+f[1]:void 0;for(const t of Object.values(o)){const e=t.pieceData.map(t=>a(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const i=null!=d&&isFinite(d)?d:Math.min(...e),r=null!=g&&isFinite(g)?g:Math.max(...e),o=(r-i)/u||1,n=Array(u).fill(0);for(const t of e)i>t||t>r||n[Math.min(Math.floor((t-i)/o),u-1)]++;const f=e.length,y=Math.max(...n,1),p=s(t.pieceData[0],t.name);for(let e=0;u>e;e++){if(0===n[e])continue;const r=(h?n[e]/f:n[e]/y)*t.width*.9,a=c(i+e*o),s=c(i+(e+1)*o);l.push(z(Math.min(a,s),t.x+t.width-r,Math.abs(s-a),r,p,{bin:e,count:n[e],range:[i+e*o,i+(e+1)*o],category:t.name},t.name))}}return l},ridgeline:function(t,e){var i;const{scales:r,columns:o,config:n,getR:a,resolveSummaryStyle:s}=t,{r:c,projection:l}=r,u=[],h=n.bins||20,f="horizontal"===l,d=n.amplitude||1.5;for(const t of Object.values(o)){const e=t.pieceData.map(t=>a(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const r=e[0],o=e[e.length-1],n=(o-r)/h||1,l=Array(h).fill(0);for(const t of e)r>t||t>o||l[Math.min(Math.floor((t-r)/n),h-1)]++;const g=Math.max(...l,1),y=s(t.pieceData[0],t.name),p=t.width*d;let m="";if(f){const e=t.x+t.width;m=`M ${c(r)} ${e}`;for(let t=0;h>t;t++)m+=` L ${c(r+(t+.5)*n)} ${e-l[t]/g*p}`;m+=` L ${c(o)} ${e} Z`}else{const e=t.x;m=`M ${e} ${c(r)}`;for(let t=0;h>t;t++){const i=c(r+(t+.5)*n);m+=` L ${e+l[t]/g*p} ${i}`}m+=` L ${e} ${c(o)} Z`}const x=f?{x:Math.min(c(r),c(o)),y:t.x,width:Math.abs(c(o)-c(r)),height:t.width}:{x:t.x,y:Math.min(c(o),c(r)),width:t.width,height:Math.abs(c(o)-c(r))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:x,stats:Kt(e),style:Object.assign(Object.assign({},y),{fillOpacity:null!==(i=y.fillOpacity)&&void 0!==i?i:.5}),datum:t.pieceData,category:t.name})}return u},timeline:function(t,e){const{scales:i,columns:r,getRawRange:o,resolvePieceStyle:n}=t,{r:a,projection:s}=i,c=[],l="horizontal"===s;for(const t of Object.values(r))for(const e of t.pieceData){const i=o(e);if(!i)continue;const[r,s]=i,u=n(e,t.name);if(l){const i=a(Math.min(r,s)),o=a(Math.max(r,s));c.push(z(i,t.x,o-i,t.width,u,e,t.name))}else{const i=a(Math.max(r,s)),o=a(Math.min(r,s));c.push(z(t.x,i,t.width,o-i,u,e,t.name))}}return c},funnel:function(t,i){var r,o,n,a,s,c,l;const{columns:u,getR:h,getStack:f,resolvePieceStyle:d}=t,g=[],y=i.width/2,p=!1!==t.config.showLabels,m=t.scales.o.domain().map(t=>u[t]).filter(Boolean);if(0===m.length)return g;const x=[],v=new Set;for(const t of m)for(const e of t.pieceData){const t=f?f(e):"_default";v.has(t)||(v.add(t),x.push(t))}const b=x.length>1&&"_default"!==x[0],k=[];let w=0;for(const t of m){const e=new Map;let i=0;for(const r of t.pieceData){const t=f?f(r):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t),n=h(r);o.total+=n,o.pieces.push(r),i+=n}k.push({col:t,groups:e,stepTotal:i}),b||i>w&&(w=i)}if(b)for(const t of k){let e=0,i=0;for(let r=0;x.length>r;r++){const o=t.groups.get(x[r]);o&&(r%2==0?e+=o.total:i+=o.total)}const r=Math.max(e,i);r>w&&(w=r)}if(0===w)return g;const A=new Map;for(const t of x){const e=k[0].groups.get(t);A.set(t,null!==(r=null==e?void 0:e.total)&&void 0!==r?r:0)}const S=k[0].stepTotal,_=b?.95*y:.9*i.width,E=e.scaleLinear().domain([0,w]).range([0,_]),P=null!==(o=t.config.connectorOpacity)&&void 0!==o?o:.3;let M=new Map;for(let t=0;k.length>t;t++){const e=k[t],i=e.col,r=0===t,o=i.width,u=.55*o,h=i.x+(o-u)/2,f=new Map;if(b){let t=0;for(const i of x){const r=e.groups.get(i);r&&(t+=E(r.total))}let o=y,n=y;for(let a=0;x.length>a;a++){const c=x[a],l=e.groups.get(c);if(!l)continue;const m=E(l.total),v=a%2==0,b=v?o:n-m;v?o+=m:n-=m;const k=d(l.pieces[0],c),w=null!==(s=A.get(c))&&void 0!==s?s:l.total,S=w>0?l.total/w*100:0,_=Object.assign(Object.assign({},l.pieces[0]),{__funnelValue:l.total,__funnelPercent:S,__funnelStep:i.name,__funnelIsFirstStep:r,__aggregateValue:l.total,__pieceCount:l.pieces.length,category:c});p&&(0===a&&(_.__funnelStepLabel=i.name,_.__funnelStepLabelX=y,_.__funnelStepLabelY=h,_.__funnelRowWidth=t),_.__funnelValueLabelX=b+m/2,_.__funnelValueLabelY=h,_.__funnelBarW=m),g.push(z(b,h,m,u,k,_,c)),f.set(c,{x:b,y:h,w:m,h:u})}}else{const t=e.stepTotal,o=E(t),s=y-o/2,c=x[0],l="_default"!==c,m=null!==(a=null===(n=e.groups.get(c))||void 0===n?void 0:n.pieces[0])&&void 0!==a?a:i.pieceData[0],v=l?c:i.name,b=d(m,v),k=S>0?t/S*100:0,w=Object.assign(Object.assign({},m),{__funnelValue:t,__funnelPercent:k,__funnelStep:i.name,__funnelIsFirstStep:r,category:l?c:i.name});p&&(w.__funnelStepLabel=i.name,w.__funnelStepLabelX=y,w.__funnelStepLabelY=h,w.__funnelRowWidth=o,w.__funnelValueLabelX=y,w.__funnelValueLabelY=h,w.__funnelBarW=o),g.push(z(s,h,o,u,b,w,v)),f.set(c,{x:s,y:h,w:o,h:u})}if(t>0&&M.size>0){const t=b?x:[x[0]];for(const r of t){const t=M.get(r),o=f.get(r);if(!t||!o)continue;const n=(()=>{const t=e.groups.get(r);return d(t?t.pieces[0]:i.pieceData[0],"_default"===r?i.name:r)})(),a={type:"trapezoid",points:[[t.x,t.y+t.h],[t.x+t.w,t.y+t.h],[o.x+o.w,o.y],[o.x,o.y]],style:{fill:n.fill||"#999",opacity:P},datum:null!==(l=null===(c=e.groups.get(r))||void 0===c?void 0:c.pieces[0])&&void 0!==l?l:i.pieceData[0],category:"_default"===r?i.name:r};g.push(a)}}M=f}return g},"bar-funnel":function(t,e){var i,r,o,n;const{columns:a,getR:s,getStack:c,resolvePieceStyle:l,scales:u}=t,h=[],f=u.o.domain().map(t=>a[t]).filter(Boolean);if(0===f.length)return h;const d=[],g=new Set;for(const t of f)for(const e of t.pieceData){const t=c?c(e):"_default";g.has(t)||(g.add(t),d.push(t))}const y=d.length>1&&"_default"!==d[0],p=[];for(const t of f){const e=new Map;let i=0;for(const r of t.pieceData){const t=c?c(r):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t),n=s(r);o.total+=n,o.pieces.push(r),i+=n}p.push({col:t,groups:e,stepTotal:i})}const m=new Map;for(const t of d){const e=null===(i=p[0])||void 0===i?void 0:i.groups.get(t);m.set(t,null!==(r=null==e?void 0:e.total)&&void 0!==r?r:0)}const x=u.r,v=y?d.length:1,b=y?.15:0;for(let t=0;p.length>t;t++){const e=p[t],i=e.col,r=0===t,a=t>0?p[t-1]:null,s=i.width/v,c=s*b,u=s-c;for(let t=0;d.length>t;t++){const f=d[t],g=e.groups.get(f);if(!g)continue;const p=g.total,v=null!==(o=m.get(f))&&void 0!==o?o:p,b=v>0?p/v*100:0,k=null==a?void 0:a.groups.get(f),w=null!==(n=null==k?void 0:k.total)&&void 0!==n?n:p,A=r?0:Math.max(0,w-p),S=i.x+t*s+c/2,_=x(p),E=x(0)-_,P=l(g.pieces[0],y?f:i.name),M=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:p,__barFunnelPercent:b,__barFunnelIsFirstStep:r,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:A,__barFunnelCategory:"_default"===f?void 0:f,category:y?f:i.name,__barFunnelLabelX:S+u/2,__barFunnelLabelY:x(p+A)});if(h.push(z(S,_,u,E,P,M,y?f:i.name)),A>0){const t=x(p+A),e=_-t,r=Object.assign({},P),o=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:A,__barFunnelPercent:v>0?A/v*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===f?void 0:f,category:y?f:i.name});h.push(z(S,t,u,e,r,o,y?f:i.name))}}}return h},swimlane:function(t,e){const{scales:i,columns:r,getR:o,getStack:n,resolvePieceStyle:a}=t,{r:s,projection:c}=i,l=[],u="horizontal"===c;for(const t of Object.values(r)){let e=0;for(const i of t.pieceData){const r=Math.abs(o(i));if(0===r)continue;const c=n?n(i):t.name,h=a(i,c);if(u){const o=s(e),n=s(e+r);l.push(z(o,t.x,n-o,t.width,h,i,c))}else{const o=s(e+r),n=s(e);l.push(z(t.x,o,t.width,n-o,h,i,c))}e+=r}}return l}};class Qt{constructor(t){this.rExtent=new y,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.version=0,this.config=t,this.buffer=new g(t.windowSize),this.getO=b(t.oAccessor||t.categoryAccessor,"category");const e="streaming"===t.runtimeMode,i=t.rAccessor;Array.isArray(i)?(this.rAccessors=i.map(t=>x(t,"value")),this.getR=this.rAccessors[0],this.rExtents=i.map(()=>new y)):(this.getR=x(e&&(t.timeAccessor||t.valueAccessor)&&t.valueAccessor||i,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=b(t.stackBy),this.getGroup=b(t.groupBy),this.getColor=b(t.colorAccessor),this.getConnector=b(t.connectorAccessor),this.getDataId=b(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new g(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,t.bounded){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=t.totalSize||t.inserts.length;i>this.buffer.capacity&&(this.buffer.resize(i),this.timestampBuffer&&i>this.timestampBuffer.capacity&&this.timestampBuffer.resize(i));for(const i of t.inserts)this.buffer.push(i),this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i)}else{this._hasStreamingData=!0;for(const i of t.inserts){const t=this.buffer.push(i);this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i),null!=t&&this.evictValueExtent(t)}}return!0}pushValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.push(e[0]),this.rExtent.push(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].push(this.rAccessors[e](t));this.rExtent.push(this.getR(t))}else this.rExtent.push(this.getR(t))}evictValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.evict(e[0]),this.rExtent.evict(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].evict(this.rAccessors[e](t));this.rExtent.evict(this.getR(t))}else this.rExtent.evict(this.getR(t))}getRawRange(t){const e=this.config.rAccessor;if(!e)return null;const i="function"==typeof e?e(t):t[e];return Array.isArray(i)&&i.length>=2?[+i[0],+i[1]]:null}computeScene(t){const{config:i,buffer:r}=this;if(0===r.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(r,this.getR);const o=r.toArray(),n=i.projection||"vertical",a=i.oExtent||this.resolveCategories(o),s=this.computeValueDomain(o,a),c="horizontal"===n,l=null!=i.barPadding?i.barPadding/("vertical"===n?t.width:t.height):.1;let u,h;if("radial"===n){u=e.scaleBand().domain(a).range([0,1]).padding(0);const r=Math.min(t.width,t.height)/2,o=i.innerRadius||0;h=e.scaleLinear().domain(s).range([o,r])}else c?(u=e.scaleBand().domain(a).range([0,t.height]).padding(l),h=e.scaleLinear().domain(s).range([0,t.width])):(u=e.scaleBand().domain(a).range([0,t.width]).padding(l),h=e.scaleLinear().domain(s).range([t.height,0]));this.scales={o:u,r:h,projection:n},this.multiScales=this.rAccessors.length>1&&i.multiAxis?this.rAccessors.map((o,n)=>{var a;const s=this.rExtents[n];s.dirty&&s.recalculate(r,o);let[l,u]=s.extent;l===1/0&&(l=0,u=1);const h=null!==(a=i.extentPadding)&&void 0!==a?a:.05,f=u-l,d=f>0?f*h:1;return l-=d,u+=d,l>0&&(l=0),c?e.scaleLinear().domain([l,u]).range([0,t.width]):e.scaleLinear().domain([l,u]).range([t.height,0])}):[];let f=o;this.rAccessors.length>1&&(f=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(f,a,u,n,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(f,t),this.config.decay&&this.applyDecay(this.scene,o),this.config.pulse&&this.applyPulse(this.scene,o),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(t){const e=Array.isArray(this.config.rAccessor)?this.config.rAccessor[t]:this.config.rAccessor;return"string"==typeof e?e:"value"+t}resolveCategories(t){const e=Array.from(this.categories),i=this.config.oSort;if(("streaming"===this.config.runtimeMode||this._hasStreamingData)&&void 0===i){const i=new Set;for(const e of t)i.add(this.getO(e));const r=Math.max(50,3*i.size);if(this.categories.size>r){let t=this.categories.size-r;for(const e of this.categories){if(0>=t)break;i.has(e)||(this.categories.delete(e),t--)}}return e.filter(t=>i.has(t))}if(!1===i)return e;if("function"==typeof i)return e.sort(i);const r=new Map;for(const e of t){const t=this.getO(e);r.set(t,(r.get(t)||0)+Math.abs(this.getR(e)))}return e.sort("asc"===i?(t,e)=>(r.get(t)||0)-(r.get(e)||0):(t,e)=>(r.get(e)||0)-(r.get(t)||0))}computeValueDomain(t,e){var i,r,o,n,a;const s=this.config.chartType,c=null!==(i=this.config.extentPadding)&&void 0!==i?i:.05;if("radial"===this.config.projection&&("pie"===s||"donut"===s))return[0,1];let l=0,u=0;if("bar"===s&&this.getStack&&this.config.normalize)l=0,u=1;else if("bar"===s&&this.getStack){const e=new Map,i=new Map;for(const r of t){const t=this.getO(r),o=this.getR(r);0>o?i.set(t,(i.get(t)||0)+o):e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>u&&(u=t);for(const t of i.values())l>t&&(l=t)}else if("bar"===s){const e=new Map;for(const i of t){const t=this.getO(i),r=this.getR(i);e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>u&&(u=t),l>t&&(l=t)}else if("swimlane"===s){const e=new Map;for(const i of t){const t=this.getO(i),r=Math.abs(this.getR(i));e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>u&&(u=t)}else if("clusterbar"===s||"bar-funnel"===s)for(const e of t){const t=this.getR(e);t>u&&(u=t),l>t&&(l=t)}else{const t=this.rExtent.extent[0],e=this.rExtent.extent[1];t!==1/0&&(l=t),e!==-1/0&&(u=e)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(l=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(u=this.config.rExtent[1]));const h="bar"===s||"clusterbar"===s||"bar-funnel"===s||"swimlane"===s;if(h&&null==(null===(r=this.config.rExtent)||void 0===r?void 0:r[0])&&null==(null===(o=this.config.rExtent)||void 0===o?void 0:o[1])&&(l>0&&(l=0),0>u&&(u=0)),"bar-funnel"!==s){const t=u-l,e=t>0?t*c:1;null!=(null===(n=this.config.rExtent)||void 0===n?void 0:n[0])||h&&!this.config.baselinePadding&&0===l||(l-=e),null!=(null===(a=this.config.rExtent)||void 0===a?void 0:a[1])||h&&!this.config.baselinePadding&&0===u||"swimlane"===s||(u+=e)}return[l,u]}buildColumns(t,e,i,r,o){var n;const a={},s=new Map;for(const e of t){const t=this.getO(e);s.has(t)||s.set(t,[]),s.get(t).push(e)}let c=0;if("radial"===r)for(const e of t)c+=Math.abs(this.getR(e));const l=this.config.dynamicColumnWidth;let u=null;if(l&&"radial"!==r){u=new Map;let t=0;for(const i of e){const e=s.get(i)||[];let r;r="string"==typeof l?e.reduce((t,e)=>t+(Number(e[l])||0),0):l(e),u.set(i,r),t+=r}const n=("horizontal"===r?o.height:o.width)-i.padding()*i.step()*e.length;if(t>0)for(const[e,i]of u)u.set(e,i/t*n)}let h=0,f=0;for(const t of e){const e=s.get(t)||[],r=e.reduce((t,e)=>t+Math.abs(this.getR(e)),0),o=c>0?r/c:0;let l,d;u?(l=f,d=u.get(t)||i.bandwidth(),f+=d+i.padding()*i.step()):(l=null!==(n=i(t))&&void 0!==n?n:0,d=i.bandwidth()),a[t]={name:t,x:l,y:0,width:d,middle:l+d/2,padding:i.padding()*i.step(),pieceData:e,pct:o,pctStart:h},h+=o}return a}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(t,e)=>this.resolvePieceStyle(t,e),resolveSummaryStyle:(t,e)=>this.resolveSummaryStyle(t,e),getRawRange:t=>this.getRawRange(t)}}buildSceneNodes(t,e){if(!this.scales)return[];const i=this.getSceneContext(),r=Ut[this.config.chartType];let o=r?r(i,e):[];if(this.getConnector&&this.scales){const t=function(t,e){const{scales:i,config:r,getConnector:o,getO:n}=t;if(!o||!i)return[];const a=[],{projection:s}=i,c=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const i=o(e);if(!i)continue;let r,a;"point"===t.type?(r=t.x,a=t.y):(r=t.x+t.w/2,a=t.y+("vertical"===s?0:t.h/2)),c.has(i)||c.set(i,[]),c.get(i).push({x:r,y:a,datum:e,category:n(e)})}const l=i.o.domain(),u=r.connectorStyle;for(const[t,e]of c)if(e.length>=2){e.sort((t,e)=>l.indexOf(t.category)-l.indexOf(e.category));for(let i=0;e.length-1>i;i++){const r=e[i],o=e[i+1],n="function"==typeof u?u(r.datum):u||{stroke:"#999",strokeWidth:1,opacity:.5};a.push({type:"connector",x1:r.x,y1:r.y,x2:o.x,y2:o.y,style:n,datum:r.datum,group:t})}}return a}(i,o);o=[...t,...o]}return o}resolvePieceStyle(t,e){if("function"==typeof this.config.pieceStyle){const i=this.config.pieceStyle(t,e);return i&&!i.fill&&e?Object.assign(Object.assign({},i),{fill:this.getColorFromScheme(e)}):i}return this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&e?{fill:this.config.barColors[e]||"#007bff"}:e?{fill:this.getColorFromScheme(e)}:{fill:"#007bff"}}getColorFromScheme(t){this._colorSchemeMap||(this._colorSchemeMap=new Map);const e=this._colorSchemeMap.get(t);if(e)return e;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:k,r=i[this._colorSchemeIndex%i.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(t,r),r}resolveSummaryStyle(t,e){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(t,e):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(t,e){var i,r,o;const n=this.config.decay;if(!n||1>=e)return 1;const a=null!==(i=n.minOpacity)&&void 0!==i?i:.1,s=e-1-t;switch(n.type){case"linear":return a+(1-s/(e-1))*(1-a);case"exponential":{const t=null!==(r=n.halfLife)&&void 0!==r?r:e/2;return a+Math.pow(.5,s/t)*(1-a)}case"step":return(null!==(o=n.stepThreshold)&&void 0!==o?o:.5*e)>s?1:a;default:return 1}}applyDecay(t,e){var i,r;if(!this.config.decay)return;const o=e.length;if(1>=o)return;const n=new Map;for(let t=0;e.length>t;t++)n.set(e[t],t);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;const t=n.get(e.datum);if(null==t)continue;const a=this.computeDecayOpacity(t,o),s=null!==(r=null===(i=e.style)||void 0===i?void 0:i.opacity)&&void 0!==r?r:1;e.style=Object.assign(Object.assign({},e.style),{opacity:s*a})}}applyPulse(t,e){var i,r,o;if(!this.config.pulse||!this.timestampBuffer)return;const n="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(i=this.config.pulse.duration)&&void 0!==i?i:500,s=null!==(r=this.config.pulse.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",c=null!==(o=this.config.pulse.glowRadius)&&void 0!==o?o:4,l=new Map;for(let t=0;e.length>t;t++)l.set(e[t],t);for(const i of t){if("connector"===i.type||"violin"===i.type||"boxplot"===i.type)continue;if("wedge"===i.type){const t=i.category;if(!t)continue;let r=0;for(let i=0;e.length>i;i++){const o=e[i],s=this.config.oAccessor;if(("function"==typeof s?s(o):o[s||"category"])!==t)continue;const c=this.timestampBuffer.get(i);if(null==c)continue;const l=n-c;if(a>l){const t=1-l/a;t>r&&(r=t)}}r>0&&(i._pulseIntensity=r,i._pulseColor=s);continue}const t=l.get(i.datum);if(null==t)continue;const r=this.timestampBuffer.get(t);if(null==r)continue;const o=n-r;a>o&&(i._pulseIntensity=1-o/a,i._pulseColor=s,i._pulseGlowRadius=c)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,r=this.timestampBuffer.peek();return null!=r&&i>e-r}getNodeKey(t,e){var i,r;if("point"===t.type){const i=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,r=e.get(i)||0;return e.set(i,r+1),`${i}:${r}`}return"rect"===t.type?`r:${t.group||""}:${null!==(r=null===(i=t.datum)||void 0===i?void 0:i.category)&&void 0!==r?r:""}`:null}snapshotPositions(){this.prevPositionMap.clear();const t=new Map;for(let e=0;this.scene.length>e;e++){const i=this.scene[e],r=this.getNodeKey(i,t);r&&("point"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity}):"rect"===i.type&&this.prevPositionMap.set(r,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity}))}}startTransition(){var t,e,i,r,o,n,a,s,c,l,u,h;if(!this.config.transition||0===this.prevPositionMap.size)return;const f=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}let d=!1;const g=new Set,y=new Map;for(let t=0;this.scene.length>t;t++){const s=this.scene[t],c=this.getNodeKey(s,y);if(!c)continue;s._transitionKey=c;const l=this.prevPositionMap.get(c);"point"===s.type?l?(g.add(c),s._targetOpacity=null!==(e=s.style.opacity)&&void 0!==e?e:1,l.x===s.x&&l.y===s.y||(s._targetX=s.x,s._targetY=s.y,s.x=l.x,s.y=l.y,d=!0)):(s._targetOpacity=null!==(i=s.style.opacity)&&void 0!==i?i:1,s.style=Object.assign(Object.assign({},s.style),{opacity:0}),d=!0):"rect"===s.type&&(l?(g.add(c),s._targetOpacity=null!==(r=s.style.opacity)&&void 0!==r?r:1,l.x===s.x&&l.y===s.y&&l.w===s.w&&l.h===s.h||(s._targetX=s.x,s._targetY=s.y,s._targetW=s.w,s._targetH=s.h,s.x=l.x,s.y=l.y,s.w=null!==(o=l.w)&&void 0!==o?o:s.w,s.h=null!==(n=l.h)&&void 0!==n?n:s.h,d=!0)):(s._targetOpacity=null!==(a=s.style.opacity)&&void 0!==a?a:1,s.style=Object.assign(Object.assign({},s.style),{opacity:0}),d=!0))}this.exitNodes=[];for(const[t,e]of this.prevPositionMap)g.has(t)||(t.startsWith("p:")?this.exitNodes.push({type:"point",x:e.x,y:e.y,r:null!==(s=e.r)&&void 0!==s?s:3,style:{opacity:null!==(c=e.opacity)&&void 0!==c?c:1},datum:null,_targetOpacity:0,_transitionKey:t}):t.startsWith("r:")&&this.exitNodes.push({type:"rect",x:e.x,y:e.y,w:null!==(l=e.w)&&void 0!==l?l:0,h:null!==(u=e.h)&&void 0!==u?u:0,style:{opacity:null!==(h=e.opacity)&&void 0!==h?h:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t}),d=!0);this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),d&&(this.activeTransition={startTime:P(),duration:f})}advanceTransition(t){var e,i,r;if(!this.activeTransition)return!1;const o=_(t,this.activeTransition),n=S(o,"linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?"linear":"ease-out-cubic");for(const t of this.scene){const e=t._transitionKey;if(e)if("point"===t.type){if(void 0!==t._targetOpacity){const r=this.prevPositionMap.get(e),o=r?null!==(i=r.opacity)&&void 0!==i?i:1:0;t.style.opacity=E(o,t._targetOpacity,n)}if(void 0===t._targetX)continue;const r=this.prevPositionMap.get(e);if(!r)continue;t.x=E(r.x,t._targetX,n),t.y=E(r.y,t._targetY,n)}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e),o=i?null!==(r=i.opacity)&&void 0!==r?r:1:0;t.style.opacity=E(o,t._targetOpacity,n)}if(void 0===t._targetX)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=E(i.x,t._targetX,n),t.y=E(i.y,t._targetY,n),void 0!==i.w&&(t.w=E(i.w,t._targetW,n),t.h=E(i.h,t._targetH,n))}}if(o>=1){for(const t of this.scene)if(void 0!==t._targetOpacity&&(t.style=Object.assign(Object.assign({},t.style||{}),{opacity:0===t._targetOpacity?0:t._targetOpacity}),t._targetOpacity=void 0),"point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}getData(){return this.buffer.toArray()}remove(t){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");const e=new Set(Array.isArray(t)?t:[t]),i=this.getDataId,r=t=>e.has(i(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,i)=>{r(t)&&e.add(i)}),this.timestampBuffer.clear();for(let i=0;t.length>i;i++)e.has(i)||this.timestampBuffer.push(t[i])}const o=this.buffer.remove(r);if(0===o.length)return o;for(const t of o)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach(t=>this.categories.add(this.getO(t))),this.version++,o}update(t,e){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const i=new Set(Array.isArray(t)?t:[t]),r=this.getDataId,o=new Set;this.buffer.forEach((t,e)=>{i.has(r(t))&&o.add(e)});const n=this.buffer.update(t=>i.has(r(t)),e);if(0===n.length)return n;for(const t of n)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach((t,e)=>{this.categories.add(this.getO(t)),o.has(e)&&this.pushValueExtent(t)}),this.version++,n}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}updateConfig(t){const e=Object.assign({},this.config);if(t.colorScheme!==this.config.colorScheme&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),Object.assign(this.config,t),(void 0!==t.oAccessor||void 0!==t.categoryAccessor)&&(m(t.oAccessor||t.categoryAccessor,e.oAccessor||e.categoryAccessor)||(this.getO=b(this.config.oAccessor||this.config.categoryAccessor,"category"),this.categories.clear())),void 0!==t.rAccessor){const i=Array.isArray(t.rAccessor)?t.rAccessor:[t.rAccessor],r=Array.isArray(e.rAccessor)?e.rAccessor:[e.rAccessor];if(i.length!==r.length||i.some((t,e)=>!m(t,r[e]))){const t=this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>x(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new y)):(this.getR=x(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!m(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?b(this.config.stackBy):void 0),"groupBy"in t&&!m(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?b(this.config.groupBy):void 0),"colorAccessor"in t&&!m(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?b(this.config.colorAccessor):void 0),"connectorAccessor"in t&&!m(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?b(this.config.connectorAccessor):void 0)}}const Jt={mercator:u.geoMercator,equalEarth:u.geoEqualEarth,albersUsa:u.geoAlbersUsa,orthographic:u.geoOrthographic,naturalEarth:u.geoNaturalEarth1,equirectangular:u.geoEquirectangular};function te(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function ee(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function ie(t,e,i){return t?Object.assign(Object.assign({},i),"function"==typeof t?t(e):t):i}const re={fill:"#e0e0e0",stroke:"#999",strokeWidth:.5,fillOpacity:1},oe={fill:"#4e79a7",r:4,fillOpacity:.8},ne={stroke:"#4e79a7",strokeWidth:1.5,fill:"none"};function ae(t,e){if(2>t.length)return[t];const i=.4*e,r=[];let o=[t[0]];for(let e=1;t.length>e;e++){const n=t[e];Math.abs(n[0]-t[e-1][0])>i?(2>o.length||r.push(o),o=[n]):o.push(n)}return 2>o.length||r.push(o),r}function se(t,e,i=24){const r=e[0]-t[0],o=e[1]-t[1],n=Math.sqrt(r*r+o*o);if(0===n)return[t,e];const a=-o/n,s=r/n,c=Math.min(.3*n,80),l=(t[0]+e[0])/2+a*c,u=(t[1]+e[1])/2+s*c,h=[];for(let r=0;i>=r;r++){const o=r/i,n=1-o;h.push([n*n*t[0]+2*n*o*l+o*o*e[0],n*n*t[1]+2*n*o*u+o*o*e[1]])}return h}function ce(t,e){if(2>t.length)return t;const i=e/2+1,r=[];for(let e=0;t.length>e;e++){const o=t[e];let n,a;0===e?(n=t[1][0]-o[0],a=t[1][1]-o[1]):e===t.length-1?(n=o[0]-t[e-1][0],a=o[1]-t[e-1][1]):(n=t[e+1][0]-t[e-1][0],a=t[e+1][1]-t[e-1][1]);const s=Math.sqrt(n*n+a*a)||1;r.push([o[0]+a/s*i,o[1]+-n/s*i])}return r}function le(t,e,i,r,o){const n=e[0]-t[0],a=e[1]-t[1],s=Math.sqrt(n*n+a*a);if(0===s)return[t,e];const c=a/s,l=-n/s,u=o/2+1;return[[t[0]+c*u,t[1]+l*u],[e[0]+c*u,e[1]+l*u]]}class ue{constructor(t){this.scene=[],this.scales=null,this.version=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this.config=t}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}setAreas(t){this.areas=t}setPoints(t){this.pointData=t,this.streaming=!1}setLines(t){this.lineData=t}initStreaming(t=500){this.pointBuffer=new g(t),this.timestampBuffer=new g(t),this.streaming=!0}pushPoint(t){this.pointBuffer||this.initStreaming(),this.pointBuffer.push(t),this.timestampBuffer.push(performance.now()),this.lastIngestTime=performance.now()}pushMany(t){this.pointBuffer||this.initStreaming();const e=performance.now();for(const i of t)this.pointBuffer.push(i),this.timestampBuffer.push(e);this.lastIngestTime=e}removePoint(t){const{pointIdAccessor:e}=this.config;if(!e)throw Error("removePoint() requires pointIdAccessor to be configured");const i="function"==typeof e?e:t=>t[e],r=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>r.has(i(t)+"");if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),i=new Set;this.pointBuffer.forEach((e,r)=>{t(e)&&i.add(r)}),this.timestampBuffer.clear();for(let t=0;e.length>t;t++)i.has(t)||this.timestampBuffer.push(e[t])}const e=this.pointBuffer.remove(t);return e.length>0&&this.version++,e}{const t=[];return this.pointData=this.pointData.filter(e=>!r.has(i(e)+"")||(t.push(e),!1)),t.length>0&&this.version++,t}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.scene=[],this.scales=null,this.version++}computeScene(t){const{config:e}=this;this.projection=function(t){if(!t)return u.geoEqualEarth();if("string"==typeof t){const e=Jt[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),u.geoEqualEarth())}if("object"==typeof t&&"type"in t){const e=Jt[t.type],i=e?e():u.geoEqualEarth();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=u.geoPath(this.projection),this.fitProjection(t),this.geoPath=u.geoPath(this.projection);const i=this.projection;this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null};const r=this.scene;this.scene=this.buildSceneNodes(t),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&r.length>0&&this.startTransition(r),this.version++}fitProjection(t){var e,i,r,o,n;const a=this.projection,s=this.config,c=[...this.areas],l=te(s.xAccessor,"lon"),u=te(s.yAccessor,"lat"),h=this.getPoints();if(h.length>0){const t=h.map(t=>[l(t),u(t)]);c.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const f=ee(s.lineDataAccessor);for(const t of this.lineData){const e=f(t);if(e&&e.length>0){const t=e.map(t=>[l(t),u(t)]);c.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==c.length){if(s.projectionExtent){const[[e,i],[r,o]]=s.projectionExtent;a.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[e,i],[r,i],[r,o],[e,o],[e,i]]]}})}else if(a.clipAngle&&(null!==(e=a.clipAngle())&&void 0!==e?e:0)>0){const e=null!==(i=s.fitPadding)&&void 0!==i?i:0,r=Math.min(t.width,t.height);a.scale(r/2-r*e),a.translate([t.width/2,t.height/2])}else{const e=null!==(r=s.fitPadding)&&void 0!==r?r:0,i=t.width*e,o=t.height*e;a.fitExtent([[i,o],[t.width-i,t.height-o]],{type:"FeatureCollection",features:c})}this.baseScale=a.scale(),this.baseTranslate=a.translate(),this.baseRotation=null!==(n=null===(o=a.rotate)||void 0===o?void 0:o.call(a))&&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=u.geoPath(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyZoomScale(t,e){const i=this.projection;i&&(i.scale(this.baseScale*t),i.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=u.geoPath(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyRotation(t,e){const i=this.projection;i&&i.rotate&&(i.rotate(t),this.geoPath=u.geoPath(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}setRotation(t){const e=this.projection;e&&e.rotate&&e.rotate(t)}getRotation(){var t,e,i;return null!==(i=null===(e=null===(t=this.projection)||void 0===t?void 0:t.rotate)||void 0===e?void 0:e.call(t))&&void 0!==i?i:this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}buildSceneNodes(t){var e,i,r;const o=[],{config:n}=this,a=this.projection,s=this.geoPath,c=te(n.xAccessor,"lon"),l=te(n.yAccessor,"lat");if(n.graticule){const e=!0===n.graticule?{}:n.graticule,i=u.geoGraticule();e.step&&i.step(e.step);const r=s(i())||"";r&&o.push({type:"geoarea",pathData:r,centroid:[t.width/2,t.height/2],bounds:[[0,0],[t.width,t.height]],screenArea:0,style:{fill:"none",stroke:e.stroke||"#e0e0e0",strokeWidth:e.strokeWidth||.5,strokeDasharray:e.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const t of this.areas){const e=s(t);if(!e)continue;const i=s.centroid(t),r=s.bounds(t),a=s.area(t),c=ie(n.areaStyle,t,re);o.push({type:"geoarea",pathData:e,centroid:i,bounds:r,screenArea:a,style:c,datum:t,interactive:!0})}const h=ee(n.lineDataAccessor);for(const e of this.lineData){const i=h(e);if(!i||2>i.length)continue;const r=i.map(t=>[c(t),l(t)]);let s;if("geo"===n.lineType){const t=[];for(let e=0;r.length-1>e;e++){const i=r[e],o=r[e+1],n=u.geoDistance(i,o)||0,a=Math.max(2,Math.ceil(n/(Math.PI/180))),s=u.geoInterpolate(i,o);for(let i=0;a>=i;i++)e>0&&0===i||t.push(s(i/a))}s=t.map(([t,e])=>a([t,e])).filter(t=>null!=t)}else s=r.map(([t,e])=>a([t,e])).filter(t=>null!=t);if(2>s.length)continue;const f=ie(n.lineStyle,e,ne),d="number"==typeof f.strokeWidth?f.strokeWidth:1;2!==r.length||2>s.length||"arc"!==n.flowStyle?2!==r.length||2>s.length||"offset"!==n.flowStyle||(s="geo"===n.lineType?ce(s,d):le(s[0],s[s.length-1],0,0,d)):s=se(s[0],s[s.length-1]);const g=ae(s,t.width);if(g.length>1)for(const t of g){if(2>t.length)continue;const i={type:"line",path:t,style:Object.assign(Object.assign({},f),{_edgeFade:!0}),datum:e};o.push(i)}else o.push({type:"line",path:2>s.length&&g[0]||s,style:f,datum:e})}const f=this.getPoints(),d=n.pointIdAccessor?"function"==typeof n.pointIdAccessor?n.pointIdAccessor:t=>t[n.pointIdAccessor]:null,g=a.clipAngle&&null!==(e=a.clipAngle())&&void 0!==e?e:0,y=g>0?g*Math.PI/180:null,p=a.rotate?a.rotate():[0,0,0],m="function"==typeof a.center?a.center():[0,0],x=[(null!==(i=m[0])&&void 0!==i?i:0)-p[0],(null!==(r=m[1])&&void 0!==r?r:0)-p[1]];for(let t=0;f.length>t;t++){const e=f[t],i=c(e),r=l(e);if(null!=y&&u.geoDistance([i,r],x)>y)continue;const s=a([i,r]);if(!s)continue;const h=n.pointStyle?n.pointStyle(e):Object.assign({},oe),g={type:"point",x:s[0],y:s[1],r:h.r||4,style:h,datum:e,pointId:d?d(e)+"":void 0};o.push(g)}return o}applyCartogramTransform(t,i){var r,o,n;const a=this.scene.filter(t=>"point"===t.type);if(2>a.length)return;const s=null!==(r=t.strength)&&void 0!==r?r:1;if(0===s)return;const c=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:t=>t.id,l="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],u=a.find(e=>c(e.datum)+""==t.center+"");if(!u)return void("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`));const h=u.x,f=u.y,d=a.map(t=>l(t.datum)).filter(t=>isFinite(t)&&t>=0),g=Math.max(...d,1),y=Math.min(i.width,i.height)/2,p=e.scaleLinear().domain([0,g]).range([0,y]);this.cartogramLayout={cx:h,cy:f,maxCost:g,availableRadius:y},this.areas.length>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them."),this.scene=this.scene.filter(t=>"geoarea"!==t.type||!t.interactive);for(const t of a){if(t===u)continue;const e=Math.atan2(t.y-f,t.x-h),i=Math.sqrt(Math.pow(t.x-h,2)+Math.pow(t.y-f,2)),r=l(t.datum),o=i+((isFinite(r)?p(r):i)-i)*s;t.x=h+Math.cos(e)*o,t.y=f+Math.sin(e)*o}const m=i.width/2,x=i.height/2,v=m-u.x,b=x-u.y;if(Math.abs(v)>.5||Math.abs(b)>.5)for(const t of a)t.x+=v,t.y+=b;this.cartogramLayout={cx:m,cy:x,maxCost:g,availableRadius:y};const k=this.scene.filter(t=>"line"===t.type);if(k.length>0&&"fractional"!==t.lineMode){const t=new Map;for(const e of a)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,r=null===(n=e.datum)||void 0===n?void 0:n.target;if(i&&r){const o=t.get(i+""),n=t.get(r+"");o&&n&&(e.path=[o,n])}}}}applyDecay(){var t,e,i;const r=this.config.decay;if(!r||!this.pointBuffer)return;const o=this.pointBuffer.size;if(0===o)return;const n=null!==(t=r.minOpacity)&&void 0!==t?t:.1,a=null!==(e=r.halfLife)&&void 0!==e?e:o/2,s=null!==(i=r.stepThreshold)&&void 0!==i?i:.5*o,c=this.scene.filter(t=>"point"===t.type);for(let t=0;c.length>t;t++){const e=o-1-t;let i;switch(r.type){case"exponential":i=n+Math.pow(.5,e/a)*(1-n);break;case"step":i=s>e?1:n;break;default:i=n+(o>1?1-e/(o-1):1)*(1-n)}c[t]._decayOpacity=i,c[t].style=Object.assign(Object.assign({},c[t].style),{opacity:i})}}applyPulse(){var t,e;const i=this.config.pulse;if(!i||!this.timestampBuffer)return;const r=null!==(t=i.duration)&&void 0!==t?t:500,o=performance.now(),n=this.scene.filter(t=>"point"===t.type),a=this.timestampBuffer.toArray();for(let t=0;n.length>t&&a.length>t;t++){const s=o-a[t];r>s&&(n[t]._pulseIntensity=1-s/r,n[t]._pulseColor=i.color||"rgba(255,255,255,0.6)",n[t]._pulseGlowRadius=null!==(e=i.glowRadius)&&void 0!==e?e:4)}}get hasActivePulses(){var t,e;if(!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const i=null!==(e=null===(t=this.config.pulse)||void 0===t?void 0:t.duration)&&void 0!==e?e:500,r=this.timestampBuffer.toArray()[this.timestampBuffer.size-1];return performance.now()-r<i}startTransition(t){var e,i;const r=null!==(i=null===(e=this.config.transition)||void 0===e?void 0:e.duration)&&void 0!==i?i:300;if(0>=r)return;const o=new Map;for(const e of t)"point"===e.type&&e.pointId&&o.set(e.pointId,[e.x,e.y]);const n=this.scene.filter(t=>"point"===t.type);let a=!1;for(const t of n)if(t.pointId){const e=o.get(t.pointId);e&&(t._targetX=t.x,t._targetY=t.y,t.x=e[0],t.y=e[1],(Math.abs(e[0]-t._targetX)>.5||Math.abs(e[1]-t._targetY)>.5)&&(a=!0))}a&&(this.activeTransition={startTime:performance.now(),duration:r})}advanceTransition(t){if(!this.activeTransition)return!1;const e=_(t,this.activeTransition),i=S(e),r=this.scene.filter(t=>"point"===t.type);for(const t of r)if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=E(t.x,t._targetX,i),t.y=E(e,t._targetY,i)}if(e>=1){for(const t of r)null!=t._targetX&&(t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0);return this.activeTransition=null,!1}return!0}}function he(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}function fe(t,e){var i,r,o;switch(t.type){case"line":{const i=t;if(0===i.path.length)return null;const r="M"+i.path.map(([t,e])=>`${t},${e}`).join("L");return f.createElement("path",{key:"line-"+e,d:r,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth||2,strokeDasharray:i.style.strokeDasharray,opacity:i.style.opacity})}case"area":{const o=t;if(0===o.topPath.length)return null;const n=o.topPath.map(([t,e])=>`${t},${e}`).join("L"),a=[...o.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return f.createElement("path",{key:"area-"+e,d:`M${n}L${a}Z`,fill:he(o.style.fill),fillOpacity:null!==(r=null!==(i=o.style.fillOpacity)&&void 0!==i?i:o.style.opacity)&&void 0!==r?r:.7,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})}case"point":{const i=t;return f.createElement("circle",{key:"point-"+e,cx:i.x,cy:i.y,r:i.r,fill:he(i.style.fill),opacity:null!==(o=i.style.opacity)&&void 0!==o?o:.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})}case"rect":{const i=t;return f.createElement("rect",{key:"rect-"+e,x:i.x,y:i.y,width:i.w,height:i.h,fill:he(i.style.fill),opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})}case"heatcell":{const i=t;if(i.showValues&&null!=i.value&&i.w>=20&&i.h>=20){const t=i.valueFormat?i.valueFormat(i.value):Number.isInteger(i.value)?i.value+"":100>Math.abs(i.value)?1>Math.abs(i.value)?i.value.toPrecision(3):i.value.toFixed(1):i.value.toFixed(0),[r,o,n]=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]}(i.fill),a=.299*r+.587*o+.114*n>128?"#000":"#fff",s=Math.max(10,Math.min(16,.3*Math.min(i.w,i.h)));return f.createElement("g",{key:"heatcell-"+e},f.createElement("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill}),f.createElement("text",{x:i.x+i.w/2,y:i.y+i.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:s+"px"},t))}return f.createElement("rect",{key:"heatcell-"+e,x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill})}case"candlestick":{const i=t,r=Math.min(i.openY,i.closeY),o=Math.max(Math.abs(i.openY-i.closeY),1),n=i.isUp?i.upColor:i.downColor;return f.createElement("g",{key:"candle-"+e},f.createElement("line",{x1:i.x,y1:i.highY,x2:i.x,y2:i.lowY,stroke:i.wickColor,strokeWidth:i.wickWidth}),f.createElement("rect",{x:i.x-i.bodyWidth/2,y:r,width:i.bodyWidth,height:o,fill:n,stroke:n,strokeWidth:1}))}default:return null}}function de(t,e){var i,r,o,n,a;const s=t.category||t.group||"",l=i=>`ord-${t.type}-${s}-${e}-${i}`,u=`ord-${t.type}-${s}-${e}`;switch(t.type){case"rect":{const e=t;return f.createElement("rect",{key:u,x:e.x,y:e.y,width:e.w,height:e.h,fill:he(e.style.fill),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})}case"point":{const e=t;return f.createElement("circle",{key:u,cx:e.x,cy:e.y,r:e.r,fill:he(e.style.fill),opacity:null!==(i=e.style.opacity)&&void 0!==i?i:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})}case"wedge":{const e=t,i=c.arc().innerRadius(e.innerRadius).outerRadius(e.outerRadius).startAngle(e.startAngle).endAngle(e.endAngle)({})||"";return f.createElement("path",{key:u,d:i,transform:`translate(${e.cx},${e.cy})`,fill:he(e.style.fill),stroke:e.style.stroke,strokeWidth:e.style.strokeWidth,opacity:e.style.opacity})}case"boxplot":{const e=t,i=e.columnWidth/2;return"vertical"===e.projection?f.createElement("g",{key:u},f.createElement("line",{x1:e.x,y1:e.minPos,x2:e.x,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:1}),f.createElement("rect",{x:e.x-i,y:Math.min(e.q1Pos,e.q3Pos),width:e.columnWidth,height:Math.abs(e.q3Pos-e.q1Pos),fill:he(e.style.fill),fillOpacity:null!==(r=e.style.fillOpacity)&&void 0!==r?r:.6,stroke:e.style.stroke||"#333",strokeWidth:1}),f.createElement("line",{x1:e.x-i,y1:e.medianPos,x2:e.x+i,y2:e.medianPos,stroke:e.style.stroke||"#333",strokeWidth:2}),f.createElement("line",{x1:e.x-.5*i,y1:e.minPos,x2:e.x+.5*i,y2:e.minPos,stroke:e.style.stroke||"#333",strokeWidth:1}),f.createElement("line",{x1:e.x-.5*i,y1:e.maxPos,x2:e.x+.5*i,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:1})):f.createElement("g",{key:u},f.createElement("line",{x1:e.minPos,y1:e.y,x2:e.maxPos,y2:e.y,stroke:e.style.stroke||"#333",strokeWidth:1}),f.createElement("rect",{x:Math.min(e.q1Pos,e.q3Pos),y:e.y-i,width:Math.abs(e.q3Pos-e.q1Pos),height:e.columnWidth,fill:he(e.style.fill),fillOpacity:null!==(o=e.style.fillOpacity)&&void 0!==o?o:.6,stroke:e.style.stroke||"#333",strokeWidth:1}),f.createElement("line",{x1:e.medianPos,y1:e.y-i,x2:e.medianPos,y2:e.y+i,stroke:e.style.stroke||"#333",strokeWidth:2}),f.createElement("line",{x1:e.minPos,y1:e.y-.5*i,x2:e.minPos,y2:e.y+.5*i,stroke:e.style.stroke||"#333",strokeWidth:1}),f.createElement("line",{x1:e.maxPos,y1:e.y-.5*i,x2:e.maxPos,y2:e.y+.5*i,stroke:e.style.stroke||"#333",strokeWidth:1}))}case"violin":{const e=t,i=[f.createElement("path",{key:l("path"),d:e.pathString,transform:e.translateX||e.translateY?`translate(${e.translateX},${e.translateY})`:void 0,fill:he(e.style.fill),fillOpacity:null!==(n=e.style.fillOpacity)&&void 0!==n?n:.6,stroke:e.style.stroke||"#333",strokeWidth:e.style.strokeWidth||1})];if(e.iqrLine&&e.bounds){const t=e.bounds,r=t.x+t.width/2,o=t.y+t.height/2;t.height>t.width?i.push(f.createElement("line",{key:l("iqr"),x1:r,y1:e.iqrLine.q1Pos,x2:r,y2:e.iqrLine.q3Pos,stroke:e.style.stroke||"#333",strokeWidth:2}),f.createElement("circle",{key:l("med"),cx:r,cy:e.iqrLine.medianPos,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1})):i.push(f.createElement("line",{key:l("iqr"),x1:e.iqrLine.q1Pos,y1:o,x2:e.iqrLine.q3Pos,y2:o,stroke:e.style.stroke||"#333",strokeWidth:2}),f.createElement("circle",{key:l("med"),cx:e.iqrLine.medianPos,cy:o,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1}))}return f.createElement("g",{key:u},i)}case"connector":return f.createElement("line",{key:u,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:null!==(a=t.style.opacity)&&void 0!==a?a:.5});case"trapezoid":{const e=t,i=e.points.map(t=>`${t[0]},${t[1]}`).join(" ");return f.createElement("polygon",{key:u,points:i,fill:he(e.style.fill,"#999"),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})}default:return null}}const ge={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},ye={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},pe={mode:"light",colors:{primary:"#0000cc",categorical:["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],sequential:"blues",diverging:"RdBu",background:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};t.createContext(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:ge,setTheme(e){t(t=>{if("light"===e)return{theme:ge};if("dark"===e)return{theme:ye};if("high-contrast"===e)return{theme:pe};if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?ye:ge;return{theme:Object.assign(Object.assign(Object.assign({},t),e),{colors:Object.assign(Object.assign({},t.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.typography),e.typography||{})})}}return{theme:Object.assign(Object.assign(Object.assign({},t.theme),e),{colors:Object.assign(Object.assign({},t.theme.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.theme.typography),e.typography||{})})}})}}));const me={light:ge,dark:ye,"high-contrast":pe,pastels:{mode:"light",colors:{primary:"#c9a0dc",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",text:"#4a3728",textSecondary:"#8b7355",grid:"#e8d5c4",border:"#e8d5c4",focus:"#c9a0dc"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",text:"#2c3e50",textSecondary:"#7f8c9b",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}};function xe(t){if(!t)return ge;if("string"==typeof t){if("light"===t)return ge;if("dark"===t)return ye;if("high-contrast"===t)return pe;return me[t]||ge}const e="dark"===t.mode?ye:ge;return Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{}),tooltip:Object.assign(Object.assign({},e.tooltip),t.tooltip||{})})}function ve(t){return{background:t.colors.background,text:t.colors.text,textSecondary:t.colors.textSecondary,grid:t.colors.grid,border:t.colors.border,primary:t.colors.primary,fontFamily:t.typography.fontFamily,titleSize:t.typography.titleSize,labelSize:t.typography.labelSize,tickSize:t.typography.tickSize,categorical:t.colors.categorical}}function be(t){const{categories:i,colorScheme:o,theme:n,position:a="right",totalWidth:s,totalHeight:c,margin:l,hasTitle:u=!1}=t;if(!i||0===i.length)return null;const h=function(t,i,o){const n=Array.isArray(i)?i:o.colors.categorical.length>0?o.colors.categorical:r.schemeCategory10;return e.scaleOrdinal().domain(t).range(n)}(i,o,n);let d,g;if("left"===a?(d=4,g=l.top):"top"===a?(d=l.left,g=u?32:8):"bottom"===a?(d=l.left,g=c-l.bottom+8):(d=s-l.right+10,g=l.top),"top"===a||"bottom"===a){let t=0;const e=i.map((e,i)=>{const r=t;return t+=22+6.5*e.length+8,f.createElement("g",{key:"legend-"+i,transform:`translate(${r},0)`},f.createElement("rect",{width:14,height:14,fill:h(e),rx:2}),f.createElement("text",{x:20,y:7,dominantBaseline:"central",fontSize:n.typography.tickSize,fill:n.colors.text,fontFamily:n.typography.fontFamily},e))});return f.createElement("g",{className:"semiotic-legend",transform:`translate(${d},${g})`},e)}const y=i.map((t,e)=>f.createElement("g",{key:"legend-"+e,transform:`translate(0,${20*e})`},f.createElement("rect",{width:14,height:14,fill:h(t),rx:2}),f.createElement("text",{x:20,y:7,dominantBaseline:"central",fontSize:n.typography.tickSize,fill:n.colors.text,fontFamily:n.typography.fontFamily},t)));return f.createElement("g",{className:"semiotic-legend",transform:`translate(${d},${g})`},y)}function ke(t,e){if(!e||!t||0===t.length)return[];const i="function"==typeof e?e:t=>t[e],r=new Set;for(const e of t){const t=i(e);null!=t&&r.add(t+"")}return Array.from(r)}function we(t){const{annotations:e}=t;if(!e||0===e.length)return null;const i=[];for(let r=0;e.length>r;r++){const o=Ae(e[r],r,t);o&&i.push(o)}return i.length>0?f.createElement("g",{id:(t.idPrefix?t.idPrefix+"-":"")+"annotations",className:"semiotic-annotations"},i):null}function Ae(t,e,i){var r,o,n,a;const{scales:s,layout:c,theme:l,xAccessor:u,yAccessor:h}=i;switch(t.type){case"y-threshold":{const o=t.value;if(null==o)return null;const n=t.color||l.colors.primary,a=t.label,u=t.labelPosition||"right",h=t.strokeDasharray||"6,4",d=null!==(r=t.strokeWidth)&&void 0!==r?r:1.5;if("horizontal"===i.projection&&s.r){const t=s.r(o);return null==t?null:f.createElement("g",{key:"ann-ythresh-"+e},f.createElement("line",{x1:t,y1:0,x2:t,y2:c.height,stroke:n,strokeWidth:d,strokeDasharray:h}),a&&f.createElement("text",{x:t+4,y:12,textAnchor:"start",fontSize:l.typography.tickSize,fill:n,fontFamily:l.typography.fontFamily},a))}const g=s.y?s.y(o):s.r?s.r(o):null;return null==g?null:f.createElement("g",{key:"ann-ythresh-"+e},f.createElement("line",{x1:0,y1:g,x2:c.width,y2:g,stroke:n,strokeWidth:d,strokeDasharray:h}),a&&f.createElement("text",{x:"left"===u?4:"center"===u?c.width/2:c.width-4,y:g-6,textAnchor:"left"===u?"start":"center"===u?"middle":"end",fontSize:l.typography.tickSize,fill:n,fontFamily:l.typography.fontFamily},a))}case"x-threshold":{const i=t.value;if(null==i||!s.x)return null;const r=s.x(i);if(null==r)return null;const n=t.color||l.colors.primary,a=t.label,u=t.labelPosition||"top",h=null!==(o=t.strokeWidth)&&void 0!==o?o:1.5;return f.createElement("g",{key:"ann-xthresh-"+e},f.createElement("line",{x1:r,y1:0,x2:r,y2:c.height,stroke:n,strokeWidth:h,strokeDasharray:t.strokeDasharray||"6,4"}),a&&f.createElement("text",{x:r+4,y:"bottom"===u?c.height-4:"center"===u?c.height/2:12,textAnchor:"start",fontSize:l.typography.tickSize,fill:n,fontFamily:l.typography.fontFamily},a))}case"band":{const i=null!=t.y0&&s.y?s.y(t.y0):null,r=null!=t.y1&&s.y?s.y(t.y1):null;if(null==i||null==r)return null;const o=Math.min(i,r),a=t.fill||t.color||l.colors.primary,u=null!==(n=t.opacity)&&void 0!==n?n:.1;return f.createElement("g",{key:"ann-band-"+e},f.createElement("rect",{x:0,y:o,width:c.width,height:Math.abs(r-i),fill:a,opacity:u}),t.label&&f.createElement("text",{x:c.width-4,y:o+12,textAnchor:"end",fontSize:l.typography.tickSize,fill:a,fontFamily:l.typography.fontFamily},t.label))}case"category-highlight":{if(!t.category||!s.o)return null;const r=s.o(t.category);if(null==r)return null;const o=s.o.bandwidth?s.o.bandwidth():40,n=t.color||l.colors.primary,u=null!==(a=t.opacity)&&void 0!==a?a:.1;return f.createElement("rect","horizontal"===i.projection?{key:"ann-cathighlight-"+e,x:0,y:r,width:c.width,height:o,fill:n,opacity:u}:{key:"ann-cathighlight-"+e,x:r,y:0,width:o,height:c.height,fill:n,opacity:u})}case"label":case"text":{const i=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}(t,s,u),r=function(t,e,i){return null!=t.y&&e.y?e.y(t.y):i&&null!=t[i]&&e.y?e.y(t[i]):null}(t,s,h);if(null==i||null==r)return null;const o=t.dx||0,n=t.dy||0,a=t.color||l.colors.text;return f.createElement("g",{key:"ann-label-"+e},"label"===t.type&&f.createElement("line",{x1:i,y1:r,x2:i+o,y2:r+n,stroke:l.colors.textSecondary,strokeWidth:1}),f.createElement("text",{x:i+o,y:r+n,textAnchor:t.textAnchor||"start",fontSize:t.fontSize||l.typography.labelSize,fill:a,fontFamily:l.typography.fontFamily,fontWeight:t.fontWeight},t.label||t.title))}default:return null}}const Se=require("react-dom/server");function _e(t){return Math.round(100*t)/100+""}function Ee(t,e){const i=ve(e.theme),r=e.idPrefix?e.idPrefix+"-":"",o="string"==typeof e.title?e.title:void 0,n=o?r+"semiotic-title":void 0,a=e.description?r+"semiotic-desc":void 0,s=[n,a].filter(Boolean).join(" ")||void 0;return f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className,width:e.width,height:e.height,role:"img","aria-labelledby":s,style:{fontFamily:i.fontFamily}},o&&f.createElement("title",{id:n},o),e.description&&f.createElement("desc",{id:a},e.description),e.defs&&f.createElement("defs",null,e.defs),e.background&&"transparent"!==e.background&&f.createElement("rect",{x:0,y:0,width:e.width,height:e.height,fill:e.background}),f.createElement("g",{id:r+"data-area",transform:e.innerTransform},t),o&&f.createElement("text",{id:r+"chart-title",x:e.width/2,y:16,textAnchor:"middle",fontSize:i.titleSize,fontWeight:"bold",fill:i.text,fontFamily:i.fontFamily},o),e.legend&&f.createElement("g",{id:r+"legend"},e.legend),e.outerElements)}function Pe(t){var e,i,r,o;const n=xe(t.theme),a=t.size||[500,300],s=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),t.margin),c=t.legendPosition;t.showLegend&&(c&&"right"!==c?"left"===c?s.left=Math.max(s.left,100):"bottom"===c?s.bottom=Math.max(s.bottom,70):"top"===c&&(s.top=Math.max(s.top,40)):s.right=Math.max(s.right,100));const l=a[0]-s.left-s.right,u=a[1]-s.top-s.bottom,h="streaming"===t.runtimeMode||["bar","swarm","waterfall"].includes(t.chartType),d={chartType:t.chartType,windowSize:null!==(e=t.windowSize)&&void 0!==e?e:200,windowMode:null!==(i=t.windowMode)&&void 0!==i?i:"sliding",arrowOfTime:h&&null!==(r=t.arrowOfTime)&&void 0!==r?r:"right",extentPadding:null!==(o=t.extentPadding)&&void 0!==o?o:.1,xAccessor:h?void 0:t.xAccessor,yAccessor:h?void 0:t.yAccessor,timeAccessor:h?t.timeAccessor:void 0,valueAccessor:t.valueAccessor,colorAccessor:t.colorAccessor,sizeAccessor:t.sizeAccessor,groupAccessor:t.groupAccessor,categoryAccessor:t.categoryAccessor,lineDataAccessor:t.lineDataAccessor,xExtent:t.xExtent,yExtent:t.yExtent,sizeRange:t.sizeRange,binSize:t.binSize,normalize:t.normalize,boundsAccessor:t.boundsAccessor,boundsStyle:t.boundsStyle,openAccessor:t.openAccessor,highAccessor:t.highAccessor,lowAccessor:t.lowAccessor,closeAccessor:t.closeAccessor,candlestickStyle:t.candlestickStyle,lineStyle:t.lineStyle,pointStyle:t.pointStyle,areaStyle:t.areaStyle,colorScheme:t.colorScheme||n.colors.categorical,barColors:t.barColors},g=new W(d);if(t.data&&g.ingest({inserts:t.data,bounded:!0}),g.computeScene({width:l,height:u}),!g.scales||0===g.scene.length)return Se.renderToStaticMarkup(Ee(null,{width:a[0],height:a[1],className:"stream-xy-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:n,innerTransform:`translate(${s.left},${s.top})`,idPrefix:t._idPrefix}));const y=t._idPrefix,p=t.showGrid?function(t,e,i,r){const{grid:o}=ve(i),n=r?r+"-":"",a=t.x.ticks(5),s=t.y.ticks(5);return f.createElement("g",{id:n+"grid",className:"semiotic-grid",opacity:.8},a.map((i,r)=>{const n=t.x(i);return f.createElement("line",{key:"gx-"+r,x1:n,y1:0,x2:n,y2:e.height,stroke:o,strokeWidth:.5})}),s.map((i,r)=>{const n=t.y(i);return f.createElement("line",{key:"gy-"+r,x1:0,y1:n,x2:e.width,y2:n,stroke:o,strokeWidth:.5})}))}(g.scales,{width:l,height:u},n,y):null,m=g.scene.map((t,e)=>fe(t,e)).filter(Boolean),x=!1!==t.showAxes?function(t,e,i,r,o){var n,a,s,c;const l=ve(r),u=t.x.ticks(5).map(e=>({pixel:t.x(e),label:(i.xFormat||i.tickFormatTime||_e)(e)})),h=t.y.ticks(5).map(e=>({pixel:t.y(e),label:(i.yFormat||i.tickFormatValue||_e)(e)}));return f.createElement("g",{id:(o?o+"-":"")+"axes",className:"stream-axes"},f.createElement("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:l.border,strokeWidth:1}),u.map((t,i)=>f.createElement("g",{key:"xtick-"+i,transform:`translate(${t.pixel},${e.height})`},f.createElement("line",{y2:5,stroke:l.border,strokeWidth:1}),f.createElement("text",{y:18,textAnchor:"middle",fontSize:l.tickSize,fill:l.textSecondary,fontFamily:l.fontFamily},t.label))),i.xLabel&&f.createElement("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:l.labelSize,fill:l.text,fontFamily:l.fontFamily},i.xLabel),f.createElement("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:l.border,strokeWidth:1}),h.map((t,e)=>f.createElement("g",{key:"ytick-"+e,transform:`translate(0,${t.pixel})`},f.createElement("line",{x2:-5,stroke:l.border,strokeWidth:1}),f.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:l.tickSize,fill:l.textSecondary,fontFamily:l.fontFamily},t.label))),i.yLabel&&f.createElement("text",{x:15-(null!==(a=null===(n=i.margin)||void 0===n?void 0:n.left)&&void 0!==a?a:40),y:e.height/2,textAnchor:"middle",fontSize:l.labelSize,fill:l.text,fontFamily:l.fontFamily,transform:`rotate(-90, ${15-(null!==(c=null===(s=i.margin)||void 0===s?void 0:s.left)&&void 0!==c?c:40)}, ${e.height/2})`},i.yLabel))}(g.scales,{width:l,height:u},t,n,y):null,v=t.annotations?we({annotations:t.annotations,scales:{x:g.scales.x,y:g.scales.y},layout:{width:l,height:u},theme:n,xAccessor:"string"==typeof t.xAccessor?t.xAccessor:void 0,yAccessor:"string"==typeof t.yAccessor?t.yAccessor:void 0,idPrefix:y}):null,b=t.showLegend?(()=>{const e=ke(t.data||[],t.colorAccessor||t.groupAccessor);return 0===e.length?null:be({categories:e,colorScheme:t.colorScheme,theme:n,position:t.legendPosition||"right",totalWidth:a[0],totalHeight:a[1],margin:s,hasTitle:!!t.title})})():null,k=f.createElement(f.Fragment,null,p,v,m,x);return Se.renderToStaticMarkup(Ee(k,{width:a[0],height:a[1],className:"stream-xy-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:n,innerTransform:`translate(${s.left},${s.top})`,legend:b,idPrefix:t._idPrefix}))}function Me(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const Oe=new Set(["tree","cluster","treemap","circlepack","partition"]);function Le(t){const e=xe(t.theme),i=t.chartType||"force",r=t.size||[500,500],o=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),t.margin),n=r[0]-o.left-o.right,a=r[1]-o.top-o.bottom,s=function(t){return Ht[t]}(i);if(!s)throw Error(`No layout plugin found for chart type: "${i}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const l={chartType:i,nodeIDAccessor:t.nodeIDAccessor,sourceAccessor:t.sourceAccessor,targetAccessor:t.targetAccessor,valueAccessor:t.valueAccessor,childrenAccessor:t.childrenAccessor,hierarchySum:t.hierarchySum,orientation:t.orientation,nodeAlign:t.nodeAlign,nodePaddingRatio:t.nodePaddingRatio,nodeWidth:t.nodeWidth,iterations:t.iterations,forceStrength:t.forceStrength,padAngle:t.padAngle,groupWidth:t.groupWidth,sortGroups:t.sortGroups,edgeSort:t.edgeSort,treeOrientation:t.treeOrientation,edgeType:t.edgeType,padding:t.padding,paddingTop:t.paddingTop,nodeStyle:t.nodeStyle,edgeStyle:t.edgeStyle,nodeLabel:t.nodeLabel,showLabels:t.showLabels,colorBy:t.colorBy,colorScheme:t.colorScheme||e.colors.categorical,edgeColorBy:t.edgeColorBy,edgeOpacity:t.edgeOpacity,colorByDepth:t.colorByDepth,nodeSize:t.nodeSize,nodeSizeRange:t.nodeSizeRange};let u,h;if(Oe.has(i)){const i=t.data||t.edges;if(!i||Array.isArray(i))return Se.renderToStaticMarkup(Ee(null,{width:r[0],height:r[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:e,innerTransform:`translate(${o.left},${o.top})`,idPrefix:t._idPrefix}));l.__hierarchyRoot=i,u=[],h=[]}else{const i=t.nodes||[],n=Array.isArray(t.edges)?t.edges:[];if(0===i.length&&0===n.length)return Se.renderToStaticMarkup(Ee(null,{width:r[0],height:r[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:e,innerTransform:`translate(${o.left},${o.top})`,idPrefix:t._idPrefix}));if(h=function(t,e){const i=Me(e.sourceAccessor,"source"),r=Me(e.targetAccessor,"target"),o=Me(e.valueAccessor,"value");return t.map(t=>({source:i(t)+"",target:r(t)+"",value:Number(o(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(n,l),0===i.length&&h.length>0){const t=new Set;for(const e of h){const i="string"==typeof e.target?e.target:e.target.id;t.add("string"==typeof e.source?e.source:e.source.id),t.add(i)}u=Array.from(t).map(t=>({id:t,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:t}}))}else u=function(t,e){const i=Me(e.nodeIDAccessor,"id");return t.map(t=>{var e,r;return{id:i(t)+"",x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(r=t.y)&&void 0!==r?r:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}})}(i,l)}s.computeLayout(u,h,l,[n,a]);const{sceneNodes:d,sceneEdges:g,labels:y}=s.buildScene(u,h,l,[n,a]),p=ve(e);for(const t of y)t.fill||(t.fill=p.text);const m=g.map((t,e)=>function(t,e){switch(t.type){case"line":return f.createElement("line",{key:"net-edge-"+e,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity});case"bezier":{const i=t;return f.createElement("path",{key:"net-edge-"+e,d:i.pathD,fill:he(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}case"ribbon":{const i=t;return f.createElement("path",{key:"net-edge-"+e,d:i.pathD,fill:he(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}case"curved":{const i=t;return f.createElement("path",{key:"net-edge-"+e,d:i.pathD,fill:he(i.style.fill,"none"),stroke:i.style.stroke||"#999",strokeWidth:i.style.strokeWidth||1,opacity:i.style.opacity})}default:return null}}(t,e)).filter(Boolean),x=d.map((t,e)=>function(t,e){switch(t.type){case"circle":{const i=t;return f.createElement("circle",{key:"net-circle-"+e,cx:i.cx,cy:i.cy,r:i.r,fill:he(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}case"rect":{const i=t;return f.createElement("rect",{key:"net-rect-"+e,x:i.x,y:i.y,width:i.w,height:i.h,fill:he(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}case"arc":{const i=t,r=c.arc().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle).endAngle(i.endAngle)({})||"";return f.createElement("path",{key:"net-arc-"+e,d:r,transform:`translate(${i.cx},${i.cy})`,fill:he(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}default:return null}}(t,e)).filter(Boolean),v=y.map((t,e)=>function(t,e){return f.createElement("text",{key:"net-label-"+e,x:t.x,y:t.y,textAnchor:t.anchor||"middle",dominantBaseline:t.baseline||"auto",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"#333",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder},t.text)}(t,e)).filter(Boolean),b=f.createElement(f.Fragment,null,m,x,v);return Se.renderToStaticMarkup(Ee(b,{width:r[0],height:r[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:e,innerTransform:`translate(${o.left},${o.top})`,idPrefix:t._idPrefix}))}function De(t){var e,i,r,o,n;const a=xe(t.theme),s=t.size||[500,400],c=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),t.margin),l=t.legendPosition;t.showLegend&&(l&&"right"!==l?"left"===l?c.left=Math.max(c.left,100):"bottom"===l?c.bottom=Math.max(c.bottom,70):"top"===l&&(c.top=Math.max(c.top,40)):c.right=Math.max(c.right,100));const u=s[0]-c.left-c.right,h=s[1]-c.top-c.bottom,d=t.projection||"vertical",g="radial"===d,y={chartType:t.chartType,windowSize:null!==(e=t.windowSize)&&void 0!==e?e:1e4,windowMode:null!==(i=t.windowMode)&&void 0!==i?i:"sliding",extentPadding:null!==(r=t.extentPadding)&&void 0!==r?r:.05,projection:d,oAccessor:t.oAccessor,rAccessor:t.rAccessor,colorAccessor:t.colorAccessor,stackBy:t.stackBy,groupBy:t.groupBy,categoryAccessor:t.categoryAccessor,valueAccessor:t.valueAccessor,timeAccessor:t.timeAccessor,rExtent:t.rExtent,oExtent:t.oExtent,barPadding:t.barPadding,innerRadius:t.innerRadius,normalize:t.normalize,startAngle:t.startAngle,bins:t.bins,showOutliers:t.showOutliers,showIQR:t.showIQR,amplitude:t.amplitude,oSort:t.oSort,connectorAccessor:t.connectorAccessor,connectorStyle:t.connectorStyle,dynamicColumnWidth:t.dynamicColumnWidth,pieceStyle:t.pieceStyle,summaryStyle:t.summaryStyle,colorScheme:t.colorScheme||a.colors.categorical,barColors:t.barColors},p=new Qt(y);if(t.data&&p.ingest({inserts:t.data,bounded:!0}),p.computeScene({width:u,height:h}),!p.scales||0===p.scene.length)return Se.renderToStaticMarkup(Ee(null,{width:s[0],height:s[1],className:"stream-ordinal-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:a,innerTransform:`translate(${c.left},${c.top})`,idPrefix:t._idPrefix}));const m=t._idPrefix,x=t.showGrid?function(t,e,i,r){const o=t.scales;if(!o||"radial"===o.projection)return null;const{grid:n}=ve(i),a=r?r+"-":"",s="vertical"===o.projection,c=o.r.ticks(5);return f.createElement("g",{id:a+"grid",className:"semiotic-grid",opacity:.8},c.map(s?(t,i)=>{const r=o.r(t);return f.createElement("line",{key:"gr-"+i,x1:0,y1:r,x2:e.width,y2:r,stroke:n,strokeWidth:.5})}:(t,i)=>{const r=o.r(t);return f.createElement("line",{key:"gr-"+i,x1:r,y1:0,x2:r,y2:e.height,stroke:n,strokeWidth:.5})}))}(p,{width:u,height:h},a,m):null,v=p.scene.some(t=>{var e;return"rect"===t.type&&(null===(e=t.datum)||void 0===e?void 0:e.__barFunnelIsDropoff)});let b=null;if(v){const e=function(t){const e=t._idPrefix||t.chartId;if(e){const t=(e+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(t)?t:"c"+t}const i=`${t.chartType||""}:${t.title||""}:${Array.isArray(t.data)?t.data.length:0}`;let r=0;for(let t=0;i.length>t;t++)r=31*r+i.charCodeAt(t)|0;return"c"+(r>>>0).toString(36)}(t),i=new Set;for(const t of p.scene)"rect"===t.type&&(null===(o=t.datum)||void 0===o?void 0:o.__barFunnelIsDropoff)&&i.add("string"==typeof t.style.fill?t.style.fill:"#666");b=Array.from(i).map((t,i)=>function(t){const{id:e,background:i="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:n=6,angle:a=45}=t,s=Math.max(8,Math.ceil(2*n));return f.createElement("pattern",{key:e,id:e,width:s,height:s,patternUnits:"userSpaceOnUse",patternTransform:0!==a?`rotate(${a})`:void 0},i&&"transparent"!==i&&f.createElement("rect",{width:s,height:s,fill:i}),f.createElement("line",{x1:0,y1:0,x2:0,y2:s,stroke:r,strokeWidth:o}),f.createElement("line",{x1:n,y1:0,x2:n,y2:s,stroke:r,strokeWidth:o}))}({id:`funnel-hatch-${e}-${i}`,background:t,stroke:"transparent"===a.colors.background?"#fff":a.colors.background,lineWidth:1.5,spacing:5,angle:45}));const r=new Map;Array.from(i).forEach((t,i)=>r.set(t,`funnel-hatch-${e}-${i}`));for(const t of p.scene)if("rect"===t.type&&(null===(n=t.datum)||void 0===n?void 0:n.__barFunnelIsDropoff)){const e="string"==typeof t.style.fill?t.style.fill:"#666";t.style=Object.assign(Object.assign({},t.style),{fill:`url(#${r.get(e)})`})}}const k=p.scene.map((t,e)=>de(t,e)).filter(Boolean),w=!1!==t.showAxes?function(t,e,i,r,o){var n,a,s,c,l,u,h,d;const g=t.scales;if(!g)return null;if("radial"===g.projection)return null;const y=ve(r),p="vertical"===g.projection,m=Object.values(t.columns).map(t=>({pixel:t.middle,label:(i.oFormat||String)(t.name)})),x=g.r.ticks(5).map(t=>({pixel:g.r(t),label:(i.rFormat||_e)(t)}));return p?f.createElement("g",{id:(o?o+"-":"")+"axes",className:"ordinal-axes"},f.createElement("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:y.border,strokeWidth:1}),m.map((t,i)=>f.createElement("g",{key:"oxtick-"+i,transform:`translate(${t.pixel},${e.height})`},f.createElement("line",{y2:5,stroke:y.border,strokeWidth:1}),f.createElement("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily},t.label))),i.oLabel&&f.createElement("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily},i.oLabel),f.createElement("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:y.border,strokeWidth:1}),x.map((t,e)=>f.createElement("g",{key:"oytick-"+e,transform:`translate(0,${t.pixel})`},f.createElement("line",{x2:-5,stroke:y.border,strokeWidth:1}),f.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily},t.label))),i.rLabel&&f.createElement("text",{x:15-(null!==(a=null===(n=i.margin)||void 0===n?void 0:n.left)&&void 0!==a?a:40),y:e.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(c=null===(s=i.margin)||void 0===s?void 0:s.left)&&void 0!==c?c:40)}, ${e.height/2})`},i.rLabel)):f.createElement("g",{id:(o?o+"-":"")+"axes",className:"ordinal-axes"},f.createElement("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:y.border,strokeWidth:1}),x.map((t,i)=>f.createElement("g",{key:"oxtick-"+i,transform:`translate(${t.pixel},${e.height})`},f.createElement("line",{y2:5,stroke:y.border,strokeWidth:1}),f.createElement("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily},t.label))),i.rLabel&&f.createElement("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily},i.rLabel),f.createElement("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:y.border,strokeWidth:1}),m.map((t,e)=>f.createElement("g",{key:"oytick-"+e,transform:`translate(0,${t.pixel})`},f.createElement("line",{x2:-5,stroke:y.border,strokeWidth:1}),f.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily},t.label))),i.oLabel&&f.createElement("text",{x:15-(null!==(u=null===(l=i.margin)||void 0===l?void 0:l.left)&&void 0!==u?u:40),y:e.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(d=null===(h=i.margin)||void 0===h?void 0:h.left)&&void 0!==d?d:40)}, ${e.height/2})`},i.oLabel))}(p,{width:u,height:h},t,a,m):null,A=t.annotations?we({annotations:t.annotations,scales:{r:p.scales.r,y:"vertical"===p.scales.projection?p.scales.r:void 0},layout:{width:u,height:h},theme:a,projection:d,idPrefix:m}):null,S=t.showLegend?(()=>{const e=ke(t.data||[],t.colorAccessor||t.stackBy||t.groupBy);return 0===e.length?null:be({categories:e,colorScheme:t.colorScheme,theme:a,position:t.legendPosition||"right",totalWidth:s[0],totalHeight:s[1],margin:c,hasTitle:!!t.title})})():null,_=g?c.left+u/2:c.left,E=g?c.top+h/2:c.top,P=f.createElement(f.Fragment,null,x,A,k,w);return Se.renderToStaticMarkup(Ee(P,{width:s[0],height:s[1],className:"stream-ordinal-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:a,innerTransform:`translate(${_},${E})`,legend:S,defs:b,idPrefix:t._idPrefix}))}function ze(t){var e,i,r,o,n,a,s,c;const l=xe(t.theme),u=t.size||[t.width||600,t.height||400],h=Object.assign(Object.assign({},{top:10,right:10,bottom:10,left:10}),t.margin),d=u[0]-(null!==(e=h.left)&&void 0!==e?e:0)-(null!==(i=h.right)&&void 0!==i?i:0),g=u[1]-(null!==(r=h.top)&&void 0!==r?r:0)-(null!==(o=h.bottom)&&void 0!==o?o:0),y=new ue({projection:t.projection||"equalEarth",xAccessor:t.xAccessor,yAccessor:t.yAccessor,lineDataAccessor:t.lineDataAccessor,pointIdAccessor:t.pointIdAccessor,lineType:t.lineType,areaStyle:t.areaStyle,pointStyle:t.pointStyle,lineStyle:t.lineStyle,graticule:t.graticule,fitPadding:t.fitPadding,projectionTransform:t.projectionTransform});if(t.areas){if("string"==typeof t.areas)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${t.areas}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${t.areas}')\` before calling renderGeoToStaticSVG.`);y.setAreas(t.areas)}if(t.points&&y.setPoints(t.points),t.lines&&y.setLines(t.lines),y.computeScene({width:d,height:g}),0===y.scene.length)return Se.renderToStaticMarkup(Ee(null,{width:u[0],height:u[1],className:"stream-geo-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:l,innerTransform:`translate(${null!==(n=h.left)&&void 0!==n?n:0},${null!==(a=h.top)&&void 0!==a?a:0})`,idPrefix:t._idPrefix}));const p=y.scene.map((t,e)=>function(t,e){var i,r,o,n,a,s;switch(t.type){case"geoarea":{const o=t;return o.pathData?f.createElement("path",{key:"geoarea-"+e,d:o.pathData,fill:he(o.style.fill,"#e0e0e0"),fillOpacity:null!==(i=o.style.fillOpacity)&&void 0!==i?i:1,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth||.5,strokeDasharray:o.style.strokeDasharray,opacity:null!==(r=o._decayOpacity)&&void 0!==r?r:1}):null}case"point":{const i=t;return f.createElement("circle",{key:"point-"+e,cx:i.x,cy:i.y,r:i.r,fill:he(i.style.fill),fillOpacity:null!==(o=i.style.fillOpacity)&&void 0!==o?o:.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:null!==(n=i._decayOpacity)&&void 0!==n?n:null!==(a=i.style.opacity)&&void 0!==a?a:1})}case"line":{const i=t;if(2>i.path.length)return null;const r="M"+i.path.map(t=>`${t[0]},${t[1]}`).join("L");return f.createElement("path",{key:"line-"+e,d:r,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth||1.5,strokeDasharray:i.style.strokeDasharray,opacity:null!==(s=i.style.opacity)&&void 0!==s?s:1})}default:return null}}(t,e)).filter(Boolean),m=f.createElement(f.Fragment,null,p);return Se.renderToStaticMarkup(Ee(m,{width:u[0],height:u[1],className:"stream-geo-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:l,innerTransform:`translate(${null!==(s=h.left)&&void 0!==s?s:0},${null!==(c=h.top)&&void 0!==c?c:0})`,idPrefix:t._idPrefix}))}function je(t,e){switch(t){case"xy":return Pe(e);case"ordinal":return De(e);case"network":return Le(e);case"geo":return ze(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", or "geo".`)}}function Te(t,e,i){var r,o,n,a,s,c,l,u;const{data:h,width:d=600,height:g=400,theme:y,title:p,description:m,showLegend:x,showGrid:v,background:b,className:k,annotations:w,margin:A,colorScheme:S,colorBy:_,legendPosition:E}=e,P=function(t,e){var i={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&0>e.indexOf(r)&&(i[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);r.length>o;o++)0>e.indexOf(r[o])&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(i[r[o]]=t[r[o]])}return i}(e,["data","width","height","theme","title","description","showLegend","showGrid","background","className","annotations","margin","colorScheme","colorBy","legendPosition"]),M=[d,g],O=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},P.frameProps||{}),{theme:y,title:p,description:m,showLegend:x,showGrid:v,background:b,className:k,annotations:w,size:M}),void 0!==A&&{margin:A}),void 0!==S&&{colorScheme:S}),void 0!==E&&{legendPosition:E}),{_idPrefix:P._idPrefix});switch(t){case"Sparkline":return Pe(Object.assign(Object.assign({chartType:"line",data:h,xAccessor:P.xAccessor||"x",yAccessor:P.yAccessor||"y",groupAccessor:P.lineBy||_,colorAccessor:_},O),{showAxes:!1,margin:O.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0}));case"LineChart":return Pe(Object.assign({chartType:"line",data:h,xAccessor:P.xAccessor||"x",yAccessor:P.yAccessor||"y",groupAccessor:P.lineBy||_,lineDataAccessor:P.lineDataAccessor,colorAccessor:_},O));case"AreaChart":return Pe(Object.assign({chartType:"area",data:h,xAccessor:P.xAccessor||"x",yAccessor:P.yAccessor||"y",groupAccessor:P.areaBy||_,colorAccessor:_},O));case"StackedAreaChart":return Pe(Object.assign({chartType:"stackedarea",data:h,xAccessor:P.xAccessor||"x",yAccessor:P.yAccessor||"y",groupAccessor:P.areaBy,colorAccessor:_||P.areaBy,normalize:P.normalize},O));case"Scatterplot":case"BubbleChart":return Pe(Object.assign({chartType:"scatter",data:h,xAccessor:P.xAccessor||"x",yAccessor:P.yAccessor||"y",colorAccessor:_,sizeAccessor:P.sizeBy,sizeRange:P.sizeRange||("BubbleChart"===t?[5,40]:void 0)},O));case"ConnectedScatterplot":return Pe(Object.assign({chartType:"scatter",data:h,xAccessor:P.xAccessor||"x",yAccessor:P.yAccessor||"y",colorAccessor:_},O));case"Heatmap":return Pe(Object.assign({chartType:"heatmap",data:h,xAccessor:P.xAccessor||"x",yAccessor:P.yAccessor||"y",valueAccessor:P.valueAccessor||"value",colorScheme:S||"blues"},O));case"BarChart":return De(Object.assign({chartType:"bar",data:h,oAccessor:P.categoryAccessor||"category",rAccessor:P.valueAccessor||"value",projection:"horizontal"===P.orientation?"horizontal":"vertical",colorAccessor:_,barPadding:P.barPadding},O));case"StackedBarChart":return De(Object.assign({chartType:"bar",data:h,oAccessor:P.categoryAccessor||"category",rAccessor:P.valueAccessor||"value",stackBy:P.stackBy,projection:"horizontal"===P.orientation?"horizontal":"vertical",colorAccessor:_||P.stackBy,normalize:P.normalize,barPadding:P.barPadding},O));case"GroupedBarChart":return De(Object.assign({chartType:"clusterbar",data:h,oAccessor:P.categoryAccessor||"category",rAccessor:P.valueAccessor||"value",groupBy:P.groupBy,projection:"horizontal"===P.orientation?"horizontal":"vertical",colorAccessor:_||P.groupBy,barPadding:P.barPadding},O));case"PieChart":return De(Object.assign({chartType:"pie",data:h,oAccessor:P.categoryAccessor||"category",rAccessor:P.valueAccessor||"value",projection:"radial",colorAccessor:_||P.categoryAccessor||"category"},O));case"DonutChart":return De(Object.assign({chartType:"donut",data:h,oAccessor:P.categoryAccessor||"category",rAccessor:P.valueAccessor||"value",projection:"radial",innerRadius:P.innerRadius||60,colorAccessor:_||P.categoryAccessor||"category"},O));case"Histogram":return De(Object.assign({chartType:"histogram",data:h,oAccessor:P.categoryAccessor||"category",rAccessor:P.valueAccessor||"value",bins:P.bins||25,projection:"horizontal"},O));case"BoxPlot":return De(Object.assign({chartType:"boxplot",data:h,oAccessor:P.categoryAccessor||"category",rAccessor:P.valueAccessor||"value",colorAccessor:_},O));case"ViolinPlot":return De(Object.assign({chartType:"violin",data:h,oAccessor:P.categoryAccessor||"category",rAccessor:P.valueAccessor||"value",colorAccessor:_,bins:P.bins},O));case"SwarmPlot":return De(Object.assign({chartType:"swarm",data:h,oAccessor:P.categoryAccessor||"category",rAccessor:P.valueAccessor||"value",colorAccessor:_},O));case"DotPlot":return De(Object.assign(Object.assign({chartType:"point",data:h,oAccessor:P.categoryAccessor||"category",rAccessor:P.valueAccessor||"value",colorAccessor:_},O),{showGrid:null==v||v}));case"SwimlaneChart":return De(Object.assign({chartType:"swimlane",data:h,oAccessor:P.categoryAccessor||"category",rAccessor:P.valueAccessor||"value",stackBy:P.subcategoryAccessor,projection:"vertical"===P.orientation?"vertical":"horizontal",colorAccessor:_||P.subcategoryAccessor,barPadding:P.barPadding},O));case"FunnelChart":{const t="vertical"===P.orientation;return De(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:t?"bar-funnel":"funnel",data:h,oAccessor:P.stepAccessor||"step",rAccessor:P.valueAccessor||"value"},P.categoryAccessor&&{stackBy:P.categoryAccessor}),{projection:t?"vertical":"horizontal",colorAccessor:_||P.categoryAccessor,barPadding:t?null!==(r=P.barPadding)&&void 0!==r?r:40:null!==(o=P.barPadding)&&void 0!==o?o:0}),!t&&{connectorAccessor:()=>!0,connectorStyle:{opacity:null!==(n=P.connectorOpacity)&&void 0!==n?n:.3}}),{showAxes:t,showCategoryTicks:t,showGrid:t,showLabels:P.showLabels}),O))}case"RidgelinePlot":return De(Object.assign({chartType:"ridgeline",data:h,oAccessor:P.categoryAccessor||"category",rAccessor:P.valueAccessor||"value",bins:P.bins,amplitude:P.amplitude},O));case"GaugeChart":{const t=null!==(a=P.min)&&void 0!==a?a:0,e=null!==(s=P.max)&&void 0!==s?s:100,i=null!==(c=P.sweep)&&void 0!==c?c:240,r=null!==(l=P.arcWidth)&&void 0!==l?l:.3,o=180+(360-i)/2,n=P.thresholds||[{value:e,color:"#4e79a7"}],h=n.map((e,i)=>({category:e.label||"zone-"+i,value:e.value-(i>0?n[i-1].value:t)})),p={};n.forEach((t,e)=>{p[t.label||"zone-"+e]=t.color||"#4e79a7"});const m=O.margin||{top:20,right:20,bottom:30,left:40},x=(d||300)-m.left-m.right,v=(g||300)-m.top-m.bottom,b=Math.min(x,v),k=Math.max(10,b/2*(1-r)),w=Math.max(t,Math.min(e,null!==(u=P.value)&&void 0!==u?u:t)),A=(o+(e===t?0:(w-t)/(e-t))*i-90)*Math.PI/180,S=b/2*.85,_=m.left+x/2,E=m.top+v/2,M=xe(y).colors.text,L=De(Object.assign(Object.assign({chartType:"donut",data:h,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:k,sweepAngle:i,startAngle:o,oSort:!1,pieceStyle:(t,e)=>({fill:p[e||""]||"#4e79a7"})},O),{showAxes:!1})),D=Se.renderToStaticMarkup(f.createElement(f.Fragment,null,f.createElement("line",{x1:_,y1:E,x2:_+S*Math.cos(A),y2:E+S*Math.sin(A),stroke:M,strokeWidth:2.5,strokeLinecap:"round"}),f.createElement("circle",{cx:_,cy:E,r:4,fill:M})));return L.replace("</svg>",D+"</svg>")}case"ForceDirectedGraph":return Le(Object.assign({chartType:"force",nodes:P.nodes,edges:P.edges,nodeIDAccessor:P.nodeIDAccessor,sourceAccessor:P.sourceAccessor,targetAccessor:P.targetAccessor,colorBy:_,colorScheme:S,iterations:P.iterations,forceStrength:P.forceStrength,showLabels:P.showLabels,nodeLabel:P.nodeLabel,nodeSize:P.nodeSize,nodeSizeRange:P.nodeSizeRange,nodeStyle:P.nodeStyle,edgeStyle:P.edgeStyle},O));case"SankeyDiagram":return Le(Object.assign({chartType:"sankey",nodes:P.nodes,edges:P.edges,nodeIDAccessor:P.nodeIdAccessor||P.nodeIDAccessor,sourceAccessor:P.sourceAccessor,targetAccessor:P.targetAccessor,valueAccessor:P.valueAccessor,orientation:P.orientation,nodeAlign:P.nodeAlign,nodeWidth:P.nodeWidth,nodePaddingRatio:P.nodePaddingRatio,showLabels:P.showLabels,nodeLabel:P.nodeLabel,colorBy:_,edgeColorBy:P.edgeColorBy,edgeOpacity:P.edgeOpacity,nodeStyle:P.nodeStyle,edgeStyle:P.edgeStyle,colorScheme:S},O));case"ChordDiagram":return Le(Object.assign({chartType:"chord",nodes:P.nodes,edges:P.edges,valueAccessor:P.valueAccessor,padAngle:P.padAngle,groupWidth:P.groupWidth,showLabels:P.showLabels,colorBy:_,edgeColorBy:P.edgeColorBy,colorScheme:S},O));case"TreeDiagram":return Le(Object.assign({chartType:"cluster"===P.layout?"cluster":"tree",data:h,childrenAccessor:P.childrenAccessor,colorBy:_,colorByDepth:P.colorByDepth,orientation:P.orientation,showLabels:P.showLabels,colorScheme:S},O));case"Treemap":return Le(Object.assign({chartType:"treemap",data:h,childrenAccessor:P.childrenAccessor,hierarchySum:P.valueAccessor,colorBy:_,colorByDepth:P.colorByDepth,showLabels:P.showLabels,colorScheme:S},O));case"CirclePack":return Le(Object.assign({chartType:"circlepack",data:h,childrenAccessor:P.childrenAccessor,hierarchySum:P.valueAccessor,colorBy:_,colorByDepth:P.colorByDepth,colorScheme:S},O));case"ChoroplethMap":return ze(Object.assign({areas:P.areas,projection:P.projection||"equalEarth",areaStyle:P.areaStyle,graticule:P.graticule,fitPadding:P.fitPadding},O));case"ProportionalSymbolMap":return ze(Object.assign({points:P.points,areas:P.areas,xAccessor:P.xAccessor||"lon",yAccessor:P.yAccessor||"lat",pointStyle:P.pointStyle,projection:P.projection||"equalEarth",graticule:P.graticule,fitPadding:P.fitPadding},O));default:throw Error(`Unknown chart component: "${t}". See CLAUDE.md for supported chart types.`)}}const Ne=require("react-dom/server");function $e(t,e,i,r={}){const{stepSize:o,windowSize:n,frameCount:a,xExtent:s,yExtent:c,transitionFrames:l=4,fps:u=12,easing:h="ease-out",decay:f}=r,d=i.width||600,g=i.height||400,y=xe(i.theme),p=Object.assign(Object.assign(Object.assign({},i),s&&{xExtent:s}),c&&{yExtent:c});if(!e||0===e.length)return[];const m=o||Math.max(1,Math.ceil(e.length/(a||Math.min(60,Math.max(10,e.length))))),x=[];for(let t=m;e.length>=t;t+=m)x.push(t);x[x.length-1]!==e.length&&x.push(e.length);const v=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(t),b=Object.assign({top:20,right:20,bottom:30,left:40},i.margin),k=d-b.left-b.right,w=g-b.top-b.bottom,A=[];if(v)for(let r=0;x.length>r;r++){const o=x[r],a=e.slice(n?Math.max(0,o-n):0,o),s=Object.assign({chartType:t,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:i.projection||"vertical",oAccessor:i.oAccessor||i.categoryAccessor||"category",rAccessor:i.rAccessor||i.valueAccessor||"value",colorAccessor:i.colorAccessor||i.colorBy,stackBy:i.stackBy,groupBy:i.groupBy,barPadding:i.barPadding,innerRadius:i.innerRadius,normalize:i.normalize,bins:i.bins,colorScheme:i.colorScheme||y.colors.categorical},f&&{decay:f}),c=new Qt(s);c.ingest({inserts:a,bounded:!0}),c.computeScene({width:k,height:w}),c.scene.length>0&&A.push(Re(c.scene,d,g,y,p))}else for(let r=0;x.length>r;r++){const o=x[r],a=e.slice(n?Math.max(0,o-n):0,o),m=Object.assign(Object.assign({chartType:t,windowSize:a.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:s,yExtent:c,colorScheme:i.colorScheme||y.colors.categorical,lineStyle:i.lineStyle,pointStyle:i.pointStyle,areaStyle:i.areaStyle,sizeAccessor:i.sizeAccessor||i.sizeBy,sizeRange:i.sizeRange},f&&{decay:f}),l>0&&{transition:{duration:l*(1e3/u),easing:h}}),v=new W(m);if(v.ingest({inserts:a,bounded:!0}),v.computeScene({width:k,height:w}),0===v.scene.length)continue;const b=v.scales?{y:v.scales.y}:void 0;if(A.push(We(v.scene,d,g,y,p,b)),l>0&&r>0&&v.activeTransition){const t=l*(1e3/u);for(let e=1;l>=e;e++)v.advanceTransition(v.activeTransition.startTime+e/l*t),A.push(We(v.scene,d,g,y,p,b))}}return A}function Be(t,e){const i=t.background||e.colors.background;return i&&"transparent"!==i?i:null}function We(t,e,i,r,o,n){const a=ve(r),s=Object.assign({top:20,right:20,bottom:30,left:40},o.margin),c=e-s.left-s.right,l=i-s.top-s.bottom,u=Be(o,r),h=t.map((t,e)=>fe(t,e)).filter(Boolean),d=function(t,e,i,r,o,n){var a;if(!t||0===t.length)return null;const s=ve(r),c=[];for(let r=0;t.length>r;r++){const l=t[r];if("y-threshold"===l.type&&null!=l.value){let t=null;if(n)t=n(l.value);else if(o){const[e,r]=o,n=r-e;if(0===n)continue;t=i-(l.value-e)/n*i}if(null==t)continue;const u=l.color||s.primary,h=null!==(a=l.strokeWidth)&&void 0!==a?a:1.5,d=l.labelPosition||"right";c.push(f.createElement("g",{key:"ann-"+r},f.createElement("line",{x1:0,y1:t,x2:e,y2:t,stroke:u,strokeWidth:h,strokeDasharray:l.strokeDasharray||"6,4"}),l.label&&f.createElement("text",{x:"left"===d?4:"center"===d?e/2:e-4,y:t-5,textAnchor:"left"===d?"start":"center"===d?"middle":"end",fontSize:s.tickSize,fill:u,fontFamily:s.fontFamily},l.label)))}}return c.length>0?f.createElement(f.Fragment,null,c):null}(o.annotations,c,l,r,o.yExtent,null==n?void 0:n.y),g="string"==typeof o.title?o.title:void 0,y="string"==typeof o.description?o.description:void 0,p=g?"semiotic-title":void 0,m=y?"semiotic-desc":void 0,x=[p,m].filter(Boolean).join(" ")||void 0,v=f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:i,role:"img","aria-labelledby":x,style:{fontFamily:a.fontFamily}},g&&f.createElement("title",{id:p},g),y&&f.createElement("desc",{id:m},y),u&&f.createElement("rect",{x:0,y:0,width:e,height:i,fill:u}),f.createElement("g",{transform:`translate(${s.left},${s.top})`},d,h),g&&f.createElement("text",{x:e/2,y:16,textAnchor:"middle",fontSize:a.titleSize,fontWeight:"bold",fill:a.text,fontFamily:a.fontFamily},g));return Ne.renderToStaticMarkup(v)}function Re(t,e,i,r,o){const n=ve(r),a=Object.assign({top:20,right:20,bottom:30,left:40},o.margin),s="radial"===o.projection,c=s?a.left+(e-a.left-a.right)/2:a.left,l=s?a.top+(i-a.top-a.bottom)/2:a.top,u=Be(o,r),h=t.map((t,e)=>de(t,e)).filter(Boolean),d="string"==typeof o.title?o.title:void 0,g="string"==typeof o.description?o.description:void 0,y=d?"semiotic-title":void 0,p=g?"semiotic-desc":void 0,m=[y,p].filter(Boolean).join(" ")||void 0,x=f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:i,role:"img","aria-labelledby":m,style:{fontFamily:n.fontFamily}},d&&f.createElement("title",{id:y},d),g&&f.createElement("desc",{id:p},g),u&&f.createElement("rect",{x:0,y:0,width:e,height:i,fill:u}),f.createElement("g",{transform:`translate(${c},${l})`},h),d&&f.createElement("text",{x:e/2,y:16,textAnchor:"middle",fontSize:n.titleSize,fontWeight:"bold",fill:n.text,fontFamily:n.fontFamily},d));return Ne.renderToStaticMarkup(x)}exports.generateFrameSVGs=$e,exports.generateFrameSequence=function(t,e,i={}){return e.map(e=>{try{return Te(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>`}})},exports.renderChart=Te,exports.renderDashboard=function(t,e={}){var i;const{title:r,subtitle:o,theme:n,width:a=1200,height:s,layout:c={},background:l}=e,u=ve(xe(n)),h=c.columns||2,d=null!==(i=c.gap)&&void 0!==i?i:16;let g=0;r&&(g+=30),o&&(g+=20),g>0&&(g+=10);const y=Math.floor((a-d-d*(h-1))/h),p=[];let m=0,x=g+d,v=0;for(const e of t){const t=Math.min(e.colSpan||1,h),i=e.props.height||300;m+t>h&&(x+=v+d,m=0,v=0),p.push({chart:e,x:d/2+m*(y+d),y:x,w:y*t+d*(t-1),h:i}),v=Math.max(v,i),m+=t}const b=s||x+v+d,k=p.map((t,e)=>{const{chart:i,x:r,y:o,w:a,h:s}=t,c=Object.assign(Object.assign({},i.props),{width:a,height:s,theme:n,_idPrefix:"chart-"+e});let l;return l=i.component?Te(i.component,c):i.frameType?je(i.frameType,c):`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${s}"></svg>`,f.createElement("g",{key:"dashboard-chart-"+e,transform:`translate(${r},${o})`},f.createElement("foreignObject",{width:a,height:s},f.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:l}})))}),w=f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:a,height:b,role:"img","aria-label":r||"Dashboard",style:{fontFamily:u.fontFamily}},r&&f.createElement("title",null,r),l&&f.createElement("rect",{x:0,y:0,width:a,height:b,fill:l}),r&&f.createElement("text",{x:a/2,y:24,textAnchor:"middle",fontSize:u.titleSize+4,fontWeight:"bold",fill:u.text,fontFamily:u.fontFamily},r),o&&f.createElement("text",{x:a/2,y:r?46:20,textAnchor:"middle",fontSize:u.labelSize,fill:u.textSecondary,fontFamily:u.fontFamily},o),k);return Se.renderToStaticMarkup(w)},exports.renderGeoToStaticSVG=function(t){return ze(t)},exports.renderNetworkToStaticSVG=function(t){return Le(t)},exports.renderOrdinalToStaticSVG=function(t){return De(t)},exports.renderToAnimatedGif=function(t,e,i){return d(this,arguments,void 0,function*(t,e,i,r={}){const{fps:o=12,loop:n=!0,scale:a=1,background:s}=r,c=i.height||400,l=Math.round((i.width||600)*a),u=Math.round(c*a),h=$e(t,e,s?Object.assign(Object.assign({},i),{background:s}):i,r);if(0===h.length)throw Error("No frames generated — check that data is not empty");let f,d,g,y;try{f=require("sharp")}catch(t){throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t=require("gifenc");d=t.GIFEncoder,g=t.quantize,y=t.applyPalette}catch(t){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc')}const p=Math.round(1e3/o),m=d();for(let t=0;h.length>t;t++){const e=h[t],i=yield f(Buffer.from(e),{density:72*a}).resize(l,u).ensureAlpha().raw().toBuffer(),r=new Uint8Array(i),o=g(r,256),s=y(r,o);m.writeFrame(s,l,u,{palette:o,delay:p,repeat:n?0:-1})}return m.finish(),Buffer.from(m.bytes())})},exports.renderToImage=function(t,e){return d(this,arguments,void 0,function*(t,e,i={}){var r,o;const{format:n="png",scale:a=1,background:s}=i;let c,l;c=["xy","ordinal","network","geo"].includes(t)?je(t,e):Te(t,e),s&&(c=c.replace(/<svg /,`<svg style="background:${s}" `));try{l=require("sharp")}catch(t){throw Error('Image export requires the "sharp" package and a Node.js runtime. Install it:\n npm install sharp\nsharp is listed as an optional dependency of semiotic.')}const u=e.width||(null===(r=e.size)||void 0===r?void 0:r[0])||600,h=e.height||(null===(o=e.size)||void 0===o?void 0:o[1])||400,f=l(void 0!==globalThis.Buffer?globalThis.Buffer.from(c):(new TextEncoder).encode(c),{density:72*a}).resize(Math.round(u*a),Math.round(h*a));return"jpeg"===n?f.jpeg({quality:90}).toBuffer():f.png().toBuffer()})},exports.renderToStaticSVG=je,exports.renderXYToStaticSVG=function(t){return Pe(t)},exports.resolveTheme=xe,exports.themeStyles=ve;